repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
reznikmm/gela
Ada
3,110
ads
------------------------------------------------------------------------------ -- G E L A G R A M M A R S -- -- Library for dealing with grammars for Gela project, -- -- a portable Ada compiler -- -- http://gela.ada-ru.org/ -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license in gela.ads file -- ------------------------------------------------------------------------------ with League.Strings; with Anagram.Grammars.Ordered; with Anagram.Grammars.Rule_Templates; package AG_Tools.Visit_Generators is type Generator is limited interface; type Generator_Access is access all Generator'Class; not overriding procedure Make_Local_Variable (Self : access Generator; Origin : League.Strings.Universal_String; Attribute : Anagram.Grammars.Attribute_Declaration) is abstract; -- Generate local variable to store value of given Attribute not overriding procedure Make_Get (Self : access Generator; Attribute : Anagram.Grammars.Attribute; Template : Anagram.Grammars.Rule_Templates.Rule_Template) is abstract; -- Generate code to get/fetch value of given Attribute not overriding procedure Make_Set (Self : access Generator; Attribute : Anagram.Grammars.Attribute) is abstract; -- Generate code to set/update value in given Attribute type Part_Generator is limited interface and Generator; type Part_Generator_Access is access all Part_Generator'Class; not overriding procedure Make_Descent (Self : access Part_Generator; Part : Anagram.Grammars.Part_Index; Pass : Positive) is abstract; -- Generate code to go deeper in the tree not overriding procedure Make_Local_Variable (Self : access Part_Generator; Part : Anagram.Grammars.Part_Index) is abstract; -- Generate local variable to store value of given Attribute type NT_Generator is limited interface and Generator; type NT_Generator_Access is access all NT_Generator'Class; not overriding procedure Make_Procedure (Self : access NT_Generator; Order : Anagram.Grammars.Ordered.Order_Maps.Map; NT : Anagram.Grammars.Non_Terminal; Pass : Positive) is abstract; -- Generate procedure type Factory is limited interface; type Factory_Access is access all Factory'Class; not overriding function Get (Self : access Factory; NT : Anagram.Grammars.Non_Terminal) return NT_Generator_Access is abstract; not overriding function Get (Self : access Factory; Part : Anagram.Grammars.Part) return Part_Generator_Access is abstract; not overriding function Get (Self : access Factory; Attr : Anagram.Grammars.Attribute; NT : Anagram.Grammars.Non_Terminal) return AG_Tools.Visit_Generators.Generator_Access is abstract; end AG_Tools.Visit_Generators;
AdaCore/training_material
Ada
258
adb
package body Swap_Generics is procedure Swap_Generic (Value_1 : in out Data_Type; Value_2 : in out Data_Type) is Tmp : Data_Type; begin Tmp := Value_1; Value_1 := Value_2; Value_2 := Tmp; end Swap_Generic; end Swap_Generics;
reznikmm/matreshka
Ada
4,596
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. ------------------------------------------------------------------------------ -- A signal event represents the receipt of an asynchronous signal instance. -- A signal event may, for example, cause a state machine to trigger a -- transition. ------------------------------------------------------------------------------ with AMF.UML.Message_Events; limited with AMF.UML.Signals; package AMF.UML.Signal_Events is pragma Preelaborate; type UML_Signal_Event is limited interface and AMF.UML.Message_Events.UML_Message_Event; type UML_Signal_Event_Access is access all UML_Signal_Event'Class; for UML_Signal_Event_Access'Storage_Size use 0; not overriding function Get_Signal (Self : not null access constant UML_Signal_Event) return AMF.UML.Signals.UML_Signal_Access is abstract; -- Getter of SignalEvent::signal. -- -- The specific signal that is associated with this event. not overriding procedure Set_Signal (Self : not null access UML_Signal_Event; To : AMF.UML.Signals.UML_Signal_Access) is abstract; -- Setter of SignalEvent::signal. -- -- The specific signal that is associated with this event. end AMF.UML.Signal_Events;
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.Presentation_Sound_Elements is pragma Preelaborate; type ODF_Presentation_Sound is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Presentation_Sound_Access is access all ODF_Presentation_Sound'Class with Storage_Size => 0; end ODF.DOM.Presentation_Sound_Elements;
burratoo/Acton
Ada
1,193
ads
------------------------------------------------------------------------------------------ -- -- -- OAK COMPONENTS -- -- -- -- OAK.OAK_TIME.CONVERSION -- -- -- -- Copyright (C) 2012-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with Ada.Real_Time; with Ada.Unchecked_Conversion; package Oak.Oak_Time.Conversion is function To_Oak_Time is new Ada.Unchecked_Conversion (Ada.Real_Time.Time, Oak.Oak_Time.Time); function To_Oak_Time_Span is new Ada.Unchecked_Conversion (Ada.Real_Time.Time_Span, Oak.Oak_Time.Time_Span); end Oak.Oak_Time.Conversion;
stcarrez/dynamo
Ada
8,641
adb
----------------------------------------------------------------------- -- gen-commands-plugins -- Plugin creation and management commands for dynamo -- Copyright (C) 2012, 2015, 2017, 2018, 2019, 2021, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Ada.Text_IO; with Gen.Artifacts; with Gen.Model.Projects; with GNAT.Command_Line; with Util.Files; with Util.Log.Loggers; with Util.Strings.Transforms; package body Gen.Commands.Plugins is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Gen.Commands.Project"); -- ------------------------------ -- Generator Command -- ------------------------------ -- 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; function Get_Directory_Name (Name : in String; Name_Dir : in UString) return String; function Get_Directory_Name (Name : in String; Name_Dir : in UString) return String is begin if Ada.Strings.Unbounded.Length (Name_Dir) = 0 then return Name; else return To_String (Name_Dir); end if; end Get_Directory_Name; Result_Dir : constant String := Generator.Get_Result_Directory; Name_Dir : UString; 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: d:") is when ASCII.NUL => exit; when 'd' => Name_Dir := To_UString (Parameter); 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; declare Name : constant String := Get_Argument; Kind : constant String := Get_Argument; Dir : constant String := Generator.Get_Plugin_Directory; Plugin_Dir : constant String := Get_Directory_Name (Name, Name_Dir); Path : constant String := Util.Files.Compose (Dir, Plugin_Dir); begin if Name'Length = 0 then Generator.Error ("Missing plugin name"); Cmd.Usage (Name, Generator); return; end if; if Kind /= "ada" and then Kind /= "web" then Generator.Error ("Invalid plugin type (must be 'ada' or 'web')"); return; end if; if Ada.Directories.Exists (Path) then Generator.Error ("Plugin {0} exists already", Name); return; end if; if not Ada.Directories.Exists (Dir) then Ada.Directories.Create_Directory (Dir); end if; Ada.Directories.Create_Directory (Path); Generator.Set_Result_Directory (Path); -- Create the plugin project instance and generate its dynamo.xml file. -- The new plugin is added to the current project so that it will be referenced. declare procedure Create_Plugin (Project : in out Model.Projects.Root_Project_Definition); procedure Create_Plugin (Project : in out Model.Projects.Root_Project_Definition) is Plugin : Gen.Model.Projects.Project_Definition_Access; File : constant String := Util.Files.Compose (Path, "dynamo.xml"); begin Project.Create_Project (Name => Name, Path => File, Project => Plugin); Project.Add_Module (Plugin); Plugin.Props.Set ("license", Project.Props.Get ("license", "none")); Plugin.Props.Set ("author", Project.Props.Get ("author", "")); Plugin.Props.Set ("author_email", Project.Props.Get ("author_email", "")); Plugin.Save (File); end Create_Plugin; begin Generator.Update_Project (Create_Plugin'Access); end; -- Generate the new plugin content. Generator.Set_Force_Save (False); Generator.Set_Global ("pluginName", Name); Generator.Set_Global ("pluginDir", Plugin_Dir); Gen.Generator.Generate_All (Generator, Gen.Artifacts.ITERATION_TABLE, "create-plugin-" & Kind); -- And save the project dynamo.xml file which now refers to the new plugin. Generator.Set_Result_Directory (Result_Dir); Generator.Save_Project; exception when Ada.Directories.Name_Error | Ada.Directories.Use_Error => Generator.Error ("Cannot create directory {0}", Path); 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-plugin: Create a new plugin for the current project"); Put_Line ("Usage: create-plugin [-l apache|gpl|gpl3|mit|bsd3|proprietary] " & "[-d DIR] NAME [ada | web]"); New_Line; Put_Line (" Creates a new AWA plugin for the application with the name passed in NAME."); Put_Line (" The plugin license is controlled by the -l option."); Put_Line (" The plugin type is specified as the last argument which can be one of:"); New_Line; Put_Line (" ada the plugin contains Ada code and a GNAT project is created"); Put_Line (" web the plugin contains XHTML, CSS, Javascript files only"); New_Line; Put_Line (" The -d option allows to control the plugin directory name. The plugin NAME"); Put_Line (" is used by default. The plugin is created in the directory:"); Put_Line (" plugins/NAME or plugins/DIR"); New_Line; Put_Line (" For the Ada plugin, the command generates the following files" & " in the plugin directory:"); Put_Line (" src/<project>-<plugin>.ads"); Put_Line (" src/<project>-<plugin>-<module>.ads"); Put_Line (" src/<project>-<plugin>-<module>.adb"); end Help; end Gen.Commands.Plugins;
michalkonecny/polypaver
Ada
1,316
ads
--# inherit PolyPaver.Exact; package PolyPaver.Long_Floats is --# function Is_Range(Variable : Long_Float; Min : Long_Float; Max : Long_Float) return Boolean; function Eps_Abs return Long_Float; function Eps_Rel return Long_Float; --# function Plus_Minus_Eps_Abs return Long_Float; --# function Plus_Minus_Eps_Rel return Long_Float; function Pi return Long_Float; function Add (X,Y : Long_Float) return Long_Float; --# pre Add(X,Y) in Long_Float; function Subtract (X,Y : Long_Float) return Long_Float; --# pre Subtract(X,Y) in Long_Float; function Multiply (X,Y : Long_Float) return Long_Float; --# pre Multiply(X,Y) in Long_Float; function Divide (X,Y : Long_Float) return Long_Float; --# pre Y /= 0.0 and --# Divide(X,Y) in Long_Float; function Square (X : Long_Float) return Long_Float; --# pre Square(X) in Long_Float; function Sqrt (X : Long_Float) return Long_Float; --# pre X >= 0.0 and --# Sqrt(X) in Long_Float; function Exp (X : Long_Float) return Long_Float; --# pre Exp(X) in Long_Float; function Sin (X : Long_Float) return Long_Float; --# pre Sin(X) in Long_Float; function Cos (X : Long_Float) return Long_Float; --# pre Cos(X) in Long_Float; end PolyPaver.Long_Floats;
reznikmm/matreshka
Ada
5,223
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Qt4.Settings.Constructors; with Qt4.Strings; with Qt4.Variants; with Main_Windows.Moc; package body Main_Windows is function "+" (Item : String) return Qt4.Strings.Q_String renames Qt4.Strings.From_Utf_8; ----------------- -- Close_Event -- ----------------- overriding procedure Close_Event (Self : not null access Main_Window; Event : not null access Qt4.Close_Events.Q_Close_Event'Class) is Settings : constant not null Qt4.Settings.Q_Settings_Access := Qt4.Settings.Constructors.Create; begin Settings.Begin_Group (+"MainWindow"); Settings.Set_Value (+"size", Qt4.Variants.Create (Self.Size)); Settings.End_Group; Settings.Sync; Settings.Delete_Later; end Close_Event; ------------------ -- Constructors -- ------------------ package body Constructors is procedure Initialize (Self : not null access Main_Window'Class); ------------ -- Create -- ------------ function Create return not null Main_Window_Access is begin return Self : constant not null Main_Window_Access := new Main_Window do Initialize (Self); end return; end Create; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : not null access Main_Window'Class) is Settings : constant not null Qt4.Settings.Q_Settings_Access := Qt4.Settings.Constructors.Create; begin Qt4.Main_Windows.Directors.Constructors.Initialize (Self); Settings.Begin_Group (+"MainWindow"); if Settings.Contains (+"size") then Self.Resize (Settings.Value (+"size").To_Size); end if; Settings.End_Group; Settings.Delete_Later; end Initialize; end Constructors; end Main_Windows;
reznikmm/matreshka
Ada
3,739
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Form_Navigation_Mode_Attributes is pragma Preelaborate; type ODF_Form_Navigation_Mode_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Navigation_Mode_Attribute_Access is access all ODF_Form_Navigation_Mode_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Navigation_Mode_Attributes;
Rodeo-McCabe/orka
Ada
1,987
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 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 Orka.SIMD.AVX.Doubles.Arithmetic; with Orka.SIMD.AVX2.Doubles.Swizzle; package body Orka.SIMD.FMA.Doubles.Arithmetic is function "*" (Left, Right : m256d_Array) return m256d_Array is Result : m256d_Array; begin for I in Index_Homogeneous'Range loop Result (I) := Left * Right (I); end loop; return Result; end "*"; function "*" (Left : m256d_Array; Right : m256d) return m256d is use SIMD.AVX.Doubles.Arithmetic; use SIMD.AVX2.Doubles.Swizzle; Mask_0_0_0_0 : constant Unsigned_32 := 0 or 0 * 4 or 0 * 16 or 0 * 64; Mask_1_1_1_1 : constant Unsigned_32 := 1 or 1 * 4 or 1 * 16 or 1 * 64; Mask_2_2_2_2 : constant Unsigned_32 := 2 or 2 * 4 or 2 * 16 or 2 * 64; Mask_3_3_3_3 : constant Unsigned_32 := 3 or 3 * 4 or 3 * 16 or 3 * 64; XXXX, YYYY, ZZZZ, WWWW, Result : m256d; begin XXXX := Permute (Right, Mask_0_0_0_0); YYYY := Permute (Right, Mask_1_1_1_1); ZZZZ := Permute (Right, Mask_2_2_2_2); WWWW := Permute (Right, Mask_3_3_3_3); Result := XXXX * Left (X); Result := Multiply_Add (YYYY, Left (Y), Result); Result := Multiply_Add (ZZZZ, Left (Z), Result); Result := Multiply_Add (WWWW, Left (W), Result); return Result; end "*"; end Orka.SIMD.FMA.Doubles.Arithmetic;
reznikmm/matreshka
Ada
1,008
ads
with League.Stream_Element_Vectors; package Styx.Messages.Reads is type Read_Request is new Request with record FID : Styx.Messages.FID; Offset : Interfaces.Unsigned_64; Count : Size; end record; procedure Visit (Visiter : in out Styx.Request_Visiters.Request_Visiter'Class; Value : Read_Request); type Read_Request_Access is access all Read_Request; type Read_Reply is new Reply with record Data : League.Stream_Element_Vectors.Stream_Element_Vector; end record; procedure Visit (Visiter : in out Styx.Reply_Visiters.Reply_Visiter'Class; Value : Read_Reply); type Directory_Entry_Array is array (Positive range <>) of Directory_Entry; type Read_Directory_Reply (Count : Natural) is new Reply with record Data : Directory_Entry_Array (1 .. Count); end record; procedure Visit (Visiter : in out Styx.Reply_Visiters.Reply_Visiter'Class; Value : Read_Directory_Reply); end Styx.Messages.Reads;
Componolit/libsparkcrypto
Ada
1,993
ads
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2018, Componolit GmbH -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the nor the names of its contributors may be used -- to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with AUnit.Test_Suites; package LSC_Internal_Suite is function Suite return AUnit.Test_Suites.Access_Test_Suite; end LSC_Internal_Suite;
reznikmm/matreshka
Ada
4,310
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$ ------------------------------------------------------------------------------ private with Ada.Finalization; private with AMF.Internals.Collections.Strings; package AMF.String_Collections is pragma Preelaborate; type Collection_Of_String is tagged private; type Set_Of_String is new Collection_Of_String with private; type Ordered_Set_Of_String is new Collection_Of_String with private; type Bag_Of_String is new Collection_Of_String with private; type Sequence_Of_String is new Collection_Of_String with private; private type Collection_Of_String is new Ada.Finalization.Controlled with record Collection : AMF.Internals.Collections.Strings.Shared_String_Collection_Access; end record; type Set_Of_String is new Collection_Of_String with null record; type Ordered_Set_Of_String is new Collection_Of_String with null record; type Bag_Of_String is new Collection_Of_String with null record; type Sequence_Of_String is new Collection_Of_String with null record; end AMF.String_Collections;
jscparker/math_packages
Ada
3,235
adb
with Runge_8th; with Text_IO; use Text_IO; with Quadrature; with Ada.Numerics.Generic_Elementary_Functions; procedure runge_8th_order_demo_3 is type Real is digits 15; package mth is new Ada.Numerics.Generic_Elementary_Functions(Real); use mth; -- for Sin package quadr is new Quadrature (Real, Sin); use quadr; package Area_Under_the_Curve is new Runge_8th (Real, Dyn_Index, Dynamical_Variable, F, "*", "+", "-", Norm); use Area_Under_the_Curve; package rio is new Float_IO(Real); use rio; package iio is new Integer_IO(Step_Integer); use iio; Initial_Condition : Dynamical_Variable; Previous_Y, Final_Y : Dynamical_Variable; Final_Time, Starting_Time : Real; Previous_t, Final_t : Real; Delta_t : Real; Steps : Step_Integer; Error_Tolerance : Real := 1.0E-10; Error_Control_Desired : Boolean := False; Answer : Character := 'n'; begin -- choose initial conditions new_line; put ("The test integrates (d/dt) Y(t) = Sin(t) for Y(t)."); new_line(2); put ("Ordinary quadrature is just an area-under-the-curve problem, "); new_line; put ("where you solve: (d/dt) Y(t) = Sin(t) for Y."); new_line(2); put ("Input number of steps (try 16 with and without error control)"); new_line; get (Steps); new_line; put ("Every time the integration advances this number of steps, ERROR is printed."); new_line; new_line; put ("Use error control? Enter y or n:"); new_line; get (Answer); if (Answer = 'Y') or (Answer = 'y') then Error_Control_Desired := True; put ("Error control it is."); new_line; else Error_Control_Desired := False; put ("OK, no error control."); new_line; end if; Initial_Condition(0) := -1.0; Starting_Time := 0.0; Final_Time := 32.0; Previous_Y := Initial_Condition; Previous_t := Starting_Time; Delta_t := Final_Time - Starting_Time; for i in 1..20 loop Final_t := Previous_t + Delta_t; Integrate (Final_State => Final_Y, -- the result (output). Final_Time => Final_t, -- end integration here. Initial_State => Previous_Y, -- the initial condition (input). Initial_Time => Previous_t, -- start integrating here. No_Of_Steps => Steps, -- if no err control, uses this. Error_Control_Desired => Error_Control_Desired, Error_Tolerance => Error_Tolerance); Previous_Y := Final_Y; Previous_t := Final_t; new_line; put ("Time = t ="); put (Final_t, Aft => 7); put (", Error = (Cos (t) - Integrated Cos) = "); put (Abs (-Cos(Final_t) - Final_Y(0)), Aft => 7); end loop; if (Answer = 'Y') or (Answer = 'y') then new_line(2); put ("With error control enabled, program attempted to reduce"); new_line; put ("error *per step* to (well) under: "); put (Error_Tolerance, Aft => 6); new_line; put ("Over thousands of steps, accumulated error will be much larger than that."); new_line(2); end if; end;
AdaCore/training_material
Ada
163
adb
select accept Receive_Message (V : String) do Put_Line ("T: Receive " & V); end Receive_Message; else Put_Line ("T: Nothing received"); end select;
Rodeo-McCabe/orka
Ada
7,873
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Low_Level; with GL.Rasterization; with GL.Types.Colors; package GL.Buffers is pragma Preelaborate; use GL.Types; type Buffer_Bits is record Depth : Boolean := False; Stencil : Boolean := False; Color : Boolean := False; end record; subtype Depth is Single range 0.0 .. 1.0; subtype Stencil_Index is Int; type Stencil_Action is (Zero, Invert, Keep, Replace, Increment, Decrement, Increment_Wrap, Decrement_Wrap); type Color_Buffer_Selector is (None, Front_Left, Front_Right, Back_Left, Back_Right, Front, Back, Left, Right, Front_And_Back, Color_Attachment0, Color_Attachment1, Color_Attachment2, Color_Attachment3, Color_Attachment4, Color_Attachment5, Color_Attachment6, Color_Attachment7, Color_Attachment8, Color_Attachment9, Color_Attachment10, Color_Attachment11, Color_Attachment12, Color_Attachment13, Color_Attachment14, Color_Attachment15); -- Defined here because of following subtype declaration for Color_Buffer_Selector use (None => 0, Front_Left => 16#0400#, Front_Right => 16#0401#, Back_Left => 16#0402#, Back_Right => 16#0403#, Front => 16#0404#, Back => 16#0405#, Left => 16#0406#, Right => 16#0407#, Front_And_Back => 16#0408#, Color_Attachment0 => 16#8CE0#, Color_Attachment1 => 16#8CE1#, Color_Attachment2 => 16#8CE2#, Color_Attachment3 => 16#8CE3#, Color_Attachment4 => 16#8CE4#, Color_Attachment5 => 16#8CE5#, Color_Attachment6 => 16#8CE6#, Color_Attachment7 => 16#8CE7#, Color_Attachment8 => 16#8CE8#, Color_Attachment9 => 16#8CE9#, Color_Attachment10 => 16#8CEA#, Color_Attachment11 => 16#8CEB#, Color_Attachment12 => 16#8CEC#, Color_Attachment13 => 16#8CED#, Color_Attachment14 => 16#8CEE#, Color_Attachment15 => 16#8CEF#); for Color_Buffer_Selector'Size use Low_Level.Enum'Size; subtype Draw_Buffer_Index is UInt range 0 .. 15; type Color_Buffer_List is array (Draw_Buffer_Index range <>) of Color_Buffer_Selector; subtype Default_Color_Buffer_Selector is Color_Buffer_Selector range Front_Left .. Back_Right; -- Table 17.4 of the OpenGL specification subtype Explicit_Color_Buffer_Selector is Color_Buffer_Selector range Color_Attachment0 .. Color_Attachment15; -- Table 17.5 of the OpenGL specification subtype Single_Face_Selector is Rasterization.Face_Selector range Rasterization.Front .. Rasterization.Back; ----------------------------------------------------------------------------- -- Depth -- ----------------------------------------------------------------------------- procedure Set_Depth_Function (Func : Compare_Function); function Depth_Function return Compare_Function; procedure Set_Depth_Mask (Enabled : Boolean); function Depth_Mask return Boolean; ----------------------------------------------------------------------------- -- Color -- ----------------------------------------------------------------------------- procedure Set_Color_Mask (Value : Colors.Enabled_Color); -- Set the color mask for all draw buffers procedure Set_Color_Mask (Index : Draw_Buffer_Index; Value : Colors.Enabled_Color); -- Set the color mask for a particular draw buffer function Color_Mask (Index : Draw_Buffer_Index) return Colors.Enabled_Color; -- Return the color mask of a particular draw buffer ----------------------------------------------------------------------------- -- Stencil -- ----------------------------------------------------------------------------- procedure Set_Stencil_Function (Face : Rasterization.Face_Selector; Func : Compare_Function; Ref : Int; Mask : UInt); function Stencil_Function (Face : Single_Face_Selector) return Compare_Function; function Stencil_Reference_Value (Face : Single_Face_Selector) return Int; function Stencil_Value_Mask (Face : Single_Face_Selector) return UInt; procedure Set_Stencil_Operation (Face : Rasterization.Face_Selector; Stencil_Fail : Buffers.Stencil_Action; Depth_Fail : Buffers.Stencil_Action; Depth_Pass : Buffers.Stencil_Action); function Stencil_Operation_Stencil_Fail (Face : Single_Face_Selector) return Buffers.Stencil_Action; function Stencil_Operation_Depth_Fail (Face : Single_Face_Selector) return Buffers.Stencil_Action; function Stencil_Operation_Depth_Pass (Face : Single_Face_Selector) return Buffers.Stencil_Action; procedure Set_Stencil_Mask (Value : UInt); procedure Set_Stencil_Mask (Face : Rasterization.Face_Selector; Value : UInt); function Stencil_Mask (Face : Single_Face_Selector) return UInt; private for Buffer_Bits use record Depth at 0 range 8 .. 8; Stencil at 0 range 10 .. 10; Color at 0 range 14 .. 14; end record; for Buffer_Bits'Size use Low_Level.Bitfield'Size; for Stencil_Action use (Zero => 0, Invert => 16#150A#, Keep => 16#1E00#, Replace => 16#1E01#, Increment => 16#1E02#, Decrement => 16#1E03#, Increment_Wrap => 16#8507#, Decrement_Wrap => 16#8508#); for Stencil_Action'Size use Low_Level.Enum'Size; pragma Convention (C, Color_Buffer_List); end GL.Buffers;
reznikmm/matreshka
Ada
3,754
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Draw_Caption_Angle_Type_Attributes is pragma Preelaborate; type ODF_Draw_Caption_Angle_Type_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Caption_Angle_Type_Attribute_Access is access all ODF_Draw_Caption_Angle_Type_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Caption_Angle_Type_Attributes;
zhmu/ananas
Ada
36,509
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ S P A R K -- -- -- -- 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. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Checks; use Checks; with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Exp_Attr; with Exp_Ch3; with Exp_Ch4; with Exp_Ch5; use Exp_Ch5; with Exp_Dbug; use Exp_Dbug; with Exp_Util; use Exp_Util; with Ghost; use Ghost; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Restrict; use Restrict; with Rident; use Rident; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Ch7; use Sem_Ch7; with Sem_Ch8; use Sem_Ch8; with Sem_Prag; use Sem_Prag; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; with Sinfo.Utils; use Sinfo.Utils; with Snames; use Snames; with Stand; use Stand; with Tbuild; use Tbuild; with Uintp; use Uintp; package body Exp_SPARK is ----------------------- -- Local Subprograms -- ----------------------- procedure Expand_SPARK_N_Attribute_Reference (N : Node_Id); -- Perform attribute-reference-specific expansion procedure Expand_SPARK_N_Delta_Aggregate (N : Node_Id); -- Perform delta-aggregate-specific expansion procedure Expand_SPARK_N_Freeze_Entity (N : Node_Id); -- Do a minimal expansion of freeze entities required by GNATprove. It is -- a subset of what is done for GNAT in Exp_Ch13.Expand_N_Freeze_Entity. -- Those two routines should be kept in sync. procedure Expand_SPARK_N_Loop_Statement (N : Node_Id); -- Perform loop-statement-specific expansion procedure Expand_SPARK_N_Object_Declaration (N : Node_Id); -- Perform object-declaration-specific expansion procedure Expand_SPARK_N_Object_Renaming_Declaration (N : Node_Id); -- Perform name evaluation for a renamed object procedure Expand_SPARK_N_Op_Ne (N : Node_Id); -- Rewrite operator /= based on operator = when defined explicitly procedure Expand_SPARK_Delta_Or_Update (Typ : Entity_Id; Aggr : Node_Id); -- Common expansion for attribute Update and delta aggregates procedure SPARK_Freeze_Type (N : Node_Id); -- Do a minimal type freezing required by GNATprove. It is a subset of what -- is done for GNAT in Exp_Ch3.Freeze_Type. Those two routines should be -- kept in sync. -- -- Currently in freezing we build the spec of dispatching equality. This -- spec is needed to properly resolve references to the equality operator. -- The body is not needed, because proof knows how to directly synthesize a -- logical meaning for it. Also, for tagged types with extension the -- expanded body would compare the _parent component, which is -- intentionally not generated in the GNATprove mode. -- -- We build the DIC procedure body here as well. ------------------ -- Expand_SPARK -- ------------------ procedure Expand_SPARK (N : Node_Id) is begin case Nkind (N) is -- Qualification of entity names in formal verification mode -- is limited to the addition of a suffix for homonyms (see -- Exp_Dbug.Qualify_Entity_Name). We used to qualify entity names -- as full expansion does, but this was removed as this prevents the -- verification back-end from using a short name for debugging and -- user interaction. The verification back-end already takes care -- of qualifying names when needed. when N_Block_Statement | N_Entry_Declaration | N_Package_Body | N_Package_Declaration | N_Protected_Type_Declaration | N_Subprogram_Body | N_Task_Type_Declaration => Qualify_Entity_Names (N); -- Replace occurrences of System'To_Address by calls to -- System.Storage_Elements.To_Address. when N_Attribute_Reference => Expand_SPARK_N_Attribute_Reference (N); when N_Delta_Aggregate => Expand_SPARK_N_Delta_Aggregate (N); when N_Expanded_Name | N_Identifier => Expand_SPARK_Potential_Renaming (N); -- Loop iterations over arrays need to be expanded, to avoid getting -- two names referring to the same object in memory (the array and -- the iterator) in GNATprove, especially since both can be written -- (thus possibly leading to interferences due to aliasing). No such -- problem arises with quantified expressions over arrays, which are -- dealt with specially in GNATprove. when N_Loop_Statement => Expand_SPARK_N_Loop_Statement (N); when N_Object_Declaration => Expand_SPARK_N_Object_Declaration (N); when N_Object_Renaming_Declaration => Expand_SPARK_N_Object_Renaming_Declaration (N); when N_Op_Ne => Expand_SPARK_N_Op_Ne (N); when N_Freeze_Entity => -- Currently we only expand type freeze entities, so ignore other -- freeze entites, because it is expensive to create a suitable -- freezing environment. if Is_Type (Entity (N)) then Expand_SPARK_N_Freeze_Entity (N); end if; -- In SPARK mode, no other constructs require expansion when others => null; end case; end Expand_SPARK; ---------------------------------- -- Expand_SPARK_Delta_Or_Update -- ---------------------------------- procedure Expand_SPARK_Delta_Or_Update (Typ : Entity_Id; Aggr : Node_Id) is Assoc : Node_Id; Comp : Node_Id; Comp_Id : Entity_Id; Comp_Type : Entity_Id; Expr : Node_Id; Index : Node_Id; Index_Typ : Entity_Id; New_Assoc : Node_Id; begin -- Apply scalar range checks on the updated components, if needed if Is_Array_Type (Typ) then -- Multidimensional arrays if Present (Next_Index (First_Index (Typ))) then Assoc := First (Component_Associations (Aggr)); while Present (Assoc) loop Expr := Expression (Assoc); Comp_Type := Component_Type (Typ); if Is_Scalar_Type (Comp_Type) then Apply_Scalar_Range_Check (Expr, Comp_Type); end if; -- The current association contains a sequence of indexes -- denoting an element of a multidimensional array: -- -- (Index_1, ..., Index_N) Expr := First (Choices (Assoc)); pragma Assert (Nkind (Aggr) = N_Aggregate); while Present (Expr) loop Index := First (Expressions (Expr)); Index_Typ := First_Index (Typ); while Present (Index_Typ) loop Apply_Scalar_Range_Check (Index, Etype (Index_Typ)); Next (Index); Next_Index (Index_Typ); end loop; Next (Expr); end loop; Next (Assoc); end loop; -- One-dimensional arrays else Assoc := First (Component_Associations (Aggr)); while Present (Assoc) loop Expr := Expression (Assoc); Comp_Type := Component_Type (Typ); -- Analyze expression of the iterated_component_association -- with its index parameter in scope. if Nkind (Assoc) = N_Iterated_Component_Association then Push_Scope (Scope (Defining_Identifier (Assoc))); Enter_Name (Defining_Identifier (Assoc)); Analyze_And_Resolve (Expr, Comp_Type); end if; if Is_Scalar_Type (Comp_Type) then Apply_Scalar_Range_Check (Expr, Comp_Type); end if; -- Restore scope of the iterated_component_association if Nkind (Assoc) = N_Iterated_Component_Association then End_Scope; end if; Index := First (Choice_List (Assoc)); Index_Typ := First_Index (Typ); while Present (Index) loop -- If the index denotes a range of elements or a constrained -- subtype indication, then their low and high bounds -- already have range checks applied. if Nkind (Index) in N_Range | N_Subtype_Indication then null; -- Otherwise the index denotes a single expression where -- range checks need to be applied or a subtype name -- (without range constraints) where applying checks is -- harmless. -- -- In delta_aggregate and Update attribute on array the -- others_choice is not allowed. else pragma Assert (Nkind (Index) in N_Subexpr); Apply_Scalar_Range_Check (Index, Etype (Index_Typ)); end if; Next (Index); end loop; Next (Assoc); end loop; end if; else pragma Assert (Is_Record_Type (Typ)); -- If the aggregate has multiple component choices, e.g.: -- -- X'Update (A | B | C => 123) -- -- then each component might be of a different type and might or -- might not require a range check. We first rewrite associations -- into single-component choices, e.g.: -- -- X'Update (A => 123, B => 123, C => 123) -- -- and then apply range checks to individual copies of the -- expressions. We do the same for delta aggregates, accordingly. -- Iterate over associations of the original aggregate Assoc := First (Component_Associations (Aggr)); -- Rewrite into a new aggregate and decorate case Nkind (Aggr) is when N_Aggregate => Rewrite (Aggr, Make_Aggregate (Sloc => Sloc (Aggr), Component_Associations => New_List)); when N_Delta_Aggregate => Rewrite (Aggr, Make_Delta_Aggregate (Sloc => Sloc (Aggr), Expression => Expression (Aggr), Component_Associations => New_List)); when others => raise Program_Error; end case; Set_Etype (Aggr, Typ); -- Populate the new aggregate with component associations while Present (Assoc) loop Expr := Expression (Assoc); Comp := First (Choices (Assoc)); while Present (Comp) loop Comp_Id := Entity (Comp); Comp_Type := Etype (Comp_Id); New_Assoc := Make_Component_Association (Sloc => Sloc (Assoc), Choices => New_List (New_Occurrence_Of (Comp_Id, Sloc (Comp))), Expression => New_Copy_Tree (Expr)); -- New association must be attached to the aggregate before we -- analyze it. Append (New_Assoc, Component_Associations (Aggr)); Analyze_And_Resolve (Expression (New_Assoc), Comp_Type); if Is_Scalar_Type (Comp_Type) then Apply_Scalar_Range_Check (Expression (New_Assoc), Comp_Type); end if; Next (Comp); end loop; Next (Assoc); end loop; end if; end Expand_SPARK_Delta_Or_Update; ---------------------------------- -- Expand_SPARK_N_Freeze_Entity -- ---------------------------------- procedure Expand_SPARK_N_Freeze_Entity (N : Entity_Id) is E : constant Entity_Id := Entity (N); Action : Node_Id; E_Scope : Entity_Id; In_Other_Scope : Boolean; In_Outer_Scope : Boolean; begin -- Here E is a type or a subprogram E_Scope := Scope (E); -- This is an error protection against previous errors if No (E_Scope) then Check_Error_Detected; return; end if; -- The entity may be a subtype declared for a constrained record -- component, in which case the relevant scope is the scope of -- the record. This happens for class-wide subtypes created for -- a constrained type extension with inherited discriminants. if Is_Type (E_Scope) and then not Is_Concurrent_Type (E_Scope) then E_Scope := Scope (E_Scope); -- The entity may be a subtype declared for an iterator elsif Ekind (E_Scope) = E_Loop then E_Scope := Scope (E_Scope); end if; -- If we are freezing entities defined in protected types, they belong -- in the enclosing scope, given that the original type has been -- expanded away. The same is true for entities in task types, in -- particular the parameter records of entries (Entities in bodies are -- all frozen within the body). If we are in the task body, this is a -- proper scope. If we are within a subprogram body, the proper scope -- is the corresponding spec. This may happen for itypes generated in -- the bodies of protected operations. if Ekind (E_Scope) = E_Protected_Type or else (Ekind (E_Scope) = E_Task_Type and then not Has_Completion (E_Scope)) then E_Scope := Scope (E_Scope); elsif Ekind (E_Scope) = E_Subprogram_Body then E_Scope := Corresponding_Spec (Unit_Declaration_Node (E_Scope)); end if; -- If the scope of the entity is in open scopes, it is the current one -- or an enclosing one, including a loop, a block, or a subprogram. if In_Open_Scopes (E_Scope) then In_Other_Scope := False; In_Outer_Scope := E_Scope /= Current_Scope; -- Otherwise it is a local package or a different compilation unit else In_Other_Scope := True; In_Outer_Scope := False; end if; -- If the entity being frozen is defined in a scope that is not -- currently on the scope stack, we must establish the proper -- visibility before freezing the entity and related subprograms. if In_Other_Scope then Push_Scope (E_Scope); -- Finalizers are little odd in terms of freezing. The spec of the -- procedure appears in the declarations while the body appears in -- the statement part of a single construct. Since the finalizer must -- be called by the At_End handler of the construct, the spec is -- manually frozen right after its declaration. The only side effect -- of this action appears in contexts where the construct is not in -- its final resting place. These contexts are: -- * Entry bodies - The declarations and statements are moved to -- the procedure equivalen of the entry. -- * Protected subprograms - The declarations and statements are -- moved to the non-protected version of the subprogram. -- * Task bodies - The declarations and statements are moved to the -- task body procedure. -- * Blocks that will be rewritten as subprograms when unnesting -- is in effect. -- Visible declarations do not need to be installed in these three -- cases since it does not make semantic sense to do so. All entities -- referenced by a finalizer are visible and already resolved, plus -- the enclosing scope may not have visible declarations at all. if Ekind (E) = E_Procedure and then Is_Finalizer (E) and then (Is_Entry (E_Scope) or else (Is_Subprogram (E_Scope) and then Is_Protected_Type (Scope (E_Scope))) or else Is_Task_Type (E_Scope) or else Ekind (E_Scope) = E_Block) then null; else Install_Visible_Declarations (E_Scope); end if; if Is_Concurrent_Type (E_Scope) or else Is_Package_Or_Generic_Package (E_Scope) then Install_Private_Declarations (E_Scope); end if; -- If the entity is in an outer scope, then that scope needs to -- temporarily become the current scope so that operations created -- during type freezing will be declared in the right scope and -- can properly override any corresponding inherited operations. elsif In_Outer_Scope then Push_Scope (E_Scope); end if; -- Remember that we are processing a freezing entity and its freezing -- nodes. This flag (non-zero = set) is used to avoid the need of -- climbing through the tree while processing the freezing actions (ie. -- to avoid generating spurious warnings or to avoid killing constant -- indications while processing the code associated with freezing -- actions). We use a counter to deal with nesting. Inside_Freezing_Actions := Inside_Freezing_Actions + 1; -- Currently only types require freezing in SPARK SPARK_Freeze_Type (N); -- Analyze actions in freeze node, if any Action := First (Actions (N)); while Present (Action) loop Analyze (Action); Next (Action); end loop; -- Pop scope if we installed one for the analysis if In_Other_Scope then if Ekind (Current_Scope) = E_Package then End_Package_Scope (E_Scope); else End_Scope; end if; elsif In_Outer_Scope then Pop_Scope; end if; -- Restore previous value of the nesting-level counter that records -- whether we are inside a (possibly nested) call to this procedure. Inside_Freezing_Actions := Inside_Freezing_Actions - 1; end Expand_SPARK_N_Freeze_Entity; ---------------------------------------- -- Expand_SPARK_N_Attribute_Reference -- ---------------------------------------- procedure Expand_SPARK_N_Attribute_Reference (N : Node_Id) is Aname : constant Name_Id := Attribute_Name (N); Attr_Id : constant Attribute_Id := Get_Attribute_Id (Aname); Loc : constant Source_Ptr := Sloc (N); Pref : constant Node_Id := Prefix (N); Typ : constant Entity_Id := Etype (N); Expr : Node_Id; begin case Attr_Id is when Attribute_To_Address => -- Extract and convert argument to expected type for call Expr := Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (RTE (RE_Integer_Address), Loc), Expression => Relocate_Node (First (Expressions (N)))); -- Replace attribute reference with call Rewrite (N, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_To_Address), Loc), Parameter_Associations => New_List (Expr))); Analyze_And_Resolve (N, Typ); when Attribute_Object_Size | Attribute_Size | Attribute_Value_Size | Attribute_VADS_Size => Exp_Attr.Expand_Size_Attribute (N); -- For attributes which return Universal_Integer, introduce a -- conversion to the expected type with the appropriate check flags -- set. when Attribute_Aft | Attribute_Alignment | Attribute_Bit | Attribute_Bit_Position | Attribute_Descriptor_Size | Attribute_First_Bit | Attribute_Last_Bit | Attribute_Length | Attribute_Max_Alignment_For_Allocation | Attribute_Max_Size_In_Storage_Elements | Attribute_Pos | Attribute_Position | Attribute_Range_Length => -- If the expected type is Long_Long_Integer, there will be no -- check flag as the compiler assumes attributes always fit in -- this type. Since in SPARK_Mode we do not take Storage_Error -- into account, we cannot make this assumption and need to -- produce a check. ??? It should be enough to add this check for -- attributes 'Length, 'Range_Length and 'Pos when the type is as -- big as Long_Long_Integer. declare Typ : Entity_Id; begin if Attr_Id in Attribute_Pos | Attribute_Range_Length then Typ := Etype (Prefix (N)); elsif Attr_Id = Attribute_Length then Typ := Get_Index_Subtype (N); else Typ := Empty; end if; Apply_Universal_Integer_Attribute_Checks (N); if Present (Typ) and then Known_RM_Size (Typ) and then RM_Size (Typ) = RM_Size (Standard_Long_Long_Integer) then -- ??? This should rather be a range check, but this would -- crash GNATprove which somehow recovers the proper kind -- of check anyway. Set_Do_Overflow_Check (N); end if; end; when Attribute_Constrained => -- If the prefix is an access to object, the attribute applies to -- the designated object, so rewrite with an explicit dereference. if Is_Access_Type (Etype (Pref)) and then (not Is_Entity_Name (Pref) or else Is_Object (Entity (Pref))) then Rewrite (Pref, Make_Explicit_Dereference (Loc, Relocate_Node (Pref))); Analyze_And_Resolve (N, Standard_Boolean); end if; when Attribute_Update => Expand_SPARK_Delta_Or_Update (Typ, First (Expressions (N))); when others => null; end case; end Expand_SPARK_N_Attribute_Reference; ------------------------------------ -- Expand_SPARK_N_Delta_Aggregate -- ------------------------------------ procedure Expand_SPARK_N_Delta_Aggregate (N : Node_Id) is begin Expand_SPARK_Delta_Or_Update (Etype (N), N); end Expand_SPARK_N_Delta_Aggregate; ----------------------------------- -- Expand_SPARK_N_Loop_Statement -- ----------------------------------- procedure Expand_SPARK_N_Loop_Statement (N : Node_Id) is Scheme : constant Node_Id := Iteration_Scheme (N); begin -- Loop iterations over arrays need to be expanded, to avoid getting -- two names referring to the same object in memory (the array and the -- iterator) in GNATprove, especially since both can be written (thus -- possibly leading to interferences due to aliasing). No such problem -- arises with quantified expressions over arrays, which are dealt with -- specially in GNATprove. if Present (Scheme) and then Present (Iterator_Specification (Scheme)) and then Is_Iterator_Over_Array (Iterator_Specification (Scheme)) then Expand_Iterator_Loop_Over_Array (N); end if; end Expand_SPARK_N_Loop_Statement; --------------------------------------- -- Expand_SPARK_N_Object_Declaration -- --------------------------------------- procedure Expand_SPARK_N_Object_Declaration (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Obj_Id : constant Entity_Id := Defining_Identifier (N); Typ : constant Entity_Id := Etype (Obj_Id); Call : Node_Id; begin -- If the object declaration denotes a variable without initialization -- whose type is subject to pragma Default_Initial_Condition, create -- and analyze a dummy call to the DIC procedure of the type in order -- to detect potential elaboration issues. if Comes_From_Source (Obj_Id) and then Ekind (Obj_Id) = E_Variable and then Has_DIC (Typ) and then Present (DIC_Procedure (Typ)) and then not Has_Init_Expression (N) then Call := Build_DIC_Call (Loc, New_Occurrence_Of (Obj_Id, Loc), Typ); -- Partially insert the call into the tree by setting its parent -- pointer. Set_Parent (Call, N); Analyze (Call); end if; end Expand_SPARK_N_Object_Declaration; ------------------------------------------------ -- Expand_SPARK_N_Object_Renaming_Declaration -- ------------------------------------------------ procedure Expand_SPARK_N_Object_Renaming_Declaration (N : Node_Id) is CFS : constant Boolean := Comes_From_Source (N); Loc : constant Source_Ptr := Sloc (N); Obj_Id : constant Entity_Id := Defining_Entity (N); Nam : constant Node_Id := Name (N); Typ : constant Entity_Id := Etype (Obj_Id); begin -- Transform a renaming of the form -- Obj_Id : <subtype mark> renames <function call>; -- into -- Obj_Id : constant <subtype mark> := <function call>; -- Invoking Evaluate_Name and ultimately Remove_Side_Effects introduces -- a temporary to capture the function result. Once potential renamings -- are rewritten for SPARK, the temporary may be leaked out into source -- constructs and lead to confusing error diagnostics. Using an object -- declaration prevents this unwanted side effect. if Nkind (Nam) = N_Function_Call then Rewrite (N, Make_Object_Declaration (Loc, Defining_Identifier => Obj_Id, Constant_Present => True, Object_Definition => New_Occurrence_Of (Typ, Loc), Expression => Nam)); -- Inherit the original Comes_From_Source status of the renaming Set_Comes_From_Source (N, CFS); -- Sever the link to the renamed function result because the entity -- will no longer alias anything. Set_Renamed_Object (Obj_Id, Empty); -- Remove the entity of the renaming declaration from visibility as -- the analysis of the object declaration will reintroduce it again. Remove_Entity_And_Homonym (Obj_Id); Analyze (N); -- Otherwise unconditionally remove all side effects from the name else Evaluate_Name (Nam); end if; end Expand_SPARK_N_Object_Renaming_Declaration; -------------------------- -- Expand_SPARK_N_Op_Ne -- -------------------------- procedure Expand_SPARK_N_Op_Ne (N : Node_Id) is Typ : constant Entity_Id := Etype (Left_Opnd (N)); begin -- Case of elementary type with standard operator if Is_Elementary_Type (Typ) and then Sloc (Entity (N)) = Standard_Location then null; else Exp_Ch4.Expand_N_Op_Ne (N); end if; end Expand_SPARK_N_Op_Ne; ------------------------------------- -- Expand_SPARK_Potential_Renaming -- ------------------------------------- procedure Expand_SPARK_Potential_Renaming (N : Node_Id) is function In_Insignificant_Pragma (Nod : Node_Id) return Boolean; -- Determine whether arbitrary node Nod appears within a significant -- pragma for SPARK. ----------------------------- -- In_Insignificant_Pragma -- ----------------------------- function In_Insignificant_Pragma (Nod : Node_Id) return Boolean is Par : Node_Id; begin -- Climb the parent chain looking for an enclosing pragma Par := Nod; while Present (Par) loop if Nkind (Par) = N_Pragma then return not Pragma_Significant_In_SPARK (Get_Pragma_Id (Par)); -- Prevent the search from going too far elsif Is_Body_Or_Package_Declaration (Par) then exit; end if; Par := Parent (Par); end loop; return False; end In_Insignificant_Pragma; -- Local variables Loc : constant Source_Ptr := Sloc (N); Obj_Id : constant Entity_Id := Entity (N); Typ : constant Entity_Id := Etype (N); Ren : Node_Id; -- Start of processing for Expand_SPARK_Potential_Renaming begin -- Replace a reference to a renaming with the actual renamed object if Is_Object (Obj_Id) then Ren := Renamed_Object (Obj_Id); if Present (Ren) then -- Do not process a reference when it appears within a pragma of -- no significance to SPARK. It is assumed that the replacement -- will violate the semantics of the pragma and cause a spurious -- error. if In_Insignificant_Pragma (N) then return; -- Instantiations and inlining of subprograms employ "prologues" -- which map actual to formal parameters by means of renamings. -- Replace a reference to a formal by the corresponding actual -- parameter. elsif Nkind (Ren) in N_Entity then Rewrite (N, New_Occurrence_Of (Ren, Loc)); -- Otherwise the renamed object denotes a name else Rewrite (N, New_Copy_Tree (Ren, New_Sloc => Loc)); Reset_Analyzed_Flags (N); end if; Analyze_And_Resolve (N, Typ); end if; end if; end Expand_SPARK_Potential_Renaming; ----------------------- -- SPARK_Freeze_Type -- ----------------------- procedure SPARK_Freeze_Type (N : Entity_Id) is Typ : constant Entity_Id := Entity (N); Renamed_Eq : Node_Id; -- Defining unit name for the predefined equality function in the case -- where the type has a primitive operation that is a renaming of -- predefined equality (but only if there is also an overriding -- user-defined equality function). Used to pass this entity from -- Make_Predefined_Primitive_Specs to Predefined_Primitive_Bodies. Decl : Node_Id; Eq_Spec : Node_Id := Empty; Predef_List : List_Id; Wrapper_Decl_List : List_Id; Wrapper_Body_List : List_Id := No_List; Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; -- Save the Ghost-related attributes to restore on exit begin -- The type being frozen may be subject to pragma Ghost. Set the mode -- now to ensure that any nodes generated during freezing are properly -- marked as Ghost. Set_Ghost_Mode (Typ); -- When a DIC is inherited by a tagged type, it may need to be -- specialized to the descendant type, hence build a separate DIC -- procedure for it as done during regular expansion for compilation. if Has_DIC (Typ) and then Is_Tagged_Type (Typ) then -- Why is this needed for DIC, but not for other aspects (such as -- Type_Invariant)??? Build_DIC_Procedure_Body (Typ); end if; if Ekind (Typ) = E_Record_Type and then Is_Tagged_Type (Typ) and then not Is_Interface (Typ) and then not Is_Limited_Type (Typ) then if Is_CPP_Class (Root_Type (Typ)) and then Convention (Typ) = Convention_CPP then null; -- Do not add the spec of the predefined primitives if we are -- compiling under restriction No_Dispatching_Calls. elsif not Restriction_Active (No_Dispatching_Calls) then Set_Is_Frozen (Typ, False); Predef_List := New_List; Exp_Ch3.Make_Predefined_Primitive_Eq_Spec (Typ, Predef_List, Renamed_Eq); Eq_Spec := First (Predef_List); Insert_List_Before_And_Analyze (N, Predef_List); Set_Is_Frozen (Typ); -- Remove link from the parent list to the spec and body of -- the dispatching equality, but keep the link in the opposite -- direction, to allow up-traversal of the AST. if Present (Eq_Spec) then Decl := Parent (Eq_Spec); Remove (Eq_Spec); Set_Parent (Eq_Spec, Decl); end if; end if; end if; if Ekind (Typ) = E_Record_Type and then Is_Tagged_Type (Typ) and then not Is_CPP_Class (Typ) then -- Ada 2005 (AI-391): For a nonabstract null extension, create -- wrapper functions for each nonoverridden inherited function -- with a controlling result of the type. The wrapper for such -- a function returns an extension aggregate that invokes the -- parent function. if Ada_Version >= Ada_2005 and then not Is_Abstract_Type (Typ) and then Is_Null_Extension (Typ) then Exp_Ch3.Make_Controlling_Function_Wrappers (Typ, Wrapper_Decl_List, Wrapper_Body_List); Insert_List_Before_And_Analyze (N, Wrapper_Decl_List); end if; -- Ada 2005 (AI-391): If any wrappers were created for nonoverridden -- inherited functions, then add their bodies to the AST, so they -- will be processed like ordinary subprogram bodies (even though the -- compiler adds them into the freezing action). if not Is_Interface (Typ) then Insert_List_Before_And_Analyze (N, Wrapper_Body_List); end if; end if; Restore_Ghost_Region (Saved_GM, Saved_IGR); end SPARK_Freeze_Type; end Exp_SPARK;
AaronC98/PlaneSystem
Ada
4,837
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2004-2012, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ package AWS.Services.Split_Pages.Alpha is -- Split in (at most) 28 pages, one for empty fields, one for all fields -- that start with a digit, and one for each different initial letter. -- Note that leading spaces in the key field are ignored; this means that a -- key field containing only spaces is treated as an empty field. -- The key field is set by calling Set_Key. If no key is defined, or no -- corresponding association is found in Table, or the association is not a -- vector, Splitter_Error is raised. -- The key field must be sorted, and all values must be empty or start with -- a digit or letter (case ignored). Otherwise, Splitter_Error is raised. -- Letters that do not appear in the key field are associated to the empty -- string; an Href can be specified instead by calling Set_Default_Href. -- -- Tags: -- NEXT The href to the next page. -- PREVIOUS The href to the previous page. -- FIRST The href to the first page. -- LAST The href to the last page. -- PAGE_INDEX Position of the current page in the INDEXES_V vector -- HREFS_V A vector tag containing a set of href to pages, or "" if -- their is no page for the corresponding letter. -- INDEXES_V A vector tag (synchronized with HREFS_V) containing ' ' -- and the letters 'A' .. 'Z' -- -- HREFS_V and INDEXES_V can be used to create an index to the generated -- pages. Splitter_Error : exception renames Split_Pages.Splitter_Error; type Splitter is new Split_Pages.Splitter with private; overriding function Get_Page_Ranges (This : Splitter; Table : Templates.Translate_Set) return Ranges_Table; overriding function Get_Translations (This : Splitter; Page : Positive; URIs : URI_Table; Ranges : Ranges_Table) return Templates.Translate_Set; procedure Set_Key (This : in out Splitter; Key : String); -- Set the key field, this is the name of the vector association in the -- translate_set that will be used to create the index. procedure Set_Default_Href (This : in out Splitter; Href : String); -- Href to use for letter having no entry in the key, if not specified the -- empty string is used. private type Splitter is new Split_Pages.Splitter with record Key : Unbounded_String; Default_Href : Unbounded_String; Index : Lines_Table; HREFS_V : Templates.Tag; INDEXES_V : Templates.Tag; end record; end AWS.Services.Split_Pages.Alpha;
reznikmm/matreshka
Ada
3,603
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.Components.Hash is new AMF.Elements.Generic_Hash (UML_Component, UML_Component_Access);
stcarrez/ada-util
Ada
2,349
adb
----------------------------------------------------------------------- -- util-properties-form-tests -- Test reading JSON file into properties -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Files; package body Util.Properties.Form.Tests is package Caller is new Util.Test_Caller (Test, "Properties.Form"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Properties.Form.Parse_Form", Test_Parse_Form'Access); end Add_Tests; -- Test loading a JSON file into a properties object. procedure Test_Parse_Form (T : in out Test) is procedure Check (Name : in String; Value : in String); P : Util.Properties.Manager; procedure Check (Name : in String; Value : in String) is begin T.Assert (P.Exists (Name), "Missing property: " & Name); Util.Tests.Assert_Equals (T, Value, String '(P.Get (Name)), "Invalid property: " & Name); end Check; Path : constant String := Util.Tests.Get_Path ("regtests/files/test-1.form"); S : Ada.Strings.Unbounded.Unbounded_String; begin Util.Files.Read_File (Path, S); Util.Properties.Form.Parse_Form (P, Ada.Strings.Unbounded.To_String (S)); Check ("access_token", "97356"); Check ("token_type", "bearer"); Check ("refresh_token_expires_in", "15724800"); Check ("refresh_token", "r1.714b6"); Check ("scope", ""); Check ("scope", ""); end Test_Parse_Form; end Util.Properties.Form.Tests;
PThierry/ewok-kernel
Ada
822
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- package ewok.exported is end ewok.exported;
jrmarino/AdaBase
Ada
1,901
ads
--- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt with CommonText; with Ada.Calendar; with AdaBase.Interfaces.Logger; package AdaBase.Logger.Base is package CT renames CommonText; package AC renames Ada.Calendar; package AIL renames AdaBase.Interfaces.Logger; type Base_Logger is abstract new Base_Pure and AIL.iLogger with private; type BaseClass_Logger_access is access all Base_Logger'Class; procedure set_information (listener : out Base_Logger; category : Log_Category; driver : Driver_Type; message : CT.Text; error_msg : CT.Text := CT.blank; error_code : Driver_Codes := 0; sqlstate : SQL_State := stateless); function timestamp (listener : Base_Logger) return AC.Time; function category (listener : Base_Logger) return Log_Category; function driver (listener : Base_Logger) return Driver_Type; function composite (listener : Base_Logger) return CT.Text; function message (listener : Base_Logger) return CT.Text; function error_msg (listener : Base_Logger) return CT.Text; function error_code (listener : Base_Logger) return Driver_Codes; function sqlstate (listener : Base_Logger) return SQL_State; function is_error (listener : Base_Logger) return Boolean; private type Base_Logger is abstract new Base_Pure and AIL.iLogger with record prop_timestamp : AC.Time; prop_category : Log_Category; prop_driver : Driver_Type; prop_composite : CT.Text := CT.blank; prop_message : CT.Text := CT.blank; prop_error_msg : CT.Text := CT.blank; prop_error_code : Driver_Codes; prop_sqlstate : SQL_State; prop_is_error : Boolean; end record; end AdaBase.Logger.Base;
reznikmm/matreshka
Ada
3,765
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.Draw.Fill_Color is type Draw_Fill_Color_Node is new Matreshka.ODF_Attributes.Draw.Draw_Node_Base with null record; type Draw_Fill_Color_Access is access all Draw_Fill_Color_Node'Class; overriding function Get_Local_Name (Self : not null access constant Draw_Fill_Color_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.Draw.Fill_Color;
burratoo/Acton
Ada
1,425
ads
------------------------------------------------------------------------------------------ -- -- -- OAK CORE SUPPORT PACKAGE -- -- ARM CORTEX M4F -- -- -- -- OAK.CORE_SUPPORT_PACKAGE.CALL_STACK.OPS -- -- -- -- Copyright (C) 2014-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with Oak.Memory.Call_Stack; use Oak.Memory.Call_Stack; with System; use System; package Oak.Core_Support_Package.Call_Stack.Ops with Pure is procedure Set_Task_Instruction_Pointer (Stack : in out Call_Stack_Handler; Instruction_Address : in Address) with Inline; procedure Set_Task_Body_Procedure (Stack : in out Call_Stack_Handler; Procedure_Address : in Address; Task_Value_Record : in Address); end Oak.Core_Support_Package.Call_Stack.Ops;
AdaCore/training_material
Ada
7,554
ads
------------------------------------------------------------------------------ -- -- -- Hardware Abstraction Layer for STM32 Targets -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This file provides definitions for the STM32F4 (ARM Cortex M4F -- from ST Microelectronics) Serial Peripheral Interface (SPI) facility. package STM32F4.SPI is type SPI_Port is limited private; type SPI_Data_Direction is (D2Lines_FullDuplex, D2Lines_RxOnly, D1Line_Rx, D1Line_Tx); type SPI_Data_Size is (Data_16, Data_8); type SPI_Mode is (Master, Slave); type SPI_CLock_Polarity is (High, Low); type SPI_CLock_Phase is (P1Edge, P2Edge); type SPI_Slave_Management is (Soft, Hard); type SPI_Baud_Rate_Prescaler is (BRP_2, BRP_4, BRP_8, BRP_16, BRP_32, BRP_64, BRP_128, BRP_256); type SPI_First_Bit is (MSB, LSB); type SPI_Configuration is record Direction : SPI_Data_Direction; Mode : SPI_Mode; Data_Size : SPI_Data_Size; Clock_Polarity : SPI_Clock_Polarity; Clock_Phase : SPI_Clock_Phase; Slave_Management : SPI_Slave_Management; Baud_Rate_Prescaler : SPI_Baud_Rate_Prescaler; First_Bit : SPI_First_Bit; CRC_Poly : Half_Word; end record; procedure Configure (Port : in out SPI_Port; Conf : SPI_Configuration); procedure Enable (Port : in out SPI_Port); procedure Disable (Port : in out SPI_Port); function Enabled (Port : SPI_Port) return Boolean; procedure Send (Port : in out SPI_Port; Data : Half_Word); function Data (Port : SPI_Port) return Half_Word with Inline; procedure Send (Port : in out SPI_Port; Data : Byte); function Data (Port : SPI_Port) return Byte with Inline; function Rx_Is_Empty (Port : SPI_Port) return Boolean with Inline; function Tx_Is_Empty (Port : SPI_Port) return Boolean with Inline; function Busy (Port : SPI_Port) return Boolean with Inline; function Channel_Side_Indicated (Port : SPI_Port) return Boolean with Inline; function Underrun_Indicated (Port : SPI_Port) return Boolean with Inline; function CRC_Error_Indicated (Port : SPI_Port) return Boolean with Inline; function Mode_Fault_Indicated (Port : SPI_Port) return Boolean with Inline; function Overrun_Indicated (Port : SPI_Port) return Boolean with Inline; function Frame_Fmt_Error_Indicated (Port : SPI_Port) return Boolean with Inline; private type SPI_Control_Register is record Clock_Phase : Bits_1; Clock_Polarity : Bits_1; Master_Select : Bits_1; Baud_Rate_Ctrl : Bits_3; SPI_Enable : Bits_1; LSB_First : Bits_1; -- Frame Format Slave_Select : Bits_1; Soft_Slave_Mgt : Bits_1; -- Software Slave Management RXOnly : Bits_1; Data_Frame_Fmt : Bits_1; -- 1=16-bit 0=8-bit CRC_Next : Bits_1; -- 1=CRC Phase 0=No CRC Phase CRC_Enable : Bits_1; Output_BiDir : Bits_1; -- Output enable in bidirectional mode BiDir_Mode : Bits_1; -- Bidirectional data mode enable end record with Pack, Volatile, Size => 16; type SPI_Control_Register2 is record RX_DMA_Enable : Bits_1; TX_DMA_Enable : Bits_1; SS_Out_Enable : Bits_1; Reserved_1 : Bits_1; Frame_Fmt : Bits_1; -- 0=Motorola Mode 1=TI Mode Err_Int_Enable : Bits_1; RX_Not_Empty_Int_Enable : Bits_1; TX_Empty_Int_Enable : Bits_1; Reserved_2 : Bits_8; end record with Pack, Volatile, Size => 16; type SPI_I2S_Config_Register is record Channel_Length : Bits_1; Data_Length : Bits_2; Clock_Polarity : Bits_1; I2S_Standard : Bits_2; -- 00==Philips 01=MSB (L) 10=LSB (R) 11=PCM Reserved_1 : Bits_1; PCM_Frame_Sync : Bits_1; -- 0=Short 1=Long Config_Mode : Bits_2; -- 00=SlaveTX 01=SlaveRX 10=MasterTX11=MasterRX Enable : Bits_1; Mode_Select : Bits_1; -- 0=SPI Mode 1=I2S Mode Reserved_2 : Bits_4; end record with Pack, Volatile, Size => 16; type SPI_I2S_Prescale_Register is record Linear_Prescler : Bits_8; Odd_Factor : Bits_1; Master_CLK_Out_Enable : Bits_1; Reserved : Bits_6; end record with Pack, Volatile, Size => 16; type SPI_Status_Register is record RX_Buffer_Not_Empty : Boolean; TX_Buffer_Empty : Boolean; Channel_Side : Boolean; Underrun_Flag : Boolean; CRC_Error_Flag : Boolean; Mode_Fault : Boolean; Overrun_Flag : Boolean; Busy_Flag : Boolean; Frame_Fmt_Error : Boolean; Reserved : Bits_7; end record with Pack, Volatile, Size => 16; type SPI_Port is record CTRL1 : SPI_Control_Register; Reserved_1 : Half_Word; CTRL2 : SPI_Control_Register2; Reserved_2 : Half_Word; Status : SPI_Status_Register; Reserved_3 : Half_Word; Data : Half_Word; Reserved_4 : Half_Word; CRC_Poly : Half_Word; -- Default = 16#0007# Reserved_5 : Half_Word; RX_CRC : Half_Word; Reserved_6 : Half_Word; TX_CRC : Half_Word; Reserved_7 : Half_Word; I2S_Conf : SPI_I2S_Config_Register; Reserved_8 : Half_Word; I2S_PreScal : SPI_I2S_Prescale_Register; Reserved_9 : Half_Word; end record with Pack, Volatile, Size => 9 * 32; end STM32F4.SPI;
reznikmm/matreshka
Ada
4,559
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_Smil.Mode_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Smil_Mode_Attribute_Node is begin return Self : Smil_Mode_Attribute_Node do Matreshka.ODF_Smil.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Smil_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Smil_Mode_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Mode_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Smil_URI, Matreshka.ODF_String_Constants.Mode_Attribute, Smil_Mode_Attribute_Node'Tag); end Matreshka.ODF_Smil.Mode_Attributes;
reznikmm/matreshka
Ada
4,229
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.FO.Page_Width.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.FO.Page_Width.FO_Page_Width_Access) return ODF.DOM.Attributes.FO.Page_Width.ODF_FO_Page_Width 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.FO.Page_Width.FO_Page_Width_Access) return ODF.DOM.Attributes.FO.Page_Width.ODF_FO_Page_Width is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.FO.Page_Width.Internals;
apple-oss-distributions/old_ncurses
Ada
10,569
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Form_Demo.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 ------------------------------------------------------------------------------ with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Sample.Manifest; use Sample.Manifest; with Sample.Helpers; use Sample.Helpers; with Sample.Keyboard_Handler; use Sample.Keyboard_Handler; with Sample.Explanation; use Sample.Explanation; package body Sample.Form_Demo.Aux is procedure Geometry (F : in Form; L : out Line_Count; -- Lines used for menu C : out Column_Count; -- Columns used for menu Y : out Line_Position; -- Proposed Line for menu X : out Column_Position) -- Proposed Column for menu is begin Scale (F, L, C); L := L + 2; -- count for frame at top and bottom C := C + 2; -- " -- Calculate horizontal coordinate at the screen center X := (Columns - C) / 2; Y := 1; -- start always in line 1 end Geometry; function Create (F : Form; Title : String; Lin : Line_Position; Col : Column_Position) return Panel is W, S : Window; L : Line_Count; C : Column_Count; Y : Line_Position; X : Column_Position; Pan : Panel; begin Geometry (F, L, C, Y, X); W := New_Window (L, C, Lin, Col); Set_Meta_Mode (W); Set_KeyPad_Mode (W); if Has_Colors then Set_Background (Win => W, Ch => (Ch => ' ', Color => Default_Colors, Attr => Normal_Video)); Set_Character_Attributes (Win => W, Color => Default_Colors, Attr => Normal_Video); Erase (W); end if; S := Derived_Window (W, L - 2, C - 2, 1, 1); Set_Meta_Mode (S); Set_KeyPad_Mode (S); Box (W); Set_Window (F, W); Set_Sub_Window (F, S); if Title'Length > 0 then Window_Title (W, Title); end if; Pan := New_Panel (W); Post (F); return Pan; end Create; procedure Destroy (F : in Form; P : in out Panel) is W, S : Window; begin W := Get_Window (F); S := Get_Sub_Window (F); Post (F, False); Erase (W); Delete (P); Set_Window (F, Null_Window); Set_Sub_Window (F, Null_Window); Delete (S); Delete (W); Update_Panels; end Destroy; function Get_Request (F : Form; P : Panel; Handle_CRLF : Boolean := True) return Key_Code is W : constant Window := Get_Window (F); K : Real_Key_Code; Ch : Character; begin Top (P); loop K := Get_Key (W); if K in Special_Key_Code'Range then case K is when HELP_CODE => Explain_Context; when EXPLAIN_CODE => Explain ("FORMKEYS"); when Key_Home => return F_First_Field; when Key_End => return F_Last_Field; when QUIT_CODE => return QUIT; when Key_Cursor_Down => return F_Down_Char; when Key_Cursor_Up => return F_Up_Char; when Key_Cursor_Left => return F_Previous_Char; when Key_Cursor_Right => return F_Next_Char; when Key_Next_Page => return F_Next_Page; when Key_Previous_Page => return F_Previous_Page; when Key_Backspace => return F_Delete_Previous; when Key_Clear_Screen => return F_Clear_Field; when Key_Clear_End_Of_Line => return F_Clear_EOF; when others => return K; end case; elsif K in Normal_Key_Code'Range then Ch := Character'Val (K); case Ch is when CAN => return QUIT; -- CTRL-X when ACK => return F_Next_Field; -- CTRL-F when STX => return F_Previous_Field; -- CTRL-B when FF => return F_Left_Field; -- CTRL-L when DC2 => return F_Right_Field; -- CTRL-R when NAK => return F_Up_Field; -- CTRL-U when EOT => return F_Down_Field; -- CTRL-D when ETB => return F_Next_Word; -- CTRL-W when DC4 => return F_Previous_Word; -- CTRL-T when SOH => return F_Begin_Field; -- CTRL-A when ENQ => return F_End_Field; -- CTRL-E when HT => return F_Insert_Char; -- CTRL-I when SI => return F_Insert_Line; -- CTRL-O when SYN => return F_Delete_Char; -- CTRL-V when BS => return F_Delete_Previous; -- CTRL-H when EM => return F_Delete_Line; -- CTRL-Y when BEL => return F_Delete_Word; -- CTRL-G when VT => return F_Clear_EOF; -- CTRL-K when SO => return F_Next_Choice; -- CTRL-N when DLE => return F_Previous_Choice; -- CTRL-P when CR | LF => if Handle_CRLF then return F_New_Line; else return K; end if; when others => return K; end case; else return K; end if; end loop; end Get_Request; function Make (Top : Line_Position; Left : Column_Position; Text : String) return Field is Fld : Field; C : Column_Count := Column_Count (Text'Length); begin Fld := New_Field (1, C, Top, Left); Set_Buffer (Fld, 0, Text); Switch_Options (Fld, (Active => True, others => False), False); if Has_Colors then Set_Background (Fld => Fld, Color => Default_Colors); end if; return Fld; end Make; function Make (Height : Line_Count := 1; Width : Column_Count; Top : Line_Position; Left : Column_Position; Off_Screen : Natural := 0) return Field is Fld : Field := New_Field (Height, Width, Top, Left, Off_Screen); begin if Has_Colors then Set_Foreground (Fld => Fld, Color => Form_Fore_Color); Set_Background (Fld => Fld, Color => Form_Back_Color); else Set_Background (Fld, (Reverse_Video => True, others => False)); end if; return Fld; end Make; function Default_Driver (F : Form; K : Key_Code; P : Panel) return Boolean is begin if K in User_Key_Code'Range and then K = QUIT then if Driver (F, F_Validate_Field) = Form_Ok then return True; end if; end if; return False; end Default_Driver; function Count_Active (F : Form) return Natural is N : Natural := 0; O : Field_Option_Set; H : constant Natural := Field_Count (F); begin if H > 0 then for I in 1 .. H loop Get_Options (Fields (F, I), O); if O.Active then N := N + 1; end if; end loop; end if; return N; end Count_Active; end Sample.Form_Demo.Aux;
annexi-strayline/ASAP-UUIDs
Ada
26,539
adb
------------------------------------------------------------------------------ -- -- -- Common UUID Handling Package -- -- - RFC 4122 Implementation - -- -- -- -- Version 1.0 -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Version 1 (Time-based) UUID Generation Package -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2018, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contibutors: -- -- * Aninda Poddar (ANNEXI-STRAYLINE) -- -- -- -- First release review and refinement -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of ANNEXI-STRAYLINE 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 ANNEXI-STRAYLINE -- -- 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 System; with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Calendar.Arithmetic; with Ada.Exceptions; use Ada; with Hex.Modular_Codec; package body UUIDs.Version_1 is type Bitfield_4 is mod 2**4 with Size => 4; type Bitfield_6 is mod 2**6 with Size => 6; type Bitfield_12 is mod 2**12 with Size => 12; type Bitfield_14 is mod 2**14 with Size => 14; type Bitfield_60 is mod 2**60 with Size => 60; -- -- State Management Utilities -- package Node_ID_Hex_Codec is new Hex.Modular_Codec (Bitfield_48, 48); ----------------- -- Format_Time -- ----------------- -- Takes a 60-bit UUID Version 1 timestamp (RFC 4122, Section 4.1.4), and -- breaks it out into the UUID standard fields, in a portable way which is -- machine-endian independent. procedure Format_Time (From_Timestamp: in Timestamp; Time_High : out Bitfield_12; Time_Low : out Bitfield_32; Time_Mid : out Bitfield_16) with Inline => True is begin -- To extract the high 12 bits of the total time field -- (Total_100_Nano_Seconds) mask everything other than the first 12 bits -- and shift the bitfield 60 by 48 bits -- to get the 12 most significant bits into Time_High Time_High := (Bitfield_12((From_Timestamp and 16#fff0_0000_0000_000#) / 2**48)); Time_Mid := (Bitfield_16((From_Timestamp and 16#000f_fff0_0000_000#) / 2**32)); Time_Low := (Bitfield_32((From_Timestamp and 16#0000_000f_ffff_fff#))); end Format_Time; ----------------------- -- Extract_Timestamp -- ----------------------- -- Extract the UUID Version 1 timestamp (RFC 4122, Section 4.1.4) from the -- current State (itself just a Version 1 UUID) function Extract_Timestamp (State: Version_1_State) return Timestamp with Inline => True is -- Extract the last time stamp to later compare with the current -- time generated according to RFC 4122 begin return UUID_timestamp: Timestamp := 0 do -- Mask the first 4 bits containing the version number, leaving -- the high bits of the timestamp, then shift left by 48 bits, -- putting it at the most significant 12 bits of the timestamp. UUID_timestamp := Timestamp (State.Last_ID.time_hi_and_version and 16#0fff#) * 2**48; -- Insert the time_mid in the last time stamp by shifting left -- 32 bits, and dropping it in with an or operation UUID_timestamp := (Timestamp (State.Last_ID.time_mid) * 2**32) or UUID_timestamp; -- The low bits get dropped in as-is UUID_timestamp := UUID_timestamp + Timestamp (State.Last_ID.time_low); end return; end Extract_Timestamp; -- -- Implementation of Specification -- --------------------- -- Standard_Source -- --------------------- -- Generates a 60-bit unsigned modular timestamp value as specified in -- RFC 4122, Section 4.1.4: -- "The timestamp is a 60-bit value. For UUID version 1, this is represented -- by Coordinated Universal Time (UTC) as a count of 100-nanosecond -- intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian -- reform to the Christian calendar)." function Standard_Source return Timestamp is -- Generate a current timestamp from the system clock use Ada.Calendar.Arithmetic; Old_1901 : Time; Days_1901_Now : Day_Count; Seconds : Duration; Leap_Seconds : Leap_Seconds_Count; Total_Days : Timestamp; Total_Seconds : Timestamp; Now : Time := Clock; Days_1582_1901 : constant := 116225; begin Old_1901:= Time_Of (Year => 1901, Month => 1, Day => 1, Hour => 0, Minute => 0, Second => 0); -- At the time of writing, the Ada 2012 Reference Manual states this is -- the earliest possible time which may be represented by a value of type -- Time. We need to use this as a base point, from which we will add on -- the days from 1582/01/01:00:00:00.00 until 1900/12/31:00:00:00.00 UTC -- Get the time difference from now to Jan 1st 1901 Difference (Left => Now, Right => Old_1901, Days => Days_1901_Now, Seconds => Seconds, Leap_Seconds => Leap_Seconds); -- Though the Ada RM doesn't specifically state that Clock should be in -- UTC, it does suggest as much. For most uses, this will likely be true. -- RFC 4122 does not require the time to be UTC, but rather that it is -- consistent. Implementations may want to audit UUID generation to ensure -- that clock is set correctly, if this is a cause for concern. -- Get the current time as a 60-bit count of 100-nanosecond intervals -- since 00:00:00.00, 15 October 1582 Total_Days := Timestamp (Days_1901_Now + Days_1582_1901); -- Add all the seconds Total_Seconds := (Total_Days * 24 * 60 * 60) + Timestamp (Seconds) + Timestamp (Leap_Seconds); -- Multiply to get 100 ns (10_000_000 100 ns intervals/s) and return return (Total_Seconds * 10_000_000); end Standard_Source; --------------- -- New_State -- --------------- function New_State (Node_ID : Node_ID_Hex; Initial_Clock_Sequence: Clock_Sequence; Initial_Timestamp : Timestamp := Standard_Source; Fail_Active : Boolean := False) return Version_1_State is Node_48_Bits: Bitfield_48; Time_High : Bitfield_12; Time_Low : Bitfield_32; Time_Mid : Bitfield_16; Clock_Low : Bitfield_8; Clock_High : Bitfield_6; begin -- Convert node_id_hex to 48 bits. This may be needed for handling an -- exception, and so is placed out here if not Hex.Valid_Hex_String (Node_Id) then raise Constraint_Error with "Node ID is not a valid hexadecimal"; end if; Node_48_Bits := Node_ID_Hex_Codec.Decode (Node_ID); return State: Version_1_State do -- Period start set to the current (initial) clock sequence State.Period_Start := Initial_Clock_Sequence; -- Masking everything other that the 6 most significant bits of -- clock_sequence for clock_seq_high and shift richt2e by 8 bits -- to keep only the 6 bits Clock_High := Bitfield_6 ((Initial_Clock_Sequence and 2#1111_1100_0000_00#) / 2**8); Clock_Low := Bitfield_8 ((Initial_Clock_Sequence and 2#0000_0011_1111_11#)); State.Last_ID.clock_seq_low := Bitfield_8 (Clock_Low); -- Insert the variant number into the clock_seq_hi_and_reserved part State.Last_ID.clock_seq_hi_and_reserved := Bitfield_8 (Clock_High) or 2#1000_0000#; ----- -- The above statements should not possibly result in an exception, -- whereas the below very well may. If Fail_Active is enabled, we can -- catch this and at least return a valid state, with a zeroed timestamp -- Get the current time as a 60-bit count of 100-nanosecond intervals -- since 00:00:00.00, 15 October 1582, and set it as the "Previous -- TS" for the state State.Base_TS := Initial_Timestamp; -- Set-up the value for "Last_ID" State.Last_ID.node := Node_48_Bits; -- Split our 60-bit full timestamp into the requisite individual -- bitfields for insertion into the actual UUID Format_Time (From_Timestamp => State.Base_TS, Time_High => Time_High, Time_Mid => Time_Mid, Time_Low => Time_Low); State.Last_ID.time_low := Time_Low; State.Last_ID.time_mid := Time_Mid; State.Last_ID.time_hi_and_version := (Bitfield_16 (Time_High)) or 16#1000#; -- RFC 4122 states that the high bit is set. exception when others => if Fail_Active then State.Last_ID.time_low := 0; State.Last_ID.time_mid := 0; State.Last_ID.time_hi_and_version := 16#1000#; else raise; end if; end return; exception when others => if Fail_Active then return Version_1_State' (Last_ID => (node => Node_48_Bits, others => <>), others => <>); else raise; end if; end New_State; --------------------- -- Extract_Node_ID -- --------------------- function Extract_Node_ID (State: Version_1_State) return Node_ID_Hex is begin return Node_ID: Node_ID_Hex do Node_ID_Hex_Codec.Encode (Value => State.Last_ID.node, Buffer => Node_ID); end return; end Extract_Node_ID; ----------------------- -- Generic_Generator -- ----------------------- function Generic_Generator (State : in out Version_1_State; Overrun: in Sequence_Overrun) return UUID is UUID_Last_Node_ID : Bitfield_48; UUID_Last_Timestamp: Timestamp; Current_Timestamp : Timestamp; Time_High : Bitfield_12; Time_Low : Bitfield_32; Time_Mid : Bitfield_16; This_Sequence : Clock_Sequence; Clock_Low : Bitfield_8; Clock_High : Bitfield_6; Overrun_Decision : Sequence_Overrun := Overrun; begin -- From the last UUID generator state read the values of: -- timestamp, clock sequence, and node ID UUID_Last_Node_ID := State.Last_ID.node; UUID_Last_Timestamp := Extract_Timestamp (State); -- Get the current time as a 60-bit count of 100-nanosecond intervals -- since 00:00:00.00, 15 October 1582 -- Get current node ID -- Extracting the last clock sequence from State, to be the assumed -- current sequence, unless we absolutely need to increment it This_Sequence := Extract_Sequence (State.Last_ID); -- An interesting problem occurs when generating Version 1 UUIDs on -- typical server hardware: the generation rate is very high, but the -- system clock tick is often not very fine-grain. -- -- We will attempt to be smart about this by synthesizing clock ticks, -- and backing off said synthesis when we find that we have outrun the -- system clock, at which point we will fall back to clock sequence -- incrementation. -- -- We achieve this by recording the last valid "Base" timestamp in the -- state, which lets us detect an actual system clock advancement. -- -- Note that for new or restored states, the "Base timestamp" is zero, -- and so we are assured that we will see a "new clock tick" this time. -- If the state was restored from an "advanced" state, then the "last" -- timestamp will be in the future, which simulates a clock overrun -- condition, and causes us to increment the clock sequence until the -- clock catches-up. This is conformant with RFC 4122. Current_Timestamp := Timestamp_Source; -- First-off, we take a look at if Current_Timestamp = State.Base_TS then -- This means the system clock has not advanced since last time we -- generated an ID. So we will therefore simply synthesize a clock -- tick, and skip to the end Current_Timestamp := UUID_Last_Timestamp + 1; -- It also marks a new clock sequence period for the state State.Period_Start := This_Sequence; else -- Otherwise, we now that we have a new clock tick. We need to decide -- if we can use it (and update State.Base_TS), or otherwise it means -- we have overrun the system clock, and we need to wait for it to -- catch up by incrementing the clock sequence. This leaves a -- possibility that we will need to implement an explicit delay and -- retry. We will put all the logic into a loop, so that we can -- appropriately handle a clock sequence overrun, should it happen. -- Note that for newly Restored states, the initial Base_TS is always -- zero, which works out perfectly by ensuring only the clock sequence -- increments until the system clock catches up loop if Current_Timestamp > UUID_Last_Timestamp then -- This means we have a new valid (advanced) timestamp, and -- we can safely use this and commit it as the new Base_TS State.Base_TS := Current_Timestamp; -- Also marks a new clock sequence period State.Period_Start := This_Sequence; exit; else -- Assume last timestamp Current_Timestamp := UUID_Last_Timestamp; -- This is the classic use-case for clock sequence -- incrementation. We are unable to increment the last used -- timestamp, and so we must make the UUID unique by changing the -- clock sequence. if (This_Sequence + 1) = State.Period_Start then -- We have an clock sequence overrun! case Overrun_Decision is when Delay_or_Error => delay (System.Tick * 2); -- This is the only delay, so next iteration, we need -- to act as if we are configured for Error on overrun Overrun_Decision := Error; when Delay_Until => delay System.Tick; when Error => raise Generation_Failed with "Clock sequence overrun"; end case; else -- Clock sequence is OK for increment This_Sequence := This_Sequence + 1; exit; end if; end if; -- If we get here, it means we are trying again (after a delay) Current_Timestamp := Timestamp_Source; end loop; end if; -- Finally, we have a valid timestamp and clock sequence with which to -- generate our new UUID -- Format a UUID from the current timestamp, clock sequence, and node Format_Time (From_Timestamp => Current_Timestamp, Time_High => Time_High, Time_Mid => Time_Mid, Time_Low => Time_Low); return Generated_UUID: UUID do -- Format time Generated_UUID.time_low := Time_Low; Generated_UUID.time_mid := Time_Mid; Generated_UUID.time_hi_and_version := (Bitfield_16 (Time_High)) or 16#1000#; -- Masking everything other that the 6 most significant bits of -- clock_sequence for clock_seq_high and shift left by 8 bits -- to keep only the 6 bits Clock_High := Bitfield_6 ((This_Sequence and 2#11_1111_0000_0000#) / 2**8); Clock_Low := Bitfield_8 (This_Sequence and 2#00_0000_1111_1111#); Generated_UUID.clock_seq_low := Bitfield_8 (Clock_Low); -- Insert the variant number into the clock_seq_hi_and_reserved part Generated_UUID.clock_seq_hi_and_reserved := Bitfield_8 (Clock_High) or 2#1000_0000#; -- Copy in the node ID Generated_UUID.node := UUID_Last_Node_ID; -- Save the id to the State State.Last_ID := Generated_UUID; end return; exception when e: others => raise Generation_Failed with "Generation raised an exception: " & Exceptions.Exception_Information (e); end Generic_Generator; --------------------- -- Local_Generator -- --------------------- package body Local_Generator is State: Version_1_State; function Generate_Actual is new Generic_Generator (Timestamp_Source); -------------- -- Generate -- -------------- function Generate (Overrun: Sequence_Overrun := Default_Overrun) return UUID is (Generate_Actual (State => State, Overrun => Overrun)); ------------------ -- Export_State -- ------------------ function Export_State (Advance: Duration := 0.0) return Version_1_State is UUID_Last_timestamp : Timestamp; Time_High : Bitfield_12; Time_Low : Bitfield_32; Time_Mid : Bitfield_16; begin -- Check for a default Advance of 0.0 if Advance = 0.0 then return State; end if; UUID_Last_Timestamp := Extract_Timestamp (State); -- Add the advance nanoseconds (10,000,000 100ns/s) UUID_Last_Timestamp := UUID_Last_Timestamp + Timestamp (Advance * 10_000_000); return Advanced_State: Version_1_State := State do -- We copy out the current State, only updating the advance -- timestamp, and clearing the Base_TS; Format_Time (From_Timestamp => UUID_Last_timestamp, Time_High => Time_High, Time_Mid => Time_Mid , Time_Low => Time_Low); Advanced_State.Last_ID.time_low := Time_Low; Advanced_State.Last_ID.time_mid := Time_Mid; -- Insert the version number of 1 into the time_hi_and_version part Advanced_State.Last_ID.time_hi_and_version := Bitfield_16 (Time_High) or 16#1000#; Advanced_State.Base_TS := 0; end return; end Export_State; ------------------ -- Import_State -- ------------------ procedure Import_State (New_State: Version_1_State) is begin State := New_State; end Import_State; end Local_Generator; ---------------------- -- Global_Generator -- ---------------------- package body Global_Generator is package Generator is new Local_Generator (Default_Overrun => Default_Overrun, Timestamp_Source => Timestamp_Source); -- Protected body from which to call The Local Generator -- Global Lock protected Protected_Generator is procedure Generate (ID: out UUID; Overrun: in Sequence_Overrun); function Export_State (Advance: duration) return Version_1_State; procedure Import_State (New_State: Version_1_State); end Protected_Generator; protected body Protected_Generator is procedure Generate (ID: out UUID; Overrun: in Sequence_Overrun) is begin ID := Generator.Generate (Overrun); end Generate; function Export_State (Advance: duration) return Version_1_State is begin return Generator.Export_State (Advance); end Export_State; procedure Import_State (New_State: Version_1_State) is begin Generator.Import_State (New_State); end Import_State; end Protected_Generator; -------------- -- Generate -- -------------- function Generate (Overrun: Sequence_Overrun := Default_Overrun) return UUID is begin return ID: UUID do Protected_Generator.Generate (ID => ID, Overrun => Overrun); end return; end Generate; ------------------ -- Export_State -- ------------------ function Export_State (Advance: Duration := 0.0) return Version_1_State is begin return ID: Version_1_State do ID := Protected_Generator.Export_State(Advance); end return; end Export_State; ------------------ -- Import_State -- ------------------ procedure Import_State (New_State: Version_1_State) is begin Protected_Generator.Import_State(New_State); end Import_State; end Global_Generator; end UUIDs.Version_1;
stcarrez/helios
Ada
3,490
adb
----------------------------------------------------------------------- -- helios-monitor-disks -- Linux disks monitor -- 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 Util.Strings.Transforms; with Helios.Tools.Files; package body Helios.Monitor.Disks is use Util.Strings.Transforms; -- ------------------------------ -- Start the agent and build the definition tree. -- ------------------------------ overriding procedure Start (Agent : in out Agent_Type; Config : in Util.Properties.Manager) is Values : constant String := Config.Get ("values", "*"); Disks : constant String := Config.Get ("partitions", "*"); Line : Helios.Tools.Files.File_Extractor; begin Line.Open ("/proc/diskstats"); Line.Name_Pos := 3; loop Line.Read; exit when Line.Is_Eof; Make_Disk (Agent, Line.Get_Value (3), Disks, Values); end loop; end Start; -- ------------------------------ -- Collect the values in the snapshot. -- ------------------------------ overriding procedure Collect (Agent : in out Agent_Type; Values : in out Datas.Snapshot_Type) is use type Schemas.Definition_Type_Access; Line : Helios.Tools.Files.File_Extractor; Node : Schemas.Definition_Type_Access; Disk : Disk_Definition_Type_Access; begin Line.Open ("/proc/diskstats"); Line.Name_Pos := 3; loop Line.Read; exit when Line.Is_Eof; Node := Agent.Find_Definition (Line.Get_Value (3)); if Node /= null then Disk := Disk_Definition_Type'Class (Node.all)'Access; for I in Disk.Stats'Range loop Values.Set_Value (Disk.Stats (I), Line.Get_Value (4 + Stat_Type'Pos (I))); end loop; end if; end loop; end Collect; -- ------------------------------ -- Make a new disk definition for the given disk name. -- ------------------------------ procedure Make_Disk (Agent : in out Agent_Type; Name : in String; Disks : in String; Filter : in String) is Disk : Disk_Definition_Type_Access; begin if not Helios.Schemas.Is_Filter_Enable (Name, Disks) then return; end if; Disk := new Disk_Definition_Type (Len => Name'Length); Disk.Name := Name; Agent.Add_Definition (Disk.all'Access); for I in Disk.Stats'Range loop Disk.Stats (I) := Schemas.Create_Definition (Disk.all'Access, To_Lower_Case (Stat_Type'Image (I)), Filter); end loop; end Make_Disk; end Helios.Monitor.Disks;
AdaCore/ada-traits-containers
Ada
2,706
adb
-- -- Copyright (C) 2016, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- pragma Ignore_Pragma (Assertion_Policy); with Conts; use Conts; with Conts.Vectors.Indefinite_Unbounded_SPARK; with Conts.Vectors.Definite_Bounded; procedure Vectors is procedure Test_Bounded; -- Test the bounded definite case procedure Test_Unbounded; -- Test the unbounded indefinite case procedure Test_Bounded is package My_Vectors is new Conts.Vectors.Definite_Bounded (Index_Type => Positive, Element_Type => Integer); use My_Vectors; V, S : Vector (200); C : Cursor; begin C := V.First; for I in 1 .. 10 loop V.Append (I); end loop; for I in 5 .. 10 loop V.Insert (10, I); end loop; V.Reserve_Capacity (20); V.Shrink_To_Fit; V.Resize (20, 0); pragma Assert (V.Length = 20); V.Resize (10, 100); pragma Assert (V.Last_Element = 10); V.Replace_Element (3, 42); V.Swap (1, 3); V.Delete (1); pragma Assert (My_Vectors.Vectors.As_Element (V, 1) = 2); V.Delete_Last; C := V.Next (V.First); C := V.Previous (C); C := V.Previous (V.First); S.Assign (V); V.Clear; V.Append (10, 40); V.Delete (V.Last - 1, 40); V.Insert (15, 10, 40); V.Delete (15, 40); for E of S loop pragma Assert (E in 1 .. 10); end loop; end Test_Bounded; procedure Test_Unbounded is package My_Vectors is new Conts.Vectors.Indefinite_Unbounded_SPARK (Index_Type => Positive, Element_Type => Integer); use My_Vectors; V : Vector; S : Vector; C : Cursor; begin C := V.First; for I in 1 .. 10 loop V.Append (I); end loop; for I in 5 .. 10 loop V.Insert (10, I); end loop; V.Reserve_Capacity (20); V.Shrink_To_Fit; V.Resize (20, 0); pragma Assert (V.Length = 20); V.Resize (10, 100); pragma Assert (V.Last_Element = 10); V.Replace_Element (3, 42); V.Swap (1, 3); V.Delete (1); pragma Assert (My_Vectors.Vectors.As_Element (V, 1) = 2); V.Delete_Last; C := V.Next (V.First); C := V.Previous (C); C := V.Previous (V.First); S.Assign (V); V.Clear; V.Append (10, 40); V.Delete (V.Last - 1, 40); V.Insert (15, 10, 40); V.Delete (15, 40); for E of S loop pragma Assert (E in 1 .. 10); end loop; end Test_Unbounded; begin Test_Unbounded; Test_Bounded; end Vectors;
AdaCore/gpr
Ada
9,258
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Containers; use Ada.Containers; with Ada.Containers.Hashed_Maps; with Ada.Unchecked_Deallocation; with System; with GNATCOLL.Traces; with Gpr_Parser_Support.Hashes; use Gpr_Parser_Support.Hashes; with Gpr_Parser_Support.Types; use Gpr_Parser_Support.Types; with Gpr_Parser_Support.Vectors; package Gpr_Parser_Support.Lexical_Envs is type Lookup_Cache_Kind is (Disabled, Toplevel_Only, Full); Lookup_Cache_Mode : Lookup_Cache_Kind := Full; -- Lookup cache mode for the lexical envs. -- -- ``Full`` means that every env.get request, including intermediate ones -- happening as part of a user requested env.get, will be cached. -- -- ``Toplevel_Only`` means that only top level requests, directly requested -- by the user of the Lexical_Envs API, will be cached. -- -- ``Disabled`` means no caching will happen. -- -- This setting is for debugging: caching all requests is the normal mode -- (maximum optimization), and the other modes reduce the amount of caching -- done (less optimization, thus taking longer to run) to ease the -- investigation of env caching bugs. ------------- -- Traces -- ------------- -- Traces to debug lexical envs. Those traces are meant to be activated on -- demand, when the client of lexical env wants more information about -- this specific lookup. Me : constant GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create ("LANGKIT.LEXICAL_ENV", GNATCOLL.Traces.From_Config); -- This is the main trace for lexical environments, providing a basic level -- of logging for env.get requests. Rec : constant GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create ("LANGKIT.LEXICAL_ENV.RECURSIVE", GNATCOLL.Traces.From_Config); -- This is the recursive trace, providing info about recursive internal -- calls to env.get. Caches_Trace : constant GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create ("LANGKIT.LEXICAL_ENV.CACHES", GNATCOLL.Traces.From_Config); -- This a trace to show caching information Min : constant GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create ("LANGKIT.LEXICAL_ENV_MINIMAL", GNATCOLL.Traces.From_Config); -- This is a trace independent from the three last traces, that you can -- activate separately, and that will provide you the most basic level of -- logging for toplevel env.get requests. function Has_Trace return Boolean is (Me.Active); ----------------- -- Lexical_Env -- ----------------- type Lexical_Env_Kind is (Static_Primary, Dynamic_Primary, Orphaned, Grouped, Rebound); -- Kind of lexical environment. Tells how a lexical environment was -- created. -- -- Static_Primary ones are not ref-counted. Except for the special -- Empty_Env and each context's root scope, they are created by lexical -- environment population. -- -- Dynamic_Primary are not ref-counted neither. They are created on-demand -- during semantic analysis, but their life cycle is tied to their owning -- analysis unit, just like Static_Primary envs. They carry no map, but -- instead use a property reference to dynamically compute environment -- associations (an array of Inner_Env_Assoc). -- -- Orphaned ones are copies whose parents have been stripped. -- -- Grouped ones are just a collection of environments glued together as if -- they were only one environment. -- -- Rebound ones are copies annotated with environment rebindings. subtype Primary_Kind is Lexical_Env_Kind range Static_Primary .. Dynamic_Primary; type Base_Lexical_Env_Record is abstract tagged null record; -- Root class of the lexical env type for all languages type Generic_Lexical_Env_Ptr is access all Base_Lexical_Env_Record'Class; -- Generic access to lexical environment records. The actual record type -- depends on each language, hence the generic pointer. No_Lexical_Env : constant Generic_Lexical_Env_Ptr := null; type Generic_Unit_Ptr is new System.Address; -- Likewise for analysis units No_Generic_Unit : constant Generic_Unit_Ptr := Generic_Unit_Ptr (System.Null_Address); type Lexical_Env is record Env : Generic_Lexical_Env_Ptr; -- Referenced lexical environment Hash : Hash_Type; -- Env's hash. We need to pre-compute it so that the value is available -- even after Env is deallocated. This makes it possible to destroy a -- hash table that contains references to deallocated environments. Kind : Lexical_Env_Kind; -- The kind of Env. When it is Primary, we can avoid calling Dec_Ref at -- destruction time. This is useful because at analysis unit destruction -- time, this may be a dangling access to an environment from another -- unit. Owner : Generic_Unit_Ptr := No_Generic_Unit; -- Unit that owns this lexical environment. Only Primary and Rebound -- lexical env will have a non-null value for this field. Version : Version_Number := 0; -- Version of the unit when this reference was made. Used to determine -- whether this reference is valid or not. end record; -- Reference to a lexical environment. This is the type that shall be used. Null_Lexical_Env : constant Lexical_Env := (No_Lexical_Env, 0, Static_Primary, No_Generic_Unit, 0); type Lexical_Env_Array is array (Positive range <>) of Lexical_Env; type Lexical_Env_Array_Access is access all Lexical_Env_Array; procedure Destroy is new Ada.Unchecked_Deallocation (Lexical_Env_Array, Lexical_Env_Array_Access); function Is_Primary (Self : Lexical_Env) return Boolean is (Self.Kind in Primary_Kind); -- Return whether Self is a primary lexical environment function Has_Lookup_Cache (Self : Lexical_Env) return Boolean is (Self.Kind = Static_Primary); -- Whether lookup cache is available/enabled for the given lexical -- environment. function Hash (Env : Lexical_Env) return Hash_Type is (Env.Hash); type Lookup_Kind_Type is (Recursive, Flat, Minimal); -------------------- -- Env_Rebindings -- -------------------- type Env_Rebindings_Type; type Env_Rebindings is access all Env_Rebindings_Type; -- Set of mappings from one lexical environment to another. This is used to -- temporarily substitute lexical environment during symbol lookup. package Env_Rebindings_Vectors is new Gpr_Parser_Support.Vectors (Env_Rebindings); type Env_Rebindings_Type is record -- Start of ABI area. In order to perform fast checks from foreign -- languages, we maintain minimal ABI for env rebindings records: this -- allows us in language bindings to directly peek in this record rather -- than rely on (slow) calls to getters. Version : Version_Number; -- Allocated Env_Rebindings_Type records can be used multiple times -- for a given analysis context. Each time we re-use one, we bump its -- version number, so that we can reject the use of stale references. -- End of ABI area Parent : Env_Rebindings; Old_Env, New_Env : Lexical_Env; Children : Env_Rebindings_Vectors.Vector; end record with Convention => C; -- Tree of remappings from one lexical environment (Old_Env) to another -- (New_Env). Note that both referenced environments must be primary and -- env rebindings are supposed to be destroyed when one of their -- dependencies (Parent, Old_Env or New_Env) is destroyed, so there is no -- need for ref-counting primitives. function Hash is new Hashes.Hash_Access (Env_Rebindings_Type, Env_Rebindings); package Env_Rebindings_Pools is new Ada.Containers.Hashed_Maps (Key_Type => Lexical_Env, Element_Type => Env_Rebindings, Hash => Hash, Equivalent_Keys => "=", "=" => "="); type Env_Rebindings_Pool is access all Env_Rebindings_Pools.Map; -- Pool of env rebindings to be stored in a lexical environment procedure Destroy is new Ada.Unchecked_Deallocation (Env_Rebindings_Pools.Map, Env_Rebindings_Pool); ----------------------------- -- Referenced environments -- ----------------------------- type Ref_Kind is (Transitive, Prioritary, Normal); -- Kind for a referenced env. Can be any of: -- -- * Transitive: The reference is transitive, e.g. it will be explored in -- every case (whether the lookup is recursive or not). It will be -- explored *before* parent environments. -- -- * Prioritary: The reference is non transitive, e.g. it will be -- explored only if the lookup on the env is recursive. It will be -- explored *before* parent environments. -- -- * Normal: The reference is non transitive, e.g. it will be explored -- only if the lookup on the env is recursive. It will be explored -- *after* parent environments. type Refd_Env_State is (Active, Inactive); end Gpr_Parser_Support.Lexical_Envs;
reznikmm/matreshka
Ada
3,657
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.Standard_Profile_L2.Realizations.Hash is new AMF.Elements.Generic_Hash (Standard_Profile_L2_Realization, Standard_Profile_L2_Realization_Access);
RREE/ada-util
Ada
2,243
ads
-- Generated by utildgen.c from system includes with Interfaces.C; package Util.Systems.Types is subtype dev_t is Long_Long_Integer; subtype ino_t is Interfaces.C.unsigned; subtype off_t is Interfaces.C.int; subtype blksize_t is Interfaces.C.int; subtype blkcnt_t is Interfaces.C.int; subtype uid_t is Interfaces.C.unsigned; subtype gid_t is Interfaces.C.unsigned; subtype nlink_t is Interfaces.C.unsigned; subtype mode_t is Interfaces.C.unsigned; S_IFMT : constant mode_t := 8#00170000#; S_IFDIR : constant mode_t := 8#00040000#; S_IFCHR : constant mode_t := 8#00020000#; S_IFBLK : constant mode_t := 8#00060000#; S_IFREG : constant mode_t := 8#00100000#; S_IFIFO : constant mode_t := 8#00010000#; S_IFLNK : constant mode_t := 8#00120000#; S_IFSOCK : constant mode_t := 8#00140000#; S_ISUID : constant mode_t := 8#00004000#; S_ISGID : constant mode_t := 8#00002000#; S_IREAD : constant mode_t := 8#00000400#; S_IWRITE : constant mode_t := 8#00000200#; S_IEXEC : constant mode_t := 8#00000100#; type File_Type is new Interfaces.C.int; subtype Time_Type is Interfaces.C.unsigned; type Timespec is record tv_sec : Time_Type; tv_nsec : Interfaces.C.int; end record; pragma Convention (C_Pass_By_Copy, Timespec); type Seek_Mode is (SEEK_SET, SEEK_CUR, SEEK_END); for Seek_Mode use (SEEK_SET => 0, SEEK_CUR => 1, SEEK_END => 2); STAT_NAME : constant String := "stat"; FSTAT_NAME : constant String := "fstat"; type Stat_Type is record st_dev : dev_t; pad1 : Interfaces.C.unsigned_short; st_ino : ino_t; st_mode : mode_t; st_nlink : nlink_t; st_uid : uid_t; st_gid : gid_t; st_rdev : dev_t; pad2 : Interfaces.C.unsigned_short; st_size : off_t; st_blksize : blksize_t; st_blocks : blkcnt_t; pad3_1 : Interfaces.C.unsigned_long; st_atim : Timespec; st_mtim : Timespec; st_ctim : Timespec; pad3 : Interfaces.C.unsigned_long; pad4 : Interfaces.C.unsigned_long; end record; pragma Convention (C_Pass_By_Copy, Stat_Type); end Util.Systems.Types;
kjseefried/coreland-cgbc
Ada
917
adb
with Ada.Strings; with CGBC.Bounded_Wide_Wide_Strings; with Test; procedure T_WWBstr_Append_LB02 is package BS renames CGBC.Bounded_Wide_Wide_Strings; TC : Test.Context_t; S1 : BS.Bounded_String (8); S : constant Wide_Wide_String := " H"; begin Test.Initialize (Test_Context => TC, Program => "t_wwbstr_append_lb02", Test_DB => "TEST_DB", Test_Results => "TEST_RESULTS"); BS.Append (S1, "ABCDEFG"); -- As Append_L02 but with unusual bounds on New_Item. pragma Assert (S (10 .. 10) = "H"); BS.Append (Source => S1, New_Item => S (10 .. 10), Drop => Ada.Strings.Left); Test.Check (TC, 2221, BS.Length (S1) = 8, "BS.Length (S1) = 8"); Test.Check (TC, 2222, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8"); Test.Check (TC, 2223, BS.To_String (S1) = "ABCDEFGH", "BS.To_String (S1) = ""ABCDEFGH"""); end T_WWBstr_Append_LB02;
annexi-strayline/AURA
Ada
4,639
adb
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ separate (Specification_Scanner) procedure Scan_Generic (Buffer : in out Ada_Lexical_Parser.Source_Buffer; Unit_Tree: in out Declaration_Trees.Tree; Root : in Declaration_Trees.Cursor) is use Ada_Lexical_Parser; use Declaration_Trees; package Toolkit is new Parse_Toolkit (Buffer); use Toolkit; use type WWU.Unbounded_Wide_Wide_String; begin Unit_Tree(Root).Is_Generic := True; -- Try to keep this as simple as possible, for now we really don't need -- this information to generate the configuration extractor programs. loop Skip_To_Semicolon; Next_Element; exit when Category = Reserved_Word and then Content in "package" | "procedure" | "function"; end loop; if Content = "package" then Scan_Specification (Buffer => Buffer, Unit_Tree => Unit_Tree, Root => Root); elsif Content in "procedure" | "function" then Scan_Subprogram (Buffer => Buffer, Unit_Tree => Unit_Tree, Subprogram_Node => Root); end if; end Scan_Generic;
io7m/coreland-lua-ada-load
Ada
463
adb
with Ada.Text_IO; with Test; procedure test0006 is package IO renames Ada.Text_IO; begin Test.Init ("test0006.lua"); begin Test.Load.Table_Start (Test.Loader_Access, "y"); exception when Test.Load.Load_Error => IO.Put_Line (Test.Load.Error_String (Test.Loader_Access)); end; exception when Test.Load.Load_Error => IO.Put_Line ("fail: " & Test.Load.Error_String (Test.Loader_Access)); raise Test.Load.Load_Error; end test0006;
reznikmm/matreshka
Ada
4,600
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.Operator_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Operator_Attribute_Node is begin return Self : Table_Operator_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_Operator_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Operator_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Operator_Attribute, Table_Operator_Attribute_Node'Tag); end Matreshka.ODF_Table.Operator_Attributes;
zhmu/ananas
Ada
77
ads
---- package Predicate2.Project.Registry is end Predicate2.Project.Registry;
stcarrez/ada-ado
Ada
1,804
ads
----------------------------------------------------------------------- -- ado-c -- Support for driver implementation -- Copyright (C) 2009, 2010, 2011, 2012, 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 Interfaces.C; with Interfaces.C.Strings; with Ada.Finalization; with Ada.Unchecked_Conversion; with System; package ADO.C is type String_Ptr is limited private; -- Convert a string to a C string. function To_String_Ptr (S : String) return String_Ptr; -- Get the C string pointer. function To_C (S : String_Ptr) return Interfaces.C.Strings.chars_ptr; -- Set the string procedure Set_String (S : in out String_Ptr; Value : in String); function To_chars_ptr is new Ada.Unchecked_Conversion (System.Address, Interfaces.C.Strings.chars_ptr); private use Interfaces.C; type String_Ptr is new Ada.Finalization.Limited_Controlled with record Ptr : Strings.chars_ptr := Interfaces.C.Strings.Null_Ptr; end record; -- Reclaim the storage held by the C string. overriding procedure Finalize (S : in out String_Ptr); end ADO.C;
charlie5/cBound
Ada
2,178
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with Interfaces.C.Strings; with Interfaces.C; with Interfaces.C.Pointers; with Interfaces.C.Strings; with System; package clib.lconv is -- Item -- type Item is record decimal_point : aliased Interfaces.C.Strings.chars_ptr; thousands_sep : aliased Interfaces.C.Strings.chars_ptr; grouping : aliased Interfaces.C.Strings.chars_ptr; int_curr_symbol : aliased Interfaces.C.Strings.chars_ptr; currency_symbol : aliased Interfaces.C.Strings.chars_ptr; mon_decimal_point : aliased Interfaces.C.Strings.chars_ptr; mon_thousands_sep : aliased Interfaces.C.Strings.chars_ptr; mon_grouping : aliased Interfaces.C.Strings.chars_ptr; positive_sign : aliased Interfaces.C.Strings.chars_ptr; negative_sign : aliased Interfaces.C.Strings.chars_ptr; int_frac_digits : aliased Interfaces.C.char; frac_digits : aliased Interfaces.C.char; p_cs_precedes : aliased Interfaces.C.char; p_sep_by_space : aliased Interfaces.C.char; n_cs_precedes : aliased Interfaces.C.char; n_sep_by_space : aliased Interfaces.C.char; p_sign_posn : aliased Interfaces.C.char; n_sign_posn : aliased Interfaces.C.char; a_a_int_p_cs_precedes : aliased Interfaces.C.char; a_a_int_p_sep_by_space : aliased Interfaces.C.char; a_a_int_n_cs_precedes : aliased Interfaces.C.char; a_a_int_n_sep_by_space : aliased Interfaces.C.char; a_a_int_p_sign_posn : aliased Interfaces.C.char; a_a_int_n_sign_posn : aliased Interfaces.C.char; end record; -- Items -- type Items is array (Interfaces.C.size_t range <>) of aliased clib.lconv.Item; -- Pointer -- type Pointer is access all clib.lconv.Item; -- Pointers -- type Pointers is array (Interfaces.C.size_t range <>) of aliased clib.lconv.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all clib.lconv.Pointer; end clib.lconv;
reznikmm/matreshka
Ada
3,633
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.CMOF.Behavioral_Features.Hash is new AMF.Elements.Generic_Hash (CMOF_Behavioral_Feature, CMOF_Behavioral_Feature_Access);
reznikmm/matreshka
Ada
4,615
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Use_Caption_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Use_Caption_Attribute_Node is begin return Self : Text_Use_Caption_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Use_Caption_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Use_Caption_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Use_Caption_Attribute, Text_Use_Caption_Attribute_Node'Tag); end Matreshka.ODF_Text.Use_Caption_Attributes;
VMika/DES_Ada
Ada
4,846
adb
with P_StructuralTypes; use P_StructuralTypes; with Ada.Text_IO; use Ada.Text_IO; with Ada.Sequential_IO; with Ada.Strings.Unbounded.Text_IO; with Ada.Streams; use Ada.Streams; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; package body P_StepHandler.InputHandler is ------------------------------------------------------------------------- ------------------------- CONSTRUCTOR ----------------------------------- ------------------------------------------------------------------------- function Make (Self : in out InputHandler; File_Name : in Unbounded_String) return InputHandler is package Char_IO is new Ada.Sequential_IO (Character); use Char_IO; Input_File : Char_IO.File_Type; count : Integer := 0; Buffer : Character; begin Self.Input_Name := File_Name; Open (Input_File, In_File, To_String(Self.Input_Name)); while not (End_Of_File(Input_File)) loop count := count + 1; Char_IO.Read (File => Input_File, Item => Buffer); end loop; Close (Input_File); Self.Set_Input_Length(count); if count mod 8 = 0 then Self.Set_Input_Size(count / 8); else Self.Set_Input_Size(count / 8 + 1); end if; if Self.Input_Length mod 8 /= 0 then Self.PaddingBitsNumber := 64 - (8 * (Self.Input_Length mod 8)); else Self.PaddingBitsNumber := 0; end if; return Self; end; --------------------------------------------------------------- --- HANDLE PROCEDURE : OVERRIDEN FROM PARENT ABSTRACT CLASS --- --------------------------------------------------------------- overriding procedure Handle (Self : in out InputHandler) is package Char_IO is new Ada.Sequential_IO (Character); use Char_IO; Input : Char_IO.File_Type; Buffer : Character; TextStream : Unbounded_String; TmpBlock : T_BinaryBlock; Index : Integer := 1; begin ------------------------------------------------------------------------- -- This handler has two tasks : -- => Loop through the text to define where blocks start and stop -- => Convert these blocks into binary values and putting them in the -- array containing the whole text in BinaryBlock form ------------------------------------------------------------------------- -- We're using an unbound string to add character as we read the file -- We initialize it at null value TextStream := Null_Unbounded_String; -- Opening the input file Open (Input, In_File, To_String(Self.Input_Name)); -- As long as there is a character in the file while not (End_Of_File(Input)) loop -- Reading the character and putting it in the TextBlock Char_IO.Read (File => Input, Item => Buffer); TextStream := TextStream & Buffer; -- If the block is full (ie 8 characters) we're calling the method -- to convert the Unbound_String to Binary and emptying the TextBlock if Length (TextStream) = 8 then TmpBlock := TextBlock_To_Binary(To_String(TextStream)); Replace_Block(Self.Get_BinaryContainer,Index,TmpBlock); Index := Index + 1; TextStream := Null_Unbounded_String; end if; end loop; if Length (TextStream) /= 0 then -- We're calling the conversion function a last time if there is uncon- -- verted text (shall only happen if the size of the raw text mod 8 is -- not 0) to convert the remaining text TmpBlock := TextBlock_To_Binary(To_String(TextStream)); Replace_Block(Self.Get_BinaryContainer,Index,TmpBlock); end if; -- Closing the ressource Close (Input); if Self.NextHandler /= null then Self.NextHandler.Handle; end if; end; --------------------------------------------------------------- ------------------------- GETTER ---------------------------- --------------------------------------------------------------- function Get_Input_Size (Self : in InputHandler) return Integer is begin return Self.Input_Size; end; function Get_PaddingBitsNumber (Self : in InputHandler) return Integer is begin return Self.PaddingBitsNumber; end; procedure Set_Input_Length (Self : in out InputHandler; Length : in Integer) is begin Self.Input_Length := Length; end; procedure Set_Input_Size (Self : in out InputHandler; Size : in Integer) is begin Self.Input_Size := Size; end; end P_StepHandler.InputHandler;
reznikmm/matreshka
Ada
3,759
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.Text_Use_Floating_Frames_Attributes is pragma Preelaborate; type ODF_Text_Use_Floating_Frames_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Use_Floating_Frames_Attribute_Access is access all ODF_Text_Use_Floating_Frames_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Use_Floating_Frames_Attributes;
BrickBot/Bound-T-H8-300
Ada
44,138
adb
-- Options (body) -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.141 $ -- $Date: 2015/10/27 22:34:32 $ -- -- $Log: options.adb,v $ -- Revision 1.141 2015/10/27 22:34:32 niklas -- Use Value_Image, not 'Image, for enumerating discrete option values. -- -- Revision 1.140 2015/10/25 19:03:41 niklas -- Added procedure Set_Option, which also calls When_Set. -- -- Revision 1.139 2015/10/24 20:05:50 niklas -- Moved to free licence. -- -- Revision 1.138 2014/06/01 10:28:21 niklas -- Added the Refused exception to signal serious errors -- in option values. -- Added the image function Modular_Valued.Type_Alone for -- better display of certain option values. -- - -- -- Revision 1.137 2012-02-12 14:13:19 niklas -- Added Integer_Valued.Type_Alone, for BT-CH-0229. -- -- Revision 1.136 2012-01-19 21:33:36 niklas -- Added Base parameter to Integer_Valued. -- Added Modular_Valued, also with Base parameter. -- -- Revision 1.135 2011-09-06 17:40:58 niklas -- Added "lib" as a default help directory. -- -- Revision 1.134 2011-09-01 21:29:53 niklas -- Changed the image of a Discret_Set_Valued option, when an empty -- set, from "" to "empty by default". -- -- Revision 1.133 2011-08-31 04:23:34 niklas -- BT-CH-0222: Option registry. Option -dump. External help files. -- with Ada.Text_IO; with Ada.Characters.Handling; with Ada.Command_Line; with Ada.Environment_Variables; with Ada.Strings; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; with File_System; with Topo_Sort; package body Options is use type Group_Name_T; function Trim (Item : String) return String is begin return Ada.Strings.Fixed.Trim (Item, Ada.Strings.Both); end Trim; -- --- Option-value enumerators -- overriding function Current_Value (Enum : Not_Enumerable_T) return String is begin return ""; end Current_Value; overriding procedure Next ( Enum : in out Not_Enumerable_T; Ended : out Boolean) is begin Ended := True; end Next; -- --- Option objects -- function Enumerator (Option : Option_T) return Enumerator_T'Class is begin return Not_Enumerable; end Enumerator; -- --- Common functions -- function To_Internal (Value : String) return String -- -- Removes all leading and trailing blanks and hyphens from Value, and -- replaces in the remainder all embedded strings of spaces or hyphens -- with single underscores. -- -- This converts the external (user-written) form of an option value -- to its internal (Ada enumeration literal) form. -- is Result : String (1 .. Value'Length); Last : Natural := 0; -- The result is Result(1 .. Last). begin for V in Value'Range loop case Value(V) is when ' ' | '-' => if Last > 0 and then Result(Last) /= ' ' then -- The first space or hyphen in an embedded (or trailing) -- string of spaces or hyphens. Last := Last + 1; Result(Last) := ' '; -- Will later be replaced by '_', or deleted. end if; when others => if Last > 0 and then Result(Last) = ' ' then -- The first non-space, non-hyphen character after -- an embedded string of spaces and hyphens. Result(Last) := '_'; end if; Last := Last + 1; Result(Last) := Value(V); end case; end loop; if Last > 0 and then Result(Last) = ' ' then -- This represents a trailing sequence of spaces and hyphens, -- to be ignored. Last := Last - 1; end if; return Result(1 .. Last); end To_Internal; Item_Suffix : constant String := "_item"; -- -- A suffix that may be present in the Ada enumeration literals -- for option values. This is necessary if the literal would -- otherwise be an Ada reserved word. function To_External (Value : String) return String -- -- Converts the Value to lower-case and then removes a -- possible trailing Item_Suffix. -- -- This converts the internal (Ada enumeration literal) form -- of an option value to its (canonical) external form. -- is use Ada.Characters.Handling; Result : String (1 .. Value'Length) := To_Lower (Value); -- The Value in lower-case letters. Suffix_Start : constant Integer := Result'Last - Item_Suffix'Length + 1; -- The starting index in Result of a possible Item_Suffix. begin if Suffix_Start >= Result'First and then Result(Suffix_Start .. Result'Last) = Item_Suffix then -- There is a suffix, so we remove it: return Result(1 .. Suffix_Start - 1); else -- No suffix. return Result; end if; end To_External; -- Generic discrete-valued options function Discrete_Image (Item : String) return String is Low_Item : constant String := Ada.Characters.Handling.To_Lower (Item); -- The item in lowercase letters. begin if Low_Item'Length >= 5 and then Low_Item(Low_Item'Last - 4 .. Low_Item'Last) = "_item" then return Low_Item(Low_Item'First .. Low_Item'Last - 5); else return Low_Item; end if; end Discrete_Image; function Quoted ( Item : String; Quote : Boolean) return String -- -- Possible Quote the given Item. -- is begin if Quote then return '"' & Item & '"'; else return Item; end if; end Quoted; package body Discrete_Valued is function Image (Item : Value_Type) return String is begin if Use_Discrete_Image then return Discrete_Image (Value_Image (Item)); else return Value_Image (Item); end if; end Image; overriding function Type_And_Default (Option : access Option_T) return String is begin return Value_Type_Description & ", default " & Image (Option.Default); end Type_And_Default; overriding procedure Reset (Option : access Option_T) is begin Option.Value := Option.Default; end Reset; overriding procedure Set ( Option : access Option_T; Value : in String) is Can_Value : constant String := To_Internal (Value); begin Option.Value := Value_Type'Value (Can_Value); exception when Constraint_Error => Option.Value := Value_Type'Value (Can_Value & "_Item"); end Set; overriding function Enumerator (Option : Option_T) return Enumerator_T'Class is begin if Option.Enumerable then return Enumerator_T'Class (Enum_T'(Current => Value_Type'First)); else return Not_Enumerable; end if; end Enumerator; overriding function Current_Value (Enum : Enum_T) return String is begin return To_External (Image (Enum.Current)); end Current_Value; overriding procedure Next (Enum : in out Enum_T; Ended : out Boolean) is begin Ended := Enum.Current = Value_Type'Last; if not Ended then Enum.Current := Value_Type'Succ (Enum.Current); end if; end Next; end Discrete_Valued; package body Discrete_Set_Valued is function Image (Item : Item_Type) return String -- -- The Item_Image, perhaps thru Discrete_Image. -- is begin if Use_Discrete_Image then return Discrete_Image (Item_Image (Item)); else return Item_Image (Item); end if; end Image; function Image (Set : Set_Type) return String -- -- The images of the items in the Set, separated by commas. -- is use Ada.Strings.Unbounded; Result : Unbounded_String; -- The result to be, initially null. begin for I in Item_Type loop if Set(I) then if Length (Result) > 0 then Append (Result, ','); end if; Append (Result, Image (I)); end if; end loop; return To_String (Result); end Image; overriding function Type_And_Default (Option : access Option_T) return String is Default_Items : constant String := Image (Option.Default); -- The images of the items in the default set, -- separated by commas. begin if Default_Items'Length > 0 then return Value_Type_Description & ", default " & Quoted (Default_Items, Quote_Image); else return Value_Type_Description & ", empty by default"; end if; end Type_And_Default; overriding procedure Reset (Option : access Option_T) is begin Option.Value := Option.Default; end Reset; procedure Update ( Option : access Option_T; Literal : in String; Member : in Boolean) is Item : Item_Type; -- The item identified by the literal. begin begin Item := Item_Type'Value (Literal); exception when Constraint_Error => Item := Item_Type'Value (Literal & "_Item"); end; Option.Value(Item) := Member; end Update; overriding procedure Set ( Option : access Option_T; Value : in String) is Can_Value : constant String := To_Internal (Value); First : Positive := Can_Value'First; Comma : Natural; -- One of the "item" literals is Can_Value(First .. Comma - 1), -- perhaps with a "no_" prefix and without an "_Item" suffix. begin while First <= Can_Value'Last loop Comma := First; while Comma <= Can_Value'Last and then Can_Value(Comma) /= ',' loop Comma := Comma + 1; end loop; if First + 2 < Comma and then Can_Value(First .. First + 2) = "no_" then -- An item to be removed from the option value. Update ( Option => Option_Class_Ref (Option), Literal => Can_Value(First + 3 .. Comma - 1), Member => False); elsif First < Comma then -- An item to be added to the option value. Update ( Option => Option_Class_Ref (Option), Literal => Can_Value(First .. Comma - 1), Member => True); -- else -- Two consecutive commas, or a comma at the start -- of Can_Value. Ignore it. end if; First := Comma + 1; end loop; end Set; overriding function Enumerator (Option : Option_T) return Enumerator_T'Class is begin if Option.Enumerable then return Enumerator_T'Class (Enum_T'(Current => Item_Type'First)); else return Not_Enumerable; end if; end Enumerator; overriding function Current_Value (Enum : Enum_T) return String is begin return To_External (Image (Enum.Current)); end Current_Value; overriding procedure Next (Enum : in out Enum_T; Ended : out Boolean) is begin Ended := Enum.Current = Item_Type'Last; if not Ended then Enum.Current := Item_Type'Succ (Enum.Current); end if; end Next; end Discrete_Set_Valued; Base_Digits : constant array (Natural range 0 .. 15) of Character := "0123456789abcdef"; -- -- Numerical digits for bases up to 16. package body Integer_Valued is function Image (Item : Value_Type) return String is begin if Base = 10 then return Trim (Value_Type'Image (Item)); elsif Item < 0 then return '-' & Image (abs Item); elsif Item < Value_Type'Base (Base) then return (1 => Base_Digits(Natural (Item))); else return Image (Item / Value_Type (Base)) & Base_Digits(Natural (Item mod Value_Type (Base))); end if; end Image; function Type_Alone (Option : access Option_T) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; -- The result, constructed piece by piece. Low_Bound, High_Bound : Boolean; -- Whether Value_Type is constrained on its low/high -- end with respect to its base type. begin Append (Result, "Integer"); Low_Bound := Value_Type'First /= Value_Type'Base'First; High_Bound := Value_Type'Last /= Value_Type'Base'Last ; if Low_Bound and High_Bound then -- The type is constrained at both ends. Append (Result, ' ' & Image (Value_Type'First) & " .. " & Image (Value_Type'Last )); elsif Low_Bound then -- Only the lower bound is constrained. Append (Result, " >= " & Image (Value_Type'First)); elsif High_Bound then -- Only the upper bound is constrained. Append (Result, " <= " & Image (Value_Type'Last)); end if; if Base /= 10 then Append (Result, ", base" & Number_Base_T'Image (Base)); end if; return To_String (Result); end Type_Alone; overriding function Type_And_Default (Option : access Option_T) return String is begin return Type_Alone (Option) & ", default " & Image (Option.Default); end Type_And_Default; overriding procedure Reset (Option : access Option_T) is begin Option.Value := Option.Default; end Reset; overriding procedure Set ( Option : access Option_T; Value : in String) is begin if Base = 10 then Option.Value := Value_Type'Value (Value); else Option.Value := Value_Type'Value ( Trim (Number_Base_T'Image (Base)) & '#' & Value & '#'); end if; end Set; end Integer_Valued; package body Modular_Valued is function Image (Item : Value_Type) return String is begin if Base = 10 then return Trim (Value_Type'Image (Item)); elsif Item < 0 then return '-' & Image (abs Item); elsif Item < Value_Type'Base (Base) then return (1 => Base_Digits(Natural (Item))); else return Image (Item / Value_Type (Base)) & Base_Digits(Natural (Item mod Value_Type (Base))); end if; end Image; function Type_Alone (Option : access Option_T) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; -- The result, constructed piece by piece. Low_Bound, High_Bound : Boolean; -- Whether Value_Type is constrained on its low/high -- end with respect to its base type. begin Append (Result, "Unsigned integer"); Low_Bound := Value_Type'First /= Value_Type'Base'First; High_Bound := Value_Type'Last /= Value_Type'Base'Last ; if Low_Bound and High_Bound then -- The type is constrained at both ends. Append (Result, ' ' & Image (Value_Type'First) & " .. " & Image (Value_Type'Last )); elsif Low_Bound then -- Only the lower bound is constrained. Append (Result, " >= " & Image (Value_Type'First)); elsif High_Bound then -- Only the upper bound is constrained. Append (Result, " <= " & Image (Value_Type'Last)); end if; if Base /= 10 then Append (Result, ", base" & Number_Base_T'Image (Base)); end if; return To_String (Result); end Type_Alone; overriding function Type_And_Default (Option : access Option_T) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; -- The result, constructed piece by piece. Low_Bound, High_Bound : Boolean; -- Whether Value_Type is constrained on its low/high -- end with respect to its base type. begin Append (Result, "Integer"); Low_Bound := Value_Type'First /= Value_Type'Base'First; High_Bound := Value_Type'Last /= Value_Type'Base'Last ; if Low_Bound and High_Bound then -- The type is constrained at both ends. Append (Result, ' ' & Image (Value_Type'First) & " .. " & Image (Value_Type'Last )); elsif Low_Bound then -- Only the lower bound is constrained. Append (Result, " >= " & Image (Value_Type'First)); elsif High_Bound then -- Only the upper bound is constrained. Append (Result, " <= " & Image (Value_Type'Last)); end if; if Base /= 10 then Append (Result, ", base" & Number_Base_T'Image (Base)); end if; Append (Result, ", default " & Image (Option.Default)); return To_String (Result); end Type_And_Default; overriding procedure Reset (Option : access Option_T) is begin Option.Value := Option.Default; end Reset; overriding procedure Set ( Option : access Option_T; Value : in String) is begin if Base = 10 then Option.Value := Value_Type'Value (Value); else Option.Value := Value_Type'Value ( Trim (Number_Base_T'Image (Base)) & '#' & Value & '#'); end if; end Set; end Modular_Valued; package body Valued is function Default (Value : Value_Type) return Option_T is begin return (Default => Value, Value => Value); end Default; overriding function Type_And_Default (Option : access Option_T) return String is begin return Value_Type_Description & ", default " & Image (Option.Default); end Type_And_Default; overriding procedure Reset (Option : access Option_T) is begin Option.Value := Option.Default; end Reset; overriding procedure Set ( Option : access Option_T; Value : in String) is begin Option.Value := Valued.Value (Value); end Set; end Valued; -- --- Option groups -- function Group (S : String) return Group_Name_T is begin return String_Pool.To_Item (S); end Group; function Name_Of (Group : Group_T) return Group_Name_T is begin return Group.Name; end Name_Of; function Name_Of (Group : Group_T) return String is begin return String_Pool.To_String (Group.Name); end Name_Of; function Name_Of (Group : Group_Index_T) return String is begin return String_Pool.To_String (Group_Table(Group).Name); end Name_Of; function Names_Group (Name : String) return Boolean is Group_Name : constant Group_Name_T := Group (Name); -- The given Name, formatted as an option-group name. begin for G in First_Group .. Last_Group loop if Group_Name_T'(Name_Of (Group_Table(G))) = Group_Name then return True; end if; end loop; return False; end Names_Group; procedure Find_Group ( Name : in String; Found : out Boolean; Group : out Group_T) is Group_Name : constant Group_Name_T := Options.Group (Name); -- The given Name, formatted as an option-group name. begin Found := False; for G in First_Group .. Last_Group loop if Group_Name_T'(Name_Of (Group_Table(G))) = Group_Name then Found := True; Group := Group_Table(G); return; end if; end loop; end Find_Group; function Priority_Of (Group : Group_Index_T) return Group_Priority_T is begin return Group_Table(Group).Priority; end Priority_Of; function Image (Item : Group_Set_T) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; -- The result, which is the comma-separated list of group names. begin for I in Item'Range loop if Item(I) then if Length (Result) > 0 then Append (Result, ", "); end if; Append (Result, Name_Of (Group => I)); end if; end loop; return To_String (Result); end Image; procedure Register_Group ( Name : in Group_Name_T; Index : out Group_Index_T) -- -- Registers a group by this Name in the Group_Table, and -- returns its Index. -- is begin -- Is the group already registered? for G in Group_Index_T'First .. Last_Group loop if Group_Table(G).Name = Name then -- Yes, the group is registered. Index := G; return; end if; end loop; -- A new group. Last_Group := Last_Group + 1; Index := Last_Group; Group_Table(Index) := ( Name => Name, Index => Last_Group, Priority => Index); -- -- The Priority will be recomputed later, when the -- groups are sorted. end Register_Group; type Group_Order_T is record Higher : Group_Index_T; Lower : Group_Index_T; end record; -- -- Expresses the priority order between two groups. function Higher (Item : Group_Order_T) return Group_Index_T is begin return Item.Higher; end Higher; function Lower (Item : Group_Order_T) return Group_Index_T is begin return Item.Lower; end Lower; type Group_List_T is array (Positive range <>) of Group_Index_T; -- -- A list (sequence) of groups, possibly in a significant order. type Group_Order_List_T is array (Positive range <>) of Group_Order_T; -- -- A set of pairwise group priority orderings. Max_Group_Orders : constant := 100; -- -- An upper bound on the number of group-order pairs -- that can be defined, in order to sort the groups by -- priority. Num_Group_Orders : Natural := 0; -- -- The actual number of group-order pairs defined so far. Group_Orders : Group_Order_List_T (1 .. Max_Group_Orders); -- -- The group-order pairs defined so far are -- Group_Orders (1 .. Num_Group_Orders). procedure Set_Group_Priority ( Higher : in Group_Name_T; Lower : in Group_Name_T) is High, Low : Group_Index_T; -- The indices of the two groups. begin Register_Group (Name => Higher, Index => High); Register_Group (Name => Lower , Index => Low ); Num_Group_Orders := Num_Group_Orders + 1; if Num_Group_Orders <= Max_Group_Orders then Group_Orders(Num_Group_Orders) := ( Higher => High, Lower => Low ); end if; end Set_Group_Priority; function Sort_Groups is new Topo_Sort ( Element => Group_Index_T, Pair => Group_Order_T, Element_List => Group_List_T, Pair_List => Group_Order_List_T, Lesser => Higher, Greater => Lower); -- -- Sorts a group list into a linear order that satisfies all -- of a given set of group-orders. Groups_By_Prio : Group_List_T (1 .. Max_Groups); -- -- The registered groups listed in an order that satisfies all -- given pairwise group-orders. -- -- Defined by Finish_Group_Definition. The defined index -- range is 1 .. Last_Group - First_Group + 1, or less if there -- is a priority cycle. procedure Finish_Group_Definition -- -- To be called once after all option groups and their pairwise -- priorities are defined. -- -- Computes Groups_By_Prio and sets the Priority of all registered -- groups accordingly. -- is All_Groups : Group_List_T (1 .. Last_Group - First_Group + 1); Num_Groups : Natural := 0; -- The list of indices of the registered groups, in order, is -- All_Groups(1 .. Num_Groups). Num_Orders : Natural; -- The number of registered pairwise group orders. begin -- Check and set Num_Orders: if Num_Group_Orders <= Max_Group_Orders then -- Good, we have registered all the pairwise orderings. Num_Orders := Num_Group_Orders; else -- Oops, more pairwise orderings than we have room for. Num_Orders := Max_Group_Orders; Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Defined" & Natural'Image (Num_Group_Orders) & " pairwise group orders, using only" & Natural'Image (Num_Orders)); end if; -- Get the indices of the registered groups: for G in First_Group .. Last_Group loop Num_Groups := Num_Groups + 1; All_Groups(Num_Groups) := G; end loop; -- Sort the groups (indices) topologically by the group-orders: declare Sorted_Groups : constant Group_List_T := Sort_Groups ( Elements => All_Groups, Pairs => Group_Orders(1 .. Num_Orders)); -- The indices of all registered groups, in priority order, -- unless the group-orders defined a cycle, in which case -- some groups are missing from Sorted_Groups. begin if Sorted_Groups'Length < Num_Groups then Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Options.Finish_Group_Definition:" & "Group priority cycle, only" & Natural'Image (Sorted_Groups'Length) & " groups sorted, of" & Natural'Image (Num_Groups) & " total."); end if; Groups_By_Prio(1 .. Sorted_Groups'Length) := Sorted_Groups; -- Define the priority of the groups by their position (index) -- in Sorted_Groups: for G in 1 .. Sorted_Groups'Length loop Group_Table(Sorted_Groups(G)).Priority := G; --Ada.Text_IO.Put_Line ( -- "Group " -- & Name_Of (Sorted_Groups(G)) -- & " has priority" -- & Group_Priority_T'Image (G)); end loop; end; end Finish_Group_Definition; -- --- Option table -- function Option (Element : Option_Element_T) return Option_Ref is begin return Element.Option; end Option; function Name_Of (Element : Option_Element_T) return String is begin return String_Pool.To_String (Element.Real_Name); end Name_Of; function Is_Synonym (Element : Option_Element_T) return Boolean is begin return Element.Name /= Element.Real_Name; end Is_Synonym; function Prefixed ( Prefix : String; Item : String) return String is begin if Prefix'Length > 0 then return Prefix & Prefix_Sep & Item; else return Item; end if; end Prefixed; function Imp_Item (Item : String) return String is begin return Prefixed ("imp", Item); end Imp_Item; function Trace_Item (Item : String) return String is begin return Prefixed ("trace", Item); end Trace_Item; function Warn_Item (Item : String) return String is begin return Prefixed ("warn", Item); end Warn_Item; function Prefix_Of (Prefixed_Name : String) return String is Sep : constant Natural := Ada.Strings.Fixed.Index ( Source => Prefixed_Name, Pattern => (1 => Prefix_Sep)); -- The index of the first Prefix_Sep in Prefixed_Name, -- or zero if there is no Prefix_Sep there. begin return Prefixed_Name(Prefixed_Name'First .. Sep - 1); end Prefix_Of; function Item_Of (Prefixed_Name : String) return String is Sep : constant Positive := Ada.Strings.Fixed.Index ( Source => Prefixed_Name, Pattern => (1 => Prefix_Sep)); -- The index of the first Prefix_Sep in Prefixed_Name, -- or Constraint_Error if there is no Prefix_Sep there. begin return Prefixed_Name(Sep + 1 .. Prefixed_Name'Last); end Item_Of; procedure Register ( Option : in Option_Ref; Name : in String; Synonym : in String := ""; Groups : in Groups_T := No_Groups; Reset : in Reset_Action_T := No_Action'access; Set : in Set_Action_T := No_Action'access) is Option_Name : constant Option_Name_T := Options.Option_Name (Name); -- The internal form of the Name. Synonym_Name : Option_Name_T; -- The internal form of the Synonym, if not null. Group_Set : Group_Set_T := (others => False); -- The set of Groups. Group_Index : Group_Index_T; -- The index of one of the Groups. begin for G in Groups'Range loop Register_Group ( Name => Groups(G), Index => Group_Index); Group_Set(Group_Index) := True; end loop; Option_Maps.Insert ( Container => Option_Table, Key => Option_Name, New_Item => ( Option => Option, Name => Option_Name, Real_Name => Option_Name, Groups => Group_Set, Enabled => True, -- TBM! When_Reset => Reset, When_Set => Set)); if Synonym /= "" then Synonym_Name := Options.Option_Name (Synonym); Option_Maps.Insert ( Container => Option_Table, Key => Synonym_Name, New_Item => ( Option => Option, Name => Synonym_Name, Real_Name => Option_Name, Groups => Group_Set, Enabled => True, -- TBM! When_Reset => Reset, When_Set => Set)); end if; exception when Constraint_Error => -- Duplicated Name of Option. Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Duplicated option name " & Name); end Register; procedure Register ( Option : in Option_Ref; Name : in String; Synonym : in String := ""; Group : in Group_Name_T; Reset : in Reset_Action_T := No_Action'access; Set : in Set_Action_T := No_Action'access) is begin Register ( Option => Option, Name => Name, Synonym => Synonym, Groups => (1 => Group), Reset => Reset, Set => Set); end Register; procedure Find_Option ( Name : in String; Found : out Boolean; Option : out Option_Element_T) is use Option_Maps; Here : constant Cursor := Find (Option_Table, Option_Name (Name)); -- Designates the table element for this option, if any. begin Found := Here /= No_Element; if Found then Option := Element (Here); end if; end Find_Option; function Option (Name : String) return Option_Ref is use Option_Maps; Here : constant Cursor := Find (Option_Table, Option_Name (Name)); -- Designates the table element for this option, if any. begin if Here = No_Element then return null; else return Element (Here).Option; end if; end Option; function Name_Of (Option : access Option_T) return String is use Option_Maps; Here : Cursor := First (Option_Table); begin loop exit when Here = No_Element; exit when Element (Here).Option = Option; Next (Here); end loop; return Name_Of (Element (Here)); end Name_Of; procedure Reset (Option : in Option_Element_T) is begin Reset (Option.Option); Option.When_Reset (Option.Option); end Reset; procedure Set ( Option : in Option_Element_T; Value : in String) is begin Set (Option.Option, Value); Option.When_Set (Option.Option, Value); end Set; procedure Set_Option ( Name : in String; Value : in String) is Found : Boolean; Option : Option_Element_T; -- The option with this Name, if Found. begin Find_Option ( Name => Name, Found => Found, Option => Option); if not Found then -- Oh oh. raise Program_Error; else Set ( Option => Option, Value => Value); end if; end Set_Option; procedure Finish_Definition is begin Finish_Group_Definition; end Finish_Definition; -- --- Usage and option descriptions ("help" system) -- Description_Root : Ada.Strings.Unbounded.Unbounded_String; -- -- The root of the directory path to the directories that -- contain option description files ("help" files). Defined -- by an environment variable. Bound_T_Help : constant String := "BOUNDT_HELP"; -- -- The (name of the) environment variable that defines the -- value of Description_Root. Description_Paths : Ada.Strings.Unbounded.Unbounded_String; -- -- The list of paths to directories that contain option description -- files ("help" files). There may be zero, one, or several paths, -- separated by the Path_Separator character. Path_Separator : constant Character := ';'; -- -- The character that separates paths within Description_Paths. procedure Add_Help ( Path : in String; Relative : in Boolean := True) is use Ada.Strings.Unbounded; New_Path : Unbounded_String; -- The path to be added. begin if Relative then New_Path := To_Unbounded_String (File_System.Path_Name ( Path => To_String (Description_Root), File => Path)); else New_Path := To_Unbounded_String (Path); end if; if Length (Description_Paths) = 0 then -- This is the first Path. Description_Paths := New_Path; else -- This is an additional Path. -- We add it at the front of the paths so that a general -- option can be given a more specific description for a -- known target or host system. Description_Paths := New_Path & Path_Separator & Description_Paths; end if; end Add_Help; procedure Add_Help ( Path, Subpath : in String; Relative : in Boolean := True) is begin Add_Help (File_System.Path_Name (Path, Subpath), Relative); end Add_Help; function All_Options return Option_List_T is use Option_Maps; List : Option_List_T (1 .. Integer (Length (Option_Table))); Last : Natural := 0; -- The result is List(1 .. Last). Opt : Cursor := First (Option_Table); -- Traversing the option table in alphabetical order. begin while Opt /= No_Element loop Last := Last + 1; List(Last) := Element (Opt); Next (Opt); end loop; return List(1 .. Last); end All_Options; function First_Option (With_Prefix : in String) return Option_Maps.Cursor is use Option_Maps; Cur : Cursor := Ceiling ( Container => Option_Table, Key => Option_Name (Prefixed ( Prefix => With_Prefix, Item => ""))); -- The first option with a name >= With_Prefix & '.' & "". begin if Prefix_Of (Name_Of (Element (Cur))) = With_Prefix then return Cur; else return Option_Maps.No_Element; end if; end First_Option; function Last_Option (With_Prefix : in String) return Option_Maps.Cursor is use Option_Maps; Cur : Cursor := Floor ( Container => Option_Table, Key => Option_Name (Prefixed ( Prefix => With_Prefix, Item => (1 => Character'Last)))); -- The last option with a name <= With_Prefix & '.' & some item -- where the first character of the item is not Character'Last. begin if Prefix_Of (Name_Of (Element (Cur))) = With_Prefix then return Cur; else return Option_Maps.No_Element; end if; end Last_Option; function All_Options (With_Prefix : in String) return Option_List_T is use Option_Maps; List : Option_List_T (1 .. Integer (Length (Option_Table))); Last : Natural := 0; -- The result is List(1 .. Last). Cur : Cursor := First_Option (With_Prefix); -- The first option with the given prefix. Fin : Cursor := Last_Option (With_Prefix); -- The last option with the given prefix. begin loop exit when Cur = No_Element; Last := Last + 1; List(Last) := Element (Cur); exit when Cur = Fin; Next (Cur); end loop; return List(1 .. Last); end All_Options; function Options_In (Group : Group_T) return Option_List_T is use Option_Maps; List : Option_List_T (1 .. Integer (Length (Option_Table))); Last : Natural := 0; -- The result is List(1 .. Last). Opt : Cursor := First (Option_Table); -- Traversing the option table in alphabetical order. begin while Opt /= No_Element loop if Element(Opt).Groups(Group.Index) then Last := Last + 1; List(Last) := Element (Opt); end if; Next (Opt); end loop; return List(1 .. Last); end Options_In; -- --- Help files describing options and option groups -- procedure Open_Description ( Name : in String; Form : in String; File : in out Ada.Text_IO.File_Type) is use Ada.Strings.Fixed; use Ada.Strings.Unbounded; Very_Last : constant Natural := Length (Description_Paths); -- The end of the Description Paths. First : Positive := 1; -- The start of the next path in Description_Paths. begin loop declare Sep : constant Natural := Index ( Source => Description_Paths, Pattern => (1 => Path_Separator), From => First); -- The index in Description_Paths of the separator that -- terminates the present path within Description_Paths, -- or zero if there is none. Last : Natural; -- The end of the present path in Description_Paths. begin if Sep = 0 then -- This is the last path in Description_Paths. Last := Very_Last; else Last := Sep - 1; end if; Ada.Text_IO.Open ( File => File, Mode => Ada.Text_IO.In_File, Name => File_System.Path_Name ( Path => Slice (Description_Paths, First, Last), File => Name & '.' & Form)); -- Success! exit; exception when Ada.Text_IO.Name_Error | Ada.Text_IO.Use_Error => -- File not found with this path. -- Look for the next path in Path. First := Last + 2; while First <= Very_Last and then Element (Description_Paths, First) = Path_Separator loop First := First + 1; end loop; if First > Very_Last then -- No more paths to try. raise; end if; end; end loop; end Open_Description; function Group_Description_File (Group : Group_T) return String is begin return String'(Name_Of (Group)) & "-group"; end Group_Description_File; begin -- Options if Ada.Environment_Variables.Exists (Bound_T_Help) then Description_Root := Ada.Strings.Unbounded.To_Unbounded_String ( Ada.Environment_Variables.Value (Bound_T_Help)); Add_Help ("gen"); -- The subdirectory for general options. Add_Help ("lib"); -- The subdirectory for options defined in various -- libraries that may or may not be included in a -- given version of Bound-T. else Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Environment variable " & Bound_T_Help & " is not defined, option -help will not work."); end if; end Options;
emacsmirror/ada-mode
Ada
77,551
adb
-- Abstract : -- -- see spec. -- -- Copyright (C) 2018 - 2022 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with Ada_Annex_P_Process_Actions; with WisiToken.Parse.LR.McKenzie_Recover.Base; with WisiToken.Parse.LR.McKenzie_Recover.Parse; package body WisiToken.Parse.LR.McKenzie_Recover.Ada is use Ada_Annex_P_Process_Actions; -- token names, To_Token_Enum use all type Syntax_Trees.In_Parse_Actions.Status_Label; Descriptor : WisiToken.Descriptor renames Ada_Annex_P_Process_Actions.Descriptor; subtype Grammar_Token_ID_Set is WisiToken.Token_ID_Set (Descriptor.First_Terminal .. Descriptor.Last_Nonterminal); subtype Terminal_Token_ID_Set is WisiToken.Token_ID_Set (Descriptor.First_Terminal .. Descriptor.Last_Terminal); -- From ada.wy, all nonterms with a Match_Names check: -- -- nonterm <begin_name_token> <end_name_token> -- |-----------------------------|-------------------------|------------- -- accept_statement IDENTIFIER identifier_opt -- block_statement block_label_opt identifier_opt -- entry_body IDENTIFIER identifier_opt -- loop_statement block_label_opt identifier_opt -- package_body name name_opt -- package_specification name name_opt -- protected_body IDENTIFIER identifier_opt -- protected_type_declaration IDENTIFIER protected_definition -- single_protected_declaration IDENTIFIER protected_definition -- single_task_declaration IDENTIFIER task_definition -- subprogram_body subprogram_specification name_opt -- task_body IDENTIFIER identifier_opt -- task_type_declaration IDENTIFIER task_definition No_Statements_Nonterm_IDs : constant Grammar_Token_ID_Set := To_Token_ID_Set -- Nonterms that cannot contain a handled_sequence_of_statements -- (transitive). (Descriptor.First_Terminal, Descriptor.Last_Nonterminal, +package_specification_ID & (+protected_type_declaration_ID) & (+single_protected_declaration_ID) & (+single_task_declaration_ID) & (+task_type_declaration_ID)); End_Keyword_IDs : constant Terminal_Token_ID_Set := To_Token_ID_Set (Descriptor.First_Terminal, Descriptor.Last_Terminal, +CASE_ID & (+IF_ID) & (+LOOP_ID) & (+RECORD_ID) & (+RETURN_ID) & (+SELECT_ID)); procedure Handle_In_Parse_Action_Fail (Super : in out WisiToken.Parse.LR.McKenzie_Recover.Base.Supervisor; Shared_Parser : in out Parser.Parser; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in Configuration) with Pre => Config.In_Parse_Action_Status.Label /= Ok is use Syntax_Trees; Tree : Syntax_Trees.Tree renames Shared_Parser.Tree; Parse_Table : WisiToken.Parse.LR.Parse_Table renames Shared_Parser.Table.all; Parser_Label : constant Syntax_Trees.Stream_ID := Super.Stream (Parser_Index); procedure Put (Message : in String; Config : in Configuration) is begin Put (Message, Tree, Parser_Label, Config); end Put; End_Name_Token : constant Recover_Token := Recover_Stacks.Peek (Config.Stack, Config.In_Parse_Action_Token_Count - Config.In_Parse_Action_Status.End_Name + 1).Token; begin -- There is a top level exception handler in McKenzie_Recover; the -- user has no way to work around an exception. If we are trying to -- fix a particular use case, the trace messages will be enough. case Config.In_Parse_Action_Status.Label is when Ok => raise SAL.Programmer_Error; when Match_Names_Error => -- There are several cases: -- -- 0. User name error. The input looks like: -- -- "<begin_name_token> ... <end_name_token> ;" -- -- where the names do not match, because the user is changing them. -- -- The fix is to ignore the error. See -- test/ada_mode-recover_change_name.adb. -- -- 1. The mismatch indicates one or more missing 'end's. The input -- looks like: -- -- "<correct_begin_name_token> ... <bad_begin_name_token> ... <end_name_token> ;" -- -- where <correct_begin_name_token> matches <end_name_token>, but -- <bad_begin_name_token> does not, and the erroneous reduce has -- matched <bad_begin_name_token> with <end_name_token>. -- -- The fix is to insert one or more 'end ;' before <end_name_token>. -- See test/ada_mode-recover_match_names.adb Package_Body_1 procedure A. -- -- 2. The mismatch indicates a missing block start. The input looks like: -- -- "<bad_begin_name_token> ... begin ... end <end_name_token> ;" -- -- where the matching begin name token has been deleted. -- -- The fix is to insert a matching block start before the 'begin'. -- See test/ada_mode-recover_deleted_procedure_1.adb -- -- -- It is not possible for the mismatch to indicate an extra 'end'; -- that would generate either a Missing_Name_Error, or a syntax -- error. -- -- To distinguish between case 0 and 1, we search the stack for -- <correct_begin_name_token>. If found, it's case 1, otherwise case -- 0 or 2. We cannot distinguish between 0 and 2 (without parsing -- ahead). -- -- If there is more than one missing 'end', a later recover operation -- will fix the others. For example, in test_mckenzie_recover -- Extra_Name_2, we get here on a second semantic check error. -- This case doesn't use Tree, and it can handle some virtual tokens. declare End_Name : constant String := Tree.Lexer.Buffer_Text (Tree.Name (End_Name_Token)); Matching_Name_Index : SAL.Peek_Type := 3; -- start search before <end_name_token> begin Find_Matching_Name (Config, Tree, End_Name, Matching_Name_Index, Case_Insensitive => True); if Matching_Name_Index = Config.Stack.Depth then -- case 0 or 2. if To_Token_Enum (Tree.Element_ID (Config.Error_Token)) in protected_body_ID | protected_type_declaration_ID | single_protected_declaration_ID | single_task_declaration_ID then -- Not case 2 return; end if; declare New_Config : Configuration := Config; begin -- These solutions must compete with 'ignore check fail', so give them the same cost. New_Config.Cost := New_Config.Cost + Parse_Table.McKenzie_Param.Ignore_Check_Fail; New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.In_Parse_Action_Status := (Label => Ok); case To_Token_Enum (Tree.Element_ID (Config.Error_Token)) is when block_statement_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +identifier_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, +BEGIN_ID); when entry_body_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +name_opt_ID, +END_ID, +handled_sequence_of_statements_ID), Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, +BEGIN_ID); when loop_statement_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +identifier_opt_ID, +LOOP_ID, +END_ID), Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, +LOOP_ID); when package_body_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +name_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); if Tree.Element_ID (New_Config.Stack.Peek (1).Token) = +handled_sequence_of_statements_ID then Push_Back_Check (Super, Shared_Parser, New_Config, (+handled_sequence_of_statements_ID, +BEGIN_ID), Push_Back_Undo_Reduce => True); end if; Push_Back_Check (Super, Shared_Parser, New_Config, (1 => +declarative_part_ID), Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, (+PACKAGE_ID, +BODY_ID, +IDENTIFIER_ID, +IS_ID)); when package_specification_ID => -- ada_mode-recover_bad_char.adb Push_Back_Check (Super, Shared_Parser, New_Config, (+name_opt_ID, +END_ID, +basic_declarative_item_list_ID), Push_Back_Undo_Reduce => True); if Tree.Element_ID (New_Config.Stack.Peek (1).Token) = +PRIVATE_ID then Push_Back_Check (Super, Shared_Parser, New_Config, (+PRIVATE_ID, +basic_declarative_item_list_ID), Push_Back_Undo_Reduce => True); end if; Insert (Super, Shared_Parser, New_Config, (+PACKAGE_ID, +IDENTIFIER_ID, +IS_ID)); when subprogram_body_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +name_opt_ID, +END_ID, +handled_sequence_of_statements_ID, +BEGIN_ID, +declarative_part_ID), Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, (+PROCEDURE_ID, +IDENTIFIER_ID, +IS_ID)); when task_body_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +name_opt_ID, +END_ID, +handled_sequence_of_statements_ID), Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, +BEGIN_ID); when others => if Trace_McKenzie > Outline then Put ("Language_Fixes Match_Names_Error 2: unknown error token", Config); end if; return; end case; if Trace_McKenzie > Detail then Put ("Language_Fixes Match_Names_Error 2 " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; Local_Config_Heap.Add (New_Config); exception when Invalid_Case => null; end; else -- Case 1. declare New_Config : Configuration := Config; begin New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.In_Parse_Action_Status := (Label => Ok); New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, (case To_Token_Enum (Tree.Element_ID (Config.Error_Token)) is when package_body_ID | package_specification_ID | subprogram_body_ID => +name_opt_ID, when protected_type_declaration_ID | single_protected_declaration_ID => +protected_definition_ID, when others => +identifier_opt_ID)), Push_Back_Undo_Reduce => True); if New_Config.Stack.Peek.Token.Virtual then -- 'end' is on top of stack, and is from a previous fix; don't mess -- with that. return; end if; Push_Back_Check (Super, Shared_Parser, New_Config, +END_ID, Push_Back_Undo_Reduce => True); -- Minimal_Complete_Actions does not insert an optional name, but we -- know we need one here. Insert (Super, Shared_Parser, New_Config, (+END_ID, +IDENTIFIER_ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes Match_Names_Error 1 " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; exception when Invalid_Case => null; end; end if; end; when Missing_Name_Error => -- 0. User name error. The input looks like: -- -- "<begin_name_token> ... <end_name_token> ;" -- -- where <end_name_token> is empty, because the user is changing it. -- -- There are two cases: -- -- 0a. The nonterm can contain a handled_sequence_of_statements; ie a subprogram or named block -- -- 0b. The nonterm cannot contain a handled_sequence_of_statements; -- ie a protected object or type declaration. -- -- The fix is to ignore the error. -- -- 1. missing 'begin' or extra 'end'. The stack looks like: -- -- "<begin_named_token> ... begin handled_sequence_of_statements end <end_name_token> ;" -- -- where the <end_name_token> is empty. See test_mckenzie_recover.adb -- Missing_Name_*, ada_mode-recover_15.adb, ada_mode-recover_42.adb. -- -- There are two subcases: -- -- 1a. The 'end <end_name_token> ;' is left over from editing, and -- should be deleted. Note that there could be an End_Keyword_IDs -- with that end instead of a name. -- -- 1b. There is a missing 'begin'. -- -- We can distinguish between 1a and 1b by looking for 'exception'; -- if it is present, it is more likely there is a missing 'begin'. -- However, 'exception' is contained by -- 'handled_sequence_of_statements' on the stack, so we have to look -- inside that using the syntax tree. -- -- We cannot distinguish between cases 0 and 1, other than by parsing -- ahead, except in case 0b. So we enqueue two solutions; 'ignore -- error' and either 'insert begin' or 'delete end;'. if not Valid_Tree_Indices (Config.Stack, Config.In_Parse_Action_Token_Count) then -- The logic below depends on valid tree refs, not virtual tokens. return; end if; if No_Statements_Nonterm_IDs (Tree.Element_ID (Config.Error_Token)) then -- case 0b. -- test/ada_mode.ads return; end if; if Config.Stack.Depth < 4 or else Config.Stack.Peek (4).Token.Virtual or else not Is_Nonterminal (Tree.Element_ID (Config.Stack.Peek (4).Token), Tree.Lexer.Descriptor.all) then return; end if; if Invalid_Node_Access = Tree.Find_Child (Config.Stack.Peek (4).Token.Node, +EXCEPTION_ID) then -- 'exception' not found; case 1a - assume extra 'end [keyword] ;'; delete it. declare use Recover_Op_Arrays; New_Config : aliased Configuration := Config; Ops : Recover_Op_Arrays.Vector renames New_Config.Ops; Stack : Recover_Stacks.Stack renames New_Config.Stack; Keyword_Item : Recover_Stack_Item; -- keyword after 'end'; may not be present begin New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.In_Parse_Action_Status := (Label => Ok); -- This is a guess, and sometimes deleting the error keyword is better, so -- give it a cost. New_Config.Cost := New_Config.Cost + 1; New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; case To_Token_Enum (Tree.Element_ID (Config.Error_Token)) is when block_statement_ID | package_body_ID | subprogram_body_ID | task_body_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, (if Tree.Element_ID (Config.Error_Token) in +block_statement_ID | +task_body_ID then +identifier_opt_ID else +name_opt_ID), +END_ID), Push_Back_Undo_Reduce => True); if Undo_Reduce_Valid (Super, Shared_Parser, New_Config) then if Tree.Element_ID (New_Config.Stack.Peek.Token) = +handled_sequence_of_statements_ID then Undo_Reduce_Check (Super, Shared_Parser, New_Config, (+handled_sequence_of_statements_ID, +sequence_of_statements_ID)); else if Debug_Mode then raise Bad_Config with "Language_Fixes unimplemented nonterm for Missing_Name_Error " & Image (Tree.Element_ID (Config.Error_Token), Descriptor); else raise Invalid_Case; end if; end if; else raise Invalid_Case; end if; when package_specification_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +name_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); Undo_Reduce_Check (Super, Shared_Parser, New_Config, +basic_declarative_item_list_ID); when loop_statement_ID => Keyword_Item := Stack.Peek (3); Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +identifier_opt_ID, +LOOP_ID, +END_ID), Push_Back_Undo_Reduce => True); if Undo_Reduce_Valid (Super, Shared_Parser, New_Config) and then Tree.Element_ID (New_Config.Stack.Peek.Token) = +handled_sequence_of_statements_ID then Undo_Reduce_Check (Super, Shared_Parser, New_Config, (+handled_sequence_of_statements_ID, +sequence_of_statements_ID)); end if; when others => raise Bad_Config with "Language_Fixes unimplemented nonterm for Missing_Name_Error " & Image (Tree.Element_ID (Config.Error_Token), Descriptor); end case; if not Has_Space (Ops, 3) then raise Invalid_Case; end if; if Tree.Element_ID (Keyword_Item.Token) /= Invalid_Token_ID then Delete_Check (Super, Shared_Parser, New_Config, (+END_ID, Tree.Element_ID (Keyword_Item.Token), +SEMICOLON_ID)); else -- We don't need to delete the identifier|name ; it is missing and therefore empty. Delete_Check (Super, Shared_Parser, New_Config, (+END_ID, +SEMICOLON_ID)); end if; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes Missing_Name_Error 1a " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; exception when Invalid_Case => null; end; else -- 'exception' found; case 1b - assume missing 'begin'; insert it -- before 'handled_sequence_of_statements' declare New_Config : Configuration := Config; begin New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.In_Parse_Action_Status := (Label => Ok); New_Config.Cost := New_Config.Cost + 1; New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, (if Tree.Element_ID (Config.Error_Token) = +block_statement_ID then +identifier_opt_ID else +name_opt_ID), +END_ID, +handled_sequence_of_statements_ID), Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, +BEGIN_ID); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes Missing_Name_Error 1b " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; exception when Invalid_Case => null; end; end if; when Extra_Name_Error => -- The input looks like -- -- "<begin_name_token> ... block_label_opt begin ... end <end_name_token> ;" -- -- where the erroneous reduce matches the empty 'block_label_opt' -- with '<end_name_Token>'. -- -- 0. If a matching <begin_name_token> is found, this is not a -- plausible user name error (but we always allow 'ignore error'). If -- it is not found, the user could be adding/deleting names; ignore -- error is appropriate. In either case, enqueue other solutions. -- -- 1. There is at least one missing 'end' before 'begin'. See -- test_mckenzie_recover.adb Extra_Name_1, Extra_Name_2, -- Two_Missing_Ends. The solution is to insert 'end ;' before the -- 'begin'. -- -- 2. There is at least one missing 'end' after 'begin'. See -- test/ada_mode-recover_exception_1.adb. The solution is to insert -- 'end' before the 'end', and let Minimal_Complete finish the block. -- -- 3. There is an extra 'begin', before the 'begin'. See -- test/ada_mode-recover_block_name_mismatch.adb -- -- There is no reliable way to distinguish between the three cases, so we -- enqueue all solutions. -- -- If there is more than one missing 'end', a later recover operation -- will fix the others. -- This case can handle Config.Error_Token.Virtual = True, and it -- doesn't use Tree. -- Case 1 declare New_Config : Configuration := Config; begin New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.In_Parse_Action_Status := (Label => Ok); New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; -- Push_Back the failed reduce tokens. for I in 1 .. New_Config.In_Parse_Action_Token_Count loop Push_Back (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True); end loop; if New_Config.Stack.Depth <= 1 then -- ada_mode-partial_parse_indent_begin.adb raise Invalid_Case; end if; if To_Token_Enum (Tree.Element_ID (New_Config.Stack.Peek.Token)) /= sequence_of_statements_ID then Insert (Super, Shared_Parser, New_Config, (+NULL_ID, +SEMICOLON_ID)); -- We don't need Undo_Reduce if sequence_of_statements is present; -- parser will handle that. end if; -- We know there is no name here. Insert (Super, Shared_Parser, New_Config, (+END_ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes Extra_Name_Error 1 " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; exception when Invalid_Case => null; end; -- Case 2 declare New_Config : Configuration := Config; begin New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.In_Parse_Action_Status := (Label => Ok); New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; case To_Token_Enum (Tree.Element_ID (Config.Error_Token)) is when accept_statement_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +identifier_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); when block_statement_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +identifier_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); when loop_statement_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +identifier_opt_ID, +LOOP_ID, +END_ID), Push_Back_Undo_Reduce => True); when package_specification_ID | package_body_ID => -- ada_mode-recover_string_quote_1.adb if Tree.Element_ID (New_Config.Stack.Peek.Token) = +SEMICOLON_ID then -- ada_mode-recover_50.adb Push_Back (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True); end if; Push_Back_Check (Super, Shared_Parser, New_Config, (+name_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); when protected_body_ID => -- ada_mode-recover_50.adb if Tree.Element_ID (New_Config.Stack.Peek.Token) = +SEMICOLON_ID then Push_Back (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True); end if; Push_Back_Check (Super, Shared_Parser, New_Config, (+identifier_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); when protected_type_declaration_ID | single_protected_declaration_ID | single_task_declaration_ID => -- ada_mode-recover_50.adb Push_Back_Check (Super, Shared_Parser, New_Config, +SEMICOLON_ID, Push_Back_Undo_Reduce => True); case To_Token_Enum (Tree.Element_ID (New_Config.Stack.Peek.Token)) is when protected_definition_ID | task_definition_ID => raise Invalid_Case; when identifier_opt_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+identifier_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); when others => raise SAL.Programmer_Error with "code does not match grammar"; end case; when subprogram_body_ID => Push_Back_Check (Super, Shared_Parser, New_Config, (+SEMICOLON_ID, +name_opt_ID, +END_ID), Push_Back_Undo_Reduce => True); when others => raise Bad_Config with "Language_Fixes Extra_Name_Error 2: unrecognized Error_Token " & Image (Tree.Element_ID (Config.Error_Token), Tree.Lexer.Descriptor.all); end case; -- We know there is no name here. Insert (Super, Shared_Parser, New_Config, (+END_ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes Extra_Name_Error 2 " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; exception when Invalid_Case => null; end; -- Case 3. Delete the extra begin -- -- If the first begin was inserted by recovery, we actually want to -- delete the second begin. see test/ada_mode-recover_indent_4.adb declare New_Config : aliased Configuration := Config; I : SAL.Peek_Type := 1; First_Begin_I : SAL.Peek_Type; Second_Begin_I : SAL.Peek_Type; begin loop if Tree.Element_ID (New_Config.Stack.Peek (I).Token) = +BEGIN_ID then Second_Begin_I := I; exit; end if; I := I + 1; if I >= New_Config.Stack.Depth then raise Invalid_Case; end if; end loop; loop I := I + 1; if I >= New_Config.Stack.Depth then raise Invalid_Case; end if; if Tree.Element_ID (New_Config.Stack.Peek (I).Token) = +BEGIN_ID then First_Begin_I := I; exit; end if; end loop; if New_Config.Stack.Peek (First_Begin_I).Token.Virtual then if New_Config.Stack.Peek (Second_Begin_I).Token.Virtual then -- nothing we can do. return; end if; -- Delete the second begin for I in 1 .. Second_Begin_I loop Push_Back (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True); end loop; case To_Token_Enum (Tree.Element_ID (New_Config.Stack.Peek.Token)) is when COLON_ID => -- block label is present Push_Back_Check (Super, Shared_Parser, New_Config, (+COLON_ID, +statement_identifier_ID), Push_Back_Undo_Reduce => True); Delete_Check (Super, Shared_Parser, New_Config, (+IDENTIFIER_ID, +COLON_ID, +BEGIN_ID)); when label_opt_ID => if Tree.Is_Empty_Nonterm (New_Config.Stack.Peek.Token) then Undo_Reduce_Check (Super, Shared_Parser, New_Config, +label_opt_ID); else Undo_Reduce_Check (Super, Shared_Parser, New_Config, +label_opt_ID); Push_Back_Check (Super, Shared_Parser, New_Config, (+COLON_ID, +statement_identifier_ID), Push_Back_Undo_Reduce => True); Delete_Check (Super, Shared_Parser, New_Config, (+IDENTIFIER_ID, +COLON_ID, +BEGIN_ID)); end if; when others => Delete_Check (Super, Shared_Parser, New_Config, +BEGIN_ID); end case; if Undo_Reduce_Valid (Super, Shared_Parser, New_Config) then Undo_Reduce_Check (Super, Shared_Parser, New_Config, +statement_statement_list_ID); elsif Push_Back_Valid (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True) then Push_Back_Check (Super, Shared_Parser, New_Config, +statement_statement_list_ID, Push_Back_Undo_Reduce => True); else raise Invalid_Case; end if; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes Extra_Name_Error 3a " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; else -- Delete the first begin. We assume it is in a subprogram body, so -- we don't need to adjust anything else. for I in 1 .. First_Begin_I loop Push_Back (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True); end loop; Delete_Check (Super, Shared_Parser, New_Config, +BEGIN_ID); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes Extra_Name_Error 3b " & Image (Tree.Element_ID (Config.Error_Token), Descriptor), New_Config); end if; end if; exception when Invalid_Case => null; end; end case; exception when Bad_Config => if Debug_Mode then raise; elsif Trace_McKenzie > Outline then Tree.Lexer.Trace.Put_Line ("Language_Fixes Handle_In_Parse_Action_Fail Bad_Config"); end if; end Handle_In_Parse_Action_Fail; procedure Handle_Parse_Error (Super : in out WisiToken.Parse.LR.McKenzie_Recover.Base.Supervisor; Shared_Parser : in out Parser.Parser; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in Configuration) with Pre => Config.In_Parse_Action_Status.Label = Ok is use Syntax_Trees; Tree : Syntax_Trees.Tree renames Shared_Parser.Tree; Parser_Label : constant Syntax_Trees.Stream_ID := Super.Stream (Parser_Index); procedure Put (Message : in String; Config : in Configuration) is begin Put (Message, Tree, Parser_Label, Config); end Put; begin if (Tree.Element_ID (Config.Error_Token) = +COLON_ID and (Tree.Element_ID (Config.Stack.Peek.Token) /= Invalid_Token_ID and then -Tree.Element_ID (Config.Stack.Peek.Token) in direct_name_ID | IDENTIFIER_ID)) and then Push_Back_Valid (Super, Shared_Parser, Config, Push_Back_Undo_Reduce => True) then -- Code looks like: -- -- ... <variable_name> : [aliased constant] <subtype_indication> := <expression> ... -- -- Assume the user copied a declaration with an initializer, and is -- converting it to an expression; see ada_mode-recover_02.adb, -- test/ada_mode-recover_constant_as_expression_1.adb. Delete -- '<variable_identifier> : [aliased constant] <subtype_indication> -- :='. -- -- We cannot reliably search ahead in the unparsed tokens for ':="; -- <subtype_indication> can include a constraint with an arbitrarily -- complex expression. So we only handle the common case where the -- <subtype_indication> is a simple identifier or selected_component. -- -- Note that if the user was converting to an assignment, there would -- not be a partial statement in progress before the <variable -- identifier>, and the error would be on 'constant', not ':'. -- -- compare to "decl as statement"/"missing end"/"extra begin" case below. declare New_Config : aliased Configuration := Config; Peek_State : Peek_Sequential_State (New_Config.Input_Stream'Access); begin Push_Back (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True); -- variable_name Peek_State := Peek_Sequential_Start (Super, Shared_Parser, New_Config); Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +IDENTIFIER_ID); Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +COLON_ID); if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +ALIASED_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +ALIASED_ID); end if; if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +CONSTANT_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +CONSTANT_ID); end if; if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +NOT_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +NOT_ID); end if; if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +NULL_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +NULL_ID); end if; -- look for ':=' loop exit when Peek_Sequential_Terminal (Peek_State) = Invalid_Node_Access; case To_Token_Enum (Tree.ID (Peek_Sequential_Terminal (Peek_State))) is when IDENTIFIER_ID => Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +IDENTIFIER_ID); when DOT_ID => Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +DOT_ID); when COLON_EQUAL_ID => Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +COLON_EQUAL_ID); exit; when Wisi_EOI_ID => exit; when others => raise Invalid_Case; end case; end loop; New_Config.Cost := New_Config.Cost + 1; New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes variable decl as expression", New_Config); end if; exception when Invalid_Case => null; end; elsif (To_Token_Enum (Tree.Element_ID (Config.Error_Token)) in ALIASED_ID | CONSTANT_ID | IDENTIFIER_ID and Tree.Element_ID (Config.Stack.Peek.Token) = +COLON_ID) and then Push_Back_Valid (Super, Shared_Parser, Config, Push_Back_Undo_Reduce => True) then -- Code looks like: -- -- <statement> <variable_identifier> : [aliased constant] <subtype_indication> <expression> ... -- -- The variable_name looks like a statement_identifier (ie block -- name). compare to "variable decl as expression" case above. -- -- 1) This is a copied variable declaration that the user is converting -- to an assignment. See -- test/ada_mode-recover_constant_as_statement_1.adb. Delete -- ': [aliased constant] <subtype_indication>' -- -- We cannot reliably search ahead in the unparsed tokens for ':="; -- <subtype_indication> can include a constraint with an arbitrarily -- complex expression. So we only handle the common case where the -- <subtype_indication> is a simple identifier or selected_component. -- -- 2) There is a missing 'end;' before <variable_name>. See -- test/ada_mode-recover_25.adb. Push_Back + Minimal_Complete also -- handles this case, but we enqueue the same solution here at lower -- cost, so it can compete with the solution for cases 1 and 3. -- -- 3) There is an extra 'begin' before the <variable_name>. See -- test/ada_mode-recover_27.adb. Delete the 'begin'. -- -- 4) This is an incomplete object_declaration; let minimal_complete -- handle it. test/ada_mode-recover_38.adb. -- case 1 declare New_Config : aliased Configuration := Config; Peek_State : Peek_Sequential_State (New_Config.Input_Stream'Access); begin Push_Back_Check (Super, Shared_Parser, New_Config, +COLON_ID, Push_Back_Undo_Reduce => True); Peek_State := Peek_Sequential_Start (Super, Shared_Parser, New_Config); Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +COLON_ID); if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +ALIASED_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +ALIASED_ID); end if; if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +CONSTANT_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +CONSTANT_ID); end if; if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +NOT_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +NOT_ID); end if; if Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +NULL_ID then Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +NULL_ID); end if; -- look for and keep ':=' loop exit when Peek_Sequential_Terminal (Peek_State) = Invalid_Node_Access; case To_Token_Enum (Tree.ID (Peek_Sequential_Terminal (Peek_State))) is when IDENTIFIER_ID => Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +IDENTIFIER_ID); when DOT_ID => Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +DOT_ID); when COLON_EQUAL_ID | Wisi_EOI_ID => exit; when others => raise Invalid_Case; end case; end loop; New_Config.Cost := New_Config.Cost + 1; New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes constant decl as statement 1", New_Config); end if; exception when Invalid_Case => null; end; declare New_Config_1 : Configuration := Config; begin -- ada_mode-recover_38.adb, ada_mode-recover_46.adb Push_Back_Check (Super, Shared_Parser, New_Config_1, +COLON_ID, Push_Back_Undo_Reduce => True); Push_Back_Check (Super, Shared_Parser, New_Config_1, Tree.Element_ID (New_Config_1.Stack.Peek.Token), Push_Back_Undo_Reduce => True); if Tree.Element_ID (New_Config_1.Stack.Peek.Token) = +sequence_of_statements_ID then -- Case 2 null; elsif Tree.Element_ID (New_Config_1.Stack.Peek.Token) = +BEGIN_ID then -- Case 2 or 3 declare New_Config_2 : Configuration := New_Config_1; begin if Push_Back_Valid (Super, Shared_Parser, New_Config_1, Push_Back_Undo_Reduce => True) then Push_Back_Check (Super, Shared_Parser, New_Config_2, +BEGIN_ID, Push_Back_Undo_Reduce => True); Delete_Check (Super, Shared_Parser, New_Config_2, +BEGIN_ID); if Undo_Reduce_Valid (Super, Shared_Parser, New_Config_2) then if Tree.Element_ID (New_Config_2.Stack.Peek.Token) = +declarative_part_ID then Undo_Reduce_Check (Super, Shared_Parser, New_Config_2, +declarative_part_ID); end if; end if; -- This is a guess, so add a cost, equal to case 1, 2. New_Config_2.Cost := New_Config_2.Cost + 1; New_Config_2.Strategy_Counts (Language_Fix) := New_Config_2.Strategy_Counts (Language_Fix) + 1; Local_Config_Heap.Add (New_Config_2); if Trace_McKenzie > Detail then Put ("Language_Fixes constant decl as statement 3", New_Config_2); end if; end if; end; Insert (Super, Shared_Parser, New_Config_1, (+NULL_ID, +SEMICOLON_ID)); end if; -- If we don't insert the ';' here, <variable_name> looks like a -- block end name. Insert (Super, Shared_Parser, New_Config_1, (+END_ID, +SEMICOLON_ID)); -- This is a guess, so add a cost, equal to case 1. New_Config_1.Cost := New_Config_1.Cost + 1; New_Config_1.Strategy_Counts (Language_Fix) := New_Config_1.Strategy_Counts (Language_Fix) + 1; Local_Config_Heap.Add (New_Config_1); if Trace_McKenzie > Detail then Put ("Language_Fixes constant decl as statement 2", New_Config_1); end if; exception when Invalid_Case => null; end; elsif Tree.Element_ID (Config.Error_Token) = +DOT_ID then -- We've encountered a selected_component when we were expecting a -- simple IDENTIFIER. If the selected_component is preceded by 'end', -- then this is similar to a semantic check Extra_Name_Error, and the -- solutions are similar. if To_Token_Enum (Tree.Element_ID (Config.Stack.Peek.Token)) in IDENTIFIER_ID | identifier_opt_ID and Tree.Element_ID (Config.Stack.Peek (2).Token) = +END_ID then -- The input looks like one of: -- -- 1) "<begin_name_token_1> ... <begin_name_token_2> ... begin ... begin ... end <end_name_token_1> ;" -- -- 2) "<begin_name_token_1> ... begin ... declare ... begin ... end <end_name_token_1> ;" -- -- Case 1) is missing 'end <end_name_token_2> ;' between the -- 'begin's, so parsing expects <end_name_token_1> to match the -- second 'begin', which looks like an unnamed block. See -- test_mckenzie_recover Match_Selected_Component_1. 'declare ...' is -- _not_ present on the second begin (because it is part of the -- syntax for <begin_name_token_1>). The solution is to insert 'end -- ;' before the second 'begin'. -- -- Case 2) is missing 'end;' after the second 'begin'. See -- test_mckenzie_recover Match_Selected_Component_2. 'declare ...' -- may be absent on the second begin, or a name may be present. The -- solution is to insert 'end;' after the second 'begin' (ie before -- the last 'end'). -- -- Minimal_Complete_Actions does not handle this case well. -- -- Note that it's _not_ possible the user is just editing names; that -- would generate a semantic check fail, not a parse table error, -- since a "." would be permitted. declare Label : constant String := "selected_component 1"; New_Config_1 : Configuration := Config; begin New_Config_1.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config_1.Strategy_Counts (Language_Fix) := New_Config_1.Strategy_Counts (Language_Fix) + 1; Push_Back_Check (Super, Shared_Parser, New_Config_1, (Tree.Element_ID (Config.Stack.Peek.Token), +END_ID), Push_Back_Undo_Reduce => True); if New_Config_1.Stack.Depth <= 3 then raise Invalid_Case; end if; if Tree.Element_ID (New_Config_1.Stack.Peek (3).Token) = +declarative_part_ID then -- 'declare' is present; case 2 Insert (Super, Shared_Parser, New_Config_1, (+END_ID, +IDENTIFIER_ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config_1); else -- no 'declare'; either case 1 or 2, so enqueue both declare New_Config_2 : Configuration := New_Config_1; begin case To_Token_Enum (Tree.Element_ID (New_Config_2.Stack.Peek.Token)) is when handled_sequence_of_statements_ID | sequence_of_statements_ID => -- see test/ada_mode-recover_partial_24.adb Push_Back_Check (Super, Shared_Parser, New_Config_2, (+handled_sequence_of_statements_ID, +BEGIN_ID, +label_opt_ID), Push_Back_Undo_Reduce => True); when protected_operation_item_list_ID => -- ada_mode-recover_protected_01.adb -- Can't be case 2. raise Invalid_Case; when others => raise Bad_Config with "Language_Fixes " & Label & " unimplemented case " & Image (Tree.Element_ID (New_Config_2.Stack.Peek.Token), Descriptor); end case; Insert (Super, Shared_Parser, New_Config_2, (+END_ID, +IDENTIFIER_ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config_2); if Trace_McKenzie > Detail then Put ("Language_Fixes " & Label, New_Config_2); end if; exception when Invalid_Case => null; end; Insert (Super, Shared_Parser, New_Config_1, (+END_ID, +IDENTIFIER_ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config_1); end if; if Trace_McKenzie > Detail then Put ("Language_Fixes " & Label, New_Config_1); end if; exception when Invalid_Case => null; end; end if; elsif To_Token_Enum (Tree.Element_ID (Config.Error_Token)) in IDENTIFIER_ID | CASE_ID | IF_ID | LOOP_ID | RECORD_ID | RETURN_ID | SELECT_ID | name_opt_ID and Tree.Element_ID (Config.Stack.Peek.Token) = +END_ID then -- We've encountered a token after 'end' when expecting a -- different token. See test/ada_mode-recover_17, _20, _24, _26, _39.adb. -- -- There are several cases: -- -- a: There is a missing 'end <compound_statement_id> ;' before the -- 'end'. We can get the ID to insert from Parse_Table -- Minimal_Complete_Actions. -- -- b: If the error token is IDENTIFIER or name_opt, and there is not -- a matching name, the error token should be something else; delete -- it. -- -- If there is a matching name, Minimal_Complete_Actions inserts -- '<compound_statement_id> ;'. We want to insert 'end -- <id> ;' before the existing 'end', so Insert_After places the -- tokens better; see test/ada_mode-recover_17, _20.adb. -- -- c: There is a missing 'end <name>;' before the 'end' -- -- d: There is a missing matching component_statement start -- -- We can't reliably distinguish between a: and b:, so we do both. c: -- is distinguished by the minimal action being 'reduce to name'. d: -- is distinguished by searching for an open matching -- component_statement start. declare procedure Insert_End_Token_Semi (Label : in String; New_Config : in out Configuration) is End_ID_Actions : constant Minimal_Action_Arrays.Vector := Shared_Parser.Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions; begin if End_ID_Actions.Length /= 1 then -- FIXME: do all actions? need a test case raise Bad_Config with "Language_Fixes Insert_End_Token_Semi multiple actions"; else New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Push_Back_Check (Super, Shared_Parser, New_Config, +END_ID, Push_Back_Undo_Reduce => True); case End_ID_Actions (End_ID_Actions.First_Index).Verb is when Shift => -- case a or b -- Inserting the end keyword and semicolon here avoids the costs added by -- Insert_Minimal_Complete_Actions. Insert (Super, Shared_Parser, New_Config, (+END_ID, End_ID_Actions (End_ID_Actions.First_Index).ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes " & "wrong end keyword a", New_Config); end if; when Reduce => -- case c: ada_mode-recover_39.adb. Insert (Super, Shared_Parser, New_Config, (+END_ID, +IDENTIFIER_ID, +SEMICOLON_ID)); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes " & Label, New_Config); end if; end case; end if; end Insert_End_Token_Semi; begin if not (To_Token_Enum (Tree.Element_ID (Config.Error_Token)) in IDENTIFIER_ID | name_opt_ID) then -- First exclude case b declare New_Config : aliased Configuration := Config; Error_Token_ID : constant Token_ID := Tree.Element_ID (New_Config.Error_Token); Found : constant Boolean := Find_ID (Tree, New_Config, Error_Token_ID); begin if not Found then -- case d. ada_mode-recover_extra_end_loop.adb New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; -- We could push_back 'end' and insert a matching start, but it's -- simpler to delete 'end <keyword> ;' Push_Back (Super, Shared_Parser, New_Config, Push_Back_Undo_Reduce => True); -- END_ID declare Peek_State : Peek_Sequential_State := Peek_Sequential_Start (Super, Shared_Parser, New_Config); begin Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +END_ID); Delete_Check (Super, Shared_Parser, New_Config, Peek_State, Error_Token_ID); if +SEMICOLON_ID = Tree.ID (WisiToken.Parse.LR.McKenzie_Recover.Parse.Peek_Current_First_Sequential_Terminal (Super, Shared_Parser, Config)) then -- Might not be there while typing code; ada_mode-interactive_09.adb Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +SEMICOLON_ID); end if; end; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes wrong end name", New_Config); end if; else Insert_End_Token_Semi ("wrong end keyword c", New_Config); end if; exception when Invalid_Case => null; end; end if; -- Now try case b. if Tree.Element_ID (Config.Error_Token) in +IDENTIFIER_ID | +name_opt_ID then declare New_Config : aliased Configuration := Config; function Get_End_Name return String is use Standard.Ada.Strings.Unbounded; Result : Unbounded_String := +Tree.Lexer.Buffer_Text (Tree.Byte_Region (New_Config.Error_Token)); begin if Tree.Element_Is_Terminal (New_Config.Error_Token) then declare Peek_State : Peek_Sequential_State := Peek_Sequential_Start (Super, Shared_Parser, New_Config); begin loop Peek_Next_Sequential_Terminal (Tree, Peek_State); exit when Peek_Sequential_Terminal (Peek_State) = Invalid_Node_Access; exit when -Tree.ID (Peek_Sequential_Terminal (Peek_State)) not in IDENTIFIER_ID | DOT_ID; Result := Result & Tree.Lexer.Buffer_Text (Tree.Byte_Region (Peek_Sequential_Terminal (Peek_State), Trailing_Non_Grammar => False)); end loop; end; end if; return -Result; end Get_End_Name; End_Name : constant String := Get_End_Name; Matching_Name_Index : SAL.Peek_Type := 2; -- start search before 'end' begin Find_Matching_Name (New_Config, Tree, End_Name, Matching_Name_Index, Case_Insensitive => True); if Matching_Name_Index < New_Config.Stack.Depth then -- Matching name found; insert 'end ... ;' before the -- existing 'end'. Insert_End_Token_Semi ("wrong end keyword b 1", New_Config); else declare Label : constant String := "wrong end keyword b 2"; begin -- Matching name not found: delete Error_Token New_Config.Strategy_Counts (Language_Fix) := @ + 1; Delete_Check (Super, Shared_Parser, New_Config, Invalid_Token_ID); New_Config.Error_Token := (True, Invalid_Token_ID, others => <>); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes " & Label, New_Config); end if; end; end if; exception when Invalid_Case => null; end; end if; end; elsif To_Token_Enum (Tree.Element_ID (Config.Error_Token)) in PRAGMA_ID | USE_ID and Tree.Element_ID (Config.Stack.Peek.Token) = +BEGIN_ID then -- Code looks like: -- -- a) <subprogram|package start> is ... begin use <name>; -- b) <subprogram|package start> is ... begin pragma ... -- -- There is an extra 'begin' before 'use' or 'pragma'. See -- test/ada_mode-recover_14.adb. Delete the 'begin'. if Push_Back_Valid (Super, Shared_Parser, Config, Push_Back_Undo_Reduce => True) then declare New_Config : Configuration := Config; begin New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Push_Back_Check (Super, Shared_Parser, New_Config, +BEGIN_ID, Push_Back_Undo_Reduce => True); if Tree.Element_ID (New_Config.Stack.Peek.Token) = +declarative_part_ID then if Undo_Reduce_Valid (Super, Shared_Parser, New_Config) then Undo_Reduce_Check (Super, Shared_Parser, New_Config, +declarative_part_ID); else raise Invalid_Case; end if; end if; Delete_Check (Super, Shared_Parser, New_Config, +BEGIN_ID); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes extra begin 2", New_Config); end if; exception when Invalid_Case => null; end; end if; elsif Tree.Element_ID (Config.Error_Token) = +OR_ID and then Tree.Element_ID (Config.Stack.Peek.Token) = +expression_ID then -- Code looks like: -- -- expr1 and expr2 or expr3 -- -- where 'expr1 and expr2' is in the expression on the stack. Missing -- left paren before expr1. See test/ada_mode-recover_20.adb. -- -- We could check for the presence of 'and' in expression, but -- that requires a syntax tree. If the left paren doesn't help, this -- config will be dropped. declare New_Config : Configuration := Config; begin New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Push_Back_Check (Super, Shared_Parser, New_Config, +expression_ID, Push_Back_Undo_Reduce => True); Insert (Super, Shared_Parser, New_Config, +LEFT_PAREN_ID); -- Minimal_Complete will add the matching right paren. Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes and/or", New_Config); end if; exception when Invalid_Case => null; end; elsif Tree.Element_ID (Config.Error_Token) = +TICK_1_ID and Config.Error_Token.Virtual = False then -- Maybe editing "Put ('|');" => "Put ('|-');"; need to change ' to ". -- ada_mode-recover_string_quote_6.adb is not doing this. declare New_Config : aliased Configuration := Config; Token_Count : Integer := 0; begin New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; declare Peek_State : Peek_Sequential_State := Peek_Sequential_Start (Super, Shared_Parser, New_Config); pragma Assert (Tree.Element_ID (New_Config.Error_Token) = Tree.ID (Peek_Sequential_Terminal (Peek_State))); begin Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +TICK_1_ID); -- increments Peek_State loop Delete_Check (Super, Shared_Parser, New_Config, Peek_State, Invalid_Token_ID); Token_Count := @ + 1; if Peek_Sequential_Terminal (Peek_State) = Invalid_Node_Access or -- ada_mode-interactive_01.adb, ada_mode-recover_string_quote_6.adb Token_Count > 9 then raise Invalid_Case; end if; exit when Tree.ID (Peek_Sequential_Terminal (Peek_State)) = +TICK_1_ID; end loop; Delete_Check (Super, Shared_Parser, New_Config, Peek_State, +TICK_1_ID); Insert (Super, Shared_Parser, New_Config, Peek_Sequential_Terminal (Peek_State), +STRING_LITERAL_ID); end; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes char_literal to string", New_Config); end if; exception when Invalid_Case => null; end; elsif Tree.Element_ID (Config.Error_Token) = +IN_ID and then (Tree.Element_ID (Config.Stack.Peek.Token) = +COLON_ID and Tree.Element_ID (Config.Stack.Peek (2).Token) = +defining_identifier_list_ID) then -- See test/ada_mode-recover_partial_03.adb. -- Code looks like: -- -- is Node : in Valid_Node_Index) -- -- error on "in"; missing 'procedure IDENTIFIER (' before 'Node' declare New_Config : Configuration := Config; begin New_Config.Strategy_Counts (Language_Fix) := New_Config.Strategy_Counts (Language_Fix) + 1; Push_Back_Check (Super, Shared_Parser, New_Config, (+COLON_ID, +defining_identifier_list_ID), Push_Back_Undo_Reduce => True); -- We could search ahead for 'return', but that's not simple; let -- recover handle it. Insert (Super, Shared_Parser, New_Config, (+PROCEDURE_ID, +IDENTIFIER_ID, +LEFT_PAREN_ID)); Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Put ("Language_Fixes exposed argument list", New_Config); end if; exception when Invalid_Case => null; end; end if; exception when Bad_Config => if Debug_Mode then raise; elsif Trace_McKenzie > Outline then Tree.Lexer.Trace.Put_Line ("Language_Fixes Handle_Parse_Error Bad_Config"); end if; end Handle_Parse_Error; ---------- -- Public subprograms procedure Language_Fixes (Super : in out WisiToken.Parse.LR.McKenzie_Recover.Base.Supervisor; Shared_Parser : in out Parser.Parser; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in Configuration) is begin if Trace_McKenzie > Extra then Put ("Language_Fixes", Shared_Parser.Tree, Super.Stream (Parser_Index), Config); Put_Line (Shared_Parser.Tree, Super.Stream (Parser_Index), "config stack: " & Image (Config.Stack, Shared_Parser.Tree)); end if; case Config.In_Parse_Action_Status.Label is when Ok => Handle_Parse_Error (Super, Shared_Parser, Parser_Index, Local_Config_Heap, Config); when others => Handle_In_Parse_Action_Fail (Super, Shared_Parser, Parser_Index, Local_Config_Heap, Config); end case; end Language_Fixes; procedure Matching_Begin_Tokens (Super : in out WisiToken.Parse.LR.McKenzie_Recover.Base.Supervisor; Shared_Parser : in out Parser.Parser; Tokens : in Token_ID_Array_1_3; Config : aliased in Configuration; Matching_Tokens : in out Token_ID_Arrays.Vector; Forbid_Minimal_Complete : in out Boolean) is use Token_ID_Arrays; Tree : Syntax_Trees.Tree renames Shared_Parser.Tree; function Matching_Begin_For_End return Token_ID_Arrays.Vector is Next_Index : constant Positive := 2; begin return Result : Token_ID_Arrays.Vector do if Tokens (Next_Index) = Invalid_Token_ID then -- Better to delete 'end' Result := Empty_Vector; else case To_Token_Enum (Tokens (Next_Index)) is when CASE_ID | IF_ID | LOOP_ID | RETURN_ID | SELECT_ID => Result := To_Vector (Tokens (Next_Index)); when IDENTIFIER_ID => -- Check for existing 'begin' with matching name. ada_mode-recover_03.adb declare function Get_End_Name return String is use Standard.Ada.Strings.Unbounded; use Syntax_Trees; Result : Unbounded_String; Peek_State : Peek_Sequential_State := Peek_Sequential_Start (Super, Shared_Parser, Config); begin loop Peek_Next_Sequential_Terminal (Tree, Peek_State); exit when Peek_Sequential_Terminal (Peek_State) = Invalid_Node_Access; exit when -Tree.ID (Peek_Sequential_Terminal (Peek_State)) not in IDENTIFIER_ID | DOT_ID; Result := Result & Tree.Lexer.Buffer_Text (Tree.Byte_Region (Peek_Sequential_Terminal (Peek_State), Trailing_Non_Grammar => False)); end loop; return -Result; end Get_End_Name; End_Name : constant String := Get_End_Name; Matching_Name_Index : SAL.Peek_Type := 1; begin Find_Matching_Name (Config, Tree, End_Name, Matching_Name_Index, Case_Insensitive => True); if Matching_Name_Index < Config.Stack.Depth then -- Matching name found; let minimal_complete handle it. null; elsif Tokens (Next_Index + 1) /= Invalid_Token_ID and then To_Token_Enum (Tokens (Next_Index + 1)) = DOT_ID then Result := To_Vector ((+PACKAGE_ID, +BODY_ID, +IDENTIFIER_ID, +IS_ID)); -- package body else Result := To_Vector ((+IDENTIFIER_ID, +COLON_ID, +BEGIN_ID)); -- named block begin end if; end; when SEMICOLON_ID => Result := To_Vector (+BEGIN_ID); when others => null; end case; end if; end return; end Matching_Begin_For_End; begin Forbid_Minimal_Complete := False; case To_Token_Enum (Tokens (1)) is -- Token_Enum_ID alphabetical order when COMMA_ID => -- Commas always occur in parens; if no left paren on stack, insert -- one. Also start an expression before the comma. -- ada_mode-recover_39.adb Forbid_Minimal_Complete := True; if Stack_Has (Tree, Config.Stack, +LEFT_PAREN_ID) then Matching_Tokens := To_Vector (+IDENTIFIER_ID); else Matching_Tokens := To_Vector ((+IDENTIFIER_ID, +LEFT_PAREN_ID, +IDENTIFIER_ID)); end if; when END_ID => if Config.Stack.Depth = 1 then -- ada_mode-partial_parse.adb return; end if; case To_Token_Enum (Tree.Element_ID (Config.Stack.Peek.Token)) is when ABORT_ID | -- asynchronous_select BEGIN_ID | -- ada_mode-recover_indent_3.adb DO_ID | -- return_statement, accept_statement ELSE_ID | -- if_statement, select_statement, conditional_entry_call THEN_ID => -- Empty sequence_of_statements. This can be handled by -- minimal_complete, but we want to prevent Matching_Begin_For_End, -- and we know what to insert. Matching_Tokens := To_Vector ((+NULL_ID, +SEMICOLON_ID)); Forbid_Minimal_Complete := True; when LOOP_ID => if To_Token_Enum (Tree.Element_ID (Config.Stack.Peek (2).Token)) = END_ID then -- Let minimal_complete insert the semicolon. return; else -- empty sequence of statements. Matching_Tokens := To_Vector ((+NULL_ID, +SEMICOLON_ID)); Forbid_Minimal_Complete := True; end if; when AND_ID | -- parallel_block_statement or expression IS_ID | -- variant_part,package_spec, *_body, case_statement ... OR_ID | -- timed_entry_call, expression PRIVATE_ID | -- package_specification, protected_definition, task_item_list RECORD_ID -- record_representation_clause or record_defition => -- We don't know what to insert; let minimal_complete handle it. return; when others => Matching_Tokens := Matching_Begin_For_End; end case; when ELSE_ID | ELSIF_ID => if Tree.Element_ID (Config.Stack.Peek.Token) = +THEN_ID then -- Empty sequence_of_statements in 'if then else'; ada_mode-recover_27.adb Matching_Tokens := To_Vector ((+NULL_ID, +SEMICOLON_ID)); Forbid_Minimal_Complete := True; else -- ada_mode-recover_40.adb Matching_Tokens := To_Vector ((+IF_ID, +IDENTIFIER_ID, +THEN_ID, +NULL_ID, +SEMICOLON_ID)); end if; when THEN_ID => if Tree.Element_ID (Config.Stack.Peek.Token) = +IF_ID then -- Empty expression in 'if then' Matching_Tokens := To_Vector (+IDENTIFIER_ID); Forbid_Minimal_Complete := True; else Matching_Tokens := To_Vector ((+IF_ID, +IDENTIFIER_ID)); end if; when EXCEPTION_ID => if Tree.Element_ID (Config.Stack.Peek.Token) = +BEGIN_ID then -- Empty sequence_of_statements Matching_Tokens := To_Vector ((+NULL_ID, +SEMICOLON_ID)); Forbid_Minimal_Complete := True; else Matching_Tokens := To_Vector (+BEGIN_ID); end if; -- We don't return LEFT_PAREN for RIGHT_PAREN; better to delete it. when WHEN_ID => if Tree.Element_ID (Config.Stack.Peek.Token) = +EQUAL_GREATER_ID then -- Empty sequence_of_statements Matching_Tokens := To_Vector ((+NULL_ID, +SEMICOLON_ID)); Forbid_Minimal_Complete := True; else Matching_Tokens := To_Vector ((+CASE_ID, +IDENTIFIER_ID, +IS_ID)); end if; when others => null; end case; if not Forbid_Minimal_Complete then if Tree.Element_ID (Config.Stack.Peek.Token) = +END_ID and ((Tokens (1) = +IDENTIFIER_ID and (Tokens (2) /= Invalid_Token_ID and then -Tokens (2) in DOT_ID | SEMICOLON_ID)) or End_Keyword_IDs (Tokens (1))) then Forbid_Minimal_Complete := True; else Forbid_Minimal_Complete := False; end if; end if; end Matching_Begin_Tokens; function String_ID_Set (Descriptor : in WisiToken.Descriptor; String_Literal_ID : in Token_ID) return Token_ID_Set is begin -- Character literal can be part of a string primary, so the nonterms -- are independent of String_Literal_ID. return Result : Token_ID_Set (Descriptor.First_Terminal .. Descriptor.Last_Nonterminal) := (others => False) do Result (String_Literal_ID) := True; Result (+name_ID) := True; Result (+primary_ID) := True; Result (+factor_ID) := True; Result (+term_ID) := True; Result (+simple_expression_ID) := True; Result (+relation_ID) := True; Result (+expression_ID) := True; end return; end String_ID_Set; end WisiToken.Parse.LR.McKenzie_Recover.Ada; -- Local Variables: -- ada-case-strict: nil -- End:
AdaCore/training_material
Ada
712
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Text_Buffers; procedure Main is --$ begin cut type R is null record with Put_Image => My_Put_Image; --$ end cut -- Providing the spec is mandatory due to freeze-point rules and -- the early use of it in the Put_Image aspect procedure My_Put_Image (Output : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; Obj : R); --$ begin cut procedure My_Put_Image (Output : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; Obj : R) is begin Output.Put ("my very own null record"); end My_Put_Image; --$ end cut O : R; begin Put_Line (O'Image); end Main;
AdaCore/gpr
Ada
26
adb
package 1pck is end 1pck;
charlie5/cBound
Ada
884
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with gmp_c.a_a_mpz_struct; with Interfaces.C; package gmp_c.a_a_mpq_struct is -- Item -- type Item is record a_mp_num : aliased gmp_c.a_a_mpz_struct.Item; a_mp_den : aliased gmp_c.a_a_mpz_struct.Item; end record; -- Items -- type Items is array (Interfaces.C.size_t range <>) of aliased gmp_c.a_a_mpq_struct.Item; -- Pointer -- type Pointer is access all gmp_c.a_a_mpq_struct.Item; -- Pointers -- type Pointers is array (Interfaces.C.size_t range <>) of aliased gmp_c.a_a_mpq_struct.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all gmp_c.a_a_mpq_struct.Pointer; function construct return gmp_c.a_a_mpq_struct.Item; private pragma Import (C, construct, "Ada_new___mpq_struct"); end gmp_c.a_a_mpq_struct;
aherd2985/Amass
Ada
3,150
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "SecurityTrails" type = "api" function start() setratelimit(1) end function check() local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local resp local vurl = verturl(domain) -- Check if the response data is in the graph database if (cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(vurl, cfg.ttl) end if (resp == nil or resp == "") then local err resp, err = request(ctx, { url=vurl, headers={ APIKEY=c.key, ['Content-Type']="application/json", }, }) if (err ~= nil and err ~= "") then return end if (cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(vurl, resp) end end local j = json.decode(resp) if (j == nil or #(j.subdomains) == 0) then return end for i, sub in pairs(j.subdomains) do sendnames(ctx, sub .. "." .. domain) end end function verturl(domain) return "https://api.securitytrails.com/v1/domain/" .. domain .. "/subdomains" end function sendnames(ctx, content) local names = find(content, subdomainre) if (names == nil) then return end local found = {} for i, v in pairs(names) do if (found[v] == nil) then newname(ctx, v) found[v] = true end end end function horizontal(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == "") then return end local resp local hurl = horizonurl(domain) -- Check if the response data is in the graph database if (cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(hurl, cfg.ttl) end if (resp == nil or resp == "") then local err resp, err = request(ctx, { url=hurl, headers={ APIKEY=c.key, ['Content-Type']="application/json", }, }) if (err ~= nil and err ~= "") then return end if (cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(hurl, resp) end end local j = json.decode(resp) if (j == nil or #(j.records) == 0) then return end for i, r in pairs(j.records) do if (r.hostname ~= "") then associated(ctx, domain, r.hostname) end end end function horizonurl(domain) return "https://api.securitytrails.com/v1/domain/" .. domain .. "/associated" end
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.Cell_Address_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Cell_Address_Attribute_Node is begin return Self : Table_Cell_Address_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_Cell_Address_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Cell_Address_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Cell_Address_Attribute, Table_Cell_Address_Attribute_Node'Tag); end Matreshka.ODF_Table.Cell_Address_Attributes;
tum-ei-rcs/StratoX
Ada
2,685
adb
-- Institution: Technische Universität München -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- -- Authors: Emanuel Regnath ([email protected]) with STM32.I2C; with STM32.Device; with HAL.I2C; with HMC5883L.Register; with Interfaces.Bit_Types; use Interfaces.Bit_Types; -- @summary -- Target-specific mapping for HIL of I2C package body HIL.I2C with SPARK_Mode => Off is ADDR_HMC5883L :constant HAL.I2C.I2C_Address := HMC5883L.Register.HMC5883L_ADDRESS; procedure initialize is Config : constant STM32.I2C.I2C_Configuration := ( Clock_Speed => 100_000, Mode => STM32.I2C.I2C_Mode, Duty_Cycle => STM32.I2C.DutyCycle_2, Addressing_Mode => STM32.I2C.Addressing_Mode_7bit, Own_Address => 16#00#, General_Call_Enabled => False, Clock_Stretching_Enabled => False ); begin STM32.Device.Reset(STM32.Device.I2C_1); STM32.I2C.Configure(STM32.Device.I2C_1, Config); -- is_Init := True; end initialize; procedure write (Device : in Device_Type; Data : in Data_Type) is Status : HAL.I2C.I2C_Status; begin case (Device) is when UNKNOWN => null; when MAGNETOMETER => STM32.I2C.Master_Transmit(STM32.Device.I2C_1, ADDR_HMC5883L, HAL.I2C.I2C_Data( Data ), Status); end case; end write; procedure read (Device : in Device_Type; Data : out Data_Type) is Data_RX_I2C : HAL.I2C.I2C_Data(1 .. Data'Length); Status : HAL.I2C.I2C_Status; begin case (Device) is when UNKNOWN => null; when MAGNETOMETER => STM32.I2C.Master_Receive(STM32.Device.I2C_1, ADDR_HMC5883L, Data_RX_I2C, Status); Data := Data_Type( Data_RX_I2C); end case; end read; procedure transfer (Device : in Device_Type; Data_TX : in Data_Type; Data_RX : out Data_Type) is Data_RX_I2C : HAL.I2C.I2C_Data(1 .. Data_RX'Length); Status : HAL.I2C.I2C_Status; begin case (Device) is when UNKNOWN => null; when MAGNETOMETER => STM32.I2C.Mem_Read(STM32.Device.I2C_1, ADDR_HMC5883L, Short( Data_TX(1) ), HAL.I2C.Memory_Size_8b, Data_RX_I2C, Status); -- STM32.I2C.Master_Transmit(STM32.Device.I2C_1, ADDR_HMC5883L, HAL.I2C.I2C_Data( Data_TX ), Status); -- STM32.I2C.Master_Receive(STM32.Device.I2C_1, ADDR_HMC5883L, Data_RX_I2C, Status); Data_RX := Data_Type( Data_RX_I2C); end case; end transfer; end HIL.I2C;
greifentor/archimedes-legacy
Ada
85,719
ads
<Diagramm> <AdditionalSQLCode> <SQLCode> <AdditionalSQLCodePostChanging></AdditionalSQLCodePostChanging> <AdditionalSQLCodePostReducing></AdditionalSQLCodePostReducing> <AdditionalSQLCodePreChanging></AdditionalSQLCodePreChanging> <AdditionalSQLCodePreExtending></AdditionalSQLCodePreExtending> </SQLCode> </AdditionalSQLCode> <Colors> <Anzahl>23</Anzahl> <Color0> <B>255</B> <G>0</G> <Name>blau</Name> <R>0</R> </Color0> <Color1> <B>221</B> <G>212</G> <Name>blaugrau</Name> <R>175</R> </Color1> <Color10> <B>192</B> <G>192</G> <Name>hellgrau</Name> <R>192</R> </Color10> <Color11> <B>255</B> <G>0</G> <Name>kamesinrot</Name> <R>255</R> </Color11> <Color12> <B>0</B> <G>200</G> <Name>orange</Name> <R>255</R> </Color12> <Color13> <B>255</B> <G>247</G> <Name>pastell-blau</Name> <R>211</R> </Color13> <Color14> <B>186</B> <G>245</G> <Name>pastell-gelb</Name> <R>255</R> </Color14> <Color15> <B>234</B> <G>255</G> <Name>pastell-gr&amp;uuml;n</Name> <R>211</R> </Color15> <Color16> <B>255</B> <G>211</G> <Name>pastell-lila</Name> <R>244</R> </Color16> <Color17> <B>191</B> <G>165</G> <Name>pastell-rot</Name> <R>244</R> </Color17> <Color18> <B>175</B> <G>175</G> <Name>pink</Name> <R>255</R> </Color18> <Color19> <B>0</B> <G>0</G> <Name>rot</Name> <R>255</R> </Color19> <Color2> <B>61</B> <G>125</G> <Name>braun</Name> <R>170</R> </Color2> <Color20> <B>0</B> <G>0</G> <Name>schwarz</Name> <R>0</R> </Color20> <Color21> <B>255</B> <G>255</G> <Name>t&amp;uuml;rkis</Name> <R>0</R> </Color21> <Color22> <B>255</B> <G>255</G> <Name>wei&amp;szlig;</Name> <R>255</R> </Color22> <Color3> <B>64</B> <G>64</G> <Name>dunkelgrau</Name> <R>64</R> </Color3> <Color4> <B>84</B> <G>132</G> <Name>dunkelgr&amp;uuml;n</Name> <R>94</R> </Color4> <Color5> <B>0</B> <G>255</G> <Name>gelb</Name> <R>255</R> </Color5> <Color6> <B>0</B> <G>225</G> <Name>goldgelb</Name> <R>255</R> </Color6> <Color7> <B>128</B> <G>128</G> <Name>grau</Name> <R>128</R> </Color7> <Color8> <B>0</B> <G>255</G> <Name>gr&amp;uuml;n</Name> <R>0</R> </Color8> <Color9> <B>255</B> <G>212</G> <Name>hellblau</Name> <R>191</R> </Color9> </Colors> <ComplexIndices> <IndexCount>0</IndexCount> </ComplexIndices> <DataSource> <Import> <DBName></DBName> <Description></Description> <Domains>false</Domains> <Driver></Driver> <Name></Name> <Referenzen>false</Referenzen> <User></User> </Import> </DataSource> <DatabaseConnections> <Count>2</Count> <DatabaseConnection0> <DBExecMode>POSTGRESQL</DBExecMode> <Driver>org.postgresql.Driver</Driver> <Name>LIB (PostgreSQL)</Name> <Quote>"</Quote> <SetDomains>false</SetDomains> <SetNotNull>true</SetNotNull> <SetReferences>true</SetReferences> <URL>jdbc:postgresql://MYKENE/TEST_OLI_ISIS_2</URL> <UserName>op1</UserName> </DatabaseConnection0> <DatabaseConnection1> <DBExecMode>MYSQL</DBExecMode> <Driver>com.mysql.jdbc.Driver</Driver> <Name>LIB (mySQL)</Name> <Quote></Quote> <SetDomains>false</SetDomains> <SetNotNull>false</SetNotNull> <SetReferences>false</SetReferences> <URL>jdbc:mysql://KIMON/LIB</URL> <UserName>lib</UserName> </DatabaseConnection1> </DatabaseConnections> <DefaultComment> <Anzahl>0</Anzahl> </DefaultComment> <Domains> <Anzahl>9</Anzahl> <Domain0> <Datatype>12</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>50</Length> <NKS>0</NKS> <Name>BookType</Name> <Parameters>ENUM: tst.BookType</Parameters> </Domain0> <Domain1> <Datatype>-7</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>0</Length> <NKS>0</NKS> <Name>Boolean</Name> <Parameters></Parameters> </Domain1> <Domain2> <Datatype>-1</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>0</Length> <NKS>0</NKS> <Name>Content</Name> <Parameters></Parameters> </Domain2> <Domain3> <Datatype>12</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>25</Length> <NKS>0</NKS> <Name>ISBN</Name> <Parameters></Parameters> </Domain3> <Domain4> <Datatype>-5</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>0</Length> <NKS>0</NKS> <Name>Ident</Name> <Parameters></Parameters> </Domain4> <Domain5> <Datatype>12</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>100</Length> <NKS>0</NKS> <Name>Name</Name> <Parameters></Parameters> </Domain5> <Domain6> <Datatype>2</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>8</Length> <NKS>2</NKS> <Name>Price</Name> <Parameters></Parameters> </Domain6> <Domain7> <Datatype>12</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>10</Length> <NKS>0</NKS> <Name>Signature</Name> <Parameters></Parameters> </Domain7> <Domain8> <Datatype>12</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>255</Length> <NKS>0</NKS> <Name>Title</Name> <Parameters></Parameters> </Domain8> </Domains> <Factories> <Object>archimedes.legacy.scheme.DefaultObjectFactory</Object> </Factories> <Pages> <PerColumn>5</PerColumn> <PerRow>10</PerRow> </Pages> <Parameter> <AdditionalSQLScriptListener></AdditionalSQLScriptListener> <Applicationname></Applicationname> <AufgehobeneAusblenden>false</AufgehobeneAusblenden> <Autor>ollie</Autor> <Basepackagename></Basepackagename> <CodeFactoryClassName></CodeFactoryClassName> <Codebasispfad>.\</Codebasispfad> <DBVersionDBVersionColumn></DBVersionDBVersionColumn> <DBVersionDescriptionColumn></DBVersionDescriptionColumn> <DBVersionTablename></DBVersionTablename> <History></History> <Kommentar>&amp;lt;null&amp;gt;</Kommentar> <Name>LIB</Name> <Optionen> <Anzahl>0</Anzahl> </Optionen> <PflichtfelderMarkieren>false</PflichtfelderMarkieren> <ReferenzierteSpaltenAnzeigen>true</ReferenzierteSpaltenAnzeigen> <RelationColorExternalTables>hellgrau</RelationColorExternalTables> <RelationColorRegular>schwarz</RelationColorRegular> <SchemaName>LIB</SchemaName> <Schriftgroessen> <Tabelleninhalte>16</Tabelleninhalte> <Ueberschriften>30</Ueberschriften> <Untertitel>16</Untertitel> </Schriftgroessen> <Scripte> <AfterWrite>&amp;lt;null&amp;gt;</AfterWrite> </Scripte> <TechnischeFelderAusgrauen>false</TechnischeFelderAusgrauen> <TransienteFelderAusgrauen>false</TransienteFelderAusgrauen> <UdschebtiBaseClassName></UdschebtiBaseClassName> <Version>1</Version> <Versionsdatum>16.12.2015</Versionsdatum> <Versionskommentar>&amp;lt;null&amp;gt;</Versionskommentar> </Parameter> <Sequences> <Count>0</Count> </Sequences> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Tabellen> <Anzahl>7</Anzahl> <Tabelle0> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>goldgelb</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>Book</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>4</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula></UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Id</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>BookType</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue>PAPER_BACK</IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>BookType</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte1> <Spalte2> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Content</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Content</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte2> <Spalte3> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Title</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>true</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Title</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte3> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>50</X> <Y>575</Y> </View0> </Views> </Tabelle0> <Tabelle1> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>pastell-gelb</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>Author</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>3</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula>Name &amp; Vorname</UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Id</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Name</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Name</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte1> <Spalte2> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Name</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Vorname</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte2> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>50</X> <Y>150</Y> </View0> </Views> </Tabelle1> <Tabelle2> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>hellblau</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>Publisher</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>2</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula></UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Id</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Name</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Name</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>true</Unique> </Spalte1> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>550</X> <Y>150</Y> </View0> </Views> </Tabelle2> <Tabelle3> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>pastell-gr&amp;uuml;n</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>Release</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>4</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula></UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>true</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Book</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <Referenz> <Direction0>LEFT</Direction0> <Direction1>RIGHT</Direction1> <Offset0>25</Offset0> <Offset1>25</Offset1> <Spalte>Id</Spalte> <Tabelle>Book</Tabelle> <Views> <Anzahl>1</Anzahl> <View0> <Direction0>LEFT</Direction0> <Direction1>RIGHT</Direction1> <Name>Main</Name> <Offset0>25</Offset0> <Offset1>25</Offset1> <Points> <Anzahl>0</Anzahl> </Points> </View0> </Views> </Referenz> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>true</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Publisher</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <Referenz> <Direction0>UP</Direction0> <Direction1>DOWN</Direction1> <Offset0>25</Offset0> <Offset1>25</Offset1> <Spalte>Id</Spalte> <Tabelle>Publisher</Tabelle> <Views> <Anzahl>1</Anzahl> <View0> <Direction0>UP</Direction0> <Direction1>DOWN</Direction1> <Name>Main</Name> <Offset0>25</Offset0> <Offset1>25</Offset1> <Points> <Anzahl>0</Anzahl> </Points> </View0> </Views> </Referenz> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte1> <Spalte2> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>ISBN</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>ISBN</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>true</Unique> </Spalte2> <Spalte3> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Price</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>RecommendedRetailPrice</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte3> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>550</X> <Y>575</Y> </View0> </Views> </Tabelle3> <Tabelle4> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>pastell-rot</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>WrittenBy</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>3</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula></UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>true</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Author</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <Referenz> <Direction0>UP</Direction0> <Direction1>DOWN</Direction1> <Offset0>25</Offset0> <Offset1>25</Offset1> <Spalte>Id</Spalte> <Tabelle>Author</Tabelle> <Views> <Anzahl>1</Anzahl> <View0> <Direction0>UP</Direction0> <Direction1>DOWN</Direction1> <Name>Main</Name> <Offset0>25</Offset0> <Offset1>25</Offset1> <Points> <Anzahl>0</Anzahl> </Points> </View0> </Views> </Referenz> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>true</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Book</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <Referenz> <Direction0>DOWN</Direction0> <Direction1>UP</Direction1> <Offset0>25</Offset0> <Offset1>25</Offset1> <Spalte>Id</Spalte> <Tabelle>Book</Tabelle> <Views> <Anzahl>1</Anzahl> <View0> <Direction0>DOWN</Direction0> <Direction1>UP</Direction1> <Name>Main</Name> <Offset0>25</Offset0> <Offset1>25</Offset1> <Points> <Anzahl>0</Anzahl> </Points> </View0> </Views> </Referenz> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte1> <Spalte2> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Boolean</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Editor</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte2> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>50</X> <Y>325</Y> </View0> </Views> </Tabelle4> <Tabelle5> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>grau</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>Stack</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>2</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula></UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Id</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Name</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Name</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>true</Unique> </Spalte1> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>50</X> <Y>1125</Y> </View0> </Views> </Tabelle5> <Tabelle6> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>hellgrau</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>BinLocation</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>3</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula></UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>true</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Book</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <Referenz> <Direction0>UP</Direction0> <Direction1>DOWN</Direction1> <Offset0>25</Offset0> <Offset1>25</Offset1> <Spalte>Id</Spalte> <Tabelle>Book</Tabelle> <Views> <Anzahl>1</Anzahl> <View0> <Direction0>UP</Direction0> <Direction1>DOWN</Direction1> <Name>Main</Name> <Offset0>25</Offset0> <Offset1>25</Offset1> <Points> <Anzahl>0</Anzahl> </Points> </View0> </Views> </Referenz> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>true</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Stack</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <Referenz> <Direction0>DOWN</Direction0> <Direction1>UP</Direction1> <Offset0>25</Offset0> <Offset1>25</Offset1> <Spalte>Id</Spalte> <Tabelle>Stack</Tabelle> <Views> <Anzahl>1</Anzahl> <View0> <Direction0>DOWN</Direction0> <Direction1>UP</Direction1> <Name>Main</Name> <Offset0>25</Offset0> <Offset1>25</Offset1> <Points> <Anzahl>0</Anzahl> </Points> </View0> </Views> </Referenz> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte1> <Spalte2> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Signature</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Signature</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>true</Unique> </Spalte2> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>50</X> <Y>825</Y> </View0> </Views> </Tabelle6> </Tabellen> <Views> <Anzahl>1</Anzahl> <View0> <Beschreibung>Diese Sicht beinhaltet alle Tabellen des Schemas</Beschreibung> <Name>Main</Name> <ReferenzierteSpaltenAnzeigen>true</ReferenzierteSpaltenAnzeigen> <Tabelle0>Book</Tabelle0> <Tabelle1>Author</Tabelle1> <Tabelle2>Publisher</Tabelle2> <Tabelle3>Release</Tabelle3> <Tabelle4>WrittenBy</Tabelle4> <Tabelle5>Stack</Tabelle5> <Tabelle6>BinLocation</Tabelle6> <Tabellenanzahl>7</Tabellenanzahl> <TechnischeSpaltenVerstecken>false</TechnischeSpaltenVerstecken> </View0> </Views> </Diagramm>
joakim-strandberg/wayland_ada_binding
Ada
2,834
adb
package body C_Binding.Linux.Files is procedure Set_File_Descriptor (This : in out File; Value : Integer) is begin This.My_File_Descriptor := Interfaces.C.int (Value); end Set_File_Descriptor; procedure Open (This : in out File; File_Name : in String; Mode : in File_Mode; Permissions : in File_Permissions) is M : O_FLag := 0; P : S_FLag := 0; begin case Mode is when Read_Only => M := M or O_RDONLY; when Write_Only => M := M or O_WRONLY; when Read_Write => M := M or O_RDWR; end case; if Permissions (Owner_Read) then P := P or S_IRUSR; end if; if Permissions (Owner_Write) then P := P or S_IWUSR; end if; if Permissions (Owner_Execute) then P := P or S_IXGRP; end if; if Permissions (Group_Read) then P := P or S_IRGRP; end if; if Permissions (Group_Write) then P := P or S_IWGRP; end if; if Permissions (Group_Execute) then P := P or S_IXUSR; end if; if Permissions (Others_Read) then P := P or S_IROTH; end if; if Permissions (Others_Write) then P := P or S_IWOTH; end if; if Permissions (Others_Execute) then P := P or S_IXOTH; end if; This.My_File_Descriptor := C_Open (+File_Name, M, P); end Open; function Close (This : in out File) return Success_Flag is Result : Interfaces.C.int; Flag : Success_Flag; begin Result := C_Close (Interfaces.C.int (This.My_File_Descriptor)); if Result = -1 then Flag := Failure; else Flag := Success; end if; return Flag; end Close; procedure Write (This : File; Bytes : Ada.Streams.Stream_Element_Array) is SSize : SSize_Type; pragma Unreferenced (SSize); begin SSize := C_Write (File_Descriptor => Interfaces.C.int (This.My_File_Descriptor), Buffer => Bytes, Count => Bytes'Length); end Write; function Read (This : File; Bytes : in out Ada.Streams.Stream_Element_Array) return Read_Result is Result : SSize_Type := C_Read (Interfaces.C.int (This.My_File_Descriptor), Bytes, Bytes'Length); begin case Result is when SSize_Type'First .. -1 => return (Kind_Id => Read_Failure); when 0 => return (Kind_Id => End_Of_File_Reached); when 1 .. SSize_Type'Last => return (Kind_Id => Read_Success, Element_Count => Ada.Streams.Stream_Element_Count (Result)); end case; end Read; end C_Binding.Linux.Files;
MinimSecure/unum-sdk
Ada
1,024
ads
-- Copyright 2015-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. generic type Index_Base_T is range <>; type Component_T is private; package Array_List_G is subtype Length_T is Index_Base_T range 0 .. Index_Base_T'Last; subtype Index_T is Length_T range 1 .. Length_T'Last; type T is array (Index_T range <>) of Component_T; pragma Pack(T); end Array_List_G;
jwarwick/aoc_2020
Ada
322
adb
-- AOC 2020, Day 6 with Ada.Text_IO; use Ada.Text_IO; with Day; use Day; procedure main is anyone : constant Natural := anyone_sum("input.txt"); everyone : constant Natural := everyone_sum("input.txt"); begin put_line("Part 1: " & Natural'Image(anyone)); put_line("Part 2: " & Natural'Image(everyone)); end main;
reznikmm/matreshka
Ada
3,629
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_P_Elements is pragma Preelaborate; type ODF_Text_P is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_P_Access is access all ODF_Text_P'Class with Storage_Size => 0; end ODF.DOM.Text_P_Elements;
AdaCore/Ada_Drivers_Library
Ada
62,522
ads
-- This spec has been automatically generated from STM32F46_79x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.CAN is pragma Preelaborate; --------------- -- Registers -- --------------- -- master control register type MCR_Register is record -- INRQ INRQ : Boolean := False; -- SLEEP SLEEP : Boolean := True; -- TXFP TXFP : Boolean := False; -- RFLM RFLM : Boolean := False; -- NART NART : Boolean := False; -- AWUM AWUM : Boolean := False; -- ABOM ABOM : Boolean := False; -- TTCM TTCM : Boolean := False; -- unspecified Reserved_8_14 : HAL.UInt7 := 16#0#; -- RESET RESET : Boolean := False; -- DBF DBF : Boolean := True; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MCR_Register use record INRQ at 0 range 0 .. 0; SLEEP at 0 range 1 .. 1; TXFP at 0 range 2 .. 2; RFLM at 0 range 3 .. 3; NART at 0 range 4 .. 4; AWUM at 0 range 5 .. 5; ABOM at 0 range 6 .. 6; TTCM at 0 range 7 .. 7; Reserved_8_14 at 0 range 8 .. 14; RESET at 0 range 15 .. 15; DBF at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; -- master status register type MSR_Register is record -- Read-only. INAK INAK : Boolean := False; -- Read-only. SLAK SLAK : Boolean := True; -- ERRI ERRI : Boolean := False; -- WKUI WKUI : Boolean := False; -- SLAKI SLAKI : Boolean := False; -- unspecified Reserved_5_7 : HAL.UInt3 := 16#0#; -- Read-only. TXM TXM : Boolean := False; -- Read-only. RXM RXM : Boolean := False; -- Read-only. SAMP SAMP : Boolean := True; -- Read-only. RX RX : Boolean := True; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MSR_Register use record INAK at 0 range 0 .. 0; SLAK at 0 range 1 .. 1; ERRI at 0 range 2 .. 2; WKUI at 0 range 3 .. 3; SLAKI at 0 range 4 .. 4; Reserved_5_7 at 0 range 5 .. 7; TXM at 0 range 8 .. 8; RXM at 0 range 9 .. 9; SAMP at 0 range 10 .. 10; RX at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype TSR_CODE_Field is HAL.UInt2; -- TSR_TME array type TSR_TME_Field_Array is array (0 .. 2) of Boolean with Component_Size => 1, Size => 3; -- Type definition for TSR_TME type TSR_TME_Field (As_Array : Boolean := False) is record case As_Array is when False => -- TME as a value Val : HAL.UInt3; when True => -- TME as an array Arr : TSR_TME_Field_Array; end case; end record with Unchecked_Union, Size => 3; for TSR_TME_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- TSR_LOW array type TSR_LOW_Field_Array is array (0 .. 2) of Boolean with Component_Size => 1, Size => 3; -- Type definition for TSR_LOW type TSR_LOW_Field (As_Array : Boolean := False) is record case As_Array is when False => -- LOW as a value Val : HAL.UInt3; when True => -- LOW as an array Arr : TSR_LOW_Field_Array; end case; end record with Unchecked_Union, Size => 3; for TSR_LOW_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- transmit status register type TSR_Register is record -- RQCP0 RQCP0 : Boolean := False; -- TXOK0 TXOK0 : Boolean := False; -- ALST0 ALST0 : Boolean := False; -- TERR0 TERR0 : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- ABRQ0 ABRQ0 : Boolean := False; -- RQCP1 RQCP1 : Boolean := False; -- TXOK1 TXOK1 : Boolean := False; -- ALST1 ALST1 : Boolean := False; -- TERR1 TERR1 : Boolean := False; -- unspecified Reserved_12_14 : HAL.UInt3 := 16#0#; -- ABRQ1 ABRQ1 : Boolean := False; -- RQCP2 RQCP2 : Boolean := False; -- TXOK2 TXOK2 : Boolean := False; -- ALST2 ALST2 : Boolean := False; -- TERR2 TERR2 : Boolean := False; -- unspecified Reserved_20_22 : HAL.UInt3 := 16#0#; -- ABRQ2 ABRQ2 : Boolean := False; -- Read-only. CODE CODE : TSR_CODE_Field := 16#0#; -- Read-only. Lowest priority flag for mailbox 0 TME : TSR_TME_Field := (As_Array => False, Val => 16#1#); -- Read-only. Lowest priority flag for mailbox 0 LOW : TSR_LOW_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSR_Register use record RQCP0 at 0 range 0 .. 0; TXOK0 at 0 range 1 .. 1; ALST0 at 0 range 2 .. 2; TERR0 at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ABRQ0 at 0 range 7 .. 7; RQCP1 at 0 range 8 .. 8; TXOK1 at 0 range 9 .. 9; ALST1 at 0 range 10 .. 10; TERR1 at 0 range 11 .. 11; Reserved_12_14 at 0 range 12 .. 14; ABRQ1 at 0 range 15 .. 15; RQCP2 at 0 range 16 .. 16; TXOK2 at 0 range 17 .. 17; ALST2 at 0 range 18 .. 18; TERR2 at 0 range 19 .. 19; Reserved_20_22 at 0 range 20 .. 22; ABRQ2 at 0 range 23 .. 23; CODE at 0 range 24 .. 25; TME at 0 range 26 .. 28; LOW at 0 range 29 .. 31; end record; subtype RF0R_FMP0_Field is HAL.UInt2; -- receive FIFO 0 register type RF0R_Register is record -- Read-only. FMP0 FMP0 : RF0R_FMP0_Field := 16#0#; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- FULL0 FULL0 : Boolean := False; -- FOVR0 FOVR0 : Boolean := False; -- RFOM0 RFOM0 : Boolean := False; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RF0R_Register use record FMP0 at 0 range 0 .. 1; Reserved_2_2 at 0 range 2 .. 2; FULL0 at 0 range 3 .. 3; FOVR0 at 0 range 4 .. 4; RFOM0 at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; subtype RF1R_FMP1_Field is HAL.UInt2; -- receive FIFO 1 register type RF1R_Register is record -- Read-only. FMP1 FMP1 : RF1R_FMP1_Field := 16#0#; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- FULL1 FULL1 : Boolean := False; -- FOVR1 FOVR1 : Boolean := False; -- RFOM1 RFOM1 : Boolean := False; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RF1R_Register use record FMP1 at 0 range 0 .. 1; Reserved_2_2 at 0 range 2 .. 2; FULL1 at 0 range 3 .. 3; FOVR1 at 0 range 4 .. 4; RFOM1 at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- interrupt enable register type IER_Register is record -- TMEIE TMEIE : Boolean := False; -- FMPIE0 FMPIE0 : Boolean := False; -- FFIE0 FFIE0 : Boolean := False; -- FOVIE0 FOVIE0 : Boolean := False; -- FMPIE1 FMPIE1 : Boolean := False; -- FFIE1 FFIE1 : Boolean := False; -- FOVIE1 FOVIE1 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- EWGIE EWGIE : Boolean := False; -- EPVIE EPVIE : Boolean := False; -- BOFIE BOFIE : Boolean := False; -- LECIE LECIE : Boolean := False; -- unspecified Reserved_12_14 : HAL.UInt3 := 16#0#; -- ERRIE ERRIE : Boolean := False; -- WKUIE WKUIE : Boolean := False; -- SLKIE SLKIE : Boolean := False; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IER_Register use record TMEIE at 0 range 0 .. 0; FMPIE0 at 0 range 1 .. 1; FFIE0 at 0 range 2 .. 2; FOVIE0 at 0 range 3 .. 3; FMPIE1 at 0 range 4 .. 4; FFIE1 at 0 range 5 .. 5; FOVIE1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; EWGIE at 0 range 8 .. 8; EPVIE at 0 range 9 .. 9; BOFIE at 0 range 10 .. 10; LECIE at 0 range 11 .. 11; Reserved_12_14 at 0 range 12 .. 14; ERRIE at 0 range 15 .. 15; WKUIE at 0 range 16 .. 16; SLKIE at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; subtype ESR_LEC_Field is HAL.UInt3; subtype ESR_TEC_Field is HAL.UInt8; subtype ESR_REC_Field is HAL.UInt8; -- interrupt enable register type ESR_Register is record -- Read-only. EWGF EWGF : Boolean := False; -- Read-only. EPVF EPVF : Boolean := False; -- Read-only. BOFF BOFF : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- LEC LEC : ESR_LEC_Field := 16#0#; -- unspecified Reserved_7_15 : HAL.UInt9 := 16#0#; -- Read-only. TEC TEC : ESR_TEC_Field := 16#0#; -- Read-only. REC REC : ESR_REC_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ESR_Register use record EWGF at 0 range 0 .. 0; EPVF at 0 range 1 .. 1; BOFF at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; LEC at 0 range 4 .. 6; Reserved_7_15 at 0 range 7 .. 15; TEC at 0 range 16 .. 23; REC at 0 range 24 .. 31; end record; subtype BTR_BRP_Field is HAL.UInt10; subtype BTR_TS1_Field is HAL.UInt4; subtype BTR_TS2_Field is HAL.UInt3; subtype BTR_SJW_Field is HAL.UInt2; -- bit timing register type BTR_Register is record -- BRP BRP : BTR_BRP_Field := 16#0#; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; -- TS1 TS1 : BTR_TS1_Field := 16#0#; -- TS2 TS2 : BTR_TS2_Field := 16#0#; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- SJW SJW : BTR_SJW_Field := 16#0#; -- unspecified Reserved_26_29 : HAL.UInt4 := 16#0#; -- LBKM LBKM : Boolean := False; -- SILM SILM : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BTR_Register use record BRP at 0 range 0 .. 9; Reserved_10_15 at 0 range 10 .. 15; TS1 at 0 range 16 .. 19; TS2 at 0 range 20 .. 22; Reserved_23_23 at 0 range 23 .. 23; SJW at 0 range 24 .. 25; Reserved_26_29 at 0 range 26 .. 29; LBKM at 0 range 30 .. 30; SILM at 0 range 31 .. 31; end record; subtype TI0R_EXID_Field is HAL.UInt18; subtype TI0R_STID_Field is HAL.UInt11; -- TX mailbox identifier register type TI0R_Register is record -- TXRQ TXRQ : Boolean := False; -- RTR RTR : Boolean := False; -- IDE IDE : Boolean := False; -- EXID EXID : TI0R_EXID_Field := 16#0#; -- STID STID : TI0R_STID_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TI0R_Register use record TXRQ at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; subtype TDT0R_DLC_Field is HAL.UInt4; subtype TDT0R_TIME_Field is HAL.UInt16; -- mailbox data length control and time stamp register type TDT0R_Register is record -- DLC DLC : TDT0R_DLC_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- TGT TGT : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- TIME TIME : TDT0R_TIME_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TDT0R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; TGT at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; TIME at 0 range 16 .. 31; end record; -- TDL0R_DATA array element subtype TDL0R_DATA_Element is HAL.UInt8; -- TDL0R_DATA array type TDL0R_DATA_Field_Array is array (0 .. 3) of TDL0R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data low register type TDL0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : TDL0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDL0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- TDH0R_DATA array element subtype TDH0R_DATA_Element is HAL.UInt8; -- TDH0R_DATA array type TDH0R_DATA_Field_Array is array (4 .. 7) of TDH0R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type TDH0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : TDH0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDH0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; subtype TI1R_EXID_Field is HAL.UInt18; subtype TI1R_STID_Field is HAL.UInt11; -- mailbox identifier register type TI1R_Register is record -- TXRQ TXRQ : Boolean := False; -- RTR RTR : Boolean := False; -- IDE IDE : Boolean := False; -- EXID EXID : TI1R_EXID_Field := 16#0#; -- STID STID : TI1R_STID_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TI1R_Register use record TXRQ at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; subtype TDT1R_DLC_Field is HAL.UInt4; subtype TDT1R_TIME_Field is HAL.UInt16; -- mailbox data length control and time stamp register type TDT1R_Register is record -- DLC DLC : TDT1R_DLC_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- TGT TGT : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- TIME TIME : TDT1R_TIME_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TDT1R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; TGT at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; TIME at 0 range 16 .. 31; end record; -- TDL1R_DATA array element subtype TDL1R_DATA_Element is HAL.UInt8; -- TDL1R_DATA array type TDL1R_DATA_Field_Array is array (0 .. 3) of TDL1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data low register type TDL1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : TDL1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDL1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- TDH1R_DATA array element subtype TDH1R_DATA_Element is HAL.UInt8; -- TDH1R_DATA array type TDH1R_DATA_Field_Array is array (4 .. 7) of TDH1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type TDH1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : TDH1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDH1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; subtype TI2R_EXID_Field is HAL.UInt18; subtype TI2R_STID_Field is HAL.UInt11; -- mailbox identifier register type TI2R_Register is record -- TXRQ TXRQ : Boolean := False; -- RTR RTR : Boolean := False; -- IDE IDE : Boolean := False; -- EXID EXID : TI2R_EXID_Field := 16#0#; -- STID STID : TI2R_STID_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TI2R_Register use record TXRQ at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; subtype TDT2R_DLC_Field is HAL.UInt4; subtype TDT2R_TIME_Field is HAL.UInt16; -- mailbox data length control and time stamp register type TDT2R_Register is record -- DLC DLC : TDT2R_DLC_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- TGT TGT : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- TIME TIME : TDT2R_TIME_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TDT2R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; TGT at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; TIME at 0 range 16 .. 31; end record; -- TDL2R_DATA array element subtype TDL2R_DATA_Element is HAL.UInt8; -- TDL2R_DATA array type TDL2R_DATA_Field_Array is array (0 .. 3) of TDL2R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data low register type TDL2R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : TDL2R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDL2R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- TDH2R_DATA array element subtype TDH2R_DATA_Element is HAL.UInt8; -- TDH2R_DATA array type TDH2R_DATA_Field_Array is array (4 .. 7) of TDH2R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type TDH2R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : TDH2R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for TDH2R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; subtype RI0R_EXID_Field is HAL.UInt18; subtype RI0R_STID_Field is HAL.UInt11; -- receive FIFO mailbox identifier register type RI0R_Register is record -- unspecified Reserved_0_0 : HAL.Bit; -- Read-only. RTR RTR : Boolean; -- Read-only. IDE IDE : Boolean; -- Read-only. EXID EXID : RI0R_EXID_Field; -- Read-only. STID STID : RI0R_STID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RI0R_Register use record Reserved_0_0 at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; subtype RDT0R_DLC_Field is HAL.UInt4; subtype RDT0R_FMI_Field is HAL.UInt8; subtype RDT0R_TIME_Field is HAL.UInt16; -- mailbox data high register type RDT0R_Register is record -- Read-only. DLC DLC : RDT0R_DLC_Field; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. FMI FMI : RDT0R_FMI_Field; -- Read-only. TIME TIME : RDT0R_TIME_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RDT0R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; FMI at 0 range 8 .. 15; TIME at 0 range 16 .. 31; end record; -- RDL0R_DATA array element subtype RDL0R_DATA_Element is HAL.UInt8; -- RDL0R_DATA array type RDL0R_DATA_Field_Array is array (0 .. 3) of RDL0R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type RDL0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : RDL0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDL0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- RDH0R_DATA array element subtype RDH0R_DATA_Element is HAL.UInt8; -- RDH0R_DATA array type RDH0R_DATA_Field_Array is array (4 .. 7) of RDH0R_DATA_Element with Component_Size => 8, Size => 32; -- receive FIFO mailbox data high register type RDH0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : RDH0R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDH0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; subtype RI1R_EXID_Field is HAL.UInt18; subtype RI1R_STID_Field is HAL.UInt11; -- mailbox data high register type RI1R_Register is record -- unspecified Reserved_0_0 : HAL.Bit; -- Read-only. RTR RTR : Boolean; -- Read-only. IDE IDE : Boolean; -- Read-only. EXID EXID : RI1R_EXID_Field; -- Read-only. STID STID : RI1R_STID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RI1R_Register use record Reserved_0_0 at 0 range 0 .. 0; RTR at 0 range 1 .. 1; IDE at 0 range 2 .. 2; EXID at 0 range 3 .. 20; STID at 0 range 21 .. 31; end record; subtype RDT1R_DLC_Field is HAL.UInt4; subtype RDT1R_FMI_Field is HAL.UInt8; subtype RDT1R_TIME_Field is HAL.UInt16; -- mailbox data high register type RDT1R_Register is record -- Read-only. DLC DLC : RDT1R_DLC_Field; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. FMI FMI : RDT1R_FMI_Field; -- Read-only. TIME TIME : RDT1R_TIME_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RDT1R_Register use record DLC at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; FMI at 0 range 8 .. 15; TIME at 0 range 16 .. 31; end record; -- RDL1R_DATA array element subtype RDL1R_DATA_Element is HAL.UInt8; -- RDL1R_DATA array type RDL1R_DATA_Field_Array is array (0 .. 3) of RDL1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type RDL1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : RDL1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDL1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- RDH1R_DATA array element subtype RDH1R_DATA_Element is HAL.UInt8; -- RDH1R_DATA array type RDH1R_DATA_Field_Array is array (4 .. 7) of RDH1R_DATA_Element with Component_Size => 8, Size => 32; -- mailbox data high register type RDH1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt32; when True => -- DATA as an array Arr : RDH1R_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RDH1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; subtype FMR_CAN2SB_Field is HAL.UInt6; -- filter master register type FMR_Register is record -- FINIT FINIT : Boolean := True; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; -- CAN2SB CAN2SB : FMR_CAN2SB_Field := 16#E#; -- unspecified Reserved_14_31 : HAL.UInt18 := 16#A870#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FMR_Register use record FINIT at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; CAN2SB at 0 range 8 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; -- FM1R_FBM array type FM1R_FBM_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FM1R_FBM type FM1R_FBM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FBM as a value Val : HAL.UInt28; when True => -- FBM as an array Arr : FM1R_FBM_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FM1R_FBM_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter mode register type FM1R_Register is record -- Filter mode FBM : FM1R_FBM_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FM1R_Register use record FBM at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- FS1R_FSC array type FS1R_FSC_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FS1R_FSC type FS1R_FSC_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FSC as a value Val : HAL.UInt28; when True => -- FSC as an array Arr : FS1R_FSC_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FS1R_FSC_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter scale register type FS1R_Register is record -- Filter scale configuration FSC : FS1R_FSC_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS1R_Register use record FSC at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- FFA1R_FFA array type FFA1R_FFA_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FFA1R_FFA type FFA1R_FFA_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FFA as a value Val : HAL.UInt28; when True => -- FFA as an array Arr : FFA1R_FFA_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FFA1R_FFA_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter FIFO assignment register type FFA1R_Register is record -- Filter FIFO assignment for filter 0 FFA : FFA1R_FFA_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FFA1R_Register use record FFA at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- FA1R_FACT array type FA1R_FACT_Field_Array is array (0 .. 27) of Boolean with Component_Size => 1, Size => 28; -- Type definition for FA1R_FACT type FA1R_FACT_Field (As_Array : Boolean := False) is record case As_Array is when False => -- FACT as a value Val : HAL.UInt28; when True => -- FACT as an array Arr : FA1R_FACT_Field_Array; end case; end record with Unchecked_Union, Size => 28; for FA1R_FACT_Field use record Val at 0 range 0 .. 27; Arr at 0 range 0 .. 27; end record; -- filter activation register type FA1R_Register is record -- Filter active FACT : FA1R_FACT_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FA1R_Register use record FACT at 0 range 0 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- F0R_FB array type F0R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 0 register 1 type F0R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F0R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F0R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F1R_FB array type F1R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 1 register 1 type F1R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F1R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F1R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F2R_FB array type F2R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 2 register 1 type F2R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F2R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F2R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F3R_FB array type F3R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 3 register 1 type F3R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F3R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F3R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F4R_FB array type F4R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 4 register 1 type F4R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F4R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F4R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F5R_FB array type F5R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 5 register 1 type F5R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F5R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F5R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F6R_FB array type F6R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 6 register 1 type F6R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F6R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F6R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F7R_FB array type F7R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 7 register 1 type F7R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F7R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F7R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F8R_FB array type F8R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 8 register 1 type F8R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F8R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F8R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F9R_FB array type F9R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 9 register 1 type F9R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F9R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F9R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F10R_FB array type F10R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 10 register 1 type F10R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F10R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F10R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F11R_FB array type F11R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 11 register 1 type F11R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F11R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F11R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F12R_FB array type F12R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 4 register 1 type F12R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F12R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F12R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F13R_FB array type F13R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 13 register 1 type F13R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F13R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F13R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F14R_FB array type F14R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 14 register 1 type F14R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F14R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F14R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F15R_FB array type F15R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 15 register 1 type F15R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F15R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F15R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F16R_FB array type F16R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 16 register 1 type F16R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F16R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F16R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F17R_FB array type F17R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 17 register 1 type F17R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F17R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F17R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F18R_FB array type F18R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 18 register 1 type F18R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F18R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F18R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F19R_FB array type F19R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 19 register 1 type F19R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F19R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F19R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F20R_FB array type F20R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 20 register 1 type F20R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F20R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F20R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F21R_FB array type F21R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 21 register 1 type F21R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F21R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F21R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F22R_FB array type F22R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 22 register 1 type F22R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F22R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F22R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F23R_FB array type F23R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 23 register 1 type F23R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F23R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F23R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F24R_FB array type F24R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 24 register 1 type F24R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F24R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F24R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F25R_FB array type F25R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 25 register 1 type F25R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F25R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F25R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F26R_FB array type F26R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 26 register 1 type F26R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F26R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F26R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- F27R_FB array type F27R_FB_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Filter bank 27 register 1 type F27R_Register (As_Array : Boolean := False) is record case As_Array is when False => -- FB as a value Val : HAL.UInt32; when True => -- FB as an array Arr : F27R_FB_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for F27R_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Controller area network type CAN_Peripheral is record -- master control register MCR : aliased MCR_Register; -- master status register MSR : aliased MSR_Register; -- transmit status register TSR : aliased TSR_Register; -- receive FIFO 0 register RF0R : aliased RF0R_Register; -- receive FIFO 1 register RF1R : aliased RF1R_Register; -- interrupt enable register IER : aliased IER_Register; -- interrupt enable register ESR : aliased ESR_Register; -- bit timing register BTR : aliased BTR_Register; -- TX mailbox identifier register TI0R : aliased TI0R_Register; -- mailbox data length control and time stamp register TDT0R : aliased TDT0R_Register; -- mailbox data low register TDL0R : aliased TDL0R_Register; -- mailbox data high register TDH0R : aliased TDH0R_Register; -- mailbox identifier register TI1R : aliased TI1R_Register; -- mailbox data length control and time stamp register TDT1R : aliased TDT1R_Register; -- mailbox data low register TDL1R : aliased TDL1R_Register; -- mailbox data high register TDH1R : aliased TDH1R_Register; -- mailbox identifier register TI2R : aliased TI2R_Register; -- mailbox data length control and time stamp register TDT2R : aliased TDT2R_Register; -- mailbox data low register TDL2R : aliased TDL2R_Register; -- mailbox data high register TDH2R : aliased TDH2R_Register; -- receive FIFO mailbox identifier register RI0R : aliased RI0R_Register; -- mailbox data high register RDT0R : aliased RDT0R_Register; -- mailbox data high register RDL0R : aliased RDL0R_Register; -- receive FIFO mailbox data high register RDH0R : aliased RDH0R_Register; -- mailbox data high register RI1R : aliased RI1R_Register; -- mailbox data high register RDT1R : aliased RDT1R_Register; -- mailbox data high register RDL1R : aliased RDL1R_Register; -- mailbox data high register RDH1R : aliased RDH1R_Register; -- filter master register FMR : aliased FMR_Register; -- filter mode register FM1R : aliased FM1R_Register; -- filter scale register FS1R : aliased FS1R_Register; -- filter FIFO assignment register FFA1R : aliased FFA1R_Register; -- filter activation register FA1R : aliased FA1R_Register; -- Filter bank 0 register 1 F0R1 : aliased F0R_Register; -- Filter bank 0 register 2 F0R2 : aliased F0R_Register; -- Filter bank 1 register 1 F1R1 : aliased F1R_Register; -- Filter bank 1 register 2 F1R2 : aliased F1R_Register; -- Filter bank 2 register 1 F2R1 : aliased F2R_Register; -- Filter bank 2 register 2 F2R2 : aliased F2R_Register; -- Filter bank 3 register 1 F3R1 : aliased F3R_Register; -- Filter bank 3 register 2 F3R2 : aliased F3R_Register; -- Filter bank 4 register 1 F4R1 : aliased F4R_Register; -- Filter bank 4 register 2 F4R2 : aliased F4R_Register; -- Filter bank 5 register 1 F5R1 : aliased F5R_Register; -- Filter bank 5 register 2 F5R2 : aliased F5R_Register; -- Filter bank 6 register 1 F6R1 : aliased F6R_Register; -- Filter bank 6 register 2 F6R2 : aliased F6R_Register; -- Filter bank 7 register 1 F7R1 : aliased F7R_Register; -- Filter bank 7 register 2 F7R2 : aliased F7R_Register; -- Filter bank 8 register 1 F8R1 : aliased F8R_Register; -- Filter bank 8 register 2 F8R2 : aliased F8R_Register; -- Filter bank 9 register 1 F9R1 : aliased F9R_Register; -- Filter bank 9 register 2 F9R2 : aliased F9R_Register; -- Filter bank 10 register 1 F10R1 : aliased F10R_Register; -- Filter bank 10 register 2 F10R2 : aliased F10R_Register; -- Filter bank 11 register 1 F11R1 : aliased F11R_Register; -- Filter bank 11 register 2 F11R2 : aliased F11R_Register; -- Filter bank 4 register 1 F12R1 : aliased F12R_Register; -- Filter bank 12 register 2 F12R2 : aliased F12R_Register; -- Filter bank 13 register 1 F13R1 : aliased F13R_Register; -- Filter bank 13 register 2 F13R2 : aliased F13R_Register; -- Filter bank 14 register 1 F14R1 : aliased F14R_Register; -- Filter bank 14 register 2 F14R2 : aliased F14R_Register; -- Filter bank 15 register 1 F15R1 : aliased F15R_Register; -- Filter bank 15 register 2 F15R2 : aliased F15R_Register; -- Filter bank 16 register 1 F16R1 : aliased F16R_Register; -- Filter bank 16 register 2 F16R2 : aliased F16R_Register; -- Filter bank 17 register 1 F17R1 : aliased F17R_Register; -- Filter bank 17 register 2 F17R2 : aliased F17R_Register; -- Filter bank 18 register 1 F18R1 : aliased F18R_Register; -- Filter bank 18 register 2 F18R2 : aliased F18R_Register; -- Filter bank 19 register 1 F19R1 : aliased F19R_Register; -- Filter bank 19 register 2 F19R2 : aliased F19R_Register; -- Filter bank 20 register 1 F20R1 : aliased F20R_Register; -- Filter bank 20 register 2 F20R2 : aliased F20R_Register; -- Filter bank 21 register 1 F21R1 : aliased F21R_Register; -- Filter bank 21 register 2 F21R2 : aliased F21R_Register; -- Filter bank 22 register 1 F22R1 : aliased F22R_Register; -- Filter bank 22 register 2 F22R2 : aliased F22R_Register; -- Filter bank 23 register 1 F23R1 : aliased F23R_Register; -- Filter bank 23 register 2 F23R2 : aliased F23R_Register; -- Filter bank 24 register 1 F24R1 : aliased F24R_Register; -- Filter bank 24 register 2 F24R2 : aliased F24R_Register; -- Filter bank 25 register 1 F25R1 : aliased F25R_Register; -- Filter bank 25 register 2 F25R2 : aliased F25R_Register; -- Filter bank 26 register 1 F26R1 : aliased F26R_Register; -- Filter bank 26 register 2 F26R2 : aliased F26R_Register; -- Filter bank 27 register 1 F27R1 : aliased F27R_Register; -- Filter bank 27 register 2 F27R2 : aliased F27R_Register; end record with Volatile; for CAN_Peripheral use record MCR at 16#0# range 0 .. 31; MSR at 16#4# range 0 .. 31; TSR at 16#8# range 0 .. 31; RF0R at 16#C# range 0 .. 31; RF1R at 16#10# range 0 .. 31; IER at 16#14# range 0 .. 31; ESR at 16#18# range 0 .. 31; BTR at 16#1C# range 0 .. 31; TI0R at 16#180# range 0 .. 31; TDT0R at 16#184# range 0 .. 31; TDL0R at 16#188# range 0 .. 31; TDH0R at 16#18C# range 0 .. 31; TI1R at 16#190# range 0 .. 31; TDT1R at 16#194# range 0 .. 31; TDL1R at 16#198# range 0 .. 31; TDH1R at 16#19C# range 0 .. 31; TI2R at 16#1A0# range 0 .. 31; TDT2R at 16#1A4# range 0 .. 31; TDL2R at 16#1A8# range 0 .. 31; TDH2R at 16#1AC# range 0 .. 31; RI0R at 16#1B0# range 0 .. 31; RDT0R at 16#1B4# range 0 .. 31; RDL0R at 16#1B8# range 0 .. 31; RDH0R at 16#1BC# range 0 .. 31; RI1R at 16#1C0# range 0 .. 31; RDT1R at 16#1C4# range 0 .. 31; RDL1R at 16#1C8# range 0 .. 31; RDH1R at 16#1CC# range 0 .. 31; FMR at 16#200# range 0 .. 31; FM1R at 16#204# range 0 .. 31; FS1R at 16#20C# range 0 .. 31; FFA1R at 16#214# range 0 .. 31; FA1R at 16#21C# range 0 .. 31; F0R1 at 16#240# range 0 .. 31; F0R2 at 16#244# range 0 .. 31; F1R1 at 16#248# range 0 .. 31; F1R2 at 16#24C# range 0 .. 31; F2R1 at 16#250# range 0 .. 31; F2R2 at 16#254# range 0 .. 31; F3R1 at 16#258# range 0 .. 31; F3R2 at 16#25C# range 0 .. 31; F4R1 at 16#260# range 0 .. 31; F4R2 at 16#264# range 0 .. 31; F5R1 at 16#268# range 0 .. 31; F5R2 at 16#26C# range 0 .. 31; F6R1 at 16#270# range 0 .. 31; F6R2 at 16#274# range 0 .. 31; F7R1 at 16#278# range 0 .. 31; F7R2 at 16#27C# range 0 .. 31; F8R1 at 16#280# range 0 .. 31; F8R2 at 16#284# range 0 .. 31; F9R1 at 16#288# range 0 .. 31; F9R2 at 16#28C# range 0 .. 31; F10R1 at 16#290# range 0 .. 31; F10R2 at 16#294# range 0 .. 31; F11R1 at 16#298# range 0 .. 31; F11R2 at 16#29C# range 0 .. 31; F12R1 at 16#2A0# range 0 .. 31; F12R2 at 16#2A4# range 0 .. 31; F13R1 at 16#2A8# range 0 .. 31; F13R2 at 16#2AC# range 0 .. 31; F14R1 at 16#2B0# range 0 .. 31; F14R2 at 16#2B4# range 0 .. 31; F15R1 at 16#2B8# range 0 .. 31; F15R2 at 16#2BC# range 0 .. 31; F16R1 at 16#2C0# range 0 .. 31; F16R2 at 16#2C4# range 0 .. 31; F17R1 at 16#2C8# range 0 .. 31; F17R2 at 16#2CC# range 0 .. 31; F18R1 at 16#2D0# range 0 .. 31; F18R2 at 16#2D4# range 0 .. 31; F19R1 at 16#2D8# range 0 .. 31; F19R2 at 16#2DC# range 0 .. 31; F20R1 at 16#2E0# range 0 .. 31; F20R2 at 16#2E4# range 0 .. 31; F21R1 at 16#2E8# range 0 .. 31; F21R2 at 16#2EC# range 0 .. 31; F22R1 at 16#2F0# range 0 .. 31; F22R2 at 16#2F4# range 0 .. 31; F23R1 at 16#2F8# range 0 .. 31; F23R2 at 16#2FC# range 0 .. 31; F24R1 at 16#300# range 0 .. 31; F24R2 at 16#304# range 0 .. 31; F25R1 at 16#308# range 0 .. 31; F25R2 at 16#30C# range 0 .. 31; F26R1 at 16#310# range 0 .. 31; F26R2 at 16#314# range 0 .. 31; F27R1 at 16#318# range 0 .. 31; F27R2 at 16#31C# range 0 .. 31; end record; -- Controller area network CAN1_Periph : aliased CAN_Peripheral with Import, Address => System'To_Address (16#40006400#); -- Controller area network CAN2_Periph : aliased CAN_Peripheral with Import, Address => System'To_Address (16#40006800#); end STM32_SVD.CAN;
reznikmm/matreshka
Ada
4,061
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.Office_Dde_Application_Attributes; package Matreshka.ODF_Office.Dde_Application_Attributes is type Office_Dde_Application_Attribute_Node is new Matreshka.ODF_Office.Abstract_Office_Attribute_Node and ODF.DOM.Office_Dde_Application_Attributes.ODF_Office_Dde_Application_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Office_Dde_Application_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Office_Dde_Application_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Office.Dde_Application_Attributes;
Componolit/libsparkcrypto
Ada
2,313
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2010, Alexander Senier -- Copyright (C) 2010, secunet Security Networks AG -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the nor the names of its contributors may be used -- to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.Ops64; package body LSC.Internal.Byteswap64 is function Swap (Value : Types.Word64) return Types.Word64 is Temp : Types.Byte_Array64_Type; begin Temp := Types.Word64_To_Byte_Array64 (Value); return Ops64.Bytes_To_Word (Temp (0), Temp (1), Temp (2), Temp (3), Temp (4), Temp (5), Temp (6), Temp (7)); end Swap; end LSC.Internal.Byteswap64;
AdaCore/libadalang
Ada
42
adb
-- main.adb is not supposed to read this
zhmu/ananas
Ada
3,855
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T E X T _ I O . C O M P L E X _ I O -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Numerics.Generic_Complex_Types; generic with package Complex_Types is new Ada.Numerics.Generic_Complex_Types (<>); package Ada.Text_IO.Complex_IO is Default_Fore : Field := 2; Default_Aft : Field := Complex_Types.Real'Digits - 1; Default_Exp : Field := 3; procedure Get (File : File_Type; Item : out Complex_Types.Complex; Width : Field := 0); procedure Get (Item : out Complex_Types.Complex; Width : Field := 0); procedure Put (File : File_Type; Item : Complex_Types.Complex; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp); procedure Put (Item : Complex_Types.Complex; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp); procedure Get (From : String; Item : out Complex_Types.Complex; Last : out Positive); procedure Put (To : out String; Item : Complex_Types.Complex; Aft : Field := Default_Aft; Exp : Field := Default_Exp); private pragma Inline (Get); pragma Inline (Put); end Ada.Text_IO.Complex_IO;
reznikmm/matreshka
Ada
3,603
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.Namespaces.Hash is new AMF.Elements.Generic_Hash (UML_Namespace, UML_Namespace_Access);
OneWingedShark/Byron
Ada
824
adb
Pragma Ada_2012; Pragma Assertion_Policy( Check ); Package Body Byron.Internals.SPARK.Element with SPARK_Mode => On is Function Transformation( Input : Element_Type ) Return Element_Type is -- The input is not mutable here, so we need to use an Identity to -- get a mutable copy. Object : Element_Type := Copy(Input); begin -- We then apply the given function. Transform( Object ); -- And return a copy of the result. (Becase we have no assignment.) Return Result : Constant Element_Type:= Copy( Object ); End Transformation; Procedure Transform( Input : in out Element_Type ) is Begin T1(Input); T2(Input); End Transform; -- Takes F & G returning G( F() ). Function Compose( Input : Element_Type ) Return Element_Type is ( G( F(Input) ) ); End Byron.Internals.SPARK.Element;
jhumphry/aLua
Ada
23,745
ads
-- Lua.Internal -- Contains the raw interfaces with the Lua library written in C -- Generated from lua.h and then manually tidied up -- Copyright (c) 2015, James Humphry -- Derived from the original Lua work -- Copyright (C) 1994-2015 Lua.org, PUC-Rio. -- See LICENSE for details with Interfaces.C; use Interfaces.C; with Interfaces.C.Extensions; with System; with Interfaces.C.Strings; with Ada.Characters.Latin_1; private package Lua.Internal is -- mark for precompiled code ('<esc>Lua') LUA_SIGNATURE : constant String := Ada.Characters.Latin_1.ESC & "Lua"; -- is this null terminated? -- option for multiple returns in 'lua_pcall' and 'lua_call' LUA_MULTRET : constant := (-1); -- /usr/include/lua.h:34 -- minimum Lua stack available to a C function LUA_MINSTACK : constant := 20; -- /usr/include/lua.h:79 -- arg-macro: procedure lua_call (L, n, r) -- lua_callk(L, (n), (r), 0, NULL) -- arg-macro: procedure lua_pcall (L, n, r, f) -- lua_pcallk(L, (n), (r), (f), 0, NULL) -- arg-macro: procedure lua_yield (L, n) -- lua_yieldk(L, (n), 0, NULL) -- arg-macro: function lua_getextraspace (L) -- return (void *)((char *)(L) - LUA_EXTRASPACE); -- arg-macro: procedure lua_tonumber (L, i) -- lua_tonumberx(L,(i),NULL) -- arg-macro: procedure lua_tointeger (L, i) -- lua_tointegerx(L,(i),NULL) -- arg-macro: function lua_register (L, n, f) -- return lua_pushcfunction(L, (f)), lua_setglobal(L, (n)); -- arg-macro: procedure lua_pushcfunction (L, f) -- lua_pushcclosure(L, (f), 0) -- arg-macro: function lua_isfunction (L, n) -- return lua_type(L, (n)) = LUA_TFUNCTION; -- arg-macro: function lua_istable (L, n) -- return lua_type(L, (n)) = LUA_TTABLE; -- arg-macro: function lua_islightuserdata (L, n) -- return lua_type(L, (n)) = LUA_TLIGHTUSERDATA; -- arg-macro: function lua_isnil (L, n) -- return lua_type(L, (n)) = LUA_TNIL; -- arg-macro: function lua_isboolean (L, n) -- return lua_type(L, (n)) = LUA_TBOOLEAN; -- arg-macro: function lua_isthread (L, n) -- return lua_type(L, (n)) = LUA_TTHREAD; -- arg-macro: function lua_isnone (L, n) -- return lua_type(L, (n)) = LUA_TNONE; -- arg-macro: function lua_isnoneornil (L, n) -- return lua_type(L, (n)) <= 0; -- arg-macro: procedure lua_tostring (L, i) -- lua_tolstring(L, (i), NULL) LUA_HOOKCALL : constant := 0; -- /usr/include/lua.h:402 LUA_HOOKRET : constant := 1; -- /usr/include/lua.h:403 LUA_HOOKLINE : constant := 2; -- /usr/include/lua.h:404 LUA_HOOKCOUNT : constant := 3; -- /usr/include/lua.h:405 LUA_HOOKTAILCALL : constant := 4; -- /usr/include/lua.h:406 -- unsupported macro: LUA_MASKCALL (1 << LUA_HOOKCALL) -- unsupported macro: LUA_MASKRET (1 << LUA_HOOKRET) -- unsupported macro: LUA_MASKLINE (1 << LUA_HOOKLINE) -- unsupported macro: LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) -- type of numbers in Lua subtype lua_Number is double; -- /usr/include/lua.h:89 -- type for integer functions subtype lua_Integer is Long_Long_Integer; -- /usr/include/lua.h:93 -- unsigned integer type subtype lua_Unsigned is Extensions.unsigned_long_long; -- /usr/include/lua.h:96 -- type for continuation-function contexts subtype lua_KContext is Interfaces.C.ptrdiff_t; -- /usr/include/lua.h:99 --** Type for C functions registered with Lua -- type lua_CFunction is access function (arg1 : System.Address) return int; pragma Convention (C, lua_CFunction); -- /usr/include/lua.h:105 --** Type for continuation functions -- type lua_KFunction is access function (arg1 : System.Address; arg2 : int; arg3 : lua_KContext) return int; pragma Convention (C, lua_KFunction); -- /usr/include/lua.h:110 --** Type for functions that read/write blocks when loading/dumping Lua chunks -- type lua_Reader is access function (arg1 : System.Address; arg2 : System.Address; arg3 : access Interfaces.C.size_t) return Interfaces.C.Strings.chars_ptr; pragma Convention (C, lua_Reader); -- /usr/include/lua.h:116 type lua_Writer is access function (arg1 : System.Address; arg2 : System.Address; arg3 : Interfaces.C.size_t; arg4 : System.Address) return int; pragma Convention (C, lua_Writer); -- /usr/include/lua.h:118 --** Type for memory-allocation functions -- type lua_Alloc is access function (ud : System.Address; ptr : System.Address; osize : Interfaces.C.size_t; nsize : Interfaces.C.size_t) return System.Address; pragma Convention (C, lua_Alloc); -- /usr/include/lua.h:124 --** state manipulation -- function lua_newstate (arg1 : lua_Alloc; arg2 : System.Address) return System.Address; -- /usr/include/lua.h:145 pragma Import (C, lua_newstate, "lua_newstate"); procedure lua_close (arg1 : System.Address); -- /usr/include/lua.h:146 pragma Import (C, lua_close, "lua_close"); function lua_newthread (arg1 : System.Address) return System.Address; -- /usr/include/lua.h:147 pragma Import (C, lua_newthread, "lua_newthread"); function lua_atpanic (arg1 : System.Address; arg2 : lua_CFunction) return lua_CFunction; -- /usr/include/lua.h:149 pragma Import (C, lua_atpanic, "lua_atpanic"); function lua_version (arg1 : System.Address) return access constant lua_Number; -- /usr/include/lua.h:152 pragma Import (C, lua_version, "lua_version"); --** basic stack manipulation -- function lua_absindex (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:158 pragma Import (C, lua_absindex, "lua_absindex"); function lua_gettop (arg1 : System.Address) return int; -- /usr/include/lua.h:159 pragma Import (C, lua_gettop, "lua_gettop"); procedure lua_settop (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:160 pragma Import (C, lua_settop, "lua_settop"); procedure lua_pushvalue (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:161 pragma Import (C, lua_pushvalue, "lua_pushvalue"); procedure lua_rotate (arg1 : System.Address; arg2 : int; arg3 : int); -- /usr/include/lua.h:162 pragma Import (C, lua_rotate, "lua_rotate"); procedure lua_copy (arg1 : System.Address; arg2 : int; arg3 : int); -- /usr/include/lua.h:163 pragma Import (C, lua_copy, "lua_copy"); function lua_checkstack (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:164 pragma Import (C, lua_checkstack, "lua_checkstack"); procedure lua_xmove (arg1 : System.Address; arg2 : System.Address; arg3 : int); -- /usr/include/lua.h:166 pragma Import (C, lua_xmove, "lua_xmove"); --** access functions (stack -> C) -- function lua_isnumber (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:173 pragma Import (C, lua_isnumber, "lua_isnumber"); function lua_isstring (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:174 pragma Import (C, lua_isstring, "lua_isstring"); function lua_iscfunction (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:175 pragma Import (C, lua_iscfunction, "lua_iscfunction"); function lua_isinteger (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:176 pragma Import (C, lua_isinteger, "lua_isinteger"); function lua_isuserdata (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:177 pragma Import (C, lua_isuserdata, "lua_isuserdata"); function lua_type (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:178 pragma Import (C, lua_type, "lua_type"); function lua_typename (arg1 : System.Address; arg2 : int) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:179 pragma Import (C, lua_typename, "lua_typename"); function lua_tonumberx (arg1 : System.Address; arg2 : int; arg3 : access int) return lua_Number; -- /usr/include/lua.h:181 pragma Import (C, lua_tonumberx, "lua_tonumberx"); function lua_tointegerx (arg1 : System.Address; arg2 : int; arg3 : access int) return lua_Integer; -- /usr/include/lua.h:182 pragma Import (C, lua_tointegerx, "lua_tointegerx"); function lua_toboolean (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:183 pragma Import (C, lua_toboolean, "lua_toboolean"); function lua_tolstring (arg1 : System.Address; arg2 : int; arg3 : access Interfaces.C.size_t) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:184 pragma Import (C, lua_tolstring, "lua_tolstring"); function lua_rawlen (arg1 : System.Address; arg2 : int) return Interfaces.C.size_t; -- /usr/include/lua.h:185 pragma Import (C, lua_rawlen, "lua_rawlen"); function lua_tocfunction (arg1 : System.Address; arg2 : int) return lua_CFunction; -- /usr/include/lua.h:186 pragma Import (C, lua_tocfunction, "lua_tocfunction"); function lua_touserdata (arg1 : System.Address; arg2 : int) return System.Address; -- /usr/include/lua.h:187 pragma Import (C, lua_touserdata, "lua_touserdata"); function lua_tothread (arg1 : System.Address; arg2 : int) return System.Address; -- /usr/include/lua.h:188 pragma Import (C, lua_tothread, "lua_tothread"); function lua_topointer (arg1 : System.Address; arg2 : int) return System.Address; -- /usr/include/lua.h:189 pragma Import (C, lua_topointer, "lua_topointer"); --** Comparison and arithmetic functions -- procedure lua_arith (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:211 pragma Import (C, lua_arith, "lua_arith"); function lua_rawequal (arg1 : System.Address; arg2 : int; arg3 : int) return int; -- /usr/include/lua.h:217 pragma Import (C, lua_rawequal, "lua_rawequal"); function lua_compare (arg1 : System.Address; arg2 : int; arg3 : int; arg4 : int) return int; -- /usr/include/lua.h:218 pragma Import (C, lua_compare, "lua_compare"); --** push functions (C -> stack) -- procedure lua_pushnil (arg1 : System.Address); -- /usr/include/lua.h:224 pragma Import (C, lua_pushnil, "lua_pushnil"); procedure lua_pushnumber (arg1 : System.Address; arg2 : lua_Number); -- /usr/include/lua.h:225 pragma Import (C, lua_pushnumber, "lua_pushnumber"); procedure lua_pushinteger (arg1 : System.Address; arg2 : lua_Integer); -- /usr/include/lua.h:226 pragma Import (C, lua_pushinteger, "lua_pushinteger"); function lua_pushlstring (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : Interfaces.C.size_t) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:227 pragma Import (C, lua_pushlstring, "lua_pushlstring"); function lua_pushstring (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:228 pragma Import (C, lua_pushstring, "lua_pushstring"); function lua_pushvfstring (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : access System.Address) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:229 pragma Import (C, lua_pushvfstring, "lua_pushvfstring"); function lua_pushfstring (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr -- , ... ) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:231 pragma Import (C, lua_pushfstring, "lua_pushfstring"); procedure lua_pushcclosure (arg1 : System.Address; arg2 : lua_CFunction; arg3 : int); -- /usr/include/lua.h:232 pragma Import (C, lua_pushcclosure, "lua_pushcclosure"); procedure lua_pushboolean (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:233 pragma Import (C, lua_pushboolean, "lua_pushboolean"); procedure lua_pushlightuserdata (arg1 : System.Address; arg2 : System.Address); -- /usr/include/lua.h:234 pragma Import (C, lua_pushlightuserdata, "lua_pushlightuserdata"); function lua_pushthread (arg1 : System.Address) return int; -- /usr/include/lua.h:235 pragma Import (C, lua_pushthread, "lua_pushthread"); --** get functions (Lua -> stack) -- function lua_getglobal (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr) return int; -- /usr/include/lua.h:241 pragma Import (C, lua_getglobal, "lua_getglobal"); function lua_gettable (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:242 pragma Import (C, lua_gettable, "lua_gettable"); function lua_getfield (arg1 : System.Address; arg2 : int; arg3 : Interfaces.C.Strings.chars_ptr) return int; -- /usr/include/lua.h:243 pragma Import (C, lua_getfield, "lua_getfield"); function lua_geti (arg1 : System.Address; arg2 : int; arg3 : lua_Integer) return int; -- /usr/include/lua.h:244 pragma Import (C, lua_geti, "lua_geti"); function lua_rawget (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:245 pragma Import (C, lua_rawget, "lua_rawget"); function lua_rawgeti (arg1 : System.Address; arg2 : int; arg3 : lua_Integer) return int; -- /usr/include/lua.h:246 pragma Import (C, lua_rawgeti, "lua_rawgeti"); function lua_rawgetp (arg1 : System.Address; arg2 : int; arg3 : System.Address) return int; -- /usr/include/lua.h:247 pragma Import (C, lua_rawgetp, "lua_rawgetp"); procedure lua_createtable (arg1 : System.Address; arg2 : int; arg3 : int); -- /usr/include/lua.h:249 pragma Import (C, lua_createtable, "lua_createtable"); function lua_newuserdata (arg1 : System.Address; arg2 : Interfaces.C.size_t) return System.Address; -- /usr/include/lua.h:250 pragma Import (C, lua_newuserdata, "lua_newuserdata"); function lua_getmetatable (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:251 pragma Import (C, lua_getmetatable, "lua_getmetatable"); function lua_getuservalue (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:252 pragma Import (C, lua_getuservalue, "lua_getuservalue"); --** set functions (stack -> Lua) -- procedure lua_setglobal (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr); -- /usr/include/lua.h:258 pragma Import (C, lua_setglobal, "lua_setglobal"); procedure lua_settable (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:259 pragma Import (C, lua_settable, "lua_settable"); procedure lua_setfield (arg1 : System.Address; arg2 : int; arg3 : Interfaces.C.Strings.chars_ptr); -- /usr/include/lua.h:260 pragma Import (C, lua_setfield, "lua_setfield"); procedure lua_seti (arg1 : System.Address; arg2 : int; arg3 : lua_Integer); -- /usr/include/lua.h:261 pragma Import (C, lua_seti, "lua_seti"); procedure lua_rawset (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:262 pragma Import (C, lua_rawset, "lua_rawset"); procedure lua_rawseti (arg1 : System.Address; arg2 : int; arg3 : lua_Integer); -- /usr/include/lua.h:263 pragma Import (C, lua_rawseti, "lua_rawseti"); procedure lua_rawsetp (arg1 : System.Address; arg2 : int; arg3 : System.Address); -- /usr/include/lua.h:264 pragma Import (C, lua_rawsetp, "lua_rawsetp"); function lua_setmetatable (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:265 pragma Import (C, lua_setmetatable, "lua_setmetatable"); procedure lua_setuservalue (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:266 pragma Import (C, lua_setuservalue, "lua_setuservalue"); --** 'load' and 'call' functions (load and run Lua code) -- procedure lua_callk (arg1 : System.Address; arg2 : int; arg3 : int; arg4 : lua_KContext; arg5 : lua_KFunction); -- /usr/include/lua.h:272 pragma Import (C, lua_callk, "lua_callk"); function lua_pcallk (arg1 : System.Address; arg2 : int; arg3 : int; arg4 : int; arg5 : lua_KContext; arg6 : lua_KFunction) return int; -- /usr/include/lua.h:276 pragma Import (C, lua_pcallk, "lua_pcallk"); function lua_load (arg1 : System.Address; arg2 : lua_Reader; arg3 : System.Address; arg4 : Interfaces.C.Strings.chars_ptr; arg5 : Interfaces.C.Strings.chars_ptr) return int; -- /usr/include/lua.h:280 pragma Import (C, lua_load, "lua_load"); function lua_dump (arg1 : System.Address; arg2 : lua_Writer; arg3 : System.Address; arg4 : int) return int; -- /usr/include/lua.h:283 pragma Import (C, lua_dump, "lua_dump"); --** coroutine functions -- function lua_yieldk (arg1 : System.Address; arg2 : int; arg3 : lua_KContext; arg4 : lua_KFunction) return int; -- /usr/include/lua.h:289 pragma Import (C, lua_yieldk, "lua_yieldk"); function lua_resume (arg1 : System.Address; arg2 : System.Address; arg3 : int) return int; -- /usr/include/lua.h:291 pragma Import (C, lua_resume, "lua_resume"); function lua_status (arg1 : System.Address) return int; -- /usr/include/lua.h:292 pragma Import (C, lua_status, "lua_status"); function lua_isyieldable (arg1 : System.Address) return int; -- /usr/include/lua.h:293 pragma Import (C, lua_isyieldable, "lua_isyieldable"); --** garbage-collection function and options -- function lua_gc (arg1 : System.Address; arg2 : int; arg3 : int) return int; -- /usr/include/lua.h:312 pragma Import (C, lua_gc, "lua_gc"); --** miscellaneous functions -- function lua_error (arg1 : System.Address) return int; -- /usr/include/lua.h:319 pragma Import (C, lua_error, "lua_error"); function lua_next (arg1 : System.Address; arg2 : int) return int; -- /usr/include/lua.h:321 pragma Import (C, lua_next, "lua_next"); procedure lua_concat (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:323 pragma Import (C, lua_concat, "lua_concat"); procedure lua_len (arg1 : System.Address; arg2 : int); -- /usr/include/lua.h:324 pragma Import (C, lua_len, "lua_len"); function lua_stringtonumber (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.size_t; -- /usr/include/lua.h:326 pragma Import (C, lua_stringtonumber, "lua_stringtonumber"); function lua_getallocf (arg1 : System.Address; arg2 : System.Address) return lua_Alloc; -- /usr/include/lua.h:328 pragma Import (C, lua_getallocf, "lua_getallocf"); procedure lua_setallocf (arg1 : System.Address; arg2 : lua_Alloc; arg3 : System.Address); -- /usr/include/lua.h:329 pragma Import (C, lua_setallocf, "lua_setallocf"); --** {============================================================== --** some useful macros --** =============================================================== -- -- }============================================================== --** {============================================================== --** compatibility macros for unsigned conversions --** =============================================================== -- -- }============================================================== --** {====================================================================== --** Debug API --** ======================================================================= -- --** Event codes -- --** Event masks -- -- activation record -- Functions to be called by the debugger in specific events type lua_Hook is access procedure (arg1 : System.Address; arg2 : System.Address); pragma Convention (C, lua_Hook); -- /usr/include/lua.h:421 function lua_getstack (arg1 : System.Address; arg2 : int; arg3 : System.Address) return int; -- /usr/include/lua.h:424 pragma Import (C, lua_getstack, "lua_getstack"); function lua_getinfo (arg1 : System.Address; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : System.Address) return int; -- /usr/include/lua.h:425 pragma Import (C, lua_getinfo, "lua_getinfo"); function lua_getlocal (arg1 : System.Address; arg2 : System.Address; arg3 : int) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:426 pragma Import (C, lua_getlocal, "lua_getlocal"); function lua_setlocal (arg1 : System.Address; arg2 : System.Address; arg3 : int) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:427 pragma Import (C, lua_setlocal, "lua_setlocal"); function lua_getupvalue (arg1 : System.Address; arg2 : int; arg3 : int) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:428 pragma Import (C, lua_getupvalue, "lua_getupvalue"); function lua_setupvalue (arg1 : System.Address; arg2 : int; arg3 : int) return Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:429 pragma Import (C, lua_setupvalue, "lua_setupvalue"); function lua_upvalueid (arg1 : System.Address; arg2 : int; arg3 : int) return System.Address; -- /usr/include/lua.h:431 pragma Import (C, lua_upvalueid, "lua_upvalueid"); procedure lua_upvaluejoin (arg1 : System.Address; arg2 : int; arg3 : int; arg4 : int; arg5 : int); -- /usr/include/lua.h:432 pragma Import (C, lua_upvaluejoin, "lua_upvaluejoin"); procedure lua_sethook (arg1 : System.Address; arg2 : lua_Hook; arg3 : int; arg4 : int); -- /usr/include/lua.h:435 pragma Import (C, lua_sethook, "lua_sethook"); function lua_gethook (arg1 : System.Address) return lua_Hook; -- /usr/include/lua.h:436 pragma Import (C, lua_gethook, "lua_gethook"); function lua_gethookmask (arg1 : System.Address) return int; -- /usr/include/lua.h:437 pragma Import (C, lua_gethookmask, "lua_gethookmask"); function lua_gethookcount (arg1 : System.Address) return int; -- /usr/include/lua.h:438 pragma Import (C, lua_gethookcount, "lua_gethookcount"); -- (n) -- (n) 'global', 'local', 'field', 'method' -- (S) 'Lua', 'C', 'main', 'tail' -- (S) -- (l) -- (S) -- (S) -- (u) number of upvalues -- (u) number of parameters -- (u) -- (t) -- (S) -- private part -- active function -- skipped empty struct CallInfo subtype anon1072_anon1110_array is Interfaces.C.char_array (0 .. 59); type lua_Debug is record event : aliased int; -- /usr/include/lua.h:442 name : Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:443 namewhat : Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:444 what : Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:445 source : Interfaces.C.Strings.chars_ptr; -- /usr/include/lua.h:446 currentline : aliased int; -- /usr/include/lua.h:447 linedefined : aliased int; -- /usr/include/lua.h:448 lastlinedefined : aliased int; -- /usr/include/lua.h:449 nups : aliased unsigned_char; -- /usr/include/lua.h:450 nparams : aliased unsigned_char; -- /usr/include/lua.h:451 isvararg : aliased char; -- /usr/include/lua.h:452 istailcall : aliased char; -- /usr/include/lua.h:453 short_src : aliased anon1072_anon1110_array; -- /usr/include/lua.h:454 i_ci : System.Address; -- /usr/include/lua.h:456 end record; pragma Convention (C_Pass_By_Copy, lua_Debug); -- /usr/include/lua.h:441 -- }====================================================================== end Lua.Internal;
godunko/cga
Ada
7,363
adb
-- -- Copyright (C) 2023, Vadim Godunko <[email protected]> -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with CGK.Primitives.XYs; with CGK.Reals; package body CGK.Primitives.Triangulators_2D is use CGK.Primitives.XYs; use CGK.Reals; type Winding_Direction is (Left, Right); -- Sequence of Point_2D indices package Point_2D_Array_Index_Sequences is new CGK.Internals.Generic_Sequences (Positive, Point_2D_Array_Index); subtype Point_2D_Array_Index_Sequence is Point_2D_Array_Index_Sequences.Sequence; function Can_Cut (Points : Point_2D_Sequence; Verticies : Point_2D_Array_Index_Sequence; Previous : Positive; Current : Positive; Next : Positive) return Boolean; function Inside (A : XYs.XY; B : XYs.XY; C : XYs.XY; P : XYs.XY) return Boolean; -- Check whether P is inside of triangle ABC. function Detect_Winding (Points : Point_2D_Sequence'Class) return Winding_Direction; -- Return winding of the given polygon. procedure Invalidate (Self : in out Triangulator_2D); ----------------------- -- Add_Polygon_Point -- ----------------------- function Add_Polygon_Point (Self : in out Triangulator_2D; Point : CGK.Primitives.Points_2D.Point_2D) return Vertex_Index is begin Self.Points.Append (Point); return Vertex_Index (Self.Points.Last); end Add_Polygon_Point; ------------- -- Can_Cut -- ------------- function Can_Cut (Points : Point_2D_Sequence; Verticies : Point_2D_Array_Index_Sequence; Previous : Positive; Current : Positive; Next : Positive) return Boolean is A : constant XYs.XY := Points_2D.XY (Points (Verticies (Previous))); B : constant XYs.XY := Points_2D.XY (Points (Verticies (Current))); C : constant XYs.XY := Points_2D.XY (Points (Verticies (Next))); begin if (X (B) - X (A)) * (Y (C) - Y (A)) - (Y (B) - Y (A)) * (X (C) - X (A)) < Resolution then return False; end if; for J in Verticies.First .. Verticies.Last loop if J /= Previous and J /= Current and J /= Next then declare P : constant XYs.XY := Points_2D.XY (Points (Verticies (J))); begin if Inside (A, B, C, P) then return False; end if; end; end if; end loop; return True; end Can_Cut; ----------- -- Clear -- ----------- procedure Clear (Self : in out Triangulator_2D) is begin Invalidate (Self); Self.Points.Clear; Self.Result.Clear; end Clear; -------------------- -- Detect_Winding -- -------------------- function Detect_Winding (Points : Point_2D_Sequence'Class) return Winding_Direction is -- Compute polygon's signed area. If it is negative, the polygon is -- right-winding. Area : Real := 0.0; Previous : XYs.XY := Points_2D.XY (Points.Last_Element); Current : XYs.XY; begin for Index in Points.First .. Points.Last loop Current := Points_2D.XY (Points (Index)); Area := @ + X (Previous) * Y (Current) - Y (Previous) * X (Current); Previous := Current; end loop; return (if Area >= 0.0 then Left else Right); end Detect_Winding; ------------ -- Inside -- ------------ function Inside (A : XYs.XY; B : XYs.XY; C : XYs.XY; P : XYs.XY) return Boolean is AX : constant Real := X (C) - X (B); AY : constant Real := Y (C) - Y (B); BX : constant Real := X (A) - X (C); BY : constant Real := Y (A) - Y (C); CX : constant Real := X (B) - X (A); CY : constant Real := Y (B) - Y (A); APX : constant Real := X (P) - X (A); APY : constant Real := Y (P) - Y (A); BPX : constant Real := X (P) - X (B); BPY : constant Real := Y (P) - Y (B); CPX : constant Real := X (P) - X (C); CPY : constant Real := Y (P) - Y (C); ABP : constant Real := AX * BPY - AY * BPX; CAP : constant Real := CX * APY - CY * APX; BCP : constant Real := BX * CPY - BY * CPX; begin return ABP >= 0.0 and CAP >= 0.0 and BCP >= 0.0; end Inside; ---------------- -- Invalidate -- ---------------- procedure Invalidate (Self : in out Triangulator_2D) is begin Self.Valid := False; end Invalidate; -------------- -- Is_Valid -- -------------- function Is_Valid (Self : Triangulator_2D) return Boolean is begin return Self.Valid; end Is_Valid; ------------ -- Length -- ------------ function Length (Self : Triangulator_2D) return Triangle_Count is begin Assert_Invalid_State_Error (Self.Valid); return Self.Result.Length; end Length; -------------- -- Triangle -- -------------- procedure Triangle (Self : Triangulator_2D; Index : Triangle_Index; A : out Vertex_Index; B : out Vertex_Index; C : out Vertex_Index) is begin Assert_Invalid_State_Error (Self.Valid); A := Self.Result (Index).A; B := Self.Result (Index).B; C := Self.Result (Index).C; end Triangle; ----------------- -- Triangulate -- ----------------- procedure Triangulate (Self : in out Triangulator_2D) is Verticies : Point_2D_Array_Index_Sequence; Previous : Positive; Current : Positive; Next : Positive; Count : Natural; begin Invalidate (Self); Self.Result.Clear; -- Order verticies in necessary direction. Verticies.Set_Capacity (Positive (Self.Points.Length)); case Detect_Winding (Self.Points) is when Left => for J in Self.Points.First .. Self.Points.Last loop Verticies.Append (J); end loop; when Right => for J in reverse Self.Points.First .. Self.Points.Last loop Verticies.Append (J); end loop; end case; -- Main loop Current := Verticies.Last; Count := 2 * Verticies.Length; while Verticies.Length > 2 loop -- Non simple polygon has been detected. if Count = 0 then Self.Result.Clear; return; end if; Count := @ - 1; -- Compute indicies of three consecutive verticies Previous := Current; if Previous > Verticies.Last then Previous := Verticies.First; end if; Current := @ + 1; if Current > Verticies.Last then Current := Verticies.First; end if; Next := Current + 1; if Next > Verticies.Last then Next := Verticies.First; end if; if Can_Cut (Self.Points, Verticies, Previous, Current, Next) then Self.Result.Append ((Vertex_Count (Verticies (Previous)), Vertex_Count (Verticies (Current)), Vertex_Count (Verticies (Next)))); Verticies.Delete (Current); Count := 2 * Verticies.Length; end if; end loop; Self.Valid := True; end Triangulate; end CGK.Primitives.Triangulators_2D;
reznikmm/matreshka
Ada
3,779
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Draw_Frame_Display_Scrollbar_Attributes is pragma Preelaborate; type ODF_Draw_Frame_Display_Scrollbar_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Frame_Display_Scrollbar_Attribute_Access is access all ODF_Draw_Frame_Display_Scrollbar_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Frame_Display_Scrollbar_Attributes;
zhmu/ananas
Ada
2,929
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T E X T _ I O . E N U M E R A T I O N _ I O -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- In Ada 95, the package Ada.Text_IO.Enumeration_IO is a subpackage of -- Text_IO. This is for compatibility with Ada 83. In GNAT we make it a -- child package to avoid loading the necessary code if Enumeration_IO is -- not instantiated. See routine Rtsfind.Check_Text_IO_Special_Unit for a -- description of how we patch up the difference in semantics so that it -- is invisible to the Ada programmer. private generic type Enum is (<>); package Ada.Text_IO.Enumeration_IO is Default_Width : Field := 0; Default_Setting : Type_Set := Upper_Case; procedure Get (File : File_Type; Item : out Enum) with Pre => Is_Open (File) and then Mode (File) = In_File, Global => (In_Out => File_System); procedure Get (Item : out Enum) with Post => Line_Length'Old = Line_Length and Page_Length'Old = Page_Length, Global => (In_Out => File_System); procedure Put (File : File_Type; Item : Enum; Width : Field := Default_Width; Set : Type_Set := Default_Setting) with Pre => Is_Open (File) and then Mode (File) /= In_File, Post => Line_Length (File)'Old = Line_Length (File) and Page_Length (File)'Old = Page_Length (File), Global => (In_Out => File_System); procedure Put (Item : Enum; Width : Field := Default_Width; Set : Type_Set := Default_Setting) with Post => Line_Length'Old = Line_Length and Page_Length'Old = Page_Length, Global => (In_Out => File_System); procedure Get (From : String; Item : out Enum; Last : out Positive) with Global => null; procedure Put (To : out String; Item : Enum; Set : Type_Set := Default_Setting) with Global => null; end Ada.Text_IO.Enumeration_IO;
sungyeon/drake
Ada
6,133
adb
with Ada.Exceptions; with Ada.Unchecked_Deallocation; with System.Address_To_Named_Access_Conversions; with System.Shared_Locking; package body System.Finalization_Masters is pragma Suppress (All_Checks); use type Storage_Barriers.Flag; procedure Free is new Ada.Unchecked_Deallocation (FM_List, FM_List_Access); package FMN_Ptr_Conv is new Address_To_Named_Access_Conversions (FM_Node, FM_Node_Ptr); procedure Initialize_List (List : not null FM_List_Access); procedure Initialize_List (List : not null FM_List_Access) is begin List.Objects.Next := List.Objects'Access; List.Objects.Prev := List.Objects'Access; end Initialize_List; procedure Finalize_List ( List : not null FM_List_Access; Raised : in out Boolean; X : in out Ada.Exceptions.Exception_Occurrence); procedure Finalize_List ( List : not null FM_List_Access; Raised : in out Boolean; X : in out Ada.Exceptions.Exception_Occurrence) is begin while List.Objects.Next /= List.Objects'Unchecked_Access loop declare Curr_Ptr : constant FM_Node_Ptr := List.Objects.Next; Obj_Addr : constant Address := FMN_Ptr_Conv.To_Address (Curr_Ptr) + Header_Size; begin Detach_Unprotected (Curr_Ptr); begin List.Finalize_Address (Obj_Addr); exception when E : others => if not Raised then Raised := True; Ada.Exceptions.Save_Occurrence (X, E); end if; end; end; end loop; end Finalize_List; procedure Get_List_Unprotected ( Master : in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr; List : out FM_List_Access); procedure Get_List_Unprotected ( Master : in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr; List : out FM_List_Access) is begin if Master.List.Finalize_Address = null then Master.List.Finalize_Address := Fin_Addr_Ptr; List := Master.List'Unchecked_Access; else declare I : FM_List_Access := Master.List'Unchecked_Access; begin while I /= null loop if I.Finalize_Address = Fin_Addr_Ptr then List := I; return; -- found end if; I := I.Next; end loop; end; declare New_List : constant FM_List_Access := new FM_List; begin Initialize_List (New_List); New_List.Finalize_Address := Fin_Addr_Ptr; New_List.Next := Master.List.Next; Master.List.Next := New_List; List := New_List; end; end if; end Get_List_Unprotected; -- implementation procedure Attach_Unprotected (N, L : not null FM_Node_Ptr) is begin L.Next.Prev := N; N.Next := L.Next; L.Next := N; N.Prev := L; end Attach_Unprotected; procedure Detach_Unprotected (N : not null FM_Node_Ptr) is begin if N.Prev /= null and then N.Next /= null then N.Prev.Next := N.Next; N.Next.Prev := N.Prev; N.Prev := null; N.Next := null; end if; end Detach_Unprotected; function Objects_Unprotected ( Master : aliased in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr) return FM_Node_Ptr is List : FM_List_Access; begin Get_List_Unprotected (Master, Fin_Addr_Ptr, List); return List.Objects'Access; end Objects_Unprotected; function Finalization_Started (Master : Finalization_Master'Class) return Boolean is begin return Storage_Barriers.atomic_load ( Master.Finalization_Started'Access) /= 0; end Finalization_Started; procedure Set_Finalize_Address_Unprotected ( Master : in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr) is Dummy : FM_List_Access; begin Get_List_Unprotected (Master, Fin_Addr_Ptr, Dummy); end Set_Finalize_Address_Unprotected; procedure Set_Finalize_Address ( Master : in out Finalization_Master'Class; Fin_Addr_Ptr : Finalize_Address_Ptr) is begin Shared_Locking.Enter; Set_Finalize_Address_Unprotected (Master, Fin_Addr_Ptr); Shared_Locking.Leave; end Set_Finalize_Address; overriding procedure Initialize (Object : in out Finalization_Master) is begin Storage_Barriers.atomic_clear (Object.Finalization_Started'Access); Initialize_List (Object.List'Unchecked_Access); Object.List.Finalize_Address := null; Object.List.Next := null; end Initialize; overriding procedure Finalize (Object : in out Finalization_Master) is begin if not Storage_Barriers.atomic_test_and_set ( Object.Finalization_Started'Access) then declare Raised : Boolean := False; X : Ada.Exceptions.Exception_Occurrence; begin Finalize_List (Object.List'Unchecked_Access, Raised, X); declare I : FM_List_Access := Object.List.Next; begin while I /= null loop declare Next : constant FM_List_Access := I.Next; begin Finalize_List (I, Raised, X); Free (I); I := Next; end; end loop; end; if Raised then Ada.Exceptions.Reraise_Nonnull_Occurrence (X); end if; end; end if; end Finalize; function Base_Pool (Master : Finalization_Master'Class) return Any_Storage_Pool_Ptr is begin return Master.Base_Pool; end Base_Pool; procedure Set_Base_Pool ( Master : in out Finalization_Master'Class; Pool_Ptr : Any_Storage_Pool_Ptr) is begin Master.Base_Pool := Pool_Ptr; end Set_Base_Pool; end System.Finalization_Masters;
persan/protobuf-ada
Ada
2,112
ads
with Ada.Finalization; with Ada.Streams; with Ada.Containers.Vectors; -- At present the package relies on Stream_Element being 8-bits in size, but -- size of a Stream_Element is implementation defined. Better fix this??? package Buffered_Byte_Stream is type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; type Byte_Buffer (Size : Ada.Containers.Count_Type) is new Ada.Finalization.Limited_Controlled with private; type Byte_Stream (Size : Ada.Containers.Count_Type) is new Ada.Streams.Root_Stream_Type with record Byte_Stream_Buffer : Byte_Buffer (Size); end record; type Byte_Stream_Access is access all Byte_Stream; overriding procedure Read (Stream : in out Byte_Stream; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); overriding procedure Write (Stream : in out Byte_Stream; Item : in Ada.Streams.Stream_Element_Array); procedure Reset (Stream : in out Byte_Stream_Access); function To_Stream_Element_Array (Stream : in Byte_Stream_Access) return Ada.Streams.Stream_Element_Array; procedure Empty_And_Load_Buffer (Stream : in out Byte_Stream_Access; Byte_Array : in Ada.Streams.Stream_Element_Array); procedure Free (Stream : in out Byte_Stream_Access); private package Stream_Element_Buffer is new Ada.Containers.Vectors (Natural, Ada.Streams.Stream_Element, Ada.Streams."="); type Byte_Buffer (Size : Ada.Containers.Count_Type) is new Ada.Finalization.Limited_Controlled with record Count : Ada.Containers.Count_Type; Buffer : Stream_Element_Buffer.Vector; end record; overriding procedure Initialize (The_Byte_Buffer : in out Byte_Buffer); procedure Read (The_Byte_Buffer : in out Byte_Buffer; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Write (The_Byte_Buffer : in out Byte_Buffer; Item : in Ada.Streams.Stream_Element_Array); end Buffered_Byte_Stream;
rogermc2/GA_Ada
Ada
8,084
ads
with GL.Types; with GA_Maths; use GA_Maths; with Multivectors; use Multivectors; package E3GA is type Array_19F is array (1 .. 19) of float; -- subtype M_Vector is GA_Maths.Coords_Continuous_Array (1 .. 3); -- m_c[3] coordinate storage subtype E3_Vector is GL.Types.Singles.Vector3; -- m_c[3] coordinate storage -- types type G2_Type is (MVT_None, MVT_E1_T, MVT_E2_T, MVT_E3_T, MVT_Scalar, MVT_Vector_2D, MVT_Vector, MVT_Bivector, MVT_Trivector, MVT_Rotor, MVT_E1_CT, MVT_E2_CT, MVT_E3_CT, MVT_I3_CT, MVT_I3I_CT, MVT_MV, MVT_Last); -- Outermorphism types type OM_Type is (OMT_None, OMT_OM, OMT_Last); -- type Rotor_Coordinates_Type is (Rotor_Scalar_e1e2_e2e3_e3e1); -- type Scalar is private; -- type Bivector is private; type Outermorphism is private; type Syn_SMultivector is private; -- type Rotor is private; -- type Trivector is private; -- M_Vector corresponds to e3ga.Vector coordinate storage float m_c[3] -- type M_Vector is private; type MV_Coordinate_Array is new GA_Maths.Coords_Continuous_Array (1 .. 8); -- type Multivector (Grade_Use : Grade_Usage) is record -- Coordinates : MV_Coordinate_Array := (others => 0.0); -- m_c[8] -- end record; -- Joinable grade definitions Grade_0 : constant integer := 1; Grade_1 : constant integer := 2; Grade_2 : constant integer := 4; Grade_3 : constant integer := 8; -- function "=" (V1, V2 : M_Vector) return Boolean; function "+" (V1, V2 : E3_Vector) return E3_Vector; function "-" (V : E3_Vector) return E3_Vector; -- function "-" (VL, VR : E3_Vector) return E3_Vector; function "*" (Weight : float; V : E3_Vector) return E3_Vector; -- function "*" (Weight : float; BV : Bivector) return Bivector; function "*" (R1, R2 : Rotor) return Rotor; -- function "*" (R : Rotor; V : M_Vector) return Rotor; -- function "*" (V : M_Vector; R : Rotor) return Rotor; function "/" (R : Rotor; S : float) return Rotor; -- function "+" (W : float; BV : BiVector) return Rotor; function "+" (W : float; R : Rotor) return Rotor; function "-" (W : float; R : Rotor) return Rotor; -- function e1 (V : E2GA.M_Vector) return float; -- function e2 (V : E2GA.M_Vector) return float; -- function e1 return M_Vector; -- function e2 return M_Vector; -- function e3 return M_Vector; function e1 return Multivectors.M_Vector; function e2 return Multivectors.M_Vector; function e3 return Multivectors.M_Vector; function e1 (MV : Multivector) return float; function e2 (MV : Multivector) return float; function e3 (MV : Multivector) return float; function e1_e2 (MV : Multivector) return float; function e1_e3 (MV : Multivector) return float; function e2_e3 (MV : Multivector) return float; function e3_e1 (MV : Multivector) return float; function e1_e2_e3 (MV : Multivector) return float; -- -- function e1e2 (R : Rotor) return float; -- function e2e3 (R : Rotor) return float; -- function e3e1 (R : Rotor) return float; -- function R_Scalar (R : Rotor) return float; -- function Apply_Outermorphism (OM : Outermorphism; BV : Bivector) return Bivector; -- function Apply_Outermorphism (OM : Outermorphism; V : M_Vector) return M_Vector; function Dot_Product (R1, R2 : Rotor) return float; -- function Dot_Product (V1, V2 : M_Vector) return float; -- function Get_Coord (S : Scalar) return float; -- function Get_Coords (BV : Bivector) return Array_3D; function Get_Coords (MV : Multivector) return MV_Coordinate_Array; function Get_Coords (R : Rotor) return Float_4D; -- function Get_Coord_1 (V : M_Vector) return float; -- function Get_Coord_2 (V : M_Vector) return float; -- function Get_Coord_3 (V : M_Vector) return float; function Get_Coords (Vec : Multivectors.M_Vector) return E3_Vector; -- function Get_Coords (SMV : Syn_SMultivector) return Array_4D; function Get_Outermorphism (OM : Outermorphism) return Array_19F; -- function Get_Size (MV : Multivector) return Integer; -- function Geometric_Product (BV : Bivector; R : Rotor) return Rotor; -- function Geometric_Product (R : Rotor; BV : Bivector) return Rotor; -- function Geometric_Product (V : M_Vector; R : Rotor) return Syn_SMultivector; -- function Geometric_Product (R : Rotor; MV : Syn_SMultivector) return Syn_SMultivector; -- function Geometric_Product (V : M_Vector; MV : Syn_SMultivector) return Rotor; -- function Geometric_Product (R : Rotor; V : M_Vector) return Syn_SMultivector; -- function Geometric_Product (R1, R2 : Rotor) return Rotor; -- function Geometric_Product (V1, V2 : M_Vector) return Rotor; -- function Grade_Use (BV : Bivector) return GA_Maths.Unsigned_32; -- function Grade_Use (MV : Multivector) return GA_Maths.Unsigned_32; -- function Inverse (aRotor : Rotor) return Rotor; -- function Inverse (V : M_Vector) return M_Vector; function Is_Zero (V : E3_Vector) return Boolean; -- function Left_Contraction (BV1, BV2 : Bivector) return Scalar; -- function Left_Contraction (MV1, MV2 : Multivector) return Multivector; -- function Left_Contraction (V : M_Vector; BV : Bivector) return M_Vector; -- function Left_Contraction (V1 : M_Vector; V2 : M_Vector) return Scalar; -- function Magnitude (V : M_Vector) return float; -- function MV_String (MV : Multivector; Text : String := "") -- return Ada.Strings.Unbounded.Unbounded_String; function Outer_Product (V1, V2 : E3_Vector) return E3_Vector; -- function Norm_E2 (BV : Bivector) return Scalar; -- function Norm_E2 (V : M_Vector) return Scalar; -- function Norm_E2 (MV : E2GA.Multivector) return Scalar; -- function Norm_E2 (R : Rotor) return Scalar; -- function Norm_E2 (TV : Trivector) return Scalar; -- procedure Set_Coords (V : out M_Vector; C1, C2, C3 : float); procedure Set_Coords (MV : out Multivector; C1, C2, C3 : float); -- function Scalar_Product (V1, V2 : M_Vector) return Scalar; -- procedure Set_Bivector (BV : out Bivector; C1, C2, C3 : float); -- procedure Set_Rotor (X : out Rotor; C_Scalar, C2, C3, C4 : float); -- procedure Set_Rotor (X : out Rotor; C_Scalar : float); -- procedure Set_Rotor (X : out Rotor; MV : Multivector); -- procedure Set_Rotor (X : out Rotor; BV : Bivector); -- procedure Set_Rotor (X : out Rotor; C_Scalar : float; BV : Bivector); -- procedure Set_Scalar (S : out Scalar; Value : float); -- function To_Unsigned (V : M_Vector) return Vector_Unsigned; -- function To_2D (V : M_Vector) return E2GA.M_Vector; -- function To_3D (V : E2GA.M_Vector) return M_Vector; -- function To_Vector (MV : Syn_SMultivector) return M_Vector; function To_MV_Vector (V : E3_Vector) return Multivectors.M_Vector; -- Unit_e normalizes rotor R -- function Unit_e (R : Rotor) return Rotor; -- Unit_e normalizes M_Vector X function Unit_E (X : E3_Vector) return E3_Vector; private -- M_Vector corresponds to e3ga.M_Vector coordinate storage float m_c[3] -- type M_Vector is record -- Coordinates : Vector_Coords_3D := (0.0, 0.0, 0.0); -- m_c[3] -- end record; -- -- type Bivector is record -- Grade_Use : Grade_Usage := 7; -- 2^2 + 2^1 +2^0 -- C1_e1e2 : float := 0.0; -- C2_e2e3 : float := 0.0; -- C3_e3e1 : float := 0.0; -- end record; type Outermorphism is new Array_19F; -- type Rotor is record -- -- Coords_Type : Rotor_Coordinates_Type := Rotor_Scalar_e1e2_e2e3_e3e1; -- C1_Scalar : float := 0.0; -- C2_e1e2 : float := 0.0; -- C3_e2e3 : float := 0.0; -- C4_e3e1 : float := 0.0; -- end record; type Syn_SMultivector is record C1_e1 : float := 0.0; C2_e2 : float := 0.0; C3_e3 : float := 0.0; C4_e1e2e3 : float := 0.0; end record; end E3GA;
AdaCore/training_material
Ada
1,145
ads
-- Routines used to print messages on the screen package Screen_Output is procedure Msg (S1 : String; S2 : String := ""; End_Line : Boolean := True); -- Prints message S1 followed by S2 on the screen. If End_Line is True -- appends to the message a carriage return (ie it ends a line). procedure Debug_Msg (S : String); -- Prints a debugging message if the flag Debug_On defined inside -- the body of this package is set to True; procedure Error_Msg (S1 : String; S2 : String := ""; S3 : String := ""); -- Prints the error message S1 followed by S2 followed by S3 on the screen. procedure Syntax_Error (S : String; Error_Pos : Natural := 0); -- Prints the current input line that is being read indicating the -- character that caused the syntax error. The position of this -- character is given in Error_Pos. If Error_Pos = 0 then the position -- of the last character read is used. After printing the current input -- line prints message S preceded by the current line number. procedure Pause; -- Prints a pause message, and then wait for a carriage return. end Screen_Output;
shintakezou/adaplayground
Ada
121
adb
with Ada.Text_IO; use Ada.Text_IO; with My_Class; procedure Test is T : My_Class.Object; begin T.Write; end Test;
reznikmm/matreshka
Ada
4,095
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_Strikethrough_Thickness_Attributes; package Matreshka.ODF_Svg.Strikethrough_Thickness_Attributes is type Svg_Strikethrough_Thickness_Attribute_Node is new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node and ODF.DOM.Svg_Strikethrough_Thickness_Attributes.ODF_Svg_Strikethrough_Thickness_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Strikethrough_Thickness_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Svg_Strikethrough_Thickness_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Svg.Strikethrough_Thickness_Attributes;
reznikmm/matreshka
Ada
3,759
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.Presentation_Placeholder_Attributes is pragma Preelaborate; type ODF_Presentation_Placeholder_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Presentation_Placeholder_Attribute_Access is access all ODF_Presentation_Placeholder_Attribute'Class with Storage_Size => 0; end ODF.DOM.Presentation_Placeholder_Attributes;
alvaromb/Compilemon
Ada
23,018
adb
with Semantica.Declsc3a, Decls.Dtdesc, Decls.Dgenerals; use Semantica.Declsc3a, Decls.Dtdesc, Decls.Dgenerals; package body Semantica.Assemblador is -- Caracter TAB per els comentaris Tab : constant Character := Ascii.Ht; -- Variable per mantenir la profunditat Prof_Actual : Nprof; -- Procediments per inserir les instruccions -- de codi assemblador. Tenim per els tres -- tipus de instruccions C3@: -- Instruccio amb 0 operadors procedure Instr_0_Op (Instruccio : in String) is begin Put_Line(Fitxer_Asmbl, Tab & Instruccio); end Instr_0_Op; -- Instruccio amb 1 operador procedure Instr_1_Op (Instruccio, Operand : in String) is begin Put_Line(Fitxer_Asmbl, Tab & Instruccio & Tab & Operand); end Instr_1_Op; -- Instruccio amb 2 operadors procedure Instr_2_Op (Instruccio, Operand1, Operand2 : in String) is begin Put_Line(Fitxer_Asmbl, Tab & Instruccio & Tab & Operand1 & ", " & Operand2); end Instr_2_Op; -- Comentaris procedure Comentari (Comentari : in String) is begin Put_Line(Fitxer_Asmbl, Tab & " # " & Tab & Comentari); end Comentari; -- Etiquetes procedure Etiqueta (Etiqueta : in String) is begin Put_Line(Fitxer_Asmbl, Trim(Etiqueta, Both) & ": nop"); end Etiqueta; -- LD a, %eax procedure Ld (Org : in Camp; --per ara usam camp Dst : in String) is Ivar : Info_Var; Prof_Var : Nprof; Vc : Valor; Dpa : Integer; Da : Despl renames Ivar.Desp; begin case Org.Tc is when Var => Ivar := Consulta(Tv, Org.Idv); Prof_Var := Consulta(Tp, Ivar.Np).Prof; -- 'a' es una variable constant if Ivar.Const then Comentari("LD variable constant" & Org.Idv'Img & ", " & Dst & " i TS " & Ivar.Tsub'Img); if Ivar.Tsub = Tsstr then Instr_2_Op("movl", "$_cnt_" & Trim(Org.Idv'Img, Both), Dst); else Instr_2_Op("movl", "$" & Trim(Ivar.Valconst'Img, Both), Dst); end if; -- 'a' es local elsif Prof_Var = Prof_Actual then -- 'a' es parametre local if Ivar.Param then Comentari("LD parametre local"); Instr_2_Op("movl", Da'Img & "(%ebp)", "%esi"); Instr_2_Op("movl", "(%esi)", Dst); -- 'a' es variable local else Comentari("LD variable local"); Instr_2_Op("movl", Trim(Da'Img, Both) & "(%ebp)", Dst); end if; -- 'a' es global elsif Prof_Var < Prof_Actual then -- 'a' es parametre global if Ivar.Param then Comentari("LD parametre global"); Instr_2_Op("movl", "$DISP", "%esi"); Dpa := 4*Integer(Prof_Var); Instr_2_Op("movl", Trim(Dpa'Img, Both) & "(%esi)", "%esi"); Instr_2_Op("movl", Trim(Da'Img, Both) & "(%esi)", "%esi"); Instr_2_Op("movl", "(%esi)", Dst); -- 'a' es variable global else Comentari("LD variable global"); Instr_2_Op("movl", "$DISP", "%esi"); Dpa := 4*Integer(Prof_Var); Instr_2_Op("movl", Trim(Dpa'Img, Both) & "(%esi)", "%esi"); Instr_2_Op("movl", Trim(Da'Img, Both) & "(%esi)", Dst); end if; else raise Error_Assemblador; end if; when Const => -- 'a' es una constant Ivar := Consulta(Tv, Org.Idc); Vc := Ivar.Valconst; if Ivar.Tsub = Tsstr then Comentari("LD es una constant string" & Org.Idc'Img & ", " & Dst); Instr_2_Op("movl", "$_cnt_" & Trim(Org.Idc'Img, Both), Dst); else Comentari("LD es una constant " & Org.Idc'Img & ", " & Dst); Instr_2_Op("movl", "$" & Trim(Vc'Img, Both), Dst); end if; when others => raise Error_Assemblador; end case; end Ld; -- ST %eax, a procedure St (Org : in String; Dst : in Camp) is Prof_Var : Nprof; Idst : Info_Var; Dpa : Integer; Da : Despl renames Idst.Desp; begin if Dst.Tc /= Var then raise Error_Assemblador; end if; Idst := Consulta(Tv, Dst.Idv); Prof_Var := Consulta(Tp, Idst.Np).Prof; -- 'a' es local if Prof_Var = Prof_Actual then -- 'a' es una variable local if not Idst.Param then Comentari("ST a una variable local"); Instr_2_Op("movl", Org, Trim(Da'Img, Both) & "(%ebp)"); -- 'a' es un parametre local else Comentari("ST a un parametre local"); Instr_2_Op("movl", Trim(Da'Img, Both) & "(%ebp)", "%edi"); Instr_2_Op("movl", Org, "(%edi)"); end if; -- 'a' es global elsif Prof_Var < Prof_Actual then -- 'a' es una variable global if not Idst.Param then Comentari("ST a una variable global"); Instr_2_Op("movl", "$DISP", "%esi"); Dpa := 4*Integer(Prof_Var); Instr_2_Op("addl", "$" & Trim(Dpa'Img, Both), "%esi"); Instr_2_Op("movl", "(%esi)", "%edi"); Instr_2_Op("movl", Org, Trim(Da'Img, Both) & "(%edi)"); -- 'a' es un parametre global else Comentari("ST a un parametre global"); Instr_2_Op("movl", "$DISP", "%esi"); Dpa := 4*Integer(Prof_Var); Instr_2_Op("addl", "$" & Trim(Dpa'Img, Both), "%esi"); Instr_2_Op("movl", "(%esi)", "%esi"); Instr_2_Op("movl", Trim(Da'Img, Both) & "(%esi)", "%edi"); Instr_2_Op("movl", Org, "(%edi)"); end if; else raise Error_Assemblador; end if; end St; -- LDA a, %eax procedure Ldaddr (Org : in Camp; Dst : in String) is Ivar : Info_Var; Prof_Var : Nprof; Dpa : Integer; Da : Despl renames Ivar.Desp; begin Ivar := Consulta(Tv, Org.Idv); case Org.Tc is -- 'a' es constant when Const => Comentari("LDADDR amb a constant" & Org.Idc'Img & ", " & Dst); Instr_2_Op("movl", "$" & Trim(Cons_Nom(Tn, Ivar.Id), Both), Dst); -- 'a' es una variable when Var => Prof_Var := Consulta(Tp, Ivar.Np).Prof; -- 'a' es una variable constant if Ivar.Const then Comentari("LDADDR amb var. constant" & Org.Idc'Img & ", " & Dst); Instr_2_Op("movl", "$" & Trim(Cons_Nom(Tn, Ivar.Id), Both), Dst); -- 'a' es local elsif Prof_Var = Prof_Actual then -- 'a' es una variable local if not Ivar.Param then Comentari("LDADDR amb variable local"); Instr_2_Op("leal", Trim(Da'Img, Both) & "(%ebp)", Dst); -- 'a' es un parametre local else Comentari("LDADDR amb parametre local"); Instr_2_Op("movl", Trim(Da'Img, Both) & "(%ebp)", Dst); end if; -- 'a' es global elsif Prof_Var < Prof_Actual then -- 'a' es una variable global if not Ivar.Param then Comentari("LDADDR amb variable global"); Instr_2_Op("movl", "$DISP", "%esi"); Dpa := 4*Integer(Prof_Var); Instr_2_Op("movl", Trim(Dpa'Img, Both) & "(%esi)", "%esi"); Instr_2_Op("leal", Trim(Da'Img, Both) & "(%esi)", Dst); -- 'a' es un parametre global else Comentari("LDADDR amb parametre global"); Instr_2_Op("movl", "$DISP", "%esi"); Dpa := 4*Integer(Prof_Var); Instr_2_Op("movl", Trim(Dpa'Img, Both) & "(%esi)", "%esi"); Instr_2_Op("movl", Trim(Da'Img, Both) & "(%esi)", Dst); end if; else raise Error_Assemblador; end if; when others => raise Error_Assemblador; end case; end Ldaddr; procedure Gce_Inicialitza (Nom_Fitxer : in String) is Iv : Info_Var; begin Create(Fitxer_Asmbl, Out_File, Nom_Fitxer & ".s"); Obrir_Fitxer(Nom_Fitxer); --dc3a --1) Constants Put_Line(Fitxer_Asmbl, ".section .data"); for I in Num_Var range 1..Tv.Nv loop Iv := Consulta(Tv, I); if Iv.Const then if Iv.Tsub = Tsstr then --Si es un String --s1 : .asciiz "El nombre de a's es" Put_Line(Fitxer_Asmbl, Tab & Cons_Nom(Tn, Iv.Id) & " : .asciz " & Trim(Cons_Str(Tn, rang_tcar(Iv.Valconst)), Both)); elsif Iv.Tsub = Tsent or Iv.Tsub = Tsbool then --Si es un numeric --c3 : .long 3 Put_Line(Fitxer_Asmbl, Tab & Cons_Nom(Tn, Iv.Id) & " : .long " & Trim(Iv.Valconst'Img, Both)); else --Si es un caracter --cc2 : .ascii "A" Put_Line(Fitxer_Asmbl, Tab & Cons_Nom(Tn, Iv.Id) & " : .ascii """ & Trim(Iv.Valconst'Img, Both) & """"); end if; end if; end loop; --2) Variables comuns New_Line(Fitxer_Asmbl); Put_Line(Fitxer_Asmbl, ".section .bss"); Put_Line(Fitxer_Asmbl, Tab & ".comm DISP, 100"); --3) Instruccions New_Line(Fitxer_Asmbl); Put_Line(Fitxer_Asmbl, ".section .text"); Put_Line(Fitxer_Asmbl, Tab & ".global main"); New_Line(Fitxer_Asmbl); Put_Line(Fitxer_Asmbl, "main:"); Put_Line(Fitxer_Asmbl, Tab & "jmp _etq_1"); end Gce_Inicialitza; procedure Gce_Genera is Ic3a : c3a; Txt : String (1..10); Dpn : Integer; Ide : Num_Etiq; Ipr : Info_Proc; begin while not Fi_Fitxer loop Ipr := Info_Proc_Nul; Ide := Etiq_Nul; Llegir_Fitxer(Ic3a); Txt := (others => ' '); Dpn := 0; case Ic3a.Instr is when Rtn => if Ic3a.Camp1.Tc /= Proc then raise Error_Assemblador; end if; New_Line(Fitxer_Asmbl); Comentari("Return " & Ic3a.Camp1.Idp'Img); Np := Np - 1; Ipr := Consulta(Tp, Ic3a.Camp1.Idp); Instr_2_Op("movl", "%ebp", "%esp"); Instr_1_Op("popl", "%ebp"); Instr_2_Op("movl", "$DISP", "%edi"); Dpn := 4*Integer(Ipr.Prof); Instr_1_Op("popl", Trim(Dpn'Img, Both) & "(%edi)"); Instr_0_Op("ret"); when Call => if Ic3a.Camp1.Tc /= Proc then raise Error_Assemblador; end if; New_Line(Fitxer_Asmbl); Comentari("Call " & Ic3a.Camp1.Idp'Img); Ipr := Consulta(Tp, Ic3a.Camp1.Idp); if Ic3a.Camp1.Idp = Id_Puts or Ic3a.Camp1.Idp = Id_Gets then Comentari("Crida a 'gets' o 'puts'"); Instr_1_Op("popl", "%eax"); Instr_2_Op("movl", "(%eax)", "%eax"); Instr_1_Op("pushl", "%eax"); end if; Instr_1_Op("call", Trim(Etiqueta(Ipr), Both)); Instr_2_Op("addl", "$" & Trim(Ipr.Ocup_Param'Img, Both), "%esp"); --end if; when Preamb => if Ic3a.Camp1.Tc /= Proc then raise Error_Assemblador; end if; New_Line(Fitxer_Asmbl); Comentari("Preambul "& Ic3a.Camp1.Idp'Img); Nproc := Nproc + 1; Ipr := Consulta(Tp, Ic3a.Camp1.Idp); Prof_Actual := Ipr.Prof; Instr_2_Op("movl", "$DISP", "%esi"); Dpn := 4*Integer(Ipr.Prof); Instr_1_Op("pushl", Trim(Dpn'Img, Both) & "(%esi)"); Instr_1_Op("pushl", "%ebp"); Instr_2_Op("movl", "%esp", "%ebp"); Instr_2_Op("movl", "%ebp", Trim(Dpn'Img, Both) & "(%esi)"); Instr_2_Op("subl", "$" & Trim(Ipr.Ocup_Var'Img, Both), "%esp"); when Params => New_Line(Fitxer_Asmbl); Comentari("Parametre Simple"); Ldaddr(Ic3a.Camp1, "%eax"); Instr_1_Op("pushl", "%eax"); when Etiqueta => if Ic3a.Camp1.Tc /= Etiq then raise Error_Assemblador; end if; New_Line(Fitxer_Asmbl); Comentari("Etiqueta " & Ic3a.Camp1.Ide'Img); Etiqueta("_etq_" & Trim(Ic3a.Camp1.Ide'Img, Both)); when Branc_Inc => if Ic3a.Camp1.Tc /= Etiq then raise Error_Assemblador; end if; New_Line(Fitxer_Asmbl); Comentari("Brancament Incondicional " & Ic3a.Camp1.Ide'Img); Instr_1_Op("jmp", "_etq_" & Trim(Ic3a.Camp1.Ide'Img, Both)); -- 2 Operands when Negacio => New_Line(Fitxer_Asmbl); Comentari("Negacio"); Instr_2_Op("xorl", "%eax", "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("subl", "%ebx", "%eax"); St("%eax", Ic3a.Camp1); when Op_Not => New_Line(Fitxer_Asmbl); Comentari("Not"); Ld(Ic3a.Camp2, "%eax"); Instr_1_Op("notl", "%eax"); St("%eax", Ic3a.Camp1); when Copia => New_Line(Fitxer_Asmbl); Comentari("Copia"); Ld(Ic3a.Camp2, "%eax"); St("%eax", Ic3a.Camp1); when Paramc => New_Line(Fitxer_Asmbl); Comentari("Parametre Compost"); Ldaddr(Ic3a.Camp1, "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("addl", "%ebx", "%eax"); Instr_1_Op("pushl", "%eax"); -- 3 Operands when Suma => New_Line(Fitxer_Asmbl); Comentari("Suma"); Ld(Ic3a.Camp2, "%eax"); Ld(Ic3a.Camp3, "%ebx"); Instr_2_Op("addl", "%eax", "%ebx"); St("%ebx", Ic3a.Camp1); when Resta => New_Line(Fitxer_Asmbl); Comentari("Resta"); Ld(Ic3a.Camp2, "%eax"); Ld(Ic3a.Camp3, "%ebx"); Instr_2_Op("subl", "%ebx", "%eax"); St("%eax", Ic3a.Camp1); when Producte => New_Line(Fitxer_Asmbl); Comentari("Producte"); Ld(Ic3a.Camp2, "%eax"); Ld(Ic3a.Camp3, "%ebx"); Instr_2_Op("imull", "%eax", "%ebx"); St("%ebx", Ic3a.Camp1); when Divisio => New_Line(Fitxer_Asmbl); Comentari("Divisio"); Ld(Ic3a.Camp2, "%eax"); Instr_2_Op("movl", "%eax", "%edx"); Instr_2_Op("sarl", "$31", "%edx"); Ld(Ic3a.Camp3, "%ebx"); Instr_1_Op("idivl", "%ebx"); St("%eax", Ic3a.Camp1); when Modul => New_Line(Fitxer_Asmbl); Comentari("Modul"); Ld(Ic3a.Camp2, "%eax"); Instr_2_Op("movl", "%eax", "%edx"); Instr_2_Op("sarl", "$31", "%edx"); Ld(Ic3a.Camp3, "%ebx"); Instr_1_Op("idivl", "%ebx"); St("%edx", Ic3a.Camp1); when Op_And => New_Line(Fitxer_Asmbl); Comentari("AND"); Ld(Ic3a.Camp2, "%eax"); Ld(Ic3a.Camp3, "%ebx"); Instr_2_Op("andl", "%ebx", "%eax"); St("%eax", Ic3a.Camp1); when Op_Or => New_Line(Fitxer_Asmbl); Comentari("OR"); Ld(Ic3a.Camp2, "%eax"); Ld(Ic3a.Camp3, "%ebx"); Instr_2_Op("orl", "%ebx", "%eax"); St("%eax", Ic3a.Camp1); when Consindex => New_Line(Fitxer_Asmbl); Comentari("Consulta index"); Ldaddr(Ic3a.Camp2, "%esi"); Ld(Ic3a.Camp3, "%eax"); Instr_2_Op("addl", "%eax", "%esi"); Instr_2_Op("movl", "(%esi)", "%eax"); St("%eax", Ic3a.Camp1); when Asigindex => New_Line(Fitxer_Asmbl); Comentari("Assignacio d'index"); Ldaddr(Ic3a.Camp1, "%edi"); Ld(Ic3a.Camp2, "%eax"); Instr_2_Op("addl", "%eax", "%edi"); Ld(Ic3a.Camp3, "%eax"); Instr_2_Op("movl", "%eax","(%edi)"); when Menor => if Ic3a.Camp3.Tc /= Etiq then raise Error_Assemblador; end if; Comentari("IF Menor"); Ide := Nova_Etiq; Ld(Ic3a.Camp1, "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("cmpl", "%ebx", "%eax"); Instr_1_Op("jge", "_etq_" & Trim(Ide'Img, Both)); Instr_1_Op("jmp", "_etq_" & Trim(Ic3a.Camp3.Ide'Img, Both)); Etiqueta("_etq_" & Trim(Ide'Img, Both)); when Menorigual => if Ic3a.Camp3.Tc /= Etiq then raise Error_Assemblador; end if; Comentari("IF Menor o Igual"); Ide := Nova_Etiq; Ld(Ic3a.Camp1, "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("cmpl", "%ebx", "%eax"); Instr_1_Op("jg", "_etq_" & Trim(Ide'Img, Both)); Instr_1_Op("jmp", "_etq_" & Trim(Ic3a.Camp3.Ide'Img, Both)); Etiqueta("_etq_" & Trim(Ide'Img, Both)); when Igual => if Ic3a.Camp3.Tc /= Etiq then raise Error_Assemblador; end if; Comentari("IF Igual"); Ide := Nova_Etiq; Ld(Ic3a.Camp1, "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("cmpl", "%ebx", "%eax"); Instr_1_Op("jne", "_etq_" & Trim(Ide'Img, Both)); Instr_1_Op("jmp", "_etq_" & Trim(Ic3a.Camp3.Ide'Img, Both)); Etiqueta("_etq_" & Trim(Ide'Img, Both)); when Majorigual => if Ic3a.Camp3.Tc /= Etiq then raise Error_Assemblador; end if; Comentari("IF Major o Igual"); Ide := Nova_Etiq; Ld(Ic3a.Camp1, "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("cmpl", "%ebx", "%eax"); Instr_1_Op("jl", "_etq_" & Trim(Ide'Img, Both)); Instr_1_Op("jmp", "_etq_" & Trim(Ic3a.Camp3.Ide'Img, Both)); Etiqueta("_etq_" & Trim(Ide'Img, Both)); when Major => if Ic3a.Camp3.Tc /= Etiq then raise Error_Assemblador; end if; Comentari("IF Major"); Ide := Nova_Etiq; Ld(Ic3a.Camp1, "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("cmpl", "%ebx", "%eax"); Instr_1_Op("jle", "_etq_" & Trim(Ide'Img, Both)); Instr_1_Op("jmp", "_etq_" & Trim(Ic3a.Camp3.Ide'Img, Both)); Etiqueta("_etq_" & Trim(Ide'Img, Both)); when Diferent => if Ic3a.Camp3.Tc /= Etiq then raise Error_Assemblador; end if; Comentari("IF Diferent"); Ide := Nova_Etiq; Ld(Ic3a.Camp1, "%eax"); Ld(Ic3a.Camp2, "%ebx"); Instr_2_Op("cmpl", "%ebx", "%eax"); Instr_1_Op("je", "_etq_" & Trim(Ide'Img, Both)); Instr_1_Op("jmp", "_etq_" & Trim(Ic3a.Camp3.Ide'Img, Both)); Etiqueta("_etq_" & Trim(Ide'Img, Both)); when others => raise Error_Assemblador; end case; end loop; end Gce_Genera; procedure Gce_Finalitza is begin Tanca_Fitxer; --dc3a Close(Fitxer_Asmbl); exception when others=> null; end Gce_Finalitza; procedure Genera_Assemblador (Nom_Fitxer : in String) is begin if Esem then raise Error_Assemblador; end if; Gce_Inicialitza(Nom_Fitxer); Gce_Genera; Gce_Finalitza; exception when Error_Assemblador => Comentari("Error assemblador"); end Genera_Assemblador; end Semantica.Assemblador;
reznikmm/matreshka
Ada
4,783
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_Index_Entry_Text_Elements; package Matreshka.ODF_Text.Index_Entry_Text_Elements is type Text_Index_Entry_Text_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Index_Entry_Text_Elements.ODF_Text_Index_Entry_Text with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Index_Entry_Text_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Index_Entry_Text_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Index_Entry_Text_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_Index_Entry_Text_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_Index_Entry_Text_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.Index_Entry_Text_Elements;
persan/protobuf-ada
Ada
15,917
adb
pragma Ada_2012; with Ada.Unchecked_Conversion; with Ada.IO_Exceptions; package body Protocol_Buffers.IO.Coded_Input_Stream is ----------------------- -- Decode_Zig_Zag_32 -- ----------------------- function Decode_Zig_Zag_32 (Value : in TMP_UNSIGNED_INTEGER) return TMP_UNSIGNED_INTEGER is Value_To_Unsigned_32 : Interfaces.Unsigned_32 := Interfaces.Unsigned_32 (Value); use type Interfaces.Unsigned_32; begin return TMP_UNSIGNED_INTEGER (Interfaces.Shift_Right (Value_To_Unsigned_32, 1) xor - (Value_To_Unsigned_32 and 1)); end Decode_Zig_Zag_32; ----------------------- -- Decode_Zig_Zag_64 -- ----------------------- function Decode_Zig_Zag_64 (Value : in TMP_UNSIGNED_LONG) return TMP_UNSIGNED_LONG is Value_To_Unsigned_64 : Interfaces.Unsigned_64 := Interfaces.Unsigned_64 (Value); use type Interfaces.Unsigned_64; begin return TMP_UNSIGNED_LONG (Interfaces.Shift_Right (Value_To_Unsigned_64, 1) xor - (Value_To_Unsigned_64 and 1)); end Decode_Zig_Zag_64; ------------------ -- Read_Boolean -- ------------------ function Read_Boolean (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_BOOLEAN is function BOOLEAN_TO_TMP_BOOLEAN is new Ada.Unchecked_Conversion (Source => Boolean, Target => TMP_BOOLEAN); use type TMP_UNSIGNED_BYTE; begin return BOOLEAN_TO_TMP_BOOLEAN (The_Coded_Input_Stream.Read_Raw_Byte /= 0); end Read_Boolean; ----------------- -- Read_Double -- ----------------- function Read_Double (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_DOUBLE is function TMP_UNSIGNED_LONG_To_TMP_DOUBLE is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_LONG, Target => TMP_DOUBLE); begin return TMP_UNSIGNED_LONG_To_TMP_DOUBLE (The_Coded_Input_Stream.Read_Raw_Little_Endian_64); end Read_Double; ---------------------- -- Read_Enumeration -- ---------------------- function Read_Enumeration (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_INTEGER is function TMP_UNSIGNED_INTEGER_To_TMP_INTEGER is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_INTEGER, Target => TMP_INTEGER); begin return TMP_UNSIGNED_INTEGER_To_TMP_INTEGER (The_Coded_Input_Stream.Read_Raw_Varint_32); end Read_Enumeration; ------------------- -- Read_Fixed_32 -- ------------------- function Read_Fixed_32 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_INTEGER is begin return The_Coded_Input_Stream.Read_Raw_Little_Endian_32; end Read_Fixed_32; ------------------- -- Read_Fixed_64 -- ------------------- function Read_Fixed_64 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_LONG is begin return The_Coded_Input_Stream.Read_Raw_Little_Endian_64; end Read_Fixed_64; ---------------- -- Read_Float -- ---------------- function Read_Float (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_FLOAT is function TMP_UNSIGNED_INTEGER_To_TMP_FLOAT is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_INTEGER, Target => TMP_FLOAT); begin return TMP_UNSIGNED_INTEGER_To_TMP_FLOAT (The_Coded_Input_Stream.Read_Raw_Little_Endian_32); end Read_Float; --------------------- -- Read_Integer_32 -- --------------------- function Read_Integer_32 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_INTEGER is function TMP_UNSIGNED_INTEGER_To_TMP_INTEGER is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_INTEGER, Target => TMP_INTEGER); begin return TMP_UNSIGNED_INTEGER_To_TMP_INTEGER (The_Coded_Input_Stream.Read_Raw_Varint_32); end Read_Integer_32; --------------------- -- Read_Integer_64 -- --------------------- function Read_Integer_64 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_LONG is function TMP_UNSIGNED_LONG_To_TMP_LONG is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_LONG, Target => TMP_LONG); begin return TMP_UNSIGNED_LONG_To_TMP_LONG (The_Coded_Input_Stream.Read_Raw_Varint_64); end Read_Integer_64; ------------------- -- Read_Raw_Byte -- ------------------- function Read_Raw_Byte (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_BYTE is Value : TMP_UNSIGNED_BYTE; begin TMP_UNSIGNED_BYTE'Read (The_Coded_Input_Stream.Input_Stream, Value); return Value; end Read_Raw_Byte; ------------------------------- -- Read_Raw_Little_Endian_32 -- ------------------------------- function Read_Raw_Little_Endian_32 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_INTEGER is Value : TMP_UNSIGNED_INTEGER; begin TMP_UNSIGNED_INTEGER'Read (The_Coded_Input_Stream.Input_Stream, Value); return Value; end Read_Raw_Little_Endian_32; ------------------------------- -- Read_Raw_Little_Endian_64 -- ------------------------------- function Read_Raw_Little_Endian_64 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_LONG is Value : TMP_UNSIGNED_LONG; begin TMP_UNSIGNED_LONG'Read (The_Coded_Input_Stream.Input_Stream, Value); return Value; end Read_Raw_Little_Endian_64; ------------------------ -- Read_Raw_Varint_32 -- ------------------------ function Read_Raw_Varint_32 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_INTEGER is Result : TMP_UNSIGNED_INTEGER := 0; Tmp : TMP_UNSIGNED_BYTE := The_Coded_Input_Stream.Read_Raw_Byte; Byte_MSB_Set : constant := 16#80#; use type TMP_UNSIGNED_BYTE; use type TMP_UNSIGNED_INTEGER; begin -- MSB not set, which means that varint consist of only one byte. See Base 128 Varints: -- https://developers.google.com/protocol-buffers/docs/encoding if Tmp < Byte_MSB_Set then return TMP_UNSIGNED_INTEGER (Tmp); end if; Result := TMP_UNSIGNED_INTEGER (Tmp and 16#7F#); -- (TMP and 16#7F#) == set MSB to 0 Tmp := The_Coded_Input_Stream.Read_Raw_Byte; if Tmp < Byte_MSB_Set then Result := Result or Shift_Left (TMP_UNSIGNED_INTEGER (Tmp), 7); else Result := Result or Shift_Left (TMP_UNSIGNED_INTEGER (Tmp and 16#7F#), 7); Tmp := The_Coded_Input_Stream.Read_Raw_Byte; if Tmp < Byte_MSB_Set then Result := Result or Shift_Left (TMP_UNSIGNED_INTEGER (Tmp), 14); else Result := Result or Shift_Left (TMP_UNSIGNED_INTEGER (Tmp and 16#7F#), 14); Tmp := The_Coded_Input_Stream.Read_Raw_Byte; if Tmp < Byte_MSB_Set then Result := Result or Shift_Left (TMP_UNSIGNED_INTEGER (Tmp), 21); else Result := Result or Shift_Left (TMP_UNSIGNED_INTEGER (Tmp and 16#7F#), 21); Tmp := The_Coded_Input_Stream.Read_Raw_Byte; Result := Result or Shift_Left (TMP_UNSIGNED_INTEGER (Tmp), 28); -- Tests if last byte has MSB set in which case the varint is -- malformed, since it cannot be represented by a 32-bit type. if Tmp >= Byte_MSB_Set then -- Discard upper 32-bits for I in 1 .. 5 loop Tmp := The_Coded_Input_Stream.Read_Raw_Byte; if Tmp < Byte_MSB_Set then return Result; end if; end loop; pragma Compile_Time_Warning (Standard.True, "Add indication of malformed varint"); end if; end if; end if; end if; return Result; end Read_Raw_Varint_32; ------------------------ -- Read_Raw_Varint_64 -- ------------------------ function Read_Raw_Varint_64 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_LONG is Shift : Natural := 0; Result : TMP_UNSIGNED_LONG := 0; Tmp : TMP_UNSIGNED_BYTE; Byte_MSB_Set : constant := 16#80#; use type TMP_UNSIGNED_BYTE; use type TMP_UNSIGNED_LONG; begin while Shift < 64 loop Tmp := The_Coded_Input_Stream.Read_Raw_Byte; Result := Result or Shift_Left (TMP_UNSIGNED_LONG (Tmp and 16#7F#), Shift); if (Tmp and Byte_MSB_Set) = 0 then return Result; end if; Shift := Shift + 7; end loop; pragma Compile_Time_Warning (Standard.True, "Add indication of malformed varint"); return Result; -- Temporary fix end Read_Raw_Varint_64; -------------------------- -- Read_Signed_Fixed_32 -- -------------------------- function Read_Signed_Fixed_32 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_INTEGER is function TMP_UNSIGNED_INTEGER_To_TMP_INTEGER is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_INTEGER, Target => TMP_INTEGER); begin return TMP_UNSIGNED_INTEGER_To_TMP_INTEGER (The_Coded_Input_Stream.Read_Raw_Little_Endian_32); end Read_Signed_Fixed_32; -------------------------- -- Read_Signed_Fixed_64 -- -------------------------- function Read_Signed_Fixed_64 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_LONG is function TMP_UNSIGNED_LONG_To_TMP_LONG is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_LONG, Target => TMP_LONG); begin return TMP_UNSIGNED_LONG_To_TMP_LONG (The_Coded_Input_Stream.Read_Raw_Little_Endian_64); end Read_Signed_Fixed_64; ---------------------------- -- Read_Signed_Integer_32 -- ---------------------------- function Read_Signed_Integer_32 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_INTEGER is function TMP_UNSIGNED_INTEGER_To_TMP_INTEGER is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_INTEGER, Target => TMP_INTEGER); begin return TMP_UNSIGNED_INTEGER_To_TMP_INTEGER (Decode_Zig_Zag_32 (The_Coded_Input_Stream.Read_Raw_Varint_32)); end Read_Signed_Integer_32; ---------------------------- -- Read_Signed_Integer_64 -- ---------------------------- function Read_Signed_Integer_64 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_LONG is function TMP_UNSIGNED_LONG_To_TMP_LONG is new Ada.Unchecked_Conversion (Source => TMP_UNSIGNED_LONG, Target => TMP_LONG); begin return TMP_UNSIGNED_LONG_To_TMP_LONG (Decode_Zig_Zag_64 (The_Coded_Input_Stream.Read_Raw_Varint_64)); end Read_Signed_Integer_64; ----------------- -- Read_String -- ----------------- function Read_String (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return Ada.Strings.Unbounded.Unbounded_String is function To_Standard_Character is new Ada.Unchecked_Conversion (Source => Interfaces.Unsigned_8, Target => Standard.Character); -- begin -- The_Coded_Output_Stream.Write_Raw_Varint_32 (Value'Length); -- for I in 1 .. Value'Length loop -- The_Coded_Output_Stream.Write_Raw_Byte(To_Interfaces_Unsigned_8(Value(I))); -- end loop; String_Length : Integer := Integer(The_Coded_Input_Stream.Read_Raw_Varint_32); Target_String : String(1..String_Length); begin for I in 1 .. String_Length loop Target_String(I) := To_Standard_Character(The_Coded_Input_Stream.Read_Raw_Byte); end loop; return Ada.Strings.Unbounded.To_Unbounded_String(Target_String); end Read_String; -------------- -- Read_Tag -- -------------- function Read_Tag (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_INTEGER is begin declare begin return The_Coded_Input_Stream.Read_Raw_Varint_32; exception when Ada.IO_Exceptions.End_Error => return 0; end; end Read_Tag; ------------------------------ -- Read_Unsigned_Integer_32 -- ------------------------------ function Read_Unsigned_Integer_32 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_INTEGER is begin return The_Coded_Input_Stream.Read_Raw_Varint_32; end Read_Unsigned_Integer_32; ------------------------------ -- Read_Unsigned_Integer_64 -- ------------------------------ function Read_Unsigned_Integer_64 (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) return TMP_UNSIGNED_LONG is begin return The_Coded_Input_Stream.Read_Raw_Varint_64; end Read_Unsigned_Integer_64; ---------------- -- Skip_Field -- ---------------- function Skip_Field (The_Coded_Input_Stream : in Coded_Input_Stream.Instance; Tag : in TMP_UNSIGNED_INTEGER) return Boolean is Dummy_1 : TMP_INTEGER; Dummy_2 : TMP_UNSIGNED_INTEGER; Dummy_3 : TMP_UNSIGNED_LONG; begin case Get_Tag_Wire_Type (Tag) is when VARINT => Dummy_1 := The_Coded_Input_Stream.Read_Integer_32; return True; when FIXED_32 => Dummy_2 := The_Coded_Input_Stream.Read_Raw_Little_Endian_32; return True; when FIXED_64 => Dummy_3 := The_Coded_Input_Stream.Read_Raw_Little_Endian_64; return True; when LENGTH_DELIMITED => The_Coded_Input_Stream.Skip_Raw_Bytes (The_Coded_Input_Stream.Read_Raw_Varint_32); return True; when START_GROUP => pragma Compile_Time_Warning (Standard.True, "START_GROUP unimplemented"); return True; when END_GROUP => return False; end case; end Skip_Field; -------------------- -- Skip_Raw_Bytes -- -------------------- procedure Skip_Raw_Bytes (The_Coded_Input_Stream : in Coded_Input_Stream.Instance; Bytes_To_Skip : in TMP_UNSIGNED_INTEGER) is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Skip_Raw_Bytes unimplemented"); raise Program_Error with "Unimplemented procedure Skip_Raw_Bytes"; end Skip_Raw_Bytes; ------------------ -- Skip_Message -- ------------------ procedure Skip_Message (The_Coded_Input_Stream : in Coded_Input_Stream.Instance) is Tag : TMP_UNSIGNED_INTEGER; use type TMP_UNSIGNED_INTEGER; begin loop Tag := The_Coded_Input_Stream.Read_Tag; if Tag = 0 or else (not The_Coded_Input_Stream.Skip_Field (Tag)) then return; end if; end loop; end Skip_Message; end Protocol_Buffers.IO.Coded_Input_Stream;
zhmu/ananas
Ada
8,572
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- V A L I D S W -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-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 unit contains the routines used to handle setting of validity -- checking options. package Validsw is ----------------------------- -- Validity Check Switches -- ----------------------------- -- The following flags determine the specific set of validity checks -- to be made if validity checking is active (Validity_Checks_On = True) -- See GNAT users guide for an exact description of each option. The letter -- given in the comment is the letter used in the -gnatV compiler switch -- or in the argument of a Validity_Checks pragma to activate the option. -- The corresponding upper case letter deactivates the option. Validity_Check_Components : Boolean := False; -- Controls validity checking for assignment to elementary components of -- records. If this switch is set to True using -gnatVe, or an 'e' in the -- argument of Validity_Checks pragma, then the right-hand side of an -- assignment to such a component is checked for validity. Validity_Check_Copies : Boolean := False; -- Controls the validity checking of copies. If this switch is set to -- True using -gnatVc, or a 'c' in the argument of a Validity_Checks -- pragma, then the right-hand side of assignments and also initializing -- expressions in object declarations are checked for validity. Validity_Check_Default : Boolean := True; -- Controls default (reference manual) validity checking. If this switch is -- set to True using -gnatVd or a 'd' in the argument of a Validity_Checks -- pragma (or the initial default value is used, set True), then left-hand -- side subscripts and case statement arguments are checked for validity. -- This switch is also set by default if no -gnatV switch is used and no -- Validity_Checks pragma is processed. Validity_Check_Floating_Point : Boolean := False; -- Normally validity checking applies only to discrete values (integer and -- enumeration types). If this switch is set to True using -gnatVf or an -- 'f' in the argument of a Validity_Checks pragma, then floating-point -- values are also checked. If the context in which such checks occur -- depends on other flags, e.g. if Validity_Check_Copies is also set, -- then floating-point values on the right-hand side of an assignment -- will be validity checked. Validity_Check_In_Out_Params : Boolean := False; -- Controls the validity checking of IN OUT parameters. If this switch -- is set to True using -gnatVm or a 'm' in the argument of a pragma -- Validity_Checks, then the initial value of all IN OUT parameters -- will be checked at the point of call of a procedure. Note that the -- character 'm' here stands for modified (parameters). Validity_Check_In_Params : Boolean := False; -- Controls the validity checking of IN parameters. If this switch is -- set to True using -gnatVi or an 'i' in the argument of a pragma -- Validity_Checks, then the initial value of all IN parameters -- will be checked at the point of call of a procedure or function. Validity_Check_Operands : Boolean := False; -- Controls validity checking of operands. If this switch is set to -- True using -gnatVo or an 'o' in the argument of a Validity_Checks -- pragma, then operands of all predefined operators and attributes -- will be validity checked. Validity_Check_Parameters : Boolean := False; -- This controls validity treatment for parameters within a subprogram. -- Normally if validity checking is enabled for parameters on a call -- (Validity_Check_In[_Out]_Params) then an assumption is made that the -- parameter values are valid on entry and not checked again within a -- procedure. Setting Validity_Check_Parameters removes this assumption -- and ensures that no assumptions are made about parameters, so that -- they will always be checked. Validity_Check_Returns : Boolean := False; -- Controls validity checking of returned values. If this switch is set -- to True using -gnatVr, or an 'r' in the argument of a Validity_Checks -- pragma, then the expression in a RETURN statement is validity checked. Validity_Check_Subscripts : Boolean := False; -- Controls validity checking of subscripts. If this switch is set to True -- using -gnatVs, or an 's' in the argument of a Validity_Checks pragma, -- then all subscripts are checked for validity. Note that left-hand side -- subscript checking is also controlled by Validity_Check_Default. If -- Validity_Check_Subscripts is True, then all subscripts are checked, -- otherwise if Validity_Check_Default is True, then left-hand side -- subscripts are checked; otherwise no subscripts are checked. Validity_Check_Tests : Boolean := False; -- Controls validity checking of tests that occur in conditions (i.e. the -- tests in IF, WHILE, and EXIT statements, and in entry guards). If this -- switch is set to True using -gnatVt, or a 't' in the argument of a -- Validity_Checks pragma, then all such conditions are validity checked. Force_Validity_Checks : Boolean := False; -- Normally, operands that do not come from source (i.e. cases of expander -- generated code) are not checked, if this flag is set True, then checking -- of such operands is forced (if Validity_Check_Operands is set). ----------------- -- Subprograms -- ----------------- procedure Set_Validity_Check_Options (Options : String; OK : out Boolean; Err_Col : out Natural); -- This procedure is called to set the validity check options that -- correspond to the characters in the given Options string. If -- all options are valid, then Set_Default_Validity_Check_Options -- is first called to set the defaults, and then the options in the -- given string are set in an additive manner. If any invalid character -- is found, then OK is False on exit, and Err_Col is the index in -- in options of the bad character. If all options are valid, then -- OK is True on return, and Err_Col is set to options'Last + 1. procedure Set_Validity_Check_Options (Options : String); -- Like the above procedure, except that the call is simply ignored if -- there are any error conditions, this is for example appropriate for -- calls where the string is known to be valid. procedure Reset_Validity_Check_Options; -- Sets all validity check options to off subtype Validity_Check_Options is String (1 .. 16); -- Long enough string to hold all options from Save call below end Validsw;
DrenfongWong/tkm-rpc
Ada
1,077
adb
with Tkmrpc.Operations.Cfg; with Tkmrpc.Operation_Handlers.Cfg.Tkm_Version; with Tkmrpc.Operation_Handlers.Cfg.Tkm_Limits; with Tkmrpc.Operation_Handlers.Cfg.Tkm_Reset; package body Tkmrpc.Dispatchers.Cfg is ------------------------------------------------------------------------- procedure Dispatch (Req : Request.Data_Type; Res : out Response.Data_Type) is begin case Req.Header.Operation is when Operations.Cfg.Tkm_Version => Operation_Handlers.Cfg.Tkm_Version.Handle (Req => Req, Res => Res); when Operations.Cfg.Tkm_Limits => Operation_Handlers.Cfg.Tkm_Limits.Handle (Req => Req, Res => Res); when Operations.Cfg.Tkm_Reset => Operation_Handlers.Cfg.Tkm_Reset.Handle (Req => Req, Res => Res); when others => Res := Response.Null_Data; Res.Header.Operation := Req.Header.Operation; end case; Res.Header.Request_Id := Req.Header.Request_Id; end Dispatch; end Tkmrpc.Dispatchers.Cfg;
reznikmm/matreshka
Ada
4,425
adb
-- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/ayacc.a,v 1.1 88/08/08 12:07:07 arcadia Exp $ --************************************************************************ -- ayacc -- version 1.1 -- --*********************************************************************** -- -- Arcadia Project -- Department of Information and Computer Science -- University of California -- Irvine, California 92717 -- -- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- The primary authors of ayacc were David Taback and Deepak Tolani. -- Enhancements were made by Ronald J. Schmalz. -- Further enhancements were made by Yidong Chen. -- -- Send requests for ayacc information to [email protected] -- Send bug reports for ayacc to [email protected] -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- Module : ayacc.ada -- Component of : ayacc -- Version : 1.2 -- Date : 11/21/86 12:28:24 -- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxayacc.ada -- $Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/ayacc.a,v 1.1 88/08/08 12:07:07 arcadia Exp $ -- $Log: ayacc.a,v $ --Revision 1.1 88/08/08 12:07:07 arcadia --Initial revision -- -- Revision 0.1 86/04/01 15:04:07 ada -- This version fixes some minor bugs with empty grammars -- and $$ expansion. It also uses vads5.1b enhancements -- such as pragma inline. -- -- -- Revision 0.0 86/02/19 19:00:49 ada -- -- These files comprise the initial version of Ayacc -- designed and implemented by David Taback and Deepak Tolani. -- Ayacc has been compiled and tested under the Verdix Ada compiler -- version 4.06 on a vax 11/750 running Unix 4.2BSD. -- with Source_File, Ayacc_File_Names, Options, Parser, Tokens_File, Output_File, Parse_Table, Text_IO, -- u_env, -- For getting the command line arguments Symbol_Table, -- Used for statistics only Rule_Table; -- Used for statistics only -- UMASS CODES : with Error_Report_File; -- END OF UMASS CODES. procedure Ayacc is Rcs_ID : constant String := "$Header: /cf/ua/arcadia/alex-ayacc/ayacc/src/RCS/ayacc.a,v 1.1 88/08/08 12:07:07 arcadia Exp $"; copyright : constant string := "@(#) Copyright (c) 1990 Regents of the University of California."; copyright2 : constant string := "All rights reserved."; Illegal_Argument_List : exception; use Text_IO; procedure Initialize is separate; procedure Print_Statistics is separate; begin Initialize; Source_File.Open; Tokens_File.Open; Parser.Parse_Declarations; Parser.Parse_Rules; Parse_Table.Make_Parse_Table; Output_File.Make_Output_File; Tokens_File.Complete_Tokens_Package; -- UMASS CODES : -- Generate the error report file if the codes -- of error recovery extension should be generated. if Options.Error_Recovery_Extension then Error_Report_File.Write_File; end if; -- END OF UMASS CODES. Source_File.Close; Tokens_File.Close; if Options.Interface_to_C then Tokens_File.Make_C_Lex_Package; end if; Print_Statistics; exception when Ayacc_File_Names.Illegal_File_Name => Put_Line("Ayacc: Illegal Filename."); when Options.Illegal_Option | Illegal_Argument_List => null; when Parser.Syntax_Error => -- Error has already been reported. Source_File.Close; when Text_IO.Name_Error | Text_IO.Use_Error => null; -- Error has already been reported. when others => Put_Line ("Ayacc: Internal Error, Please Submit an LCR."); end Ayacc;
yannickmoy/SPARKNaCl
Ada
2,523
adb
with SPARKNaCl; use SPARKNaCl; with SPARKNaCl.Core; use SPARKNaCl.Core; with SPARKNaCl.Debug; use SPARKNaCl.Debug; with SPARKNaCl.Secretbox; use SPARKNaCl.Secretbox; with SPARKNaCl.Stream; with Ada.Text_IO; use Ada.Text_IO; procedure Secretbox is Firstkey : constant Core.Salsa20_Key := Construct ((16#1b#, 16#27#, 16#55#, 16#64#, 16#73#, 16#e9#, 16#85#, 16#d4#, 16#62#, 16#cd#, 16#51#, 16#19#, 16#7a#, 16#9a#, 16#46#, 16#c7#, 16#60#, 16#09#, 16#54#, 16#9e#, 16#ac#, 16#64#, 16#74#, 16#f2#, 16#06#, 16#c4#, 16#ee#, 16#08#, 16#44#, 16#f6#, 16#83#, 16#89#)); Nonce : constant Stream.HSalsa20_Nonce := (16#69#, 16#69#, 16#6e#, 16#e9#, 16#55#, 16#b6#, 16#2b#, 16#73#, 16#cd#, 16#62#, 16#bd#, 16#a8#, 16#75#, 16#fc#, 16#73#, 16#d6#, 16#82#, 16#19#, 16#e0#, 16#03#, 16#6b#, 16#7a#, 16#0b#, 16#37#); M : constant Byte_Seq (0 .. 162) := (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16#be#, 16#07#, 16#5f#, 16#c5#, 16#3c#, 16#81#, 16#f2#, 16#d5#, 16#cf#, 16#14#, 16#13#, 16#16#, 16#eb#, 16#eb#, 16#0c#, 16#7b#, 16#52#, 16#28#, 16#c5#, 16#2a#, 16#4c#, 16#62#, 16#cb#, 16#d4#, 16#4b#, 16#66#, 16#84#, 16#9b#, 16#64#, 16#24#, 16#4f#, 16#fc#, 16#e5#, 16#ec#, 16#ba#, 16#af#, 16#33#, 16#bd#, 16#75#, 16#1a#, 16#1a#, 16#c7#, 16#28#, 16#d4#, 16#5e#, 16#6c#, 16#61#, 16#29#, 16#6c#, 16#dc#, 16#3c#, 16#01#, 16#23#, 16#35#, 16#61#, 16#f4#, 16#1d#, 16#b6#, 16#6c#, 16#ce#, 16#31#, 16#4a#, 16#db#, 16#31#, 16#0e#, 16#3b#, 16#e8#, 16#25#, 16#0c#, 16#46#, 16#f0#, 16#6d#, 16#ce#, 16#ea#, 16#3a#, 16#7f#, 16#a1#, 16#34#, 16#80#, 16#57#, 16#e2#, 16#f6#, 16#55#, 16#6a#, 16#d6#, 16#b1#, 16#31#, 16#8a#, 16#02#, 16#4a#, 16#83#, 16#8f#, 16#21#, 16#af#, 16#1f#, 16#de#, 16#04#, 16#89#, 16#77#, 16#eb#, 16#48#, 16#f5#, 16#9f#, 16#fd#, 16#49#, 16#24#, 16#ca#, 16#1c#, 16#60#, 16#90#, 16#2e#, 16#52#, 16#f0#, 16#a0#, 16#89#, 16#bc#, 16#76#, 16#89#, 16#70#, 16#40#, 16#e0#, 16#82#, 16#f9#, 16#37#, 16#76#, 16#38#, 16#48#, 16#64#, 16#5e#, 16#07#, 16#05#); C : Byte_Seq (0 .. 162); S : Boolean; begin Create (C, S, M, Nonce, Firstkey); Put_Line ("Status is " & S'Img); DH ("C is", C); end Secretbox;
rveenker/sdlada
Ada
1,610
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- Unit_Tests -- -- Test runner. -------------------------------------------------------------------------------------------------------------------- with AUnit.Run; with AUnit.Reporter.Text; with SDL_Suites; procedure Unit_Tests is procedure Run is new AUnit.Run.Test_Runner (SDL_Suites.Suite); Reporter : AUnit.Reporter.Text.Text_Reporter; begin Reporter.Set_Use_ANSI_Colors (True); Run (Reporter); end Unit_Tests;
reznikmm/matreshka
Ada
3,636
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.Elements.Generic_Hash; function AMF.Utp.Timer_Running_Actions.Hash is new AMF.Elements.Generic_Hash (Utp_Timer_Running_Action, Utp_Timer_Running_Action_Access);
reznikmm/matreshka
Ada
6,313
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015-2017, 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.Definitions; with Asis.Elements; package body Properties.Definitions.Subtype_Indication is --------------- -- Alignment -- --------------- function Alignment (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Integer_Property) return Integer is Mark : constant Asis.Definition := Asis.Definitions.Subtype_Mark (Element); begin return Engine.Integer.Get_Property (Mark, Name); end Alignment; ------------ -- Bounds -- ------------ function Bounds (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Text_Property) return League.Strings.Universal_String is Mark : constant Asis.Definition := Asis.Definitions.Subtype_Mark (Element); Constr : constant Asis.Definition := Asis.Definitions.Subtype_Constraint (Element); begin if Asis.Elements.Is_Nil (Constr) then return Engine.Text.Get_Property (Mark, Name); else return Engine.Text.Get_Property (Constr, Name); end if; end Bounds; ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Text_Property) return League.Strings.Universal_String is Mark : constant Asis.Definition := Asis.Definitions.Subtype_Mark (Element); begin return Engine.Text.Get_Property (Mark, Name); end Code; ---------------- -- Initialize -- ---------------- function Initialize (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Text_Property) return League.Strings.Universal_String is Text : League.Strings.Universal_String; Mark : constant Asis.Definition := Asis.Definitions.Subtype_Mark (Element); Is_Simple : constant Boolean := Engine.Boolean.Get_Property (Element, Engines.Is_Simple_Type); Constr : constant Asis.Definition := Asis.Definitions.Subtype_Constraint (Element); begin if Is_Simple then Text := Engine.Text.Get_Property (Mark, Name); else Text.Append (" new "); Text.Append (Engine.Text.Get_Property (Mark, Engines.Code)); Text.Append ("("); if not Asis.Elements.Is_Nil (Constr) then Text.Append (Engine.Text.Get_Property (Constr, Engines.Code)); end if; Text.Append (")"); end if; return Text; end Initialize; function Is_Simple_Type (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Boolean_Property) return Boolean is Mark : constant Asis.Definition := Asis.Definitions.Subtype_Mark (Element); begin return Engine.Boolean.Get_Property (Mark, Name); end Is_Simple_Type; end Properties.Definitions.Subtype_Indication;
stcarrez/ada-util
Ada
1,908
ads
----------------------------------------------------------------------- -- util-commands-parsers.gnat_parser -- GNAT command line parser for command drivers -- Copyright (C) 2018, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with GNAT.Command_Line; package Util.Commands.Parsers.GNAT_Parser is package GC renames GNAT.Command_Line; subtype Config_Type is GC.Command_Line_Configuration; procedure Execute (Config : in out Config_Type; Args : in Util.Commands.Argument_List'Class; Process : not null access procedure (Cmd_Args : in Commands.Argument_List'Class)); procedure Usage (Name : in String; Config : in out Config_Type); -- Get all the remaining arguments from the GNAT command line parse. procedure Get_Arguments (List : in out Dynamic_Argument_List; Command : in String; Parser : in GC.Opt_Parser := GC.Command_Line_Parser); package Config_Parser is new Util.Commands.Parsers.Config_Parser (Config_Type => Config_Type, Execute => Execute); end Util.Commands.Parsers.GNAT_Parser;
reznikmm/matreshka
Ada
3,961
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_Style_Attributes; package Matreshka.ODF_Draw.Style_Attributes is type Draw_Style_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Style_Attributes.ODF_Draw_Style_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Style_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Style_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Style_Attributes;
charlie5/aIDE
Ada
71
ads
package AdaM.Assist.Query.find_All is end AdaM.Assist.Query.find_All;
sf17k/sdlada
Ada
1,921
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- package body SDL.Video.Surfaces is use type SDL.C_Pointers.Surface_Pointer; overriding procedure Finalize (Self : in out Surface) is -- procedure SDL_Destroy_Renderer (R : in SDL.C_Pointers.Renderer_Pointer) with -- Import => True, -- Convention => C, -- External_Name => "SDL_DestroyRenderer"; begin if Self.Internal /= null and then Self.Owns then -- SDL_Destroy_Renderer (Self.Internal); Self.Internal := null; end if; end Finalize; function Get_Internal_Surface (Self : in Surface) return SDL.C_Pointers.Surface_Pointer is begin return Self.Internal; end Get_Internal_Surface; end SDL.Video.Surfaces;
sungyeon/drake
Ada
733
adb
with Ada.Text_IO; procedure tty_key is use type Ada.Text_IO.Count; C, D : Character; Avail : Boolean; Line_Length : Ada.Text_IO.Count := Ada.Text_IO.Line_Length; Start_Col, Current_Col : Ada.Text_IO.Count; begin Ada.Text_IO.New_Page; -- clear screen Ada.Text_IO.Put ("push any key:"); Ada.Text_IO.Get_Immediate (C); Start_Col := Ada.Text_IO.Col; Current_Col := Start_Col; loop Ada.Text_IO.Get_Immediate (D, Avail); if Avail then exit when C = D; Current_Col := Ada.Text_IO.Col; else Ada.Text_IO.Put (C); Current_Col := Current_Col + 1; end if; if Current_Col = Line_Length then Ada.Text_IO.Set_Col (Start_Col); Current_Col := Start_Col; end if; end loop; Ada.Text_IO.New_Line; end tty_key;
AdaCore/libadalang
Ada
56
adb
-- This is src-p1/pkg.adb package body Pkg is end Pkg;
kevans91/synth
Ada
3,540
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Interfaces.C; with Interfaces.C_Streams; with Interfaces.C.Strings; with JohnnyText; package Unix is package JT renames JohnnyText; package IC renames Interfaces.C; package ICS renames Interfaces.C.Strings; package CSM renames Interfaces.C_Streams; type process_exit is (still_running, exited_normally, exited_with_error); type Int32 is private; subtype pid_t is Int32; -- check if process identified by pid has exited or keeps going function process_status (pid : pid_t) return process_exit; -- Kill everything with the identified process group procedure kill_process_tree (process_group : pid_t); -- Allows other packages to call external commands (e.g. Pilot) -- Returns "True" on success function external_command (command : String) return Boolean; -- wrapper for nonblocking spawn function launch_process (command : String) return pid_t; -- Returns True if pid is less than zero function fork_failed (pid : pid_t) return Boolean; -- Returns True if "variable" is defined in the environment. The -- value of variable is irrelevant function env_variable_defined (variable : String) return Boolean; -- Return value of "variable" defined in environment. If it's not -- defined than an empty string is returned; function env_variable_value (variable : String) return String; -- Execute popen and return stdout+stderr combined -- Also the result status is returned as an "out" variable function piped_command (command : String; status : out Integer) return JT.Text; -- Run external command that is expected to have no output to standard -- out, but catch stdout anyway. Don't return any output, but do return -- True of the command returns status of zero. function piped_mute_command (command : String; abnormal : out JT.Text) return Boolean; -- When the cone of silence is deployed, the terminal does not echo -- and Control-Q/S keystrokes are not captured (and vice-versa) procedure cone_of_silence (deploy : Boolean); -- Returns True if a TTY device is detected function screen_attached return Boolean; -- Equivalent of libc's realpath() function -- It resolves symlinks and relative directories to get the true path function true_path (provided_path : String) return String; private type uInt8 is mod 2 ** 16; type Int32 is range -(2 ** 31) .. +(2 ** 31) - 1; function popen (Command, Mode : IC.char_array) return CSM.FILEs; pragma Import (C, popen); function pclose (FileStream : CSM.FILEs) return CSM.int; pragma Import (C, pclose); function realpath (pathname, resolved_path : IC.char_array) return ICS.chars_ptr; pragma Import (C, realpath, "realpath"); function nohang_waitpid (pid : pid_t) return uInt8; pragma Import (C, nohang_waitpid, "__nohang_waitpid"); function silent_control return uInt8; pragma Import (C, silent_control, "__silent_control"); function chatty_control return uInt8; pragma Import (C, chatty_control, "__chatty_control"); function signal_runaway (pid : pid_t) return IC.int; pragma Import (C, signal_runaway, "__shut_it_down"); -- internal pipe close command function pipe_close (OpenFile : CSM.FILEs) return Integer; -- internal pipe read command function pipe_read (OpenFile : CSM.FILEs) return JT.Text; end Unix;
AdaDoom3/wayland_ada_binding
Ada
11,568
adb
package body Wayland_XML is procedure Set_Summary (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Summary := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Summary; procedure Set_Interface_Attribute (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Interface_Attribute := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Interface_Attribute; procedure Set_Type_Attribute (This : in out Arg_Tag; Value : String) is begin if Value = "int" then This.My_Type_Attribute := (Exists => True, Value => Type_Integer); elsif Value = "uint" then This.My_Type_Attribute := (Exists => True, Value => Type_Unsigned_Integer); elsif Value = "string" then This.My_Type_Attribute := (Exists => True, Value => Type_String); elsif Value = "fd" then This.My_Type_Attribute := (Exists => True, Value => Type_FD); elsif Value = "new_id" then This.My_Type_Attribute := (Exists => True, Value => Type_New_Id); elsif Value = "object" then This.My_Type_Attribute := (Exists => True, Value => Type_Object); elsif Value = "fixed" then This.My_Type_Attribute := (Exists => True, Value => Type_Fixed); elsif Value = "array" then This.My_Type_Attribute := (Exists => True, Value => Type_Array); else raise TYPE_ATTRIBUTE_EXCEPTION with Value; end if; end Set_Type_Attribute; procedure Set_Name (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Name := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Name; procedure Set_Allow_Null (This : in out Arg_Tag; Value : Boolean) is begin This.My_Allow_Null := (Exists => True, Value => Value); end Set_Allow_Null; procedure Set_Enum (This : in out Arg_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Enum := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Enum; procedure Set_Text (This : in out Copyright_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Text := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Text; procedure Set_Text (This : in out Description_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Text := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Text; procedure Set_Summary (This : in out Description_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Summary := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Summary; procedure Set_Value (This : in out Entry_Tag; Value : Entry_Value) is begin This.My_Value := (Exists => True, Value => Value); end Set_Value; procedure Set_Summary (This : in out Entry_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Summary := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Summary; procedure Set_Name (This : in out Entry_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Name := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Name; procedure Set_Since (This : in out Entry_Tag; Value : Version_Number) is begin This.My_Since := (Exists => True, Value => Value); end Set_Since; procedure Set_Name (This : in out Enum_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Name := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Name; procedure Set_Bitfield (This : in out Enum_Tag; Value : Boolean) is begin This.My_Bitfield := (Exists => True, Value => Value); end Set_Bitfield; procedure Set_Since (This : in out Enum_Tag; Value : Version_Number) is begin This.My_Since := (Exists => True, Value => Value); end Set_Since; procedure Append_Child (This : in out Enum_Tag; Item : not null Wayland_XML.Description_Tag_Ptr) is Child : Enum_Child := (Child_Description, Item); begin This.My_Children.Append (Child); end Append_Child; procedure Append_Child (This : in out Enum_Tag; Item : not null Entry_Tag_Ptr) is Child : Enum_Child := (Child_Entry, Item); begin This.My_Children.Append (Child); end Append_Child; procedure Set_Name (This : in out Event_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Name := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Name; procedure Set_Since_Attribute (This : in out Event_Tag; Value : Version_Number) is begin This.My_Since_Attribute := (Exists => True, Value => Value); end Set_Since_Attribute; procedure Append_Child (This : in out Event_Tag; Item : not null Wayland_XML.Description_Tag_Ptr) is C : Event_Child := (Child_Description, Item); begin This.My_Children.Append (C); end Append_Child; procedure Append_Child (This : in out Event_Tag; Item : not null Wayland_XML.Arg_Tag_Ptr) is C : Event_Child := (Child_Arg, Item); begin This.My_Children.Append (C); end Append_Child; procedure Set_Name (This : in out Request_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Name := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Name; procedure Append_Child (This : in out Request_Tag; Item : not null Description_Tag_Ptr) is C : Request_Child := (Child_Description, Item); begin This.My_Children.Append (C); end Append_Child; procedure Append_Child (This : in out Request_Tag; Item : not null Wayland_XML.Arg_Tag_Ptr) is C : Request_Child := (Child_Arg, Item); begin This.My_Children.Append (C); end Append_Child; procedure Set_Type_Attribute (This : in out Request_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Type_Attribute := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Type_Attribute; procedure Set_Since (This : in out Request_Tag; Value : Version_Number) is begin This.My_Since := (Exists => True, Value => Value); end Set_Since; function Exists_Description (This : Request_Tag) return Boolean is N : Aida.Nat32_T := 0; begin for Child of This.Children loop if Child.Kind_Id = Child_Description and then Child.Description_Tag.Exists_Text then N := N + 1; end if; end loop; return N = 1; end Exists_Description; function Description (This : Request_Tag) return String is C : Request_Child; begin for Child of This.Children loop if Child.Kind_Id = Child_Description then C := Child; exit; end if; end loop; return C.Description_Tag.Text; end Description; procedure Set_Name (This : in out Interface_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Name := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Name; procedure Set_Version (This : in out Interface_Tag; Value : Version_Number) is begin This.My_Version := (Exists => True, Value => Value); end Set_Version; procedure Append_Child (This : in out Interface_Tag; Item : not null Description_Tag_Ptr) is C : Interface_Child := (Child_Description, Item); begin This.My_Children.Append (C); end Append_Child; procedure Append_Child (This : in out Interface_Tag; Item : not null Request_Tag_Ptr) is C : Interface_Child := (Child_Request, Item); begin This.My_Children.Append (C); end Append_Child; procedure Append_Child (This : in out Interface_Tag; Item : not null Event_Tag_Ptr) is C : Interface_Child := (Child_Event, Item); begin This.My_Children.Append (C); end Append_Child; procedure Append_Child (This : in out Interface_Tag; Item : not null Enum_Tag_Ptr) is C : Interface_Child := (Child_Enum, Item); begin This.My_Children.Append (C); end Append_Child; procedure Set_Name (This : in out Protocol_Tag; Value : String; Subpool : Dynamic_Pools.Subpool_Handle) is begin This.My_Name := (Exists => True, Value => new (Subpool) String'(Value)); end Set_Name; procedure Append_Child (This : in out Protocol_Tag; Item : not null Wayland_XML.Copyright_Ptr) is C : Protocol_Child := (Kind_Id => Child_Copyright, Copyright_Tag => Item); begin This.My_Children.Append (C); end Append_Child; procedure Append_Child (This : in out Protocol_Tag; Item : not null Interface_Tag_Ptr) is C : Protocol_Child := (Kind_Id => Child_Interface, Interface_Tag => Item); begin This.My_Children.Append (C); end Append_Child; end Wayland_XML;
Componolit/libsparkcrypto
Ada
4,377
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- @author Alexander Senier -- @date 2019-01-21 -- -- Copyright (C) 2018 Componolit GmbH -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the nor the names of its contributors may be used -- to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.SHA256; with LSC.Internal.SHA512; with LSC.Internal.Convert_Hash; package body LSC.SHA2_Generic is ----------------- -- Hash_SHA256 -- ----------------- function Hash_SHA256 (Message : Message_Type) return Hash_Type is function Hash_Internal is new Internal.Convert_Hash.Hash (64, Message_Index_Type, Message_Elem_Type, Message_Type, Hash_Index_Type, Hash_Elem_Type, Hash_Type, Internal.SHA256.Context_Type, Internal.SHA256.Block_Type, Internal.SHA256.Block_Length_Type, Internal.SHA256.SHA256_Hash_Type, Internal.SHA256.SHA256_Context_Init, Internal.SHA256.Context_Update, Internal.SHA256.Context_Finalize, Internal.SHA256.SHA256_Get_Hash); begin return Hash_Internal (Message); end Hash_SHA256; ----------------- -- Hash_SHA384 -- ----------------- function Hash_SHA384 (Message : Message_Type) return Hash_Type is function Hash_Internal is new Internal.Convert_Hash.Hash (128, Message_Index_Type, Message_Elem_Type, Message_Type, Hash_Index_Type, Hash_Elem_Type, Hash_Type, Internal.SHA512.Context_Type, Internal.SHA512.Block_Type, Internal.SHA512.Block_Length_Type, Internal.SHA512.SHA384_Hash_Type, Internal.SHA512.SHA384_Context_Init, Internal.SHA512.Context_Update, Internal.SHA512.Context_Finalize, Internal.SHA512.SHA384_Get_Hash); begin return Hash_Internal (Message); end Hash_SHA384; ----------------- -- Hash_SHA512 -- ----------------- function Hash_SHA512 (Message : Message_Type) return Hash_Type is function Hash_Internal is new Internal.Convert_Hash.Hash (128, Message_Index_Type, Message_Elem_Type, Message_Type, Hash_Index_Type, Hash_Elem_Type, Hash_Type, Internal.SHA512.Context_Type, Internal.SHA512.Block_Type, Internal.SHA512.Block_Length_Type, Internal.SHA512.SHA512_Hash_Type, Internal.SHA512.SHA512_Context_Init, Internal.SHA512.Context_Update, Internal.SHA512.Context_Finalize, Internal.SHA512.SHA512_Get_Hash); begin return Hash_Internal (Message); end Hash_SHA512; end LSC.SHA2_Generic;
AdaCore/libadalang
Ada
216
adb
package body Bar is procedure Foo is type T is tagged null record; procedure Lol (X : T); --% node.p_subp_spec_or_null().p_primitive_subp_tagged_type() begin null; end Foo; end Bar;
sebsgit/textproc
Ada
3,838
adb
with AUnit.Assertions; use AUnit.Assertions; with Ada.Text_IO; with Tensor; with NN2; package body LayerModelTests is procedure Register_Tests (T: in out TestCase) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, testDense'Access, "Layer Model: Dense"); Register_Routine (T, testDenseDeep'Access, "Layer Model: Dense (multilayer)"); end Register_Tests; function Name(T: TestCase) return Test_String is begin return Format("Layer Model Tests"); end Name; procedure testDense(T : in out Test_Cases.Test_Case'Class) is model: NN2.Model := NN2.Create(input_size => 2); layer: constant NN2.Dense_Layer_Access := model.Add_Dense_Layer(neuron_count => 1); begin layer.weights.Set((1.0, 2.0)); layer.biases.Set((1 => 0.0)); Assert(NN2.Output_Size(layer.all) = 1, ""); declare fwd_data: constant Tensor.Var := Tensor.Variable(values => (4.0, 5.0)); fwd_result: constant Tensor.Var := NN2.Forward(layer.all, fwd_data); model_fwd: constant Tensor.Var := model.Forward(fwd_data); begin Assert(fwd_result.Dimension_Count = 1, ""); Assert(fwd_result.Dimension(1) = 1, ""); Assert(fwd_result.Element(1, 1) = 14.0, ""); Assert(model_fwd.Dimension_Count = 1, ""); Assert(model_fwd.Dimension(1) = 1, ""); Assert(model_fwd.Element(1, 1) = 14.0, ""); end; end testDense; procedure testDenseDeep(T : in out Test_Cases.Test_Case'Class) is model: NN2.Model := NN2.Create(input_size => 3); layer0: constant NN2.Dense_Layer_Access := model.Add_Dense_Layer(neuron_count => 2); layer1: constant NN2.Dense_Layer_Access := model.Add_Dense_Layer(neuron_count => 3); output_layer: constant NN2.Dense_Layer_Access := model.Add_Dense_Layer(neuron_count => 1); begin -- I0 - L1_0 - -- L0_0 - -- I1 - L1_1 - OUT -- L0_1 - -- I2 - L1_2 - Assert(NN2.Input_Size(layer0.all) = 3, ""); Assert(NN2.Input_Size(layer1.all) = 2, ""); Assert(NN2.Input_Size(output_layer.all) = 3, ""); Assert(NN2.Output_Size(layer0.all) = 2, ""); Assert(NN2.Output_Size(layer1.all) = 3, ""); Assert(NN2.Output_Size(output_layer.all) = 1, ""); layer0.weights.Set(values => (1.0, 2.0, 1.0, -1.0, -0.5, 2.0)); layer1.weights.Set(values => (0.5, 0.2, 0.7, 0.3, -0.1, 0.5)); output_layer.weights.Set(values => (0.3, 0.4, 0.3)); layer0.biases.Set((0.5, 0.7)); layer1.biases.Set((1.1, 2.1, 3.1)); output_layer.biases.Set((1 => -1.0)); declare input: constant Tensor.Var := Tensor.Variable(values => (10.0, 15.0, 20.0)); output: constant Tensor.Var := model.Forward(input); layer_0_res: constant Tensor.Float_Array := (1 => 1.0 * 10.0 + 2.0 * 15.0 + 1.0 * 20.0 + 0.5, 2 => -1.0 * 10.0 - 0.5 * 15.0 + 2.0 * 20.0 + 0.7); layer_1_res: constant Tensor.Float_Array := (1 => 0.5 * layer_0_res(1) + 0.2 * layer_0_res(2) + 1.1, 2 => 0.7 * layer_0_res(1) + 0.3 * layer_0_res(2) + 2.1, 3 => -0.1 * layer_0_res(1) + 0.5 * layer_0_res(2) + 3.1); expected_result: constant Float := 0.3 * layer_1_res(1) + 0.4 * layer_1_res(2) + 0.3 * layer_1_res(3) - 1.0; begin Assert(output.Element_Count = 1, ""); Assert(expected_result = output.Element(1, 1), "Expected: " & expected_result'Image & ", actual: " & Float(output.Element(1, 1))'Image); end; end testDenseDeep; end LayerModelTests;
micahwelf/FLTK-Ada
Ada
1,026
ads
package FLTK.Widgets.Groups.Tiled is type Tiled_Group is new Group with private; type Tiled_Group_Reference (Data : not null access Tiled_Group'Class) is limited null record with Implicit_Dereference => Data; package Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Tiled_Group; end Forge; procedure Position (This : in out Tiled_Group; Old_X, Old_Y : in Integer; New_X, New_Y : in Integer); procedure Draw (This : in out Tiled_Group); function Handle (This : in out Tiled_Group; Event : in Event_Kind) return Event_Outcome; private type Tiled_Group is new Group with null record; overriding procedure Finalize (This : in out Tiled_Group); pragma Inline (Position); pragma Inline (Draw); pragma Inline (Handle); end FLTK.Widgets.Groups.Tiled;
AaronC98/PlaneSystem
Ada
2,309
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2004-2012, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ package AWS.Client.XML is -- Root package for client HTTP XML support end AWS.Client.XML;