repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
AdaCore/gpr
Ada
6,671
adb
------------------------------------------------------------------------------ -- -- -- GPR2 PROJECT MANAGER -- -- -- -- Copyright (C) 2022-2023, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with GNAT; see file COPYING. If not, -- -- see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; with GNATCOLL.Traces; with GPR2.Containers; with GPR2.Options; with GPRtools; with GPRtools.Command_Line; with GPRtools.Util; with GPRtools.Options; with GPRinspect.Process; procedure GPRinspect.Main is use Ada; Options : GPRinspect.GPRinspect_Options; procedure On_Switch (Parser : GPRtools.Command_Line.Command_Line_Parser'Class; Res : not null access GPRtools.Command_Line.Command_Line_Result'Class; Arg : GPRtools.Command_Line.Switch_Type; Index : String; Param : String); procedure Parse_Command_Line; -- Parse command line parameters --------------- -- On_Switch -- --------------- procedure On_Switch (Parser : GPRtools.Command_Line.Command_Line_Parser'Class; Res : not null access GPRtools.Command_Line.Command_Line_Result'Class; Arg : GPRtools.Command_Line.Switch_Type; Index : String; Param : String) is pragma Unreferenced (Parser, Index); use type GPRtools.Command_Line.Switch_Type; Result : constant access GPRinspect_Options := GPRinspect_Options (Res.all)'Access; begin if Arg = "--display" then if Param = "json" then Result.Kind_Of_Display := GPRtools.K_JSON; elsif Param = "json-compact" then Result.Kind_Of_Display := GPRtools.K_JSON_Compact; elsif Param = "textual" then Result.Kind_Of_Display := GPRtools.K_Textual_IO; else raise GPR2.Options.Usage_Error with "use --display=<value> " & "with <value>=[json, json-compact, textual]"; end if; elsif Arg = "-r" then Result.All_Projects := True; elsif Arg = "--all" then Result.Display_Everything := True; elsif Arg = "--attributes" then Result.Display_Attributes := True; elsif Arg = "-c" then Result.Display_Config_Attributes := True; elsif Arg = "--packages" then Result.Display_Packages := True; elsif Arg = "--variables" then Result.Display_Variables := True; elsif Arg = "--views" then declare Scope : Restricted_Scope (Restrict => True); begin Scope.Views := GPR2.Containers.Create (GPR2.Name_Type (Param), Separator => ","); Result.All_Projects := True; Result.Restricted_Views := Scope; end; end if; end On_Switch; ------------------------ -- Parse_Command_Line -- ------------------------ procedure Parse_Command_Line is use GPRtools.Command_Line; use GPRtools.Options; Parser : GPRtools.Options.Command_Line_Parser := Create (Initial_Year => "2022", Allow_No_Project => False, Allow_Quiet => False); Group : constant GPRtools.Command_Line.Argument_Group := Parser.Add_Argument_Group ("gprinspect", On_Switch'Unrestricted_Access); begin Setup (Tool => GPRtools.Inspect); Parser.Add_Argument (Group, Create (Name => "--display", Help => "output formatting", Delimiter => Equal, Parameter => "json|json-compact|textual", Default => "textual")); Parser.Add_Argument (Group, Create (Name => "--views", Help => "Select the view to display. Only " & "available when using [--display=textual].", In_Switch_Attr => False, Delimiter => Equal, Parameter => "view1[,view2]", Default => "")); Parser.Add_Argument (Group, Create ("-r", "--recursive", Help => "All none external projects recursively")); Parser.Add_Argument (Group, Create ("--all", Help => "Display everything")); Parser.Add_Argument (Group, Create ("--attributes", Help => "Display attributes")); Parser.Add_Argument (Group, Create ("-c", "--from-config", Help => "Display attributes inherited from configuration")); Parser.Add_Argument (Group, Create ("--packages", Help => "Display packages")); Parser.Add_Argument (Group, Create ("--variables", Help => "Display variables & types")); Parser.Get_Opt (Options); end Parse_Command_Line; begin GNATCOLL.Traces.Parse_Config_File; -- Set program name GPRtools.Util.Set_Program_Name ("gprinspect"); -- Run the GPRinspect main procedure depending on command line options Parse_Command_Line; GPRinspect.Process (Options => Options); exception when E : GPR2.Options.Usage_Error => Text_IO.Put_Line (Text_IO.Standard_Error, "gprinspect: " & Exception_Message (E)); GPRtools.Command_Line.Try_Help; GPRtools.Util.Exit_Program (GPRtools.Util.E_Fatal); when E : others => GPRtools.Util.Fail_Program ("Fatal error: " & Exception_Information (E)); end GPRinspect.Main;
AdaCore/libadalang
Ada
1,842
adb
with Ada.Text_IO; use Ada.Text_IO; with Libadalang.Analysis; use Libadalang.Analysis; with Libadalang.Common; use Libadalang.Common; with Libadalang.Helpers; use Libadalang.Helpers; procedure Main is procedure Process_Unit (Context : App_Job_Context; Unit : Analysis_Unit); function Visit (Node : Ada_Node'Class) return Visit_Status; package App is new Libadalang.Helpers.App (Name => "example", Description => "Example app", Process_Unit => Process_Unit); ------------------ -- Process_Unit -- ------------------ procedure Process_Unit (Context : App_Job_Context; Unit : Analysis_Unit) is pragma Unreferenced (Context); begin Unit.Root.Traverse (Visit'Access); New_Line; end Process_Unit; ----------- -- Visit -- ----------- function Visit (Node : Ada_Node'Class) return Visit_Status is begin case Node.Kind is when Ada_Subp_Body | Ada_Subp_Body_Stub => declare N : constant Body_Node := Node.As_Body_Node; begin Put_Line ("== " & N.Image & " =="); New_Line; Put_Line ("Previous part: " & N.P_Previous_Part.Image); Put_Line ("Next part: " & N.P_Next_Part_For_Decl.Image); Put_Line ("Decl part: " & N.P_Decl_Part.Image); New_Line; end; when Ada_Subp_Decl => declare N : constant Subp_Decl := Node.As_Subp_Decl; begin Put_Line ("== " & N.Image & " =="); New_Line; Put_Line ("Body part: " & N.P_Body_Part.Image); New_Line; end; when others => null; end case; return Into; end Visit; begin App.Run; Put_Line ("Done"); end Main;
eqcola/ada-ado
Ada
10,781
adb
----------------------------------------------------------------------- -- ADO Sqlite Database -- SQLite Database connections -- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Sqlite3_H; with Interfaces.C.Strings; with Util.Log; with Util.Log.Loggers; with ADO.C; with ADO.Statements.Sqlite; with ADO.Schemas.Sqlite; package body ADO.Drivers.Connections.Sqlite is use ADO.Statements.Sqlite; use Interfaces.C; pragma Linker_Options ("-lsqlite3"); Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ADO.Databases.Sqlite"); Driver_Name : aliased constant String := "sqlite"; Driver : aliased Sqlite_Driver; No_Callback : constant Sqlite3_H.sqlite3_callback := null; -- ------------------------------ -- Get the database driver which manages this connection. -- ------------------------------ overriding function Get_Driver (Database : in Database_Connection) return Driver_Access is pragma Unreferenced (Database); begin return Driver'Access; end Get_Driver; -- ------------------------------ -- Check for an error after executing a sqlite statement. -- ------------------------------ procedure Check_Error (Connection : in Sqlite_Access; Result : in int) is begin if Result /= Sqlite3_H.SQLITE_OK and Result /= Sqlite3_H.SQLITE_DONE then declare Error : constant Strings.chars_ptr := Sqlite3_H.sqlite3_errmsg (Connection); Msg : constant String := Strings.Value (Error); begin Log.Error ("Error {0}: {1}", int'Image (Result), Msg); end; end if; end Check_Error; overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement_Access is begin return Create_Statement (Database => Database.Server, Table => Table); end Create_Statement; overriding function Create_Statement (Database : in Database_Connection; Query : in String) return Query_Statement_Access is begin return Create_Statement (Database => Database.Server, Query => Query); end Create_Statement; -- ------------------------------ -- Create a delete statement. -- ------------------------------ overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement_Access is begin return Create_Statement (Database => Database.Server, Table => Table); end Create_Statement; -- ------------------------------ -- Create an insert statement. -- ------------------------------ overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement_Access is begin return Create_Statement (Database => Database.Server, Table => Table); end Create_Statement; -- ------------------------------ -- Create an update statement. -- ------------------------------ overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement_Access is begin return Create_Statement (Database => Database.Server, Table => Table); end Create_Statement; -- ------------------------------ -- Start a transaction. -- ------------------------------ procedure Begin_Transaction (Database : in out Database_Connection) is begin -- Database.Execute ("begin transaction;"); null; end Begin_Transaction; -- ------------------------------ -- Commit the current transaction. -- ------------------------------ procedure Commit (Database : in out Database_Connection) is begin -- Database.Execute ("commit transaction;"); null; end Commit; -- ------------------------------ -- Rollback the current transaction. -- ------------------------------ procedure Rollback (Database : in out Database_Connection) is begin -- Database.Execute ("rollback transaction;"); null; end Rollback; procedure Sqlite3_Free (Arg1 : Strings.chars_ptr); pragma Import (C, sqlite3_free, "sqlite3_free"); procedure Execute (Database : in out Database_Connection; SQL : in Query_String) is use type Strings.chars_ptr; SQL_Stat : constant ADO.C.String_Ptr := ADO.C.To_String_Ptr (SQL); Result : int; Error_Msg : Strings.chars_ptr; begin Log.Debug ("Execute: {0}", SQL); for Retry in 1 .. 100 loop Result := Sqlite3_H.sqlite3_exec (Database.Server, ADO.C.To_C (SQL_Stat), No_Callback, System.Null_Address, Error_Msg'Address); exit when Result /= Sqlite3_H.SQLITE_BUSY; delay 0.01 * Retry; end loop; Check_Error (Database.Server, Result); if Error_Msg /= Strings.Null_Ptr then Log.Error ("Error: {0}", Strings.Value (Error_Msg)); Sqlite3_Free (Error_Msg); end if; -- Free -- Strings.Free (SQL_Stat); end Execute; -- ------------------------------ -- Closes the database connection -- ------------------------------ overriding procedure Close (Database : in out Database_Connection) is pragma Unreferenced (Database); Result : int; begin Log.Info ("Close connection"); -- if Database.Count = 1 then -- Result := Sqlite3_H.sqlite3_close (Database.Server); -- Database.Server := System.Null_Address; -- end if; pragma Unreferenced (Result); end Close; -- ------------------------------ -- Releases the sqlite connection if it is open -- ------------------------------ overriding procedure Finalize (Database : in out Database_Connection) is Result : int; begin Log.Debug ("Release connection"); Result := Sqlite3_H.sqlite3_close (Database.Server); Database.Server := System.Null_Address; pragma Unreferenced (Result); end Finalize; -- ------------------------------ -- Load the database schema definition for the current database. -- ------------------------------ overriding procedure Load_Schema (Database : in Database_Connection; Schema : out ADO.Schemas.Schema_Definition) is begin ADO.Schemas.Sqlite.Load_Schema (Database, Schema); end Load_Schema; DB : Ref.Ref; -- ------------------------------ -- Initialize the database connection manager. -- ------------------------------ procedure Create_Connection (D : in out Sqlite_Driver; Config : in Configuration'Class; Result : in out Ref.Ref'Class) is pragma Unreferenced (D); use Strings; use type System.Address; Name : constant String := To_String (Config.Database); Filename : Strings.chars_ptr; Status : int; Handle : aliased System.Address; Flags : constant int := Sqlite3_H.SQLITE_OPEN_FULLMUTEX + Sqlite3_H.SQLITE_OPEN_READWRITE; begin Log.Info ("Opening database {0}", Name); if not DB.Is_Null then Result := Ref.Create (DB.Value); return; end if; Filename := Strings.New_String (Name); Status := Sqlite3_H.sqlite3_open_v2 (Filename, Handle'Access, Flags, Strings.Null_Ptr); Strings.Free (Filename); if Status /= Sqlite3_H.SQLITE_OK then raise DB_Error; end if; declare Database : constant Database_Connection_Access := new Database_Connection; procedure Configure (Name : in String; Item : in Util.Properties.Value); function Escape (Value : in Util.Properties.Value) return String; function Escape (Value : in Util.Properties.Value) return String is S : constant String := Util.Properties.To_String (Value); begin if S'Length > 0 and then S (S'First) >= '0' and then S (S'First) <= '9' then return S; elsif S'Length > 0 and then S (S'First) = ''' then return S; else return "'" & S & "'"; end if; end Escape; procedure Configure (Name : in String; Item : in Util.Properties.Value) is SQL : constant String := "PRAGMA " & Name & "=" & Escape (Item); begin Log.Info ("Configure database with {0}", SQL); Database.Execute (SQL); end Configure; begin Database.Server := Handle; Database.Name := Config.Database; DB := Ref.Create (Database.all'Access); -- Configure the connection by setting up the SQLite 'pragma X=Y' SQL commands. -- Typical configuration includes: -- synchronous=OFF -- temp_store=MEMORY -- encoding='UTF-8' Config.Properties.Iterate (Process => Configure'Access); Result := Ref.Create (Database.all'Access); end; end Create_Connection; -- ------------------------------ -- Initialize the SQLite driver. -- ------------------------------ procedure Initialize is use type Util.Strings.Name_Access; begin Log.Debug ("Initializing sqlite driver"); if Driver.Name = null then Driver.Name := Driver_Name'Access; Register (Driver'Access); end if; end Initialize; end ADO.Drivers.Connections.Sqlite;
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.Text_Use_Index_Marks_Attributes is pragma Preelaborate; type ODF_Text_Use_Index_Marks_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Use_Index_Marks_Attribute_Access is access all ODF_Text_Use_Index_Marks_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Use_Index_Marks_Attributes;
reznikmm/matreshka
Ada
3,684
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.Anim_Name_Attributes is pragma Preelaborate; type ODF_Anim_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Anim_Name_Attribute_Access is access all ODF_Anim_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Anim_Name_Attributes;
AdaCore/training_material
Ada
3,751
adb
with System; use System; with System.Storage_Elements; with System.Address_To_Access_Conversions; with SDL_pixels_h; use SDL_pixels_h; package body Display.Basic.Utils is --------------- -- Put_Pixel -- --------------- package Address_To_Pixel is new System.Address_To_Access_Conversions (SDL_stdinc_h.Uint32); function RGBA_To_Uint32(Screen : access SDL_Surface; Color : RGBA_T) return Uint32 is begin return SDL_MapRGBA (Screen.format, unsigned_char (Color.R), unsigned_char (Color.G), unsigned_char (Color.B), unsigned_char (Color.A)); end RGBA_To_Uint32; procedure Put_Pixel_Slow (Screen : access SDL_Surface; X, Y : Integer; Color : RGBA_T) is begin -- Just ignore out of screen draws if X >= Integer(Screen.w) or else X < 0 or else Y >= Integer(Screen.h) or else Y < 0 then return; end if; declare use System.Storage_Elements; Offset : Storage_Offset := Storage_Offset ((Y * Integer (Screen.w) + X) * Integer (Screen.format.all.BytesPerPixel)); Pixels : System.Address := Screen.pixels + Offset; begin Address_To_Pixel.To_Pointer (Pixels).all := SDL_MapRGBA (Screen.format, unsigned_char (Color.R), unsigned_char (Color.G), unsigned_char (Color.B), unsigned_char (Color.A)); end; end Put_Pixel_Slow; procedure Put_Pixel (Screen : access SDL_Surface; X, Y : Integer; Color : Uint32) is begin -- Just ignore out of screen draws if X >= Integer(Screen.w) or else X < 0 or else Y >= Integer(Screen.h) or else Y < 0 then return; end if; declare use System.Storage_Elements; Offset : Storage_Offset := Storage_Offset ((Y * Integer (Screen.w) + X) * Integer (Screen.format.all.BytesPerPixel)); Pixels : System.Address := Screen.pixels + Offset; begin Address_To_Pixel.To_Pointer (Pixels).all := Color; end; end Put_Pixel; Nb_Canvas : Integer := 0; function Register_SDL_Surface(S : access SDL_Surface) return Canvas_ID is Current_Id : Canvas_ID; begin if Nb_Canvas = Internal_Canvas'Length then raise Too_Many_Canvas; end if; Current_Id := Canvas_ID(Integer(Internal_Canvas'First) + Nb_Canvas); Internal_Canvas(Current_Id) := T_Internal_Canvas'(Surface => S, Zoom_Factor => 1.0, Center => (0, 0)); Nb_Canvas := Nb_Canvas + 1; return Current_Id; end Register_SDL_Surface; procedure Update_SDL_Surface(Canvas : Canvas_ID; S : access SDL_Surface) is begin Internal_Canvas (Canvas).Surface := S; end Update_SDL_Surface; function Get_Internal_Canvas(Canvas : Canvas_ID) return T_Internal_Canvas is begin return Internal_Canvas (Canvas); end Get_Internal_Canvas; procedure Set_Center (Canvas : Canvas_ID; Center : Screen_Point) is begin Internal_Canvas(Canvas).Center := Center; end Set_Center; function Get_Center (Canvas : Canvas_ID) return Screen_Point is begin return Internal_Canvas(Canvas).Center; end Get_Center; procedure Set_Zoom_Factor (Canvas : Canvas_ID; ZF : Float) is begin Internal_Canvas(Canvas).Zoom_Factor := ZF; end Set_Zoom_Factor; end Display.Basic.Utils;
stcarrez/ada-awa
Ada
2,320
adb
----------------------------------------------------------------------- -- awa-storages -- Storage module -- Copyright (C) 2012, 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; package body AWA.Storages is -- ------------------------------ -- Get the path to get access to the file. -- ------------------------------ function Get_Path (File : in Storage_File) return String is begin return Ada.Strings.Unbounded.To_String (File.Path); end Get_Path; -- ------------------------------ -- Set the file path for the FILE, URL, CACHE or TMP storage. -- ------------------------------ procedure Set (File : in out Storage_File; Path : in String) is begin File.Path := Ada.Strings.Unbounded.To_Unbounded_String (Path); end Set; -- ------------------------------ -- Set the file database storage identifier. -- ------------------------------ procedure Set (File : in out Storage_File; Workspace : in ADO.Identifier; Store : in ADO.Identifier) is begin File.Workspace := Workspace; File.Store := Store; end Set; overriding procedure Finalize (File : in out Storage_File) is begin if File.Storage = TMP and then Ada.Strings.Unbounded.Length (File.Path) > 0 then declare Path : constant String := Ada.Strings.Unbounded.To_String (File.Path); begin if Ada.Directories.Exists (Path) then Ada.Directories.Delete_File (Path); end if; end; end if; end Finalize; end AWA.Storages;
reznikmm/matreshka
Ada
4,664
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Apply_Style_Name_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Apply_Style_Name_Attribute_Node is begin return Self : Style_Apply_Style_Name_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Apply_Style_Name_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Apply_Style_Name_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Apply_Style_Name_Attribute, Style_Apply_Style_Name_Attribute_Node'Tag); end Matreshka.ODF_Style.Apply_Style_Name_Attributes;
reznikmm/matreshka
Ada
3,599
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- 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.Nodes; package XML.DOM.Entities is pragma Preelaborate; type DOM_Entity is limited interface and XML.DOM.Nodes.DOM_Node; type DOM_Entity_Access is access all DOM_Entity'Class with Storage_Size => 0; end XML.DOM.Entities;
faelys/natools
Ada
6,448
ads
------------------------------------------------------------------------------ -- Copyright (c) 2016-2017, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Smaz_Implementations.Base_64_Tools provides types and primitives -- -- common to both base-64 and base-4096 variants of Smaz. -- ------------------------------------------------------------------------------ with Ada.Streams; package Natools.Smaz_Implementations.Base_64_Tools is pragma Pure; use type Ada.Streams.Stream_Element; type Base_64_Digit is range 0 .. 63; subtype Single_Byte_Padding is Base_64_Digit range 0 .. 15; -- Padding after a single-byte partial block subtype Double_Byte_Padding is Base_64_Digit range 0 .. 3; -- Padding after a double-byte partial block subtype Full_Block is String (1 .. 3); subtype Double_Byte is String (1 .. 2); subtype Full_Block_Image is Ada.Streams.Stream_Element_Array (1 .. 4); subtype Double_Byte_Image is Ada.Streams.Stream_Element_Array (1 .. 3); subtype Single_Byte_Image is Ada.Streams.Stream_Element_Array (1 .. 2); type Base_64_Array is array (Ada.Streams.Stream_Element_Offset range <>) of Base_64_Digit; subtype Base_64_Symbol is Ada.Streams.Stream_Element with Static_Predicate => Base_64_Symbol in Character'Pos ('A') .. Character'Pos ('Z') | Character'Pos ('a') .. Character'Pos ('z') | Character'Pos ('0') .. Character'Pos ('9') | Character'Pos ('+') | Character'Pos ('/'); function Image (Digit : in Base_64_Digit) return Ada.Streams.Stream_Element is (case Digit is when 0 .. 25 => Character'Pos ('A') + Ada.Streams.Stream_Element (Digit) - 0, when 26 .. 51 => Character'Pos ('a') + Ada.Streams.Stream_Element (Digit) - 26, when 52 .. 61 => Character'Pos ('0') + Ada.Streams.Stream_Element (Digit) - 52, when 62 => Character'Pos ('+'), when 63 => Character'Pos ('/')); -- Printable character representation of Digit function Value (Symbol : in Base_64_Symbol) return Base_64_Digit is (case Symbol is when Character'Pos ('A') .. Character'Pos ('Z') => Base_64_Digit (Symbol - Character'Pos ('A') + 0), when Character'Pos ('a') .. Character'Pos ('z') => Base_64_Digit (Symbol - Character'Pos ('a') + 26), when Character'Pos ('0') .. Character'Pos ('9') => Base_64_Digit (Symbol - Character'Pos ('0') + 52), when Character'Pos ('+') => 62, when Character'Pos ('/') => 63); -- Value represented by a symbol function Image_Length (Input_Length : in Natural) return Ada.Streams.Stream_Element_Count is (Ada.Streams.Stream_Element_Count (Input_Length + (Input_Length + 2) / 3)); -- Paddingless encoded length function Value_Length (Input_Length : in Ada.Streams.Stream_Element_Count) return Natural is (Natural (Input_Length) - (Natural (Input_Length) + 3) / 4); -- Original length of an encoded array procedure Encode (Input : in String; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset); -- Paddingless raw encoding of Input data procedure Decode (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out String); -- Paddingless raw decoding of Input data procedure Encode_Block (Input : in Full_Block; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset); procedure Encode_Double (Input : in Double_Byte; Padding : in Double_Byte_Padding; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset); procedure Encode_Single (Input : in Character; Padding : in Single_Byte_Padding; Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset); -- Encode a complete or partial block into Output at Offset procedure Decode_Block (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out Full_Block); procedure Decode_Double (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out Double_Byte; Padding : out Double_Byte_Padding); procedure Decode_Single (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out Character; Padding : out Single_Byte_Padding); procedure Next_Digit (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Digit : out Base_64_Digit); procedure Next_Digit_Or_End (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Digit : out Base_64_Digit; Finished : out Boolean); -- Look for the first valid symbol in Input from Offset, and decode it end Natools.Smaz_Implementations.Base_64_Tools;
twdroeger/ada-awa
Ada
11,617
ads
----------------------------------------------------------------------- -- awa-jobs-services -- Job services -- Copyright (C) 2012, 2014, 2015, 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.Beans.Basic; with Util.Beans.Objects; with Util.Beans.Objects.Maps; with Util.Refs; with ADO.Sessions; with ADO.Objects; with AWA.Events; with AWA.Jobs.Models; -- == Job Service == -- The `AWA.Jobs.Services` package defines the type abstractions and the -- core operation to define a job operation procedure, create and schedule -- a job and perform the job work when it is scheduled. -- -- @type Abstract_Job_Type -- -- @type package AWA.Jobs.Services is -- The job is closed. The status cannot be modified. Closed_Error : exception; -- The job is already scheduled. Schedule_Error : exception; -- The job had an execution error. Execute_Error : exception; -- The parameter value is invalid and cannot be set on the job instance. Invalid_Value : exception; -- Event posted when a job is created. package Job_Create_Event is new AWA.Events.Definition (Name => "job-create"); -- Get the job status. function Get_Job_Status (Id : in ADO.Identifier) return Models.Job_Status_Type; -- ------------------------------ -- Abstract_Job Type -- ------------------------------ -- The `Abstract_Job_Type` is an abstract tagged record which defines -- a job that can be scheduled and executed. This is the base type of -- any job implementation. It defines the `Execute` abstract procedure -- that must be implemented in concrete job types. -- It provides operation to setup and retrieve the job parameter. -- When the job `Execute` procedure is called, it allows to set the -- job execution status and result. type Abstract_Job_Type is abstract new Util.Refs.Ref_Entity and Util.Beans.Basic.Readonly_Bean with private; type Abstract_Job_Type_Access is access all Abstract_Job_Type'Class; type Work_Access is access procedure (Job : in out Abstract_Job_Type'Class); -- Execute the job. This operation must be implemented and should -- perform the work represented by the job. It should use the -- `Get_Parameter` function to retrieve the job parameter and it can -- use the `Set_Result` operation to save the result. procedure Execute (Job : in out Abstract_Job_Type) is abstract; -- Set the job parameter identified by the `Name` to the value -- given in `Value`. procedure Set_Parameter (Job : in out Abstract_Job_Type; Name : in String; Value : in String); -- Set the job parameter identified by the `Name` to the value -- given in `Value`. procedure Set_Parameter (Job : in out Abstract_Job_Type; Name : in String; Value : in Integer); -- Set the job parameter identified by the `Name` to the value -- given in `Value`. procedure Set_Parameter (Job : in out Abstract_Job_Type; Name : in String; Value : in ADO.Objects.Object_Ref'Class); -- Set the job parameter identified by the `Name` to the value -- given in `Value`. -- The value object can hold any kind of basic value type -- (integer, enum, date, strings). If the value represents -- a bean, the `Invalid_Value` exception is raised. procedure Set_Parameter (Job : in out Abstract_Job_Type; Name : in String; Value : in Util.Beans.Objects.Object); -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. overriding function Get_Value (Job : in Abstract_Job_Type; Name : in String) return Util.Beans.Objects.Object; -- Get the job parameter identified by the `Name` and convert -- the value into a string. function Get_Parameter (Job : in Abstract_Job_Type; Name : in String) return String; -- Get the job parameter identified by the `Name` and convert -- the value as an integer. If the parameter is not defined, -- return the default value passed in `Default`. function Get_Parameter (Job : in Abstract_Job_Type; Name : in String; Default : in Integer) return Integer; -- Get the job parameter identified by the `Name` and convert -- the value as a database identifier. If the parameter is not defined, -- return the `ADO.NO_IDENTIFIER`. function Get_Parameter (Job : in Abstract_Job_Type; Name : in String) return ADO.Identifier; -- Get the job parameter identified by the `Name` and return it as -- a typed object. function Get_Parameter (Job : in Abstract_Job_Type; Name : in String) return Util.Beans.Objects.Object; -- Get the job status. function Get_Status (Job : in Abstract_Job_Type) return Models.Job_Status_Type; -- Get the job identifier once the job was scheduled. -- The job identifier allows to retrieve the job and check its -- execution and completion status later on. function Get_Identifier (Job : in Abstract_Job_Type) return ADO.Identifier; -- Set the job status. When the job is terminated, it is closed -- and the job parameters or results cannot be changed. procedure Set_Status (Job : in out Abstract_Job_Type; Status : in AWA.Jobs.Models.Job_Status_Type); -- Set the job result identified by the `Name` to the value given -- in `Value`. The value object can hold any kind of basic value -- type (integer, enum, date, strings). If the value represents a bean, -- the `Invalid_Value` exception is raised. procedure Set_Result (Job : in out Abstract_Job_Type; Name : in String; Value : in Util.Beans.Objects.Object); -- Set the job result identified by the `Name` to the value given in `Value`. procedure Set_Result (Job : in out Abstract_Job_Type; Name : in String; Value : in String); -- Save the job information in the database. Use the database session -- defined by `DB` to save the job. procedure Save (Job : in out Abstract_Job_Type; DB : in out ADO.Sessions.Master_Session'Class); -- ------------------------------ -- Job Factory -- ------------------------------ -- The `Job_Factory` is the interface that allows to create a job -- instance in order to execute a scheduled job. The `Create` function -- is called to create a new job instance when the job is scheduled -- for execution. type Job_Factory is abstract tagged limited null record; type Job_Factory_Access is access all Job_Factory'Class; -- Create the job instance using the job factory. function Create (Factory : in Job_Factory) return Abstract_Job_Type_Access is abstract; -- Get the job factory name. function Get_Name (Factory : in Job_Factory'Class) return String; -- Schedule the job. procedure Schedule (Job : in out Abstract_Job_Type; Definition : in Job_Factory'Class); -- ------------------------------ -- Job Type -- ------------------------------ -- The `Job_Type` is a concrete job used by the `Work_Factory` to execute -- a simple `Work_Access` procedure. type Job_Type is new Abstract_Job_Type with private; overriding procedure Execute (Job : in out Job_Type); -- ------------------------------ -- Work Factory -- ------------------------------ -- The `Work_Factory` is a simplified `Job_Factory` that allows to register -- simple `Work_Access` procedures to execute the job. type Work_Factory (Work : Work_Access) is new Job_Factory with null record; -- Create the job instance to execute the associated `Work_Access` procedure. overriding function Create (Factory : in Work_Factory) return Abstract_Job_Type_Access; -- ------------------------------ -- Job Declaration -- ------------------------------ -- The `Definition` package must be instantiated with a given job type to -- register the new job definition. generic type T is new Abstract_Job_Type with private; package Definition is type Job_Type_Factory is new Job_Factory with null record; overriding function Create (Factory : in Job_Type_Factory) return Abstract_Job_Type_Access; -- The job factory. Factory : constant Job_Factory_Access; private Instance : aliased Job_Type_Factory; Factory : constant Job_Factory_Access := Instance'Access; end Definition; generic Work : in Work_Access; package Work_Definition is type S_Factory is new Work_Factory with null record; -- The job factory. Factory : constant Job_Factory_Access; private Instance : aliased S_Factory := S_Factory '(Work => Work); Factory : constant Job_Factory_Access := Instance'Access; end Work_Definition; type Job_Ref is private; -- Get the job parameter identified by the `Name` and return it as -- a typed object. Return the `Null_Object` if the job is empty -- or there is no such parameter. function Get_Parameter (Job : in Job_Ref; Name : in String) return Util.Beans.Objects.Object; -- Execute the job associated with the given event. procedure Execute (Event : in AWA.Events.Module_Event'Class; Result : in out Job_Ref); private -- Execute the job and save the job information in the database. procedure Execute (Job : in out Abstract_Job_Type'Class; DB : in out ADO.Sessions.Master_Session'Class); type Abstract_Job_Type is abstract new Util.Refs.Ref_Entity and Util.Beans.Basic.Readonly_Bean with record Job : AWA.Jobs.Models.Job_Ref; Props : Util.Beans.Objects.Maps.Map; Results : Util.Beans.Objects.Maps.Map; Props_Modified : Boolean := False; Results_Modified : Boolean := False; end record; -- ------------------------------ -- Job Type -- ------------------------------ -- The `Job_Type` is a concrete job used by the `Work_Factory` to execute -- a simple `Work_Access` procedure. type Job_Type is new Abstract_Job_Type with record Work : Work_Access; end record; package Job_Refs is new Util.Refs.Indefinite_References (Element_Type => Abstract_Job_Type'Class, Element_Access => Abstract_Job_Type_Access); type Job_Ref is new Job_Refs.Ref with null record; end AWA.Jobs.Services;
reznikmm/matreshka
Ada
4,001
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Style_Name_Attributes; package Matreshka.ODF_Text.Style_Name_Attributes is type Text_Style_Name_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Style_Name_Attributes.ODF_Text_Style_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Style_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Style_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Style_Name_Attributes;
onox/orka
Ada
1,221
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with AUnit.Test_Suites; with AUnit.Test_Fixtures; package Test_SIMD_AVX_Compare is function Suite return AUnit.Test_Suites.Access_Test_Suite; private type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; procedure Test_Equal (Object : in out Test); procedure Test_Not_Equal (Object : in out Test); procedure Test_Greater_Than (Object : in out Test); procedure Test_Less_Than (Object : in out Test); procedure Test_Nan (Object : in out Test); procedure Test_Not_Nan (Object : in out Test); end Test_SIMD_AVX_Compare;
charlie5/lace
Ada
1,523
adb
with lace.Environ, ada.Text_IO; procedure test_Environ_compression is use lace.Environ, ada.Text_IO; test_Error : exception; digits_Text : constant String := "0123456789"; begin put_Line ("Begin"); verify_Folder ("tmp"); goto_Folder ("tmp"); --- Compress single files. -- save (digits_Text, "digits.txt-original"); copy_File ("digits.txt-original", "digits.txt"); for Each in compress_Format loop compress ("digits.txt", Each); rid_File ("digits.txt"); decompress ("digits.txt" & format_Suffix (Each)); if load ("digits.txt") /= digits_Text then raise test_Error with "'" & load ("digits.txt") & "'"; end if; rid_File ("digits.txt" & format_Suffix (Each)); end loop; --- Compress directories. -- verify_Folder ("archive-original"); move_Files ("*", "archive-original"); copy_Folder ("archive-original", "archive"); for Each in folder_compress_Format loop compress ("archive", Each); rid_Folder ("archive"); decompress ("archive" & format_Suffix (Each)); if load ("archive/digits.txt") /= load ("archive-original/digits.txt") then raise test_Error with "'" & load ("archive/digits.txt") & "'"; end if; rid_File ("archive" & format_Suffix (Each)); end loop; --- Tidy up -- goto_Folder (".."); rid_Folder ("tmp"); put_Line ("Success"); end test_Environ_compression;
sparre-consafe/Black
Ada
9,098
adb
-- Black HTTP and Websocket library - License -- -- Copyright (c) 2014, AdaHeads K/S -- Copyright (c) 2016, JSA Research & Innovation -- Copyright (c) 2017, Consafe Logistics A/S -- -- Permission to use, copy, modify, and distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. with Ada.Unchecked_Conversion; package body Black.Streams.Memory is not overriding function Length (Stream : in Instance) return Ada.Streams.Stream_Element_Offset is use Ada.Streams; begin return Stream_Element_Offset (Stream.Data.Length) * Buffer_Type'Length - (Stream.Head - Buffer_Type'First) - (Buffer_Type'Last - Stream.Tail); end Length; not overriding function Length (Stream : in Instance) return Natural is (Natural (Ada.Streams.Stream_Element_Offset'(Stream.Length))); overriding procedure Read (Stream : in out Instance; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is use Ada.Streams; use type Ada.Containers.Count_Type; begin Last := Item'First - 1; loop exit when Stream.Data.Is_Empty; exit when Stream.Data.Length = 1 and then Stream.Head > Stream.Tail; exit when Last >= Item'Last; declare First_Element : Stream_Element_Array renames Stream.Data.First_Element; Remaining : Stream_Element_Array renames First_Element (Stream.Head .. (if Stream.Data.Length > 1 then First_Element'Last else Stream.Tail)); Target : Stream_Element_Array renames Item (Last + 1 .. Item'Last); Copy : constant Stream_Element_Offset := Stream_Element_Offset'Min (Remaining'Length, Target'Length); begin Target (Target'First .. Target'First + Copy - 1) := Remaining (Remaining'First .. Remaining'First + Copy - 1); Last := Last + Copy; Stream.Head := Stream.Head + Copy; if Stream.Head > Buffer_Type'Last then Stream.Data.Delete_First; Stream.Head := Buffer_Type'First; end if; end; end loop; if Stream.Data.Is_Empty then Stream.Head := Buffer_Type'First; Stream.Tail := Buffer_Type'Last; end if; end Read; not overriding procedure Read (Stream : in out Instance; Item : out String; Last : out Natural) is use Ada.Streams; Buffer : Stream_Element_Array (1 .. Item'Length); Read_Elements : Stream_Element_Offset; pragma Assert (Buffer'Size = Item'Size); pragma Assert (Buffer'Component_Size = Item'Component_Size); begin Stream.Read (Item => Buffer, Last => Read_Elements); declare subtype Stream_Index_Range is Stream_Element_Count range 1 .. Read_Elements; subtype String_Index_Range is Positive range 1 .. Natural (Read_Elements); subtype Fixed_Stream_Element_Buffer is Stream_Element_Array (Stream_Index_Range); subtype Fixed_Character_Buffer is String (String_Index_Range); function "+" is new Ada.Unchecked_Conversion (Source => Fixed_Stream_Element_Buffer, Target => Fixed_Character_Buffer); Stream_View : Fixed_Stream_Element_Buffer renames Buffer (Stream_Index_Range); String_View : Fixed_Character_Buffer renames Item (String_Index_Range); begin String_View := +Stream_View; Last := Item'First + String_View'Length - 1; end; end Read; not overriding procedure Read (Stream : in out Instance; Item : out Ada.Strings.Unbounded.Unbounded_String) is Buffer : String (1 .. Stream.Length); Last : Natural; begin Stream.Read (Item => Buffer, Last => Last); pragma Assert (Stream.Length = 0); pragma Assert (Last = Buffer'Last); Item := Ada.Strings.Unbounded.To_Unbounded_String (Buffer); end Read; overriding procedure Write (Stream : in out Instance; Item : in Ada.Streams.Stream_Element_Array) is use Ada.Streams; Next : Stream_Element_Offset := Item'First; begin loop exit when Next > Item'Last; if Stream.Tail = Buffer_Type'Last then declare Buffer : Buffer_Type; Elements_To_Copy : constant Stream_Element_Count := Stream_Element_Offset'Min (Buffer_Type'Length, Item'Last - Next + 1); Source : Stream_Element_Array renames Item (Next .. Next + Elements_To_Copy - 1); Target : Stream_Element_Array renames Buffer (Buffer'First .. Buffer'First + Elements_To_Copy - 1); begin Target := Source; Stream.Data.Append (Buffer); Stream.Tail := Target'Last; Next := Next + Elements_To_Copy; end; else declare Buffer : Buffer_Type := Stream.Data.Last_Element; Elements_To_Copy : constant Stream_Element_Count := Stream_Element_Offset'Min (Buffer_Type'Length - Stream.Tail, Item'Last - Next + 1); Source : Stream_Element_Array renames Item (Next .. Next + Elements_To_Copy - 1); Target : Stream_Element_Array renames Buffer (Stream.Tail + 1 .. Stream.Tail + 1 + Elements_To_Copy - 1); begin Target := Source; Stream.Data.Replace_Element (Position => Stream.Data.Last, New_Item => Buffer); Stream.Tail := Target'Last; Next := Next + Elements_To_Copy; end; end if; end loop; end Write; not overriding procedure Write (Stream : in out Instance; Item : in String) is use Ada.Strings.Unbounded; use Ada.Streams; pragma Assert (Stream_Element_Array'Component_Size = String'Component_Size, "Character size /= stream element size."); subtype String_Index_Range is Positive range 1 .. Item'Length; subtype Stream_Index_Range is Stream_Element_Count range 1 .. Item'Length; subtype Fixed_Character_Buffer is String (String_Index_Range); subtype Fixed_Stream_Element_Buffer is Stream_Element_Array (Stream_Index_Range); function "+" is new Ada.Unchecked_Conversion (Source => Fixed_Character_Buffer, Target => Fixed_Stream_Element_Buffer); As_Characters : Fixed_Character_Buffer renames Item; begin Stream.Write (Item => +As_Characters); end Write; not overriding procedure Write (Stream : in out Instance; Item : in Ada.Strings.Unbounded.Unbounded_String) is use Ada.Strings.Unbounded; use Ada.Streams; pragma Assert (Stream_Element_Array'Component_Size = String'Component_Size, "Character size /= stream element size."); subtype String_Index_Range is Positive range 1 .. Length (Item); subtype Stream_Index_Range is Stream_Element_Count range 1 .. Stream_Element_Offset (Length (Item)); subtype Fixed_Character_Buffer is String (String_Index_Range); subtype Fixed_Stream_Element_Buffer is Stream_Element_Array (Stream_Index_Range); function "+" is new Ada.Unchecked_Conversion (Source => Fixed_Character_Buffer, Target => Fixed_Stream_Element_Buffer); As_Characters : constant Fixed_Character_Buffer := To_String (Item); begin Stream.Write (Item => +As_Characters); end Write; end Black.Streams.Memory;
jwarwick/aoc_2020
Ada
1,528
adb
-- AoC 2020, Day 15 with Ada.Text_IO; with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Containers; use Ada.Containers; package body Day is package TIO renames Ada.Text_IO; function natural_hash(n : in Natural) return Hash_Type is begin return Hash_Type(n); end natural_hash; package Natural_Hashed_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => Natural, Element_Type => Natural, Hash => Natural_Hash, Equivalent_Keys => "="); use Natural_Hashed_Maps; last_age : Natural_Hashed_Maps.Map := Empty_Map; previous_age : Natural_Hashed_Maps.Map := Empty_Map; function sequence(s : in Input_Array; step : in Natural) return Natural is index : Natural := 1; last : Natural; prev : Natural; diff : Natural; begin clear(last_age); clear(previous_age); for e of s loop last_age.insert(e, index); last := e; index := index + 1; end loop; loop if not previous_age.contains(last) then diff := 0; else prev := previous_age(last); last := last_age(last); diff := last - prev; end if; if last_age.contains(diff) then previous_age.include(diff, last_age(diff)); end if; last_age.include(diff, index); last := diff; if index = step then return last; end if; if index mod 100_000 = 0 then TIO.put_line(Natural'Image(index)); end if; index := index + 1; end loop; end sequence; end Day;
annexi-strayline/AURA
Ada
4,466
adb
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Core -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Registrar.Registry; with Registrar.Source_Files.Allocation; procedure Registrar.Registration.Unchecked_Deregister_Unit (Unit: in out Registrar.Library_Units.Library_Unit) is use Library_Units; procedure Destroy_File (File: in out Source_Files.Source_File_Access) is use Source_Files; begin if File = null then return; end if; declare Ownership: Source_Stream := Checkout_Read_Stream (File); begin Source_Files.Allocation.Discard (File => File, Checkout => Ownership); end; end Destroy_File; begin -- We assume the precondition holds. We will operate on Unit as the -- authority. Registry.All_Library_Units.Delete_Element (Unit); Destroy_File (Unit.Spec_File); Destroy_File (Unit.Body_File); for SB of Unit.Subunit_Bodies loop Destroy_File (SB); end loop; end Registrar.Registration.Unchecked_Deregister_Unit;
onox/orka
Ada
1,493
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with AUnit.Test_Suites; with AUnit.Test_Fixtures; package Test_SIMD_AVX_Arithmetic is function Suite return AUnit.Test_Suites.Access_Test_Suite; private type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; procedure Test_Multiply (Object : in out Test); procedure Test_Divide (Object : in out Test); procedure Test_Divide_By_Zero (Object : in out Test); procedure Test_Divide_Or_Zero (Object : in out Test); procedure Test_Add (Object : in out Test); procedure Test_Subtract (Object : in out Test); procedure Test_Minus (Object : in out Test); procedure Test_Multiply_Vector (Object : in out Test); procedure Test_Multiply_Matrices (Object : in out Test); procedure Test_Abs (Object : in out Test); procedure Test_Sum (Object : in out Test); end Test_SIMD_AVX_Arithmetic;
stcarrez/ada-keystore
Ada
1,152
ads
----------------------------------------------------------------------- -- keystore-tools-tests -- Tests for keystore files -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Keystore.Tools.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test storing a directory tree procedure Test_Store_Directory (T : in out Test); end Keystore.Tools.Tests;
ytomino/gnat4drake
Ada
450
ads
pragma License (Unrestricted); with C.stdlib; package System.CRTL is pragma Preelaborate; subtype size_t is C.size_t; -- Other C runtime functions procedure free (Ptr : System.Address) renames C.stdlib.free; function malloc (Size : size_t) return System.Address renames C.stdlib.malloc; function realloc (Ptr : System.Address; Size : size_t) return System.Address renames C.stdlib.realloc; end System.CRTL;
stcarrez/ada-asf
Ada
3,700
ads
----------------------------------------------------------------------- -- asf-components -- Component tree -- Copyright (C) 2009, 2010, 2011, 2023 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. ----------------------------------------------------------------------- -- == Components == -- The `ASF.Components` describes the components that form the -- tree view. Each component has attributes and children. Children -- represent sub-components and attributes control the rendering and -- behavior of the component. -- -- The component tree is created from the `ASF.Views` tag nodes -- for each request. Unlike tag nodes, the component tree is not shared. -- with Ada.Strings.Unbounded; with EL.Objects; with EL.Expressions; limited with ASF.Views.Nodes; package ASF.Components is use Ada.Strings.Unbounded; -- Flag indicating whether or not this component should be rendered -- (during Render Response Phase), or processed on any subsequent form submit. -- The default value for this property is true. RENDERED_NAME : constant String := "rendered"; -- A localized user presentable name for the component. LABEL_NAME : constant String := "label"; -- Converter instance registered with the component. CONVERTER_NAME : constant String := "converter"; -- A ValueExpression enabled attribute that, if present, will be used as the text -- of the converter message, replacing any message that comes from the converter. CONVERTER_MESSAGE_NAME : constant String := "converterMessage"; -- A ValueExpression enabled attribute that, if present, will be used as the text -- of the validator message, replacing any message that comes from the validator. VALIDATOR_MESSAGE_NAME : constant String := "validatorMessage"; -- Flag indicating that the user is required to provide a submitted value for -- the input component. REQUIRED_NAME : constant String := "required"; -- A ValueExpression enabled attribute that, if present, will be used as the -- text of the validation message for the "required" facility, if the "required" -- facility is used. REQUIRED_MESSAGE_NAME : constant String := "requiredMessage"; -- A ValueExpression enabled attribute that, if present, will be used as the -- text of the expiration message when the form CSRF token has expired. EXPIRED_MESSAGE_NAME : constant String := "expiredMessage"; -- The current value of the component. VALUE_NAME : constant String := "value"; ACTION_NAME : constant String := "action"; -- ------------------------------ -- Attribute of a component -- ------------------------------ type UIAttribute is private; private type UIAttribute_Access is access all UIAttribute; type UIAttribute is record Definition : access ASF.Views.Nodes.Tag_Attribute; Name : Unbounded_String; Value : EL.Objects.Object; Expr : EL.Expressions.Expression; Next_Attr : UIAttribute_Access; end record; end ASF.Components;
AdaCore/Ada_Drivers_Library
Ada
3,522
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with HAL; use HAL; with HAL.Block_Drivers; use HAL.Block_Drivers; package Monitor.Block_Drivers is type Put_Line_Procedure is access procedure (Str : String); type Block_Driver_Monitor (Driver_Under_Monitoring : not null Any_Block_Driver; Put_Line : not null Put_Line_Procedure) is new Block_Driver with private; overriding function Read (This : in out Block_Driver_Monitor; Block_Number : UInt64; Data : out Block) return Boolean; overriding function Write (This : in out Block_Driver_Monitor; Block_Number : UInt64; Data : Block) return Boolean; procedure Enable (This : in out Block_Driver_Monitor); -- Enable monitor's output (default) procedure Disable (This : in out Block_Driver_Monitor); -- Disable monitor's output private type Block_Driver_Monitor (Driver_Under_Monitoring : not null Any_Block_Driver; Put_Line : not null Put_Line_Procedure) is new Block_Driver with record Enabled : Boolean := True; end record; end Monitor.Block_Drivers;
Heziode/lsystem-editor
Ada
2,114
adb
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]> -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- with LSE.Model.IO.Drawing_Area.PostScript; package body LSE.Model.IO.Drawing_Area_Factory is procedure Make (This : out LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr.Holder; Value : String; Path : String) is Unknown_Drawing_Area_Type : exception; Found : Boolean := False; begin case Available_Export'Value (Value) is when PS => Found := True; This := To_Holder (LSE.Model.IO.Drawing_Area.PostScript.Initialize (Path)); end case; if not Found then raise Unknown_Drawing_Area_Type; end if; end Make; end LSE.Model.IO.Drawing_Area_Factory;
AdaCore/Ada_Drivers_Library
Ada
5,017
adb
with Ada.Text_IO; use Ada.Text_IO; with Test_Directories; with File_Block_Drivers; use File_Block_Drivers; with File_IO; use File_IO; with Filesystem.FAT; use Filesystem.FAT; with HAL.Filesystem; use HAL.Filesystem; with Compare_Files; procedure TC_FAT_Read is function Check_Dir (Dirname : String) return Boolean; function Check_File (Basename : String; Dirname : String) return Boolean; function Check_Expected_Number return Boolean; Number_Of_Files_Checked : Natural := 0; --------------- -- Check_Dir -- --------------- function Check_Dir (Dirname : String) return Boolean is DD : Directory_Descriptor; Status : File_IO.Status_Code; begin Put_Line ("Checking directory: '" & Dirname & "'"); Status := Open (DD, Dirname); if Status /= OK then Put_Line ("Cannot open directory: '" & Dirname & "'"); Put_Line ("Status: " & Status'Img); return False; end if; loop declare Ent : constant Directory_Entry := Read (DD); begin if Ent /= Invalid_Dir_Entry then if Ent.Name = "." or else Ent.Name = ".." then null; -- do nothing elsif Ent.Subdirectory then if not Check_Dir (Dirname & "/" & Ent.Name) then return False; end if; elsif not Ent.Symlink then if not Check_File (Ent.Name, Dirname) then return False; end if; end if; else exit; end if; end; end loop; return True; end Check_Dir; ---------------- -- Check_File -- ---------------- function Check_File (Basename : String; Dirname : String) return Boolean is FD : File_Descriptor; Status : File_IO.Status_Code; Path : constant String := Dirname & "/" & Basename; begin Status := Open (FD, Path, Read_Only); if Status /= OK then Put_Line ("Cannot open file: '" & Path & "'"); Put_Line ("Status: " & Status'Img); return False; end if; declare Hash_Str : constant String := Compare_Files.Compute_Hash (FD); begin if Hash_Str /= Basename then Put_Line ("Error: Hash is different than filename"); return False; else Number_Of_Files_Checked := Number_Of_Files_Checked + 1; return True; end if; end; end Check_File; --------------------------- -- Check_Expected_Number -- --------------------------- function Check_Expected_Number return Boolean is FD : File_Descriptor; Status : File_IO.Status_Code; Path : constant String := "/disk_img/number_of_files_to_check"; C : Character; Amount : File_IO.File_Size; begin Status := Open (FD, Path, Read_Only); if Status /= OK then Put_Line ("Cannot open file: '" & Path & "'"); Put_Line ("Status: " & Status'Img); return False; end if; Amount := 1; if Read (FD, C'Address, Amount) /= Amount then Put_Line ("Cannot read file: '" & Path & "'"); Put_Line ("Status: " & Status'Img); return False; end if; if C in '0' .. '9' and then Number_Of_Files_Checked = (Character'Pos (C) - Character'Pos ('0')) then return True; else Put_Line ("Incorrect number of files"); return False; end if; end Check_Expected_Number; Disk_Img_Path : constant String := "/test_dir/fat.fs"; Disk : aliased File_Block_Driver; FAT_FS : FAT_Filesystem_Access; FIO_Status : File_IO.Status_Code; HALFS_Status : HAL.Filesystem.Status_Code; begin Test_Directories.Mount_Test_Directory ("test_dir"); FIO_Status := Disk.Open (Disk_Img_Path, Read_Only); if FIO_Status /= OK then Put_Line ("Cannot open disk image '" & Disk_Img_Path & "': " & FIO_Status'Img); return; end if; FAT_FS := new FAT_Filesystem; HALFS_Status := Open (Controller => Disk'Unchecked_Access, LBA => 0, FS => FAT_FS.all); if HALFS_Status /= OK then Put_Line ("Cannot open FAT FS - Status:" & HALFS_Status'Img); return; end if; FIO_Status := File_IO.Mount_Volume (Mount_Point => "disk_img", FS => Any_Filesystem_Driver (FAT_FS)); if FIO_Status /= OK then Put_Line ("Cannot mount volume - Status: " & FIO_Status'Img); return; end if; if Check_Dir ("/disk_img/read_test") and then Check_Expected_Number then Put_Line ("PASS"); else Put_Line ("FAIL"); end if; end TC_FAT_Read;
damaki/libkeccak
Ada
6,528
ads
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Ada.Containers.Doubly_Linked_Lists; with Ada.Containers.Indefinite_Doubly_Linked_Lists; with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Containers.Hashed_Maps; with Ada.Finalization; use Ada.Finalization; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Unbounded.Hash; with Keccak.Types; package Test_Vectors is type Byte_Array_Access is access Keccak.Types.Byte_Array; type Value_Type is (String_Type, Integer_Type, Hex_Array_Type); type Value_Choice (VType : Value_Type) is new Ada.Finalization.Controlled with record case VType is when String_Type => Str : Unbounded_String; when Integer_Type => Int : Integer; when Hex_Array_Type => Hex : Byte_Array_Access; end case; end record; overriding procedure Initialize (Object : in out Value_Choice); overriding procedure Adjust (Object : in out Value_Choice); overriding procedure Finalize (Object : in out Value_Choice); package Value_Choice_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (Element_Type => Value_Choice, "=" => "="); type Schema_Entry is record VType : Value_Type := Integer_Type; Required : Boolean := True; Is_List : Boolean := False; end record; package Schema_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String, Element_Type => Schema_Entry, Hash => Ada.Strings.Unbounded.Hash, Equivalent_Keys => "=", "=" => "="); -- Maps test vector keys to their required types. package Test_Vector_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => Unbounded_String, Element_Type => Value_Choice_Lists.List, Hash => Ada.Strings.Unbounded.Hash, Equivalent_Keys => "=", "=" => Value_Choice_Lists."="); -- Stores all information relating to a single test vector. -- For example, the line: MD = 00112233 from the test vector file -- will be stored in the map with the key "MD" and the value "00112233" -- as a byte array or string (depending on the schema). package Lists is new Ada.Containers.Doubly_Linked_Lists (Element_Type => Test_Vector_Maps.Map, "=" => Test_Vector_Maps."="); -- A list of test vectors. function Hex_String_To_Byte_Array (Str : in String) return Byte_Array_Access; -- Convert a string of hex characters to a byte array. -- -- E.g. a string "01afBC" is converted to the array (16#01#, 16#AF#, 16#BC#) function String_To_Byte_Array (Str : in String) return Byte_Array_Access; -- Convert a string to its byte array representation. -- -- This is just a conversion of each Character to its Byte representation. function Byte_Array_To_String (Data : in Keccak.Types.Byte_Array) return String; -- Convert a byte array to a hex string representation. procedure Load (File_Name : in String; Schema : in Schema_Maps.Map; Vectors_List : out Lists.List); -- Load test vectors from a file. -- -- A test vector is in the form: Key = Value where the Value may optionally -- have quotes " around it. -- -- For example: -- Len = 17 -- Msg = 4FF400 -- MD = 94D5B162A324674454BBADB377375DA15C3BE74225D346010AE557A9 -- -- Test vectors should be separated by a blank line, but is not mandatory -- provided that each test vector has the same keys. -- -- Comments appear on their own line and start with the '#' character. -- -- The schema defines which Keys are expected, the required type of the -- corresponding Value. Schema_Error : exception; private procedure Parse_Line (Test_Vector : in out Test_Vector_Maps.Map; Vectors_List : in out Lists.List; Schema : in Schema_Maps.Map; Line : in String); procedure Add_Test_Vector_Key_Value_Pair (Test_Vector : in out Test_Vector_Maps.Map; Vectors_List : in out Lists.List; Schema : in Schema_Maps.Map; Key : in Unbounded_String; Value : in Unbounded_String); procedure Append_Test_Vector (Test_Vector : in out Test_Vector_Maps.Map; Vectors_List : in out Lists.List; Schema : in Schema_Maps.Map); end Test_Vectors;
reznikmm/matreshka
Ada
4,019
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Style_Leader_Type_Attributes; package Matreshka.ODF_Style.Leader_Type_Attributes is type Style_Leader_Type_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Leader_Type_Attributes.ODF_Style_Leader_Type_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Leader_Type_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Leader_Type_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Leader_Type_Attributes;
AdaCore/training_material
Ada
808
ads
with Screen_Interface; use Screen_Interface; package Fonts is type BMP_Font is (Font8x8, Font12x12, Font16x24); procedure Draw_Char (X, Y : Integer; Char : Character; Font : BMP_Font; FG, BG : Color); procedure Draw_Char (X, Y : Integer; Char : Character; Font : BMP_Font; FG : Color); procedure Draw_String (X, Y : Integer; Str : String; Font : BMP_Font; FG, BG : Color; Wrap : Boolean := False); procedure Draw_String (X, Y : Integer; Str : String; Font : BMP_Font; FG : Color; Wrap : Boolean := False); function Char_Size (Font : BMP_Font) return Point; function String_Size (Font : BMP_Font; Text : String) return Point; end Fonts;
reznikmm/matreshka
Ada
3,630
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.Send_Object_Actions.Hash is new AMF.Elements.Generic_Hash (UML_Send_Object_Action, UML_Send_Object_Action_Access);
adamnemecek/GA_Ada
Ada
7,217
adb
with Interfaces; with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; with GL; with GL.Window; with Utilities; with Blade; with E3GA_Utilities; with GA_Maths; with GA_Utilities; package body GL_Util is use GL.Types; procedure Pick_Matrix (Centre_X, Centre_Y : GL.Types.Size; Width, Height : GL.Types.Size); -- ------------------------------------------------------------------ procedure GL_Color_3fm (R, G, B : GL.Types.Single) is A : constant GL.Types.Single := 0.3; D : constant GL.Types.Single := 0.7; Ambient : constant array (1 .. 4) of GL.Types.Single := (A * R, A * G, A * B, 1.0); Dif : constant array (1 .. 4) of GL.Types.Single := (D * R, D * G, D * B, 1.0); begin null; end GL_Color_3fm; -- ------------------------------------------------------------------ -- Load_Pick_Matrix procedure Load_Pick_Matrix is begin null; end Load_Pick_Matrix; -- ------------------------------------------------------------------ -- Rotor_GL_Multiply multiplies GL_Matrix by rotor 'R' procedure Rotor_GL_Multiply (R : Multivector.Rotor; GL_Matrix : in out GL.Types.Singles.Matrix4) is use E3GA; use Multivector; use GL; use GL.Types.Singles; IR : constant Rotor := General_Inverse (R); E_Rot : Vector; Image : Vector3_Array (1 .. 4); VC : Vector3; Matrix : Matrix4 := Identity4; Image_Row : Int := 0; begin -- compute the images of all OpenGL basis vectors E_Rot := Geometric_Product (R, Geometric_Product (e1, IR)); Image (1) := To_GL (E_Rot); E_Rot := Geometric_Product (R, Geometric_Product (e2, IR)); Image (2) := To_GL (E_Rot); E_Rot := Geometric_Product (R, Geometric_Product (e3, IR)); Image (3) := To_GL (E_Rot); Image (4) := (0.0, 0.0, 0.0); -- Image of origin -- Transfer the coordinates to the OpenGL matrix for row in GL.Index_Homogeneous loop Image_Row := Image_Row + 1; VC := Image (Image_Row); Matrix (row, X) := VC (X); Matrix (row, Y) := VC (Y); Matrix (row, Z) := VC (Z); end loop; GL_Matrix := Matrix * GL_Matrix; exception when anError : others => Put_Line ("An exception occurred in GL_Util.Rotor_GL_Multiply."); raise; end Rotor_GL_Multiply; -- ------------------------------------------------------------------------- -- Pick_Matrix defines a picking region procedure Pick_Matrix (Centre_X, Centre_Y : GL.Types.Size; Width, Height : GL.Types.Size) is begin GL.Window.Set_Viewport (Centre_X, Centre_Y, Width, Height); end Pick_Matrix; -- ------------------------------------------------------------------ function Rotor_To_GL_Matrix (R : Multivector.Rotor) return GL.Types.Singles.Matrix4 is use GL; M3 : GA_Maths.GA_Matrix3; GL_Matrix : GL.Types.Singles.Matrix4 := GL.Types.Singles.Identity4; Mrow : integer := 0; Mcol : integer := 0; begin E3GA_Utilities.Rotor_To_Matrix (R, M3); for row in Index_Homogeneous range X .. Z loop Mrow := Mrow + 1; for col in Index_Homogeneous range X .. Z loop Mcol := Mcol + 1; GL_Matrix (col, row) := GL.Types.Single (M3 (Mrow, Mcol)); end loop; Mcol := 0; end loop; return GL_Matrix; exception when anError : others => Put_Line ("An exception occurred in GL_Util.Rotor_To_GL_Matrix."); raise; end Rotor_To_GL_Matrix; -- ------------------------------------------------------------------------- function To_GL (V3 : Multivector.Vector) return GL.Types.Doubles.Vector3 is use Interfaces; use GL.Types; use Multivector.Blade_List_Package; use Blade; use GA_Maths; Blades : Multivector.Blade_List := Multivector.Get_Blade_List (V3); Curs : Cursor := Blades.First; BM : Unsigned_32; Value : Double; Val_X : Double := 0.0; Val_Y : Double := 0.0; Val_Z : Double := 0.0; begin while Has_Element (Curs) loop BM := Unsigned_32 (Bitmap (Element (Curs))); Value := Double (Blade.Weight (Element (Curs))); if (BM and E3_Base'Enum_Rep (E3_e1)) /= 0 then Val_X := Val_X + Value; end if; if (BM and E3_Base'Enum_Rep (E3_e2)) /= 0 then Val_Y:= Val_Y + Value; end if; if (BM and E3_Base'Enum_Rep (E3_e3)) /= 0 then Val_Z := Val_Z + Value; end if; Next (Curs); end loop; return (Val_X, Val_Y, Val_Z); end To_GL; -- ------------------------------------------------------------------------- function To_GL (V3 : Multivector.Vector) return GL.Types.Singles.Vector3 is use Interfaces; use GL.Types; use Multivector.Blade_List_Package; use Blade; Blades : Multivector.Blade_List := Multivector.Get_Blade_List (V3); Curs : Cursor := Blades.First; BM : Unsigned_32; Value : Single; Val_X : Single := 0.0; Val_Y : Single := 0.0; Val_Z : Single := 0.0; begin while Has_Element (Curs) loop BM := Unsigned_32 (Bitmap (Element (Curs))); Value := Single (Blade.Weight (Element (Curs))); if (BM and E3_Base'Enum_Rep (E3_e1)) /= 0 then Val_X := Val_X + Value; end if; if (BM and E3_Base'Enum_Rep (E3_e2)) /= 0 then Val_Y:= Val_Y + Value; end if; if (BM and E3_Base'Enum_Rep (E3_e3)) /= 0 then Val_Z := Val_Z + Value; end if; Next (Curs); end loop; return (Val_X, Val_Y, Val_Z); end To_GL; -- ------------------------------------------------------------------------- procedure Viewport_Coordinates (Pt_World : GA_Maths.Array_3D; Model_View_Matrix, Projection_Matrix : GL.Types.Singles.Matrix4; Coords : out GL.Types.Singles.Vector2) is use GL; use GL.Types; use GL.Types.Singles; VP_X : Int; VP_Y : Int; Window_Width : Size; Window_Height : Size; PT1 : Vector4 := (Single (Pt_World (1)), Single (Pt_World (2)), Single (Pt_World (3)), 1.0); PT2 : Vector4 := Projection_Matrix * Model_View_Matrix * PT1; begin -- PT1 := Projection_Matrix * PT2; GL.Window.Get_Viewport (VP_X, VP_Y, Window_Width, Window_Height); Coords (X) := Single (VP_X) + (1.0 + PT2 (X) / PT2 (W)) * Single (Window_Width) / 2.0; Coords (Y) := Single (VP_Y) + (1.0 + PT2 (Y) / PT2 (W)) * Single (Window_Height) / 2.0; exception when anError : others => Put_Line ("An exception occurred in GL_Util.Viewport_Coordinates."); raise; end Viewport_Coordinates; -- ------------------------------------------------------------------------- end GL_Util;
AdaCore/training_material
Ada
2,444
adb
with Ada.Text_IO; use Ada.Text_IO; package body Input is function Get_String (Prompt : String) return String is Str : String (1 .. 100); Last : Integer; begin Put (Prompt & " > "); Ada.Text_IO.Get_Line (Str, Last); return Str (1 .. Last); end Get_String; function Get_Number (Prompt : String) return Integer_T is begin loop declare Retval : constant String := Get_String (Prompt); begin if Retval'length > 0 then return Integer_T'value (Retval); else raise Input_Canceled; end if; exception when others => Put_Line ("Invalid input"); end; end loop; end Get_Number; function Get_Float (Prompt : String) return Float_T is begin loop declare Retval : constant String := Get_String (Prompt); begin if Retval'length > 0 then return Float_T'value (Retval); else raise Input_Canceled; end if; exception when others => Put_Line ("Invalid input"); end; end loop; end Get_Float; function Get_Enum (Prompt : String) return Enum_T is begin for E in Enum_T'range loop Put_Line (Integer'image (1 + Enum_T'pos (E)) & "> " & Enum_T'image (E)); end loop; loop declare I : constant String := Get_String (Prompt); begin if I'length = 0 then raise Input_Canceled; end if; return Enum_T'val (Natural'value (I) - 1); exception when Input_Canceled => raise Input_Canceled; when others => Put_Line ("Illegal value"); end; end loop; end Get_Enum; function Internal_Get_Integer is new Get_Number (Integer); function Internal_Get_Natural is new Get_Number (Natural); function Internal_Get_Positive is new Get_Number (Positive); function Get_Integer (Prompt : String) return Integer renames Internal_Get_Integer; function Get_Natural (Prompt : String) return Natural renames Internal_Get_Natural; function Get_Positive (Prompt : String) return Positive renames Internal_Get_Positive; end Input;
reznikmm/matreshka
Ada
3,841
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.Constants; package body Matreshka.ODF_Attributes.Style.Font_Independent_Line_Spacing is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Font_Independent_Line_Spacing_Node) return League.Strings.Universal_String is begin return ODF.Constants.Font_Independent_Line_Spacing_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Font_Independent_Line_Spacing;
charlie5/cBound
Ada
1,505
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_raw_generic_event_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; pad : aliased swig.uint32_t_Array (0 .. 6); end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_raw_generic_event_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_raw_generic_event_t.Item, Element_Array => xcb.xcb_raw_generic_event_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_raw_generic_event_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_raw_generic_event_t.Pointer, Element_Array => xcb.xcb_raw_generic_event_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_raw_generic_event_t;
riccardo-bernardini/eugen
Ada
996
ads
with EU_Projects.Projects; with Ada.Strings.Bounded; with Plugins; package Project_Processor.Processors is package Processor_Names is new Ada.Strings.Bounded.Generic_Bounded_Length (16); subtype Processor_Parameter is Plugins.Parameter_Map; subtype Processor_Parameter_Access is Plugins.Parameter_Map_Access; type Processor_ID is new Processor_Names.Bounded_String; function To_Id (X : String) return Processor_ID is (Processor_ID (Processor_Names.To_Bounded_String (X))); function Image (X : Processor_ID) return String is (Processor_Names.To_String (Processor_Names.Bounded_String(X))); type Abstract_Processor is interface; function Create (Params : not null access Processor_Parameter) return Abstract_Processor is abstract; procedure Process (Processor : Abstract_Processor; Input : EU_Projects.Projects.Project_Descriptor) is abstract; Processor_Error : exception; end Project_Processor.Processors;
charlie5/lace
Ada
5,879
adb
with openGL.Buffer.general, openGL.Shader, openGL.Program, openGL.Palette, openGL.Attribute, openGL.Texture, openGL.Tasks, openGL.Errors, GL.Binding, GL.lean, GL.Pointers, System, Interfaces.C.Strings, System.storage_Elements; package body openGL.Geometry.textured is use GL.lean, GL.Pointers, Interfaces, System; ----------- -- Globals -- vertex_Shader : aliased Shader.item; fragment_Shader : aliased Shader.item; the_Program : openGL.Program.view; white_Texture : openGL.Texture.Object; Name_1 : constant String := "Site"; Name_2 : constant String := "Coords"; Attribute_1_Name : aliased C.char_array := C.to_C (Name_1); Attribute_2_Name : aliased C.char_array := C.to_C (Name_2); Attribute_1_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (Attribute_1_Name'Access); Attribute_2_Name_ptr : aliased constant C.strings.chars_ptr := C.strings.to_chars_ptr (Attribute_2_Name'Access); --------- -- Forge -- function new_Geometry return View is use type openGL.Program.view; Self : constant View := new Geometry.textured.item; begin Tasks.check; if the_Program = null then -- Define the shaders and program. declare use Palette, Attribute.Forge, system.Storage_Elements; Sample : Vertex; Attribute_1 : Attribute.view; Attribute_2 : Attribute.view; white_Image : constant openGL.Image := [1 .. 2 => [1 .. 2 => +White]]; begin white_Texture := openGL.Texture.Forge.to_Texture (white_Image); vertex_Shader .define (openGL.Shader.vertex, "assets/opengl/shader/textured.vert"); fragment_Shader.define (openGL.Shader.fragment, "assets/opengl/shader/textured.frag"); the_Program := new openGL.Program.item; the_Program.define ( vertex_Shader'Access, fragment_Shader'Access); the_Program.enable; Attribute_1 := new_Attribute (Name => Name_1, gl_Location => the_Program.attribute_Location (Name_1), Size => 3, data_Kind => Attribute.GL_FLOAT, Stride => textured.Vertex'Size / 8, Offset => 0, Normalized => False); Attribute_2 := new_Attribute (Name => Name_2, gl_Location => the_Program.attribute_Location (Name_2), Size => 2, data_Kind => attribute.GL_FLOAT, Stride => textured.Vertex'Size / 8, Offset => Sample.Coords.S'Address - Sample.Site (1)'Address, Normalized => False); the_Program.add (Attribute_1); the_Program.add (Attribute_2); glBindAttribLocation (program => the_Program.gl_Program, index => the_Program.Attribute (named => Name_1).gl_Location, name => +Attribute_1_Name_ptr); glBindAttribLocation (program => the_Program.gl_Program, index => the_Program.Attribute (named => Name_2).gl_Location, name => +Attribute_2_Name_ptr); end; end if; Self.Program_is (the_Program.all'Access); return Self; end new_Geometry; -------------- -- Attributes -- overriding function is_Transparent (Self : in Item) return Boolean is begin return Self.is_Transparent; end is_Transparent; package openGL_Buffer_of_geometry_Vertices is new Buffer.general (base_Object => Buffer.array_Object, Index => Index_t, Element => Vertex, Element_Array => Vertex_array); procedure Vertices_are (Self : in out Item; Now : in Vertex_array) is use openGL_Buffer_of_geometry_Vertices.Forge; begin Self.Vertices := new openGL_Buffer_of_geometry_Vertices.Object' (to_Buffer (Now, usage => Buffer.static_Draw)); -- Set the bounds. -- declare function get_Site (Index : in Index_t) return Vector_3 is (Now (Index).Site); function bounding_Box is new get_Bounds (Index_t, get_Site); begin Self.Bounds_are (bounding_Box (Count => Now'Length)); end; end Vertices_are; overriding procedure Indices_are (Self : in out Item; Now : in Indices; for_Facia : in Positive) is begin raise Error with "opengl gemoetry textured - 'Indices_are' ~ TODO"; end Indices_are; overriding procedure enable_Texture (Self : in Item) is use GL, GL.Binding, openGL.Texture; begin Tasks.check; glActiveTexture (gl.GL_TEXTURE0); Errors.log; if Self.Texture = openGL.Texture.null_Object then white_Texture.enable; else Self.Texture .enable; end if; end enable_Texture; end openGL.Geometry.textured;
BrickBot/Bound-T-H8-300
Ada
2,883
ads
-- Options.Bool_Ref (decl) -- -- Boolean-valued options that are implemented by an existing Boolean -- variable that is referenced from the Option_T. -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 19:36:50 $ -- -- $Log: options-bool_ref.ads,v $ -- Revision 1.2 2015/10/24 19:36:50 niklas -- Moved to free licence. -- -- Revision 1.1 2012-01-21 11:50:39 niklas -- First version, for BT-CH-0225. -- with Options.Bool; package Options.Bool_Ref is type Boolean_Ref is access all Boolean; -- -- Refers to some (aliased) Boolean variable. type Option_T (Variable : Boolean_Ref; Default : Boolean) is new Options.Bool.Option_T (Default => Default) with null record; -- -- An option with a Boolean value, with a given Default value, -- that is implemented by an existing Variable. Setting or resetting -- this option changes the value of the Variable accordingly. overriding procedure Reset (Option : access Option_T); overriding procedure Set ( Option : access Option_T; Value : in String); end Options.Bool_Ref;
sungyeon/drake
Ada
693
ads
pragma License (Unrestricted); -- implementation unit required by compiler with System.Packed_Arrays; package System.Pack_07 is pragma Preelaborate; -- It can not be Pure, subprograms would become __attribute__((const)). type Bits_07 is mod 2 ** 7; for Bits_07'Size use 7; package Indexing is new Packed_Arrays.Indexing (Bits_07); -- required for accessing arrays by compiler function Get_07 ( Arr : Address; N : Natural; Rev_SSO : Boolean) return Bits_07 renames Indexing.Get; procedure Set_07 ( Arr : Address; N : Natural; E : Bits_07; Rev_SSO : Boolean) renames Indexing.Set; end System.Pack_07;
BrickBot/Bound-T-H8-300
Ada
3,955
ads
-- License (decl) -- -- Checking the user's right to this software. -- -- 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.7 $ -- $Date: 2015/10/24 19:36:50 $ -- -- $Log: license.ads,v $ -- Revision 1.7 2015/10/24 19:36:50 niklas -- Moved to free licence. -- -- Revision 1.6 2012-01-19 19:43:29 niklas -- BT-CH-0223: Package License does not depend on package Flow. -- -- Revision 1.5 2011-03-24 20:06:27 niklas -- Added End_Of_Time. -- -- Revision 1.4 2009-12-30 10:18:25 niklas -- BT-CH-0208: Isolate licence options within package License. -- -- Revision 1.3 2009-12-27 22:34:31 niklas -- BT-CH-0205: Licensing based on code size and time/space dimensions. -- -- Revision 1.2 2004-11-16 08:55:25 niklas -- Added Image function. -- -- Revision 1.1 2001/12/18 19:07:19 holsti -- First, date-based version. -- with Ada.Calendar; package License is End_Of_Time : constant Ada.Calendar.Time := Ada.Calendar.Time_Of ( Year => 2099, Month => 12, Day => 31); -- -- A date that indicates an eternally valid licence. type Size_Measure_T is new Natural; -- -- A measure of the size of the code under analysis, -- for sze-limited licences. function Valid_Date (Measure : Size_Measure_T) return Boolean; -- -- Whether the user is still licensed to run this software, -- on the current date. If the date has passed, analysis with -- a small program size-Measure may still be allowed. function Valid_Size (Measure : Size_Measure_T) return Boolean; -- -- Whether the user is licensed to analyse program part of -- this current Measure of size. function Allows_Time_Analysis return Boolean; -- -- Whether the licence allows time (WCET) analysis. function Allows_Stack_Analysis return Boolean; -- -- Whether the licence allows stack-usage analysis. function Image return String; -- -- A user-readable description of the current license. procedure Set_Size_Limit ( To : in String; Valid : out Boolean); -- -- Changes the size limit To some value. -- This change may be Valid (allowed by the licence) -- or not. end License;
tum-ei-rcs/StratoX
Ada
17,524
adb
-- Institution: Technische Universität München -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- Author: Martin Becker ([email protected]) with HIL; use HIL; with Ada.Unchecked_Conversion; with Ada.Real_Time; use Ada.Real_Time; with ULog.Conversions; use ULog.Conversions; with Interfaces; use Interfaces; -- @summary -- Implements the structure andserialization of log objects -- according to the self-describing ULOG file format used -- in PX4. -- The serialized byte array is returned. package body ULog with SPARK_Mode => On is All_Defs : Boolean := False; Hdr_Def : Boolean := False; Next_Def : Message_Type := Message_Type'First; ULOG_VERSION : constant HIL.Byte_Array := (1 => 16#1#); ULOG_MAGIC : constant HIL.Byte_Array := (16#55#, 16#4c#, 16#6f#, 16#67#, 16#01#, 16#12#, 16#35#); ULOG_MSG_HEAD : constant HIL.Byte_Array := (16#A3#, 16#95#); ULOG_MTYPE_FMT : constant := 16#80#; -- each log message looks like this: -- +------------------+---------+----------------+ -- | ULOG_MSG_HEAD(2) | Type(1) | Msg body (var) | -- +------------------+---------+----------------+ -- -- each body can be different. The header of the log file contains -- the definitions for the body by means of fixed-length -- FMT (0x80) messages, i.e., something like this: -- +------------------+------+--------------------+ -- | ULOG_MSG_HEAD(2) | 0x80 | a definition (86B) | -- +------------------+------+--------------------+ -- whereas 'definition' is as follows: -- -- +---------+-----------+---------+------------+------------+ -- | type[1] | length[1] | name[4] | format[16] | labels[64] | -- +---------+-----------+---------+------------+------------+ -- ^^ full packet incl.header -- -- Such FMT messages define the anatomy of 'msg body' for -- all messages with Type /= 0x80. --------------------- -- USER PROTOTYPES --------------------- -- add one Serialize_Ulog_* for each new message procedure Serialize_Ulog_GPS (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = GPS; procedure Serialize_Ulog_IMU (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = IMU; procedure Serialize_Ulog_Baro (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = BARO; procedure Serialize_Ulog_Mag (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = MAG; procedure Serialize_Ulog_Controller (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = CONTROLLER; procedure Serialize_Ulog_Nav (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = NAV; procedure Serialize_Ulog_Text (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = TEXT; procedure Serialize_Ulog_LogQ (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) with Pre => msg.Typ = LOG_QUEUE; ------------------------- -- INTERNAL PROTOTYPES ------------------------- function Time_To_U64 (rtime : Ada.Real_Time.Time) return Unsigned_64 with Pre => rtime >= Ada.Real_Time.Time_First; -- SPARK: "precond. might fail". Me: no (private type). procedure Serialize_Ulog_With_Tag (ct : out ULog.Conversions.Conversion_Tag; msg : in Message; len : out Natural; bytes : out HIL.Byte_Array) with Post => len < 256 and -- ulog messages cannot be longer then len <= bytes'Length; ------------------------ -- Serialize_Ulog_GPS ------------------------ procedure Serialize_Ulog_GPS (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "GPS"); Append_Float (ct, "lat", buf, msg.lat); Append_Float (ct, "lon", buf, msg.lon); Append_Float (ct, "alt", buf, msg.alt); Append_Uint8 (ct, "sat", buf, msg.nsat); Append_Uint8 (ct, "fix", buf, msg.fix); Append_Uint16 (ct, "yr", buf, msg.gps_year); Append_Uint8 (ct, "mon", buf, msg.gps_month); Append_Uint8 (ct, "day", buf, msg.gps_day); Append_Uint8 (ct, "h", buf, msg.gps_hour); Append_Uint8 (ct, "m", buf, msg.gps_min); Append_Uint8 (ct, "s", buf, msg.gps_sec); Append_Float (ct, "acc", buf, msg.pos_acc); Append_Float (ct, "v", buf, msg.vel); end Serialize_Ulog_GPS; -- pragma Annotate -- (GNATprove, Intentional, """buf"" is not initialized", -- "done by Martin Becker"); ------------------------ -- Serialize_Ulog_Nav ------------------------ procedure Serialize_Ulog_Nav (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "NAV"); Append_Float (ct, "dist", buf, msg.home_dist); Append_Float (ct, "crs", buf, msg.home_course); Append_Float (ct, "altd", buf, msg.home_altdiff); end Serialize_Ulog_Nav; ------------------------ -- Serialize_Ulog_IMU ------------------------ procedure Serialize_Ulog_IMU (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "IMU"); Append_Float (ct, "accX", buf, msg.accX); Append_Float (ct, "accY", buf, msg.accY); Append_Float (ct, "accZ", buf, msg.accZ); Append_Float (ct, "gyroX", buf, msg.gyroX); Append_Float (ct, "gyroY", buf, msg.gyroY); Append_Float (ct, "gyroZ", buf, msg.gyroZ); Append_Float (ct, "roll", buf, msg.roll); Append_Float (ct, "pitch", buf, msg.pitch); Append_Float (ct, "yaw", buf, msg.yaw); end Serialize_Ulog_IMU; pragma Annotate (GNATprove, Intentional, """buf"" is not initialized", "done by Martin Becker"); ------------------------ -- Serialize_Ulog_BARO ------------------------ procedure Serialize_Ulog_Baro (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "Baro"); Append_Float (ct, "press", buf, msg.pressure); Append_Float (ct, "temp", buf, msg.temp); Append_Float (ct, "alt", buf, msg.press_alt); end Serialize_Ulog_Baro; pragma Annotate (GNATprove, Intentional, """buf"" is not initialized", "being done here"); ------------------------ -- Serialize_Ulog_MAG ------------------------ procedure Serialize_Ulog_Mag (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "MAG"); Append_Float (ct, "magX", buf, msg.magX); Append_Float (ct, "magY", buf, msg.magY); Append_Float (ct, "magZ", buf, msg.magZ); end Serialize_Ulog_Mag; pragma Annotate (GNATprove, Intentional, """buf"" is not initialized", "done by Martin Becker"); ------------------------------- -- Serialize_Ulog_Controller ------------------------------- procedure Serialize_Ulog_Controller (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "Ctrl"); Append_Uint8 (ct, "mode", buf, msg.ctrl_mode); Append_Float (ct, "TarYaw", buf, msg.target_yaw); Append_Float (ct, "TarRoll", buf, msg.target_roll); Append_Float (ct, "TarPitch", buf, msg.target_pitch); Append_Float (ct, "EleL", buf, msg.elevon_left); Append_Float (ct, "EleR", buf, msg.elevon_right); end Serialize_Ulog_Controller; pragma Annotate (GNATprove, Intentional, """buf"" is not initialized", "done by Martin Becker"); ------------------------ -- Serialize_Ulog_LogQ ------------------------ procedure Serialize_Ulog_LogQ (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "LogQ"); Append_Uint16 (ct, "ovf", buf, msg.n_overflows); Append_Uint8 (ct, "qd", buf, msg.n_queued); Append_Uint8 (ct, "max", buf, msg.max_queued); end Serialize_Ulog_LogQ; -- pragma Annotate -- (GNATprove, Intentional, -- """buf"" is not initialized", "done by Martin Becker"); ------------------------- -- Serialize_Ulog_Text ------------------------- procedure Serialize_Ulog_Text (ct : in out ULog.Conversions.Conversion_Tag; msg : in Message; buf : out HIL.Byte_Array) is begin Set_Name (ct, "Text"); -- we allow 128B, but the longest field is 64B. split over two. declare txt : String renames msg.txt (msg.txt'First .. msg.txt'First + 63); len : Natural; begin if msg.txt_last > txt'Last then len := txt'Length; elsif msg.txt_last >= txt'First and then msg.txt_last <= txt'Last then len := (msg.txt_last - txt'First) + 1; else len := 0; end if; Append_String64 (ct, "text1", buf, txt, len); end; declare txt : String renames msg.txt (msg.txt'First + 64 .. msg.txt'Last); len : Natural; begin if msg.txt_last > txt'Last then len := txt'Length; elsif msg.txt_last >= txt'First and then msg.txt_last <= txt'Last then len := (msg.txt_last - txt'First) + 1; else len := 0; end if; Append_String64 (ct, "text2", buf, txt, len); end; end Serialize_Ulog_Text; pragma Annotate (GNATprove, Intentional, """buf"" is not initialized", "done by Martin Becker"); -------------------- -- Time_To_U64 -------------------- function Time_To_U64 (rtime : Ada.Real_Time.Time) return Unsigned_64 is tmp : Integer; u64 : Unsigned_64; begin tmp := (rtime - Ada.Real_Time.Time_First) / Ada.Real_Time.Microseconds (1); if tmp < Integer (Unsigned_64'First) then u64 := Unsigned_64'First; else u64 := Unsigned_64 (tmp); end if; return u64; end Time_To_U64; -- SPARK: "precondition might a fail". -- Me: "no (because Time_First is private and SPARK can't know)" -------------------- -- Serialize_Ulog -------------------- procedure Serialize_Ulog (msg : in Message; len : out Natural; bytes : out HIL.Byte_Array) is ct : ULog.Conversions.Conversion_Tag; begin Serialize_Ulog_With_Tag (ct => ct, msg => msg, len => len, bytes => bytes); pragma Unreferenced (ct); -- caller doesn't want that end Serialize_Ulog; ----------------------------- -- Serialize_Ulog_With_Tag ----------------------------- procedure Serialize_Ulog_With_Tag (ct : out ULog.Conversions.Conversion_Tag; msg : in Message; len : out Natural; bytes : out HIL.Byte_Array) is begin New_Conversion (ct); -- write header Append_Unlabeled_Bytes (t => ct, buf => bytes, tail => ULOG_MSG_HEAD & HIL.Byte (Message_Type'Pos (msg.Typ))); pragma Annotate (GNATprove, Intentional, """bytes"" is not initialized", "done by Martin Becker"); -- serialize the timestamp declare pragma Assume (msg.t >= Ada.Real_Time.Time_First); -- see a-reatim.ads time_usec : constant Unsigned_64 := Time_To_U64 (msg.t); begin Append_Uint64 (t => ct, label => "t", buf => bytes, tail => time_usec); end; -- call the appropriate serializaton procedure for other components case msg.Typ is when NONE => null; when GPS => Serialize_Ulog_GPS (ct, msg, bytes); when IMU => Serialize_Ulog_IMU (ct, msg, bytes); when MAG => Serialize_Ulog_Mag (ct, msg, bytes); when CONTROLLER => Serialize_Ulog_Controller (ct, msg, bytes); when TEXT => Serialize_Ulog_Text (ct, msg, bytes); when BARO => Serialize_Ulog_Baro (ct, msg, bytes); when NAV => Serialize_Ulog_Nav (ct, msg, bytes); when LOG_QUEUE => Serialize_Ulog_LogQ (ct, msg, bytes); end case; -- read back the length, and drop incomplete messages declare SERLEN : constant Natural := Get_Size (ct); begin if Buffer_Overflow (ct) or SERLEN > bytes'Length or SERLEN > 255 then len := 0; else len := SERLEN; end if; end; -- pragma Assert (len <= bytes'Length); end Serialize_Ulog_With_Tag; ------------------- -- Serialize_CSV ------------------- -- procedure Serialize_CSV -- (msg : in Message; len : out Natural; bytes : out HIL.Byte_Array) is -- begin -- null; -- end Serialize_CSV; --------------------- -- Get_Header_Ulog --------------------- procedure Get_Header_Ulog (bytes : in out HIL.Byte_Array; len : out Natural; valid : out Boolean) with SPARK_Mode => Off is begin if All_Defs then valid := False; elsif not Hdr_Def then -- before everything, return following ULog header: -- (not required by the spec, but it helps to recover the file -- when the SD logging goes wrong): -- +------------+---------+-----------+ -- | File magic | version | timestamp | -- +------------+---------+-----------+ declare timestamp : constant HIL.Byte_Array := (0, 0, 0, 0); l : constant Integer := ULOG_MAGIC'Length + ULOG_VERSION'Length + timestamp'Length; begin if bytes'Length < l then len := 0; valid := False; end if; bytes (bytes'First .. bytes'First + l - 1) := ULOG_MAGIC & ULOG_VERSION & timestamp; len := l; end; Hdr_Def := True; valid := True; else if Next_Def = NONE then len := 0; else -- now return FMT message with definition of current type. -- Skip type=NONE declare -- the following decl prevents spark mode. -- RM 4.4(2): subtype cons. cannot depend. -- simply comment for proof. m : Message (typ => Next_Def); FMT_HEAD : constant HIL.Byte_Array := ULOG_MSG_HEAD & ULOG_MTYPE_FMT; type FMT_Msg is record HEAD : HIL.Byte_Array (1 .. 3); typ : HIL.Byte; -- auto: ID of message being described len : HIL.Byte; -- auto: length of packed message name : ULog_Name; -- auto: short name of message fmt : ULog_Format; -- format string lbl : ULog_Label; -- label string end record with Pack; FMT_MSGLEN : constant Natural := (FMT_Msg'Size + 7) / 8; -- ceil subtype foo is HIL.Byte_Array (1 .. FMT_MSGLEN); function To_Buffer is new Ada.Unchecked_Conversion (FMT_Msg, foo); fmsg : FMT_Msg; begin if FMT_MSGLEN > bytes'Length then len := 0; -- message too long for buffer...skip it return; end if; fmsg.HEAD := FMT_HEAD; fmsg.typ := HIL.Byte (Message_Type'Pos (Next_Def)); -- actually serialize a dummy message and read back things declare serbuf : HIL.Byte_Array (1 .. 512); pragma Unreferenced (serbuf); serlen : Natural; begin declare ct : ULog.Conversions.Conversion_Tag; begin Serialize_Ulog_With_Tag (ct => ct, msg => m, len => serlen, bytes => serbuf); fmsg.fmt := ULog.Conversions.Get_Format (ct); fmsg.name := ULog.Conversions.Get_Name (ct); fmsg.lbl := ULog.Conversions.Get_Labels (ct); end; fmsg.len := HIL.Byte (serlen); end; -- copy all over to caller bytes (bytes'First .. bytes'First + FMT_MSGLEN - 1) := To_Buffer (fmsg); len := FMT_MSGLEN; end; end if; if Next_Def < Message_Type'Last then Next_Def := Message_Type'Succ (Next_Def); else All_Defs := True; end if; valid := True; end if; end Get_Header_Ulog; end ULog;
zhmu/ananas
Ada
35,833
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . M A P S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- The package Strings.Maps defines the types, operations, and other entities -- needed for character sets and character-to-character mappings. -- Preconditions in this unit are meant for analysis only, not for run-time -- checking, so that the expected exceptions are raised. This is enforced by -- setting the corresponding assertion policy to Ignore. Postconditions and -- ghost code should not be executed at runtime as well, in order not to slow -- down the execution of these functions. pragma Assertion_Policy (Pre => Ignore, Post => Ignore, Ghost => Ignore); with Ada.Characters.Latin_1; package Ada.Strings.Maps with SPARK_Mode is pragma Pure; -- In accordance with Ada 2005 AI-362 -------------------------------- -- Character Set Declarations -- -------------------------------- type Character_Set is private; pragma Preelaborable_Initialization (Character_Set); -- An object of type Character_Set represents a set of characters. Null_Set : constant Character_Set; -- Null_Set represents the set containing no characters. --------------------------- -- Constructors for Sets -- --------------------------- type Character_Range is record Low : Character; High : Character; end record; -- An object Obj of type Character_Range represents the set of characters -- in the range Obj.Low .. Obj.High. type Character_Ranges is array (Positive range <>) of Character_Range; -- An object Obj of type Character_Ranges represents the union of the sets -- corresponding to Obj(I) for I in Obj'Range. function To_Set (Ranges : Character_Ranges) return Character_Set with Post => (if Ranges'Length = 0 then To_Set'Result = Null_Set) and then (for all Char in Character => (if Is_In (Char, To_Set'Result) then (for some Span of Ranges => Char in Span.Low .. Span.High))) and then (for all Span of Ranges => (for all Char in Span.Low .. Span.High => Is_In (Char, To_Set'Result))); -- If Ranges'Length=0 then Null_Set is returned; otherwise, the returned -- value represents the set corresponding to Ranges. function To_Set (Span : Character_Range) return Character_Set with Post => (if Span.High < Span.Low then To_Set'Result = Null_Set) and then (for all Char in Character => (if Is_In (Char, To_Set'Result) then Char in Span.Low .. Span.High)) and then (for all Char in Span.Low .. Span.High => Is_In (Char, To_Set'Result)); -- The returned value represents the set containing each character in Span. function To_Ranges (Set : Character_Set) return Character_Ranges with Post => (if Set = Null_Set then To_Ranges'Result'Length = 0) and then (for all Char in Character => (if Is_In (Char, Set) then (for some Span of To_Ranges'Result => Char in Span.Low .. Span.High))) and then (for all Span of To_Ranges'Result => (for all Char in Span.Low .. Span.High => Is_In (Char, Set))); -- If Set = Null_Set, then an empty Character_Ranges array is returned; -- otherwise, the shortest array of contiguous ranges of Character values -- in Set, in increasing order of Low, is returned. -- -- The postcondition above does not express that the result is the shortest -- array and that it is sorted. ---------------------------------- -- Operations on Character Sets -- ---------------------------------- function "=" (Left, Right : Character_Set) return Boolean with Post => "="'Result = (for all Char in Character => (Is_In (Char, Left) = Is_In (Char, Right))); -- The function "=" returns True if Left and Right represent identical -- sets, and False otherwise. -- Each of the logical operators "not", "and", "or", and "xor" returns a -- Character_Set value that represents the set obtained by applying the -- corresponding operation to the set(s) represented by the parameter(s) -- of the operator. function "not" (Right : Character_Set) return Character_Set with Post => (for all Char in Character => (Is_In (Char, "not"'Result) = not Is_In (Char, Right))); function "and" (Left, Right : Character_Set) return Character_Set with Post => (for all Char in Character => (Is_In (Char, "and"'Result) = (Is_In (Char, Left) and Is_In (Char, Right)))); function "or" (Left, Right : Character_Set) return Character_Set with Post => (for all Char in Character => (Is_In (Char, "or"'Result) = (Is_In (Char, Left) or Is_In (Char, Right)))); function "xor" (Left, Right : Character_Set) return Character_Set with Post => (for all Char in Character => (Is_In (Char, "xor"'Result) = (Is_In (Char, Left) xor Is_In (Char, Right)))); function "-" (Left, Right : Character_Set) return Character_Set with Post => (for all Char in Character => (Is_In (Char, "-"'Result) = (Is_In (Char, Left) and not Is_In (Char, Right)))); -- "-"(Left, Right) is equivalent to "and"(Left, "not"(Right)). function Is_In (Element : Character; Set : Character_Set) return Boolean; -- Is_In returns True if Element is in Set, and False otherwise. function Is_Subset (Elements : Character_Set; Set : Character_Set) return Boolean with Post => Is_Subset'Result = (for all Char in Character => (if Is_In (Char, Elements) then Is_In (Char, Set))); -- Is_Subset returns True if Elements is a subset of Set, and False -- otherwise. function "<=" (Left : Character_Set; Right : Character_Set) return Boolean renames Is_Subset; subtype Character_Sequence is String; -- The Character_Sequence subtype is used to portray a set of character -- values and also to identify the domain and range of a character mapping. function SPARK_Proof_Sorted_Character_Sequence (Seq : Character_Sequence) return Boolean is (for all J in Seq'Range => (if J /= Seq'Last then Seq (J) < Seq (J + 1))) with Ghost; -- Check whether the Character_Sequence is sorted in stricly increasing -- order, as expected from the result of To_Sequence and To_Domain. -- Sequence portrays the set of character values that it explicitly -- contains (ignoring duplicates). Singleton portrays the set comprising a -- single Character. Each of the To_Set functions returns a Character_Set -- value that represents the set portrayed by Sequence or Singleton. function To_Set (Sequence : Character_Sequence) return Character_Set with Post => (if Sequence'Length = 0 then To_Set'Result = Null_Set) and then (for all Char in Character => (if Is_In (Char, To_Set'Result) then (for some X of Sequence => Char = X))) and then (for all Char of Sequence => Is_In (Char, To_Set'Result)); function To_Set (Singleton : Character) return Character_Set with Post => Is_In (Singleton, To_Set'Result) and then (for all Char in Character => (if Char /= Singleton then not Is_In (Char, To_Set'Result))); function To_Sequence (Set : Character_Set) return Character_Sequence with Post => (if Set = Null_Set then To_Sequence'Result'Length = 0) and then (for all Char in Character => (if Is_In (Char, Set) then (for some X of To_Sequence'Result => Char = X))) and then (for all Char of To_Sequence'Result => Is_In (Char, Set)) and then SPARK_Proof_Sorted_Character_Sequence (To_Sequence'Result); -- The function To_Sequence returns a Character_Sequence value containing -- each of the characters in the set represented by Set, in ascending order -- with no duplicates. ------------------------------------ -- Character Mapping Declarations -- ------------------------------------ type Character_Mapping is private; pragma Preelaborable_Initialization (Character_Mapping); -- An object of type Character_Mapping represents a Character-to-Character -- mapping. type SPARK_Proof_Character_Mapping_Model is array (Character) of Character with Ghost; -- Publicly visible model of a Character_Mapping function SPARK_Proof_Model (Map : Character_Mapping) return SPARK_Proof_Character_Mapping_Model with Ghost; -- Creation of a publicly visible model of a Character_Mapping function Value (Map : Character_Mapping; Element : Character) return Character with Post => Value'Result = SPARK_Proof_Model (Map) (Element); -- The function Value returns the Character value to which Element maps -- with respect to the mapping represented by Map. -- A character C matches a pattern character P with respect to a given -- Character_Mapping value Map if Value(Map, C) = P. A string S matches -- a pattern string P with respect to a given Character_Mapping if -- their lengths are the same and if each character in S matches its -- corresponding character in the pattern string P. -- String handling subprograms that deal with character mappings have -- parameters whose type is Character_Mapping. Identity : constant Character_Mapping; -- Identity maps each Character to itself. ---------------------------- -- Operations on Mappings -- ---------------------------- function To_Mapping (From, To : Character_Sequence) return Character_Mapping with Pre => From'Length = To'Length and then (for all J in From'Range => (for all K in From'Range => (if J /= K then From (J) /= From (K)))), Post => (if From = To then To_Mapping'Result = Identity) and then (for all Char in Character => ((for all J in From'Range => (if From (J) = Char then Value (To_Mapping'Result, Char) = To (J - From'First + To'First))) and then (if (for all X of From => Char /= X) then Value (To_Mapping'Result, Char) = Char))); -- To_Mapping produces a Character_Mapping such that each element of From -- maps to the corresponding element of To, and each other character maps -- to itself. If From'Length /= To'Length, or if some character is repeated -- in From, then Translation_Error is propagated. function To_Domain (Map : Character_Mapping) return Character_Sequence with Post => (if Map = Identity then To_Domain'Result'Length = 0) and then To_Domain'Result'First = 1 and then SPARK_Proof_Sorted_Character_Sequence (To_Domain'Result) and then (for all Char in Character => (if (for all X of To_Domain'Result => X /= Char) then Value (Map, Char) = Char)) and then (for all Char of To_Domain'Result => Value (Map, Char) /= Char); -- To_Domain returns the shortest Character_Sequence value D such that each -- character not in D maps to itself, and such that the characters in D are -- in ascending order. The lower bound of D is 1. function To_Range (Map : Character_Mapping) return Character_Sequence with Post => To_Range'Result'First = 1 and then To_Range'Result'Length = To_Domain (Map)'Length and then (for all J in To_Range'Result'Range => To_Range'Result (J) = Value (Map, To_Domain (Map) (J))); -- To_Range returns the Character_Sequence value R, such that if D = -- To_Domain(Map), then R has the same bounds as D, and D(I) maps to -- R(I) for each I in D'Range. -- -- A direct encoding of the Ada RM would be the postcondition -- To_Range'Result'Last = To_Domain (Map)'Last -- which is not provable unless the postcondition of To_Domain is also -- strengthened to state the value of the high bound for an empty result. type Character_Mapping_Function is access function (From : Character) return Character; -- An object F of type Character_Mapping_Function maps a Character value C -- to the Character value F.all(C), which is said to match C with respect -- to mapping function F. private pragma Inline (Is_In); pragma Inline (Value); type Character_Set_Internal is array (Character) of Boolean; pragma Pack (Character_Set_Internal); type Character_Set is new Character_Set_Internal; -- Note: the reason for this level of derivation is to make sure -- that the predefined logical operations on this type remain -- accessible. The operations on Character_Set are overridden by -- the defined operations in the spec, but the operations defined -- on Character_Set_Internal remain visible. Null_Set : constant Character_Set := [others => False]; type Character_Mapping is array (Character) of Character; function SPARK_Proof_Model (Map : Character_Mapping) return SPARK_Proof_Character_Mapping_Model is (SPARK_Proof_Character_Mapping_Model (Map)); package L renames Ada.Characters.Latin_1; Identity : constant Character_Mapping := (L.NUL & -- NUL 0 L.SOH & -- SOH 1 L.STX & -- STX 2 L.ETX & -- ETX 3 L.EOT & -- EOT 4 L.ENQ & -- ENQ 5 L.ACK & -- ACK 6 L.BEL & -- BEL 7 L.BS & -- BS 8 L.HT & -- HT 9 L.LF & -- LF 10 L.VT & -- VT 11 L.FF & -- FF 12 L.CR & -- CR 13 L.SO & -- SO 14 L.SI & -- SI 15 L.DLE & -- DLE 16 L.DC1 & -- DC1 17 L.DC2 & -- DC2 18 L.DC3 & -- DC3 19 L.DC4 & -- DC4 20 L.NAK & -- NAK 21 L.SYN & -- SYN 22 L.ETB & -- ETB 23 L.CAN & -- CAN 24 L.EM & -- EM 25 L.SUB & -- SUB 26 L.ESC & -- ESC 27 L.FS & -- FS 28 L.GS & -- GS 29 L.RS & -- RS 30 L.US & -- US 31 L.Space & -- ' ' 32 L.Exclamation & -- '!' 33 L.Quotation & -- '"' 34 L.Number_Sign & -- '#' 35 L.Dollar_Sign & -- '$' 36 L.Percent_Sign & -- '%' 37 L.Ampersand & -- '&' 38 L.Apostrophe & -- ''' 39 L.Left_Parenthesis & -- '(' 40 L.Right_Parenthesis & -- ')' 41 L.Asterisk & -- '*' 42 L.Plus_Sign & -- '+' 43 L.Comma & -- ',' 44 L.Hyphen & -- '-' 45 L.Full_Stop & -- '.' 46 L.Solidus & -- '/' 47 '0' & -- '0' 48 '1' & -- '1' 49 '2' & -- '2' 50 '3' & -- '3' 51 '4' & -- '4' 52 '5' & -- '5' 53 '6' & -- '6' 54 '7' & -- '7' 55 '8' & -- '8' 56 '9' & -- '9' 57 L.Colon & -- ':' 58 L.Semicolon & -- ';' 59 L.Less_Than_Sign & -- '<' 60 L.Equals_Sign & -- '=' 61 L.Greater_Than_Sign & -- '>' 62 L.Question & -- '?' 63 L.Commercial_At & -- '@' 64 'A' & -- 'A' 65 'B' & -- 'B' 66 'C' & -- 'C' 67 'D' & -- 'D' 68 'E' & -- 'E' 69 'F' & -- 'F' 70 'G' & -- 'G' 71 'H' & -- 'H' 72 'I' & -- 'I' 73 'J' & -- 'J' 74 'K' & -- 'K' 75 'L' & -- 'L' 76 'M' & -- 'M' 77 'N' & -- 'N' 78 'O' & -- 'O' 79 'P' & -- 'P' 80 'Q' & -- 'Q' 81 'R' & -- 'R' 82 'S' & -- 'S' 83 'T' & -- 'T' 84 'U' & -- 'U' 85 'V' & -- 'V' 86 'W' & -- 'W' 87 'X' & -- 'X' 88 'Y' & -- 'Y' 89 'Z' & -- 'Z' 90 L.Left_Square_Bracket & -- '[' 91 L.Reverse_Solidus & -- '\' 92 L.Right_Square_Bracket & -- ']' 93 L.Circumflex & -- '^' 94 L.Low_Line & -- '_' 95 L.Grave & -- '`' 96 L.LC_A & -- 'a' 97 L.LC_B & -- 'b' 98 L.LC_C & -- 'c' 99 L.LC_D & -- 'd' 100 L.LC_E & -- 'e' 101 L.LC_F & -- 'f' 102 L.LC_G & -- 'g' 103 L.LC_H & -- 'h' 104 L.LC_I & -- 'i' 105 L.LC_J & -- 'j' 106 L.LC_K & -- 'k' 107 L.LC_L & -- 'l' 108 L.LC_M & -- 'm' 109 L.LC_N & -- 'n' 110 L.LC_O & -- 'o' 111 L.LC_P & -- 'p' 112 L.LC_Q & -- 'q' 113 L.LC_R & -- 'r' 114 L.LC_S & -- 's' 115 L.LC_T & -- 't' 116 L.LC_U & -- 'u' 117 L.LC_V & -- 'v' 118 L.LC_W & -- 'w' 119 L.LC_X & -- 'x' 120 L.LC_Y & -- 'y' 121 L.LC_Z & -- 'z' 122 L.Left_Curly_Bracket & -- '{' 123 L.Vertical_Line & -- '|' 124 L.Right_Curly_Bracket & -- '}' 125 L.Tilde & -- '~' 126 L.DEL & -- DEL 127 L.Reserved_128 & -- Reserved_128 128 L.Reserved_129 & -- Reserved_129 129 L.BPH & -- BPH 130 L.NBH & -- NBH 131 L.Reserved_132 & -- Reserved_132 132 L.NEL & -- NEL 133 L.SSA & -- SSA 134 L.ESA & -- ESA 135 L.HTS & -- HTS 136 L.HTJ & -- HTJ 137 L.VTS & -- VTS 138 L.PLD & -- PLD 139 L.PLU & -- PLU 140 L.RI & -- RI 141 L.SS2 & -- SS2 142 L.SS3 & -- SS3 143 L.DCS & -- DCS 144 L.PU1 & -- PU1 145 L.PU2 & -- PU2 146 L.STS & -- STS 147 L.CCH & -- CCH 148 L.MW & -- MW 149 L.SPA & -- SPA 150 L.EPA & -- EPA 151 L.SOS & -- SOS 152 L.Reserved_153 & -- Reserved_153 153 L.SCI & -- SCI 154 L.CSI & -- CSI 155 L.ST & -- ST 156 L.OSC & -- OSC 157 L.PM & -- PM 158 L.APC & -- APC 159 L.No_Break_Space & -- No_Break_Space 160 L.Inverted_Exclamation & -- Inverted_Exclamation 161 L.Cent_Sign & -- Cent_Sign 162 L.Pound_Sign & -- Pound_Sign 163 L.Currency_Sign & -- Currency_Sign 164 L.Yen_Sign & -- Yen_Sign 165 L.Broken_Bar & -- Broken_Bar 166 L.Section_Sign & -- Section_Sign 167 L.Diaeresis & -- Diaeresis 168 L.Copyright_Sign & -- Copyright_Sign 169 L.Feminine_Ordinal_Indicator & -- Feminine_Ordinal_Indicator 170 L.Left_Angle_Quotation & -- Left_Angle_Quotation 171 L.Not_Sign & -- Not_Sign 172 L.Soft_Hyphen & -- Soft_Hyphen 173 L.Registered_Trade_Mark_Sign & -- Registered_Trade_Mark_Sign 174 L.Macron & -- Macron 175 L.Degree_Sign & -- Degree_Sign 176 L.Plus_Minus_Sign & -- Plus_Minus_Sign 177 L.Superscript_Two & -- Superscript_Two 178 L.Superscript_Three & -- Superscript_Three 179 L.Acute & -- Acute 180 L.Micro_Sign & -- Micro_Sign 181 L.Pilcrow_Sign & -- Pilcrow_Sign 182 L.Middle_Dot & -- Middle_Dot 183 L.Cedilla & -- Cedilla 184 L.Superscript_One & -- Superscript_One 185 L.Masculine_Ordinal_Indicator & -- Masculine_Ordinal_Indicator 186 L.Right_Angle_Quotation & -- Right_Angle_Quotation 187 L.Fraction_One_Quarter & -- Fraction_One_Quarter 188 L.Fraction_One_Half & -- Fraction_One_Half 189 L.Fraction_Three_Quarters & -- Fraction_Three_Quarters 190 L.Inverted_Question & -- Inverted_Question 191 L.UC_A_Grave & -- UC_A_Grave 192 L.UC_A_Acute & -- UC_A_Acute 193 L.UC_A_Circumflex & -- UC_A_Circumflex 194 L.UC_A_Tilde & -- UC_A_Tilde 195 L.UC_A_Diaeresis & -- UC_A_Diaeresis 196 L.UC_A_Ring & -- UC_A_Ring 197 L.UC_AE_Diphthong & -- UC_AE_Diphthong 198 L.UC_C_Cedilla & -- UC_C_Cedilla 199 L.UC_E_Grave & -- UC_E_Grave 200 L.UC_E_Acute & -- UC_E_Acute 201 L.UC_E_Circumflex & -- UC_E_Circumflex 202 L.UC_E_Diaeresis & -- UC_E_Diaeresis 203 L.UC_I_Grave & -- UC_I_Grave 204 L.UC_I_Acute & -- UC_I_Acute 205 L.UC_I_Circumflex & -- UC_I_Circumflex 206 L.UC_I_Diaeresis & -- UC_I_Diaeresis 207 L.UC_Icelandic_Eth & -- UC_Icelandic_Eth 208 L.UC_N_Tilde & -- UC_N_Tilde 209 L.UC_O_Grave & -- UC_O_Grave 210 L.UC_O_Acute & -- UC_O_Acute 211 L.UC_O_Circumflex & -- UC_O_Circumflex 212 L.UC_O_Tilde & -- UC_O_Tilde 213 L.UC_O_Diaeresis & -- UC_O_Diaeresis 214 L.Multiplication_Sign & -- Multiplication_Sign 215 L.UC_O_Oblique_Stroke & -- UC_O_Oblique_Stroke 216 L.UC_U_Grave & -- UC_U_Grave 217 L.UC_U_Acute & -- UC_U_Acute 218 L.UC_U_Circumflex & -- UC_U_Circumflex 219 L.UC_U_Diaeresis & -- UC_U_Diaeresis 220 L.UC_Y_Acute & -- UC_Y_Acute 221 L.UC_Icelandic_Thorn & -- UC_Icelandic_Thorn 222 L.LC_German_Sharp_S & -- LC_German_Sharp_S 223 L.LC_A_Grave & -- LC_A_Grave 224 L.LC_A_Acute & -- LC_A_Acute 225 L.LC_A_Circumflex & -- LC_A_Circumflex 226 L.LC_A_Tilde & -- LC_A_Tilde 227 L.LC_A_Diaeresis & -- LC_A_Diaeresis 228 L.LC_A_Ring & -- LC_A_Ring 229 L.LC_AE_Diphthong & -- LC_AE_Diphthong 230 L.LC_C_Cedilla & -- LC_C_Cedilla 231 L.LC_E_Grave & -- LC_E_Grave 232 L.LC_E_Acute & -- LC_E_Acute 233 L.LC_E_Circumflex & -- LC_E_Circumflex 234 L.LC_E_Diaeresis & -- LC_E_Diaeresis 235 L.LC_I_Grave & -- LC_I_Grave 236 L.LC_I_Acute & -- LC_I_Acute 237 L.LC_I_Circumflex & -- LC_I_Circumflex 238 L.LC_I_Diaeresis & -- LC_I_Diaeresis 239 L.LC_Icelandic_Eth & -- LC_Icelandic_Eth 240 L.LC_N_Tilde & -- LC_N_Tilde 241 L.LC_O_Grave & -- LC_O_Grave 242 L.LC_O_Acute & -- LC_O_Acute 243 L.LC_O_Circumflex & -- LC_O_Circumflex 244 L.LC_O_Tilde & -- LC_O_Tilde 245 L.LC_O_Diaeresis & -- LC_O_Diaeresis 246 L.Division_Sign & -- Division_Sign 247 L.LC_O_Oblique_Stroke & -- LC_O_Oblique_Stroke 248 L.LC_U_Grave & -- LC_U_Grave 249 L.LC_U_Acute & -- LC_U_Acute 250 L.LC_U_Circumflex & -- LC_U_Circumflex 251 L.LC_U_Diaeresis & -- LC_U_Diaeresis 252 L.LC_Y_Acute & -- LC_Y_Acute 253 L.LC_Icelandic_Thorn & -- LC_Icelandic_Thorn 254 L.LC_Y_Diaeresis); -- LC_Y_Diaeresis 255 end Ada.Strings.Maps;
jwarwick/aoc_2019_ada
Ada
481
ads
with AUnit; with AUnit.Test_Cases; package IntCode.Test is type Test is new AUnit.Test_Cases.Test_Case with null record; function Name (T : Test) return AUnit.Message_String; procedure Register_Tests (T : in out Test); -- Test routines procedure Test_Load (T : in out AUnit.Test_Cases.Test_Case'Class); procedure Test_Poke (T : in out AUnit.Test_Cases.Test_Case'Class); procedure Test_Eval (T : in out AUnit.Test_Cases.Test_Case'Class); end IntCode.Test;
stcarrez/ada-asf
Ada
13,703
adb
----------------------------------------------------------------------- -- asf-models-selects -- Data model for UISelectOne and UISelectMany -- Copyright (C) 2011, 2012, 2013, 2017, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; package body ASF.Models.Selects is function UTF8_Decode (S : in String) return Wide_Wide_String renames Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode; -- ------------------------------ -- Return an Object from the select item record. -- Returns a NULL object if the item is empty. -- ------------------------------ function To_Object (Item : in Select_Item) return Util.Beans.Objects.Object is begin if Item.Item.Is_Null then return Util.Beans.Objects.Null_Object; else declare Bean : constant Select_Item_Access := new Select_Item; begin Bean.all := Item; return Util.Beans.Objects.To_Object (Bean.all'Access); end; end if; end To_Object; -- ------------------------------ -- Return the <b>Select_Item</b> instance from a generic bean object. -- Returns an empty item if the object does not hold a <b>Select_Item</b>. -- ------------------------------ function To_Select_Item (Object : in Util.Beans.Objects.Object) return Select_Item is Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Object); Result : Select_Item; begin if Bean = null then return Result; end if; if not (Bean.all in Select_Item'Class) then return Result; end if; Result := Select_Item (Bean.all); return Result; end To_Select_Item; -- ------------------------------ -- Creates a <b>Select_Item</b> with the specified label and value. -- ------------------------------ function Create_Select_Item (Label : in String; Value : in String; Description : in String := ""; Disabled : in Boolean := False; Escaped : in Boolean := True) return Select_Item is Result : Select_Item; begin Result.Item := Select_Item_Refs.Create; declare Item : constant Select_Item_Record_Accessor := Result.Item.Value; begin Item.Label := To_Unbounded_Wide_Wide_String (UTF8_Decode (Label)); Item.Value := To_Unbounded_Wide_Wide_String (UTF8_Decode (Value)); Item.Description := To_Unbounded_Wide_Wide_String (UTF8_Decode (Description)); Item.Disabled := Disabled; Item.Escape := Escaped; end; return Result; end Create_Select_Item; -- ------------------------------ -- Creates a <b>Select_Item</b> with the specified label and value. -- ------------------------------ function Create_Select_Item_Wide (Label : in Wide_Wide_String; Value : in Wide_Wide_String; Description : in Wide_Wide_String := ""; Disabled : in Boolean := False; Escaped : in Boolean := True) return Select_Item is Result : Select_Item; begin Result.Item := Select_Item_Refs.Create; declare Item : constant Select_Item_Record_Accessor := Result.Item.Value; begin Item.Label := To_Unbounded_Wide_Wide_String (Label); Item.Value := To_Unbounded_Wide_Wide_String (Value); Item.Description := To_Unbounded_Wide_Wide_String (Description); Item.Disabled := Disabled; Item.Escape := Escaped; end; return Result; end Create_Select_Item_Wide; -- ------------------------------ -- Creates a <b>Select_Item</b> with the specified label, value and description. -- The objects are converted to a wide wide string. The empty string is used if they -- are null. -- ------------------------------ function Create_Select_Item (Label : in Util.Beans.Objects.Object; Value : in Util.Beans.Objects.Object; Description : in Util.Beans.Objects.Object; Disabled : in Boolean := False; Escaped : in Boolean := True) return Select_Item is use Util.Beans.Objects; Result : Select_Item; begin Result.Item := Select_Item_Refs.Create; declare Item : constant Select_Item_Record_Accessor := Result.Item.Value; begin if not Is_Null (Label) then Item.Label := To_Unbounded_Wide_Wide_String (Label); end if; if not Is_Null (Value) then Item.Value := To_Unbounded_Wide_Wide_String (Value); end if; if not Is_Null (Description) then Item.Description := To_Unbounded_Wide_Wide_String (Description); end if; Item.Disabled := Disabled; Item.Escape := Escaped; end; return Result; end Create_Select_Item; -- ------------------------------ -- Get the item label. -- ------------------------------ function Get_Label (Item : in Select_Item) return Wide_Wide_String is begin if Item.Item.Is_Null then return ""; else return To_Wide_Wide_String (Item.Item.Value.Label); end if; end Get_Label; -- ------------------------------ -- Get the item value. -- ------------------------------ function Get_Value (Item : in Select_Item) return Wide_Wide_String is begin if Item.Item.Is_Null then return ""; else return To_Wide_Wide_String (Item.Item.Value.Value); end if; end Get_Value; -- ------------------------------ -- Get the item description. -- ------------------------------ function Get_Description (Item : in Select_Item) return Wide_Wide_String is begin if Item.Item.Is_Null then return ""; else return To_Wide_Wide_String (Item.Item.Value.Description); end if; end Get_Description; -- ------------------------------ -- Returns true if the item is disabled. -- ------------------------------ function Is_Disabled (Item : in Select_Item) return Boolean is begin if Item.Item.Is_Null then return False; else return Item.Item.Value.Disabled; end if; end Is_Disabled; -- ------------------------------ -- Returns true if the label must be escaped using HTML escape rules. -- ------------------------------ function Is_Escaped (Item : in Select_Item) return Boolean is begin if Item.Item.Is_Null then return False; else return Item.Item.Value.Escape; end if; end Is_Escaped; -- ------------------------------ -- Returns true if the select item component is empty. -- ------------------------------ function Is_Empty (Item : in Select_Item) return Boolean is begin return Item.Item.Is_Null; end Is_Empty; -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Select_Item; Name : in String) return Util.Beans.Objects.Object is begin if From.Item.Is_Null then return Util.Beans.Objects.Null_Object; end if; declare Item : constant Select_Item_Record_Accessor := From.Item.Value; begin if Name = "name" then return Util.Beans.Objects.To_Object (Item.Label); elsif Name = "value" then return Util.Beans.Objects.To_Object (Item.Value); elsif Name = "description" then return Util.Beans.Objects.To_Object (Item.Description); elsif Name = "disabled" then return Util.Beans.Objects.To_Object (Item.Disabled); elsif Name = "escaped" then return Util.Beans.Objects.To_Object (Item.Escape); else return Util.Beans.Objects.Null_Object; end if; end; end Get_Value; -- ------------------------------ -- Select Item List -- ------------------------------ -- ------------------------------ -- Return an Object from the select item list. -- Returns a NULL object if the list is empty. -- ------------------------------ function To_Object (Item : in Select_Item_List) return Util.Beans.Objects.Object is begin if Item.List.Is_Null then return Util.Beans.Objects.Null_Object; else declare Bean : constant Select_Item_List_Access := new Select_Item_List; begin Bean.all := Item; return Util.Beans.Objects.To_Object (Bean.all'Access); end; end if; end To_Object; -- ------------------------------ -- Return the <b>Select_Item_List</b> instance from a generic bean object. -- Returns an empty list if the object does not hold a <b>Select_Item_List</b>. -- ------------------------------ function To_Select_Item_List (Object : in Util.Beans.Objects.Object) return Select_Item_List is Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Object); Result : Select_Item_List; begin if Bean = null then return Result; end if; if not (Bean.all in Select_Item_List'Class) then return Result; end if; Result := Select_Item_List (Bean.all); return Result; end To_Select_Item_List; -- ------------------------------ -- Get the number of elements in the list. -- ------------------------------ overriding function Get_Count (From : in Select_Item_List) return Natural is begin return From.Length; end Get_Count; -- ------------------------------ -- Set the current row index. Valid row indexes start at 1. -- ------------------------------ overriding procedure Set_Row_Index (From : in out Select_Item_List; Index : in Natural) is begin From.Current := From.Get_Select_Item (Index); From.Row := Util.Beans.Objects.To_Object (From.Current'Unchecked_Access, Util.Beans.Objects.STATIC); end Set_Row_Index; -- ------------------------------ -- Get the element at the current row index. -- ------------------------------ overriding function Get_Row (From : in Select_Item_List) return Util.Beans.Objects.Object is begin return From.Row; end Get_Row; -- ------------------------------ -- Get the number of items in the list. -- ------------------------------ function Length (List : in Select_Item_List) return Natural is begin if List.List.Is_Null then return 0; else return Natural (List.List.Value.List.Length); end if; end Length; -- ------------------------------ -- Get the select item from the list -- ------------------------------ function Get_Select_Item (List : in Select_Item_List'Class; Pos : in Positive) return Select_Item is begin if List.List.Is_Null then raise Constraint_Error with "Select item list is empty"; end if; return List.List.Value.List.Element (Pos); end Get_Select_Item; -- ------------------------------ -- Add the item at the end of the list. -- ------------------------------ procedure Append (List : in out Select_Item_List; Item : in Select_Item'Class) is begin if List.List.Is_Null then List.List := Select_Item_Vector_Refs.Create; end if; List.List.Value.List.Append (Select_Item (Item)); end Append; -- ------------------------------ -- Add the item at the end of the list. This is a shortcut for -- Append (Create_List_Item (Label, Value)) -- ------------------------------ procedure Append (List : in out Select_Item_List; Label : in String; Value : in String) is begin List.Append (Create_Select_Item (Label, Value)); end Append; -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Select_Item_List; Name : in String) return Util.Beans.Objects.Object is pragma Unreferenced (From, Name); begin return Util.Beans.Objects.Null_Object; end Get_Value; end ASF.Models.Selects;
NCommander/dnscatcher
Ada
1,542
ads
-- Copyright 2019 Michael Casadevall <[email protected]> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- sell copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. -- @summary -- The DNSCatcher.DNS.Processor contains all data manipulation routines -- -- @description -- This package hierarchy handles wire transformations (both to and from) for -- parsing DNS requests and creating DNS requests -- -- This top level package is currently empty, but defines the submodules -- required for processing -- package DNSCatcher.DNS.Processor is end DNSCatcher.DNS.Processor;
reznikmm/matreshka
Ada
8,307
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools 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$ ------------------------------------------------------------------------------ package body Configure.Component_Switches is -------------------- -- Component_Name -- -------------------- function Create (Name : String; Description : String; Enabled : Boolean := True; Libdir_Enabled : Boolean := False) return Component_Switches is begin return (Name => +Name, Description => +Description, Enable => Enabled, Libdir_Enabled => Libdir_Enabled, others => <>); end Create; ------------------- -- Enable_Libdir -- ------------------- procedure Enable_Libdir (Self : in out Component_Switches'Class; Enabled : Boolean) is begin Self.Libdir_Enabled := Enabled; end Enable_Libdir; ---------- -- Help -- ---------- function Help (Self : Component_Switches'Class) return Unbounded_String_Vector is procedure Append (Help : in out Unbounded_String_Vector; Switch : Unbounded_String; Description : Unbounded_String); ------------ -- Append -- ------------ procedure Append (Help : in out Unbounded_String_Vector; Switch : Unbounded_String; Description : Unbounded_String) is Stop : constant := 26; Line : Unbounded_String := " " & Switch; begin if Length (Line) > Stop then Help.Append (Line); Help.Append (Stop * ' ' & Description); else Head (Line, Stop, ' '); Append (Line, Description); Help.Append (Line); end if; end Append; begin return Result : Unbounded_String_Vector do if Self.Enable then Append (Result, "--enable-" & Self.Name, "enable " & Self.Description); else Append (Result, "--disable-" & Self.Name, "enable " & Self.Description); end if; if Self.Libdir_Enabled then Append (Result, "--with-" & Self.Name & "-libdir=ARG", +" lookup for libraries in ARG"); end if; end return; end Help; ------------------------- -- Is_Enable_Specified -- ------------------------- function Is_Enable_Specified (Self : Component_Switches'Class) return Boolean is begin return Self.Enable_Specified; end Is_Enable_Specified; ---------------- -- Is_Enabled -- ---------------- function Is_Enabled (Self : Component_Switches'Class) return Boolean is begin return Self.Enable; end Is_Enabled; ------------------------- -- Is_Libdir_Specified -- ------------------------- function Is_Libdir_Specified (Self : Component_Switches'Class) return Boolean is begin return Self.Libdir_Specified; end Is_Libdir_Specified; ------------ -- Libdir -- ------------ function Libdir (Self : Component_Switches'Class) return Unbounded_String is begin -- XXX Synthetic value should be constructed then necessary. return Self.Libdir; end Libdir; -------------------- -- Parse_Switches -- -------------------- procedure Parse_Switches (Self : in out Component_Switches'Class; Arguments : in out Unbounded_String_Vector) is Enable : constant Unbounded_String := "--enable-" & Self.Name; Disable : constant Unbounded_String := "--disable-" & Self.Name; Within : constant Unbounded_String := "--with-" & Self.Name; Without : constant Unbounded_String := "--without-" & Self.Name; Libdir : constant Unbounded_String := "--with-" & Self.Name & "-libdir"; Index : Positive := 1; begin while Index <= Integer (Arguments.Length) loop declare Argument : constant Unbounded_String := Arguments.Element (Index); begin if Argument = Enable or Argument = Within then Self.Enable := True; Self.Enable_Specified := True; Arguments.Delete (Index); elsif Argument = Disable or Argument = Without then Self.Enable := False; Self.Enable_Specified := True; Arguments.Delete (Index); elsif Self.Libdir_Enabled and then Length (Argument) > Length (Libdir) and then Slice (Argument, 1, Length (Libdir)) = Libdir and then Element (Argument, Length (Libdir) + 1) = '=' then Self.Libdir := Unbounded_Slice (Argument, Length (Libdir) + 2, Length (Argument)); Self.Libdir_Specified := True; Self.Enable := True; Arguments.Delete (Index); else Index := Index + 1; end if; end; end loop; end Parse_Switches; end Configure.Component_Switches;
bdrewery/synth
Ada
9,099
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt -- GCC 6.0 only (skip Container_Checks until identified need arises) pragma Suppress (Tampering_Check); with Ada.Text_IO; with Ada.Calendar; with Ada.Containers.Hashed_Maps; with Ada.Containers.Ordered_Sets; with Ada.Containers.Vectors; with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Exceptions; with JohnnyText; with Parameters; with Definitions; use Definitions; private with Replicant.Platform; package PortScan is package JT renames JohnnyText; package AC renames Ada.Containers; package CAL renames Ada.Calendar; package AD renames Ada.Directories; package EX renames Ada.Exceptions; package TIO renames Ada.Text_IO; package LAT renames Ada.Characters.Latin_1; package PM renames Parameters; type count_type is (total, success, failure, ignored, skipped); type dim_handlers is array (count_type) of TIO.File_Type; type port_id is private; port_match_failed : constant port_id; -- Scan the entire ports tree in order with a single, non-recursive pass -- Return True on success function scan_entire_ports_tree (portsdir : String) return Boolean; -- Starting with a single port, recurse to determine a limited but complete -- dependency tree. Repeated calls will augment already existing data. -- Return True on success function scan_single_port (catport : String; always_build : Boolean; fatal : out Boolean) return Boolean; -- This procedure causes the reverse dependencies to be calculated, and -- then the extended (recursive) reverse dependencies. The former is -- used progressively to determine when a port is free to build and the -- latter sets the build priority. procedure set_build_priority; -- Wipe out all scan data so new scan can be performed procedure reset_ports_tree; -- Returns the number of cores. The set_cores procedure must be run first. -- set_cores was private previously, but we need the information to set -- intelligent defaults for the configuration file. procedure set_cores; function cores_available return cpu_range; -- Return " (port deleted)" if the catport doesn't exist -- Return " (directory empty)" if the directory exists but has no contents -- Return " (Makefile missing)" when makefile is missing -- otherwise return blank string function obvious_problem (portsdir, catport : String) return String; private package REP renames Replicant; package PLAT renames Replicant.Platform; max_ports : constant := 28000; scan_slave : constant builders := 9; ss_base : constant String := "/SL09"; dir_ports : constant String := "/xports"; chroot : constant String := "/usr/sbin/chroot "; type port_id is range -1 .. max_ports - 1; subtype port_index is port_id range 0 .. port_id'Last; port_match_failed : constant port_id := port_id'First; -- skip "package" because every port has same dependency on ports-mgmt/pkg -- except for pkg itself. Skip "test" because these dependencies are -- not required to build packages. type dependency_type is (fetch, extract, patch, build, library, runtime); subtype LR_set is dependency_type range library .. runtime; bmake_execution : exception; pkgng_execution : exception; make_garbage : exception; nonexistent_port : exception; circular_logic : exception; seek_failure : exception; unknown_format : exception; package subqueue is new AC.Vectors (Element_Type => port_index, Index_Type => port_index); package string_crate is new AC.Vectors (Element_Type => JT.Text, Index_Type => port_index, "=" => JT.SU."="); type queue_record is record ap_index : port_index; reverse_score : port_index; end record; -- Functions for ranking_crate definitions function "<" (L, R : queue_record) return Boolean; package ranking_crate is new AC.Ordered_Sets (Element_Type => queue_record); -- Functions for portkey_crate and package_crate definitions function port_hash (key : JT.Text) return AC.Hash_Type; package portkey_crate is new AC.Hashed_Maps (Key_Type => JT.Text, Element_Type => port_index, Hash => port_hash, Equivalent_Keys => JT.equivalent); package package_crate is new AC.Hashed_Maps (Key_Type => JT.Text, Element_Type => Boolean, Hash => port_hash, Equivalent_Keys => JT.equivalent); -- Functions for block_crate definitions function block_hash (key : port_index) return AC.Hash_Type; function block_ekey (left, right : port_index) return Boolean; package block_crate is new AC.Hashed_Maps (Key_Type => port_index, Element_Type => port_index, Hash => block_hash, Equivalent_Keys => block_ekey); type port_record is record sequence_id : port_index := 0; key_cursor : portkey_crate.Cursor := portkey_crate.No_Element; jobs : builders := 1; ignore_reason : JT.Text := JT.blank; port_version : JT.Text := JT.blank; package_name : JT.Text := JT.blank; pkg_dep_query : JT.Text := JT.blank; ignored : Boolean := False; scanned : Boolean := False; rev_scanned : Boolean := False; unlist_failed : Boolean := False; work_locked : Boolean := False; scan_locked : Boolean := False; pkg_present : Boolean := False; remote_pkg : Boolean := False; never_remote : Boolean := False; deletion_due : Boolean := False; use_procfs : Boolean := False; use_linprocfs : Boolean := False; reverse_score : port_index := 0; min_librun : Natural := 0; librun : block_crate.Map; blocked_by : block_crate.Map; blocks : block_crate.Map; all_reverse : block_crate.Map; options : package_crate.Map; end record; type port_record_access is access all port_record; type dim_make_queue is array (scanners) of subqueue.Vector; type dim_progress is array (scanners) of port_index; type dim_all_ports is array (port_index) of aliased port_record; all_ports : dim_all_ports; ports_keys : portkey_crate.Map; portlist : portkey_crate.Map; make_queue : dim_make_queue; mq_progress : dim_progress := (others => 0); rank_queue : ranking_crate.Set; number_cores : cpu_range := cpu_range'First; lot_number : scanners := 1; lot_counter : port_index := 0; last_port : port_index := 0; prescanned : Boolean := False; procedure iterate_reverse_deps; procedure iterate_drill_down; procedure populate_set_depends (target : port_index; catport : String; line : JT.Text; dtype : dependency_type); procedure populate_set_options (target : port_index; line : JT.Text; on : Boolean); procedure populate_port_data (target : port_index); procedure populate_port_data_fpc (target : port_index); procedure populate_port_data_nps (target : port_index); procedure drill_down (next_target : port_index; original_target : port_index); -- subroutines for populate_port_data procedure prescan_ports_tree (portsdir : String); procedure grep_Makefile (portsdir, category : String); procedure walk_all_subdirectories (portsdir, category : String); procedure wipe_make_queue; procedure parallel_deep_scan (success : out Boolean; show_progress : Boolean); -- some helper routines function find_colon (Source : String) return Natural; function scrub_phase (Source : String) return JT.Text; function get_catport (PR : port_record) return String; function scan_progress return String; function get_max_lots return scanners; function get_pkg_name (origin : String) return String; function timestamp (hack : CAL.Time; www_format : Boolean := False) return String; function clean_up_pkgsrc_ignore_reason (dirty_string : String) return JT.Text; type dim_counters is array (count_type) of Natural; -- bulk run variables Flog : dim_handlers; start_time : CAL.Time; stop_time : CAL.Time; scan_start : CAL.Time; scan_stop : CAL.Time; bld_counter : dim_counters := (0, 0, 0, 0, 0); end PortScan;
stcarrez/ada-asf
Ada
6,648
adb
----------------------------------------------------------------------- -- asf-beans-resolvers -- Resolver to create and give access to managed beans -- Copyright (C) 2013, 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 ASF.Sessions; with ASF.Beans.Params; with ASF.Beans.Flash; with ASF.Beans.Globals; with ASF.Beans.Headers; with ASF.Beans.Requests; package body ASF.Beans.Resolvers is -- ------------------------------ -- Initialize the EL resolver to use the application bean factory and the given request. -- ------------------------------ procedure Initialize (Resolver : in out ELResolver; App : in ASF.Applications.Main.Application_Access; Request : in ASF.Requests.Request_Access) is begin Resolver.Application := App; Resolver.Request := Request; Resolver.Attributes_Access := Resolver.Attributes'Unchecked_Access; end Initialize; -- ------------------------------ -- Resolve the name represented by <tt>Name</tt> according to a base object <tt>Base</tt>. -- The resolver tries to look first in pre-defined objects (params, flash, headers, initParam). -- It then looks in the request and session attributes for the value. If the value was -- not in the request or session, it uses the application bean factory to create the -- new managed bean and adds it to the request or session. -- ------------------------------ overriding function Get_Value (Resolver : in ELResolver; Context : in EL.Contexts.ELContext'Class; Base : access Util.Beans.Basic.Readonly_Bean'Class; Name : in Ada.Strings.Unbounded.Unbounded_String) return Util.Beans.Objects.Object is use type Util.Beans.Basic.Readonly_Bean_Access; use type ASF.Requests.Request_Access; Key : constant String := To_String (Name); begin if Base /= null then return Base.Get_Value (Key); elsif Key = ASF.Beans.Params.PARAM_ATTRIBUTE_NAME then return ASF.Beans.Params.Instance; elsif Key = ASF.Beans.Headers.HEADER_ATTRIBUTE_NAME then return ASF.Beans.Headers.Instance; elsif Key = ASF.Beans.Flash.FLASH_ATTRIBUTE_NAME then return ASF.Beans.Flash.Instance; elsif Key = ASF.Beans.Globals.INIT_PARAM_ATTRIBUTE_NAME then return ASF.Beans.Globals.Instance; elsif Key = ASF.Beans.Requests.REQUEST_ATTRIBUTE_NAME then return ASF.Beans.Requests.Instance; end if; declare Result : Util.Beans.Objects.Object; Scope : Scope_Type; Bean : Util.Beans.Basic.Readonly_Bean_Access; -- Look in the resolver's attributes first. Pos : constant Util.Beans.Objects.Maps.Cursor := Resolver.Attributes.Find (Key); begin if Util.Beans.Objects.Maps.Has_Element (Pos) then return Util.Beans.Objects.Maps.Element (Pos); elsif Resolver.Request /= null then Result := Resolver.Request.Get_Attribute (Key); if not Util.Beans.Objects.Is_Null (Result) then return Result; end if; -- If there is a session, look if the attribute is defined there. declare Session : ASF.Sessions.Session := Resolver.Request.Get_Session; begin if Session.Is_Valid then Result := Session.Get_Attribute (Key); if not Util.Beans.Objects.Is_Null (Result) then return Result; end if; end if; Resolver.Application.Create (Name, Context, Bean, Scope); if Bean = null then return Resolver.Application.Get_Global (Name, Context); end if; Result := Util.Beans.Objects.To_Object (Bean); if Scope = SESSION_SCOPE then Session.Set_Attribute (Name => Key, Value => Result); else Resolver.Request.Set_Attribute (Name => Key, Value => Result); end if; return Result; end; else Resolver.Application.Create (Name, Context, Bean, Scope); if Bean = null then return Resolver.Application.Get_Global (Name, Context); end if; Result := Util.Beans.Objects.To_Object (Bean); Resolver.Attributes_Access.Include (Key, Result); return Result; end if; end; end Get_Value; -- ------------------------------ -- Sets the value represented by the <tt>Name</tt> in the base object <tt>Base</tt>. -- If there is no <tt>Base</tt> object, the request attribute with the given name is -- updated to the given value. -- ------------------------------ overriding procedure Set_Value (Resolver : in out ELResolver; Context : in EL.Contexts.ELContext'Class; Base : access Util.Beans.Basic.Bean'Class; Name : in Ada.Strings.Unbounded.Unbounded_String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Context); Key : constant String := To_String (Name); begin if Base /= null then Base.Set_Value (Name => Key, Value => Value); else Resolver.Request.Set_Attribute (Name => Key, Value => Value); end if; end Set_Value; -- ------------------------------ -- Initialize the resolver. -- ------------------------------ overriding procedure Initialize (Resolver : in out ELResolver) is begin Resolver.Attributes_Access := Resolver.Attributes'Unchecked_Access; end Initialize; end ASF.Beans.Resolvers;
AdaCore/Ada_Drivers_Library
Ada
5,067
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This demo uses four channels of a single timer to make four LEDs blink -- at four different rates, without requiring periodic tasks to drive them. -- Because it uses four LEDs it runs on the STM32F4_Discovery board. Using -- a board with fewer LEDs is possible but less interesting. In that case, -- change the number of channels driven (and interrupts generated) to match -- the number of LEDs available. -- The file declares the interrupt handler and the timer values for the -- demonstration. with Ada.Interrupts.Names; use Ada.Interrupts.Names; with STM32; use STM32; with STM32.Device; use STM32.Device; with STM32.Timers; use STM32.Timers; with HAL; use HAL; package STM32F4_Timer_Interrupts is -- These values are set so that we get the four LEDs blinking at the -- desired rates indicated below. The specific LEDs (colors) associated -- with the rates are arbitrary (i.e., different LEDs could be associated -- with the channels). By controlling the rates at which the channels -- generate the interrupts we control the rates at which the LEDs blink. SystemCoreClock : constant UInt32 := System_Clock_Frequencies.SYSCLK; Prescaler : constant UInt16 := UInt16 (((SystemCoreClock / 2) / 6000) - 1); Channel_1_Period : constant := 6000 - 1; -- 1 sec Channel_2_Period : constant := ((Channel_1_Period + 1) / 2) - 1; -- 1/2 sec Channel_3_Period : constant := ((Channel_2_Period + 1) / 2) - 1; -- 1/4 sec Channel_4_Period : constant := ((Channel_3_Period + 1) / 2) - 1; -- 1/8 sec -- A convenience array for the sake of using a loop to configure the timer -- channels Channel_Periods : constant array (Timer_Channel) of UInt32 := (Channel_1_Period, Channel_2_Period, Channel_3_Period, Channel_4_Period); -- The interrupt handling PO. There is no client API so there is nothing -- declared in the visible part. This declaration could reasonably be -- moved to the package body, but we leave it here to emphasize the -- design approach using interrupts. protected Handler is pragma Interrupt_Priority; private -- Whenever the timer interrupt occurs, the handler determines which -- channel has caused the interrupt and toggles the corresponding LED. -- It then increments the channel's compare value so that the timer -- will generate another interrupt on that channel after the required -- interval specific to that channel. procedure IRQ_Handler; pragma Attach_Handler (IRQ_Handler, TIM3_Interrupt); end Handler; end STM32F4_Timer_Interrupts;
reznikmm/matreshka
Ada
4,567
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Draw.Angle_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Angle_Attribute_Node is begin return Self : Draw_Angle_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Angle_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Angle_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Angle_Attribute, Draw_Angle_Attribute_Node'Tag); end Matreshka.ODF_Draw.Angle_Attributes;
charlie5/aShell
Ada
2,236
adb
with Ada.Text_IO; use Ada.Text_IO; with Shell; package body Process_Tests is use Ahven, Ahven.Framework; procedure Test_Status is use Shell; Process : Shell.Process; begin Assert (Status (Process) = Not_Started, "Process status should be 'Not_Started' not '" & Status (Process)'Image & "'"); Start (Process, "sleep 5"); -- Start (Process, "ls -R /"); Assert (Status (Process) = Running, "Process status should be 'Running' not '" & Status (Process)'Image & "'"); delay 1.0; Pause (Process); Assert (Status (Process) = Paused, "Process status should be 'Paused' not '" & Status (Process)'Image & "'"); Put_Line (Status (Process)'Image); delay 3.0; Resume (Process); Assert (Status (Process) = Running, "Process status should be 'Running' not '" & Status (Process)'Image & "'"); Wait_On (Process); Assert (Status (Process) = Normal_Exit, "Process status should be 'Normal_Exit' not '" & Status (Process)'Image & "'"); Process := Start ("ls /non_existant_file"); Wait_On (Process); Assert (Status (Process) = Failed_Exit, "Process status should be 'Failed_Exit' not '" & Status (Process)'Image & "'"); Process := Start ("sleep 2"); Interrupt (Process); Assert (Status (Process) = Interrupted, "Process status should be 'Interrupted' not '" & Status (Process)'Image & "'"); Process := Start ("sleep 2"); Kill (Process); Assert (Status (Process) = Killed, "Process status should be 'Killed' not '" & Status (Process)'Image & "'"); end Test_Status; overriding procedure Initialize (T : in out Test) is begin T.Set_Name ("Process Tests"); T.Add_Test_Routine (Test_Status'Access, "Process Status"); end Initialize; function Get_Test_Suite return Ahven.Framework.Test_Suite is Suite : Test_Suite := Ahven.Framework.Create_Suite ("Processes"); Test : Process_Tests.Test; begin Suite.Add_Static_Test (Test); return Suite; end Get_Test_Suite; end Process_Tests;
AdaCore/training_material
Ada
2,697
adb
------------------------------------------------------------------------------ -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with System; package body STM32F4.Device_Id is ID_Address : constant System.Address := System'To_Address (16#1FFF_7A10#); --------------- -- Unique_Id -- --------------- function Unique_Id return Device_Id_Image is Result : Device_Id_Image; for Result'Address use ID_Address; pragma Import (Ada, Result); begin return Result; end Unique_Id; --------------- -- Unique_Id -- --------------- function Unique_Id return Device_Id_Tuple is Result : Device_Id_Tuple; for Result'Address use ID_Address; begin return Result; end Unique_Id; end STM32F4.Device_Id;
Louis-Aime/Milesian_calendar_Ada
Ada
4,571
adb
-- Package body Milesian_calendar ---------------------------------------------------------------------------- -- Copyright Miletus 2016-2019 -- Permission is hereby granted, free of charge, to any person obtaining -- a copy of this software and associated documentation files (the -- "Software"), to deal in the Software without restriction, including -- without limitation the rights to use, copy, modify, merge, publish, -- distribute, sublicense, and/or sell copies of the Software, and to -- permit persons to whom the Software is furnished to do so, subject to -- the following conditions: -- 1. The above copyright notice and this permission notice shall be included -- in all copies or substantial portions of the Software. -- 2. Changes with respect to any former version shall be documented. -- -- The software is provided "as is", without warranty of any kind, -- express of implied, including but not limited to the warranties of -- merchantability, fitness for a particular purpose and noninfringement. -- In no event shall the authors of 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. -- Inquiries: www.calendriermilesien.org ------------------------------------------------------------------------------- -- Version 3 (M2019-01-16): back to pure Gregorian intercalation rule -- as it was in 2016 version. with Cycle_Computations; package body Milesian_calendar is package Julian_Day_cycle is new Cycle_computations.Integer_cycle_computations (Num => Julian_Day'Base); use Julian_Day_cycle; subtype computation_month is integer range 0..12; function is_long_Milesian_year -- Milesian long year just before bissextile (y : Historical_year_number) return boolean is y1 : Historical_year_number'Base := y+1; begin return y1 mod 4 = 0 and then (y1 mod 100 /= 0 or else (y1 mod 400 = 0)); end is_long_Milesian_year; function valid (date : milesian_date) return boolean is -- whether the given date is an existing one -- on elaboration, the basic range checks on record fields have been done begin return date.day <= 30 or else (date.month mod 2 = 0 and (date.month /= 12 or else is_long_Milesian_year(date.year))); end valid; function JD_to_Milesian (jd : Julian_Day) return Milesian_Date is cc : Cycle_coordinates := Decompose_cycle (jd-1721050, 146097); -- intialise current day for the computations to 1/1m/000 yc : Historical_year_number'Base := cc.Cycle*400; -- year component for computations initialised to base 0 mc : computation_month; -- bimester and monthe rank for computations -- cc.Phase holds is rank of day within quadricentury begin cc := Decompose_cycle_ceiled (cc.Phase, 36524, 4); -- cc.Cycle is rank of century in quadricentury, -- cc.Phase is rank of day within century. -- rank of century is 0 to 3, Phase can be 36524 if rank is 3. yc := yc + (cc.Cycle) * 100; -- base century cc := Decompose_cycle (cc.Phase, 1461); -- quadriannum yc := yc + cc.Cycle * 4; cc := Decompose_cycle_ceiled (cc.Phase, 365, 4); -- year in quadriannum yc := yc + cc.Cycle; -- here we get the year cc := Decompose_cycle (cc.Phase, 61); -- cycle is rank of bimester in year; phase is rank of day in bimester mc := cc.Cycle * 2; -- 0 to 10 cc := Decompose_cycle_ceiled (cc.Phase, 30, 2); -- whether firt (0) or second (1) month in bimester, -- and rank of day, 0 .. 30 if last month. return (year => yc, month => mc + cc.Cycle + 1, day => integer(cc.Phase) + 1); -- final month number and day number computed in return command. end JD_to_Milesian; function Milesian_to_JD (md : milesian_date) return julian_day is yc : Julian_Day'Base := md.year + 4800; -- year starting at -4800 in order to be positive; -- as a variant: we could start at -4000, forbidding years before -4000. mc : computation_month := md.month - 1; begin if not valid (md) then raise Time_Error; end if; return Julian_Day'Base (yc*365) -32115 + Julian_Day'Base (yc/4 -yc/100 +yc/400 +mc*30 +mc/2 +md.day); -- integer divisions yield integer quotients. end Milesian_to_JD; end Milesian_calendar;
pdaxrom/Kino2
Ada
15,591
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- TODO use Default_Character where appropriate -- This is an Ada version of ncurses -- I translated this because it tests the most features. with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Trace; use Terminal_Interface.Curses.Trace; with Ada.Text_IO; use Ada.Text_IO; with Ada.Characters.Latin_1; -- with Ada.Characters.Handling; with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings.Unbounded; with ncurses2.util; use ncurses2.util; with ncurses2.getch_test; with ncurses2.attr_test; with ncurses2.color_test; with ncurses2.demo_panels; with ncurses2.color_edit; with ncurses2.slk_test; with ncurses2.acs_display; with ncurses2.color_edit; with ncurses2.acs_and_scroll; with ncurses2.flushinp_test; with ncurses2.test_sgr_attributes; with ncurses2.menu_test; with ncurses2.demo_pad; with ncurses2.demo_forms; with ncurses2.overlap_test; with ncurses2.trace_set; with ncurses2.getopt; use ncurses2.getopt; package body ncurses2.m is use Int_IO; function To_trace (n : Integer) return Trace_Attribute_Set; procedure usage; procedure Set_Terminal_Modes; function Do_Single_Test (c : Character) return Boolean; function To_trace (n : Integer) return Trace_Attribute_Set is a : Trace_Attribute_Set := (others => False); m : Integer; rest : Integer; begin m := n mod 2; if 1 = m then a.Times := True; end if; rest := n / 2; m := rest mod 2; if 1 = m then a.Tputs := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Update := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Cursor_Move := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Character_Output := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Calls := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Virtual_Puts := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Input_Events := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.TTY_State := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Internal_Calls := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Character_Calls := True; end if; rest := rest / 2; m := rest mod 2; if 1 = m then a.Termcap_TermInfo := True; end if; return a; end To_trace; -- these are type Stdscr_Init_Proc; function rip_footer ( Win : Window; Columns : Column_Count) return Integer; pragma Convention (C, rip_footer); function rip_footer ( Win : Window; Columns : Column_Count) return Integer is begin Set_Background (Win, (Ch => ' ', Attr => (Reverse_Video => True, others => False), Color => 0)); Erase (Win); Move_Cursor (Win, 0, 0); Add (Win, "footer:" & Columns'Img & " columns"); Refresh_Without_Update (Win); return 0; -- Curses_OK; end rip_footer; function rip_header ( Win : Window; Columns : Column_Count) return Integer; pragma Convention (C, rip_header); function rip_header ( Win : Window; Columns : Column_Count) return Integer is begin Set_Background (Win, (Ch => ' ', Attr => (Reverse_Video => True, others => False), Color => 0)); Erase (Win); Move_Cursor (Win, 0, 0); Add (Win, "header:" & Columns'Img & " columns"); -- 'Img is a GNAT extention Refresh_Without_Update (Win); return 0; -- Curses_OK; end rip_header; procedure usage is -- type Stringa is access String; use Ada.Strings.Unbounded; -- tbl : constant array (Positive range <>) of Stringa := ( tbl : constant array (Positive range <>) of Unbounded_String := ( To_Unbounded_String ("Usage: ncurses [options]"), To_Unbounded_String (""), To_Unbounded_String ("Options:"), To_Unbounded_String (" -a f,b set default-colors " & "(assumed white-on-black)"), To_Unbounded_String (" -d use default-colors if terminal " & "supports them"), To_Unbounded_String (" -e fmt specify format for soft-keys " & "test (e)"), To_Unbounded_String (" -f rip-off footer line " & "(can repeat)"), To_Unbounded_String (" -h rip-off header line " & "(can repeat)"), To_Unbounded_String (" -s msec specify nominal time for " & "panel-demo (default: 1, to hold)"), To_Unbounded_String (" -t mask specify default trace-level " & "(may toggle with ^T)") ); begin for n in tbl'Range loop Put_Line (Standard_Error, To_String (tbl (n))); end loop; -- exit(EXIT_FAILURE); -- TODO should we use Set_Exit_Status and throw and exception? end usage; procedure Set_Terminal_Modes is begin Set_Raw_Mode (SwitchOn => False); Set_Cbreak_Mode (SwitchOn => True); Set_Echo_Mode (SwitchOn => False); Allow_Scrolling (Mode => True); Use_Insert_Delete_Line (Do_Idl => True); Set_KeyPad_Mode (SwitchOn => True); end Set_Terminal_Modes; nap_msec : Integer := 1; function Do_Single_Test (c : Character) return Boolean is begin case c is when 'a' => getch_test; when 'b' => attr_test; when 'c' => if not Has_Colors then Cannot ("does not support color."); else color_test; end if; when 'd' => if not Has_Colors then Cannot ("does not support color."); elsif not Can_Change_Color then Cannot ("has hardwired color values."); else color_edit; end if; when 'e' => slk_test; when 'f' => acs_display; when 'o' => demo_panels (nap_msec); when 'g' => acs_and_scroll; when 'i' => flushinp_test (Standard_Window); when 'k' => test_sgr_attributes; when 'm' => menu_test; when 'p' => demo_pad; when 'r' => demo_forms; when 's' => overlap_test; when 't' => trace_set; when '?' => null; when others => return False; end case; return True; end Do_Single_Test; command : Character; my_e_param : Soft_Label_Key_Format := Four_Four; assumed_colors : Boolean := False; default_colors : Boolean := False; default_fg : Color_Number := White; default_bg : Color_Number := Black; -- nap_msec was an unsigned long integer in the C version, -- yet napms only takes an int! c : Integer; c2 : Character; optind : Integer := 1; -- must be initialized to one. type stringa is access String; optarg : getopt.stringa; length : Integer; tmpi : Integer; package myio is new Ada.Text_IO.Integer_IO (Integer); use myio; save_trace : Integer := 0; save_trace_set : Trace_Attribute_Set; function main return Integer is begin loop Qgetopt (c, Argument_Count, Argument'Access, "a:de:fhs:t:", optind, optarg); exit when c = -1; c2 := Character'Val (c); case c2 is when 'a' => -- Ada doesn't have scanf, it doesn't even have a -- regular expression library. assumed_colors := True; myio.Get (optarg.all, Integer (default_fg), length); myio.Get (optarg.all (length + 2 .. optarg.all'Length), Integer (default_bg), length); when 'd' => default_colors := True; when 'e' => myio.Get (optarg.all, tmpi, length); if Integer (tmpi) > 3 then usage; return 1; end if; my_e_param := Soft_Label_Key_Format'Val (tmpi); when 'f' => Rip_Off_Lines (-1, rip_footer'Access); when 'h' => Rip_Off_Lines (1, rip_header'Access); when 's' => myio.Get (optarg.all, nap_msec, length); when 't' => myio.Get (optarg.all, save_trace, length); when others => usage; return 1; end case; end loop; -- the C version had a bunch of macros here. -- if (!isatty(fileno(stdin))) -- isatty is not available in the standard Ada so skip it. save_trace_set := To_trace (save_trace); Trace_On (save_trace_set); Init_Soft_Label_Keys (my_e_param); Init_Screen; Set_Background (Ch => (Ch => Blank, Attr => Normal_Video, Color => Color_Pair'First)); if Has_Colors then Start_Color; if default_colors then Use_Default_Colors; elsif assumed_colors then Assume_Default_Colors (default_fg, default_bg); end if; end if; Set_Terminal_Modes; Save_Curses_Mode (Curses); End_Windows; -- TODO add macro #if blocks. Put_Line ("Welcome to " & Curses_Version & ". Press ? for help."); loop Put_Line ("This is the ncurses main menu"); Put_Line ("a = keyboard and mouse input test"); Put_Line ("b = character attribute test"); Put_Line ("c = color test pattern"); Put_Line ("d = edit RGB color values"); Put_Line ("e = exercise soft keys"); Put_Line ("f = display ACS characters"); Put_Line ("g = display windows and scrolling"); Put_Line ("i = test of flushinp()"); Put_Line ("k = display character attributes"); Put_Line ("m = menu code test"); Put_Line ("o = exercise panels library"); Put_Line ("p = exercise pad features"); Put_Line ("q = quit"); Put_Line ("r = exercise forms code"); Put_Line ("s = overlapping-refresh test"); Put_Line ("t = set trace level"); Put_Line ("? = repeat this command summary"); Put ("> "); Flush; command := Ada.Characters.Latin_1.NUL; -- get_input: -- loop declare Ch : Character; begin Get (Ch); -- TODO if read(ch) <= 0 -- TODO ada doesn't have an Is_Space function command := Ch; -- TODO if ch = '\n' or '\r' are these in Ada? end; -- end loop get_input; declare begin if Do_Single_Test (command) then Flush_Input; Set_Terminal_Modes; Reset_Curses_Mode (Curses); Clear; Refresh; End_Windows; if command = '?' then Put_Line ("This is the ncurses capability tester."); Put_Line ("You may select a test from the main menu by " & "typing the"); Put_Line ("key letter of the choice (the letter to left " & "of the =)"); Put_Line ("at the > prompt. The commands `x' or `q' will " & "exit."); end if; -- continue; --why continue in the C version? end if; exception when Curses_Exception => End_Windows; end; exit when command = 'q'; end loop; return 0; -- TODO ExitProgram(EXIT_SUCCESS); end main; end ncurses2.m;
sungyeon/drake
Ada
7,007
adb
pragma Check_Policy (Validate => Disable); -- with Ada.Strings.Naked_Maps.Debug; with Ada.UCD.Simple_Case_Mapping; with System.Once; with System.Reference_Counting; package body Ada.Strings.Naked_Maps.Case_Mapping is use type UCD.Difference_Base; use type UCD.UCS_4; procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type); procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type) is begin for J in Table'Range loop declare F : UCD.Map_16x1_Item_Type renames Table (J); begin Mapping.From (I) := Character_Type'Val (F.Code); Mapping.To (I) := Character_Type'Val (F.Mapping); end; I := I + 1; end loop; end Decode; procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base); procedure Decode ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base) is begin for J in Table'Range loop declare F : UCD.Simple_Case_Mapping.Compressed_Item_Type renames Table (J); From : Character_Type := Character_Type'Val (UCD.Difference_Base (F.Start) + Offset); To : Character_Type := Character_Type'Val (Character_Type'Pos (From) + F.Diff); begin for K in 1 .. F.Length loop Mapping.From (I) := From; Mapping.To (I) := To; From := Character_Type'Succ (From); To := Character_Type'Succ (To); I := I + 1; end loop; end; end loop; end Decode; procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type); procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Map_16x1_Type) is begin for J in Table'Range loop declare F : UCD.Map_16x1_Item_Type renames Table (J); begin Mapping.From (I) := Character_Type'Val (F.Mapping); Mapping.To (I) := Character_Type'Val (F.Code); end; I := I + 1; end loop; end Decode_Reverse; procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base); procedure Decode_Reverse ( Mapping : in out Character_Mapping_Data; I : in out Positive; Table : UCD.Simple_Case_Mapping.Compressed_Type; Offset : UCD.Difference_Base) is begin for J in Table'Range loop declare F : UCD.Simple_Case_Mapping.Compressed_Item_Type renames Table (J); To : Character_Type := Character_Type'Val (UCD.Difference_Base (F.Start) + Offset); From : Character_Type := Character_Type'Val (Character_Type'Pos (To) + F.Diff); begin for K in 1 .. F.Length loop Mapping.From (I) := From; Mapping.To (I) := To; From := Character_Type'Succ (From); To := Character_Type'Succ (To); I := I + 1; end loop; end; end loop; end Decode_Reverse; type Character_Mapping_Access_With_Pool is access Character_Mapping_Data; -- lower case map L_Mapping : Character_Mapping_Access_With_Pool; L_Mapping_Flag : aliased System.Once.Flag := 0; procedure L_Mapping_Init; procedure L_Mapping_Init is Mapping : Character_Mapping_Access_With_Pool renames L_Mapping; begin Mapping := new Character_Mapping_Data'( Length => UCD.Simple_Case_Mapping.L_Total, Reference_Count => System.Reference_Counting.Static, From => <>, To => <>); declare I : Positive := Mapping.From'First; begin -- 16#0041# Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX_Compressed, Offset => 0); -- 16#0100# .. Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX); -- 16#0130# .. Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.DL_Table_XXXX); -- 16#10400# Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_1XXXX_Compressed, Offset => 16#10000#); pragma Assert (I = Mapping.From'Last + 1); end; Sort (Mapping.From, Mapping.To); pragma Check (Validate, Debug.Valid (Mapping.all)); end L_Mapping_Init; -- implementation of lower case map function Lower_Case_Map return not null Character_Mapping_Access is begin System.Once.Initialize (L_Mapping_Flag'Access, L_Mapping_Init'Access); return Character_Mapping_Access (L_Mapping); end Lower_Case_Map; -- upper case map U_Mapping : Character_Mapping_Access_With_Pool; U_Mapping_Flag : aliased System.Once.Flag := 0; procedure U_Mapping_Init; procedure U_Mapping_Init is Mapping : Character_Mapping_Access_With_Pool renames U_Mapping; begin Mapping := new Character_Mapping_Data'( Length => UCD.Simple_Case_Mapping.U_Total, Reference_Count => System.Reference_Counting.Static, From => <>, To => <>); declare I : Positive := Mapping.From'First; begin -- 16#0061# Decode_Reverse ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX_Compressed, Offset => 0); -- 16#00B5# .. Decode ( Mapping.all, I, UCD.Simple_Case_Mapping.DU_Table_XXXX); -- 16#0101# .. Decode_Reverse ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_XXXX); -- 16#10440# Decode_Reverse ( Mapping.all, I, UCD.Simple_Case_Mapping.SL_Table_1XXXX_Compressed, Offset => 16#10000#); pragma Assert (I = Mapping.From'Last + 1); end; Sort (Mapping.From, Mapping.To); pragma Check (Validate, Debug.Valid (Mapping.all)); end U_Mapping_Init; -- implementation of upper case map function Upper_Case_Map return not null Character_Mapping_Access is begin System.Once.Initialize (U_Mapping_Flag'Access, U_Mapping_Init'Access); return Character_Mapping_Access (U_Mapping); end Upper_Case_Map; end Ada.Strings.Naked_Maps.Case_Mapping;
Rodeo-McCabe/orka
Ada
6,390
adb
-- 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 Ada.Unchecked_Conversion; with GL.API; with GL.Enums.Getter; package body GL.Buffers is use type Rasterization.Face_Selector; procedure Set_Color_Mask (Value : Colors.Enabled_Color) is begin API.Color_Mask.Ref (Low_Level.Bool (Value (Colors.R)), Low_Level.Bool (Value (Colors.G)), Low_Level.Bool (Value (Colors.B)), Low_Level.Bool (Value (Colors.A))); end Set_Color_Mask; procedure Set_Color_Mask (Index : Draw_Buffer_Index; Value : Colors.Enabled_Color) is begin API.Color_Mask_Indexed.Ref (Index, Low_Level.Bool (Value (Colors.R)), Low_Level.Bool (Value (Colors.G)), Low_Level.Bool (Value (Colors.B)), Low_Level.Bool (Value (Colors.A))); end Set_Color_Mask; function Color_Mask (Index : Draw_Buffer_Index) return Colors.Enabled_Color is Value : Colors.Enabled_Color; begin API.Get_Enabled_Color.Ref (Enums.Getter.Color_Writemask, Index, Value); return Value; end Color_Mask; procedure Set_Depth_Function (Func : Compare_Function) is begin API.Depth_Func.Ref (Func); end Set_Depth_Function; function Depth_Function return Compare_Function is Value : Compare_Function := Compare_Function'First; begin API.Get_Compare_Function.Ref (Enums.Getter.Depth_Func, Value); return Value; end Depth_Function; procedure Set_Depth_Mask (Enabled : Boolean) is begin API.Depth_Mask.Ref (Low_Level.Bool (Enabled)); end Set_Depth_Mask; function Depth_Mask return Boolean is Value : Low_Level.Bool := Low_Level.Bool (True); begin API.Get_Boolean.Ref (Enums.Getter.Depth_Writemask, Value); return Boolean (Value); end Depth_Mask; procedure Set_Stencil_Function (Face : Rasterization.Face_Selector; Func : Compare_Function; Ref : Int; Mask : UInt) is begin API.Stencil_Func_Separate.Ref (Face, Func, Ref, Mask); end Set_Stencil_Function; function Stencil_Function (Face : Single_Face_Selector) return Compare_Function is Value : Compare_Function := Compare_Function'First; begin if Face = Rasterization.Front then API.Get_Compare_Function.Ref (Enums.Getter.Stencil_Func, Value); else API.Get_Compare_Function.Ref (Enums.Getter.Stencil_Back_Func, Value); end if; return Value; end Stencil_Function; function Stencil_Reference_Value (Face : Single_Face_Selector) return Int is Value : Int := 0; begin if Face = Rasterization.Front then API.Get_Integer.Ref (Enums.Getter.Stencil_Ref, Value); else API.Get_Integer.Ref (Enums.Getter.Stencil_Back_Ref, Value); end if; return Value; end Stencil_Reference_Value; function Stencil_Value_Mask (Face : Single_Face_Selector) return UInt is Value : UInt := 0; begin if Face = Rasterization.Front then API.Get_Unsigned_Integer.Ref (Enums.Getter.Stencil_Value_Mask, Value); else API.Get_Unsigned_Integer.Ref (Enums.Getter.Stencil_Back_Value_Mask, Value); end if; return Value; end Stencil_Value_Mask; procedure Set_Stencil_Operation (Face : Rasterization.Face_Selector; Stencil_Fail : Buffers.Stencil_Action; Depth_Fail : Buffers.Stencil_Action; Depth_Pass : Buffers.Stencil_Action) is begin API.Stencil_Op_Separate.Ref (Face, Stencil_Fail, Depth_Fail, Depth_Pass); end Set_Stencil_Operation; function Stencil_Operation_Stencil_Fail (Face : Single_Face_Selector) return Buffers.Stencil_Action is Value : Buffers.Stencil_Action := Buffers.Stencil_Action'First; begin if Face = Rasterization.Front then API.Get_Stencil_Action.Ref (Enums.Getter.Stencil_Fail, Value); else API.Get_Stencil_Action.Ref (Enums.Getter.Stencil_Back_Fail, Value); end if; return Value; end Stencil_Operation_Stencil_Fail; function Stencil_Operation_Depth_Fail (Face : Single_Face_Selector) return Buffers.Stencil_Action is Value : Buffers.Stencil_Action := Buffers.Stencil_Action'First; begin if Face = Rasterization.Front then API.Get_Stencil_Action.Ref (Enums.Getter.Stencil_Pass_Depth_Fail, Value); else API.Get_Stencil_Action.Ref (Enums.Getter.Stencil_Back_Pass_Depth_Fail, Value); end if; return Value; end Stencil_Operation_Depth_Fail; function Stencil_Operation_Depth_Pass (Face : Single_Face_Selector) return Buffers.Stencil_Action is Value : Buffers.Stencil_Action := Buffers.Stencil_Action'First; begin if Face = Rasterization.Front then API.Get_Stencil_Action.Ref (Enums.Getter.Stencil_Pass_Depth_Pass, Value); else API.Get_Stencil_Action.Ref (Enums.Getter.Stencil_Back_Pass_Depth_Pass, Value); end if; return Value; end Stencil_Operation_Depth_Pass; procedure Set_Stencil_Mask (Value : UInt) is Face : constant Rasterization.Face_Selector := Rasterization.Front_And_Back; begin Set_Stencil_Mask (Face, Value); end Set_Stencil_Mask; procedure Set_Stencil_Mask (Face : Rasterization.Face_Selector; Value : UInt) is begin API.Stencil_Mask_Separate.Ref (Face, Value); end Set_Stencil_Mask; function Stencil_Mask (Face : Single_Face_Selector) return UInt is Value : UInt := 0; begin if Face = Rasterization.Front then API.Get_Unsigned_Integer.Ref (Enums.Getter.Stencil_Writemask, Value); else API.Get_Unsigned_Integer.Ref (Enums.Getter.Stencil_Back_Writemask, Value); end if; return Value; end Stencil_Mask; end GL.Buffers;
zhmu/ananas
Ada
174
adb
package body inline_scope_p is procedure Assert (Expr : Boolean; Str : String) is begin if Expr then null; end if; end Assert; end;
reznikmm/matreshka
Ada
3,591
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.DG.Markers.Hash is new AMF.Elements.Generic_Hash (DG_Marker, DG_Marker_Access);
reznikmm/gela
Ada
1,453
ads
with Gela.Type_Managers; private package Gela.Resolve.Each is pragma Preelaborate; function Expression (Self : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) return Gela.Interpretations.Expression_Iterators.Forward_Iterator'Class; -- Resolve given interpretation set as expression. So ignore symbol and -- others non-expression interpretations. Translate defining name into -- expression. function Prefer_Root (Self : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) return Gela.Interpretations.Expression_Iterators.Forward_Iterator'Class; -- The same as Expression, but prefere root_integer and root_read over -- other interpretations. function Prefix (Self : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) return Gela.Interpretations.Expression_Iterators.Forward_Iterator'Class; -- The same as Expression, but add implicit dereference interpretations. end Gela.Resolve.Each;
AdaCore/spat
Ada
3,408
ads
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------------ -- -- SPARK Proof Analysis Tool -- -- S.P.A.T. - Object representing an entity (name) with a file location based -- on a single source line (no column information). -- ------------------------------------------------------------------------------ with SPAT.Entity; with SPAT.Field_Names; with SPAT.Preconditions; package SPAT.Entity_Line is use all type GNATCOLL.JSON.JSON_Value_Type; --------------------------------------------------------------------------- -- Has_Required_Fields --------------------------------------------------------------------------- function Has_Required_Fields (Object : in JSON_Value) return Boolean is (Preconditions.Ensure_Field (Object => Object, Field => Field_Names.File, Kind => JSON_String_Type) and Preconditions.Ensure_Field (Object => Object, Field => Field_Names.Line, Kind => JSON_Int_Type)); type T is new Entity.T with private; --------------------------------------------------------------------------- -- Create --------------------------------------------------------------------------- not overriding function Create (Object : in JSON_Value) return T with Pre => Has_Required_Fields (Object => Object); --------------------------------------------------------------------------- -- Image --------------------------------------------------------------------------- overriding function Image (This : T) return String; --------------------------------------------------------------------------- -- Source_File --------------------------------------------------------------------------- not overriding function Source_File (This : in T) return Source_File_Name; --------------------------------------------------------------------------- -- Source_Line --------------------------------------------------------------------------- not overriding function Source_Line (This : in T) return Natural; private type T is new Entity.T with record -- These are source file references. File : Source_File_Name; Line : Natural; end record; --------------------------------------------------------------------------- -- Source_File --------------------------------------------------------------------------- not overriding function Source_File (This : in T) return Source_File_Name is (This.File); --------------------------------------------------------------------------- -- Source_Line --------------------------------------------------------------------------- not overriding function Source_Line (This : in T) return Natural is (This.Line); end SPAT.Entity_Line;
charlie5/cBound
Ada
1,511
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_end_list_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; minor_opcode : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; context_tag : aliased xcb.xcb_glx_context_tag_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_end_list_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_end_list_request_t.Item, Element_Array => xcb.xcb_glx_end_list_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_end_list_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_end_list_request_t.Pointer, Element_Array => xcb.xcb_glx_end_list_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_end_list_request_t;
Fabien-Chouteau/minisamd51_bsp
Ada
5,215
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with HAL; with SAM.Device; with SAM.Port; with SAM.SERCOM.I2C; with SAM.SERCOM.SPI; package Minisamd51 is procedure Turn_On_LED; -- Turn on the red spaceship LED procedure Turn_Off_LED; -- Turn off the red spaceship LED function Button_Pressed return Boolean; -- Return True if the button the left leg of MiniSAM is pressed procedure Set_RGB (Brightness : HAL.UInt5; R, G, B : HAL.UInt8); -- Control the "dotstar" RGB LED -- IOs -- I2C_Port : SAM.SERCOM.I2C.I2C_Device renames SAM.Device.I2C2; SPI_Port : SAM.SERCOM.SPI.SPI_Device renames SAM.Device.SPI1; D0 : SAM.Port.GPIO_Point renames SAM.Device.PA16; D1 : SAM.Port.GPIO_Point renames SAM.Device.PA17; D2 : SAM.Port.GPIO_Point renames SAM.Device.PA07; D3 : SAM.Port.GPIO_Point renames SAM.Device.PA19; D4 : SAM.Port.GPIO_Point renames SAM.Device.PA20; D5 : SAM.Port.GPIO_Point renames SAM.Device.PA21; D9 : SAM.Port.GPIO_Point renames SAM.Device.PA02; D10 : SAM.Port.GPIO_Point renames SAM.Device.PB08; D11 : SAM.Port.GPIO_Point renames SAM.Device.PB09; D12 : SAM.Port.GPIO_Point renames SAM.Device.PA04; D13 : SAM.Port.GPIO_Point renames SAM.Device.PA05; D14 : SAM.Port.GPIO_Point renames SAM.Device.PA06; AREF : SAM.Port.GPIO_Point renames SAM.Device.PA03; A0 : SAM.Port.GPIO_Point renames D9; A1 : SAM.Port.GPIO_Point renames D10; A2 : SAM.Port.GPIO_Point renames D11; A3 : SAM.Port.GPIO_Point renames D12; A4 : SAM.Port.GPIO_Point renames D13; A5 : SAM.Port.GPIO_Point renames D14; A6 : SAM.Port.GPIO_Point renames D2; DAC1 : SAM.Port.GPIO_Point renames D9; DAC0 : SAM.Port.GPIO_Point renames D13; LED : SAM.Port.GPIO_Point renames SAM.Device.PA15; Button : SAM.Port.GPIO_Point renames SAM.Device.PA00; RX : SAM.Port.GPIO_Point renames D0; TX : SAM.Port.GPIO_Point renames D1; private SWDIO : SAM.Port.GPIO_Point renames SAM.Device.PA30; SWCLK : SAM.Port.GPIO_Point renames SAM.Device.PA31; -- I2C -- SCL : SAM.Port.GPIO_Point renames SAM.Device.PA13; SDA : SAM.Port.GPIO_Point renames SAM.Device.PA12; -- SPI -- MOSI : SAM.Port.GPIO_Point renames SAM.Device.PB22; MISO : SAM.Port.GPIO_Point renames SAM.Device.PB23; SCK : SAM.Port.GPIO_Point renames SAM.Device.PA01; QSPI_SCK : SAM.Port.GPIO_Point renames SAM.Device.PB10; QSPI_CS : SAM.Port.GPIO_Point renames SAM.Device.PB11; QSPI_D0 : SAM.Port.GPIO_Point renames SAM.Device.PA08; QSPI_D1 : SAM.Port.GPIO_Point renames SAM.Device.PA09; QSPI_D2 : SAM.Port.GPIO_Point renames SAM.Device.PA10; QSPI_D3 : SAM.Port.GPIO_Point renames SAM.Device.PA11; DOTSTAR_CLK : SAM.Port.GPIO_Point renames SAM.Device.PB02; DOTSTAR_DATA : SAM.Port.GPIO_Point renames SAM.Device.PB03; end Minisamd51;
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.Table_Case_Sensitive_Attributes is pragma Preelaborate; type ODF_Table_Case_Sensitive_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Case_Sensitive_Attribute_Access is access all ODF_Table_Case_Sensitive_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Case_Sensitive_Attributes;
rogermc2/GA_Ada
Ada
5,726
adb
with Ada.Numerics.Generic_Complex_Elementary_Functions; with Ada.Text_IO; use Ada.Text_IO; with Ada_Lapack; package body SVD is package Complex_Maths is new Ada.Numerics.Generic_Complex_Elementary_Functions (Complex_Types); package Lapack is new Ada_Lapack (Real, Complex_Types, Real_Arrays, Complex_Arrays); -- ------------------------------------------------------------------------ function Singular_Value_Decomposition (aMatrix : GA_Maths.Float_Matrix) return SVD is use Complex_Arrays; use Real_Arrays; Converted_Matrix : Complex_Arrays.Complex_Matrix (aMatrix'Range (1), aMatrix'Range (2)) := (others => (others => (0.0, 0.0))); begin for row in aMatrix'Range (1) loop for col in aMatrix'Range (2) loop Converted_Matrix (row, col) := (Real (aMatrix (row, col)), 0.0); end loop; end loop; return Singular_Value_Decomposition (Converted_Matrix); end Singular_Value_Decomposition; -- ------------------------------------------------------------------------ function Singular_Value_Decomposition (aMatrix : Real_Arrays.Real_Matrix) return SVD is use Complex_Arrays; Converted_Matrix : Complex_Arrays.Complex_Matrix (aMatrix'Range (1), aMatrix'Range (2)) := (others => (others => (0.0, 0.0))); begin Set_Re (Converted_Matrix, aMatrix); return Singular_Value_Decomposition (Converted_Matrix); end Singular_Value_Decomposition; -- ------------------------------------------------------------------------ function Singular_Value_Decomposition (aMatrix : Complex_Arrays.Complex_Matrix) return SVD is use Lapack; use Real_Arrays; use Complex_Types; use Complex_Arrays; -- One : constant Real := 1.0e0; -- Zero : constant Real := 0.0e0; Num_Rows : constant Natural := aMatrix'Length (1); Num_Cols : constant Natural := aMatrix'Length (2); Matrix_A : Complex_Matrix := aMatrix; Matrix_U : Complex_Matrix (1 .. Num_Rows, 1 .. Num_Cols); V_Transpose : Complex_Matrix (1 .. Num_Cols, 1 .. Num_Cols); Vector_R : Real_Vector (1 .. Num_Rows); Short_Vector : Complex_Vector (1 .. 1); Num_Singular : Integer := GA_Maths.Minimum (Num_Rows, Num_Cols); Singular_Values : Real_Vector (1 .. Num_Singular); -- sorted: S(i) >= S(i+1). Return_Code : Integer := 0; theSVD : SVD (Num_Rows, Num_Cols, Num_Singular); -- Return_Code = 0: successful exit. -- < 0: if INFO = -i, the i-th argument had an illegal value. -- > 0: if DBDSQR did not converge, INFO specifies how many -- superdiagonals of an intermediate bidiagonal form B -- did not converge to zero. -- Refer http://www.netlib.org/lapack/explore-html/index.html for -- additional GESVD information begin GESVD (JOBU => 'S', JOBVT => 'S', M => Num_Rows, N => Num_Cols, A => Matrix_A, LDA => Num_Rows, S => Singular_Values, U => Matrix_U, LDU => Num_Rows, VT => V_Transpose, LDVT => Num_Cols, WORK => Short_Vector, LWORK => -1, RWORK => Vector_R, INFO => Return_code); declare Work_Vector_Rows : Integer := Short_Vector'Length; Work_Vector : Complex_Vector (1 .. Work_Vector_Rows); begin GESVD (JOBU => 'S', JOBVT => 'S', M => Num_Rows, N => Num_Cols, A => Matrix_A, LDA => Num_Rows, S => Singular_Values, U => Matrix_U, LDU => Num_Rows, VT => V_Transpose, LDVT => Num_Cols, WORK => Work_Vector, LWORK => Work_Vector_Rows, RWORK => Vector_R, INFO => Return_Code); if Return_Code = 0 then theSVD.Matrix_W := Work_Vector; end if; end; if Return_Code > 0 then raise SVD_Exception with "Singular_Value_Decomposition failed with return code" & Integer'Image (Return_Code); else theSVD.Matrix_U := Matrix_U; theSVD.Matrix_V := Transpose (V_Transpose); theSVD.Sorted_Singular_Values := Singular_Values; end if; return theSVD; end Singular_Value_Decomposition; -- ------------------------------------------------------------------------ function Condition_Number (aMatrix : GA_Maths.Float_Matrix) return Float is anSVD : SVD := Singular_Value_Decomposition (aMatrix); Max : Float := Float (anSVD.Sorted_Singular_Values (anSVD.Sorted_Singular_Values'First)); Min : Float := Float (anSVD.Sorted_Singular_Values (anSVD.Sorted_Singular_Values'Last)); Result : Float := 0.0; begin if Min > 0.0 then Result := Max / Min; else Result := Max / 10.0 ** (-8); end if; return Result; end Condition_Number; -- ------------------------------------------------------------------------ end SVD;
zhmu/ananas
Ada
64,131
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.INDEFINITE_DOUBLY_LINKED_LISTS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with Ada.Containers.Stable_Sorting; use Ada.Containers.Stable_Sorting; with System; use type System.Address; with System.Put_Images; package body Ada.Containers.Indefinite_Doubly_Linked_Lists with SPARK_Mode => Off is pragma Warnings (Off, "variable ""Busy*"" is not referenced"); pragma Warnings (Off, "variable ""Lock*"" is not referenced"); -- See comment in Ada.Containers.Helpers procedure Free is new Ada.Unchecked_Deallocation (Element_Type, Element_Access); ----------------------- -- Local Subprograms -- ----------------------- procedure Free (X : in out Node_Access); procedure Insert_Internal (Container : in out List; Before : Node_Access; New_Node : Node_Access); procedure Splice_Internal (Target : in out List; Before : Node_Access; Source : in out List); procedure Splice_Internal (Target : in out List; Before : Node_Access; Source : in out List; Position : Node_Access); function Vet (Position : Cursor) return Boolean; -- Checks invariants of the cursor and its designated container, as a -- simple way of detecting dangling references (see operation Free for a -- description of the detection mechanism), returning True if all checks -- pass. Invocations of Vet are used here as the argument of pragma Assert, -- so the checks are performed only when assertions are enabled. --------- -- "=" -- --------- function "=" (Left, Right : List) return Boolean is begin if Left.Length /= Right.Length then return False; end if; if Left.Length = 0 then return True; end if; declare -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. Lock_Left : With_Lock (Left.TC'Unrestricted_Access); Lock_Right : With_Lock (Right.TC'Unrestricted_Access); L : Node_Access := Left.First; R : Node_Access := Right.First; begin for J in 1 .. Left.Length loop if L.Element.all /= R.Element.all then return False; end if; L := L.Next; R := R.Next; end loop; end; return True; end "="; ------------ -- Adjust -- ------------ procedure Adjust (Container : in out List) is Src : Node_Access := Container.First; Dst : Node_Access; begin -- If the counts are nonzero, execution is technically erroneous, but -- it seems friendly to allow things like concurrent "=" on shared -- constants. Zero_Counts (Container.TC); if Src = null then pragma Assert (Container.Last = null); pragma Assert (Container.Length = 0); return; end if; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); pragma Assert (Container.Length > 0); Container.First := null; Container.Last := null; Container.Length := 0; declare Element : Element_Access := new Element_Type'(Src.Element.all); begin Dst := new Node_Type'(Element, null, null); exception when others => Free (Element); raise; end; Container.First := Dst; Container.Last := Dst; Container.Length := 1; Src := Src.Next; while Src /= null loop declare Element : Element_Access := new Element_Type'(Src.Element.all); begin Dst := new Node_Type'(Element, null, Prev => Container.Last); exception when others => Free (Element); raise; end; Container.Last.Next := Dst; Container.Last := Dst; Container.Length := Container.Length + 1; Src := Src.Next; end loop; end Adjust; ------------ -- Append -- ------------ procedure Append (Container : in out List; New_Item : Element_Type; Count : Count_Type) is begin Insert (Container, No_Element, New_Item, Count); end Append; procedure Append (Container : in out List; New_Item : Element_Type) is begin Insert (Container, No_Element, New_Item, 1); end Append; ------------ -- Assign -- ------------ procedure Assign (Target : in out List; Source : List) is Node : Node_Access; begin if Target'Address = Source'Address then return; else Target.Clear; Node := Source.First; while Node /= null loop Target.Append (Node.Element.all); Node := Node.Next; end loop; end if; end Assign; ----------- -- Clear -- ----------- procedure Clear (Container : in out List) is X : Node_Access; pragma Warnings (Off, X); begin if Container.Length = 0 then pragma Assert (Container.First = null); pragma Assert (Container.Last = null); pragma Assert (Container.TC = (Busy => 0, Lock => 0)); return; end if; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); TC_Check (Container.TC); while Container.Length > 1 loop X := Container.First; pragma Assert (X.Next.Prev = Container.First); Container.First := X.Next; Container.First.Prev := null; Container.Length := Container.Length - 1; Free (X); end loop; X := Container.First; pragma Assert (X = Container.Last); Container.First := null; Container.Last := null; Container.Length := 0; Free (X); end Clear; ------------------------ -- Constant_Reference -- ------------------------ function Constant_Reference (Container : aliased List; Position : Cursor) return Constant_Reference_Type is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong container"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Node has no element"; end if; pragma Assert (Vet (Position), "bad cursor in Constant_Reference"); declare TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Constant_Reference_Type := (Element => Position.Node.Element, Control => (Controlled with TC)) do Busy (TC.all); end return; end; end Constant_Reference; -------------- -- Contains -- -------------- function Contains (Container : List; Item : Element_Type) return Boolean is begin return Find (Container, Item) /= No_Element; end Contains; ---------- -- Copy -- ---------- function Copy (Source : List) return List is begin return Target : List do Target.Assign (Source); end return; end Copy; ------------ -- Delete -- ------------ procedure Delete (Container : in out List; Position : in out Cursor; Count : Count_Type := 1) is X : Node_Access; begin TC_Check (Container.TC); if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong container"; end if; pragma Assert (Vet (Position), "bad cursor in Delete"); if Position.Node = Container.First then Delete_First (Container, Count); Position := No_Element; -- Post-York behavior return; end if; if Count = 0 then Position := No_Element; -- Post-York behavior return; end if; for Index in 1 .. Count loop X := Position.Node; Container.Length := Container.Length - 1; if X = Container.Last then Position := No_Element; Container.Last := X.Prev; Container.Last.Next := null; Free (X); return; end if; Position.Node := X.Next; X.Next.Prev := X.Prev; X.Prev.Next := X.Next; Free (X); end loop; -- Fix this junk comment ??? Position := No_Element; -- Post-York behavior end Delete; ------------------ -- Delete_First -- ------------------ procedure Delete_First (Container : in out List; Count : Count_Type := 1) is X : Node_Access; begin if Count >= Container.Length then Clear (Container); return; end if; if Count = 0 then return; end if; TC_Check (Container.TC); for J in 1 .. Count loop X := Container.First; pragma Assert (X.Next.Prev = Container.First); Container.First := X.Next; Container.First.Prev := null; Container.Length := Container.Length - 1; Free (X); end loop; end Delete_First; ----------------- -- Delete_Last -- ----------------- procedure Delete_Last (Container : in out List; Count : Count_Type := 1) is X : Node_Access; begin if Count >= Container.Length then Clear (Container); return; end if; if Count = 0 then return; end if; TC_Check (Container.TC); for J in 1 .. Count loop X := Container.Last; pragma Assert (X.Prev.Next = Container.Last); Container.Last := X.Prev; Container.Last.Next := null; Container.Length := Container.Length - 1; Free (X); end loop; end Delete_Last; ------------- -- Element -- ------------- function Element (Position : Cursor) return Element_Type is begin if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; pragma Assert (Vet (Position), "bad cursor in Element"); return Position.Node.Element.all; end Element; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Iterator) is begin if Object.Container /= null then Unbusy (Object.Container.TC); end if; end Finalize; ---------- -- Find -- ---------- function Find (Container : List; Item : Element_Type; Position : Cursor := No_Element) return Cursor is Node : Node_Access := Position.Node; begin if Node = null then Node := Container.First; else if Checks and then Node.Element = null then raise Program_Error; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong container"; end if; pragma Assert (Vet (Position), "bad cursor in Find"); end if; -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare Lock : With_Lock (Container.TC'Unrestricted_Access); begin while Node /= null loop if Node.Element.all = Item then return Cursor'(Container'Unrestricted_Access, Node); end if; Node := Node.Next; end loop; return No_Element; end; end Find; ----------- -- First -- ----------- function First (Container : List) return Cursor is begin if Container.First = null then return No_Element; else return Cursor'(Container'Unrestricted_Access, Container.First); end if; end First; function First (Object : Iterator) return Cursor is begin -- The value of the iterator object's Node component influences the -- behavior of the First (and Last) selector function. -- When the Node component is null, this means the iterator object was -- constructed without a start expression, in which case the (forward) -- iteration starts from the (logical) beginning of the entire sequence -- of items (corresponding to Container.First, for a forward iterator). -- Otherwise, this is iteration over a partial sequence of items. When -- the Node component is non-null, the iterator object was constructed -- with a start expression, that specifies the position from which the -- (forward) partial iteration begins. if Object.Node = null then return Indefinite_Doubly_Linked_Lists.First (Object.Container.all); else return Cursor'(Object.Container, Object.Node); end if; end First; ------------------- -- First_Element -- ------------------- function First_Element (Container : List) return Element_Type is begin if Checks and then Container.First = null then raise Constraint_Error with "list is empty"; end if; return Container.First.Element.all; end First_Element; ---------- -- Free -- ---------- procedure Free (X : in out Node_Access) is procedure Deallocate is new Ada.Unchecked_Deallocation (Node_Type, Node_Access); begin -- While a node is in use, as an active link in a list, its Previous and -- Next components must be null, or designate a different node; this is -- a node invariant. For this indefinite list, there is an additional -- invariant: that the element access value be non-null. Before actually -- deallocating the node, we set the node access value components of the -- node to point to the node itself, and set the element access value to -- null (by deallocating the node's element), thus falsifying the node -- invariant. Subprogram Vet inspects the value of the node components -- when interrogating the node, in order to detect whether the cursor's -- node access value is dangling. -- Note that we have no guarantee that the storage for the node isn't -- modified when it is deallocated, but there are other tests that Vet -- does if node invariants appear to be satisifed. However, in practice -- this simple test works well enough, detecting dangling references -- immediately, without needing further interrogation. X.Next := X; X.Prev := X; begin Free (X.Element); exception when others => X.Element := null; Deallocate (X); raise; end; Deallocate (X); end Free; --------------------- -- Generic_Sorting -- --------------------- package body Generic_Sorting is --------------- -- Is_Sorted -- --------------- function Is_Sorted (Container : List) return Boolean is -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. Lock : With_Lock (Container.TC'Unrestricted_Access); Node : Node_Access; begin Node := Container.First; for J in 2 .. Container.Length loop if Node.Next.Element.all < Node.Element.all then return False; end if; Node := Node.Next; end loop; return True; end Is_Sorted; ----------- -- Merge -- ----------- procedure Merge (Target : in out List; Source : in out List) is begin -- The semantics of Merge changed slightly per AI05-0021. It was -- originally the case that if Target and Source denoted the same -- container object, then the GNAT implementation of Merge did -- nothing. However, it was argued that RM05 did not precisely -- specify the semantics for this corner case. The decision of the -- ARG was that if Target and Source denote the same non-empty -- container object, then Program_Error is raised. if Source.Is_Empty then return; end if; TC_Check (Target.TC); TC_Check (Source.TC); if Checks and then Target'Address = Source'Address then raise Program_Error with "Target and Source denote same non-empty container"; end if; if Checks and then Target.Length > Count_Type'Last - Source.Length then raise Constraint_Error with "new length exceeds maximum"; end if; declare Lock_Target : With_Lock (Target.TC'Unchecked_Access); Lock_Source : With_Lock (Source.TC'Unchecked_Access); LI, RI, RJ : Node_Access; begin LI := Target.First; RI := Source.First; while RI /= null loop pragma Assert (RI.Next = null or else not (RI.Next.Element.all < RI.Element.all)); if LI = null then Splice_Internal (Target, null, Source); exit; end if; pragma Assert (LI.Next = null or else not (LI.Next.Element.all < LI.Element.all)); if RI.Element.all < LI.Element.all then RJ := RI; RI := RI.Next; Splice_Internal (Target, LI, Source, RJ); else LI := LI.Next; end if; end loop; end; end Merge; ---------- -- Sort -- ---------- procedure Sort (Container : in out List) is begin if Container.Length <= 1 then return; end if; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); TC_Check (Container.TC); -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare Lock : With_Lock (Container.TC'Unchecked_Access); package Descriptors is new List_Descriptors (Node_Ref => Node_Access, Nil => null); use Descriptors; function Next (N : Node_Access) return Node_Access is (N.Next); procedure Set_Next (N : Node_Access; Next : Node_Access) with Inline; procedure Set_Prev (N : Node_Access; Prev : Node_Access) with Inline; function "<" (L, R : Node_Access) return Boolean is (L.Element.all < R.Element.all); procedure Update_Container (List : List_Descriptor) with Inline; procedure Set_Next (N : Node_Access; Next : Node_Access) is begin N.Next := Next; end Set_Next; procedure Set_Prev (N : Node_Access; Prev : Node_Access) is begin N.Prev := Prev; end Set_Prev; procedure Update_Container (List : List_Descriptor) is begin Container.First := List.First; Container.Last := List.Last; Container.Length := List.Length; end Update_Container; procedure Sort_List is new Doubly_Linked_List_Sort; begin Sort_List (List_Descriptor'(First => Container.First, Last => Container.Last, Length => Container.Length)); end; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); end Sort; end Generic_Sorting; ------------------------ -- Get_Element_Access -- ------------------------ function Get_Element_Access (Position : Cursor) return not null Element_Access is begin return Position.Node.Element; end Get_Element_Access; ----------------- -- Has_Element -- ----------------- function Has_Element (Position : Cursor) return Boolean is begin pragma Assert (Vet (Position), "bad cursor in Has_Element"); return Position.Node /= null; end Has_Element; ------------ -- Insert -- ------------ procedure Insert (Container : in out List; Before : Cursor; New_Item : Element_Type; Position : out Cursor; Count : Count_Type := 1) is First_Node : Node_Access; New_Node : Node_Access; begin TC_Check (Container.TC); if Before.Container /= null then if Checks and then Before.Container /= Container'Unrestricted_Access then raise Program_Error with "Before cursor designates wrong list"; end if; if Checks and then (Before.Node = null or else Before.Node.Element = null) then raise Program_Error with "Before cursor has no element"; end if; pragma Assert (Vet (Before), "bad cursor in Insert"); end if; if Count = 0 then Position := Before; return; end if; if Checks and then Container.Length > Count_Type'Last - Count then raise Constraint_Error with "new length exceeds maximum"; end if; declare -- The element allocator may need an accessibility check in the case -- the actual type is class-wide or has access discriminants (see -- RM 4.8(10.1) and AI12-0035). We don't unsuppress the check on the -- allocator in the loop below, because the one in this block would -- have failed already. pragma Unsuppress (Accessibility_Check); Element : Element_Access := new Element_Type'(New_Item); begin New_Node := new Node_Type'(Element, null, null); First_Node := New_Node; exception when others => Free (Element); raise; end; Insert_Internal (Container, Before.Node, New_Node); for J in 2 .. Count loop declare Element : Element_Access := new Element_Type'(New_Item); begin New_Node := new Node_Type'(Element, null, null); exception when others => Free (Element); raise; end; Insert_Internal (Container, Before.Node, New_Node); end loop; Position := Cursor'(Container'Unchecked_Access, First_Node); end Insert; procedure Insert (Container : in out List; Before : Cursor; New_Item : Element_Type; Count : Count_Type := 1) is Position : Cursor; begin Insert (Container, Before, New_Item, Position, Count); end Insert; --------------------- -- Insert_Internal -- --------------------- procedure Insert_Internal (Container : in out List; Before : Node_Access; New_Node : Node_Access) is begin if Container.Length = 0 then pragma Assert (Before = null); pragma Assert (Container.First = null); pragma Assert (Container.Last = null); Container.First := New_Node; Container.Last := New_Node; elsif Before = null then pragma Assert (Container.Last.Next = null); Container.Last.Next := New_Node; New_Node.Prev := Container.Last; Container.Last := New_Node; elsif Before = Container.First then pragma Assert (Container.First.Prev = null); Container.First.Prev := New_Node; New_Node.Next := Container.First; Container.First := New_Node; else pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); New_Node.Next := Before; New_Node.Prev := Before.Prev; Before.Prev.Next := New_Node; Before.Prev := New_Node; end if; Container.Length := Container.Length + 1; end Insert_Internal; -------------- -- Is_Empty -- -------------- function Is_Empty (Container : List) return Boolean is begin return Container.Length = 0; end Is_Empty; ------------- -- Iterate -- ------------- procedure Iterate (Container : List; Process : not null access procedure (Position : Cursor)) is Busy : With_Busy (Container.TC'Unrestricted_Access); Node : Node_Access := Container.First; begin while Node /= null loop Process (Cursor'(Container'Unrestricted_Access, Node)); Node := Node.Next; end loop; end Iterate; function Iterate (Container : List) return List_Iterator_Interfaces.Reversible_Iterator'class is begin -- The value of the Node component influences the behavior of the First -- and Last selector functions of the iterator object. When the Node -- component is null (as is the case here), this means the iterator -- object was constructed without a start expression. This is a -- complete iterator, meaning that the iteration starts from the -- (logical) beginning of the sequence of items. -- Note: For a forward iterator, Container.First is the beginning, and -- for a reverse iterator, Container.Last is the beginning. return It : constant Iterator := Iterator'(Limited_Controlled with Container => Container'Unrestricted_Access, Node => null) do Busy (Container.TC'Unrestricted_Access.all); end return; end Iterate; function Iterate (Container : List; Start : Cursor) return List_Iterator_Interfaces.Reversible_Iterator'Class is begin -- It was formerly the case that when Start = No_Element, the partial -- iterator was defined to behave the same as for a complete iterator, -- and iterate over the entire sequence of items. However, those -- semantics were unintuitive and arguably error-prone (it is too easy -- to accidentally create an endless loop), and so they were changed, -- per the ARG meeting in Denver on 2011/11. However, there was no -- consensus about what positive meaning this corner case should have, -- and so it was decided to simply raise an exception. This does imply, -- however, that it is not possible to use a partial iterator to specify -- an empty sequence of items. if Checks and then Start = No_Element then raise Constraint_Error with "Start position for iterator equals No_Element"; end if; if Checks and then Start.Container /= Container'Unrestricted_Access then raise Program_Error with "Start cursor of Iterate designates wrong list"; end if; pragma Assert (Vet (Start), "Start cursor of Iterate is bad"); -- The value of the Node component influences the behavior of the -- First and Last selector functions of the iterator object. When -- the Node component is non-null (as is the case here), it means -- that this is a partial iteration, over a subset of the complete -- sequence of items. The iterator object was constructed with -- a start expression, indicating the position from which the -- iteration begins. Note that the start position has the same value -- irrespective of whether this is a forward or reverse iteration. return It : constant Iterator := Iterator'(Limited_Controlled with Container => Container'Unrestricted_Access, Node => Start.Node) do Busy (Container.TC'Unrestricted_Access.all); end return; end Iterate; ---------- -- Last -- ---------- function Last (Container : List) return Cursor is begin if Container.Last = null then return No_Element; else return Cursor'(Container'Unrestricted_Access, Container.Last); end if; end Last; function Last (Object : Iterator) return Cursor is begin -- The value of the iterator object's Node component influences the -- behavior of the Last (and First) selector function. -- When the Node component is null, this means the iterator object was -- constructed without a start expression, in which case the (reverse) -- iteration starts from the (logical) beginning of the entire sequence -- (corresponding to Container.Last, for a reverse iterator). -- Otherwise, this is iteration over a partial sequence of items. When -- the Node component is non-null, the iterator object was constructed -- with a start expression, that specifies the position from which the -- (reverse) partial iteration begins. if Object.Node = null then return Indefinite_Doubly_Linked_Lists.Last (Object.Container.all); else return Cursor'(Object.Container, Object.Node); end if; end Last; ------------------ -- Last_Element -- ------------------ function Last_Element (Container : List) return Element_Type is begin if Checks and then Container.Last = null then raise Constraint_Error with "list is empty"; end if; return Container.Last.Element.all; end Last_Element; ------------ -- Length -- ------------ function Length (Container : List) return Count_Type is begin return Container.Length; end Length; ---------- -- Move -- ---------- procedure Move (Target : in out List; Source : in out List) is begin if Target'Address = Source'Address then return; end if; TC_Check (Source.TC); Clear (Target); Target.First := Source.First; Source.First := null; Target.Last := Source.Last; Source.Last := null; Target.Length := Source.Length; Source.Length := 0; end Move; ---------- -- Next -- ---------- procedure Next (Position : in out Cursor) is begin Position := Next (Position); end Next; function Next (Position : Cursor) return Cursor is begin if Position.Node = null then return No_Element; else pragma Assert (Vet (Position), "bad cursor in Next"); declare Next_Node : constant Node_Access := Position.Node.Next; begin if Next_Node = null then return No_Element; else return Cursor'(Position.Container, Next_Node); end if; end; end if; end Next; function Next (Object : Iterator; Position : Cursor) return Cursor is begin if Position.Container = null then return No_Element; end if; if Checks and then Position.Container /= Object.Container then raise Program_Error with "Position cursor of Next designates wrong list"; end if; return Next (Position); end Next; ------------- -- Prepend -- ------------- procedure Prepend (Container : in out List; New_Item : Element_Type; Count : Count_Type := 1) is begin Insert (Container, First (Container), New_Item, Count); end Prepend; -------------- -- Previous -- -------------- procedure Previous (Position : in out Cursor) is begin Position := Previous (Position); end Previous; function Previous (Position : Cursor) return Cursor is begin if Position.Node = null then return No_Element; else pragma Assert (Vet (Position), "bad cursor in Previous"); declare Prev_Node : constant Node_Access := Position.Node.Prev; begin if Prev_Node = null then return No_Element; else return Cursor'(Position.Container, Prev_Node); end if; end; end if; end Previous; function Previous (Object : Iterator; Position : Cursor) return Cursor is begin if Position.Container = null then return No_Element; end if; if Checks and then Position.Container /= Object.Container then raise Program_Error with "Position cursor of Previous designates wrong list"; end if; return Previous (Position); end Previous; ---------------------- -- Pseudo_Reference -- ---------------------- function Pseudo_Reference (Container : aliased List'Class) return Reference_Control_Type is TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Reference_Control_Type := (Controlled with TC) do Busy (TC.all); end return; end Pseudo_Reference; ------------------- -- Query_Element -- ------------------- procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)) is begin if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; pragma Assert (Vet (Position), "bad cursor in Query_Element"); declare Lock : With_Lock (Position.Container.TC'Unrestricted_Access); begin Process (Position.Node.Element.all); end; end Query_Element; --------------- -- Put_Image -- --------------- procedure Put_Image (S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : List) is First_Time : Boolean := True; use System.Put_Images; procedure Put_Elem (Position : Cursor); procedure Put_Elem (Position : Cursor) is begin if First_Time then First_Time := False; else Simple_Array_Between (S); end if; Element_Type'Put_Image (S, Element (Position)); end Put_Elem; begin Array_Before (S); Iterate (V, Put_Elem'Access); Array_After (S); end Put_Image; ---------- -- Read -- ---------- procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out List) is N : Count_Type'Base; Dst : Node_Access; begin Clear (Item); Count_Type'Base'Read (Stream, N); if N = 0 then return; end if; declare Element : Element_Access := new Element_Type'(Element_Type'Input (Stream)); begin Dst := new Node_Type'(Element, null, null); exception when others => Free (Element); raise; end; Item.First := Dst; Item.Last := Dst; Item.Length := 1; while Item.Length < N loop declare Element : Element_Access := new Element_Type'(Element_Type'Input (Stream)); begin Dst := new Node_Type'(Element, Next => null, Prev => Item.Last); exception when others => Free (Element); raise; end; Item.Last.Next := Dst; Item.Last := Dst; Item.Length := Item.Length + 1; end loop; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Cursor) is begin raise Program_Error with "attempt to stream list cursor"; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Constant_Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Read; --------------- -- Reference -- --------------- function Reference (Container : aliased in out List; Position : Cursor) return Reference_Type is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong container"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Node has no element"; end if; pragma Assert (Vet (Position), "bad cursor in function Reference"); declare TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access; begin return R : constant Reference_Type := (Element => Position.Node.Element, Control => (Controlled with TC)) do Busy (TC.all); end return; end; end Reference; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Container : in out List; Position : Cursor; New_Item : Element_Type) is begin TE_Check (Container.TC); if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unchecked_Access then raise Program_Error with "Position cursor designates wrong container"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; pragma Assert (Vet (Position), "bad cursor in Replace_Element"); declare -- The element allocator may need an accessibility check in the -- case the actual type is class-wide or has access discriminants -- (see RM 4.8(10.1) and AI12-0035). pragma Unsuppress (Accessibility_Check); X : Element_Access := Position.Node.Element; begin Position.Node.Element := new Element_Type'(New_Item); Free (X); end; end Replace_Element; ---------------------- -- Reverse_Elements -- ---------------------- procedure Reverse_Elements (Container : in out List) is I : Node_Access := Container.First; J : Node_Access := Container.Last; procedure Swap (L, R : Node_Access); ---------- -- Swap -- ---------- procedure Swap (L, R : Node_Access) is LN : constant Node_Access := L.Next; LP : constant Node_Access := L.Prev; RN : constant Node_Access := R.Next; RP : constant Node_Access := R.Prev; begin if LP /= null then LP.Next := R; end if; if RN /= null then RN.Prev := L; end if; L.Next := RN; R.Prev := LP; if LN = R then pragma Assert (RP = L); L.Prev := R; R.Next := L; else L.Prev := RP; RP.Next := L; R.Next := LN; LN.Prev := R; end if; end Swap; -- Start of processing for Reverse_Elements begin if Container.Length <= 1 then return; end if; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); TC_Check (Container.TC); Container.First := J; Container.Last := I; loop Swap (L => I, R => J); J := J.Next; exit when I = J; I := I.Prev; exit when I = J; Swap (L => J, R => I); I := I.Next; exit when I = J; J := J.Prev; exit when I = J; end loop; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); end Reverse_Elements; ------------------ -- Reverse_Find -- ------------------ function Reverse_Find (Container : List; Item : Element_Type; Position : Cursor := No_Element) return Cursor is Node : Node_Access := Position.Node; begin if Node = null then Node := Container.Last; else if Checks and then Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong container"; end if; pragma Assert (Vet (Position), "bad cursor in Reverse_Find"); end if; -- Per AI05-0022, the container implementation is required to detect -- element tampering by a generic actual subprogram. declare Lock : With_Lock (Container.TC'Unrestricted_Access); begin while Node /= null loop if Node.Element.all = Item then return Cursor'(Container'Unrestricted_Access, Node); end if; Node := Node.Prev; end loop; return No_Element; end; end Reverse_Find; --------------------- -- Reverse_Iterate -- --------------------- procedure Reverse_Iterate (Container : List; Process : not null access procedure (Position : Cursor)) is Busy : With_Busy (Container.TC'Unrestricted_Access); Node : Node_Access := Container.Last; begin while Node /= null loop Process (Cursor'(Container'Unrestricted_Access, Node)); Node := Node.Prev; end loop; end Reverse_Iterate; ------------ -- Splice -- ------------ procedure Splice (Target : in out List; Before : Cursor; Source : in out List) is begin TC_Check (Target.TC); TC_Check (Source.TC); if Before.Container /= null then if Checks and then Before.Container /= Target'Unrestricted_Access then raise Program_Error with "Before cursor designates wrong container"; end if; if Checks and then (Before.Node = null or else Before.Node.Element = null) then raise Program_Error with "Before cursor has no element"; end if; pragma Assert (Vet (Before), "bad cursor in Splice"); end if; if Target'Address = Source'Address or else Source.Length = 0 then return; end if; if Checks and then Target.Length > Count_Type'Last - Source.Length then raise Constraint_Error with "new length exceeds maximum"; end if; Splice_Internal (Target, Before.Node, Source); end Splice; procedure Splice (Container : in out List; Before : Cursor; Position : Cursor) is begin TC_Check (Container.TC); if Before.Container /= null then if Checks and then Before.Container /= Container'Unchecked_Access then raise Program_Error with "Before cursor designates wrong container"; end if; if Checks and then (Before.Node = null or else Before.Node.Element = null) then raise Program_Error with "Before cursor has no element"; end if; pragma Assert (Vet (Before), "bad Before cursor in Splice"); end if; if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong container"; end if; pragma Assert (Vet (Position), "bad Position cursor in Splice"); if Position.Node = Before.Node or else Position.Node.Next = Before.Node then return; end if; pragma Assert (Container.Length >= 2); if Before.Node = null then pragma Assert (Position.Node /= Container.Last); if Position.Node = Container.First then Container.First := Position.Node.Next; Container.First.Prev := null; else Position.Node.Prev.Next := Position.Node.Next; Position.Node.Next.Prev := Position.Node.Prev; end if; Container.Last.Next := Position.Node; Position.Node.Prev := Container.Last; Container.Last := Position.Node; Container.Last.Next := null; return; end if; if Before.Node = Container.First then pragma Assert (Position.Node /= Container.First); if Position.Node = Container.Last then Container.Last := Position.Node.Prev; Container.Last.Next := null; else Position.Node.Prev.Next := Position.Node.Next; Position.Node.Next.Prev := Position.Node.Prev; end if; Container.First.Prev := Position.Node; Position.Node.Next := Container.First; Container.First := Position.Node; Container.First.Prev := null; return; end if; if Position.Node = Container.First then Container.First := Position.Node.Next; Container.First.Prev := null; elsif Position.Node = Container.Last then Container.Last := Position.Node.Prev; Container.Last.Next := null; else Position.Node.Prev.Next := Position.Node.Next; Position.Node.Next.Prev := Position.Node.Prev; end if; Before.Node.Prev.Next := Position.Node; Position.Node.Prev := Before.Node.Prev; Before.Node.Prev := Position.Node; Position.Node.Next := Before.Node; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); end Splice; procedure Splice (Target : in out List; Before : Cursor; Source : in out List; Position : in out Cursor) is begin if Target'Address = Source'Address then Splice (Target, Before, Position); return; end if; TC_Check (Target.TC); TC_Check (Source.TC); if Before.Container /= null then if Checks and then Before.Container /= Target'Unrestricted_Access then raise Program_Error with "Before cursor designates wrong container"; end if; if Checks and then (Before.Node = null or else Before.Node.Element = null) then raise Program_Error with "Before cursor has no element"; end if; pragma Assert (Vet (Before), "bad Before cursor in Splice"); end if; if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Source'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong container"; end if; pragma Assert (Vet (Position), "bad Position cursor in Splice"); if Checks and then Target.Length = Count_Type'Last then raise Constraint_Error with "Target is full"; end if; Splice_Internal (Target, Before.Node, Source, Position.Node); Position.Container := Target'Unchecked_Access; end Splice; --------------------- -- Splice_Internal -- --------------------- procedure Splice_Internal (Target : in out List; Before : Node_Access; Source : in out List) is begin -- This implements the corresponding Splice operation, after the -- parameters have been vetted, and corner-cases disposed of. pragma Assert (Target'Address /= Source'Address); pragma Assert (Source.Length > 0); pragma Assert (Source.First /= null); pragma Assert (Source.First.Prev = null); pragma Assert (Source.Last /= null); pragma Assert (Source.Last.Next = null); pragma Assert (Target.Length <= Count_Type'Last - Source.Length); if Target.Length = 0 then pragma Assert (Before = null); pragma Assert (Target.First = null); pragma Assert (Target.Last = null); Target.First := Source.First; Target.Last := Source.Last; elsif Before = null then pragma Assert (Target.Last.Next = null); Target.Last.Next := Source.First; Source.First.Prev := Target.Last; Target.Last := Source.Last; elsif Before = Target.First then pragma Assert (Target.First.Prev = null); Source.Last.Next := Target.First; Target.First.Prev := Source.Last; Target.First := Source.First; else pragma Assert (Target.Length >= 2); Before.Prev.Next := Source.First; Source.First.Prev := Before.Prev; Before.Prev := Source.Last; Source.Last.Next := Before; end if; Source.First := null; Source.Last := null; Target.Length := Target.Length + Source.Length; Source.Length := 0; end Splice_Internal; procedure Splice_Internal (Target : in out List; Before : Node_Access; -- node of Target Source : in out List; Position : Node_Access) -- node of Source is begin -- This implements the corresponding Splice operation, after the -- parameters have been vetted. pragma Assert (Target'Address /= Source'Address); pragma Assert (Target.Length < Count_Type'Last); pragma Assert (Source.Length > 0); pragma Assert (Source.First /= null); pragma Assert (Source.First.Prev = null); pragma Assert (Source.Last /= null); pragma Assert (Source.Last.Next = null); pragma Assert (Position /= null); if Position = Source.First then Source.First := Position.Next; if Position = Source.Last then pragma Assert (Source.First = null); pragma Assert (Source.Length = 1); Source.Last := null; else Source.First.Prev := null; end if; elsif Position = Source.Last then pragma Assert (Source.Length >= 2); Source.Last := Position.Prev; Source.Last.Next := null; else pragma Assert (Source.Length >= 3); Position.Prev.Next := Position.Next; Position.Next.Prev := Position.Prev; end if; if Target.Length = 0 then pragma Assert (Before = null); pragma Assert (Target.First = null); pragma Assert (Target.Last = null); Target.First := Position; Target.Last := Position; Target.First.Prev := null; Target.Last.Next := null; elsif Before = null then pragma Assert (Target.Last.Next = null); Target.Last.Next := Position; Position.Prev := Target.Last; Target.Last := Position; Target.Last.Next := null; elsif Before = Target.First then pragma Assert (Target.First.Prev = null); Target.First.Prev := Position; Position.Next := Target.First; Target.First := Position; Target.First.Prev := null; else pragma Assert (Target.Length >= 2); Before.Prev.Next := Position; Position.Prev := Before.Prev; Before.Prev := Position; Position.Next := Before; end if; Target.Length := Target.Length + 1; Source.Length := Source.Length - 1; end Splice_Internal; ---------- -- Swap -- ---------- procedure Swap (Container : in out List; I, J : Cursor) is begin TE_Check (Container.TC); if Checks and then I.Node = null then raise Constraint_Error with "I cursor has no element"; end if; if Checks and then J.Node = null then raise Constraint_Error with "J cursor has no element"; end if; if Checks and then I.Container /= Container'Unchecked_Access then raise Program_Error with "I cursor designates wrong container"; end if; if Checks and then J.Container /= Container'Unchecked_Access then raise Program_Error with "J cursor designates wrong container"; end if; if I.Node = J.Node then return; end if; pragma Assert (Vet (I), "bad I cursor in Swap"); pragma Assert (Vet (J), "bad J cursor in Swap"); declare EI_Copy : constant Element_Access := I.Node.Element; begin I.Node.Element := J.Node.Element; J.Node.Element := EI_Copy; end; end Swap; ---------------- -- Swap_Links -- ---------------- procedure Swap_Links (Container : in out List; I, J : Cursor) is begin TC_Check (Container.TC); if Checks and then I.Node = null then raise Constraint_Error with "I cursor has no element"; end if; if Checks and then J.Node = null then raise Constraint_Error with "J cursor has no element"; end if; if Checks and then I.Container /= Container'Unrestricted_Access then raise Program_Error with "I cursor designates wrong container"; end if; if Checks and then J.Container /= Container'Unrestricted_Access then raise Program_Error with "J cursor designates wrong container"; end if; if I.Node = J.Node then return; end if; pragma Assert (Vet (I), "bad I cursor in Swap_Links"); pragma Assert (Vet (J), "bad J cursor in Swap_Links"); declare I_Next : constant Cursor := Next (I); begin if I_Next = J then Splice (Container, Before => I, Position => J); else declare J_Next : constant Cursor := Next (J); begin if J_Next = I then Splice (Container, Before => J, Position => I); else pragma Assert (Container.Length >= 3); Splice (Container, Before => I_Next, Position => J); Splice (Container, Before => J_Next, Position => I); end if; end; end if; end; pragma Assert (Container.First.Prev = null); pragma Assert (Container.Last.Next = null); end Swap_Links; -------------------- -- Update_Element -- -------------------- procedure Update_Element (Container : in out List; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)) is begin if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unchecked_Access then raise Program_Error with "Position cursor designates wrong container"; end if; pragma Assert (Vet (Position), "bad cursor in Update_Element"); declare Lock : With_Lock (Container.TC'Unchecked_Access); begin Process (Position.Node.Element.all); end; end Update_Element; --------- -- Vet -- --------- function Vet (Position : Cursor) return Boolean is begin if Position.Node = null then return Position.Container = null; end if; if Position.Container = null then return False; end if; -- An invariant of a node is that its Previous and Next components can -- be null, or designate a different node. Also, its element access -- value must be non-null. Operation Free sets the node access value -- components of the node to designate the node itself, and the element -- access value to null, before actually deallocating the node, thus -- deliberately violating the node invariant. This gives us a simple way -- to detect a dangling reference to a node. if Position.Node.Next = Position.Node then return False; end if; if Position.Node.Prev = Position.Node then return False; end if; if Position.Node.Element = null then return False; end if; -- In practice the tests above will detect most instances of a dangling -- reference. If we get here, it means that the invariants of the -- designated node are satisfied (they at least appear to be satisfied), -- so we perform some more tests, to determine whether invariants of the -- designated list are satisfied too. declare L : List renames Position.Container.all; begin if L.Length = 0 then return False; end if; if L.First = null then return False; end if; if L.Last = null then return False; end if; if L.First.Prev /= null then return False; end if; if L.Last.Next /= null then return False; end if; if Position.Node.Prev = null and then Position.Node /= L.First then return False; end if; if Position.Node.Next = null and then Position.Node /= L.Last then return False; end if; if L.Length = 1 then return L.First = L.Last; end if; if L.First = L.Last then return False; end if; if L.First.Next = null then return False; end if; if L.Last.Prev = null then return False; end if; if L.First.Next.Prev /= L.First then return False; end if; if L.Last.Prev.Next /= L.Last then return False; end if; if L.Length = 2 then if L.First.Next /= L.Last then return False; end if; if L.Last.Prev /= L.First then return False; end if; return True; end if; if L.First.Next = L.Last then return False; end if; if L.Last.Prev = L.First then return False; end if; if Position.Node = L.First then return True; end if; if Position.Node = L.Last then return True; end if; if Position.Node.Next = null then return False; end if; if Position.Node.Prev = null then return False; end if; if Position.Node.Next.Prev /= Position.Node then return False; end if; if Position.Node.Prev.Next /= Position.Node then return False; end if; if L.Length = 3 then if L.First.Next /= Position.Node then return False; end if; if L.Last.Prev /= Position.Node then return False; end if; end if; return True; end; end Vet; ----------- -- Write -- ----------- procedure Write (Stream : not null access Root_Stream_Type'Class; Item : List) is Node : Node_Access := Item.First; begin Count_Type'Base'Write (Stream, Item.Length); while Node /= null loop Element_Type'Output (Stream, Node.Element.all); Node := Node.Next; end loop; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Cursor) is begin raise Program_Error with "attempt to stream list cursor"; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Constant_Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Write; end Ada.Containers.Indefinite_Doubly_Linked_Lists;
hsgrewal/learning-ada
Ada
174
adb
-- hello_world.adb with Ada.Text_IO; use Ada.Text_IO; procedure hello_world is begin Put_Line("Hello world!"); Put("It's a wonderful day!"); New_Line; end hello_world;
AdaCore/training_material
Ada
5,282
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package SDL_blendmode_h is -- Simple DirectMedia Layer -- Copyright (C) 1997-2018 Sam Lantinga <[email protected]> -- 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. -- --* -- * \file SDL_blendmode.h -- * -- * Header file declaring the SDL_BlendMode enumeration -- -- Set up for C function definitions, even when using C++ --* -- * \brief The blend mode used in SDL_RenderCopy() and drawing operations. -- --*< no blending -- dstRGBA = srcRGBA --*< alpha blending -- dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) -- dstA = srcA + (dstA * (1-srcA)) --*< additive blending -- dstRGB = (srcRGB * srcA) + dstRGB -- dstA = dstA --*< color modulate -- dstRGB = srcRGB * dstRGB -- dstA = dstA -- Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() subtype SDL_BlendMode is unsigned; SDL_BLENDMODE_NONE : constant unsigned := 0; SDL_BLENDMODE_BLEND : constant unsigned := 1; SDL_BLENDMODE_ADD : constant unsigned := 2; SDL_BLENDMODE_MOD : constant unsigned := 4; SDL_BLENDMODE_INVALID : constant unsigned := 2147483647; -- ..\SDL2_tmp\SDL_blendmode.h:57 --* -- * \brief The blend operation used when combining source and destination pixel components -- --*< dst + src: supported by all renderers --*< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES --*< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES --*< min(dst, src) : supported by D3D11 --*< max(dst, src) : supported by D3D11 subtype SDL_BlendOperation is unsigned; SDL_BLENDOPERATION_ADD : constant unsigned := 1; SDL_BLENDOPERATION_SUBTRACT : constant unsigned := 2; SDL_BLENDOPERATION_REV_SUBTRACT : constant unsigned := 3; SDL_BLENDOPERATION_MINIMUM : constant unsigned := 4; SDL_BLENDOPERATION_MAXIMUM : constant unsigned := 5; -- ..\SDL2_tmp\SDL_blendmode.h:70 --* -- * \brief The normalized factor used to multiply pixel components -- --*< 0, 0, 0, 0 --*< 1, 1, 1, 1 --*< srcR, srcG, srcB, srcA --*< 1-srcR, 1-srcG, 1-srcB, 1-srcA --*< srcA, srcA, srcA, srcA --*< 1-srcA, 1-srcA, 1-srcA, 1-srcA --*< dstR, dstG, dstB, dstA --*< 1-dstR, 1-dstG, 1-dstB, 1-dstA --*< dstA, dstA, dstA, dstA --*< 1-dstA, 1-dstA, 1-dstA, 1-dstA subtype SDL_BlendFactor is unsigned; SDL_BLENDFACTOR_ZERO : constant unsigned := 1; SDL_BLENDFACTOR_ONE : constant unsigned := 2; SDL_BLENDFACTOR_SRC_COLOR : constant unsigned := 3; SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR : constant unsigned := 4; SDL_BLENDFACTOR_SRC_ALPHA : constant unsigned := 5; SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA : constant unsigned := 6; SDL_BLENDFACTOR_DST_COLOR : constant unsigned := 7; SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR : constant unsigned := 8; SDL_BLENDFACTOR_DST_ALPHA : constant unsigned := 9; SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA : constant unsigned := 10; -- ..\SDL2_tmp\SDL_blendmode.h:88 --* -- * \brief Create a custom blend mode, which may or may not be supported by a given renderer -- * -- * \param srcColorFactor -- * \param dstColorFactor -- * \param colorOperation -- * \param srcAlphaFactor -- * \param dstAlphaFactor -- * \param alphaOperation -- * -- * The result of the blend mode operation will be: -- * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor -- * and -- * dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor -- function SDL_ComposeCustomBlendMode (srcColorFactor : SDL_BlendFactor; dstColorFactor : SDL_BlendFactor; colorOperation : SDL_BlendOperation; srcAlphaFactor : SDL_BlendFactor; dstAlphaFactor : SDL_BlendFactor; alphaOperation : SDL_BlendOperation) return SDL_BlendMode; -- ..\SDL2_tmp\SDL_blendmode.h:105 pragma Import (C, SDL_ComposeCustomBlendMode, "SDL_ComposeCustomBlendMode"); -- Ends C function definitions when using C++ -- vi: set ts=4 sw=4 expandtab: end SDL_blendmode_h;
aeszter/lox-spark
Ada
17,963
adb
with Ada.Text_IO; with Command_Line; with Ada.Strings; with Ada.Strings.Fixed; with Ada.Characters; with Ada.Characters.Handling; procedure Generate_Ast with SPARK_Mode => Off is package IO renames Ada.Text_IO; type String_Access is access constant String; type String_Array is array (Positive range <>) of String_Access; procedure Define_Ast (Output_Dir, Base_Name : String; Types : String_Array); procedure Define_Type (Spec_File, Body_File : IO.File_Type; Base_Name, Class_Name, Field_List : String); procedure Define_Full_Type (Spec_File, Body_File : IO.File_Type; Base_Name, Class_Name, Field_List : String); procedure Define_Subprogram (Spec_File, Body_File : IO.File_Type; Base_Name, Class_Name, Field_List : String); procedure Define_Visitor (Spec_File, Body_File : IO.File_Type; Base_Name : String; Types : String_Array); procedure Define_Storage (Spec_File : IO.File_Type; Base_Name : String); function Substring (Input, Separator : String; Item_Number : Positive) return String; generic with procedure Process_Field (Field_Name, Type_Name : String; Last : Boolean); procedure Iterate_Fields (List : String); procedure Define_Ast (Output_Dir, Base_Name : String; Types : String_Array) is Spec_Path : constant String := Output_Dir & "/" & Ada.Characters.Handling.To_Lower (Base_Name) & "s.ads"; Body_Path : constant String := Output_Dir & "/" & Ada.Characters.Handling.To_Lower (Base_Name) & "s.adb"; Spec_File, Body_File : IO.File_Type; Handle_Name : constant String := Base_Name & "_Handle"; begin IO.Create (File => Spec_File, Name => Spec_Path); IO.Create (File => Body_File, Name => Body_Path); IO.Put_Line (Spec_File, "with Ada.Containers.Formal_Indefinite_Vectors;"); IO.Put_Line (Spec_File, "with L_Strings; use L_Strings;"); IO.Put_Line (Spec_File, "with Tokens; use Tokens;"); IO.New_Line (Spec_File); IO.Put_Line (Spec_File, "package " & Base_Name & "s with"); IO.Put_Line (Spec_File, " Abstract_State => State is"); IO.Put_Line (Body_File, "package body " & Base_Name & "s with"); IO.Put_Line (Body_File, " Refined_State => (State => Container) is"); IO.Put_Line (Spec_File, " type " & Base_Name & " is abstract tagged private;"); IO.Put_Line (Spec_File, " type " & Handle_Name & " is new Positive;"); IO.Put_Line (Spec_File, " function Is_Valid (Handle : " & Handle_Name & ") return Boolean;"); IO.Put_Line (Body_File, " function Is_Valid (Handle : Expr_Handle) return Boolean with"); IO.Put_Line (Body_File, " Refined_Post => (if Is_Valid'Result then " & "Handle in Storage.First_Index (Container) .. Storage.Last_Index (Container)) is"); IO.Put_Line (Body_File, " begin"); IO.Put_Line (Body_File, " return Handle in Storage.First_Index (Container) .. Storage.Last_Index (Container);"); IO.Put_Line (Body_File, " end Is_Valid;"); IO.New_Line (Body_File); IO.Put_Line (Spec_File, " procedure Store (The_" & Base_Name & " : " & Base_Name & "'Class;"); IO.Put_Line (Spec_File, " Result : out " & Handle_Name & ";"); IO.Put_Line (Spec_File, " Success : out Boolean) with"); IO.Put_Line (Spec_File, " Post => (if Success then Is_Valid (Result));"); IO.Put_Line (Spec_File, " function Retrieve (Handle : " & Handle_Name & ") return " & Base_Name & "'Class with"); IO.Put_Line (Spec_File, " Pre => Is_Valid (Handle);"); IO.Put_Line (Body_File, " function Retrieve (Handle : Expr_Handle) return Expr'Class is"); IO.Put_Line (Body_File, " begin"); IO.Put_Line (Body_File, " return Storage.Element (Container, Handle);"); IO.Put_Line (Body_File, " end Retrieve;"); IO.Put_Line (Body_File, " procedure Store (The_" & Base_Name & " : " & Base_Name & "'Class;"); IO.Put_Line (Body_File, " Result : out " & Handle_Name & ";"); IO.Put_Line (Body_File, " Success : out Boolean) is separate;"); -- The AST classes. for The_Type of Types loop declare Class_Name : constant String := Substring (The_Type.all, ":", 1); Fields : constant String := Substring (The_Type.all, ":", 2); begin Define_Type (Spec_File, Body_File, Base_Name, Class_Name, Fields); end; end loop; Define_Visitor (Spec_File, Body_File, Base_Name, Types); for The_Type of Types loop declare Class_Name : constant String := Substring (The_Type.all, ":", 1); Fields : constant String := Substring (The_Type.all, ":", 2); begin Define_Subprogram (Spec_File, Body_File, Base_Name, Class_Name, Fields); end; end loop; IO.New_Line (Spec_File); -- The base accept() method. IO.Put_Line (Spec_File, " procedure Accept_Visitor (Self : Expr; V : " & "in out Visitors.Visitor'Class) with " & "Global => (Input => State);"); IO.Put_Line (Body_File, " procedure Accept_Visitor (Self : Expr; V : " & "in out Visitors.Visitor'Class) is "); IO.Put_Line (Body_File, " begin"); IO.Put_Line (Body_File, " null; -- maybe raise an exception here"); IO.Put_Line (Body_File, " end Accept_Visitor;"); IO.New_Line (Body_File); IO.Put_Line (Spec_File, "private"); IO.Put_Line (Spec_File, " type " & Base_Name & " is abstract tagged null record;"); Define_Storage (Spec_File, Base_Name); for The_Type of Types loop declare Class_Name : constant String := Substring (The_Type.all, ":", 1); Fields : constant String := Substring (The_Type.all, ":", 2); begin Define_Full_Type (Spec_File, Body_File, Base_Name, Class_Name, Fields); end; end loop; IO.Put_Line (Spec_File, "end " & Base_Name & "s;"); IO.Close (Spec_File); pragma Unreferenced (Spec_File); IO.Put_Line (Body_File, "begin"); for The_Type of Types loop declare Class_Name : constant String := Substring (The_Type.all, ":", 1); begin IO.Put_Line (Body_File, " pragma Assert (" & Class_Name & "'Size <= Max_Element_Size, Integer'Image (" & Class_Name & "'Size) & "" > Max_Element_Size"");"); end; end loop; IO.Put_Line (Body_File, "end " & Base_Name & "s;"); IO.Close (Body_File); pragma Unreferenced (Body_File); end Define_Ast; procedure Define_Full_Type (Spec_File, Body_File : IO.File_Type; Base_Name, Class_Name, Field_List : String) is pragma Unreferenced (Body_File); use Ada.Strings.Fixed; procedure Define_One_Type (Field_Name, Type_Name : String; Last : Boolean); procedure Define_One_Type (Field_Name, Type_Name : String; Last : Boolean) is pragma Unreferenced (Last); begin IO.Put_Line (Spec_File, " " & Field_Name & " : " & Type_Name & ";"); end Define_One_Type; procedure Iterate_Types is new Iterate_Fields (Define_One_Type); begin IO.Put (Spec_File, " type " & Class_Name & " is new " & Base_Name & " with "); if Field_List'Length > 0 then IO.Put_Line (Spec_File, "record"); Iterate_Types (Field_List); IO.Put_Line (Spec_File, " end record;"); else IO.Put_Line (Spec_File, "null record;"); end if; end Define_Full_Type; procedure Define_Storage (Spec_File : IO.File_Type; Base_Name : String) is Handle_Name : constant String := Base_Name & "_Handle"; begin IO.Put_Line (Spec_File, " Max_Element_Size : constant Natural := 2272;"); IO.Put_Line (Spec_File, " package Storage is new Ada.Containers.Formal_Indefinite_Vectors"); IO.Put_Line (Spec_File, " (Index_Type => " & Handle_Name & ","); IO.Put_Line (Spec_File, " Element_Type => " & Base_Name & "'Class,"); IO.Put_Line (Spec_File, " Max_Size_In_Storage_Elements => Max_Element_Size);"); IO.Put_Line (Spec_File, " -- Should be Bounded => False, but that triggers a prover bug"); IO.Put_Line (Spec_File, " pragma Compile_Time_Warning (True, ""gnatprove bug workaround"");"); IO.New_Line (Spec_File); IO.Put_Line (Spec_File, " Container : Storage.Vector (5) with Part_Of => State;"); IO.New_Line (Spec_File); end Define_Storage; procedure Define_Subprogram (Spec_File, Body_File : IO.File_Type; Base_Name, Class_Name, Field_List : String) is pragma Unreferenced (Field_List); use Ada.Strings.Fixed; begin -- Visitor pattern. IO.New_Line (Spec_File); IO.Put_Line (Spec_File, " procedure Accept_Visitor (Self : " & Class_Name & "; V : in out Visitors.Visitor'Class) with"); IO.Put_Line (Spec_File, " Global => (Input => State);"); IO.New_Line (Body_File); IO.Put_Line (Body_File, " overriding procedure Accept_Visitor (Self : " & Class_Name & "; V : in out Visitors.Visitor'Class) is"); IO.Put_Line (Body_File, " begin"); IO.Put_Line (Body_File, " V.Visit_" & Class_Name & "_" & Base_Name & " (Self);"); IO.Put_Line (Body_File, " end Accept_Visitor;"); end Define_Subprogram; procedure Define_Type (Spec_File, Body_File : IO.File_Type; Base_Name, Class_Name, Field_List : String) is use Ada.Strings.Fixed; procedure Define_Accessor (Field_Name, Type_Name : String; Last : Boolean); procedure Define_Parameter_Body (Field_Name, Type_Name : String; Last : Boolean); procedure Define_Parameter_Spec (Field_Name, Type_Name : String; Last : Boolean); procedure Initialize_Field (Field_Name, Type_Name : String; Last : Boolean); procedure Define_Accessor (Field_Name, Type_Name : String; Last : Boolean) is pragma Unreferenced (Last); begin IO.Put (Spec_File, " function Get_" & Field_Name & " (Self : " & Class_Name & ") return " & Type_Name); if Type_Name = Base_Name & "_Handle" then IO.Put_Line (Spec_File, " with"); IO.Put_Line (Spec_File, " Post => Is_Valid (Get_" & Field_Name & "'Result);"); else IO.Put_Line (Spec_File, ";"); end if; IO.New_Line (Body_File); IO.Put_Line (Body_File, " function Get_" & Field_Name & " (Self : " & Class_Name & ") return " & Type_Name & " is"); IO.Put_Line (Body_File, " begin"); IO.Put_Line (Body_File, " return Self." & Field_Name & ";"); IO.Put_Line (Body_File, " end Get_" & Field_Name & ";"); end Define_Accessor; procedure Define_Parameter_Body (Field_Name, Type_Name : String; Last : Boolean) is begin IO.Put (Body_File, "My_" & Field_Name & " : " & Type_Name); if not Last then IO.Put (Body_File, "; "); end if; end Define_Parameter_Body; procedure Define_Parameter_Spec (Field_Name, Type_Name : String; Last : Boolean) is begin IO.Put (Spec_File, "My_" & Field_Name & " : " & Type_Name); if not Last then IO.Put (Spec_File, "; "); end if; end Define_Parameter_Spec; procedure Initialize_Field (Field_Name, Type_Name : String; Last : Boolean) is pragma Unreferenced (Type_Name, Last); begin IO.Put_Line (Body_File, " E." & Field_Name & " := My_" & Field_Name & ";"); end Initialize_Field; procedure Iterate_Accessors is new Iterate_Fields (Define_Accessor); procedure Iterate_Initialization is new Iterate_Fields (Initialize_Field); procedure Iterate_Parameters_Body is new Iterate_Fields (Define_Parameter_Body); procedure Iterate_Parameters_Spec is new Iterate_Fields (Define_Parameter_Spec); begin IO.Put_Line (Spec_File, ""); IO.Put_Line (Spec_File, " type " & Class_Name & " is new " & Base_Name & " with private;"); Iterate_Accessors (Field_List); IO.Put (Spec_File, " procedure Create_" & Class_Name & " ("); IO.New_Line (Body_File); IO.Put (Body_File, " procedure Create_" & Class_Name & " ("); Iterate_Parameters_Spec (Field_List); IO.Put_Line (Spec_File, "; Result : out " & Base_Name & "_Handle);"); Iterate_Parameters_Body (Field_List); IO.Put_Line (Body_File, "; Result : out " & Base_Name & "_Handle) is"); IO.Put_Line (Body_File, " E : " & Class_Name & ";"); IO.Put_Line (Body_File, " Success : Boolean;"); IO.Put_Line (Body_File, " begin"); Iterate_Initialization (Field_List); IO.Put_Line (Body_File, " Store (E, Result, Success);"); IO.Put_Line (Body_File, " end Create_" & Class_Name & ";"); end Define_Type; procedure Define_Visitor (Spec_File, Body_File : IO.File_Type; Base_Name : String; Types : String_Array) is begin IO.Put_Line (Spec_File, " package Visitors is"); IO.Put_Line (Spec_File, " type Visitor is tagged null record;"); IO.Put_Line (Body_File, " package body Visitors is"); for The_Type of Types loop declare Type_Name : constant String := Substring (The_Type.all, ":", 1); begin IO.Put_Line (Spec_File, " procedure Visit_" & Type_Name & "_" & Base_Name & " (Self : in out Visitor; The_" & Base_Name & " : " & Type_Name & ") with"); IO.Put_Line (Spec_File, " Global => (Input => Exprs.State);"); IO.Put_Line (Body_File, " procedure Visit_" & Type_Name & "_" & Base_Name & " (Self : in out Visitor; The_" & Base_Name & " : " & Type_Name & ") is"); IO.Put_Line (Body_File, " begin"); IO.Put_Line (Body_File, " null;"); IO.Put_Line (Body_File, " end Visit_" & Type_Name & "_" & Base_Name & ";"); IO.New_Line (Body_File); end; end loop; IO.Put_Line (Spec_File, " end Visitors;"); IO.Put_Line (Body_File, " end Visitors;"); end Define_Visitor; procedure Iterate_Fields (List : String) is use Ada.Strings.Fixed; Before, After : Natural := List'First; begin while After < List'Last loop Before := After; After := Index (Source => List, Pattern => ", ", From => Before + 1); if After = 0 then After := List'Last + 1; end if; if Before = List'First then Before := List'First - 1; else -- at "," Before := Before + 1; -- at " " end if; declare Field : constant String := List (Before + 1 .. After - 1); Space : constant Natural := Index (Source => Field, Pattern => " ", From => Field'First); Type_Name : constant String := Field (Field'First .. Space - 1); Field_Name : constant String := Field (Space + 1 .. Field'Last); begin Process_Field (Field_Name, Type_Name, After > List'Last); end; end loop; end Iterate_Fields; function Substring (Input, Separator : String; Item_Number : Positive) return String is use Ada.Strings.Fixed; Before, After : Natural := Input'First; begin for I in 1 .. Item_Number loop Before := After; After := Index (Source => Input, Pattern => Separator, From => Before + 1); if After = 0 then After := Input'Last + 1; end if; end loop; if Before > Input'First then return Trim (Input (Before + 1 .. After - 1), Ada.Strings.Both); else return Trim (Input (Input'First .. After - 1), Ada.Strings.Both); end if; end Substring; Spec_Binary : aliased constant String := "Binary :Expr_Handle left, Token operator, Expr_Handle right"; Spec_Grouping : aliased constant String := "Grouping :Expr_Handle expression"; -- Unlike Bob's original code, Literal types are separate. -- This avoids an indefinite type _inside_ Expr. -- Expr'Class is handled in package Storage, and accessed via a simple ID. -- Implementing this all over just to deal with different literal types is -- overkill. Instead, use the existing infrastructure, i.e. create new types -- deriving from Expr. Spec_Float_Literal : aliased constant String := "Float_Literal :Float value"; Spec_Num_Literal : aliased constant String := "Num_Literal :Integer value"; Spec_Str_Literal : aliased constant String := "Str_Literal :L_String value"; Spec_Unary : aliased constant String := "Unary :Token operator, Expr_Handle right"; begin if Command_Line.Argument_Count /= 1 then IO.Put_Line (IO.Standard_Error, "Usage: generate_ast <output directory>"); Command_Line.Set_Exit_Status (1); return; end if; Define_Ast (Command_Line.Argument (1), "Expr", String_Array'(Spec_Binary'Access, Spec_Grouping'Access, Spec_Float_Literal'Access, Spec_Num_Literal'Access, Spec_Str_Literal'Access, Spec_Unary'Access)); end Generate_Ast;
reznikmm/matreshka
Ada
4,706
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Draw_Image_Map_Elements; package Matreshka.ODF_Draw.Image_Map_Elements is type Draw_Image_Map_Element_Node is new Matreshka.ODF_Draw.Abstract_Draw_Element_Node and ODF.DOM.Draw_Image_Map_Elements.ODF_Draw_Image_Map with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Draw_Image_Map_Element_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Image_Map_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Draw_Image_Map_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Draw_Image_Map_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Draw_Image_Map_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Draw.Image_Map_Elements;
AdaCore/Ada_Drivers_Library
Ada
16,124
ads
-- Copyright (c) 2013, Nordic Semiconductor ASA -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * 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 Nordic Semiconductor ASA nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- This spec has been automatically generated from nrf51.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF_SVD.PPI is pragma Preelaborate; --------------- -- Registers -- --------------- --------------------------------------- -- PPI_TASKS_CHG cluster's Registers -- --------------------------------------- -- Channel group tasks. type PPI_TASKS_CHG_Cluster is record -- Enable channel group. EN : aliased HAL.UInt32; -- Disable channel group. DIS : aliased HAL.UInt32; end record with Size => 64; for PPI_TASKS_CHG_Cluster use record EN at 16#0# range 0 .. 31; DIS at 16#4# range 0 .. 31; end record; -- Channel group tasks. type PPI_TASKS_CHG_Clusters is array (0 .. 3) of PPI_TASKS_CHG_Cluster; -- Enable PPI channel 0. type CHEN_CH0_Field is (-- Channel disabled. Disabled, -- Channel enabled. Enabled) with Size => 1; for CHEN_CH0_Field use (Disabled => 0, Enabled => 1); -- CHEN_CH array type CHEN_CH_Field_Array is array (0 .. 2) of CHEN_CH0_Field with Component_Size => 1, Size => 3; -- Type definition for CHEN_CH type CHEN_CH_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt3; when True => -- CH as an array Arr : CHEN_CH_Field_Array; end case; end record with Unchecked_Union, Size => 3; for CHEN_CH_Field use record Val at 0 range 0 .. 2; Arr at 0 range 0 .. 2; end record; -- Enable PPI channel 3. type CHEN_CH3_Field is (-- Channel disabled Disabled, -- Channel enabled Enabled) with Size => 1; for CHEN_CH3_Field use (Disabled => 0, Enabled => 1); -- Enable PPI channel 4. type CHEN_CH4_Field is (-- Channel disabled. Disabled, -- Channel enabled. Enabled) with Size => 1; for CHEN_CH4_Field use (Disabled => 0, Enabled => 1); -- CHEN_CH array type CHEN_CH_Field_Array_1 is array (4 .. 15) of CHEN_CH4_Field with Component_Size => 1, Size => 12; -- Type definition for CHEN_CH type CHEN_CH_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt12; when True => -- CH as an array Arr : CHEN_CH_Field_Array_1; end case; end record with Unchecked_Union, Size => 12; for CHEN_CH_Field_1 use record Val at 0 range 0 .. 11; Arr at 0 range 0 .. 11; end record; -- Enable PPI channel 20. type CHEN_CH20_Field is (-- Channel disabled. Disabled, -- Channel enabled. Enabled) with Size => 1; for CHEN_CH20_Field use (Disabled => 0, Enabled => 1); -- CHEN_CH array type CHEN_CH_Field_Array_2 is array (20 .. 31) of CHEN_CH20_Field with Component_Size => 1, Size => 12; -- Type definition for CHEN_CH type CHEN_CH_Field_2 (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt12; when True => -- CH as an array Arr : CHEN_CH_Field_Array_2; end case; end record with Unchecked_Union, Size => 12; for CHEN_CH_Field_2 use record Val at 0 range 0 .. 11; Arr at 0 range 0 .. 11; end record; -- Channel enable. type CHEN_Register is record -- Enable PPI channel 0. CH : CHEN_CH_Field := (As_Array => False, Val => 16#0#); -- Enable PPI channel 3. CH3 : CHEN_CH3_Field := NRF_SVD.PPI.Disabled; -- Enable PPI channel 4. CH_1 : CHEN_CH_Field_1 := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_19 : HAL.UInt4 := 16#0#; -- Enable PPI channel 20. CH_2 : CHEN_CH_Field_2 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CHEN_Register use record CH at 0 range 0 .. 2; CH3 at 0 range 3 .. 3; CH_1 at 0 range 4 .. 15; Reserved_16_19 at 0 range 16 .. 19; CH_2 at 0 range 20 .. 31; end record; -- Enable PPI channel 0. type CHENSET_CH0_Field is (-- Channel disabled. Disabled, -- Channel enabled. Enabled) with Size => 1; for CHENSET_CH0_Field use (Disabled => 0, Enabled => 1); -- Enable PPI channel 0. type CHENSET_CH0_Field_1 is (-- Reset value for the field Chenset_Ch0_Field_Reset, -- Enable channel on write. Set) with Size => 1; for CHENSET_CH0_Field_1 use (Chenset_Ch0_Field_Reset => 0, Set => 1); -- CHENSET_CH array type CHENSET_CH_Field_Array is array (0 .. 15) of CHENSET_CH0_Field_1 with Component_Size => 1, Size => 16; -- Type definition for CHENSET_CH type CHENSET_CH_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt16; when True => -- CH as an array Arr : CHENSET_CH_Field_Array; end case; end record with Unchecked_Union, Size => 16; for CHENSET_CH_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- Enable PPI channel 20. type CHENSET_CH20_Field is (-- Channel disabled. Disabled, -- Channel enabled. Enabled) with Size => 1; for CHENSET_CH20_Field use (Disabled => 0, Enabled => 1); -- Enable PPI channel 20. type CHENSET_CH20_Field_1 is (-- Reset value for the field Chenset_Ch20_Field_Reset, -- Enable channel on write. Set) with Size => 1; for CHENSET_CH20_Field_1 use (Chenset_Ch20_Field_Reset => 0, Set => 1); -- CHENSET_CH array type CHENSET_CH_Field_Array_1 is array (20 .. 31) of CHENSET_CH20_Field_1 with Component_Size => 1, Size => 12; -- Type definition for CHENSET_CH type CHENSET_CH_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt12; when True => -- CH as an array Arr : CHENSET_CH_Field_Array_1; end case; end record with Unchecked_Union, Size => 12; for CHENSET_CH_Field_1 use record Val at 0 range 0 .. 11; Arr at 0 range 0 .. 11; end record; -- Channel enable set. type CHENSET_Register is record -- Enable PPI channel 0. CH : CHENSET_CH_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_19 : HAL.UInt4 := 16#0#; -- Enable PPI channel 20. CH_1 : CHENSET_CH_Field_1 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CHENSET_Register use record CH at 0 range 0 .. 15; Reserved_16_19 at 0 range 16 .. 19; CH_1 at 0 range 20 .. 31; end record; -- Disable PPI channel 0. type CHENCLR_CH0_Field is (-- Channel disabled. Disabled, -- Channel enabled. Enabled) with Size => 1; for CHENCLR_CH0_Field use (Disabled => 0, Enabled => 1); -- Disable PPI channel 0. type CHENCLR_CH0_Field_1 is (-- Reset value for the field Chenclr_Ch0_Field_Reset, -- Disable channel on write. Clear) with Size => 1; for CHENCLR_CH0_Field_1 use (Chenclr_Ch0_Field_Reset => 0, Clear => 1); -- CHENCLR_CH array type CHENCLR_CH_Field_Array is array (0 .. 15) of CHENCLR_CH0_Field_1 with Component_Size => 1, Size => 16; -- Type definition for CHENCLR_CH type CHENCLR_CH_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt16; when True => -- CH as an array Arr : CHENCLR_CH_Field_Array; end case; end record with Unchecked_Union, Size => 16; for CHENCLR_CH_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- Disable PPI channel 20. type CHENCLR_CH20_Field is (-- Channel disabled. Disabled, -- Channel enabled. Enabled) with Size => 1; for CHENCLR_CH20_Field use (Disabled => 0, Enabled => 1); -- Disable PPI channel 20. type CHENCLR_CH20_Field_1 is (-- Reset value for the field Chenclr_Ch20_Field_Reset, -- Disable channel on write. Clear) with Size => 1; for CHENCLR_CH20_Field_1 use (Chenclr_Ch20_Field_Reset => 0, Clear => 1); -- CHENCLR_CH array type CHENCLR_CH_Field_Array_1 is array (20 .. 31) of CHENCLR_CH20_Field_1 with Component_Size => 1, Size => 12; -- Type definition for CHENCLR_CH type CHENCLR_CH_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt12; when True => -- CH as an array Arr : CHENCLR_CH_Field_Array_1; end case; end record with Unchecked_Union, Size => 12; for CHENCLR_CH_Field_1 use record Val at 0 range 0 .. 11; Arr at 0 range 0 .. 11; end record; -- Channel enable clear. type CHENCLR_Register is record -- Disable PPI channel 0. CH : CHENCLR_CH_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_19 : HAL.UInt4 := 16#0#; -- Disable PPI channel 20. CH_1 : CHENCLR_CH_Field_1 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CHENCLR_Register use record CH at 0 range 0 .. 15; Reserved_16_19 at 0 range 16 .. 19; CH_1 at 0 range 20 .. 31; end record; -------------------------------- -- PPI_CH cluster's Registers -- -------------------------------- -- PPI Channel. type PPI_CH_Cluster is record -- Channel event end-point. EEP : aliased HAL.UInt32; -- Channel task end-point. TEP : aliased HAL.UInt32; end record with Size => 64; for PPI_CH_Cluster use record EEP at 16#0# range 0 .. 31; TEP at 16#4# range 0 .. 31; end record; -- PPI Channel. type PPI_CH_Clusters is array (0 .. 15) of PPI_CH_Cluster; -- Include CH0 in channel group. type CHG_CH0_Field is (-- Channel excluded. Excluded, -- Channel included. Included) with Size => 1; for CHG_CH0_Field use (Excluded => 0, Included => 1); -- CHG_CH array type CHG_CH_Field_Array is array (0 .. 15) of CHG_CH0_Field with Component_Size => 1, Size => 16; -- Type definition for CHG_CH type CHG_CH_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt16; when True => -- CH as an array Arr : CHG_CH_Field_Array; end case; end record with Unchecked_Union, Size => 16; for CHG_CH_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- Include CH20 in channel group. type CHG_CH20_Field is (-- Channel excluded. Excluded, -- Channel included. Included) with Size => 1; for CHG_CH20_Field use (Excluded => 0, Included => 1); -- CHG_CH array type CHG_CH_Field_Array_1 is array (20 .. 31) of CHG_CH20_Field with Component_Size => 1, Size => 12; -- Type definition for CHG_CH type CHG_CH_Field_1 (As_Array : Boolean := False) is record case As_Array is when False => -- CH as a value Val : HAL.UInt12; when True => -- CH as an array Arr : CHG_CH_Field_Array_1; end case; end record with Unchecked_Union, Size => 12; for CHG_CH_Field_1 use record Val at 0 range 0 .. 11; Arr at 0 range 0 .. 11; end record; -- Channel group configuration. type CHG_Register is record -- Include CH0 in channel group. CH : CHG_CH_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_19 : HAL.UInt4 := 16#0#; -- Include CH20 in channel group. CH_1 : CHG_CH_Field_1 := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CHG_Register use record CH at 0 range 0 .. 15; Reserved_16_19 at 0 range 16 .. 19; CH_1 at 0 range 20 .. 31; end record; -- Channel group configuration. type CHG_Registers is array (0 .. 3) of CHG_Register; ----------------- -- Peripherals -- ----------------- -- PPI controller. type PPI_Peripheral is record -- Channel group tasks. TASKS_CHG : aliased PPI_TASKS_CHG_Clusters; -- Channel enable. CHEN : aliased CHEN_Register; -- Channel enable set. CHENSET : aliased CHENSET_Register; -- Channel enable clear. CHENCLR : aliased CHENCLR_Register; -- PPI Channel. CH : aliased PPI_CH_Clusters; -- Channel group configuration. CHG : aliased CHG_Registers; end record with Volatile; for PPI_Peripheral use record TASKS_CHG at 16#0# range 0 .. 255; CHEN at 16#500# range 0 .. 31; CHENSET at 16#504# range 0 .. 31; CHENCLR at 16#508# range 0 .. 31; CH at 16#510# range 0 .. 1023; CHG at 16#800# range 0 .. 127; end record; -- PPI controller. PPI_Periph : aliased PPI_Peripheral with Import, Address => PPI_Base; end NRF_SVD.PPI;
damaki/SPARKNaCl
Ada
238
ads
private package SPARKNaCl.PDebug with SPARK_Mode => On is procedure DH16 (S : in String; D : in Normal_GF); procedure DH32 (S : in String; D : in GF32); procedure DH64 (S : in String; D : in GF64); end SPARKNaCl.PDebug;
reznikmm/matreshka
Ada
13,527
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Packageable_Elements; with AMF.UML.Dependencies.Collections; with AMF.UML.Instance_Specifications; with AMF.UML.Instance_Values; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements; with AMF.UML.String_Expressions; with AMF.UML.Template_Parameters; with AMF.UML.Types; with AMF.Visitors; package AMF.Internals.UML_Instance_Values is type UML_Instance_Value_Proxy is limited new AMF.Internals.UML_Packageable_Elements.UML_Packageable_Element_Proxy and AMF.UML.Instance_Values.UML_Instance_Value with null record; overriding function Get_Instance (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Instance_Specifications.UML_Instance_Specification_Access; -- Getter of InstanceValue::instance. -- -- The instance that is the specified value. overriding procedure Set_Instance (Self : not null access UML_Instance_Value_Proxy; To : AMF.UML.Instance_Specifications.UML_Instance_Specification_Access); -- Setter of InstanceValue::instance. -- -- The instance that is the specified value. overriding function Get_Type (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Types.UML_Type_Access; -- Getter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding procedure Set_Type (Self : not null access UML_Instance_Value_Proxy; To : AMF.UML.Types.UML_Type_Access); -- Setter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding function Get_Client_Dependency (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Instance_Value_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Instance_Value_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Instance_Value_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Instance_Value_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Boolean_Value (Self : not null access constant UML_Instance_Value_Proxy) return AMF.Optional_Boolean; -- Operation ValueSpecification::booleanValue. -- -- The query booleanValue() gives a single Boolean value when one can be -- computed. overriding function Integer_Value (Self : not null access constant UML_Instance_Value_Proxy) return AMF.Optional_Integer; -- Operation ValueSpecification::integerValue. -- -- The query integerValue() gives a single Integer value when one can be -- computed. overriding function Is_Compatible_With (Self : not null access constant UML_Instance_Value_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ValueSpecification::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. In addition, -- for ValueSpecification, the type must be conformant with the type of -- the specified parameterable element. overriding function Is_Computable (Self : not null access constant UML_Instance_Value_Proxy) return Boolean; -- Operation ValueSpecification::isComputable. -- -- The query isComputable() determines whether a value specification can -- be computed in a model. This operation cannot be fully defined in OCL. -- A conforming implementation is expected to deliver true for this -- operation for all value specifications that it can compute, and to -- compute all of those for which the operation is true. A conforming -- implementation is expected to be able to compute the value of all -- literals. overriding function Is_Null (Self : not null access constant UML_Instance_Value_Proxy) return Boolean; -- Operation ValueSpecification::isNull. -- -- The query isNull() returns true when it can be computed that the value -- is null. overriding function Real_Value (Self : not null access constant UML_Instance_Value_Proxy) return AMF.Optional_Real; -- Operation ValueSpecification::realValue. -- -- The query realValue() gives a single Real value when one can be -- computed. overriding function String_Value (Self : not null access constant UML_Instance_Value_Proxy) return AMF.Optional_String; -- Operation ValueSpecification::stringValue. -- -- The query stringValue() gives a single String value when one can be -- computed. overriding function Unlimited_Value (Self : not null access constant UML_Instance_Value_Proxy) return AMF.Optional_Unlimited_Natural; -- Operation ValueSpecification::unlimitedValue. -- -- The query unlimitedValue() gives a single UnlimitedNatural value when -- one can be computed. overriding function All_Owning_Packages (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Instance_Value_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Instance_Value_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Template_Parameter (Self : not null access constant UML_Instance_Value_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding procedure Enter_Element (Self : not null access constant UML_Instance_Value_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Instance_Value_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Instance_Value_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Instance_Values;
RREE/ada-util
Ada
17,232
adb
----------------------------------------------------------------------- -- util-serialize-io-csv -- CSV Serialization Driver -- Copyright (C) 2011, 2015, 2016, 2017, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Characters.Latin_1; with Ada.IO_Exceptions; with Ada.Containers; with Util.Strings; with Util.Dates.ISO8601; package body Util.Serialize.IO.CSV is -- ------------------------------ -- Set the field separator. The default field separator is the comma (','). -- ------------------------------ procedure Set_Field_Separator (Stream : in out Output_Stream; Separator : in Character) is begin Stream.Separator := Separator; end Set_Field_Separator; -- ------------------------------ -- Enable or disable the double quotes by default for strings. -- ------------------------------ procedure Set_Quotes (Stream : in out Output_Stream; Enable : in Boolean) is begin Stream.Quote := Enable; end Set_Quotes; -- ------------------------------ -- Write the value as a CSV cell. Special characters are escaped using the CSV -- escape rules. -- ------------------------------ procedure Write_Cell (Stream : in out Output_Stream; Value : in String) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Stream.Quote then Stream.Write ('"'); end if; for I in Value'Range loop if Value (I) = '"' then Stream.Write (""""""); else Stream.Write (Value (I)); end if; end loop; if Stream.Quote then Stream.Write ('"'); end if; end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Integer) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; Stream.Write (Util.Strings.Image (Value)); end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Boolean) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Value then Stream.Write ("true"); else Stream.Write ("false"); end if; end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Util.Beans.Objects.Object) is use Util.Beans.Objects; begin case Util.Beans.Objects.Get_Type (Value) is when TYPE_NULL => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Stream.Quote then Stream.Write ("""null"""); else Stream.Write ("null"); end if; when TYPE_BOOLEAN => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Util.Beans.Objects.To_Boolean (Value) then Stream.Write ("true"); else Stream.Write ("false"); end if; when TYPE_INTEGER => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; -- Stream.Write ('"'); Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value)); -- Stream.Write ('"'); when others => Stream.Write_Cell (Util.Beans.Objects.To_String (Value)); end case; end Write_Cell; -- ------------------------------ -- Start a new row. -- ------------------------------ procedure New_Row (Stream : in out Output_Stream) is begin while Stream.Column < Stream.Max_Columns loop Stream.Write (Stream.Separator); Stream.Column := Stream.Column + 1; end loop; Stream.Write (ASCII.CR); Stream.Write (ASCII.LF); Stream.Column := 1; Stream.Row := Stream.Row + 1; end New_Row; -- ----------------------- -- Write the attribute name/value pair. -- ----------------------- overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in String) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Wide_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin null; end Write_Wide_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Integer) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; -- ----------------------- -- Write the entity value. -- ----------------------- overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in String) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Wide_Entity (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin null; end Write_Wide_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Integer) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Ada.Calendar.Time) is begin Stream.Write_Entity (Name, Util.Dates.ISO8601.Image (Value, Util.Dates.ISO8601.SUBSECOND)); end Write_Entity; overriding procedure Write_Long_Entity (Stream : in out Output_Stream; Name : in String; Value : in Long_Long_Integer) is begin null; end Write_Long_Entity; overriding procedure Write_Enum_Entity (Stream : in out Output_Stream; Name : in String; Value : in String) is begin Stream.Write_Entity (Name, Value); end Write_Enum_Entity; -- ------------------------------ -- Write the attribute with a null value. -- ------------------------------ overriding procedure Write_Null_Attribute (Stream : in out Output_Stream; Name : in String) is begin Stream.Write_Entity (Name, ""); end Write_Null_Attribute; -- ------------------------------ -- Write an entity with a null value. -- ------------------------------ procedure Write_Null_Entity (Stream : in out Output_Stream; Name : in String) is begin Stream.Write_Null_Attribute (Name); end Write_Null_Entity; -- ------------------------------ -- Get the header name for the given column. -- If there was no header line, build a default header for the column. -- ------------------------------ function Get_Header_Name (Handler : in Parser; Column : in Column_Type) return String is use type Ada.Containers.Count_Type; Default_Header : constant String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Result : String (1 .. 10); N, R : Natural; Pos : Positive := Result'Last; begin if Handler.Headers.Length >= Ada.Containers.Count_Type (Column) then return Handler.Headers.Element (Positive (Column)); end if; N := Natural (Column - 1); loop R := N mod 26; N := N / 26; Result (Pos) := Default_Header (R + 1); exit when N = 0; Pos := Pos - 1; end loop; return Result (Pos .. Result'Last); end Get_Header_Name; -- ------------------------------ -- Set the cell value at the given row and column. -- The default implementation finds the column header name and -- invokes <b>Write_Entity</b> with the header name and the value. -- ------------------------------ procedure Set_Cell (Handler : in out Parser; Value : in String; Row : in Row_Type; Column : in Column_Type) is use Ada.Containers; begin if Row = 0 then -- Build the headers table. declare Missing : constant Integer := Integer (Column) - Integer (Handler.Headers.Length); begin if Missing > 0 then Handler.Headers.Set_Length (Handler.Headers.Length + Count_Type (Missing)); end if; Handler.Headers.Replace_Element (Positive (Column), Value); end; else declare Name : constant String := Handler.Get_Header_Name (Column); begin -- Detect a new row. Close the current object and start a new one. if Handler.Row /= Row then if Row > 1 then Handler.Sink.Finish_Object ("", Handler); else Handler.Sink.Start_Array ("", Handler); end if; Handler.Sink.Start_Object ("", Handler); end if; Handler.Row := Row; Handler.Sink.Set_Member (Name, Util.Beans.Objects.To_Object (Value), Handler); end; end if; end Set_Cell; -- ------------------------------ -- Set the field separator. The default field separator is the comma (','). -- ------------------------------ procedure Set_Field_Separator (Handler : in out Parser; Separator : in Character) is begin Handler.Separator := Separator; end Set_Field_Separator; -- ------------------------------ -- Get the field separator. -- ------------------------------ function Get_Field_Separator (Handler : in Parser) return Character is begin return Handler.Separator; end Get_Field_Separator; -- ------------------------------ -- Set the comment separator. When a comment separator is defined, a line which starts -- with the comment separator will be ignored. The row number will not be incremented. -- ------------------------------ procedure Set_Comment_Separator (Handler : in out Parser; Separator : in Character) is begin Handler.Comment := Separator; end Set_Comment_Separator; -- ------------------------------ -- Get the comment separator. Returns ASCII.NUL if comments are not supported. -- ------------------------------ function Get_Comment_Separator (Handler : in Parser) return Character is begin return Handler.Comment; end Get_Comment_Separator; -- ------------------------------ -- Setup the CSV parser and mapper to use the default column header names. -- When activated, the first row is assumed to contain the first item to de-serialize. -- ------------------------------ procedure Set_Default_Headers (Handler : in out Parser; Mode : in Boolean := True) is begin Handler.Use_Default_Headers := Mode; end Set_Default_Headers; -- ------------------------------ -- Parse the stream using the CSV parser. -- Call <b>Set_Cell</b> for each cell that has been parsed indicating the row and -- column numbers as well as the cell value. -- ------------------------------ overriding procedure Parse (Handler : in out Parser; Stream : in out Util.Streams.Buffered.Input_Buffer_Stream'Class; Sink : in out Reader'Class) is use Ada.Strings.Unbounded; C : Character; Token : Unbounded_String; Column : Column_Type := 1; Row : Row_Type := 0; In_Quote_Token : Boolean := False; In_Escape : Boolean := False; Ignore_Row : Boolean := False; begin if Handler.Use_Default_Headers then Row := 1; end if; Handler.Headers.Clear; Handler.Sink := Sink'Unchecked_Access; loop Stream.Read (Char => C); if C = Ada.Characters.Latin_1.CR or C = Ada.Characters.Latin_1.LF then if C = Ada.Characters.Latin_1.LF then Handler.Line_Number := Handler.Line_Number + 1; end if; if not Ignore_Row then if In_Quote_Token and not In_Escape then Append (Token, C); elsif Column > 1 or else Length (Token) > 0 then Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Set_Unbounded_String (Token, ""); Row := Row + 1; Column := 1; In_Quote_Token := False; In_Escape := False; end if; else Ignore_Row := False; end if; elsif C = Handler.Separator and not Ignore_Row then if In_Quote_Token and not In_Escape then Append (Token, C); else Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Set_Unbounded_String (Token, ""); Column := Column + 1; In_Quote_Token := False; In_Escape := False; end if; elsif C = '"' and not Ignore_Row then if In_Quote_Token then In_Escape := True; elsif In_Escape then Append (Token, C); In_Escape := False; elsif Ada.Strings.Unbounded.Length (Token) = 0 then In_Quote_Token := True; else Append (Token, C); end if; elsif C = Handler.Comment and Handler.Comment /= ASCII.NUL and Column = 1 and Length (Token) = 0 then Ignore_Row := True; elsif not Ignore_Row then Append (Token, C); In_Escape := False; end if; end loop; exception when Ada.IO_Exceptions.Data_Error => Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Handler.Sink := null; return; end Parse; -- ------------------------------ -- Get the current location (file and line) to report an error message. -- ------------------------------ overriding function Get_Location (Handler : in Parser) return String is begin return Util.Strings.Image (Handler.Line_Number); end Get_Location; end Util.Serialize.IO.CSV;
reznikmm/matreshka
Ada
4,575
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Draw.Points_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Points_Attribute_Node is begin return Self : Draw_Points_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Points_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Points_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Points_Attribute, Draw_Points_Attribute_Node'Tag); end Matreshka.ODF_Draw.Points_Attributes;
Fabien-Chouteau/GESTE-examples
Ada
2,134
adb
with SDL_Display; package body Render is Width : constant := 320; Height : constant := 240; package Display is new SDL_Display (Width => Width, Height => Height, Pixel_Scale => 3, Buffer_Size => 320 * 240); Screen_Pt : GESTE.Pix_Point := (0, 0); ----------------- -- Push_Pixels -- ----------------- procedure Push_Pixels (Buffer : GESTE.Output_Buffer) renames Display.Push_Pixels; ---------------------- -- Set_Drawing_Area -- ---------------------- procedure Set_Drawing_Area (Area : GESTE.Pix_Rect) renames Display.Set_Drawing_Area; ----------------------- -- Set_Screen_Offset -- ----------------------- procedure Set_Screen_Offset (Pt : GESTE.Pix_Point) is begin Display.Set_Screen_Offset (Pt); Screen_Pt := Pt; end Set_Screen_Offset; ---------------- -- Render_All -- ---------------- procedure Render_All (Background : GESTE_Config.Output_Color) is begin GESTE.Render_All ((Screen_Pt, (Screen_Pt.X + Width - 1, Screen_Pt.Y + Height - 1)), Background, Display.Buffer, Display.Push_Pixels'Access, Display.Set_Drawing_Area'Access); Display.Update; end Render_All; ------------------ -- Render_Dirty -- ------------------ procedure Render_Dirty (Background : GESTE_Config.Output_Color) is begin GESTE.Render_Dirty ((Screen_Pt, (Screen_Pt.X + Width - 1, Screen_Pt.Y + Height - 1)), Background, Display.Buffer, Display.Push_Pixels'Access, Display.Set_Drawing_Area'Access); Display.Update; end Render_Dirty; ---------- -- Kill -- ---------- procedure Kill is begin Display.Kill; end Kill; --------------- -- Dark_Cyan -- --------------- function Dark_Cyan return GESTE_Config.Output_Color is (Display.To_SDL_Color (176, 226, 255)); ----------- -- Black -- ----------- function Black return GESTE_Config.Output_Color is (Display.To_SDL_Color (0, 0, 0)); end Render;
onox/orka
Ada
723
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Orka.SIMD.SSE2 is pragma Pure; end Orka.SIMD.SSE2;
Skyfold/aws_sorter
Ada
1,426
adb
with generic_MergeSort; package body sorter is package sort_Float is new generic_MergeSort (Element => Float,">" => ">"); use sort_Float; subtype number_array is sort_Float.Element_Array; empty_number_array : constant number_array (2 .. 1) := (others => 0.0); ------------------ -- parse_string -- ------------------ function parse_string (text : String) return number_array is begin if text'Length = 0 then return empty_number_array; else for i in text'Range loop if text (i) = ',' then return Float'Value (text (text'First .. i - 1)) & parse_string (text (i + 1 .. text'Last)); end if; end loop; return Float'Value (text) & empty_number_array; end if; end parse_string; --------------- -- to_string -- --------------- function to_string (numbers : number_array) return String is begin if numbers'Length = 0 then return ""; elsif numbers'Length = 1 then return Float'Image (numbers (numbers'First)); else return Float'Image (numbers (numbers'First)) & ',' & to_string (numbers (numbers'First + 1 .. numbers'Last)); end if; end to_string; ---------- -- sort -- ---------- function sort (text : String) return String is begin return to_string ( sort_Float.merge_sort (parse_string (text))); end sort; end sorter;
thierr26/ada-keystore
Ada
10,514
adb
----------------------------------------------------------------------- -- keystore-passwords-files -- File based password provider -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Interfaces.C.Strings; with Ada.Directories; with Ada.Streams.Stream_IO; with Util.Systems.Types; with Util.Systems.Os; with Util.Log.Loggers; with Keystore.Random; package body Keystore.Passwords.Files is subtype Key_Length is Util.Encoders.Key_Length; use type Ada.Streams.Stream_Element_Offset; -- GNAT 2019 complains about unused use type but gcc 7.4 fails if it not defined (st_mode). pragma Warnings (Off); use type Interfaces.C.int; use type Interfaces.C.unsigned; use type Interfaces.C.unsigned_short; pragma Warnings (On); function Verify_And_Get_Size (Path : in String) return Ada.Streams.Stream_Element_Count; type Provider (Len : Key_Length) is limited new Keystore.Passwords.Provider with record Password : Ada.Streams.Stream_Element_Array (1 .. Len); end record; type File_Provider_Access is access all Provider; -- Get the password through the Getter operation. overriding procedure Get_Password (From : in Provider; Getter : not null access procedure (Password : in Secret_Key)); type Key_Provider (Len : Key_Length) is new Provider (Len) and Keys.Key_Provider and Internal_Key_Provider with null record; type Key_Provider_Access is access all Key_Provider'Class; -- Get the Key, IV and signature. overriding procedure Get_Keys (From : in Key_Provider; Key : out Secret_Key; IV : out Secret_Key; Sign : out Secret_Key); Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Passwords.Files"); overriding procedure Save_Key (Provider : in Key_Provider; Data : out Ada.Streams.Stream_Element_Array); function Verify_And_Get_Size (Path : in String) return Ada.Streams.Stream_Element_Count is P : Interfaces.C.Strings.chars_ptr; Stat : aliased Util.Systems.Types.Stat_Type; Res : Integer; Result : Ada.Streams.Stream_Element_Count; Dir : constant String := Ada.Directories.Containing_Directory (Path); begin -- Verify that the file is readable only by the current user. P := Interfaces.C.Strings.New_String (Path); Res := Util.Systems.Os.Sys_Stat (Path => P, Stat => Stat'Access); Interfaces.C.Strings.Free (P); if Res /= 0 then Log.Info ("Password file {0} does not exist", Path); raise Keystore.Bad_Password with "Password file does not exist"; end if; if (Stat.st_mode and 8#0077#) /= 0 and Util.Systems.Os.Directory_Separator = '/' then Log.Info ("Password file {0} is not safe", Path); raise Keystore.Bad_Password with "Password file is not safe"; end if; if Stat.st_size = 0 then Log.Info ("Password file {0} is empty", Path); raise Keystore.Bad_Password with "Password file is empty"; end if; if Stat.st_size > MAX_FILE_SIZE then Log.Info ("Password file {0} is too big", Path); raise Keystore.Bad_Password with "Password file is too big"; end if; Result := Ada.Streams.Stream_Element_Offset (Stat.st_size); -- Verify that the parent directory is readable only by the current user. P := Interfaces.C.Strings.New_String (Dir); Res := Util.Systems.Os.Sys_Stat (Path => P, Stat => Stat'Access); Interfaces.C.Strings.Free (P); if Res /= 0 then Log.Info ("Directory {0} is not safe for password file", Dir); raise Keystore.Bad_Password with "Directory that contains password file cannot be checked"; end if; if (Stat.st_mode and 8#0077#) /= 0 and Util.Systems.Os.Directory_Separator = '/' then Log.Info ("Directory {0} is not safe for password file", Dir); raise Keystore.Bad_Password with "Directory that contains password file is not safe"; end if; Log.Info ("Password file {0} passes the security checks", Path); return Result; end Verify_And_Get_Size; -- ------------------------------ -- Create a password provider that reads the file to build the password. -- The file must have the mode rw------- (600) and its owning directory -- the mode rwx------ (700). The Bad_Password exception is raised if -- these rules are not verified. -- ------------------------------ function Create (Path : in String) return Provider_Access is Size : Ada.Streams.Stream_Element_Offset; File : Ada.Streams.Stream_IO.File_Type; Result : File_Provider_Access; Last : Ada.Streams.Stream_Element_Offset; begin Size := Verify_And_Get_Size (Path); Ada.Streams.Stream_IO.Open (File => File, Mode => Ada.Streams.Stream_IO.In_File, Name => Path); Result := new Provider '(Len => Size, others => <>); Ada.Streams.Stream_IO.Read (File, Result.Password, Last); Ada.Streams.Stream_IO.Close (File); return Result.all'Access; end Create; -- ------------------------------ -- Get the password through the Getter operation. -- ------------------------------ overriding procedure Get_Password (From : in Provider; Getter : not null access procedure (Password : in Secret_Key)) is Password : Keystore.Secret_Key (Length => From.Len); begin Util.Encoders.Create (From.Password, Password); Getter (Password); end Get_Password; -- ------------------------------ -- Create a key provider that reads the file. The file is split in three parts -- the key, the IV, the signature which are extracted by using `Get_Keys`. -- ------------------------------ function Create (Path : in String) return Keys.Key_Provider_Access is Size : Ada.Streams.Stream_Element_Offset; File : Ada.Streams.Stream_IO.File_Type; Result : Key_Provider_Access; Last : Ada.Streams.Stream_Element_Offset; begin Size := Verify_And_Get_Size (Path); Ada.Streams.Stream_IO.Open (File => File, Mode => Ada.Streams.Stream_IO.In_File, Name => Path); Result := new Key_Provider '(Len => Size, others => <>); Ada.Streams.Stream_IO.Read (File, Result.Password, Last); Ada.Streams.Stream_IO.Close (File); return Result.all'Access; end Create; -- ------------------------------ -- Get the Key, IV and signature. -- ------------------------------ overriding procedure Get_Keys (From : in Key_Provider; Key : out Secret_Key; IV : out Secret_Key; Sign : out Secret_Key) is First : Ada.Streams.Stream_Element_Offset := 1; Last : Ada.Streams.Stream_Element_Offset := First + Key.Length - 1; begin if From.Len /= Key.Length + IV.Length + Sign.Length then raise Keystore.Bad_Password with "Invalid length for the key file"; end if; Util.Encoders.Create (From.Password (First .. Last), Key); First := Last + 1; Last := First + IV.Length - 1; Util.Encoders.Create (From.Password (First .. Last), IV); First := Last + 1; Last := First + Sign.Length - 1; Util.Encoders.Create (From.Password (First .. Last), Sign); end Get_Keys; overriding procedure Save_Key (Provider : in Key_Provider; Data : out Ada.Streams.Stream_Element_Array) is begin Data := Provider.Password; end Save_Key; -- ------------------------------ -- Generate a file that contains the keys. Keys are generated using a random generator. -- The file is created with the mode rw------- (600) and the owning directory is forced -- to the mode rwx------ (700). -- ------------------------------ function Generate (Path : in String; Length : in Key_Length := DEFAULT_KEY_FILE_LENGTH) return Keys.Key_Provider_Access is Result : Key_Provider_Access; Random : Keystore.Random.Generator; Dir : constant String := Ada.Directories.Containing_Directory (Path); File : Ada.Streams.Stream_IO.File_Type; P : Interfaces.C.Strings.chars_ptr; Res : Integer with Unreferenced; begin if not Ada.Directories.Exists (Dir) then Log.Info ("Creating directory {0}", Dir); Ada.Directories.Create_Path (Dir); end if; Log.Info ("Creating password file {0}", Path); Ada.Streams.Stream_IO.Create (File => File, Mode => Ada.Streams.Stream_IO.Out_File, Name => Path); Result := new Key_Provider '(Len => Length, others => <>); Random.Generate (Result.Password); Ada.Streams.Stream_IO.Write (File, Result.Password); Ada.Streams.Stream_IO.Close (File); P := Interfaces.C.Strings.New_String (Path); Res := Util.Systems.Os.Sys_Chmod (Path => P, Mode => 8#0600#); Interfaces.C.Strings.Free (P); P := Interfaces.C.Strings.New_String (Dir); Res := Util.Systems.Os.Sys_Chmod (Path => P, Mode => 8#0700#); Interfaces.C.Strings.Free (P); return Result.all'Access; end Generate; end Keystore.Passwords.Files;
fractal-mind/Amass
Ada
861
ads
-- Copyright 2022 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. name = "PublicWWW" type = "crawl" function start() set_rate_limit(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 scrape(ctx, {url=build_url(domain, c.key)}) end function build_url(domain, key) return "https://publicwww.com/websites/%22." .. domain .. "%22/?export=csvsnippetsu&key=" .. key end
pvrego/adaino
Ada
1,085
adb
with System.Machine_Code; with AVR.USART; with AVR.TWI; -- ============================================================================= -- Package body AVR.INTERRUPTS -- ============================================================================= package body AVR.INTERRUPTS is procedure Enable is begin System.Machine_Code.Asm ("sei", Volatile => True); end Enable; procedure Disable is begin System.Machine_Code.Asm ("cli", Volatile => True); end Disable; procedure Handle_Interrupt_USART0_RX is begin AVR.USART.Handle_ISR_RXC (AVR.USART.USART0); end Handle_Interrupt_USART0_RX; #if MCU="ATMEGA2560" then procedure Handle_Interrupt_USART2_RX is begin AVR.USART.Handle_ISR_RXC (AVR.USART.USART2); end Handle_Interrupt_USART2_RX; procedure Handle_Interrupt_USART3_RX is begin AVR.USART.Handle_ISR_RXC (AVR.USART.USART3); end Handle_Interrupt_USART3_RX; #end if; procedure Handle_Interrupt_TWI is begin AVR.TWI.Handle_Interrupts; end Handle_Interrupt_TWI; end AVR.INTERRUPTS;
reznikmm/matreshka
Ada
27,492
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ package AMF.Internals.Tables.CMOF_Metamodel.Links is procedure Initialize; private procedure Initialize_1; procedure Initialize_2; procedure Initialize_3; procedure Initialize_4; procedure Initialize_5; procedure Initialize_6; procedure Initialize_7; procedure Initialize_8; procedure Initialize_9; procedure Initialize_10; procedure Initialize_11; procedure Initialize_12; procedure Initialize_13; procedure Initialize_14; procedure Initialize_15; procedure Initialize_16; procedure Initialize_17; procedure Initialize_18; procedure Initialize_19; procedure Initialize_20; procedure Initialize_21; procedure Initialize_22; procedure Initialize_23; procedure Initialize_24; procedure Initialize_25; procedure Initialize_26; procedure Initialize_27; procedure Initialize_28; procedure Initialize_29; procedure Initialize_30; procedure Initialize_31; procedure Initialize_32; procedure Initialize_33; procedure Initialize_34; procedure Initialize_35; procedure Initialize_36; procedure Initialize_37; procedure Initialize_38; procedure Initialize_39; procedure Initialize_40; procedure Initialize_41; procedure Initialize_42; procedure Initialize_43; procedure Initialize_44; procedure Initialize_45; procedure Initialize_46; procedure Initialize_47; procedure Initialize_48; procedure Initialize_49; procedure Initialize_50; procedure Initialize_51; procedure Initialize_52; procedure Initialize_53; procedure Initialize_54; procedure Initialize_55; procedure Initialize_56; procedure Initialize_57; procedure Initialize_58; procedure Initialize_59; procedure Initialize_60; procedure Initialize_61; procedure Initialize_62; procedure Initialize_63; procedure Initialize_64; procedure Initialize_65; procedure Initialize_66; procedure Initialize_67; procedure Initialize_68; procedure Initialize_69; procedure Initialize_70; procedure Initialize_71; procedure Initialize_72; procedure Initialize_73; procedure Initialize_74; procedure Initialize_75; procedure Initialize_76; procedure Initialize_77; procedure Initialize_78; procedure Initialize_79; procedure Initialize_80; procedure Initialize_81; procedure Initialize_82; procedure Initialize_83; procedure Initialize_84; procedure Initialize_85; procedure Initialize_86; procedure Initialize_87; procedure Initialize_88; procedure Initialize_89; procedure Initialize_90; procedure Initialize_91; procedure Initialize_92; procedure Initialize_93; procedure Initialize_94; procedure Initialize_95; procedure Initialize_96; procedure Initialize_97; procedure Initialize_98; procedure Initialize_99; procedure Initialize_100; procedure Initialize_101; procedure Initialize_102; procedure Initialize_103; procedure Initialize_104; procedure Initialize_105; procedure Initialize_106; procedure Initialize_107; procedure Initialize_108; procedure Initialize_109; procedure Initialize_110; procedure Initialize_111; procedure Initialize_112; procedure Initialize_113; procedure Initialize_114; procedure Initialize_115; procedure Initialize_116; procedure Initialize_117; procedure Initialize_118; procedure Initialize_119; procedure Initialize_120; procedure Initialize_121; procedure Initialize_122; procedure Initialize_123; procedure Initialize_124; procedure Initialize_125; procedure Initialize_126; procedure Initialize_127; procedure Initialize_128; procedure Initialize_129; procedure Initialize_130; procedure Initialize_131; procedure Initialize_132; procedure Initialize_133; procedure Initialize_134; procedure Initialize_135; procedure Initialize_136; procedure Initialize_137; procedure Initialize_138; procedure Initialize_139; procedure Initialize_140; procedure Initialize_141; procedure Initialize_142; procedure Initialize_143; procedure Initialize_144; procedure Initialize_145; procedure Initialize_146; procedure Initialize_147; procedure Initialize_148; procedure Initialize_149; procedure Initialize_150; procedure Initialize_151; procedure Initialize_152; procedure Initialize_153; procedure Initialize_154; procedure Initialize_155; procedure Initialize_156; procedure Initialize_157; procedure Initialize_158; procedure Initialize_159; procedure Initialize_160; procedure Initialize_161; procedure Initialize_162; procedure Initialize_163; procedure Initialize_164; procedure Initialize_165; procedure Initialize_166; procedure Initialize_167; procedure Initialize_168; procedure Initialize_169; procedure Initialize_170; procedure Initialize_171; procedure Initialize_172; procedure Initialize_173; procedure Initialize_174; procedure Initialize_175; procedure Initialize_176; procedure Initialize_177; procedure Initialize_178; procedure Initialize_179; procedure Initialize_180; procedure Initialize_181; procedure Initialize_182; procedure Initialize_183; procedure Initialize_184; procedure Initialize_185; procedure Initialize_186; procedure Initialize_187; procedure Initialize_188; procedure Initialize_189; procedure Initialize_190; procedure Initialize_191; procedure Initialize_192; procedure Initialize_193; procedure Initialize_194; procedure Initialize_195; procedure Initialize_196; procedure Initialize_197; procedure Initialize_198; procedure Initialize_199; procedure Initialize_200; procedure Initialize_201; procedure Initialize_202; procedure Initialize_203; procedure Initialize_204; procedure Initialize_205; procedure Initialize_206; procedure Initialize_207; procedure Initialize_208; procedure Initialize_209; procedure Initialize_210; procedure Initialize_211; procedure Initialize_212; procedure Initialize_213; procedure Initialize_214; procedure Initialize_215; procedure Initialize_216; procedure Initialize_217; procedure Initialize_218; procedure Initialize_219; procedure Initialize_220; procedure Initialize_221; procedure Initialize_222; procedure Initialize_223; procedure Initialize_224; procedure Initialize_225; procedure Initialize_226; procedure Initialize_227; procedure Initialize_228; procedure Initialize_229; procedure Initialize_230; procedure Initialize_231; procedure Initialize_232; procedure Initialize_233; procedure Initialize_234; procedure Initialize_235; procedure Initialize_236; procedure Initialize_237; procedure Initialize_238; procedure Initialize_239; procedure Initialize_240; procedure Initialize_241; procedure Initialize_242; procedure Initialize_243; procedure Initialize_244; procedure Initialize_245; procedure Initialize_246; procedure Initialize_247; procedure Initialize_248; procedure Initialize_249; procedure Initialize_250; procedure Initialize_251; procedure Initialize_252; procedure Initialize_253; procedure Initialize_254; procedure Initialize_255; procedure Initialize_256; procedure Initialize_257; procedure Initialize_258; procedure Initialize_259; procedure Initialize_260; procedure Initialize_261; procedure Initialize_262; procedure Initialize_263; procedure Initialize_264; procedure Initialize_265; procedure Initialize_266; procedure Initialize_267; procedure Initialize_268; procedure Initialize_269; procedure Initialize_270; procedure Initialize_271; procedure Initialize_272; procedure Initialize_273; procedure Initialize_274; procedure Initialize_275; procedure Initialize_276; procedure Initialize_277; procedure Initialize_278; procedure Initialize_279; procedure Initialize_280; procedure Initialize_281; procedure Initialize_282; procedure Initialize_283; procedure Initialize_284; procedure Initialize_285; procedure Initialize_286; procedure Initialize_287; procedure Initialize_288; procedure Initialize_289; procedure Initialize_290; procedure Initialize_291; procedure Initialize_292; procedure Initialize_293; procedure Initialize_294; procedure Initialize_295; procedure Initialize_296; procedure Initialize_297; procedure Initialize_298; procedure Initialize_299; procedure Initialize_300; procedure Initialize_301; procedure Initialize_302; procedure Initialize_303; procedure Initialize_304; procedure Initialize_305; procedure Initialize_306; procedure Initialize_307; procedure Initialize_308; procedure Initialize_309; procedure Initialize_310; procedure Initialize_311; procedure Initialize_312; procedure Initialize_313; procedure Initialize_314; procedure Initialize_315; procedure Initialize_316; procedure Initialize_317; procedure Initialize_318; procedure Initialize_319; procedure Initialize_320; procedure Initialize_321; procedure Initialize_322; procedure Initialize_323; procedure Initialize_324; procedure Initialize_325; procedure Initialize_326; procedure Initialize_327; procedure Initialize_328; procedure Initialize_329; procedure Initialize_330; procedure Initialize_331; procedure Initialize_332; procedure Initialize_333; procedure Initialize_334; procedure Initialize_335; procedure Initialize_336; procedure Initialize_337; procedure Initialize_338; procedure Initialize_339; procedure Initialize_340; procedure Initialize_341; procedure Initialize_342; procedure Initialize_343; procedure Initialize_344; procedure Initialize_345; procedure Initialize_346; procedure Initialize_347; procedure Initialize_348; procedure Initialize_349; procedure Initialize_350; procedure Initialize_351; procedure Initialize_352; procedure Initialize_353; procedure Initialize_354; procedure Initialize_355; procedure Initialize_356; procedure Initialize_357; procedure Initialize_358; procedure Initialize_359; procedure Initialize_360; procedure Initialize_361; procedure Initialize_362; procedure Initialize_363; procedure Initialize_364; procedure Initialize_365; procedure Initialize_366; procedure Initialize_367; procedure Initialize_368; procedure Initialize_369; procedure Initialize_370; procedure Initialize_371; procedure Initialize_372; procedure Initialize_373; procedure Initialize_374; procedure Initialize_375; procedure Initialize_376; procedure Initialize_377; procedure Initialize_378; procedure Initialize_379; procedure Initialize_380; procedure Initialize_381; procedure Initialize_382; procedure Initialize_383; procedure Initialize_384; procedure Initialize_385; procedure Initialize_386; procedure Initialize_387; procedure Initialize_388; procedure Initialize_389; procedure Initialize_390; procedure Initialize_391; procedure Initialize_392; procedure Initialize_393; procedure Initialize_394; procedure Initialize_395; procedure Initialize_396; procedure Initialize_397; procedure Initialize_398; procedure Initialize_399; procedure Initialize_400; procedure Initialize_401; procedure Initialize_402; procedure Initialize_403; procedure Initialize_404; procedure Initialize_405; procedure Initialize_406; procedure Initialize_407; procedure Initialize_408; procedure Initialize_409; procedure Initialize_410; procedure Initialize_411; procedure Initialize_412; procedure Initialize_413; procedure Initialize_414; procedure Initialize_415; procedure Initialize_416; procedure Initialize_417; procedure Initialize_418; procedure Initialize_419; procedure Initialize_420; procedure Initialize_421; procedure Initialize_422; procedure Initialize_423; procedure Initialize_424; procedure Initialize_425; procedure Initialize_426; procedure Initialize_427; procedure Initialize_428; procedure Initialize_429; procedure Initialize_430; procedure Initialize_431; procedure Initialize_432; procedure Initialize_433; procedure Initialize_434; procedure Initialize_435; procedure Initialize_436; procedure Initialize_437; procedure Initialize_438; procedure Initialize_439; procedure Initialize_440; procedure Initialize_441; procedure Initialize_442; procedure Initialize_443; procedure Initialize_444; procedure Initialize_445; procedure Initialize_446; procedure Initialize_447; procedure Initialize_448; procedure Initialize_449; procedure Initialize_450; procedure Initialize_451; procedure Initialize_452; procedure Initialize_453; procedure Initialize_454; procedure Initialize_455; procedure Initialize_456; procedure Initialize_457; procedure Initialize_458; procedure Initialize_459; procedure Initialize_460; procedure Initialize_461; procedure Initialize_462; procedure Initialize_463; procedure Initialize_464; procedure Initialize_465; procedure Initialize_466; procedure Initialize_467; procedure Initialize_468; procedure Initialize_469; procedure Initialize_470; procedure Initialize_471; procedure Initialize_472; procedure Initialize_473; procedure Initialize_474; procedure Initialize_475; procedure Initialize_476; procedure Initialize_477; procedure Initialize_478; procedure Initialize_479; procedure Initialize_480; procedure Initialize_481; procedure Initialize_482; procedure Initialize_483; procedure Initialize_484; procedure Initialize_485; procedure Initialize_486; procedure Initialize_487; procedure Initialize_488; procedure Initialize_489; procedure Initialize_490; procedure Initialize_491; procedure Initialize_492; procedure Initialize_493; procedure Initialize_494; procedure Initialize_495; procedure Initialize_496; procedure Initialize_497; procedure Initialize_498; procedure Initialize_499; procedure Initialize_500; procedure Initialize_501; procedure Initialize_502; procedure Initialize_503; procedure Initialize_504; procedure Initialize_505; procedure Initialize_506; procedure Initialize_507; procedure Initialize_508; procedure Initialize_509; procedure Initialize_510; procedure Initialize_511; procedure Initialize_512; procedure Initialize_513; procedure Initialize_514; procedure Initialize_515; procedure Initialize_516; procedure Initialize_517; procedure Initialize_518; procedure Initialize_519; procedure Initialize_520; procedure Initialize_521; procedure Initialize_522; procedure Initialize_523; procedure Initialize_524; procedure Initialize_525; procedure Initialize_526; procedure Initialize_527; procedure Initialize_528; procedure Initialize_529; procedure Initialize_530; procedure Initialize_531; procedure Initialize_532; procedure Initialize_533; procedure Initialize_534; procedure Initialize_535; procedure Initialize_536; procedure Initialize_537; procedure Initialize_538; procedure Initialize_539; procedure Initialize_540; procedure Initialize_541; procedure Initialize_542; procedure Initialize_543; procedure Initialize_544; procedure Initialize_545; procedure Initialize_546; procedure Initialize_547; procedure Initialize_548; procedure Initialize_549; procedure Initialize_550; procedure Initialize_551; procedure Initialize_552; procedure Initialize_553; procedure Initialize_554; procedure Initialize_555; procedure Initialize_556; procedure Initialize_557; procedure Initialize_558; procedure Initialize_559; procedure Initialize_560; procedure Initialize_561; procedure Initialize_562; procedure Initialize_563; procedure Initialize_564; procedure Initialize_565; procedure Initialize_566; procedure Initialize_567; procedure Initialize_568; procedure Initialize_569; procedure Initialize_570; procedure Initialize_571; procedure Initialize_572; procedure Initialize_573; procedure Initialize_574; procedure Initialize_575; procedure Initialize_576; procedure Initialize_577; procedure Initialize_578; procedure Initialize_579; procedure Initialize_580; procedure Initialize_581; procedure Initialize_582; procedure Initialize_583; procedure Initialize_584; procedure Initialize_585; procedure Initialize_586; procedure Initialize_587; procedure Initialize_588; procedure Initialize_589; procedure Initialize_590; procedure Initialize_591; procedure Initialize_592; procedure Initialize_593; procedure Initialize_594; procedure Initialize_595; procedure Initialize_596; procedure Initialize_597; procedure Initialize_598; procedure Initialize_599; procedure Initialize_600; procedure Initialize_601; procedure Initialize_602; procedure Initialize_603; procedure Initialize_604; procedure Initialize_605; procedure Initialize_606; procedure Initialize_607; procedure Initialize_608; procedure Initialize_609; procedure Initialize_610; procedure Initialize_611; procedure Initialize_612; procedure Initialize_613; procedure Initialize_614; procedure Initialize_615; procedure Initialize_616; procedure Initialize_617; procedure Initialize_618; procedure Initialize_619; procedure Initialize_620; procedure Initialize_621; procedure Initialize_622; procedure Initialize_623; procedure Initialize_624; procedure Initialize_625; procedure Initialize_626; procedure Initialize_627; procedure Initialize_628; procedure Initialize_629; procedure Initialize_630; procedure Initialize_631; procedure Initialize_632; procedure Initialize_633; procedure Initialize_634; procedure Initialize_635; procedure Initialize_636; procedure Initialize_637; procedure Initialize_638; procedure Initialize_639; procedure Initialize_640; procedure Initialize_641; procedure Initialize_642; procedure Initialize_643; procedure Initialize_644; procedure Initialize_645; procedure Initialize_646; procedure Initialize_647; procedure Initialize_648; procedure Initialize_649; procedure Initialize_650; procedure Initialize_651; procedure Initialize_652; procedure Initialize_653; procedure Initialize_654; procedure Initialize_655; procedure Initialize_656; procedure Initialize_657; procedure Initialize_658; procedure Initialize_659; procedure Initialize_660; procedure Initialize_661; procedure Initialize_662; procedure Initialize_663; procedure Initialize_664; procedure Initialize_665; procedure Initialize_666; procedure Initialize_667; procedure Initialize_668; procedure Initialize_669; procedure Initialize_670; procedure Initialize_671; procedure Initialize_672; procedure Initialize_673; procedure Initialize_674; procedure Initialize_675; procedure Initialize_676; procedure Initialize_677; procedure Initialize_678; procedure Initialize_679; procedure Initialize_680; procedure Initialize_681; procedure Initialize_682; procedure Initialize_683; procedure Initialize_684; procedure Initialize_685; procedure Initialize_686; procedure Initialize_687; procedure Initialize_688; procedure Initialize_689; procedure Initialize_690; procedure Initialize_691; procedure Initialize_692; procedure Initialize_693; procedure Initialize_694; procedure Initialize_695; procedure Initialize_696; procedure Initialize_697; procedure Initialize_698; procedure Initialize_699; procedure Initialize_700; procedure Initialize_701; procedure Initialize_702; procedure Initialize_703; procedure Initialize_704; procedure Initialize_705; procedure Initialize_706; procedure Initialize_707; procedure Initialize_708; procedure Initialize_709; procedure Initialize_710; procedure Initialize_711; procedure Initialize_712; procedure Initialize_713; procedure Initialize_714; procedure Initialize_715; procedure Initialize_716; procedure Initialize_717; procedure Initialize_718; procedure Initialize_719; procedure Initialize_720; procedure Initialize_721; procedure Initialize_722; procedure Initialize_723; procedure Initialize_724; procedure Initialize_725; procedure Initialize_726; procedure Initialize_727; procedure Initialize_728; procedure Initialize_729; procedure Initialize_730; procedure Initialize_731; procedure Initialize_732; procedure Initialize_733; procedure Initialize_734; procedure Initialize_735; procedure Initialize_736; procedure Initialize_737; procedure Initialize_738; procedure Initialize_739; procedure Initialize_740; procedure Initialize_741; procedure Initialize_742; procedure Initialize_743; procedure Initialize_744; procedure Initialize_745; procedure Initialize_746; procedure Initialize_747; procedure Initialize_748; procedure Initialize_749; procedure Initialize_750; procedure Initialize_751; procedure Initialize_752; procedure Initialize_753; procedure Initialize_754; procedure Initialize_755; procedure Initialize_756; procedure Initialize_757; procedure Initialize_758; procedure Initialize_759; procedure Initialize_760; procedure Initialize_761; procedure Initialize_762; procedure Initialize_763; procedure Initialize_764; procedure Initialize_765; procedure Initialize_766; procedure Initialize_767; procedure Initialize_768; procedure Initialize_769; procedure Initialize_770; procedure Initialize_771; procedure Initialize_772; procedure Initialize_773; procedure Initialize_774; procedure Initialize_775; procedure Initialize_776; procedure Initialize_777; procedure Initialize_778; procedure Initialize_779; procedure Initialize_780; procedure Initialize_781; procedure Initialize_782; procedure Initialize_783; procedure Initialize_784; procedure Initialize_785; procedure Initialize_786; procedure Initialize_787; procedure Initialize_788; procedure Initialize_789; procedure Initialize_790; procedure Initialize_791; procedure Initialize_792; procedure Initialize_793; procedure Initialize_794; procedure Initialize_795; procedure Initialize_796; procedure Initialize_797; procedure Initialize_798; procedure Initialize_799; procedure Initialize_800; end AMF.Internals.Tables.CMOF_Metamodel.Links;
Ximalas/synth
Ada
47,814
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Command_Line; with PortScan.Ops; with Signals; with Unix; package body PortScan.Packages is package CLI renames Ada.Command_Line; package OPS renames PortScan.Ops; package SIG renames Signals; --------------------------- -- wipe_out_repository -- --------------------------- procedure wipe_out_repository (repository : String) is pkg_search : AD.Search_Type; dirent : AD.Directory_Entry_Type; begin AD.Start_Search (Search => pkg_search, Directory => repository, Filter => (AD.Ordinary_File => True, others => False), Pattern => "*.txz"); while AD.More_Entries (Search => pkg_search) loop AD.Get_Next_Entry (Search => pkg_search, Directory_Entry => dirent); declare pkgname : String := repository & "/" & AD.Simple_Name (dirent); begin AD.Delete_File (pkgname); end; end loop; end wipe_out_repository; ----------------------------- -- remove_queue_packages -- ----------------------------- procedure remove_queue_packages (repository : String) is procedure remove_package (cursor : ranking_crate.Cursor); procedure remove_package (cursor : ranking_crate.Cursor) is QR : constant queue_record := ranking_crate.Element (cursor); fullpath : constant String := repository & "/" & JT.USS (all_ports (QR.ap_index).package_name); begin if AD.Exists (fullpath) then AD.Delete_File (fullpath); end if; end remove_package; begin rank_queue.Iterate (remove_package'Access); end remove_queue_packages; ---------------------------- -- initial_package_scan -- ---------------------------- procedure initial_package_scan (repository : String; id : port_id) is begin if id = port_match_failed then return; end if; if not all_ports (id).scanned then return; end if; declare pkgname : constant String := JT.USS (all_ports (id).package_name); fullpath : constant String := repository & "/" & pkgname; msg_opt : constant String := pkgname & " failed option check."; msg_abi : constant String := pkgname & " failed architecture (ABI) check."; begin if AD.Exists (fullpath) then all_ports (id).pkg_present := True; else return; end if; if not passed_option_check (repository, id, True) then obsolete_notice (msg_opt, True); all_ports (id).deletion_due := True; return; end if; if not passed_abi_check (repository, id, True) then obsolete_notice (msg_abi, True); all_ports (id).deletion_due := True; return; end if; end; all_ports (id).pkg_dep_query := result_of_dependency_query (repository, id); end initial_package_scan; --------------------------- -- remote_package_scan -- --------------------------- procedure remote_package_scan (id : port_id) is begin if passed_abi_check (repository => "", id => id, skip_exist_check => True) then all_ports (id).remote_pkg := True; else return; end if; if not passed_option_check (repository => "", id => id, skip_exist_check => True) then all_ports (id).remote_pkg := False; return; end if; all_ports (id).pkg_dep_query := result_of_dependency_query (repository => "", id => id); end remote_package_scan; ---------------------------- -- limited_sanity_check -- ---------------------------- procedure limited_sanity_check (repository : String; dry_run : Boolean; suppress_remote : Boolean) is procedure prune_packages (cursor : ranking_crate.Cursor); procedure check_package (cursor : ranking_crate.Cursor); procedure prune_queue (cursor : subqueue.Cursor); procedure print (cursor : subqueue.Cursor); procedure fetch (cursor : subqueue.Cursor); procedure check (cursor : subqueue.Cursor); already_built : subqueue.Vector; fetch_list : subqueue.Vector; fetch_fail : Boolean := False; clean_pass : Boolean := False; listlog : TIO.File_Type; goodlog : Boolean; using_screen : constant Boolean := Unix.screen_attached; filename : constant String := "/var/synth/synth_prefetch_list.txt"; package_list : JT.Text := JT.blank; procedure check_package (cursor : ranking_crate.Cursor) is target : port_id := ranking_crate.Element (cursor).ap_index; pkgname : String := JT.USS (all_ports (target).package_name); available : constant Boolean := all_ports (target).remote_pkg or else (all_ports (target).pkg_present and then not all_ports (target).deletion_due); begin if not available then return; end if; if passed_dependency_check (query_result => all_ports (target).pkg_dep_query, id => target) then already_built.Append (New_Item => target); if all_ports (target).remote_pkg then fetch_list.Append (New_Item => target); end if; else if all_ports (target).remote_pkg then -- silently fail, remote packages are a bonus anyway all_ports (target).remote_pkg := False; else obsolete_notice (pkgname & " failed dependency check.", True); all_ports (target).deletion_due := True; end if; clean_pass := False; end if; end check_package; procedure prune_queue (cursor : subqueue.Cursor) is id : constant port_index := subqueue.Element (cursor); begin OPS.cascade_successful_build (id); end prune_queue; procedure prune_packages (cursor : ranking_crate.Cursor) is target : port_id := ranking_crate.Element (cursor).ap_index; delete_it : Boolean := all_ports (target).deletion_due; pkgname : String := JT.USS (all_ports (target).package_name); fullpath : constant String := repository & "/" & pkgname; begin if delete_it then AD.Delete_File (fullpath); end if; exception when others => null; end prune_packages; procedure print (cursor : subqueue.Cursor) is id : constant port_index := subqueue.Element (cursor); line : constant String := JT.USS (all_ports (id).package_name) & " (" & get_catport (all_ports (id)) & ")"; begin TIO.Put_Line (" => " & line); if goodlog then TIO.Put_Line (listlog, line); end if; end print; procedure fetch (cursor : subqueue.Cursor) is id : constant port_index := subqueue.Element (cursor); begin JT.SU.Append (package_list, " " & id2pkgname (id)); end fetch; procedure check (cursor : subqueue.Cursor) is id : constant port_index := subqueue.Element (cursor); name : constant String := JT.USS (all_ports (id).package_name); loc : constant String := JT.USS (PM.configuration.dir_repository) & "/" & name; begin if not AD.Exists (loc) then TIO.Put_Line ("Download failed: " & name); fetch_fail := True; end if; end check; begin if Unix.env_variable_defined ("WHYFAIL") then activate_debugging_code; end if; establish_package_architecture; original_queue_len := rank_queue.Length; for m in scanners'Range loop mq_progress (m) := 0; end loop; start_obsolete_package_logging; parallel_package_scan (repository, False, using_screen); if SIG.graceful_shutdown_requested then TIO.Close (obsolete_pkg_log); return; end if; while not clean_pass loop clean_pass := True; already_built.Clear; rank_queue.Iterate (check_package'Access); end loop; if not suppress_remote and then PM.configuration.defer_prebuilt then -- The defer_prebuilt options has been elected, so check all the -- missing and to-be-pruned ports for suitable prebuilt packages -- So we need to an incremental scan (skip valid, present packages) for m in scanners'Range loop mq_progress (m) := 0; end loop; parallel_package_scan (repository, True, using_screen); if SIG.graceful_shutdown_requested then TIO.Close (obsolete_pkg_log); return; end if; clean_pass := False; while not clean_pass loop clean_pass := True; already_built.Clear; fetch_list.Clear; rank_queue.Iterate (check_package'Access); end loop; end if; TIO.Close (obsolete_pkg_log); if SIG.graceful_shutdown_requested then return; end if; if dry_run then if not fetch_list.Is_Empty then begin -- Try to defend malicious symlink: https://en.wikipedia.org/wiki/Symlink_race if AD.Exists (filename) then AD.Delete_File (filename); end if; TIO.Create (File => listlog, Mode => TIO.Out_File, Name => filename); goodlog := True; exception when others => goodlog := False; end; TIO.Put_Line ("These are the packages that would be fetched:"); fetch_list.Iterate (print'Access); TIO.Put_Line ("Total packages that would be fetched:" & fetch_list.Length'Img); if goodlog then TIO.Close (listlog); TIO.Put_Line ("The complete build list can also be found at:" & LAT.LF & filename); end if; else if PM.configuration.defer_prebuilt then TIO.Put_Line ("No packages qualify for prefetching from " & "official package repository."); end if; end if; else rank_queue.Iterate (prune_packages'Access); fetch_list.Iterate (fetch'Access); if not JT.equivalent (package_list, JT.blank) then declare cmd : constant String := host_pkg8 & " fetch -r " & JT.USS (external_repository) & " -U -y --output " & JT.USS (PM.configuration.dir_packages) & JT.USS (package_list); begin if Unix.external_command (cmd) then null; end if; end; fetch_list.Iterate (check'Access); end if; end if; if fetch_fail then TIO.Put_Line ("At least one package failed to fetch, aborting build!"); rank_queue.Clear; else already_built.Iterate (prune_queue'Access); end if; end limited_sanity_check; --------------------------- -- preclean_repository -- --------------------------- procedure preclean_repository (repository : String) is procedure insert (cursor : string_crate.Cursor); using_screen : constant Boolean := Unix.screen_attached; uniqid : PortScan.port_id := 0; procedure insert (cursor : string_crate.Cursor) is key2 : JT.Text := string_crate.Element (cursor); begin if not portlist.Contains (key2) then uniqid := uniqid + 1; portlist.Insert (key2, uniqid); end if; end insert; begin if not scan_repository (repository) then return; end if; parallel_preliminary_package_scan (repository, using_screen); for ndx in scanners'Range loop stored_origins (ndx).Iterate (insert'Access); stored_origins (ndx).Clear; end loop; end preclean_repository; ----------------------- -- scan_repository -- ----------------------- function scan_repository (repository : String) return Boolean is pkg_search : AD.Search_Type; dirent : AD.Directory_Entry_Type; pkg_index : scanners := scanners'First; result : Boolean := False; begin AD.Start_Search (Search => pkg_search, Directory => repository, Filter => (AD.Ordinary_File => True, others => False), Pattern => "*.txz"); while AD.More_Entries (Search => pkg_search) loop AD.Get_Next_Entry (Search => pkg_search, Directory_Entry => dirent); declare pkgname : JT.Text := JT.SUS (AD.Simple_Name (dirent)); begin stored_packages (pkg_index).Append (New_Item => pkgname); if pkg_index = scanners (number_cores) then pkg_index := scanners'First; else pkg_index := pkg_index + 1; end if; pkgscan_total := pkgscan_total + 1; result := True; end; end loop; return result; end scan_repository; ----------------------------- -- generic_system_command -- ----------------------------- function generic_system_command (command : String) return JT.Text is content : JT.Text; status : Integer; begin content := Unix.piped_command (command, status); if status /= 0 then raise pkgng_execution with "pkg options query cmd: " & command & " (return code =" & status'Img & ")"; end if; return content; end generic_system_command; --------------------------- -- passed_option_check -- --------------------------- function passed_option_check (repository : String; id : port_id; skip_exist_check : Boolean := False) return Boolean is begin if id = port_match_failed or else not all_ports (id).scanned then return False; end if; declare pkg_base : constant String := id2pkgname (id); pkg_name : constant String := JT.USS (all_ports (id).package_name); fullpath : constant String := repository & "/" & pkg_name; command : constant String := host_pkg8 & " query -F " & fullpath & " %Ok:%Ov"; remocmd : constant String := host_pkg8 & " rquery -r " & JT.USS (external_repository) & " -U %Ok:%Ov " & pkg_base; content : JT.Text; topline : JT.Text; colon : Natural; required : Natural := Natural (all_ports (id).options.Length); counter : Natural := 0; begin if not skip_exist_check and then not AD.Exists (Name => fullpath) then return False; end if; declare begin if repository = "" then content := generic_system_command (remocmd); else content := generic_system_command (command); end if; exception when pkgng_execution => return False; end; loop JT.nextline (lineblock => content, firstline => topline); exit when JT.IsBlank (topline); colon := JT.SU.Index (Source => topline, Pattern => ":"); if colon < 2 then raise unknown_format with JT.USS (topline); end if; declare knob : String := JT.SU.Slice (Source => topline, Low => colon + 1, High => JT.SU.Length (topline)); namekey : JT.Text := JT.SUS (JT.SU.Slice (Source => topline, Low => 1, High => colon - 1)); knobval : Boolean; begin if knob = "on" then knobval := True; elsif knob = "off" then knobval := False; else raise unknown_format with "knob=" & knob & "(" & JT.USS (topline) & ")"; end if; counter := counter + 1; if counter > required then -- package has more options than we are looking for declare msg : String := "options " & JT.USS (namekey) & LAT.LF & pkg_name & " has more options than required " & "(" & JT.int2str (required) & ")"; begin obsolete_notice (msg, debug_opt_check); end; return False; end if; if all_ports (id).options.Contains (namekey) then if knobval /= all_ports (id).options.Element (namekey) then -- port option value doesn't match package option value declare msg_on : String := pkg_name & " " & JT.USS (namekey) & " is ON but port says it must be OFF"; msg_off : String := pkg_name & " " & JT.USS (namekey) & " is OFF but port says it must be ON"; begin if knobval then obsolete_notice (msg_on, debug_opt_check); else obsolete_notice (msg_off, debug_opt_check); end if; end; return False; end if; else -- Name of package option not found in port options declare msg : String := pkg_name & " option " & JT.USS (namekey) & " is no longer present in the port"; begin obsolete_notice (msg, debug_opt_check); end; return False; end if; end; end loop; if counter < required then -- The ports tree has more options than the existing package declare msg : String := pkg_name & " has less options than required " & "(" & JT.int2str (required) & ")"; begin obsolete_notice (msg, debug_opt_check); end; return False; end if; -- If we get this far, the package options must match port options return True; end; exception when issue : others => obsolete_notice ("option check exception" & LAT.LF & EX.Exception_Message (issue), debug_opt_check); return False; end passed_option_check; ---------------------------------- -- result_of_dependency_query -- ---------------------------------- function result_of_dependency_query (repository : String; id : port_id) return JT.Text is pkg_base : constant String := id2pkgname (id); pkg_name : constant String := JT.USS (all_ports (id).package_name); fullpath : constant String := repository & "/" & pkg_name; command : constant String := host_pkg8 & " query -F " & fullpath & " %do:%dn-%dv"; remocmd : constant String := host_pkg8 & " rquery -r " & JT.USS (external_repository) & " -U %do:%dn-%dv " & pkg_base; begin if repository = "" then return generic_system_command (remocmd); else return generic_system_command (command); end if; exception when others => return JT.blank; end result_of_dependency_query; ------------------------------- -- passed_dependency_check -- ------------------------------- function passed_dependency_check (query_result : JT.Text; id : port_id) return Boolean is begin declare content : JT.Text := query_result; topline : JT.Text; colon : Natural; min_deps : constant Natural := all_ports (id).min_librun; max_deps : constant Natural := Natural (all_ports (id).librun.Length); headport : constant String := get_catport (all_ports (id)); counter : Natural := 0; begin loop JT.nextline (lineblock => content, firstline => topline); exit when JT.IsBlank (topline); colon := JT.SU.Index (Source => topline, Pattern => ":"); if colon < 2 then raise unknown_format with JT.USS (topline); end if; declare line : constant String := JT.USS (topline); origin : constant String := JT.part_1 (line, ":"); deppkg : constant String := JT.part_2 (line, ":") & ".txz"; origintxt : JT.Text := JT.SUS (origin); target_id : port_index; target_pkg : JT.Text; available : Boolean; begin -- The packages contain only the origin. We have no idea about which -- flavor is used if that origin features flavors. We have to probe all -- flavors and deduce the correct flavor (Definitely, FPC flavors are inferior -- to Ravenports variants). -- -- The original implementation looked up the first listed flavor. If it had -- flavors defined, it would iterate through the list to match packages. We -- can't use this approach because the "rebuild-repository" routine only does -- a partial scan, so the first flavor may not be populated. Instead, we -- linearly go through the serial list until we find a match (or first part -- of origin doesn't match. if so_porthash.Contains (origintxt) then declare probe_id : port_index := so_porthash.Element (origintxt); base_pkg : String := JT.head (deppkg, "-"); found_it : Boolean := False; maxprobe : port_index := port_index (so_serial.Length) - 1; begin loop if all_ports (probe_id).scanned then declare pkg_file : String := JT.USS (all_ports (probe_id).package_name); test_pkg : String := JT.head (pkg_file, "-"); begin if test_pkg = base_pkg then found_it := True; target_id := probe_id; exit; end if; end; end if; probe_id := probe_id + 1; exit when probe_id > maxprobe; exit when not JT.leads (so_serial.Element (probe_id), origin); end loop; if not found_it then obsolete_notice (origin & " package unmatched", debug_dep_check); return False; end if; end; target_pkg := all_ports (target_id).package_name; available := all_ports (target_id).remote_pkg or else (all_ports (target_id).pkg_present and then not all_ports (target_id).deletion_due); else -- package has a dependency that has been removed from the ports tree declare msg : String := origin & " has been removed from the ports tree"; begin obsolete_notice (msg, debug_dep_check); end; return False; end if; counter := counter + 1; if counter > max_deps then -- package has more dependencies than we are looking for declare msg : String := headport & " package has more dependencies than the port " & "requires (" & JT.int2str (max_deps) & ")" & LAT.LF & "Query: " & JT.USS (query_result) & LAT.LF & "Tripped on: " & JT.USS (target_pkg) & ":" & origin; begin obsolete_notice (msg, debug_dep_check); end; return False; end if; if deppkg /= JT.USS (target_pkg) then -- The version that the package requires differs from the -- version that the ports tree will now produce declare msg : String := "Current " & headport & " package depends on " & deppkg & ", but this is a different version than requirement of " & JT.USS (target_pkg) & " (from " & origin & ")"; begin obsolete_notice (msg, debug_dep_check); end; return False; end if; if not available then -- Even if all the versions are matching, we still need -- the package to be in repository. declare msg : String := headport & " package depends on " & JT.USS (target_pkg) & " which doesn't exist or has been scheduled " & "for deletion"; begin obsolete_notice (msg, debug_dep_check); end; return False; end if; end; end loop; if counter < min_deps then -- The ports tree requires more dependencies than the existing -- package does declare msg : String := headport & " package has less dependencies than the port " & "requires (" & JT.int2str (min_deps) & ")" & LAT.LF & "Query: " & JT.USS (query_result); begin obsolete_notice (msg, debug_dep_check); end; return False; end if; -- If we get this far, the package dependencies match what the -- port tree requires exactly. This package passed sanity check. return True; end; exception when issue : others => obsolete_notice ("Dependency check exception" & LAT.LF & EX.Exception_Message (issue), debug_dep_check); return False; end passed_dependency_check; ------------------ -- id2pkgname -- ------------------ function id2pkgname (id : port_id) return String is pkg_name : constant String := JT.USS (all_ports (id).package_name); len : constant Natural := pkg_name'Length - 4; begin return pkg_name (1 .. len); end id2pkgname; ------------------------ -- passed_abi_check -- ------------------------ function passed_abi_check (repository : String; id : port_id; skip_exist_check : Boolean := False) return Boolean is pkg_base : constant String := id2pkgname (id); pkg_name : constant String := JT.USS (all_ports (id).package_name); fullpath : constant String := repository & "/" & pkg_name; command : constant String := host_pkg8 & " query -F " & fullpath & " %q"; remocmd : constant String := host_pkg8 & " rquery -r " & JT.USS (external_repository) & " -U %q " & pkg_base; content : JT.Text; topline : JT.Text; begin if not skip_exist_check and then not AD.Exists (Name => fullpath) then return False; end if; declare begin if repository = "" then content := generic_system_command (remocmd); else content := generic_system_command (command); end if; exception when pkgng_execution => return False; end; JT.nextline (lineblock => content, firstline => topline); if JT.equivalent (topline, abi_formats.calculated_abi) then return True; end if; if JT.equivalent (topline, abi_formats.calc_abi_noarch) then return True; end if; if JT.equivalent (topline, abi_formats.calculated_alt_abi) then return True; end if; if JT.equivalent (topline, abi_formats.calc_alt_abi_noarch) then return True; end if; return False; exception when others => return False; end passed_abi_check; ---------------------- -- queue_is_empty -- ---------------------- function queue_is_empty return Boolean is begin return rank_queue.Is_Empty; end queue_is_empty; -------------------------------------- -- establish_package_architecture -- -------------------------------------- procedure establish_package_architecture is begin abi_formats := Replicant.Platform.determine_package_architecture; end establish_package_architecture; --------------------------- -- original_queue_size -- --------------------------- function original_queue_size return Natural is begin return Natural (original_queue_len); end original_queue_size; ---------------------------------- -- passed_options_cache_check -- ---------------------------------- function passed_options_cache_check (id : port_id) return Boolean is target_dname : String := JT.replace (get_catport (all_ports (id)), reject => LAT.Solidus, shiny => LAT.Low_Line); target_path : constant String := JT.USS (PM.configuration.dir_options) & LAT.Solidus & target_dname & LAT.Solidus & "options"; marker : constant String := "+="; option_file : TIO.File_Type; required : Natural := Natural (all_ports (id).options.Length); counter : Natural := 0; result : Boolean := False; begin if not AD.Exists (target_path) then return True; end if; TIO.Open (File => option_file, Mode => TIO.In_File, Name => target_path); while not TIO.End_Of_File (option_file) loop declare Line : String := TIO.Get_Line (option_file); namekey : JT.Text; valid : Boolean := False; begin -- If "marker" starts at 17, it's OPTIONS_FILES_SET -- if "marker" starts at 19, it's OPTIONS_FILES_UNSET -- if neither, we don't care. if Line (17 .. 18) = marker then namekey := JT.SUS (Line (19 .. Line'Last)); valid := True; elsif Line (19 .. 20) = marker then namekey := JT.SUS (Line (21 .. Line'Last)); valid := True; end if; if valid then counter := counter + 1; if counter > required then -- The port used to have more options, abort! goto clean_exit; end if; if not all_ports (id).options.Contains (namekey) then -- cached option not found in port anymore, abort! goto clean_exit; end if; end if; end; end loop; if counter = required then result := True; end if; <<clean_exit>> TIO.Close (option_file); return result; end passed_options_cache_check; ------------------------------------ -- limited_cached_options_check -- ------------------------------------ function limited_cached_options_check return Boolean is procedure check_port (cursor : ranking_crate.Cursor); fail_count : Natural := 0; first_fail : queue_record; procedure check_port (cursor : ranking_crate.Cursor) is QR : constant queue_record := ranking_crate.Element (cursor); id : port_index := QR.ap_index; prelude : constant String := "Cached options obsolete: "; begin if not passed_options_cache_check (id) then if fail_count = 0 then first_fail := QR; end if; fail_count := fail_count + 1; TIO.Put_Line (prelude & get_catport (all_ports (id))); end if; end check_port; begin rank_queue.Iterate (Process => check_port'Access); if fail_count > 0 then CLI.Set_Exit_Status (CLI.Failure); TIO.Put (LAT.LF & "A preliminary scan has revealed the cached " & "options of"); if fail_count = 1 then TIO.Put_Line (" one port are"); else TIO.Put_Line (fail_count'Img & " ports are"); end if; TIO.Put_Line ("obsolete. Please update or remove the saved " & "options and try again."); declare portsdir : String := JT.USS (PM.configuration.dir_portsdir) & LAT.Solidus; catport : String := get_catport (all_ports (first_fail.ap_index)); begin TIO.Put_Line (" e.g. make -C " & portsdir & catport & " config"); TIO.Put_Line (" e.g. make -C " & portsdir & catport & " rmconfig"); end; end if; return (fail_count = 0); end limited_cached_options_check; ----------------------------- -- parallel_package_scan -- ----------------------------- procedure parallel_package_scan (repository : String; remote_scan : Boolean; show_progress : Boolean) is task type scan (lot : scanners); finished : array (scanners) of Boolean := (others => False); combined_wait : Boolean := True; label_shown : Boolean := False; aborted : Boolean := False; task body scan is procedure populate (cursor : subqueue.Cursor); procedure populate (cursor : subqueue.Cursor) is target_port : port_index := subqueue.Element (cursor); important : constant Boolean := all_ports (target_port).scanned; begin if not aborted and then important then if remote_scan and then not all_ports (target_port).never_remote then if not all_ports (target_port).pkg_present or else all_ports (target_port).deletion_due then remote_package_scan (target_port); end if; else initial_package_scan (repository, target_port); end if; end if; mq_progress (lot) := mq_progress (lot) + 1; end populate; begin make_queue (lot).Iterate (populate'Access); finished (lot) := True; end scan; scan_01 : scan (lot => 1); scan_02 : scan (lot => 2); scan_03 : scan (lot => 3); scan_04 : scan (lot => 4); scan_05 : scan (lot => 5); scan_06 : scan (lot => 6); scan_07 : scan (lot => 7); scan_08 : scan (lot => 8); scan_09 : scan (lot => 9); scan_10 : scan (lot => 10); scan_11 : scan (lot => 11); scan_12 : scan (lot => 12); scan_13 : scan (lot => 13); scan_14 : scan (lot => 14); scan_15 : scan (lot => 15); scan_16 : scan (lot => 16); scan_17 : scan (lot => 17); scan_18 : scan (lot => 18); scan_19 : scan (lot => 19); scan_20 : scan (lot => 20); scan_21 : scan (lot => 21); scan_22 : scan (lot => 22); scan_23 : scan (lot => 23); scan_24 : scan (lot => 24); scan_25 : scan (lot => 25); scan_26 : scan (lot => 26); scan_27 : scan (lot => 27); scan_28 : scan (lot => 28); scan_29 : scan (lot => 29); scan_30 : scan (lot => 30); scan_31 : scan (lot => 31); scan_32 : scan (lot => 32); begin while combined_wait loop delay 1.0; combined_wait := False; for j in scanners'Range loop if not finished (j) then combined_wait := True; exit; end if; end loop; if combined_wait then if not label_shown then label_shown := True; TIO.Put_Line ("Scanning existing packages."); end if; if show_progress then TIO.Put (scan_progress); end if; if SIG.graceful_shutdown_requested then aborted := True; end if; end if; end loop; end parallel_package_scan; ----------------------------------------- -- parallel_preliminary_package_scan -- ----------------------------------------- procedure parallel_preliminary_package_scan (repository : String; show_progress : Boolean) is task type scan (lot : scanners); finished : array (scanners) of Boolean := (others => False); combined_wait : Boolean := True; label_shown : Boolean := False; aborted : Boolean := False; task body scan is procedure check (csr : string_crate.Cursor); procedure check (csr : string_crate.Cursor) is begin if aborted then return; end if; declare pkgname : constant String := JT.USS (string_crate.Element (csr)); pkgpath : constant String := repository & "/" & pkgname; origin : constant String := query_origin (pkgpath); path1 : constant String := JT.USS (PM.configuration.dir_portsdir) & "/" & origin; remove : Boolean := True; begin if AD.Exists (path1) then declare full_origin : constant String := query_full_origin (pkgpath, origin); begin if current_package_name (full_origin, pkgname) then stored_origins (lot).Append (New_Item => JT.SUS (full_origin)); remove := False; end if; end; end if; if remove then AD.Delete_File (pkgpath); TIO.Put_Line ("Removed: " & pkgname); end if; exception when others => TIO.Put_Line (" Failed to remove " & pkgname); end; pkgscan_progress (lot) := pkgscan_progress (lot) + 1; end check; begin stored_packages (lot).Iterate (check'Access); stored_packages (lot).Clear; finished (lot) := True; end scan; scan_01 : scan (lot => 1); scan_02 : scan (lot => 2); scan_03 : scan (lot => 3); scan_04 : scan (lot => 4); scan_05 : scan (lot => 5); scan_06 : scan (lot => 6); scan_07 : scan (lot => 7); scan_08 : scan (lot => 8); scan_09 : scan (lot => 9); scan_10 : scan (lot => 10); scan_11 : scan (lot => 11); scan_12 : scan (lot => 12); scan_13 : scan (lot => 13); scan_14 : scan (lot => 14); scan_15 : scan (lot => 15); scan_16 : scan (lot => 16); scan_17 : scan (lot => 17); scan_18 : scan (lot => 18); scan_19 : scan (lot => 19); scan_20 : scan (lot => 20); scan_21 : scan (lot => 21); scan_22 : scan (lot => 22); scan_23 : scan (lot => 23); scan_24 : scan (lot => 24); scan_25 : scan (lot => 25); scan_26 : scan (lot => 26); scan_27 : scan (lot => 27); scan_28 : scan (lot => 28); scan_29 : scan (lot => 29); scan_30 : scan (lot => 30); scan_31 : scan (lot => 31); scan_32 : scan (lot => 32); begin while combined_wait loop delay 1.0; if show_progress then TIO.Put (package_scan_progress); end if; combined_wait := False; for j in scanners'Range loop if not finished (j) then combined_wait := True; exit; end if; end loop; if combined_wait then if not label_shown then label_shown := True; TIO.Put_Line ("Stand by, prescanning existing packages."); end if; if SIG.graceful_shutdown_requested then aborted := True; end if; end if; end loop; end parallel_preliminary_package_scan; ----------------------------------- -- located_external_repository -- ----------------------------------- function located_external_repository return Boolean is command : constant String := host_pkg8 & " -vv"; dump : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; found : Boolean := False; inspect : Boolean := False; begin declare begin dump := generic_system_command (command); exception when pkgng_execution => return False; end; crlen1 := JT.SU.Length (dump); loop JT.nextline (lineblock => dump, firstline => topline); crlen2 := JT.SU.Length (dump); exit when crlen1 = crlen2; crlen1 := crlen2; if inspect then declare line : constant String := JT.USS (topline); len : constant Natural := line'Length; begin if len > 7 and then line (1 .. 2) = " " and then line (len - 3 .. len) = ": { " and then line (3 .. len - 4) /= "Synth" then found := True; external_repository := JT.SUS (line (3 .. len - 4)); exit; end if; end; else if JT.equivalent (topline, "Repositories:") then inspect := True; end if; end if; end loop; return found; end located_external_repository; ------------------------------- -- top_external_repository -- ------------------------------- function top_external_repository return String is begin return JT.USS (external_repository); end top_external_repository; ------------------------------- -- activate_debugging_code -- ------------------------------- procedure activate_debugging_code is begin debug_opt_check := True; debug_dep_check := True; end activate_debugging_code; -------------------- -- query_origin -- -------------------- function query_origin (fullpath : String) return String is command : constant String := host_pkg8 & " query -F " & fullpath & " %o"; content : JT.Text; topline : JT.Text; begin content := generic_system_command (command); JT.nextline (lineblock => content, firstline => topline); return JT.USS (topline); exception when others => return ""; end query_origin; --------------------- -- query_pkgbase -- --------------------- function query_pkgbase (fullpath : String) return String is command : constant String := host_pkg8 & " query -F " & fullpath & " %n"; content : JT.Text; topline : JT.Text; begin content := generic_system_command (command); JT.nextline (lineblock => content, firstline => topline); return JT.USS (topline); exception when others => return ""; end query_pkgbase; ------------------------- -- query_full_origin -- ------------------------- function query_full_origin (fullpath, origin : String) return String is command : constant String := host_pkg8 & " query -F " & fullpath & " %At:%Av"; content : JT.Text; begin content := generic_system_command (command); declare contents : constant String := JT.USS (content); markers : JT.Line_Markers; begin JT.initialize_markers (contents, markers); if JT.next_line_with_content_present (contents, "flavor:", markers) then declare line : constant String := JT.extract_line (contents, markers); begin return origin & "@" & JT.part_2 (line, ":"); end; else return origin; end if; end; exception when others => return origin; end query_full_origin; ---------------------------- -- current_package_name -- ---------------------------- function current_package_name (origin, file_name : String) return Boolean is cpn : constant String := get_pkg_name (origin); begin return cpn = file_name; end current_package_name; ----------------------------- -- package_scan_progress -- ----------------------------- function package_scan_progress return String is type percent is delta 0.01 digits 5; complete : port_index := 0; pc : percent; total : constant Float := Float (pkgscan_total); begin for k in scanners'Range loop complete := complete + pkgscan_progress (k); end loop; pc := percent (100.0 * Float (complete) / total); return " progress:" & pc'Img & "% " & LAT.CR; end package_scan_progress; -------------------------------------- -- start_obsolete_package_logging -- -------------------------------------- procedure start_obsolete_package_logging is logpath : constant String := JT.USS (PM.configuration.dir_logs) & "/06_obsolete_packages.log"; begin -- Try to defend malicious symlink: https://en.wikipedia.org/wiki/Symlink_race if AD.Exists (logpath) then AD.Delete_File (logpath); end if; TIO.Create (File => obsolete_pkg_log, Mode => TIO.Out_File, Name => logpath); obsolete_log_open := True; exception when others => obsolete_log_open := False; end start_obsolete_package_logging; ----------------------- -- obsolete_notice -- ----------------------- procedure obsolete_notice (message : String; write_to_screen : Boolean) is begin if obsolete_log_open then TIO.Put_Line (obsolete_pkg_log, message); end if; if write_to_screen then TIO.Put_Line (message); end if; end obsolete_notice; end PortScan.Packages;
reznikmm/matreshka
Ada
4,055
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_Overline_Thickness_Attributes; package Matreshka.ODF_Svg.Overline_Thickness_Attributes is type Svg_Overline_Thickness_Attribute_Node is new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node and ODF.DOM.Svg_Overline_Thickness_Attributes.ODF_Svg_Overline_Thickness_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Overline_Thickness_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Svg_Overline_Thickness_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Svg.Overline_Thickness_Attributes;
noud/mouse-bsd-5.2
Ada
3,326
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp package body ZLib.Thin is ZLIB_VERSION : constant Chars_Ptr := zlibVersion; Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; -------------- -- Avail_In -- -------------- function Avail_In (Strm : in Z_Stream) return UInt is begin return Strm.Avail_In; end Avail_In; --------------- -- Avail_Out -- --------------- function Avail_Out (Strm : in Z_Stream) return UInt is begin return Strm.Avail_Out; end Avail_Out; ------------------ -- Deflate_Init -- ------------------ function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int is begin return deflateInit2 (strm, level, method, windowBits, memLevel, strategy, ZLIB_VERSION, Z_Stream_Size); end Deflate_Init; ------------------ -- Inflate_Init -- ------------------ function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is begin return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); end Inflate_Init; ------------------------ -- Last_Error_Message -- ------------------------ function Last_Error_Message (Strm : in Z_Stream) return String is use Interfaces.C.Strings; begin if Strm.msg = Null_Ptr then return ""; else return Value (Strm.msg); end if; end Last_Error_Message; ------------ -- Set_In -- ------------ procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Strm.Next_In := Buffer; Strm.Avail_In := Size; end Set_In; ------------------ -- Set_Mem_Func -- ------------------ procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func) is begin Strm.opaque := Opaque; Strm.zalloc := Alloc; Strm.zfree := Free; end Set_Mem_Func; ------------- -- Set_Out -- ------------- procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Strm.Next_Out := Buffer; Strm.Avail_Out := Size; end Set_Out; -------------- -- Total_In -- -------------- function Total_In (Strm : in Z_Stream) return ULong is begin return Strm.Total_In; end Total_In; --------------- -- Total_Out -- --------------- function Total_Out (Strm : in Z_Stream) return ULong is begin return Strm.Total_Out; end Total_Out; end ZLib.Thin;
zhmu/ananas
Ada
4,229
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- SYSTEM.STORAGE_POOLS.SUBPOOLS.FINALIZATION -- -- -- -- B o d y -- -- -- -- Copyright (C) 2011-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with System.Finalization_Masters; use System.Finalization_Masters; package body System.Storage_Pools.Subpools.Finalization is ----------------------------- -- Finalize_And_Deallocate -- ----------------------------- procedure Finalize_And_Deallocate (Subpool : in out Subpool_Handle) is procedure Free is new Ada.Unchecked_Deallocation (SP_Node, SP_Node_Ptr); begin -- Do nothing if the subpool was never created or never used. The latter -- case may arise with an array of subpool implementations. if Subpool = null or else Subpool.Owner = null or else Subpool.Node = null then return; end if; -- Clean up all controlled objects chained on the subpool's master Finalize (Subpool.Master); -- Remove the subpool from its owner's list of subpools Detach (Subpool.Node); -- Destroy the associated doubly linked list node which was created in -- Set_Pool_Of_Subpools. Free (Subpool.Node); -- Dispatch to the user-defined implementation of Deallocate_Subpool. It -- is important to first set Subpool.Owner to null, because RM-13.11.5 -- requires that "The subpool no longer belongs to any pool" BEFORE -- calling Deallocate_Subpool. The actual dispatching call required is: -- -- Deallocate_Subpool(Pool_Of_Subpool(Subpool).all, Subpool); -- -- but that can't be taken literally, because Pool_Of_Subpool will -- return null. declare Owner : constant Any_Storage_Pool_With_Subpools_Ptr := Subpool.Owner; begin Subpool.Owner := null; Deallocate_Subpool (Owner.all, Subpool); end; Subpool := null; end Finalize_And_Deallocate; end System.Storage_Pools.Subpools.Finalization;
charlie5/cBound
Ada
1,693
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_xc_misc_get_xid_range_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; start_id : aliased Interfaces.Unsigned_32; count : aliased Interfaces.Unsigned_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_xc_misc_get_xid_range_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_xc_misc_get_xid_range_reply_t.Item, Element_Array => xcb.xcb_xc_misc_get_xid_range_reply_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_xc_misc_get_xid_range_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_xc_misc_get_xid_range_reply_t.Pointer, Element_Array => xcb.xcb_xc_misc_get_xid_range_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_xc_misc_get_xid_range_reply_t;
reznikmm/matreshka
Ada
3,669
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.Style_Tab_Stop_Elements is pragma Preelaborate; type ODF_Style_Tab_Stop is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Style_Tab_Stop_Access is access all ODF_Style_Tab_Stop'Class with Storage_Size => 0; end ODF.DOM.Style_Tab_Stop_Elements;
thierr26/ada-keystore
Ada
17,382
adb
----------------------------------------------------------------------- -- akt-windows -- GtK Windows for Ada Keystore GTK application -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; with Ada.Exceptions; with Ada.Calendar.Formatting; with Interfaces; with Glib.Error; with Glib.Unicode; with Glib.Object; with Gtk.Main; with Gtk.Label; with Gtk.Enums; with Gtk.Tree_View_Column; with Gtk.Text_Iter; with Gtk.Tool_Item; with AKT.Callbacks; package body AKT.Windows is use Ada.Strings.Unbounded; use type Glib.Gint; use type Gtk.Tree_View.Gtk_Tree_View; use type Gtk.Widget.Gtk_Widget; use type Interfaces.Unsigned_64; -- ------------------------------ -- Initialize the target instance. -- ------------------------------ overriding procedure Initialize (Application : in out Application_Type) is begin null; end Initialize; -- ------------------------------ -- Release the storage. -- ------------------------------ overriding procedure Finalize (Application : in out Application_Type) is use type Gtk.Widget.Gtk_Widget; begin if Application.Main /= null then Application.Main.Destroy; Application.About.Destroy; -- Application.Chooser.Destroy; end if; end Finalize; -- Load the glade XML definition. procedure Load_UI (Application : in out Application_Type) is separate; -- ------------------------------ -- Initialize the widgets and create the Gtk gui. -- ------------------------------ procedure Initialize_Widget (Application : in out Application_Type; Widget : out Gtk.Widget.Gtk_Widget) is Timeline : Gtk.Widget.Gtk_Widget; Scrolled : Gtk.Scrolled_Window.Gtk_Scrolled_Window; Status : Gtk.Status_Bar.Gtk_Status_Bar; begin Gtk.Main.Init; Gtkada.Builder.Gtk_New (Application.Builder); Load_UI (Application); AKT.Callbacks.Initialize (Application'Unchecked_Access, Application.Builder); Application.Builder.Do_Connect; Widget := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("main")); Application.Main := Widget; Application.About := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("about")); Application.Chooser := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("filechooser")); Timeline := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("scrolledView")); Scrolled := Gtk.Scrolled_Window.Gtk_Scrolled_Window (Timeline); Timeline := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("viewport1")); Application.Viewport := Gtk.Viewport.Gtk_Viewport (Timeline); Status := Gtk.Status_Bar.Gtk_Status_Bar (Application.Builder.Get_Object ("statusbar")); Application.Status := Status; Application.Scrolled := Scrolled; Gtk.Cell_Renderer_Text.Gtk_New (Application.Col_Text); Application.Scrolled.Set_Policy (Gtk.Enums.Policy_Always, Gtk.Enums.Policy_Always); Application.Col_Text.Ref; Application.Main.Show_All; end Initialize_Widget; procedure Open_File (Application : in out Application_Type; Path : in String; Password : in Keystore.Secret_Key) is begin -- Close the current wallet if necessary. if Application.Wallet.Is_Open then Application.Wallet.Close; end if; Application.Path := To_Unbounded_String (Path); Application.Message ("Loading " & Path); Application.Wallet.Open (Path => Path, Password => Password); Application.Locked := False; Application.Refresh_Toolbar; Application.Message ("Opened " & Path); Application.List_Keystore; exception when Keystore.Bad_Password => Application.Message ("Invalid password to open " & Path); when Keystore.Corrupted | Keystore.Invalid_Storage | Keystore.Invalid_Block => Application.Message ("File is corrupted"); when Keystore.Invalid_Keystore | Ada.IO_Exceptions.End_Error => Application.Message ("File is not a keystore"); when E : others => Application.Message ("Internal error: " & Ada.Exceptions.Exception_Message (E)); end Open_File; procedure Create_File (Application : in out Application_Type; Path : in String; Storage_Count : in Natural; Password : in Keystore.Secret_Key) is Config : Keystore.Wallet_Config := Keystore.Secure_Config; begin Config.Overwrite := True; if Storage_Count > 0 then Config.Storage_Count := Storage_Count; end if; -- Close the current wallet if necessary. if Application.Wallet.Is_Open then Application.Wallet.Close; end if; Application.Path := To_Unbounded_String (Path); Application.Message ("Creating " & Path); Keystore.Files.Create (Container => Application.Wallet, Path => Path, Password => Password, Config => Config, Data_Path => ""); Application.Locked := False; Application.Refresh_Toolbar; Application.Message ("Created " & Path); Application.List_Keystore; exception when Keystore.Invalid_Keystore | Ada.IO_Exceptions.End_Error => Application.Message ("File is not a keystore"); when E : others => Log.Error ("Exception", E, True); Application.Message ("Internal error"); end Create_File; procedure List_Keystore (Application : in out Application_Type) is procedure Add_Column (Name : in String; Column_Id : in Glib.Gint); List : Keystore.Entry_Map; Iter : Keystore.Entry_Cursor; Types : constant Glib.GType_Array (0 .. 5) := (others => Glib.GType_String); procedure Add_Column (Name : in String; Column_Id : in Glib.Gint) is Col : Gtk.Tree_View_Column.Gtk_Tree_View_Column; Num : Glib.Gint; pragma Unreferenced (Num); begin Gtk.Tree_View_Column.Gtk_New (Col); Num := Application.Tree.Append_Column (Col); Col.Set_Sort_Column_Id (Column_Id - 1); Col.Set_Title (Name); Col.Pack_Start (Application.Col_Text, True); Col.Set_Sizing (Gtk.Tree_View_Column.Tree_View_Column_Autosize); Col.Add_Attribute (Application.Col_Text, "text", Column_Id - 1); end Add_Column; procedure Set_Content (Name : in String) is Data : constant String := Application.Wallet.Get (Name); Valid : Boolean; Pos : Natural; begin Glib.Unicode.UTF8_Validate (Data, Valid, Pos); if Valid then Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 5, Data); else Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 5, "--"); end if; end Set_Content; begin Gtk.Status_Bar.Remove_All (Application.Status, 1); -- <name> <type> <size> <date> <content> Application.Wallet.List (Content => List); Gtk.Tree_Store.Gtk_New (Application.List, Types); if Application.Tree /= null then Application.Tree.Destroy; end if; Gtk.Tree_View.Gtk_New (Application.Tree, Gtk.Tree_Store."+" (Application.List)); Application.Selection := Gtk.Tree_View.Get_Selection (Application.Tree); Gtk.Tree_Selection.Set_Mode (Application.Selection, Gtk.Enums.Selection_Single); Add_Column ("Date", 1); Add_Column ("Type", 2); Add_Column ("Size", 3); Add_Column ("Keys", 4); Add_Column ("Name", 5); Add_Column ("Content", 6); if Application.Editing then Application.Viewport.Remove (Application.Editor); Application.Editing := False; end if; Application.Viewport.Add (Application.Tree); Iter := List.First; while Keystore.Entry_Maps.Has_Element (Iter) loop declare Name : constant String := Keystore.Entry_Maps.Key (Iter); Item : constant Keystore.Entry_Info := Keystore.Entry_Maps.Element (Iter); begin Application.List.Append (Application.Current_Row, Gtk.Tree_Model.Null_Iter); if Application.Locked then Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 0, Ada.Calendar.Formatting.Image (Item.Create_Date)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 1, Keystore.Entry_Type'Image (Item.Kind)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 2, Interfaces.Unsigned_64'Image (Item.Size)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 3, Natural'Image (Item.Block_Count)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 4, "xxxxxxxx"); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 5, "XXXXXXXXXXX"); else Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 0, Ada.Calendar.Formatting.Image (Item.Create_Date)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 1, Keystore.Entry_Type'Image (Item.Kind)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 2, Interfaces.Unsigned_64'Image (Item.Size)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 3, Natural'Image (Item.Block_Count)); Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 4, Name); if Item.Size < 1024 then Set_Content (Name); else Gtk.Tree_Store.Set (Application.List, Application.Current_Row, 5, "--"); end if; end if; end; Keystore.Entry_Maps.Next (Iter); end loop; Application.Scrolled.Show_All; end List_Keystore; procedure Edit_Current (Application : in out Application_Type) is Model : Gtk.Tree_Model.Gtk_Tree_Model; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; begin Gtk.Status_Bar.Remove_All (Application.Status, 1); Gtk.Tree_Selection.Get_Selected (Selection => Application.Selection, Model => Model, Iter => Iter); declare Name : constant String := Gtk.Tree_Model.Get_String (Model, Iter, 0); Data : constant String := Application.Wallet.Get (Name); Valid : Boolean; Pos : Natural; begin Log.Info ("Selected {0}", Name); Glib.Unicode.UTF8_Validate (Data, Valid, Pos); if not Valid then Log.Warn ("Data is binary content and not valid UTF-8"); Application.Message ("Cannot edit binary content"); return; end if; Application.Current := Ada.Strings.Unbounded.To_Unbounded_String (Name); Gtk.Text_Buffer.Gtk_New (Application.Buffer); Gtk.Text_View.Gtk_New (Application.Editor, Application.Buffer); Gtk.Text_Buffer.Set_Text (Application.Buffer, Data); if not Application.Editing then Application.Viewport.Remove (Application.Tree); Application.Viewport.Add (Application.Editor); Application.Editor.Show_All; Application.Editing := True; end if; end; exception when E : others => Log.Error ("Exception to edit content", E); Application.Message ("Cannot edit content"); end Edit_Current; procedure Save_Current (Application : in out Application_Type) is Start : Gtk.Text_Iter.Gtk_Text_Iter; Stop : Gtk.Text_Iter.Gtk_Text_Iter; begin if Application.Editing then Gtk.Text_Buffer.Get_Bounds (Application.Buffer, Start, Stop); Application.Wallet.Set (Ada.Strings.Unbounded.To_String (Application.Current), Gtk.Text_Buffer.Get_Text (Application.Buffer, Start, Stop)); Application.List_Keystore; end if; end Save_Current; -- ------------------------------ -- Lock the keystore so that it is necessary to ask the password again to see/edit items. -- ------------------------------ procedure Lock (Application : in out Application_Type) is begin Application.Locked := True; if Application.Wallet.Is_Open then Application.List_Keystore; Application.Wallet.Close; end if; Application.Refresh_Toolbar; end Lock; -- ------------------------------ -- Unlock the keystore with the password. -- ------------------------------ procedure Unlock (Application : in out Application_Type; Password : in Keystore.Secret_Key) is begin if Application.Locked then Application.Open_File (Path => To_String (Application.Path), Password => Password); end if; end Unlock; -- ------------------------------ -- Return True if the keystore is locked. -- ------------------------------ function Is_Locked (Application : in Application_Type) return Boolean is begin return Application.Locked; end Is_Locked; -- ------------------------------ -- Return True if the keystore is open. -- ------------------------------ function Is_Open (Application : in Application_Type) return Boolean is begin return Application.Wallet.Is_Open; end Is_Open; -- ------------------------------ -- Set the UI label with the given value. -- ------------------------------ procedure Set_Label (Application : in Application_Type; Name : in String; Value : in String) is use type Glib.Object.GObject; Object : constant Glib.Object.GObject := Application.Builder.Get_Object (Name); Label : Gtk.Label.Gtk_Label; begin if Object /= null then Label := Gtk.Label.Gtk_Label (Object); Label.Set_Label (Value); end if; end Set_Label; -- ------------------------------ -- Report a message in the status area. -- ------------------------------ procedure Message (Application : in out Application_Type; Message : in String) is Msg : Gtk.Status_Bar.Message_Id with Unreferenced; begin Msg := Gtk.Status_Bar.Push (Application.Status, 1, Message); end Message; procedure Refresh_Toolbar (Application : in out Application_Type) is Unlock_Button : constant Gtk.Widget.Gtk_Widget := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("tool_unlock_button")); Lock_Button : constant Gtk.Widget.Gtk_Widget := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("tool_lock_button")); Edit_Button : constant Gtk.Widget.Gtk_Widget := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("tool_edit_button")); Save_Button : constant Gtk.Widget.Gtk_Widget := Gtk.Widget.Gtk_Widget (Application.Builder.Get_Object ("tool_save_button")); Item : Gtk.Tool_Item.Gtk_Tool_Item; begin if Lock_Button /= null then Item := Gtk.Tool_Item.Gtk_Tool_Item (Lock_Button); Item.Set_Visible_Horizontal (not Application.Is_Locked and Application.Is_Open); end if; if Unlock_Button /= null then Item := Gtk.Tool_Item.Gtk_Tool_Item (Unlock_Button); Item.Set_Visible_Horizontal (Application.Is_Locked); end if; if Edit_Button /= null then Item := Gtk.Tool_Item.Gtk_Tool_Item (Edit_Button); Item.Set_Visible_Horizontal (Application.Is_Open and not Application.Editing); end if; if Save_Button /= null then Item := Gtk.Tool_Item.Gtk_Tool_Item (Save_Button); Item.Set_Visible_Horizontal (Application.Is_Open and Application.Editing); end if; end Refresh_Toolbar; procedure Main (Application : in out Application_Type) is pragma Unreferenced (Application); begin Gtk.Main.Main; end Main; end AKT.Windows;
reznikmm/matreshka
Ada
3,607
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web 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 package configure SOAP stack to support WS-Security specification. ------------------------------------------------------------------------------ package Web_Services.SOAP.Security.Setup is pragma Elaborate_Body; end Web_Services.SOAP.Security.Setup;
reznikmm/gela
Ada
11,277
ads
------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- 9 package Asis.Ada_Environments.Containers ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- with Gela.Unit_Containers; package Asis.Ada_Environments.Containers is ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Asis.Ada_Environments.Containers -- -- If an Ada implementation supports the notion of a program library or -- "library" as specified in Subclause 10(2) of the Ada Reference Manual, -- then an ASIS Context value can be mapped onto one or more implementor -- libraries represented by Containers. -- ------------------------------------------------------------------------------- -- 9.1 type Container ------------------------------------------------------------------------------- -- -- The Container abstraction is a logical collection of compilation units. -- For example, one container might hold compilation units which include Ada -- predefined library units, another container might hold implementation- -- defined packages. Alternatively, there might be 26 containers, each holding -- compilation units that begin with their respective letter of the alphabet. -- The point is that no implementation-independent semantics are associated -- with a container; it is simply a logical collection. -- -- ASIS implementations shall minimally map the Asis.Context to a list of -- one ASIS Container whose Name is that of the Asis.Context Name. ------------------------------------------------------------------------------- type Container is private; Nil_Container : constant Container; function "=" (Left : in Container; Right : in Container) return Boolean is abstract; ------------------------------------------------------------------------------- -- 9.2 type Container_List ------------------------------------------------------------------------------- type Container_List is array (List_Index range <>) of Container; ------------------------------------------------------------------------------- -- 9.3 function Defining_Containers ------------------------------------------------------------------------------- function Defining_Containers (The_Context : in Asis.Context) return Container_List; ------------------------------------------------------------------------------- -- The_Context - Specifies the Context to define -- -- Returns a Container_List value that defines the single environment Context. -- Each Container will have an Enclosing_Context that Is_Identical to the -- argument The_Context. The order of Container values in the list is not -- defined. -- -- Returns a minimal list of length one if the ASIS Ada implementation does -- not support the concept of a program library. In this case, the Container -- will have the same name as the given Context. -- -- Raises ASIS_Inappropriate_Context if The_Context is not open. -- ------------------------------------------------------------------------------- -- 9.4 function Enclosing_Context ------------------------------------------------------------------------------- function Enclosing_Context (The_Container : in Container) return Asis.Context; ------------------------------------------------------------------------------- -- The_Container - Specifies the Container to query -- -- Returns the Context value associated with the Container. -- -- Returns the Context for which the Container value was originally obtained. -- Container values obtained through the Defining_Containers query will always -- remember the Context from which they were defined. -- -- Because Context is limited private, this function is only intended to be -- used to supply a Context parameter for other queries. -- -- Raises ASIS_Inappropriate_Container if the Container is a Nil_Container. -- ------------------------------------------------------------------------------- -- 9.5 function Library_Unit_Declaration ------------------------------------------------------------------------------- function Library_Unit_Declarations (The_Container : in Container) return Asis.Compilation_Unit_List; ------------------------------------------------------------------------------- -- The_Container - Specifies the Container to query -- -- Returns a list of all library_unit_declaration and -- library_unit_renaming_declaration elements contained in the Container. -- Individual units will appear only once in an order that is not defined. -- -- A Nil_Compilation_Unit_List is returned if there are no declarations of -- library units within the Container. -- -- This query will never return a unit with A_Configuration_Compilation or -- a Nonexistent unit kind. It will never return a unit with A_Procedure_Body -- or A_Function_Body unit kind even though the unit is interpreted as both -- the declaration and body of a library procedure or library function. -- (Reference Manual 10.1.4(4). -- -- All units in the result will have an Enclosing_Container value that -- Is_Identical to the Container. -- -- Raises ASIS_Inappropriate_Context if the Enclosing_Context(Container) -- is not open. -- ------------------------------------------------------------------------------- -- 9.6 function Compilation_Unit_Bodies ------------------------------------------------------------------------------- function Compilation_Unit_Bodies (The_Container : in Container) return Asis.Compilation_Unit_List; ------------------------------------------------------------------------------- -- The_Container - Specifies the Container to query -- -- Returns a list of all library_unit_body and subunit elements contained in -- the Container. Individual units will appear only once in an order that is -- not defined. -- -- A Nil_Compilation_Unit_List is returned if there are no bodies within the -- Container. -- -- This query will never return a unit with A_Configuration_Compilation or -- a nonexistent unit kind. -- -- All units in the result will have an Enclosing_Container value that -- Is_Identical to the Container. -- -- Raises ASIS_Inappropriate_Context if the Enclosing_Context(Container) -- is not open. -- ------------------------------------------------------------------------------- -- 9.7 function Compilation_Units ------------------------------------------------------------------------------- function Compilation_Units (The_Container : in Container) return Asis.Compilation_Unit_List; ------------------------------------------------------------------------------- -- The_Container - Specifies the Container to query -- -- Returns a list of all compilation units contained in the Container. -- Individual units will appear only once in an order that is not defined. -- -- A Nil_Compilation_Unit_List is returned if there are no units within the -- Container. -- -- This query will never return a unit with A_Configuration_Compilation or -- a nonexistent unit kind. -- -- All units in the result will have an Enclosing_Container value that -- Is_Identical to the Container. -- -- Raises ASIS_Inappropriate_Context if the Enclosing_Context(Container) -- is not open. -- ------------------------------------------------------------------------------- -- 9.8 function Is_Equal ------------------------------------------------------------------------------- function Is_Equal (Left : in Container; Right : in Container) return Boolean; ------------------------------------------------------------------------------- -- Left - Specifies the first Container -- Right - Specifies the second Container -- -- Returns True if Left and Right designate Container values that contain the -- same set of compilation units. The Container values may have been defined -- from different Context values. -- ------------------------------------------------------------------------------- -- 9.9 function Is_Identical ------------------------------------------------------------------------------- function Is_Identical (Left : in Container; Right : in Container) return Boolean; ------------------------------------------------------------------------------- -- Left - Specifies the first Container -- Right - Specifies the second Container -- -- Returns True if Is_Equal(Left, Right) and the Container values have been -- defined from Is_Equal Context values. -- ------------------------------------------------------------------------------- -- 9.10 function Name ------------------------------------------------------------------------------- function Name (The_Container : in Container) return Wide_String; ------------------------------------------------------------------------------- -- The_Container - Specifies the Container to name -- -- Returns the Name value associated with the Container. -- -- Returns a null string if the Container is a Nil_Container. -- ------------------------------------------------------------------------------- private type Container is record Context : Asis.Context; List : Gela.Unit_Containers.Unit_Container_Access; end record; Nil_Container : constant Container := (Nil_Context, null); end Asis.Ada_Environments.Containers; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- * this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in the -- * documentation and/or other materials provided with the distribution. -- -- 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. ------------------------------------------------------------------------------
meowthsli/veriflight_boards
Ada
284
ads
with Ada.Interrupts; with Ada.Interrupts.Names; package usb_handler is protected Device_Interface is pragma Interrupt_Priority; procedure Handler; pragma Attach_Handler (Handler, Ada.Interrupts.Names.OTG_FS_Interrupt); end Device_Interface; end usb_handler;
optikos/oasis
Ada
3,481
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Declarations; with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Aspect_Specifications; with Program.Element_Vectors; with Program.Elements.Exception_Handlers; with Program.Elements.Identifiers; package Program.Elements.Task_Body_Declarations is pragma Pure (Program.Elements.Task_Body_Declarations); type Task_Body_Declaration is limited interface and Program.Elements.Declarations.Declaration; type Task_Body_Declaration_Access is access all Task_Body_Declaration'Class with Storage_Size => 0; not overriding function Name (Self : Task_Body_Declaration) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is abstract; not overriding function Aspects (Self : Task_Body_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is abstract; not overriding function Declarations (Self : Task_Body_Declaration) return Program.Element_Vectors.Element_Vector_Access is abstract; not overriding function Statements (Self : Task_Body_Declaration) return not null Program.Element_Vectors.Element_Vector_Access is abstract; not overriding function Exception_Handlers (Self : Task_Body_Declaration) return Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access is abstract; not overriding function End_Name (Self : Task_Body_Declaration) return Program.Elements.Identifiers.Identifier_Access is abstract; type Task_Body_Declaration_Text is limited interface; type Task_Body_Declaration_Text_Access is access all Task_Body_Declaration_Text'Class with Storage_Size => 0; not overriding function To_Task_Body_Declaration_Text (Self : aliased in out Task_Body_Declaration) return Task_Body_Declaration_Text_Access is abstract; not overriding function Task_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Body_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function With_Token (Self : Task_Body_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Is_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Begin_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Exception_Token (Self : Task_Body_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function End_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Semicolon_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Task_Body_Declarations;
stcarrez/mat
Ada
3,444
ads
----------------------------------------------------------------------- -- mat-consoles-text - Text console interface -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Glib; with Gtk.Frame; with Gtk.Tree_Model; with Gtk.Tree_Store; with Gtk.Cell_Renderer_Text; with Gtk.Tree_View; with Gtk.Scrolled_Window; package MAT.Consoles.Gtkmat is type Console_Type is new MAT.Consoles.Console_Type with private; type Console_Type_Access is access all Console_Type'Class; -- Initialize the console to display the result in the Gtk frame. procedure Initialize (Console : in out Console_Type; Frame : in Gtk.Frame.Gtk_Frame); -- Report a notice message. overriding procedure Notice (Console : in out Console_Type; Kind : in Notice_Type; Message : in String); -- Report an error message. overriding procedure Error (Console : in out Console_Type; Message : in String); -- Print the field value for the given field. overriding procedure Print_Field (Console : in out Console_Type; Field : in Field_Type; Value : in String; Justify : in Justify_Type := J_LEFT); -- Print the title for the given field. overriding procedure Print_Title (Console : in out Console_Type; Field : in Field_Type; Title : in String); -- Start a new title in a report. overriding procedure Start_Title (Console : in out Console_Type); -- Finish a new title in a report. procedure End_Title (Console : in out Console_Type); -- Start a new row in a report. overriding procedure Start_Row (Console : in out Console_Type); -- Finish a new row in a report. overriding procedure End_Row (Console : in out Console_Type); private type Column_Type is record Field : Field_Type; Title : Ada.Strings.Unbounded.Unbounded_String; end record; type Column_Array is array (1 .. Field_Type'Pos (Field_Type'Last)) of Column_Type; type Field_Index_Array is array (Field_Type) of Glib.Gint; type Console_Type is new MAT.Consoles.Console_Type with record Frame : Gtk.Frame.Gtk_Frame; Scrolled : Gtk.Scrolled_Window.Gtk_Scrolled_Window; List : Gtk.Tree_Store.Gtk_Tree_Store; Current_Row : Gtk.Tree_Model.Gtk_Tree_Iter; File : Ada.Text_IO.File_Type; Indexes : Field_Index_Array; Columns : Column_Array; Tree : Gtk.Tree_View.Gtk_Tree_View; Col_Text : Gtk.Cell_Renderer_Text.Gtk_Cell_renderer_Text; end record; end MAT.Consoles.Gtkmat;
annexi-strayline/AURA
Ada
12,767
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. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with Stream_Hashing; with Registrar.Registration; separate (Build) package body Recompilation_Check_Orders is package Reg_Qs renames Registrar.Queries; use type Stream_Hashing.Hash_Type; use all type Registrar.Library_Units.Library_Unit_Kind; ------------------- -- Test_Isolated -- ------------------- procedure Test_Isolated (Unit : in out Registrar.Library_Units.Library_Unit; Isolated: out Boolean) with Pre => Unit.Kind in Package_Unit | Subprogram_Unit; -- Scans the specification of Unit for any generic declarations or Inline -- subprograms. If any are found, Isolated is set to False, otherwise -- Isolated is set to True. -- -- Note that this scan is somepessemistic. There may be some cases which can -- cause it to "wrongly" classify a unit as being NOT isolated when -- it really is (false negative). It shouldn't have false positives, -- however. -- -- One interesting case is where a generic unit is declared in the private -- part of a package. In this case only some of the dependent units would -- need to be recompiled. Test_Isolated will not bother trying to sort that -- out. procedure Test_Isolated (Unit : in out Registrar.Library_Units.Library_Unit; Isolated: out Boolean) is separate; ----------------------- -- Recompilation_Set -- ----------------------- protected body Recompilation_Set is ------------------ -- Enter_Subset -- ------------------ procedure Enter_Subset (Entry_Subset: in out Unit_Names.Sets.Set) is begin Entry_Subset.Difference (Master); Master.Union (Entry_Subset); end Enter_Subset; function Retrieve return Unit_Names.Sets.Set is (Master); end Recompilation_Set; ----------- -- Image -- ----------- function Image (Order: Recompilation_Check_Order) return String is ( "[Recompilation_Check_Order] (Build)" & New_Line & " Target: " & Order.Target.To_UTF8_String & New_Line & " Mode : " & Processing_Mode'Image (Order.Mode) & New_Line); ------------- -- Execute -- ------------- procedure Execute (Order: in out Recompilation_Check_Order) is use Registrar.Library_Units; package Last_Run renames Registrar.Last_Run; function Seek_Parent (Subunit_Name: Unit_Names.Unit_Name) return Unit_Names.Unit_Name is (Reg_Qs.Trace_Subunit_Parent(Reg_Qs.Lookup_Unit (Subunit_Name)).Name); procedure Recompile_All is -- Recompile_All recursively triggers the recompilation of the -- Target unit, as well as all reverse dependencies of that unit Recurse_Order: Recompilation_Check_Order := (Tracker => Order.Tracker, Mode => Set, Recomp_Set => Order.Recomp_Set, others => <>); -- A delta aggregate would be nice here.. Rev_Deps: Unit_Names.Sets.Set := Registrar.Queries.Dependent_Units (Order.Target); begin pragma Assert (for all Unit of Rev_Deps => Reg_Qs.Lookup_Unit(Unit).Kind /= Subunit); -- This should be managed in the Registrar.Dependency_Processing. -- Consolidate_Dependencies operation. -- For Test modes, add Target directly to the Recomp_Set since Test -- mode indicates that Target is the root of a dependency tree, and so -- unlike Set orders, has not already been added by an earlier -- recursive order if Order.Mode = Test then declare Just_Me: Unit_Names.Sets.Set := Unit_Names.Sets.To_Set (Order.Target); -- Needs to be a variable for Enter_Subset begin Order.Recomp_Set.Enter_Subset (Just_Me); end; end if; Order.Recomp_Set.Enter_Subset (Rev_Deps); -- Now Rev_Deps only has the unit names that have not already -- been marked as needing recompilation (the units that have -- just been added to the Recomp_Set. So we need to dispatch -- recursive orders for them, so that they will have their -- dependencies added aswell Recurse_Order.Tracker.Increase_Total_Items_By (Natural (Rev_Deps.Length)); for Name of Rev_Deps loop Recurse_Order.Target := Name; Workers.Enqueue_Order (Recurse_Order); end loop; end Recompile_All; This, Last: Library_Unit; Isolated : Boolean; begin case Order.Mode is when Test => pragma Assert (not Last_Run.All_Library_Units.Is_Empty); -- Build.Compute_Recompilations is not supposed to submit any work -- orders at all if there is no Last_Run registry This := Reg_Qs.Lookup_Unit (Order.Target); pragma Assert (This.State = Compiled); -- We should only ever be "testing" units that are compiled. Last := Last_Run.All_Library_Units (Last_Run.All_Library_Units.Find (This)); -- Note the lookup of Last should not fail because we'd only get -- here if This had a state of "Compiled", and therefore it -- must be in Last. If this fails, good, something is very wrong. if Last.State /= Compiled or else This.Kind /= Last.Kind or else (if This.Spec_File = null then This.Implementation_Hash /= Last.Implementation_Hash else This.Specification_Hash /= Last.Specification_Hash) -- Remember that subprogram units do not need a separate spec, -- so if the body changes for such a subprogram, we cannot assume -- that it doesn't effect it's reverse dependencies or else This.Compilation_Hash /= Last.Compilation_Hash then -- Definately needs recompilation Recompile_All; elsif This.Implementation_Hash /= Last.Implementation_Hash then pragma Assert (This.Body_File /= null); if This.Kind not in Package_Unit | Subprogram_Unit | Subunit then -- All non-Ada units are assumed to not be isolated. -- Also, Test_Isolated is expecting an Ada source Isolated := False; else Test_Isolated (Unit => This, Isolated => Isolated); end if; if Isolated then -- This unit can apparently be recompiled on its own declare Just_Me: Unit_Names.Sets.Set := Unit_Names.Sets.To_Set (Order.Target); begin Order.Recomp_Set.Enter_Subset (Just_Me); end; else -- No luck Recompile_All; end if; end if; when Set => Recompile_All; end case; end Execute; ------------------- -- Phase_Trigger -- ------------------- procedure Phase_Trigger (Order: in out Recompilation_Check_Order) is use Registrar.Library_Units; -- Now the Recomp_Set should be complete. We'll use it to pull a -- subset of All_Library_Units, and set all of the states to -- "Available" procedure Free is new Ada.Unchecked_Deallocation (Object => Recompilation_Set, Name => Recompilation_Set_Access); Selected_Units: Library_Unit_Sets.Set := Reg_Qs.Entered_Library_Units; Recomp_Units : Library_Unit_Sets.Set; begin for Name of Order.Recomp_Set.Retrieve loop Recomp_Units.Include (Library_Unit'(Name => Name, others => <>)); end loop; Free (Order.Recomp_Set); Selected_Units.Intersection (Recomp_Units); declare procedure Set_Available (Unit: in out Library_Unit) is begin Unit.State := Available; end Set_Available; begin for C in Selected_Units.Iterate loop Library_Unit_Sets_Keyed_Operations.Update_Element_Preserving_Key (Container => Selected_Units, Position => C, Process => Set_Available'Access); end loop; end; Registrar.Registration.Update_Library_Unit_Subset (Selected_Units); Compute_Recompilations_Completion.Leave; exception when others => Free (Order.Recomp_Set); if Compute_Recompilations_Completion.Active then Compute_Recompilations_Completion.Leave; end if; raise; end Phase_Trigger; end Recompilation_Check_Orders;
scoffable/swagger-codegen
Ada
11,809
adb
-- Swagger Petstore -- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special_key` to test the authorization filters. -- -- OpenAPI spec version: 1.0.0 -- Contact: [email protected] -- -- NOTE: This package is auto generated by the swagger code generator 2.3.0-SNAPSHOT. -- https://github.com/swagger-api/swagger-codegen.git -- Do not edit the class manually. package body Samples.Petstore.Models is use Swagger.Streams; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ApiResponse_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("code", Value.Code); Into.Write_Entity ("type", Value.P_Type); Into.Write_Entity ("message", Value.Message); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ApiResponse_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ApiResponse_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "code", Value.Code); Swagger.Streams.Deserialize (Object, "type", Value.P_Type); Swagger.Streams.Deserialize (Object, "message", Value.Message); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ApiResponse_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : ApiResponse_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Category_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); Into.Write_Entity ("name", Value.Name); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Category_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Category_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "name", Value.Name); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Category_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Category_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Tag_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); Into.Write_Entity ("name", Value.Name); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Tag_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Tag_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "name", Value.Name); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Tag_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Tag_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in User_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); Into.Write_Entity ("username", Value.Username); Into.Write_Entity ("firstName", Value.First_Name); Into.Write_Entity ("lastName", Value.Last_Name); Into.Write_Entity ("email", Value.Email); Into.Write_Entity ("password", Value.Password); Into.Write_Entity ("phone", Value.Phone); Into.Write_Entity ("userStatus", Value.User_Status); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in User_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out User_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "username", Value.Username); Swagger.Streams.Deserialize (Object, "firstName", Value.First_Name); Swagger.Streams.Deserialize (Object, "lastName", Value.Last_Name); Swagger.Streams.Deserialize (Object, "email", Value.Email); Swagger.Streams.Deserialize (Object, "password", Value.Password); Swagger.Streams.Deserialize (Object, "phone", Value.Phone); Swagger.Streams.Deserialize (Object, "userStatus", Value.User_Status); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out User_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : User_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Order_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); Serialize (Into, "petId", Value.Pet_Id); Into.Write_Entity ("quantity", Value.Quantity); Into.Write_Entity ("shipDate", Value.Ship_Date); Into.Write_Entity ("status", Value.Status); Into.Write_Entity ("complete", Value.Complete); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Order_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Order_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Swagger.Streams.Deserialize (Object, "petId", Value.Pet_Id); Swagger.Streams.Deserialize (Object, "quantity", Value.Quantity); Deserialize (Object, "shipDate", Value.Ship_Date); Swagger.Streams.Deserialize (Object, "status", Value.Status); Swagger.Streams.Deserialize (Object, "complete", Value.Complete); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Order_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Order_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Pet_Type) is begin Into.Start_Entity (Name); Serialize (Into, "id", Value.Id); Serialize (Into, "category", Value.Category); Into.Write_Entity ("name", Value.Name); Serialize (Into, "photoUrls", Value.Photo_Urls); Serialize (Into, "tags", Value.Tags); Into.Write_Entity ("status", Value.Status); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Pet_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Pet_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "id", Value.Id); Deserialize (Object, "category", Value.Category); Swagger.Streams.Deserialize (Object, "name", Value.Name); Swagger.Streams.Deserialize (Object, "photoUrls", Value.Photo_Urls); Deserialize (Object, "tags", Value.Tags); Swagger.Streams.Deserialize (Object, "status", Value.Status); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Pet_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Pet_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; end Samples.Petstore.Models;
zhmu/ananas
Ada
9,051
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 0 6 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; with System.Unsigned_Types; package body System.Pack_06 is subtype Bit_Order is System.Bit_Order; Reverse_Bit_Order : constant Bit_Order := Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order)); subtype Ofs is System.Storage_Elements.Storage_Offset; subtype Uns is System.Unsigned_Types.Unsigned; subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7; use type System.Storage_Elements.Storage_Offset; use type System.Unsigned_Types.Unsigned; type Cluster is record E0, E1, E2, E3, E4, E5, E6, E7 : Bits_06; end record; for Cluster use record E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1; E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1; E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1; E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1; E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1; E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1; E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1; E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1; end record; for Cluster'Size use Bits * 8; for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment, 1 + 1 * Boolean'Pos (Bits mod 2 = 0) + 2 * Boolean'Pos (Bits mod 4 = 0)); -- Use maximum possible alignment, given the bit field size, since this -- will result in the most efficient code possible for the field. type Cluster_Ref is access Cluster; type Rev_Cluster is new Cluster with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_Cluster_Ref is access Rev_Cluster; -- The following declarations are for the case where the address -- passed to GetU_06 or SetU_06 is not guaranteed to be aligned. -- These routines are used when the packed array is itself a -- component of a packed record, and therefore may not be aligned. type ClusterU is new Cluster; for ClusterU'Alignment use 1; type ClusterU_Ref is access ClusterU; type Rev_ClusterU is new ClusterU with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_ClusterU_Ref is access Rev_ClusterU; ------------ -- Get_06 -- ------------ function Get_06 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_06 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end Get_06; ------------- -- GetU_06 -- ------------- function GetU_06 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_06 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : ClusterU_Ref with Address => A'Address, Import; RC : Rev_ClusterU_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end GetU_06; ------------ -- Set_06 -- ------------ procedure Set_06 (Arr : System.Address; N : Natural; E : Bits_06; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end Set_06; ------------- -- SetU_06 -- ------------- procedure SetU_06 (Arr : System.Address; N : Natural; E : Bits_06; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : ClusterU_Ref with Address => A'Address, Import; RC : Rev_ClusterU_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end SetU_06; end System.Pack_06;
davidkristola/vole
Ada
515
ads
with kv.avm.Executables; with kv.avm.Actor_References; package kv.avm.Actor_Pool is procedure Add (Actor : in kv.avm.Executables.Executable_Access; Reference : out kv.avm.Actor_References.Actor_Reference_Type); procedure Delete (Reference : in kv.avm.Actor_References.Actor_Reference_Type); function Resolve(Reference : kv.avm.Actor_References.Actor_Reference_Type) return kv.avm.Executables.Executable_Access; procedure Empty_Actor_Pool; end kv.avm.Actor_Pool;
reznikmm/matreshka
Ada
840
adb
package body Forum.Topics is ------------ -- Decode -- ------------ function Decode (Image : League.Strings.Universal_String; Value : out Topic_Identifier) return Boolean is begin -- XXX This subprogram must be rewritter without use of exceptions. Value := Topic_Identifier'Wide_Wide_Value (Image.To_Wide_Wide_String); return True; exception when Constraint_Error => return False; end Decode; ------------ -- Encode -- ------------ function Encode (Item : Topic_Identifier) return League.Strings.Universal_String is Aux : constant Wide_Wide_String := Topic_Identifier'Wide_Wide_Image (Item); begin return League.Strings.To_Universal_String (Aux (Aux'First + 1 .. Aux'Last)); end Encode; end Forum.Topics;
tum-ei-rcs/StratoX
Ada
1,340
adb
with stm32.gpio; use stm32.gpio; package body HAL.GPIO is procedure write (Point : GPIO_Point_Type; Signal : GPIO_Signal_Type) is begin case Signal is when HIGH => case Point.Port is when A => GPIOA_Periph.BSRR.BS.Arr( Point.Pin ) := True; when B => GPIOB_Periph.BSRR.BS.Arr( Point.Pin ) := True; when C => GPIOC_Periph.BSRR.BS.Arr( Point.Pin ) := True; when D => GPIOD_Periph.BSRR.BS.Arr( Point.Pin ) := True; when E => GPIOE_Periph.BSRR.BS.Arr( Point.Pin ) := True; when F => GPIOF_Periph.BSRR.BS.Arr( Point.Pin ) := True; end case; when LOW => case Point.Port is when A => GPIOA_Periph.BSRR.BR.Arr( Point.Pin ) := True; when B => GPIOB_Periph.BSRR.BR.Arr( Point.Pin ) := True; when C => GPIOC_Periph.BSRR.BR.Arr( Point.Pin ) := True; when D => GPIOD_Periph.BSRR.BR.Arr( Point.Pin ) := True; when E => GPIOE_Periph.BSRR.BR.Arr( Point.Pin ) := True; when F => GPIOF_Periph.BSRR.BR.Arr( Point.Pin ) := True; end case; end case; end write; function read (Point : GPIO_Point_Type) return GPIO_Signal_Type is begin return HIGH; end read; end HAL.GPIO;
reznikmm/matreshka
Ada
4,249
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.Margin_Right.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.FO.Margin_Right.FO_Margin_Right_Access) return ODF.DOM.Attributes.FO.Margin_Right.ODF_FO_Margin_Right 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.Margin_Right.FO_Margin_Right_Access) return ODF.DOM.Attributes.FO.Margin_Right.ODF_FO_Margin_Right is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.FO.Margin_Right.Internals;
charlie5/aIDE
Ada
1,018
ads
with AdaM.a_Type.a_subtype, gtk.Widget; private with gtk.gEntry, gtk.Box, gtk.Label, gtk.Button; package aIDE.Editor.of_subtype is type Item is new Editor.item with private; type View is access all Item'Class; package Forge is function to_Editor (the_Target : in AdaM.a_Type.a_subtype.view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; private use gtk.Button, gtk.gEntry, gtk.Label, gtk.Box; type Item is new Editor.item with record Target : AdaM.a_Type.a_subtype.view; top_Box : gtk_Box; subtype_name_Entry : Gtk_Entry; type_name_Button : gtk_Button; first_Entry : Gtk_Entry; last_Entry : Gtk_Entry; rid_Button : gtk_Button; end record; overriding procedure freshen (Self : in out Item); end aIDE.Editor.of_subtype;
T-Bone-Willson/SubmarinesFormalApproaches
Ada
9,499
adb
pragma Warnings (Off); pragma Ada_95; pragma Source_File_Name (ada_main, Spec_File_Name => "b__main.ads"); pragma Source_File_Name (ada_main, Body_File_Name => "b__main.adb"); pragma Suppress (Overflow_Check); with Ada.Exceptions; package body ada_main is E072 : Short_Integer; pragma Import (Ada, E072, "system__os_lib_E"); E013 : Short_Integer; pragma Import (Ada, E013, "system__soft_links_E"); E025 : Short_Integer; pragma Import (Ada, E025, "system__exception_table_E"); E068 : Short_Integer; pragma Import (Ada, E068, "ada__io_exceptions_E"); E052 : Short_Integer; pragma Import (Ada, E052, "ada__strings_E"); E040 : Short_Integer; pragma Import (Ada, E040, "ada__containers_E"); E027 : Short_Integer; pragma Import (Ada, E027, "system__exceptions_E"); E078 : Short_Integer; pragma Import (Ada, E078, "interfaces__c_E"); E054 : Short_Integer; pragma Import (Ada, E054, "ada__strings__maps_E"); E058 : Short_Integer; pragma Import (Ada, E058, "ada__strings__maps__constants_E"); E021 : Short_Integer; pragma Import (Ada, E021, "system__soft_links__initialize_E"); E080 : Short_Integer; pragma Import (Ada, E080, "system__object_reader_E"); E047 : Short_Integer; pragma Import (Ada, E047, "system__dwarf_lines_E"); E039 : Short_Integer; pragma Import (Ada, E039, "system__traceback__symbolic_E"); E101 : Short_Integer; pragma Import (Ada, E101, "ada__tags_E"); E099 : Short_Integer; pragma Import (Ada, E099, "ada__streams_E"); E113 : Short_Integer; pragma Import (Ada, E113, "system__file_control_block_E"); E112 : Short_Integer; pragma Import (Ada, E112, "system__finalization_root_E"); E110 : Short_Integer; pragma Import (Ada, E110, "ada__finalization_E"); E109 : Short_Integer; pragma Import (Ada, E109, "system__file_io_E"); E006 : Short_Integer; pragma Import (Ada, E006, "ada__text_io_E"); E115 : Short_Integer; pragma Import (Ada, E115, "submarinesubsystem_E"); Sec_Default_Sized_Stacks : array (1 .. 1) of aliased System.Secondary_Stack.SS_Stack (System.Parameters.Runtime_Default_Sec_Stack_Size); Local_Priority_Specific_Dispatching : constant String := ""; Local_Interrupt_States : constant String := ""; Is_Elaborated : Boolean := False; procedure finalize_library is begin E006 := E006 - 1; declare procedure F1; pragma Import (Ada, F1, "ada__text_io__finalize_spec"); begin F1; end; declare procedure F2; pragma Import (Ada, F2, "system__file_io__finalize_body"); begin E109 := E109 - 1; F2; end; declare procedure Reraise_Library_Exception_If_Any; pragma Import (Ada, Reraise_Library_Exception_If_Any, "__gnat_reraise_library_exception_if_any"); begin Reraise_Library_Exception_If_Any; end; end finalize_library; procedure adafinal is procedure s_stalib_adafinal; pragma Import (C, s_stalib_adafinal, "system__standard_library__adafinal"); procedure Runtime_Finalize; pragma Import (C, Runtime_Finalize, "__gnat_runtime_finalize"); begin if not Is_Elaborated then return; end if; Is_Elaborated := False; Runtime_Finalize; s_stalib_adafinal; end adafinal; type No_Param_Proc is access procedure; procedure adainit is Main_Priority : Integer; pragma Import (C, Main_Priority, "__gl_main_priority"); Time_Slice_Value : Integer; pragma Import (C, Time_Slice_Value, "__gl_time_slice_val"); WC_Encoding : Character; pragma Import (C, WC_Encoding, "__gl_wc_encoding"); Locking_Policy : Character; pragma Import (C, Locking_Policy, "__gl_locking_policy"); Queuing_Policy : Character; pragma Import (C, Queuing_Policy, "__gl_queuing_policy"); Task_Dispatching_Policy : Character; pragma Import (C, Task_Dispatching_Policy, "__gl_task_dispatching_policy"); Priority_Specific_Dispatching : System.Address; pragma Import (C, Priority_Specific_Dispatching, "__gl_priority_specific_dispatching"); Num_Specific_Dispatching : Integer; pragma Import (C, Num_Specific_Dispatching, "__gl_num_specific_dispatching"); Main_CPU : Integer; pragma Import (C, Main_CPU, "__gl_main_cpu"); Interrupt_States : System.Address; pragma Import (C, Interrupt_States, "__gl_interrupt_states"); Num_Interrupt_States : Integer; pragma Import (C, Num_Interrupt_States, "__gl_num_interrupt_states"); Unreserve_All_Interrupts : Integer; pragma Import (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts"); Detect_Blocking : Integer; pragma Import (C, Detect_Blocking, "__gl_detect_blocking"); Default_Stack_Size : Integer; pragma Import (C, Default_Stack_Size, "__gl_default_stack_size"); Default_Secondary_Stack_Size : System.Parameters.Size_Type; pragma Import (C, Default_Secondary_Stack_Size, "__gnat_default_ss_size"); Leap_Seconds_Support : Integer; pragma Import (C, Leap_Seconds_Support, "__gl_leap_seconds_support"); Bind_Env_Addr : System.Address; pragma Import (C, Bind_Env_Addr, "__gl_bind_env_addr"); procedure Runtime_Initialize (Install_Handler : Integer); pragma Import (C, Runtime_Initialize, "__gnat_runtime_initialize"); Finalize_Library_Objects : No_Param_Proc; pragma Import (C, Finalize_Library_Objects, "__gnat_finalize_library_objects"); Binder_Sec_Stacks_Count : Natural; pragma Import (Ada, Binder_Sec_Stacks_Count, "__gnat_binder_ss_count"); Default_Sized_SS_Pool : System.Address; pragma Import (Ada, Default_Sized_SS_Pool, "__gnat_default_ss_pool"); begin if Is_Elaborated then return; end if; Is_Elaborated := True; Main_Priority := -1; Time_Slice_Value := -1; WC_Encoding := 'b'; Locking_Policy := ' '; Queuing_Policy := ' '; Task_Dispatching_Policy := ' '; Priority_Specific_Dispatching := Local_Priority_Specific_Dispatching'Address; Num_Specific_Dispatching := 0; Main_CPU := -1; Interrupt_States := Local_Interrupt_States'Address; Num_Interrupt_States := 0; Unreserve_All_Interrupts := 0; Detect_Blocking := 0; Default_Stack_Size := -1; Leap_Seconds_Support := 0; ada_main'Elab_Body; Default_Secondary_Stack_Size := System.Parameters.Runtime_Default_Sec_Stack_Size; Binder_Sec_Stacks_Count := 1; Default_Sized_SS_Pool := Sec_Default_Sized_Stacks'Address; Runtime_Initialize (1); Finalize_Library_Objects := finalize_library'access; System.Soft_Links'Elab_Spec; System.Exception_Table'Elab_Body; E025 := E025 + 1; Ada.Io_Exceptions'Elab_Spec; E068 := E068 + 1; Ada.Strings'Elab_Spec; E052 := E052 + 1; Ada.Containers'Elab_Spec; E040 := E040 + 1; System.Exceptions'Elab_Spec; E027 := E027 + 1; Interfaces.C'Elab_Spec; System.Os_Lib'Elab_Body; E072 := E072 + 1; Ada.Strings.Maps'Elab_Spec; Ada.Strings.Maps.Constants'Elab_Spec; E058 := E058 + 1; System.Soft_Links.Initialize'Elab_Body; E021 := E021 + 1; E013 := E013 + 1; System.Object_Reader'Elab_Spec; System.Dwarf_Lines'Elab_Spec; E047 := E047 + 1; E078 := E078 + 1; E054 := E054 + 1; System.Traceback.Symbolic'Elab_Body; E039 := E039 + 1; E080 := E080 + 1; Ada.Tags'Elab_Spec; Ada.Tags'Elab_Body; E101 := E101 + 1; Ada.Streams'Elab_Spec; E099 := E099 + 1; System.File_Control_Block'Elab_Spec; E113 := E113 + 1; System.Finalization_Root'Elab_Spec; E112 := E112 + 1; Ada.Finalization'Elab_Spec; E110 := E110 + 1; System.File_Io'Elab_Body; E109 := E109 + 1; Ada.Text_Io'Elab_Spec; Ada.Text_Io'Elab_Body; E006 := E006 + 1; E115 := E115 + 1; end adainit; procedure Ada_Main_Program; pragma Import (Ada, Ada_Main_Program, "_ada_main"); function main (argc : Integer; argv : System.Address; envp : System.Address) return Integer is procedure Initialize (Addr : System.Address); pragma Import (C, Initialize, "__gnat_initialize"); procedure Finalize; pragma Import (C, Finalize, "__gnat_finalize"); SEH : aliased array (1 .. 2) of Integer; Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address; pragma Volatile (Ensure_Reference); begin gnat_argc := argc; gnat_argv := argv; gnat_envp := envp; Initialize (SEH'Address); adainit; Ada_Main_Program; adafinal; Finalize; return (gnat_exit_status); end; -- BEGIN Object file/option list -- C:\Users\T-Bone-Willson\Desktop\Formal Approaches Assignment\SubmarinesFormalApproaches\obj\submarinesubsystem.o -- C:\Users\T-Bone-Willson\Desktop\Formal Approaches Assignment\SubmarinesFormalApproaches\obj\main.o -- -LC:\Users\T-Bone-Willson\Desktop\Formal Approaches Assignment\SubmarinesFormalApproaches\obj\ -- -LC:\Users\T-Bone-Willson\Desktop\Formal Approaches Assignment\SubmarinesFormalApproaches\obj\ -- -LC:/gnat/2018/lib/gcc/x86_64-pc-mingw32/7.3.1/adalib/ -- -static -- -lgnat -- -Wl,--stack=0x2000000 -- END Object file/option list end ada_main;
reznikmm/matreshka
Ada
3,549
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 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 League.Strings; with Core.Connectables.Slots_0.Slots_1; package WUI.Slots.Strings is new Core.Connectables.Slots_0.Slots_1 (League.Strings.Universal_String); pragma Preelaborate (WUI.Slots.Strings);