content stringlengths 23 1.05M |
|---|
-- *************************************************************************************
-- The recipient is warned that this code should be handled in accordance
-- with the HM Government Security Classification indicated throughout.
--
-- This code and its contents shall not be used for other than UK Government
-- purposes.
--
-- The copyright in this code is the property of BAE SYSTEMS Electronic Systems Limited.
-- The Code is supplied by BAE SYSTEMS on the express terms that it is to be treated in
-- confidence and that it may not be copied, used or disclosed to others for any
-- purpose except in accordance with DEFCON 91 (Edn 10/92).
--
-- File Name: Generic_FIFO.adb
-- Version: As detailed by ClearCase
-- Version Date: As detailed by ClearCase
-- Creation Date: 03-11-99
-- Security Classification: Unclassified
-- Project: SRLE (Sting Ray Life Extension)
-- Author: J Mann
-- Section: Tactical Software/ Software Architecture
-- Division: Underwater Systems Division
-- Description: Specification and implementation of application-wide FIFO type
-- Comments:
--
-- MODIFICATION RECORD
-- --------------------
-- NAME DATE ECR No MODIFICATION
--
-- **************************************************************************************
package body Generic_FIFO is
--
-- The free list retains the memory space of deleted items. If it results in unacceptable sizes
-- at run time, the option of deallocating excesses will be addressed
--
Free_List: FIFO_Access_Type;
--
------------------------------------------------------------------------------------------------
--
-- The FIFO is less used than the list structure, so does not as yet have the same diagnostic
-- operations. If they prove desirable, their inclusion will be considered.
--
procedure Push (
Item : in Element_Type;
Target_FIFO : in out FIFO_Type;
Top : in boolean := false) is
New_Cell: FIFO_Access_Type;
begin
-- Log.Put_Line ("Push: 'before' queue size -> "&integer'image (Target_FIFO.Size));
if Free_List = null then
--
-- there are no 'old' entries available for reuse
--
-- log.put_line ("Push called - no 'old' entries");
begin
New_Cell:= new FIFO_Cell_Type;
exception
when Storage_Error => raise FIFO_Overflow_Error ;
end;
else
--
-- there are,.. so take the first one and step on the free list
New_Cell := Free_List;
Free_List := Free_List. Next_Cell;
end if;
--
-- the new cell has been identified, so set the fields up
--
if Top then
--
-- put to FRONT of queue
--
New_Cell.all := (
Element_Pointer => Item,
Next_Cell => null,
Previous_Cell => Target_FIFO.Last_Entry);
--
-- link the new cell into the FIFO
--
if Target_FIFO.First_Entry = null then
Target_FIFO.First_Entry := New_Cell;
else
Target_FIFO.Last_Entry.Next_Cell := New_Cell;
end if;
Target_FIFO.Last_Entry := New_Cell;
else
--
-- (normal) put to back of queue
--
New_Cell.all := (
Element_Pointer => Item,
Next_Cell => Target_FIFO.First_Entry,
Previous_Cell => null);
--
-- link the new cell into the FIFO
--
if Target_FIFO.First_Entry = null then
Target_FIFO.Last_Entry := New_Cell;
else
Target_FIFO.First_Entry.Previous_Cell := New_Cell;
end if;
Target_FIFO.First_Entry := New_Cell;
end if;
--
-- and increment the size of the store
--
Target_FIFO.Size := Target_FIFO. Size + 1;
if Target_FIFO.Size > Target_FIFO.Max_Count then
Target_FIFO.Max_Count := Target_FIFO.Size;
end if;
end Push;
--
---------------------------------------------------------------------
--
procedure Pop (
Item : out Element_Type;
Target_FIFO : in out FIFO_Type) is
Old_Cell: FIFO_Access_Type;
begin
Target_FIFO := Target_FIFO;
if Target_FIFO. Last_Entry = null then raise FIFO_Underflow_Error;
--
-- trying to extract from an already-empty queue
--
else
--
-- set output parameter to be oldest entry (in time)
--
Item := Target_FIFO.Last_Entry.Element_Pointer ;
--
-- and undo and remake the links from the FIFO list
--
Old_Cell := Target_FIFO.Last_Entry;
Target_FIFO.Last_Entry := Target_FIFO.Last_Entry.Previous_Cell;
if Target_FIFO.Last_Entry /= null then
Target_FIFO.Last_Entry.Next_Cell := null;
else
Target_FIFO.First_Entry := null;
end if;
--
-- and decrement the size of the store
--
Target_FIFO.Size := Target_FIFO.Size - 1;
--
-- add deleted cell to the free list available for reuse
--
Old_Cell.Next_Cell := Free_List;
Old_Cell.Previous_Cell := null;
Free_List := Old_Cell;
end if;
end Pop;
--
---------------------------------------------------------------------
--
--
-- This function is provided only as an interface operation
--
function Queue_Length (Queue: FIFO_Type) return Natural is
begin
return Queue.Size;
end Queue_Length;
--
---------------------------------------------------------------------
function Max_Count_Of (Queue: FIFO_Type) return Natural is
begin
return Queue.Max_Count;
end Max_Count_Of;
---------------------------------------------------------------------
--
end Generic_FIFO;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> --
-- 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.Standard_Profile_L2.Auxiliaries;
with AMF.Standard_Profile_L2.Calls;
with AMF.Standard_Profile_L2.Creates;
with AMF.Standard_Profile_L2.Derives;
with AMF.Standard_Profile_L2.Destroies;
with AMF.Standard_Profile_L2.Documents;
with AMF.Standard_Profile_L2.Entities;
with AMF.Standard_Profile_L2.Executables;
with AMF.Standard_Profile_L2.Focuses;
with AMF.Standard_Profile_L2.Frameworks;
with AMF.Standard_Profile_L2.Implementation_Classes;
with AMF.Standard_Profile_L2.Implements;
with AMF.Standard_Profile_L2.Instantiates;
with AMF.Standard_Profile_L2.Libraries;
with AMF.Standard_Profile_L2.Metaclasses;
with AMF.Standard_Profile_L2.Model_Libraries;
with AMF.Standard_Profile_L2.Processes;
with AMF.Standard_Profile_L2.Realizations;
with AMF.Standard_Profile_L2.Refines;
with AMF.Standard_Profile_L2.Responsibilities;
with AMF.Standard_Profile_L2.Scripts;
with AMF.Standard_Profile_L2.Sends;
with AMF.Standard_Profile_L2.Services;
with AMF.Standard_Profile_L2.Sources;
with AMF.Standard_Profile_L2.Specifications;
with AMF.Standard_Profile_L2.Subsystems;
with AMF.Standard_Profile_L2.Traces;
with AMF.Standard_Profile_L2.Types;
with AMF.Standard_Profile_L2.Utilities;
package AMF.Visitors.Standard_Profile_L2_Iterators is
pragma Preelaborate;
type Standard_Profile_L2_Iterator is limited interface and AMF.Visitors.Abstract_Iterator;
not overriding procedure Visit_Auxiliary
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Auxiliaries.Standard_Profile_L2_Auxiliary_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Call
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Calls.Standard_Profile_L2_Call_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Create
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Creates.Standard_Profile_L2_Create_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Derive
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Derives.Standard_Profile_L2_Derive_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Destroy
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Destroies.Standard_Profile_L2_Destroy_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Document
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Documents.Standard_Profile_L2_Document_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Entity
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Entities.Standard_Profile_L2_Entity_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Executable
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Executables.Standard_Profile_L2_Executable_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Focus
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Focuses.Standard_Profile_L2_Focus_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Framework
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Frameworks.Standard_Profile_L2_Framework_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Implement
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Implements.Standard_Profile_L2_Implement_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Implementation_Class
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Implementation_Classes.Standard_Profile_L2_Implementation_Class_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Instantiate
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Instantiates.Standard_Profile_L2_Instantiate_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Library
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Libraries.Standard_Profile_L2_Library_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Metaclass
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Metaclasses.Standard_Profile_L2_Metaclass_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Model_Library
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Model_Libraries.Standard_Profile_L2_Model_Library_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Process
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Processes.Standard_Profile_L2_Process_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Realization
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Realizations.Standard_Profile_L2_Realization_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Refine
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Refines.Standard_Profile_L2_Refine_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Responsibility
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Responsibilities.Standard_Profile_L2_Responsibility_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Script
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Scripts.Standard_Profile_L2_Script_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Send
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Sends.Standard_Profile_L2_Send_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Service
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Services.Standard_Profile_L2_Service_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Source
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Sources.Standard_Profile_L2_Source_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Specification
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Specifications.Standard_Profile_L2_Specification_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Subsystem
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Subsystems.Standard_Profile_L2_Subsystem_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Trace
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Traces.Standard_Profile_L2_Trace_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Type
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Types.Standard_Profile_L2_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Utility
(Self : in out Standard_Profile_L2_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Standard_Profile_L2.Utilities.Standard_Profile_L2_Utility_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
end AMF.Visitors.Standard_Profile_L2_Iterators;
|
with Ada.Text_Io; use Ada.Text_Io;
procedure Doors is
type Door_State is (Closed, Open);
type Door_List is array(Positive range 1..100) of Door_State;
The_Doors : Door_List := (others => Closed);
begin
for I in 1..100 loop
for J in The_Doors'range loop
if J mod I = 0 then
if The_Doors(J) = Closed then
The_Doors(J) := Open;
else
The_Doors(J) := Closed;
end if;
end if;
end loop;
end loop;
for I in The_Doors'range loop
Put_Line(Integer'Image(I) & " is " & Door_State'Image(The_Doors(I)));
end loop;
end Doors;
|
with Types;
use Types;
package Mathutil with SPARK_Mode => On is
function ArcTan(Y : FloatingNumber; X : FloatingNumber) return FloatingNumber
with
Global => null,
Pre => X /= 0.0 and then Y /= 0.0,
Post => ArcTan'Result <= 180.0 and then ArcTan'Result >= (-180.0);
function Sin(X : FloatingNumber) return FloatingNumber
with
Post => Sin'Result >= -1.0 and Sin'Result <= 1.0,
Global => null;
function Cos(X : FloatingNumber) return FloatingNumber
with
Post => Cos'Result >= -1.0 and Cos'Result <= 1.0,
Global => null;
function Tan(X : FloatingNumber) return FloatingNumber
with
Global => null;
function Sin_r(X : FloatingNumber) return FloatingNumber
with
Post => Sin_r'Result >= -1.0 and Sin_r'Result <= 1.0,
Global => null;
function Cos_r(X : FloatingNumber) return FloatingNumber
with
Post => Cos_r'Result >= -1.0 and Cos_r'Result <= 1.0,
Global => null;
function Tan_r(X : FloatingNumber) return FloatingNumber
with
Global => null;
function Sqrt(X : FloatingNumber) return FloatingNumber
with
Global => null,
Pre => X > 0.0,
Post => Sqrt'Result <= X and then Sqrt'Result > 0.0;
end Mathutil;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . I M G _ U T I L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020-2021, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides some common utilities used by the s-imgxxx files
package System.Img_Util is
pragma Pure;
Max_Real_Image_Length : constant := 5200;
-- If Exp is set to zero and Aft is set to Text_IO.Field'Last (i.e., 255)
-- then Long_Long_Float'Last generates an image whose length is slightly
-- less than 5200.
procedure Set_Decimal_Digits
(Digs : in out String;
NDigs : Natural;
S : out String;
P : in out Natural;
Scale : Integer;
Fore : Natural;
Aft : Natural;
Exp : Natural);
-- Sets the image of Digs (1 .. NDigs), which is a string of decimal digits
-- preceded by either a minus sign or a space, i.e. the integer image of
-- the value in units of delta if this is for a decimal fixed point type
-- with the given Scale, or the integer image of the value converted to an
-- implicit decimal fixed point type with the given Scale if this is for an
-- ordinary fixed point type, starting at S (P + 1), updating P to point to
-- the last character stored. The caller promises that the buffer is large
-- enough and therefore no check is made for it. Constraint_Error will not
-- necessarily be raised if the requirement is violated since it is valid
-- to compile this unit with checks off. The Fore, Aft and Exp values can
-- be set to any valid values for the case of use by Text_IO.Decimal_IO or
-- Text_IO.Fixed_IO. Note that there is no leading space stored. The call
-- may destroy the value in Digs, which is why Digs is in-out (this happens
-- if rounding is required).
type Floating_Invalid_Value is (Minus_Infinity, Infinity, Not_A_Number);
procedure Set_Floating_Invalid_Value
(V : Floating_Invalid_Value;
S : out String;
P : in out Natural;
Fore : Natural;
Aft : Natural;
Exp : Natural);
-- Sets the image of a floating-point invalid value, starting at S (P + 1),
-- updating P to point to the last character stored. The caller promises
-- that the buffer is large enough and therefore no check is made for it.
-- Constraint_Error will not necessarily be raised if the requirement is
-- violated since it is valid to compile this unit with checks off.
end System.Img_Util;
|
-- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Missions.Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
with Ships; use Ships;
with Maps; use Maps;
with Bases; use Bases;
-- begin read only
-- end read only
package body Missions.Test_Data.Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
procedure Wrap_Test_GenerateMissions_2a8787_14c74a is
begin
GNATtest_Generated.GNATtest_Standard.Missions.GenerateMissions;
end Wrap_Test_GenerateMissions_2a8787_14c74a;
-- end read only
-- begin read only
procedure Test_GenerateMissions_test_generatemissions
(Gnattest_T: in out Test);
procedure Test_GenerateMissions_2a8787_14c74a
(Gnattest_T: in out Test) renames
Test_GenerateMissions_test_generatemissions;
-- id:2.2/2a8787b975b577a4/GenerateMissions/1/0/test_generatemissions/
procedure Test_GenerateMissions_test_generatemissions
(Gnattest_T: in out Test) is
procedure GenerateMissions renames
Wrap_Test_GenerateMissions_2a8787_14c74a;
-- end read only
pragma Unreferenced(Gnattest_T);
BaseIndex: constant Natural :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
begin
Sky_Bases(BaseIndex).Missions_Date := (others => 0);
GenerateMissions;
Assert(True, "This test can only crash.");
-- begin read only
end Test_GenerateMissions_test_generatemissions;
-- end read only
-- begin read only
procedure Wrap_Test_AcceptMission_979505_57ce38(MissionIndex: Positive) is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(missions.ads:0):Test_AcceptMission test requirement violated");
end;
GNATtest_Generated.GNATtest_Standard.Missions.AcceptMission
(MissionIndex);
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(missions.ads:0:):Test_AcceptMission test commitment violated");
end;
end Wrap_Test_AcceptMission_979505_57ce38;
-- end read only
-- begin read only
procedure Test_AcceptMission_test_acceptmission(Gnattest_T: in out Test);
procedure Test_AcceptMission_979505_57ce38(Gnattest_T: in out Test) renames
Test_AcceptMission_test_acceptmission;
-- id:2.2/9795058c0b298911/AcceptMission/1/0/test_acceptmission/
procedure Test_AcceptMission_test_acceptmission(Gnattest_T: in out Test) is
procedure AcceptMission(MissionIndex: Positive) renames
Wrap_Test_AcceptMission_979505_57ce38;
-- end read only
pragma Unreferenced(Gnattest_T);
BaseIndex: constant Positive :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
MissionIndex: Positive :=
Positive(Sky_Bases(BaseIndex).Missions.Length + 1);
begin
while MissionIndex > Natural(Sky_Bases(BaseIndex).Missions.Length) loop
for I in Sky_Bases(BaseIndex).Missions.Iterate loop
if Sky_Bases(BaseIndex).Missions(I).MType = Explore or
Sky_Bases(BaseIndex).Missions(I).MType = Patrol or
Sky_Bases(BaseIndex).Missions(I).MType = Destroy then
MissionIndex := Mission_Container.To_Index(I);
exit;
end if;
end loop;
if MissionIndex > Natural(Sky_Bases(BaseIndex).Missions.Length) then
Sky_Bases(BaseIndex).Missions_Date := (others => 0);
GenerateMissions;
MissionIndex := Positive(Sky_Bases(BaseIndex).Missions.Length + 1);
end if;
end loop;
AcceptMission(MissionIndex);
Assert(AcceptedMissions.Length = 1, "Accepting mission failed.");
-- begin read only
end Test_AcceptMission_test_acceptmission;
-- end read only
-- begin read only
procedure Wrap_Test_UpdateMissions_b5358e_60a195(Minutes: Positive) is
begin
GNATtest_Generated.GNATtest_Standard.Missions.UpdateMissions(Minutes);
end Wrap_Test_UpdateMissions_b5358e_60a195;
-- end read only
-- begin read only
procedure Test_UpdateMissions_test_updatemissions(Gnattest_T: in out Test);
procedure Test_UpdateMissions_b5358e_60a195(Gnattest_T: in out Test) renames
Test_UpdateMissions_test_updatemissions;
-- id:2.2/b5358ee94cb1cec0/UpdateMissions/1/0/test_updatemissions/
procedure Test_UpdateMissions_test_updatemissions
(Gnattest_T: in out Test) is
procedure UpdateMissions(Minutes: Positive) renames
Wrap_Test_UpdateMissions_b5358e_60a195;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
AcceptedMissions.Clear;
AcceptedMissions.Append
((MType => Explore, Time => 10, TargetX => 1, TargetY => 1,
Reward => 1, StartBase => 1, Finished => True, Multiplier => 0.0,
Target => 0));
UpdateMissions(8);
Assert(AcceptedMissions(1).Time = 2, "Missions wrongly updated.");
UpdateMissions(2);
Assert(AcceptedMissions.Length = 0, "Missions not removed after update");
-- begin read only
end Test_UpdateMissions_test_updatemissions;
-- end read only
-- begin read only
procedure Wrap_Test_FinishMission_c82383_b2ab56(MissionIndex: Positive) is
begin
begin
pragma Assert(MissionIndex <= AcceptedMissions.Last_Index);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(missions.ads:0):Test_FinishMission test requirement violated");
end;
GNATtest_Generated.GNATtest_Standard.Missions.FinishMission
(MissionIndex);
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(missions.ads:0:):Test_FinishMission test commitment violated");
end;
end Wrap_Test_FinishMission_c82383_b2ab56;
-- end read only
-- begin read only
procedure Test_FinishMission_test_finishmission(Gnattest_T: in out Test);
procedure Test_FinishMission_c82383_b2ab56(Gnattest_T: in out Test) renames
Test_FinishMission_test_finishmission;
-- id:2.2/c823837fea6a8759/FinishMission/1/0/test_finishmission/
procedure Test_FinishMission_test_finishmission(Gnattest_T: in out Test) is
procedure FinishMission(MissionIndex: Positive) renames
Wrap_Test_FinishMission_c82383_b2ab56;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
AcceptedMissions.Clear;
AcceptedMissions.Append
((MType => Explore, Time => 10, TargetX => 1, TargetY => 1,
Reward => 1, StartBase => 1, Finished => True, Multiplier => 0.0,
Target => 0));
FinishMission(1);
Assert
(AcceptedMissions.Length = 0,
"Explore mission not finished correctly.");
Player_Ship.Crew.Append
((Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount,
Name => To_Unbounded_String("OTKAM-740"),
Faction => To_Unbounded_String("DRONES"), ContractLength => 100,
others => <>));
AcceptedMissions.Append
((MType => Passenger, Time => 100, TargetX => 1, TargetY => 1,
Reward => 1, StartBase => 1, Finished => False, Multiplier => 0.0,
Data => 5));
FinishMission(1);
Assert
(AcceptedMissions.Length = 0,
"Passenger drone mission not finished correctly.");
-- begin read only
end Test_FinishMission_test_finishmission;
-- end read only
-- begin read only
procedure Wrap_Test_DeleteMission_4bf0c5_8b646f
(MissionIndex: Positive; Failed: Boolean := True) is
begin
begin
pragma Assert(MissionIndex <= AcceptedMissions.Last_Index);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(missions.ads:0):Test_DeleteMission test requirement violated");
end;
GNATtest_Generated.GNATtest_Standard.Missions.DeleteMission
(MissionIndex, Failed);
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(missions.ads:0:):Test_DeleteMission test commitment violated");
end;
end Wrap_Test_DeleteMission_4bf0c5_8b646f;
-- end read only
-- begin read only
procedure Test_DeleteMission_test_deletemission(Gnattest_T: in out Test);
procedure Test_DeleteMission_4bf0c5_8b646f(Gnattest_T: in out Test) renames
Test_DeleteMission_test_deletemission;
-- id:2.2/4bf0c536f42cefa3/DeleteMission/1/0/test_deletemission/
procedure Test_DeleteMission_test_deletemission(Gnattest_T: in out Test) is
procedure DeleteMission
(MissionIndex: Positive; Failed: Boolean := True) renames
Wrap_Test_DeleteMission_4bf0c5_8b646f;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
AcceptedMissions.Clear;
AcceptedMissions.Append
((MType => Explore, Time => 1, TargetX => 1, TargetY => 1, Reward => 1,
StartBase => 1, Finished => True, Multiplier => 0.0, Target => 0));
DeleteMission(1, False);
Assert
(AcceptedMissions.Length = 0,
"Failed delete mission with 0 money reward.");
-- begin read only
end Test_DeleteMission_test_deletemission;
-- end read only
-- begin read only
procedure Wrap_Test_UpdateMission_06efd0_8b6bc6(MissionIndex: Positive) is
begin
begin
pragma Assert(MissionIndex <= AcceptedMissions.Last_Index);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(missions.ads:0):Test_UpdateMission test requirement violated");
end;
GNATtest_Generated.GNATtest_Standard.Missions.UpdateMission
(MissionIndex);
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(missions.ads:0:):Test_UpdateMission test commitment violated");
end;
end Wrap_Test_UpdateMission_06efd0_8b6bc6;
-- end read only
-- begin read only
procedure Test_UpdateMission_test_updatemission(Gnattest_T: in out Test);
procedure Test_UpdateMission_06efd0_8b6bc6(Gnattest_T: in out Test) renames
Test_UpdateMission_test_updatemission;
-- id:2.2/06efd0aaaa7e1e74/UpdateMission/1/0/test_updatemission/
procedure Test_UpdateMission_test_updatemission(Gnattest_T: in out Test) is
procedure UpdateMission(MissionIndex: Positive) renames
Wrap_Test_UpdateMission_06efd0_8b6bc6;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
AcceptedMissions.Clear;
AcceptedMissions.Append
((MType => Explore, Time => 1, TargetX => 1, TargetY => 1, Reward => 1,
StartBase => 1, Finished => True, Multiplier => 0.0, Target => 0));
UpdateMission(1);
Assert(AcceptedMissions(1).Finished, "Failed to update mission.");
-- begin read only
end Test_UpdateMission_test_updatemission;
-- end read only
-- begin read only
function Wrap_Test_AutoFinishMissions_ca7126_527254 return String is
begin
declare
Test_AutoFinishMissions_ca7126_527254_Result: constant String :=
GNATtest_Generated.GNATtest_Standard.Missions.AutoFinishMissions;
begin
return Test_AutoFinishMissions_ca7126_527254_Result;
end;
end Wrap_Test_AutoFinishMissions_ca7126_527254;
-- end read only
-- begin read only
procedure Test_AutoFinishMissions_test_autofinishmissions
(Gnattest_T: in out Test);
procedure Test_AutoFinishMissions_ca7126_527254
(Gnattest_T: in out Test) renames
Test_AutoFinishMissions_test_autofinishmissions;
-- id:2.2/ca7126890331fcb0/AutoFinishMissions/1/0/test_autofinishmissions/
procedure Test_AutoFinishMissions_test_autofinishmissions
(Gnattest_T: in out Test) is
function AutoFinishMissions return String renames
Wrap_Test_AutoFinishMissions_ca7126_527254;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
AcceptedMissions.Clear;
AcceptedMissions.Append
((MType => Explore, Time => 1, TargetX => 1, TargetY => 1, Reward => 1,
StartBase => 1, Finished => True, Multiplier => 0.0, Target => 0));
Assert(AutoFinishMissions'Length = 0, "Can't autoupdate missions.");
-- begin read only
end Test_AutoFinishMissions_test_autofinishmissions;
-- end read only
-- begin read only
function Wrap_Test_Get_Mission_Type_0b70ab_fb18a6
(MType: Missions_Types) return String is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(missions.ads:0):Test_Get_Mission_Type test requirement violated");
end;
declare
Test_Get_Mission_Type_0b70ab_fb18a6_Result: constant String :=
GNATtest_Generated.GNATtest_Standard.Missions.Get_Mission_Type
(MType);
begin
begin
pragma Assert
(Test_Get_Mission_Type_0b70ab_fb18a6_Result'Length > 0);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(missions.ads:0:):Test_Get_Mission_Type test commitment violated");
end;
return Test_Get_Mission_Type_0b70ab_fb18a6_Result;
end;
end Wrap_Test_Get_Mission_Type_0b70ab_fb18a6;
-- end read only
-- begin read only
procedure Test_Get_Mission_Type_test_get_mission_type
(Gnattest_T: in out Test);
procedure Test_Get_Mission_Type_0b70ab_fb18a6
(Gnattest_T: in out Test) renames
Test_Get_Mission_Type_test_get_mission_type;
-- id:2.2/0b70abad8e94f349/Get_Mission_Type/1/0/test_get_mission_type/
procedure Test_Get_Mission_Type_test_get_mission_type
(Gnattest_T: in out Test) is
function Get_Mission_Type(MType: Missions_Types) return String renames
Wrap_Test_Get_Mission_Type_0b70ab_fb18a6;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Assert
(Get_Mission_Type(Patrol) = "Patrol area",
"Failed to get the name of the selected mission type.");
-- begin read only
end Test_Get_Mission_Type_test_get_mission_type;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Missions.Test_Data.Tests;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T A S K _ A T T R I B U T E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2014-2019, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Task_Identification;
generic
type Attribute is private;
Initial_Value : Attribute;
package Ada.Task_Attributes is
-- Note that this package will use an efficient implementation with no
-- locks and no extra dynamic memory allocation if Attribute is the size
-- of either Integer or System.Address, and Initial_Value is 0 (null for
-- an access type).
-- Other types and initial values are supported, but will require
-- the use of locking and a level of indirection (meaning extra dynamic
-- memory allocation).
-- The maximum number of task attributes supported by this implementation
-- is determined by the constant System.Parameters.Max_Attribute_Count.
-- If you exceed this number, Storage_Error will be raised during the
-- elaboration of the instantiation of this package.
type Attribute_Handle is access all Attribute;
function Value
(T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task) return Attribute;
-- Return the value of the corresponding attribute of T. Tasking_Error
-- is raised if T is terminated and Program_Error will be raised if T
-- is Null_Task_Id.
function Reference
(T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task) return Attribute_Handle;
-- Return an access value that designates the corresponding attribute of
-- T. Tasking_Error is raised if T is terminated and Program_Error will be
-- raised if T is Null_Task_Id.
procedure Set_Value
(Val : Attribute;
T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task);
-- Finalize the old value of the attribute of T and assign Val to that
-- attribute. Tasking_Error is raised if T is terminated and Program_Error
-- will be raised if T is Null_Task_Id.
procedure Reinitialize
(T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task);
-- Same as Set_Value (Initial_Value, T). Tasking_Error is raised if T is
-- terminated and Program_Error will be raised if T is Null_Task_Id.
private
pragma Inline (Value);
pragma Inline (Reference);
pragma Inline (Set_Value);
pragma Inline (Reinitialize);
end Ada.Task_Attributes;
|
with Datos;
use Datos;
procedure crear_lista_vacia( L : in out Lista) is
-- pre:
-- post: se ha creado una lista vacia
begin
L := null;
end crear_lista_vacia;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Greet_5c is
I : Integer := 1;
begin
-- Condition must be a Boolean value (no Integers)
-- Operator "<=" returns a Boolean
while I <= 5 loop
Put_Line ("Hello, World!" & Integer'Image(I));
I := I + 1;
end loop;
end Greet_5c; |
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
procedure Bulls_And_Cows is
package Random_Natural is new Ada.Numerics.Discrete_Random (Natural);
Number : String (1..4);
begin
declare -- Generation of number
use Random_Natural;
Digit : String := "123456789";
Size : Positive := 9;
Dice : Generator;
Position : Natural;
begin
Reset (Dice);
for I in Number'Range loop
Position := Random (Dice) mod Size + 1;
Number (I) := Digit (Position);
Digit (Position..Size - 1) := Digit (Position + 1..Size);
Size := Size - 1;
end loop;
end;
loop -- Guessing loop
Put ("Enter four digits:");
declare
Guess : String := Get_Line;
Bulls : Natural := 0;
Cows : Natural := 0;
begin
if Guess'Length /= 4 then
raise Data_Error;
end if;
for I in Guess'Range loop
for J in Number'Range loop
if Guess (I) not in '1'..'9' or else (I < J and then Guess (I) = Guess (J)) then
raise Data_Error;
end if;
if Number (I) = Guess (J) then
if I = J then
Bulls := Bulls + 1;
else
Cows := Cows + 1;
end if;
end if;
end loop;
end loop;
exit when Bulls = 4;
Put_Line (Integer'Image (Bulls) & " bulls," & Integer'Image (Cows) & " cows");
exception
when Data_Error => Put_Line ("You should enter four different digits 1..9");
end;
end loop;
end Bulls_And_Cows;
|
------------------------------------------------------------------------------
-- --
-- Unicode Utilities --
-- UTF-8 Stream Decoder --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019, 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.Characters.Conversions;
with Unicode.UTF8_Stream_Decoder.Codec;
package body Unicode.UTF8_Stream_Decoder is
--
-- Stream Decoders
--
-----------------
-- Decode_Next -- (Wide_Wide_Character)
-----------------
function Decode_Next (UTF8_Stream : not null access Root_Stream_Type'Class)
return Wide_Wide_Character
is
use Codec;
Buffer: Sequence_Array (1 .. 4) := (others => 0);
Last, Continuation: Stream_Element_Offset;
Status: Decode_Status;
begin
return Result: Wide_Wide_Character do
-- Load next octet (hoping for a valid starting octet)
Stream_Element'Read (UTF8_Stream, Buffer(1));
-- Phase 1, check for sync and then mult-byte sequence
Try_Decode (Sequence => Buffer(1 .. 1),
Last => Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
-- See if we have an indicated multi-byte condition
if Status = Short_Load then
-- Load the expected number of octets and re-run
declare
-- The (verified) postcondition of Try_Decode promises that
-- Continuation will be 1 .. 3. Therefore we know that the
-- above range will never be larger than 2 .. 3 + 1 = 4
pragma Suppress (Index_Check);
pragma Suppress (Length_Check);
pragma Suppress (Overflow_Check);
pragma Suppress (Range_Check);
-- 2 .. 2, 2 .. 3, 2 .. 4 - all ok
-- Also note that the components of Sequence_Array is
-- a modular type - and therefore Overflow_Check and
-- Range_Check do not apply to those (the return values)
-- anyways.
begin
Sequence_Array'Read
(UTF8_Stream, Buffer(2 .. Continuation + 1));
end;
-- Run Try_Decode again for the final Result
Try_Decode (Sequence => Buffer(1 .. Continuation + 1),
Last => Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
end if;
-- Note that the postcondition of Try_Decode promises that if Status
-- is not "Success", then Result will always be
-- Unicode_Replacement_Character
end return;
end Decode_Next;
-----------------
-- Decode_Next -- (Wide_Character)
-----------------
function Decode_Next (UTF8_Stream : not null access Root_Stream_Type'Class)
return Wide_Character
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character
:= Decode_Next (UTF8_Stream);
begin
if not Is_Wide_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Wide_Character";
else
return To_Wide_Character (Full_Char);
end if;
end Decode_Next;
-----------------
-- Decode_Next -- (Character)
-----------------
function Decode_Next (UTF8_Stream : not null access Root_Stream_Type'Class)
return Character
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character
:= Decode_Next (UTF8_Stream);
begin
if not Is_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Character";
else
return To_Character (Full_Char);
end if;
end Decode_Next;
-- Buffer Decoders ---------------------------------------------------------
-----------------
-- Decode_Next -- (Wide_Wide_Character)
-----------------
procedure Decode_Next (Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Result : out Wide_Wide_Character)
is
use Codec;
Start : Stream_Element_Offset := Buffer'First;
Continuation: Stream_Element_Offset;
Status : Decode_Status;
Sequence_Last: Sequence_Index;
begin
if Buffer'Length = 0 then
raise Short_Buffer with "Buffer is empty.";
end if;
Last := Buffer'First;
-- Phase 1, check for sync and then mult-byte sequence
Try_Decode
(Sequence => Sequence_Array'(1 => Buffer(Buffer'First)),
Last => Sequence_Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
-- See if we have an indicated multi-byte condition
if Status = Short_Load then
-- Check that we can actually provide the required number of
-- continuation bytes.
if Buffer'First + Continuation > Buffer'Last then
raise Short_Buffer;
end if;
-- Re-run with the Load the expected number of octets
declare
-- The (verified) postcondition of Try_Decode promises that
-- Continuation will be 1 .. 3. Therefore we know that the
-- above range will never be larger than 2 .. 3 + 1 = 4
pragma Suppress (Index_Check);
pragma Suppress (Length_Check);
pragma Suppress (Overflow_Check);
pragma Suppress (Range_Check);
-- 2 .. 2, 2 .. 3, 2 .. 4 - all ok
-- Also note that the components of Sequence_Array is
-- a modular type - and therefore Overflow_Check and
-- Range_Check do not apply to those (the return values)
-- anyways.
Sequence: constant Sequence_Array(1 .. 1 + Continuation)
:= Sequence_Array
(Buffer(Buffer'First .. Buffer'First + Continuation));
-- 1 + Continuation must be: 2, 3, 4
-- Buffer'First + Continuation must be <= Buffer'Last, due
-- to the if statement above
begin
-- Run Try_Decode again for the final Result
Try_Decode (Sequence => Sequence,
Last => Sequence_Last,
Continuation_Bytes => Continuation,
Result => Result,
Status => Status);
end;
end if;
Last := Buffer'First + Continuation;
if Status /= Success then
Result := Unicode_Replacement_Character;
end if;
end Decode_Next;
-----------------
-- Decode_Next -- (Wide_Character)
-----------------
procedure Decode_Next (Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Result : out Wide_Character)
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character;
Temp_Last: Stream_Element_Offset;
begin
Decode_Next (Buffer => Buffer,
Last => Temp_Last,
Result => Full_Char);
if not Is_Wide_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Wide_Character";
else
Result := To_Wide_Character (Full_Char);
Last := Temp_Last;
end if;
end Decode_Next;
-----------------
-- Decode_Next -- (Character)
-----------------
procedure Decode_Next (Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Result : out Character)
is
use Ada.Characters.Conversions;
Full_Char: Wide_Wide_Character;
Temp_Last: Stream_Element_Offset;
begin
Decode_Next (Buffer => Buffer,
Last => Temp_Last,
Result => Full_Char);
if not Is_Character (Full_Char) then
raise Insufficient_Width
with "Encoded character is not within the range of Character";
else
Result := To_Character (Full_Char);
Last := Temp_Last;
end if;
end Decode_Next;
end Unicode.UTF8_Stream_Decoder;
|
with Display.Basic.Utils; use Display.Basic.Utils;
with SDL_SDL_stdinc_h; use SDL_SDL_stdinc_h;
with SDL_SDL_video_h; use SDL_SDL_video_h;
package Display.Basic.Fonts is
type BMP_Font is (Font8x8, Font12x12, Font16x24);
procedure Draw_Char
(S : access SDL_Surface;
P : Screen_Point;
Char : Character;
Font : BMP_Font;
FG, BG : Uint32);
procedure Draw_Char
(Canvas : T_Internal_Canvas;
P : Screen_Point;
Char : Character;
Font : BMP_Font;
FG, BG : Uint32);
procedure Draw_String
(S : access SDL_Surface;
P : Screen_Point;
Str : String;
Font : BMP_Font;
FG, BG : RGBA_T;
Wrap : Boolean := False);
procedure Draw_String
(Canvas : T_Internal_Canvas;
P : Screen_Point;
Str : String;
Font : BMP_Font;
FG, BG : RGBA_T;
Wrap : Boolean := False);
function Char_Size (Font : BMP_Font) return Screen_Point;
function String_Size (Font : BMP_Font; Text : String) return Screen_Point;
end Display.Basic.Fonts;
|
with Ada.Text_IO;
with Ada.Integer_Text_IO;
package body Problem_30 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
subtype digit is Integer range 0 .. 9;
fifth_power : constant Array (0 .. 9) of Integer := (0**5, 1**5, 2**5, 3**5,
4**5, 5**5, 6**5, 7**5,
8**5, 9**5);
total_Sum : Integer := 0;
procedure Solve is
begin
for hundred_thousand_digit in 0 .. 2 loop
declare
hundred_thousand_num : constant Integer := hundred_thousand_digit * 100_000;
hundred_thousand_sum : constant Integer := fifth_power(hundred_thousand_digit);
begin
for ten_thousand_digit in digit'Range loop
declare
ten_thousand_num : constant Integer := hundred_thousand_num + ten_thousand_digit * 10_000;
ten_thousand_sum : constant Integer := hundred_thousand_sum + fifth_power(ten_thousand_digit);
begin
for thousand_digit in digit'Range loop
declare
thousand_num : constant Integer := ten_thousand_num + thousand_digit * 1_000;
thousand_sum : constant Integer := ten_thousand_sum + fifth_power(thousand_digit);
begin
for hundred_digit in digit'Range loop
declare
hundred_num : constant Integer := thousand_num + hundred_digit * 100;
hundred_sum : constant Integer := thousand_sum + fifth_power(hundred_digit);
begin
for ten_digit in digit'Range loop
declare
ten_num : constant Integer := hundred_num + ten_digit * 10;
ten_sum : constant Integer := hundred_sum + fifth_power(ten_digit);
begin
for unit_digit in digit'range loop
declare
unit_num : constant Integer := ten_num + unit_digit;
unit_sum : constant Integer := ten_sum + fifth_power(unit_digit);
begin
if unit_num = unit_sum and unit_num /= 1 then
total_sum := total_sum + unit_num;
end if;
end;
end loop;
end;
end loop;
end;
end loop;
end;
end loop;
end;
end loop;
end;
end loop;
I_IO.Put(total_sum);
IO.New_Line;
end Solve;
end Problem_30;
|
------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Atom_Buffers;
package body Natools.Web.Filters is
---------------------
-- Stack Interface --
---------------------
overriding procedure Apply
(Object : in Stack;
Output : in out Ada.Streams.Root_Stream_Type'Class;
Data : in Ada.Streams.Stream_Element_Array) is
begin
case Object.Backend.Length is
when 0 =>
Output.Write (Data);
when 1 =>
Apply (Object.Backend.First_Element, Output, Data);
when others =>
declare
Buffer : S_Expressions.Atom_Buffers.Atom_Buffer;
begin
Buffer.Append (Data);
for F of Object.Backend loop
declare
Previous : constant S_Expressions.Atom := Buffer.Data;
begin
Buffer.Soft_Reset;
Apply (F, Buffer, Previous);
end;
end loop;
Output.Write (Buffer.Data);
end;
end case;
end Apply;
not overriding procedure Insert
(Container : in out Stack;
Element : in Filter'Class;
On : in Side := Top) is
begin
case On is
when Top =>
Container.Backend.Prepend (Element);
when Bottom =>
Container.Backend.Append (Element);
end case;
end Insert;
not overriding procedure Remove
(Container : in out Stack;
Element : in Filter'Class;
From : in Side := Top) is
begin
pragma Assert (not Container.Backend.Is_Empty);
case From is
when Top =>
declare
Removed : constant Filter'Class
:= Container.Backend.First_Element;
begin
Container.Backend.Delete_First;
if Removed /= Element then
raise Program_Error
with "Filters.Remove called with wrong Element";
end if;
end;
when Bottom =>
declare
Removed : constant Filter'Class
:= Container.Backend.Last_Element;
begin
Container.Backend.Delete_Last;
if Removed /= Element then
raise Program_Error
with "Filters.Remove called with wrong Element";
end if;
end;
end case;
end Remove;
end Natools.Web.Filters;
|
-----------------------------------------------------------------------
-- security-filters -- Security filter
-- Copyright (C) 2011, 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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 Util.Log.Loggers;
with ASF.Cookies;
with ASF.Applications.Main;
with Security.Contexts;
with Security.Policies.URLs;
package body ASF.Security.Filters is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.Filters");
-- ------------------------------
-- Called by the servlet container to indicate to a servlet that the servlet
-- is being placed into service.
-- ------------------------------
procedure Initialize (Server : in out Auth_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
use ASF.Applications.Main;
begin
if Context in Application'Class then
Server.Set_Permission_Manager (Application'Class (Context).Get_Security_Manager);
end if;
end Initialize;
-- ------------------------------
-- Set the permission manager that must be used to verify the permission.
-- ------------------------------
procedure Set_Permission_Manager (Filter : in out Auth_Filter;
Manager : in Policies.Policy_Manager_Access) is
begin
Filter.Manager := Manager;
end Set_Permission_Manager;
-- ------------------------------
-- Filter the request to make sure the user is authenticated.
-- Invokes the <b>Do_Login</b> procedure if there is no user.
-- If a permission manager is defined, check that the user has the permission
-- to view the page. Invokes the <b>Do_Deny</b> procedure if the permission
-- is denied.
-- ------------------------------
procedure Do_Filter (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Chain : in out ASF.Servlets.Filter_Chain) is
use Ada.Strings.Unbounded;
use Policies.URLs;
use type Policies.Policy_Manager_Access;
Session : ASF.Sessions.Session;
SID : Unbounded_String;
AID : Unbounded_String;
Auth : ASF.Principals.Principal_Access;
pragma Unreferenced (SID);
procedure Fetch_Cookie (Cookie : in ASF.Cookies.Cookie);
-- ------------------------------
-- Collect the AID and SID cookies.
-- ------------------------------
procedure Fetch_Cookie (Cookie : in ASF.Cookies.Cookie) is
Name : constant String := ASF.Cookies.Get_Name (Cookie);
begin
if Name = SID_COOKIE then
SID := To_Unbounded_String (ASF.Cookies.Get_Value (Cookie));
elsif Name = AID_COOKIE then
AID := To_Unbounded_String (ASF.Cookies.Get_Value (Cookie));
end if;
end Fetch_Cookie;
Context : aliased Contexts.Security_Context;
begin
Request.Iterate_Cookies (Fetch_Cookie'Access);
Session := Request.Get_Session (Create => True);
-- If the session does not have a principal, try to authenticate the user with
-- the auto-login cookie.
Auth := Session.Get_Principal;
if Auth = null and then Length (AID) > 0 then
Auth_Filter'Class (F).Authenticate (Request, Response, Session, To_String (AID), Auth);
if Auth /= null then
Session.Set_Principal (Auth);
end if;
end if;
-- A permission manager is installed, check that the user can display the page.
if F.Manager /= null then
if Auth = null then
Context.Set_Context (F.Manager, null);
else
Context.Set_Context (F.Manager, Auth.all'Access);
end if;
declare
Servlet : constant String := Request.Get_Servlet_Path;
URL : constant String := Servlet & Request.Get_Path_Info;
Perm : constant Policies.URLs.URL_Permission (URL'Length)
:= URL_Permission '(Len => URL'Length, URL => URL);
begin
if not F.Manager.Has_Permission (Context, Perm) then
if Auth = null then
-- No permission and no principal, redirect to the login page.
Log.Info ("Page need authentication on {0}", URL);
Auth_Filter'Class (F).Do_Login (Request, Response);
else
Log.Info ("Deny access on {0}", URL);
Auth_Filter'Class (F).Do_Deny (Request, Response);
end if;
return;
end if;
Log.Debug ("Access granted on {0}", URL);
end;
end if;
-- Request is authorized, proceed to the next filter.
ASF.Servlets.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
end Do_Filter;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
procedure Do_Login (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
pragma Unreferenced (F, Request);
begin
Response.Send_Error (ASF.Responses.SC_UNAUTHORIZED);
end Do_Login;
-- ------------------------------
-- Display the forbidden access page. This procedure is called when the user is not
-- authorized to see the page. The default implementation returns the SC_FORBIDDEN error.
-- ------------------------------
procedure Do_Deny (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
pragma Unreferenced (F, Request);
begin
Response.Set_Status (ASF.Responses.SC_FORBIDDEN);
end Do_Deny;
-- ------------------------------
-- Authenticate a user by using the auto-login cookie. This procedure is called if the
-- current session does not have any principal. Based on the request and the optional
-- auto-login cookie passed in <b>Auth_Id</b>, it should identify the user and return
-- a principal object. The principal object will be freed when the session is closed.
-- If the user cannot be authenticated, the returned principal should be null.
--
-- The default implementation returns a null principal.
-- ------------------------------
procedure Authenticate (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Session : in ASF.Sessions.Session;
Auth_Id : in String;
Principal : out ASF.Principals.Principal_Access) is
pragma Unreferenced (F, Request, Response, Session, Auth_Id);
begin
Principal := null;
end Authenticate;
end ASF.Security.Filters;
|
type T is limited private; -- inner structure is hidden
X, Y: T;
B: Boolean;
-- The following operations do not exist:
X := Y; -- illegal (cannot be compiled
B := X = Y; -- illegal
|
-- Parallel and Distributed Computing
-- Laboratory work #4. Ada Randeveuz
-- Task: MA = (B*C)*MZ + min(Z)*(MX*MC)
-- Koval Rostyslav IO-71
with Ada.Text_IO, Ada.Integer_text_iO, Ada.Synchronous_Task_Control, Data;
use Ada.Text_IO, Ada.Integer_text_iO, Ada.Synchronous_Task_Control;
procedure main is
Value : Integer := 1;
N : Natural := 12;
P : Natural := 6;
H : Natural := N/P;
package DataN is new Data(N, H);
use DataN;
procedure StartTasks is
task T1 is
entry DATA_C2H_MX(C2H: in Vector2H; MX: in MatrixN);
entry DATA_A6(a6: in Integer);
entry DATA_X6(x6: in Integer);
entry DATA_ZH(ZH: in VectorH);
entry DATA_MZH(MZH: in MatrixH);
entry DATA_A(a: in Integer);
entry DATA_X(x: in Integer);
entry RESULT_T1(MA11 : out MatrixH; MA61 : out MatrixH);
end T1;
task T2 is
entry DATA_MC3H_B3H(MC3H: in Matrix3H; B3H: in Vector3H);
entry DATA_CH_MX(CH: in VectorH; MX: in MatrixN);
entry DATA_A1(a1: in Integer);
entry DATA_X1(x1: in Integer);
entry DATA_A5(a5: in Integer);
entry DATA_X5(x5: in Integer);
entry DATA_A3(a3: in Integer);
entry DATA_X3(x3: in Integer);
entry DATA_Z3H(Z3H: in Vector3H);
entry DATA_MZ2H(MZH: in Matrix2H);
entry RESULT_T2(MA12 : out MatrixH;MA62 : out MatrixH;MA22 : out MatrixH;MA52 : out MatrixH);
end T2;
task T3 is
entry DATA_MC2H_B2H(MC2H: in Matrix2H; B2H: in Vector2H);
entry DATA_CH_MX(CH: in VectorH; MX: in MatrixN);
entry DATA_A4(a4: in Integer);
entry DATA_X4(x4: in Integer);
entry DATA_ZH(ZH: in VectorH);
entry DATA_A(a: in Integer);
entry DATA_X(x: in Integer);
end T3;
task T4 is
entry DATA_MCH_BH(MCH: in MatrixH; BH: in VectorH);
entry DATA_MZ3H(MZ: in Matrix3H);
entry DATA_C2H_MX(C2H: in Vector2H; MX: in MatrixN);
entry DATA_ZH(ZH: in VectorH);
entry DATA_A(a: in Integer);
entry DATA_X(x: in Integer);
entry RESULT_T4(MA : out MatrixH);
end T4;
task T5 is
entry DATA_MCH_BH(MCH: in MatrixH; BH: in VectorH);
entry DATA_MZ2H(MZ2H: in Matrix2H);
entry DATA_C3H_MX(C3H: in Vector3H; MX: in MatrixN);
entry DATA_A(a: in Integer);
entry DATA_X(x: in Integer);
entry RESULT_T5(MA : out MatrixH);
end T5;
task T6 is
entry DATA_MC2H_B2H(MC2H: in Matrix2H; B2H: in Vector2H);
entry DATA_MZH(MZ: in MatrixH);
entry DATA_ZH(ZH: in VectorH);
entry DATA_A(a: in Integer);
entry DATA_X(x: in Integer);
entry RESULT_T6(MA : out MatrixH);
end T6;
task body T1 is
MA6: MatrixH;
MA1: MatrixH;
MQ1: MatrixH;
MB1: MatrixH;
B1: VectorN;
C1: Vector2H;
MZ1: MatrixH;
Z1: VectorH;
MX1: MatrixN;
MC1: MatrixN;
x_1 : Integer := 0;
x6_1: Integer := 0;
a6_1: Integer := 0;
minZ1 : Integer := 99999;
MT1: MatrixH;
MT2: MatrixH;
begin
Put_Line("T1 started");
Input(MC1,1);
Input(B1,1);
accept DATA_C2H_MX (C2H: in Vector2H; MX: in MatrixN) do
C1 := C2H;
MX1 := MX;
end DATA_C2H_MX;
T6.DATA_MC2H_B2H(MC1(4*H+1..N), B1(4*H+1..N));
T2.DATA_MC3H_B3H(MC1(H+1..4*H), B1(H+1..4*H));
accept DATA_MZH (MZH : in MatrixH) do
MZ1:=MZH;
end DATA_MZH;
accept DATA_ZH (ZH : in VectorH) do
Z1 := ZH;
end DATA_ZH;
T2.DATA_CH_MX(C1(H+1..2*H), MX1);
for I in 1..H loop
if Z1(I) < minZ1 then
minZ1 := Z1(I);
end if;
end loop;
accept DATA_A6 (A6: in Integer) do
a6_1 := A6;
end DATA_A6;
minZ1 := Min(a6_1, minZ1);
T2.DATA_A1(minZ1);
accept DATA_A (A : in Integer) do
minZ1:=A;
end DATA_A;
T6.DATA_A(minZ1);
for I in 1..H loop
x_1 := x_1 + B1(I)*C1(I);
end loop;
accept DATA_X6 (X6: in Integer) do
x6_1 := X6;
end DATA_X6;
x_1 := x_1 + x6_1;
T2.DATA_X1(x_1);
accept DATA_X (X: in Integer) do
x_1 := X;
end DATA_X;
T6.DATA_X(x_1);
for i in 1..H loop
for j in 1..N loop
MT1(i)(j):= MZ1(i)(j);
MT2(i)(j):= MC1(i)(j);
end loop;
end loop;
MA1:=Calculation(x_1,minZ1,MT1,MX1,MT2);
T6.RESULT_T6(MA6);
accept RESULT_T1 (MA11 : out MatrixH; MA61 : out MatrixH) do
MA11:=MA1;
MA61:=MA6;
end RESULT_T1;
Put_Line("T1 finished");
end T1;
task body T2 is
MT2: MatrixH;
MT22: MatrixH;
MA1: MatrixH;
MA5: MatrixH;
MA6: MatrixH;
MA2: MatrixH;
B2: Vector3H;
C2: VectorH;
MZ2: Matrix2H;
Z2: Vector3H;
MX2: MatrixN;
MC2: Matrix3H;
x_2 : Integer:=0;
x1_2: Integer;
a1_2: Integer;
x5_2: Integer;
a5_2: Integer;
x3_2: Integer;
a3_2: Integer;
minZ2 : Integer := 99999;
begin
Put_Line("T2 started");
accept DATA_Z3H (Z3H : in Vector3H) do
Z2 := Z3H;
end DATA_Z3H;
accept DATA_MZ2H (MZH : in Matrix2H) do
MZ2:=MZH;
end DATA_MZ2H;
accept DATA_MC3H_B3H (MC3H : in Matrix3H; B3H: in Vector3H) do
MC2 := MC3H;
B2 := B3H;
end DATA_MC3H_B3H;
T1.DATA_MZH(MZ2(1..H));
T1.DATA_ZH(Z2(1..H));
T3.DATA_ZH(Z2(2*H+1..3*H));
T3.DATA_MC2H_B2H(MC2(H+1..3*H), B2(H+1..3*H));
accept DATA_CH_MX (CH: in VectorH; MX: in MatrixN) do
C2 := CH;
MX2 := MX;
end DATA_CH_MX;
for I in 1..H loop
if Z2(I) < minZ2 then
minZ2 := Z2(I);
end if;
end loop;
accept DATA_A1 (A1: in Integer) do
a1_2 := A1;
end DATA_A1;
minZ2 := Min(a1_2, minZ2);
accept DATA_A3 (A3: in Integer) do
a3_2 := A3;
end DATA_A3;
minZ2 := Min(a3_2, minZ2);
accept DATA_A5 (A5: in Integer) do
a5_2 := A5;
end DATA_A5;
minZ2 := Min(a5_2, minZ2);
T1.DATA_A(minZ2);
T3.DATA_A(minZ2);
T5.DATA_A(minZ2);
for I in 1..H loop
x_2 := x_2 + B2(I)*C2(I);
end loop;
accept DATA_X1 (X1: in Integer) do
x1_2 := X1;
end DATA_X1;
x_2 := CalcSumX(x_2, x1_2);
accept DATA_X3 (X3: in Integer) do
x3_2 := X3;
end DATA_X3;
x_2 := CalcSumX(x_2, x3_2);
accept DATA_X5 (X5: in Integer) do
x5_2 := X5;
end DATA_X5;
x_2 := CalcSumX(x_2, x5_2);
T1.DATA_X(x_2);
T3.DATA_X(x_2);
T5.DATA_X(x_2);
for i in 1..H loop
for j in 1..N loop
MT2(i)(j):= MZ2(H+i)(j);
MT22(i)(j):= MC2(i)(j);
end loop;
end loop;
MA2:=Calculation(x_2,minZ2,MT2,MX2,MT22);
T1.RESULT_T1(MA1,MA6);
T5.RESULT_T5(MA5);
accept RESULT_T2 (MA12 : out MatrixH; MA62 : out MatrixH; MA22 : out MatrixH; MA52 : out MatrixH) do
MA12:=MA1;
MA62:=MA6;
MA22:=MA2;
MA52:=MA5;
end RESULT_T2;
Put_Line("T2 finished");
end T2;
task body T3 is
MT3: MatrixH;
MT32: MatrixH;
MA3: MatrixH;
MA1: MatrixH;
MA2: MatrixH;
MA4: MatrixH;
MA5: MatrixH;
MA6: MatrixH;
B3: Vector2H;
C3: VectorH;
MZ3: MatrixN;
Z3: VectorH;
MX3: MatrixN;
MC3: Matrix2H;
x_3 : Integer;
MA: MatrixN;
x4_3: Integer;
a4_3: Integer;
minZ3 : Integer := 99999;
begin
Put_Line("T3 started");
Input(MZ3,1);
T2.DATA_MZ2H(MZ3(1..2*H));
T4.DATA_MZ3H(MZ3(3*H+1..N));
accept DATA_ZH (ZH : in VectorH) do
Z3 := ZH;
end DATA_ZH;
accept DATA_MC2H_B2H (MC2H : in Matrix2H; B2H: in Vector2H) do
MC3 := MC2H;
B3 := B2H;
end DATA_MC2H_B2H;
T4.DATA_MCH_BH(MC3(H+1..2*H), B3(H+1..2*H));
accept DATA_CH_MX (CH: in VectorH; MX: in MatrixN) do
C3 := CH;
MX3 := MX;
end DATA_CH_MX;
for I in 1..H loop
if Z3(I) < minZ3 then
minZ3 := Z3(I);
end if;
end loop;
accept DATA_A4 (A4: in Integer) do
a4_3 := A4;
end DATA_A4;
minZ3 := Min(a4_3, minZ3);
T2.DATA_A3(minZ3);
accept DATA_A (A : in Integer) do
minZ3:=A;
end DATA_A;
T4.DATA_A(minZ3);
x_3 := CalcX(B3, C3);
accept DATA_X4 (X4: in Integer) do
x4_3 := X4;
end DATA_X4;
x_3 := x_3 + x4_3;
T2.DATA_X3(x_3);
accept DATA_X (X: in Integer) do
x_3 := X;
end DATA_X;
T4.DATA_X(x_3);
for i in 1..H loop
for j in 1..N loop
MT3(i)(j):= MZ3(2*H+i)(j);
MT32(i)(j):= MC3(i)(j);
end loop;
end loop;
MA3:=Calculation(x_3,minZ3,MT3,MX3,MT32);
T2.RESULT_T2(MA1,MA6,MA2,MA5);
T4.RESULT_T4(MA4);
for i in 1..H loop
for j in 1..N loop
MA(i)(j):=MA1(i)(j);
MA(H+i)(j):=MA2(i)(j);
MA(2*H+i)(j):=MA3(i)(j);
MA(3*H+i)(j):=MA4(i)(j);
MA(4*H+i)(j):=MA5(i)(j);
MA(5*H+i)(j):=MA6(i)(j);
end loop;
end loop;
Output(MA);
Put_Line("T3 finished");
end T3;
task body T4 is
MT4: MatrixH;
MT42: MatrixH;
MA4: MatrixH;
B4: VectorH;
C4: Vector2H;
MZ4: Matrix3H;
Z4: VectorH;
MX4: MatrixN;
MC4: MatrixH;
x_4 : Integer;
minZ4 : Integer := 99999;
begin
Put_Line("T4 started");
accept DATA_ZH (ZH : in VectorH) do
Z4 := ZH;
end DATA_ZH;
accept DATA_MZ3H (MZ : in Matrix3H) do
MZ4:=MZ;
end DATA_MZ3H;
accept DATA_MCH_BH (MCH : in MatrixH; BH: in VectorH) do
MC4 := MCH;
B4 := BH;
end DATA_MCH_BH;
T5.DATA_MZ2H(MZ4(H+1..3*H));
accept DATA_C2H_MX (C2H: in Vector2H; MX: in MatrixN) do
C4 := C2H;
MX4 := MX;
end DATA_C2H_MX;
T3.DATA_CH_MX(C4(1..H), MX4);
for I in 1..H loop
if Z4(I) < minZ4 then
minZ4 := Z4(I);
end if;
end loop;
T3.DATA_A4(minZ4);
accept DATA_A (A : in Integer) do
minZ4:=A;
end DATA_A;
x_4 := CalcX(B4, C4);
T3.DATA_X4(x_4);
accept DATA_X (X: in Integer) do
x_4 := X;
end DATA_X;
for i in 1..H loop
for j in 1..N loop
MT4(i)(j):= MZ4(i)(j);
MT42(i)(j):= MC4(i)(j);
end loop;
end loop;
MA4:=Calculation(x_4,minZ4,MT4,MX4,MT42);
accept RESULT_T4 (MA : out MatrixH) do
MA:= MA4;
end RESULT_T4;
Put_Line("T4 finished");
end T4;
task body T5 is
MT5: MatrixH;
MT52: MatrixH;
MA5: MatrixH;
B5: VectorH;
C5: Vector3H;
MZ5: Matrix2H;
Z5: VectorN;
MX5: MatrixN;
MC5: MatrixH;
x_5 : Integer := 0;
minZ5 : Integer := 99999;
begin
Put_Line("T5 started");
Input(Z5,1);
T2.DATA_Z3H(Z5(2*H+1..5*H));
T6.DATA_ZH(Z5(5*H+1..6*H));
T4.DATA_ZH(Z5(1..H));
accept DATA_C3H_MX (C3H: in Vector3H; MX: in MatrixN) do
C5 := C3H;
MX5 := MX;
end DATA_C3H_MX;
accept DATA_MCH_BH (MCH : in MatrixH; BH: in VectorH) do
MC5 := MCH;
B5 := BH;
end DATA_MCH_BH;
accept DATA_MZ2H (MZ2H : in Matrix2H) do
MZ5:=MZ2H;
end DATA_MZ2H;
T4.DATA_C2H_MX(C5(1..2*H), MX5);
T6.DATA_MZH(MZ5(H+1..2*H));
for I in 1..H loop
if Z5(I) < minZ5 then
minZ5 := Z5(I);
end if;
end loop;
T2.DATA_A5(minZ5);
accept DATA_A (A : in Integer) do
minZ5:=A;
end DATA_A;
x_5 := CalcX(B5, C5);
T2.DATA_X5(x_5);
accept DATA_X (X: in Integer) do
x_5 := X;
end DATA_X;
for i in 1..H loop
for j in 1..N loop
MT5(i)(j):= MZ5(i)(j);
MT52(i)(j):= MC5(i)(j);
end loop;
end loop;
MA5:=Calculation(x_5,minZ5,MT5,MX5,MT52);
accept RESULT_T5 (MA : out MatrixH) do
MA:= MA5;
end RESULT_T5;
Put_Line("T5 finished");
end T5;
task body T6 is
MT6: MatrixH;
MT62: MatrixH;
MA6: MatrixH;
B6: Vector2H;
C6: VectorN;
MZ6: MatrixH;
Z6: VectorH;
MX6: MatrixN;
MC6: Matrix2H;
x_6 : Integer;
minZ6 : Integer := 99999;
begin
Put_Line("T6 started");
Input(C6,1);
Input(MX6,1);
T1.DATA_C2H_MX(C6(1..2*H),MX6);
accept DATA_ZH (ZH: in VectorH) do
Z6 := ZH;
end DATA_ZH;
T5.DATA_C3H_MX(C6(2*H+1..5*H),MX6);
accept DATA_MC2H_B2H (MC2H : in Matrix2H; B2H: in Vector2H) do
MC6 := MC2H;
B6 := B2H;
end DATA_MC2H_B2H;
T5.DATA_MCH_BH(MC6(1..H),B6(1..H));
accept DATA_MZH (MZ : in MatrixH) do
MZ6:=MZ;
end DATA_MZH;
for I in 1..H loop
if Z6(I) < minZ6 then
minZ6 := Z6(I);
end if;
end loop;
T1.DATA_A6(minZ6);
accept DATA_A (A : in Integer) do
minZ6:=A;
end DATA_A;
x_6 := CalcX(B6, C6);
T1.DATA_X6(x_6);
accept DATA_X (X: in Integer) do
x_6 := X;
end DATA_X;
for i in 1..H loop
for j in 1..N loop
MT6(i)(j):= MZ6(i)(j);
MT62(i)(j):= MC6(H+i)(j);
end loop;
end loop;
MA6:=Calculation(x_6,minZ6,MT6,MX6,MT62);
accept RESULT_T6 (MA : out MatrixH) do
MA:= MA6;
end RESULT_T6;
Put_Line("T6 finished");
end T6;
begin
null;
end StartTasks;
begin
Put_Line ("Lab4 started");
StartTasks;
Put_Line ("Lab4 finished");
end main;
|
-----------------------------------------------------------------------
-- jason-projects-modules -- Module projects
-- Copyright (C) 2016, 2019 Stephane.Carrez
-- Written by Stephane.Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Applications;
with ADO;
with AWA.Modules;
with AWA.Tags.Beans;
with AWA.Wikis.Models;
with AWA.Wikis.Modules;
with Jason.Projects.Models;
with Security.Permissions;
private with ASF.Converters.Numbers;
package Jason.Projects.Modules is
-- The name under which the module is registered.
NAME : constant String := "projects";
package ACL_View_Projects is new Security.Permissions.Definition ("project-view");
package ACL_Create_Projects is new Security.Permissions.Definition ("project-create");
package ACL_Delete_Projects is new Security.Permissions.Definition ("project-delete");
package ACL_Update_Projects is new Security.Permissions.Definition ("project-update");
-- ------------------------------
-- Module projects
-- ------------------------------
type Project_Module is new AWA.Modules.Module with private;
type Project_Module_Access is access all Project_Module'Class;
-- Initialize the projects module.
overriding
procedure Initialize (Plugin : in out Project_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config);
-- Get the projects module.
function Get_Project_Module return Project_Module_Access;
-- Create
procedure Create (Model : in Project_Module;
Entity : in out Jason.Projects.Models.Project_Ref'Class);
-- Save
procedure Save (Model : in Project_Module;
Entity : in out Jason.Projects.Models.Project_Ref'Class);
-- Create the project wiki space.
procedure Create_Wiki (Model : in Project_Module;
Entity : in out Jason.Projects.Models.Project_Ref'Class;
Wiki : in out AWA.Wikis.Models.Wiki_Space_Ref'Class);
-- Load the project information.
procedure Load_Project (Model : in Project_Module;
Project : in out Jason.Projects.Models.Project_Ref'Class;
Wiki : in out AWA.Wikis.Models.Wiki_Space_Ref'Class;
Tags : in out AWA.Tags.Beans.Tag_List_Bean;
Id : in ADO.Identifier;
Wiki_Id : in ADO.Identifier);
private
type Project_Module is new AWA.Modules.Module with record
Wiki : AWA.Wikis.Modules.Wiki_Module_Access;
Percent_Converter : aliased ASF.Converters.Numbers.Number_Converter;
Hour_Converter : aliased ASF.Converters.Numbers.Number_Converter;
end record;
end Jason.Projects.Modules;
|
-- This spec has been automatically generated from STM32F7x9.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.PWR is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR1_PLS_Field is HAL.UInt3;
subtype CR1_VOS_Field is HAL.UInt2;
subtype CR1_UDEN_Field is HAL.UInt2;
-- power control register
type CR1_Register is record
-- Low-power deep sleep
LPDS : Boolean := False;
-- Power down deepsleep
PDDS : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Clear standby flag
CSBF : Boolean := False;
-- Power voltage detector enable
PVDE : Boolean := False;
-- PVD level selection
PLS : CR1_PLS_Field := 16#0#;
-- Disable backup domain write protection
DBP : Boolean := False;
-- Flash power down in Stop mode
FPDS : Boolean := False;
-- Low-power regulator in deepsleep under-drive mode
LPUDS : Boolean := False;
-- Main regulator in deepsleep under-drive mode
MRUDS : Boolean := False;
-- unspecified
Reserved_12_12 : HAL.Bit := 16#0#;
-- ADCDC1
ADCDC1 : Boolean := False;
-- Regulator voltage scaling output selection
VOS : CR1_VOS_Field := 16#3#;
-- Over-drive enable
ODEN : Boolean := False;
-- Over-drive switching enabled
ODSWEN : Boolean := False;
-- Under-drive enable in stop mode
UDEN : CR1_UDEN_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
LPDS at 0 range 0 .. 0;
PDDS at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
CSBF at 0 range 3 .. 3;
PVDE at 0 range 4 .. 4;
PLS at 0 range 5 .. 7;
DBP at 0 range 8 .. 8;
FPDS at 0 range 9 .. 9;
LPUDS at 0 range 10 .. 10;
MRUDS at 0 range 11 .. 11;
Reserved_12_12 at 0 range 12 .. 12;
ADCDC1 at 0 range 13 .. 13;
VOS at 0 range 14 .. 15;
ODEN at 0 range 16 .. 16;
ODSWEN at 0 range 17 .. 17;
UDEN at 0 range 18 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype CSR1_UDRDY_Field is HAL.UInt2;
-- power control/status register
type CSR1_Register is record
-- Read-only. Wakeup internal flag
WUIF : Boolean := False;
-- Read-only. Standby flag
SBF : Boolean := False;
-- Read-only. PVD output
PVDO : Boolean := False;
-- Read-only. Backup regulator ready
BRR : Boolean := False;
-- unspecified
Reserved_4_8 : HAL.UInt5 := 16#0#;
-- Backup regulator enable
BRE : Boolean := False;
-- unspecified
Reserved_10_13 : HAL.UInt4 := 16#0#;
-- Regulator voltage scaling output selection ready bit
VOSRDY : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Over-drive mode ready
ODRDY : Boolean := False;
-- Over-drive mode switching ready
ODSWRDY : Boolean := False;
-- Under-drive ready flag
UDRDY : CSR1_UDRDY_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR1_Register use record
WUIF at 0 range 0 .. 0;
SBF at 0 range 1 .. 1;
PVDO at 0 range 2 .. 2;
BRR at 0 range 3 .. 3;
Reserved_4_8 at 0 range 4 .. 8;
BRE at 0 range 9 .. 9;
Reserved_10_13 at 0 range 10 .. 13;
VOSRDY at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
ODRDY at 0 range 16 .. 16;
ODSWRDY at 0 range 17 .. 17;
UDRDY at 0 range 18 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- CR2_CWUPF array
type CR2_CWUPF_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CR2_CWUPF
type CR2_CWUPF_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CWUPF as a value
Val : HAL.UInt6;
when True =>
-- CWUPF as an array
Arr : CR2_CWUPF_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CR2_CWUPF_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- CR2_WUPP array
type CR2_WUPP_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CR2_WUPP
type CR2_WUPP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WUPP as a value
Val : HAL.UInt6;
when True =>
-- WUPP as an array
Arr : CR2_WUPP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CR2_WUPP_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- power control register
type CR2_Register is record
-- Read-only. Clear Wakeup Pin flag for PA0
CWUPF : CR2_CWUPF_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Wakeup pin polarity bit for PA0
WUPP : CR2_WUPP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
CWUPF at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
WUPP at 0 range 8 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- CSR2_WUPF array
type CSR2_WUPF_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CSR2_WUPF
type CSR2_WUPF_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WUPF as a value
Val : HAL.UInt6;
when True =>
-- WUPF as an array
Arr : CSR2_WUPF_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CSR2_WUPF_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- CSR2_EWUP array
type CSR2_EWUP_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CSR2_EWUP
type CSR2_EWUP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EWUP as a value
Val : HAL.UInt6;
when True =>
-- EWUP as an array
Arr : CSR2_EWUP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CSR2_EWUP_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- power control/status register
type CSR2_Register is record
-- Read-only. Wakeup Pin flag for PA0
WUPF : CSR2_WUPF_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Enable Wakeup pin for PA0
EWUP : CSR2_EWUP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR2_Register use record
WUPF at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
EWUP at 0 range 8 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Power control
type PWR_Peripheral is record
-- power control register
CR1 : aliased CR1_Register;
-- power control/status register
CSR1 : aliased CSR1_Register;
-- power control register
CR2 : aliased CR2_Register;
-- power control/status register
CSR2 : aliased CSR2_Register;
end record
with Volatile;
for PWR_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CSR1 at 16#4# range 0 .. 31;
CR2 at 16#8# range 0 .. 31;
CSR2 at 16#C# range 0 .. 31;
end record;
-- Power control
PWR_Periph : aliased PWR_Peripheral
with Import, Address => System'To_Address (16#40007000#);
end STM32_SVD.PWR;
|
with
Gtk.Container,
Gtk.Style_Provider,
Gtk.Style_Context,
Gtk.Css_Provider,
Glib.Error,
Glib,
Ada.Text_IO;
package body aIDE.Style
is
use Gtk.Style_Provider,
Gtk.Style_Context,
Gtk.Css_Provider,
Ada.Text_IO,
Gtk.Container;
Provider : Gtk_Css_Provider;
procedure define
is
Error : aliased Glib.Error.GError;
begin
Provider := Gtk_Css_Provider_New;
if not Provider.Load_From_Path ("./css_accordion.css", Error'Access)
then
Put_Line ("Failed to load css_accordion.css !");
Put_Line (Glib.Error.Get_Message (Error));
return;
end if;
end define;
procedure Apply_Css_recursive (Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class;
Provider : Gtk_Style_Provider)
is
package FA is new Forall_User_Data (Gtk_Style_Provider);
begin
Get_Style_Context (Widget).Add_Provider (Provider, Glib.Guint'Last);
if Widget.all in Gtk_Container_Record'Class
then
declare
Container : constant Gtk_Container := Gtk_Container (Widget);
begin
FA.Forall (Container, Apply_Css_recursive'Unrestricted_Access, Provider);
end;
end if;
end Apply_Css_recursive;
procedure apply_CSS (Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class)
is
begin
Apply_Css_recursive (Widget, +Provider);
end apply_CSS;
end aIDE.Style;
|
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro>
--
-- 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 DNSCatcher.DNS.Processor.Packet; use DNSCatcher.DNS.Processor.Packet;
-- @description
--
-- RData processor for SOA records
--
-- @summary
--
-- SOA records are Start of Authority records; they specify the authoritive
-- information for a given zone. They contain the primary nameserver for a
-- zone, a responsible contact, and caching information related to a zone,
-- and most importantly, the zone serial number.
--
-- An SOA record will exist for every given zone, and is a fundamental part of
-- the DNS record system.
--
package DNSCatcher.DNS.Processor.RData.SOA_Parser is
-- Parsed SOA Data
--
-- @value Primary_Nameserver
-- Contains the primary nameserver for the zone
--
-- @value Responsible_Contact
-- The contact information (usually an email) for the zone
--
-- @value Serial
-- The serial number of a given zone. Must be incremented every time a zone
-- is updated, and used with NOTIFY operations as well. Serial numbers are
-- *NOT* simple integer additions, but instead use serial number arithmetic
-- to handle cases such as wraparound.
--
-- @value Refresh
-- A caching nameserver should refresh the SOA for a given zone every X
-- seconds. If the SOA serial is unchanged, data can remained cached.
--
-- @value Retry
-- If the authoritive server(s) for a given zone are not responding, this
-- is the interval that should be used to retry operations. It must be less
-- than the Refresh value
--
-- @value Expire
-- This is the period of time a zone can be cached before it is deleted if
-- there is no response from the authoritive nameservers
--
-- @value Minimum
-- The minimum time/TTL for negative caching.
--
type Parsed_SOA_RData is new DNSCatcher.DNS.Processor.RData
.Parsed_RData with
record
Primary_Nameserver : Unbounded_String;
Responsible_Contact : Unbounded_String;
Serial : Unsigned_32;
Refresh : Unsigned_32;
Retry : Unsigned_32;
Expire : Unsigned_32;
Minimum : Unsigned_32;
end record;
type Parsed_SOA_RData_Access is access all Parsed_SOA_RData;
-- Converts a RR record to logicial representation
--
-- @value This
-- Class object
--
-- @value DNS_Header
-- DNS Packet Header
--
-- @value Parsed_RR
-- SOA parsed Resource Record from Processor.Packet
--
procedure From_Parsed_RR
(This : in out Parsed_SOA_RData;
DNS_Header : DNS_Packet_Header;
Parsed_RR : Parsed_DNS_Resource_Record);
-- Represents RData as a String for debug logging
--
-- @value This
-- Class object
--
-- @returns
-- String representing the status of EDNS information
--
function RData_To_String
(This : in Parsed_SOA_RData)
return String;
-- Represents the resource record packet as a whole as a string
--
-- @value This
-- Class object
--
-- @returns
-- String in the format of "SOA *soa info*
--
function Print_Packet
(This : in Parsed_SOA_RData)
return String;
-- Frees and deallocates the class object
--
-- @value This
-- Class object to deallocate
--
procedure Delete (This : in out Parsed_SOA_RData);
end DNSCatcher.DNS.Processor.RData.SOA_Parser;
|
-----------------------------------------------------------------------
-- util-encoders-quoted_printable -- Encode/Decode a stream in quoted-printable
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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.Characters.Handling;
with Interfaces;
package body Util.Encoders.Quoted_Printable is
use Ada.Characters.Handling;
use type Interfaces.Unsigned_8;
function From_Hex (C : in Character) return Interfaces.Unsigned_8 is
(if C >= '0' and C <= '9' then Character'Pos (C) - Character'Pos ('0')
elsif C >= 'A' and C <= 'F' then Character'Pos (C) - Character'Pos ('A') + 10
else 0);
function From_Hex (C1, C2 : in Character) return Character is
(Character'Val (From_Hex (C2) + Interfaces.Shift_Left (From_Hex (C1), 4)));
-- ------------------------------
-- Decode the Quoted-Printable string and return the result.
-- When Strict is true, raises the Encoding_Error exception if the
-- format is invalid. Otherwise, ignore invalid encoding.
-- ------------------------------
function Decode (Content : in String;
Strict : in Boolean := True) return String is
Result : String (1 .. Content'Length);
Read_Pos : Natural := Content'First;
Write_Pos : Natural := Result'First - 1;
C : Character;
C2 : Character;
begin
while Read_Pos <= Content'Last loop
C := Content (Read_Pos);
if C = '=' then
exit when Read_Pos = Content'Last;
if Read_Pos + 2 > Content'Last then
exit when not Strict;
raise Encoding_Error;
end if;
Read_Pos := Read_Pos + 1;
C := Content (Read_Pos);
if not Is_Hexadecimal_Digit (C) then
exit when not Strict;
raise Encoding_Error;
end if;
C2 := Content (Read_Pos + 1);
if not Is_Hexadecimal_Digit (C) then
exit when not Strict;
raise Encoding_Error;
end if;
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := From_Hex (C, C2);
Read_Pos := Read_Pos + 1;
else
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := C;
end if;
Read_Pos := Read_Pos + 1;
end loop;
return Result (1 .. Write_Pos);
end Decode;
-- ------------------------------
-- Decode the "Q" encoding, similar to Quoted-Printable but with
-- spaces that can be replaced by '_'.
-- See RFC 2047.
-- ------------------------------
function Q_Decode (Content : in String) return String is
Result : String (1 .. Content'Length);
Read_Pos : Natural := Content'First;
Write_Pos : Natural := Result'First - 1;
C : Character;
C2 : Character;
begin
while Read_Pos <= Content'Last loop
C := Content (Read_Pos);
if C = '=' then
exit when Read_Pos = Content'Last or else Read_Pos + 2 > Content'Last;
Read_Pos := Read_Pos + 1;
C := Content (Read_Pos);
exit when not Is_Hexadecimal_Digit (C);
C2 := Content (Read_Pos + 1);
exit when not Is_Hexadecimal_Digit (C);
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := From_Hex (C, C2);
Read_Pos := Read_Pos + 1;
elsif C = '_' then
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := ' ';
else
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := C;
end if;
Read_Pos := Read_Pos + 1;
end loop;
return Result (1 .. Write_Pos);
end Q_Decode;
end Util.Encoders.Quoted_Printable;
|
-----------------------------------------------------------------------
-- helios-reports-files -- Write reports in files
-- Copyright (C) 2017, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams.Stream_IO;
with Ada.Calendar;
with Ada.Directories;
with Util.Serialize.IO.JSON;
with Util.Streams.Texts;
with Util.Streams.Files;
with Util.Log.Loggers;
with Helios.Tools.Formats;
with Helios.Monitor;
package body Helios.Reports.Files is
use type Ada.Real_Time.Time_Span;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Helios.Reports.Files");
-- ------------------------------
-- The timer handler executed when the timer deadline has passed.
-- ------------------------------
overriding
procedure Time_Handler (Report : in out File_Report_Type;
Event : in out Util.Events.Timers.Timer_Ref'Class) is
Pattern : constant String := Ada.Strings.Unbounded.To_String (Report.Path);
Path : constant String := Helios.Tools.Formats.Format (Pattern, Ada.Calendar.Clock);
Dir : constant String := Ada.Directories.Containing_Directory (Path);
begin
if not Ada.Directories.Exists (Dir) then
Log.Info ("Creating directory {0}", Dir);
Ada.Directories.Create_Directory (Dir);
end if;
Save_Snapshot (Path, Helios.Monitor.Get_Report);
if Report.Period /= Ada.Real_Time.Time_Span_Zero then
Event.Repeat (Report.Period);
end if;
end Time_Handler;
-- ------------------------------
-- Write the collected snapshot in the file in JSON format.
-- ------------------------------
procedure Save_Snapshot (Path : in String;
Data : in Helios.Datas.Report_Queue_Type) is
procedure Write (Data : in Helios.Datas.Snapshot_Type;
Node : in Helios.Schemas.Definition_Type_Access);
File : aliased Util.Streams.Files.File_Stream;
Output : aliased Util.Streams.Texts.Print_Stream;
Stream : Util.Serialize.IO.JSON.Output_Stream;
procedure Write (Data : in Helios.Datas.Snapshot_Type;
Node : in Helios.Schemas.Definition_Type_Access) is
begin
Write_Snapshot (Stream, Data, Node);
end Write;
begin
Log.Info ("Saving snapshot to {0}", Path);
File.Create (Ada.Streams.Stream_IO.Out_File, Path);
Output.Initialize (File'Unchecked_Access);
Stream.Initialize (Output'Unchecked_Access);
Stream.Start_Document;
Helios.Datas.Iterate (Data, Write'Access);
Stream.End_Document;
Stream.Close;
end Save_Snapshot;
end Helios.Reports.Files;
|
package def_monitor is
protected type Monitor is
entry cadiraLock;
procedure cadiraUnlock;
entry menjarLock;
procedure menjarUnlock;
function ferMenjar return Boolean;
private
contCadires : Integer := 0;
potsMenjar : Boolean := False;
end Monitor;
end def_monitor;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . S K I P _ T B --
-- --
-- S p e c --
-- --
-- Copyright (c) 1995-2003, Free Software Foundation, Inc. --
-- --
-- ASIS-for-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 --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY 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 ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 59 Temple Place --
-- - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc --
-- (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
with Asis;
with Types; use Types;
package A4G.Skip_TB is
-- This package encapsulates routines which is used in finding the end of
-- an Element Span tp scip all the "syntax sugar", such as ";", ")",
-- "end if", "end Unit_Name" etc.
function Skip_Trailing_Brackets
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- This function encapsulates all the cases when different kinds of
-- "syntax sugar" should be skiped, being implemented as a look-up
-- table for Internal_Element_Kinds. It returns the location of the
-- very last character of the image of E, provided that S is set to
-- point to iys last component. If a given Element has several levels
-- of subcomponents, this function is called each time when the
-- next right-most component is traversed in the recursive processing
-- defined by A4G.Span_End.Nonterminal_Component.
function Needs_Extra_Parentheses (E : Asis.Element) return Boolean;
-- This function detects if we need an extra parenthesis in the qualified
-- expression in the situation like this
-- Var : String := String'((1 => C));
-- The problem is that from the point of view of ASIS Element hierarchy
-- it there is no difference between this situation and
-- Var : String := String'(1 => C);
-- because we do not have A_Parenthesized_Expression in the first case,
-- we just have to decompose the qualified expression according to the
-- syntax rule: subtype_mark'(expression), and the outer pair of
-- parenthesis belongs to a qualified expression, and the inner - to an
-- enclosed aggregate.
-- We need this function in the spec to use it in gnatpp.
end A4G.Skip_TB;
|
with Interfaces;
with kv.avm.Actor_References;
with kv.avm.Actor_References.Sets;
with kv.avm.Tuples;
with kv.avm.Registers;
with kv.avm.Memories;
with kv.avm.Executables;
with kv.avm.Processors;
with kv.avm.Control;
with kv.avm.Messages;
with kv.avm.Executable_Lists;
with kv.avm.Capabilities;
with kv.avm.Routers;
package kv.avm.Machines is
Machine_Error : exception;
type Machine_Type is new kv.avm.Control.Control_Interface with private;
type Machine_Access is access all Machine_Type;
procedure Initialize
(Self : in out Machine_Type;
Processor : in kv.avm.Processors.Processor_Access;
Factory : in kv.avm.Executables.Factory_Access);
function Get_Router(Self : Machine_Type) return kv.avm.Routers.Router_Type;
procedure Step
(Self : in out Machine_Type);
procedure Deliver_Messages
(Self : in out Machine_Type);
function Current_Instance(Self : Machine_Type) return kv.avm.Executables.Executable_Access;
function Done(Self : Machine_Type) return Boolean;
function Get_Steps(Self : Machine_Type) return Natural;
function Get_Total(Self : Machine_Type) return Natural;
function Get_Active(Self : Machine_Type) return Natural;
function Get_Idle(Self : Machine_Type) return Natural;
function Get_Blocked(Self : Machine_Type) return Natural;
function Get_Deferred(Self : Machine_Type) return Natural;
function Get_Queue_Size(Self : Machine_Type) return Natural;
procedure Set_Queue_Limit(Self : in out Machine_Type; Queue_Limit : in Natural);
function Get_Cycles(Self : Machine_Type) return Natural;
function Get_Reaped(Self : Machine_Type) return Natural;
procedure Set_Capabilities(Self : in out Machine_Type; Capabilities : in kv.avm.Capabilities.Capabilities_Type);
procedure Set_Garbage_Trigger(Self : in out Machine_Type; Garbage_Trigger : in Natural);
overriding
procedure New_Actor
(Self : in out Machine_Type;
Name : in String;
Instance : out kv.avm.Actor_References.Actor_Reference_Type);
overriding
procedure Post_Message
(Self : in out Machine_Type;
Message : in kv.avm.Messages.Message_Type;
Status : out kv.avm.Control.Status_Type);
overriding
procedure Post_Response
(Self : in out Machine_Type;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Answer : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32);
overriding
procedure Generate_Next_Future
(Self : in out Machine_Type;
Future : out Interfaces.Unsigned_32);
overriding
procedure Trap_To_The_Machine
(Self : in out Machine_Type;
Trap : in String;
Data : in kv.avm.Registers.Register_Type;
Answer : out kv.avm.Registers.Register_Type;
Status : out kv.avm.Control.Status_Type);
overriding
procedure Activate_Instance
(Self : in out Machine_Type;
Instance : in kv.avm.Actor_References.Actor_Reference_Type);
-- Create an instance of the Actor, sending it an empty CONSTRUCTOR message,
-- and then sending it Message containing Data.
--
procedure Start_With
(Self : in out Machine_Type;
Actor : in String;
Message : in String;
Data : in kv.avm.Memories.Register_Array_Type);
private
subtype Executable_State_Type is kv.avm.Control.Status_Type range kv.avm.Control.Active .. kv.avm.Control.Idle;
type Lists_Type is array (Executable_State_Type) of kv.avm.Executable_Lists.Executable_Holder_Type;
type Machine_Type is new kv.avm.control.Control_Interface with
record
Processor : kv.avm.Processors.Processor_Access;
Factory : kv.avm.Executables.Factory_Access;
Future : Interfaces.Unsigned_32;
Lists : Lists_Type;
Router : kv.avm.Routers.Router_Type;
Cursor : kv.avm.Executable_Lists.Cursor_Type := 0;
Capabilities : kv.avm.Capabilities.Capabilities_Type;
Steps : Natural;
Cycles : Natural;
Reaped : Natural;
Old_Idle : Natural := 0;
Garbage_Trigger : Natural := 500;
end record;
function Check_For_Beginning_Of_Cycle(Self : Machine_Type) return Boolean;
function Check_Message_Delivery_Policy(Self : Machine_Type) return Boolean;
function Check_Undeferral_Policy(Self : Machine_Type) return Boolean;
function Check_Garbage_Collection_Policy(Self : Machine_Type) return Boolean;
procedure Beginning_Of_Cycle
(Self : in out Machine_Type);
procedure Process_Current_Executable
(Self : in out Machine_Type);
procedure Activate_Instance
(Self : in out Machine_Type;
Instance : in kv.avm.Executables.Executable_Access);
procedure Undefer
(Self : in out Machine_Type);
function Non_Idle(Self : Machine_Type) return kv.avm.Actor_References.Sets.Set;
function Expand_Reachable_Set
(Self : Machine_Type;
Starting : kv.avm.Actor_References.Sets.Set) return kv.avm.Actor_References.Sets.Set;
procedure Delete_Unreachable_Executables
(Self : in out Machine_Type;
Reachable : in kv.avm.Actor_References.Sets.Set);
procedure Garbage_Collection
(Self : in out Machine_Type);
end kv.avm.Machines;
|
-----------------------------------------------------------------------
-- asf.filters.dump -- Filter to dump the request information
-- Copyright (C) 2010 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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.Requests;
with ASF.Responses;
with ASF.Servlets;
-- The <b>ASF.Filters.Dump</b> package provides a debugging filter which
-- can be activated in the request flow to dump the request content into
-- some log file before processing the request.
package ASF.Filters.Dump is
type Dump_Filter is new ASF.Filters.Filter with null record;
-- The Do_Filter method of the Filter is called by the container each time
-- a request/response pair is passed through the chain due to a client request
-- for a resource at the end of the chain. The Filter_Chain passed in to this
-- method allows the Filter to pass on the request and response to the next
-- entity in the chain.
--
-- A typical implementation of this method would follow the following pattern:
-- 1. Examine the request
-- 2. Optionally wrap the request object with a custom implementation to
-- filter content or headers for input filtering
-- 3. Optionally wrap the response object with a custom implementation to
-- filter content or headers for output filtering
-- 4. Either invoke the next entity in the chain using the FilterChain
-- object (chain.Do_Filter()),
-- or, not pass on the request/response pair to the next entity in the
-- filter chain to block the request processing
-- 5. Directly set headers on the response after invocation of the next
-- entity in the filter chain.
procedure Do_Filter (F : in Dump_Filter;
Request : in out Requests.Request'Class;
Response : in out Responses.Response'Class;
Chain : in out ASF.Servlets.Filter_Chain);
end ASF.Filters.Dump;
|
with agar.core.event;
with agar.core.slist;
with agar.core.timeout;
with agar.gui.surface;
with agar.gui.widget.menu;
with agar.gui.widget.scrollbar;
with agar.gui.window;
package agar.gui.widget.table is
use type c.unsigned;
type popup_t is limited private;
type popup_access_t is access all popup_t;
pragma convention (c, popup_access_t);
txt_max : constant := 128;
fmt_max : constant := 16;
col_name_max : constant := 48;
type select_mode_t is (SEL_ROWS, SEL_CELLS, SEL_COLS);
for select_mode_t use (SEL_ROWS => 0, SEL_CELLS => 1, SEL_COLS => 2);
for select_mode_t'size use c.unsigned'size;
pragma convention (c, select_mode_t);
package popup_slist is new agar.core.slist
(entry_type => popup_access_t);
type cell_type_t is (
CELL_NULL,
CELL_STRING,
CELL_INT,
CELL_UINT,
CELL_LONG,
CELL_ULONG,
CELL_FLOAT,
CELL_DOUBLE,
CELL_PSTRING,
CELL_PINT,
CELL_PUINT,
CELL_PLONG,
CELL_PULONG,
CELL_PUINT8,
CELL_PSINT8,
CELL_PUINT16,
CELL_PSINT16,
CELL_PUINT32,
CELL_PSINT32,
CELL_PFLOAT,
CELL_PDOUBLE,
CELL_INT64,
CELL_UINT64,
CELL_PINT64,
CELL_PUINT64,
CELL_POINTER,
CELL_FN_SU,
CELL_FN_TXT,
CELL_WIDGET
);
for cell_type_t use (
CELL_NULL => 0,
CELL_STRING => 1,
CELL_INT => 2,
CELL_UINT => 3,
CELL_LONG => 4,
CELL_ULONG => 5,
CELL_FLOAT => 6,
CELL_DOUBLE => 7,
CELL_PSTRING => 8,
CELL_PINT => 9,
CELL_PUINT => 10,
CELL_PLONG => 11,
CELL_PULONG => 12,
CELL_PUINT8 => 13,
CELL_PSINT8 => 14,
CELL_PUINT16 => 15,
CELL_PSINT16 => 16,
CELL_PUINT32 => 17,
CELL_PSINT32 => 18,
CELL_PFLOAT => 19,
CELL_PDOUBLE => 20,
CELL_INT64 => 21,
CELL_UINT64 => 22,
CELL_PINT64 => 23,
CELL_PUINT64 => 24,
CELL_POINTER => 25,
CELL_FN_SU => 26,
CELL_FN_TXT => 27,
CELL_WIDGET => 28
);
for cell_type_t'size use c.unsigned'size;
pragma convention (c, cell_type_t);
type cell_data_text_t is array (1 .. txt_max) of aliased c.char;
pragma convention (c, cell_data_text_t);
type cell_data_selector_t is (sel_s, sel_i, sel_f, sel_p, sel_l, sel_u64);
type cell_data_t (member : cell_data_selector_t := sel_s) is record
case member is
when sel_s => s : cell_data_text_t;
when sel_i => i : c.int;
when sel_f => f : c.double;
when sel_p => p : agar.core.types.void_ptr_t;
when sel_l => l : c.long;
when sel_u64 => u64 : agar.core.types.uint64_t;
end case;
end record;
pragma convention (c, cell_data_t);
pragma unchecked_union (cell_data_t);
type cell_format_t is array (1 .. fmt_max) of aliased c.char;
pragma convention (c, cell_format_t);
type cell_t is limited private;
type cell_access_t is access all cell_t;
pragma convention (c, cell_access_t);
type column_name_t is array (1 .. col_name_max) of aliased c.char;
pragma convention (c, column_name_t);
type column_flags_t is new c.unsigned;
TABLE_COL_FILL : constant column_flags_t := 16#01#;
TABLE_SORT_ASCENDING : constant column_flags_t := 16#02#;
TABLE_SORT_DESCENDING : constant column_flags_t := 16#04#;
TABLE_HFILL : constant column_flags_t := 16#08#;
TABLE_VFILL : constant column_flags_t := 16#10#;
TABLE_EXPAND : constant column_flags_t := TABLE_HFILL or TABLE_VFILL;
type column_t is limited private;
type column_access_t is access all column_t;
pragma convention (c, column_access_t);
type table_flags_t is new c.unsigned;
TABLE_MULTI : constant table_flags_t := 16#01#;
TABLE_MULTITOGGLE : constant table_flags_t := 16#02#;
TABLE_REDRAW_CELLS : constant table_flags_t := 16#04#;
TABLE_POLL : constant table_flags_t := 16#08#;
TABLE_HIGHLIGHT_COLS : constant table_flags_t := 16#40#;
TABLE_MULTIMODE : constant table_flags_t := TABLE_MULTI or TABLE_MULTITOGGLE;
type table_t is limited private;
type table_access_t is access all table_t;
pragma convention (c, table_access_t);
type sort_callback_t is access function
(elem1 : agar.core.types.void_ptr_t;
elem2 : agar.core.types.void_ptr_t) return c.int;
pragma convention (c, sort_callback_t);
-- API
function allocate
(parent : widget_access_t;
flags : table_flags_t) return table_access_t;
pragma import (c, allocate, "AG_TableNew");
function allocate_polled
(parent : widget_access_t;
flags : table_flags_t;
callback : agar.core.event.callback_t) return table_access_t;
pragma inline (allocate_polled);
procedure size_hint
(table : table_access_t;
width : positive;
num_rows : positive);
pragma inline (size_hint);
procedure set_separator
(table : table_access_t;
separator : string);
pragma inline (set_separator);
function set_popup
(table : table_access_t;
row : integer;
column : integer) return agar.gui.widget.menu.item_access_t;
pragma inline (set_popup);
procedure set_row_double_click_func
(table : table_access_t;
callback : agar.core.event.callback_t);
pragma inline (set_row_double_click_func);
procedure set_column_double_click_func
(table : table_access_t;
callback : agar.core.event.callback_t);
pragma inline (set_column_double_click_func);
-- table functions
procedure table_begin (table : table_access_t);
pragma import (c, table_begin, "AG_TableBegin");
procedure table_end (table : table_access_t);
pragma import (c, table_end, "AG_TableEnd");
-- column functions
function add_column
(table : table_access_t;
name : string;
size_spec : string;
sort_callback : sort_callback_t) return boolean;
pragma inline (add_column);
procedure select_column
(table : table_access_t;
column : integer);
pragma inline (select_column);
procedure deselect_column
(table : table_access_t;
column : integer);
pragma inline (deselect_column);
procedure select_all_columns (table : table_access_t);
pragma import (c, select_all_columns, "AG_TableSelectAllCols");
procedure deselect_all_columns (table : table_access_t);
pragma import (c, deselect_all_columns, "AG_TableDeselectAllCols");
function column_selected
(table : table_access_t;
column : integer) return boolean;
pragma inline (column_selected);
-- row functions
-- TODO: how to get arguments to this function (format string)?
-- function add_row
-- (table : table_access_t
-- ...
-- pragma inline (add_row);
procedure select_row
(table : table_access_t;
row : natural);
pragma inline (select_row);
procedure deselect_row
(table : table_access_t;
row : natural);
pragma inline (deselect_row);
procedure select_all_rows (table : table_access_t);
pragma import (c, select_all_rows, "AG_TableSelectAllCols");
procedure deselect_all_rows (table : table_access_t);
pragma import (c, deselect_all_rows, "AG_TableDeselectAllCols");
function row_selected
(table : table_access_t;
row : natural) return boolean;
pragma inline (row_selected);
-- cell functions
procedure select_cell
(table : table_access_t;
row : natural;
column : natural);
pragma inline (select_cell);
procedure deselect_cell
(table : table_access_t;
row : natural;
column : natural);
pragma inline (deselect_cell);
function cell_selected
(table : table_access_t;
row : natural;
column : natural) return boolean;
pragma inline (cell_selected);
function compare_cells
(cell1 : cell_access_t;
cell2 : cell_access_t) return integer;
pragma inline (compare_cells);
--
function rows (table : table_access_t) return natural;
pragma inline (rows);
function columns (table : table_access_t) return natural;
pragma inline (columns);
--
function widget (table : table_access_t) return widget_access_t;
pragma inline (widget);
private
type table_t is record
widget : aliased widget_t;
flags : table_flags_t;
selmode : select_mode_t;
w_hint : c.int;
h_hint : c.int;
sep : cs.chars_ptr;
h_row : c.int;
h_col : c.int;
w_col_min : c.int;
w_col_default : c.int;
x_offset : c.int;
m_offset : c.int;
cols : column_access_t;
cells : access cell_access_t;
n : c.unsigned;
m : c.unsigned;
m_vis : c.unsigned;
n_resizing : c.int;
v_bar : agar.gui.widget.scrollbar.scrollbar_access_t;
h_bar : agar.gui.widget.scrollbar.scrollbar_access_t;
poll_ev : agar.core.event.event_access_t;
dbl_click_row_ev : agar.core.event.event_access_t;
dbl_click_col_ev : agar.core.event.event_access_t;
dbl_click_cell_ev : agar.core.event.event_access_t;
dbl_clicked_row : c.int;
dbl_clicked_col : c.int;
dbl_clicked_cell : c.int;
wheel_ticks : agar.core.types.uint32_t;
inc_to : agar.core.timeout.timeout_t;
dec_to : agar.core.timeout.timeout_t;
r : agar.gui.rect.rect_t;
w_total : c.int;
popups : popup_slist.head_t;
end record;
pragma convention (c, table_t);
type column_t is record
name : column_name_t;
sort_fn : access function (a, b : agar.core.types.void_ptr_t) return c.int;
flags : column_flags_t;
selected : c.int;
w : c.int;
w_pct : c.int;
x : c.int;
surface : c.int;
pool : cell_access_t;
mpool : c.unsigned;
end record;
pragma convention (c, column_t);
type cell_t is record
cell_type : cell_type_t;
data : cell_data_t;
fmt : cell_format_t;
fn_su : access function
(v : agar.core.types.void_ptr_t;
n : c.int;
m : c.int) return agar.gui.surface.surface_access_t;
fn_txt : access procedure
(v : agar.core.types.void_ptr_t;
s : cs.chars_ptr;
n : c.size_t);
widget : widget_access_t;
selected : c.int;
surface : c.int;
end record;
pragma convention (c, cell_t);
type popup_t is record
m : c.int;
n : c.int;
menu : agar.gui.widget.menu.menu_access_t;
item : agar.gui.widget.menu.item_access_t;
panel : agar.gui.window.window_access_t;
popups : popup_slist.entry_t;
end record;
pragma convention (c, popup_t);
end agar.gui.widget.table;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Fixed;
with Ada.Finalization;
with Ada.Containers.Indefinite_Ordered_Maps;
with Ada.Containers.Vectors;
with EU_Projects.Times.Time_Expressions.Parsing;
-- Most of the entities in a project (WPs, tasks, deliverables, ...) share
-- many characteristics such as a name, a label (an ID, in XML jargon),
-- a short name, ... Moreover, there are some entities such as WPs and
-- tasks that have bengin/end dates while others (deliverables and milestones)
-- have just an "expected" date.
--
-- It is worth to "factorize" all these properties in a hierachy of classes.
-- More precisely we will have
--
-- * Basic nodes that have
-- - a name
-- - a short name
-- - a label
-- - an index
-- - a description
-- * Action nodes that are basic nodes with begin/end dates
-- * Timed nodes that are basic nodes with an "expected on" date
--
--
-- About names: the name of a node has possibly three parts
--
-- * A prefix that specify the type of node (T, D, ...)
-- * An index that can be simple (e.g., 4) or composite (e.g., 4.3)
-- * A title. Should we allow long+short?
--
-- A node can also have some "free attributes." This can be useful in some
-- context where I want to store some information about WP, task, ...
-- that was not forecasted.
--
package EU_Projects.Nodes is
type Node_Label is new Dotted_Identifier;
package Node_Label_Lists is
new Ada.Containers.Vectors (Positive, Node_Label);
function Parse_Label_List (Input : String) return Node_Label_Lists.Vector;
function Join (List : Node_Label_Lists.Vector;
Separator : String)
return String;
function After (Labels : Node_Label_Lists.Vector;
Done_Var : String) return String;
type Node_Class is (Info_Node, WP_Node, Task_Node, Deliverable_Node, Milestone_Node, Risk_Node, Partner_Node);
type Node_Index is new Positive;
subtype Extended_Node_Index is
Node_Index'Base range Node_Index'First - 1 .. Node_Index'Last;
No_Index : constant Extended_Node_Index := Extended_Node_Index'First;
function Image (X : Node_Index) return String
is (Chop (Node_Index'Image (X)));
-- Many nodes have an "add" function that allow to add new
-- children to a node (e.g. tasks to a WP). Every node has an
-- index. The most natural place where to add the index is
-- inside the parent, since the parent knows the number of
-- its children. However, it is possible that in some cases
-- one could want to set indixes in a non-incremental way.
-- Therefore, if the index has already been set, it must not be
-- changed.
--
-- The following function can be used in the postcondition
-- of an "add" function.
function Correctly_Updated (Old_Index, New_Index : Extended_Node_Index;
Old_Max, New_Max : Extended_Node_Index)
return Boolean
is (
(
(Old_Index = No_Index and New_Index /= No_Index)
or (Old_Index = New_Index)
)
and (
(Old_Index /= No_Index)
or (New_Index = Old_Max + 1)
)
and (New_Max = Node_Index'Max (Old_Max, New_Index))
);
type Node_Type (<>) is abstract new Ada.Finalization.Controlled with private;
type Node_Access is access all Node_Type'Class;
-- function Create (Label : Identifiers.Identifier;
-- Name : String;
-- Short_Name : String;
-- Description : String;
-- Index : Node_Index := No_Index)
-- return Node_Type;
function Index (Item : Node_Type) return Extended_Node_Index;
function Index_Image (Item : Node_Type) return String;
function Full_Index (Item : Node_Type;
Prefixed : Boolean) return String
is abstract;
-- procedure Set_Index (Item : in out Node_Type;
-- Idx : Node_Index)
-- with
-- Pre => Item.Index = No_Index;
procedure Add_Attribute (Item : in out Node_Type;
Name : in String;
Value : in String);
function Name (Item : Node_Type)
return String;
function Short_Name (Item : Node_Type)
return String;
function Label (Item : Node_Type)
return Node_Label;
function Description (Item : Node_Type) return String;
function Attribute_Exists (Item : Node_Type;
Name : String)
return Boolean;
function Get_Attribute (Item : Node_Type;
Name : String)
return String;
function Get_Attribute (Item : Node_Type;
Name : String;
Default : String)
return String;
Bad_Parent : exception;
function Class (Item : Node_Type) return Node_Class;
type Variable_List is array (Positive range<>) of Simple_Identifier;
Empty_List : constant Variable_List (2 .. 1) := (others => <>);
function Variables (Item : Node_Type) return Variable_List
is (Empty_List);
-- Every node has a number of internal variables. For example, a WP
-- has a starting time, and ending time and a duration (never mind that
-- they are not independent, they are three different variables for
-- what matters here). This function returns a list of the internal
-- variables. Note that they are Simple_Identifiers, therefore they
-- have no '.'
--
-- For example, a WP would return "begin", "end", "duration".
procedure Parse_Raw_Expressions
(Item : in out Node_Type;
Vars : Times.Time_Expressions.Parsing.Symbol_Table)
is null;
-- While parsing the nodes are initialized with time expressions in
-- string form and we need to parse them before we try to solve
-- the corresponding system of equations.
--
-- We need to do this in two separate steps since some "forward reference"
-- can be needed. For example, the ending time of a WP can have the special
-- value "end" that means when the last task ot the WP ends. In order to
-- handle this the WP needs to know all its tasks.
function Dependency_List (Item : Node_Type)
return Node_Label_Lists.Vector
is abstract;
--
-- A start time/due time has as default value the maximum of the end
-- times of all the "dependencies." This function returns the list
-- of the labels of all dependencies.
--
pragma Warnings (Off);
function Is_Variable (Item : Node_Type;
Var : Simple_Identifier) return Boolean
is (False);
-- Return if Var is a variable known to the node. Useful in contracts
function Is_A (Item : Node_Type;
Var : Simple_Identifier;
Class : Times.Time_Type)
return Boolean
is (False);
-- Return True if Var is a variable known to the node AND it contains
-- value of the specified type.
function Is_Fixed (Item : Node_Type;
Var : Simple_Identifier)
return Boolean
with Pre'Class => Is_Variable (Item, Var);
pragma Warnings (On);
function Get_Symbolic_Instant (Item : Node_Type;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Instant
is abstract;
function Get_Symbolic_Duration (Item : Node_Type;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Duration
is abstract;
procedure Fix_Instant
(Item : in out Node_Type;
Var : Simple_Identifier;
Value : Times.Instant)
with
Pre'Class => Item.Is_A (Var, Times.Instant_Value) and then not Item.Is_Fixed (Var),
Post'Class => Item.Is_Fixed (Var);
-- procedure Fix_Duration
-- (Item : in out Node_Type;
-- Var : Simple_Identifier;
-- Value : Times.Duration)
-- with
-- Pre'Class => Item.Is_A (Var, Times.Duration_Value) and then not Item.Is_Fixed (Var),
-- Post'Class => Item.Is_Fixed (Var);
Unknown_Var : exception;
Unknown_Instant_Var : exception;
Unknown_Duration_Var : exception;
-- --
-- -- There is the necessity of writing pre/post conditions that
-- -- check that a Node_Access points to a WP, Task, ... Because of
-- -- mutual dependences (e.g., a WP has a list of tasks and every
-- -- task has a "Parent" field pointing back to the WP), it is
-- -- not easy to use the facilities of Ada.Tags sinche it would
-- -- introduce circular dependencies. By using function Is_A defined
-- -- here I can break those dependencies.
-- --
-- type Node_Class is (A_WP, A_Task, A_Deliverable, A_Milestone, A_Partner);
-- function Is_A (Item : Node_Type'Class;
-- Class : Node_Class)
-- return Boolean;
private
function Shortify (Short_Name, Name : String) return Unbounded_String
is (
(if Short_Name = "" then
To_Unbounded_String (Name)
else
To_Unbounded_String (Short_Name)
)
);
package Attribute_Maps is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String,
Element_Type => String);
type Node_Type is abstract
new Ada.Finalization.Controlled
with
record
Class : Node_Class;
Label : Node_Label;
Name : Unbounded_String;
Short_Name : Unbounded_String;
Index : Extended_Node_Index := No_Index;
Description : Unbounded_String;
Attributes : Attribute_Maps.Map;
-- Parent : Node_Access;
end record;
function Trim (X : String) return String
is (Ada.Strings.Fixed.Trim (X, Ada.Strings.Both));
function Index_Image (Item : Node_Type) return String
is (Trim (Extended_Node_Index'Image (Item.Index)));
function Index (Item : Node_Type) return Extended_Node_Index
is (Item.Index);
function Class (Item : Node_Type) return Node_Class
is (Item.Class);
-- function Full_Index (Item : Node_Type) return String
-- is (
-- if Item.Parent = null then
-- Trim (Node_Index'Image (Item.Index))
-- else
-- Trim (Node_Index'Image (Item.Parent.Index))
-- & "."
-- & Trim (Node_Index'Image (Item.Index))
-- );
-- function Index (Item : Node_Type) return String
-- is (Trim (Node_Index'Image (Item.Index)));
function Name (Item : Node_Type) return String
is (To_String (Item.Name));
function Short_Name (Item : Node_Type) return String
is (To_String (Item.Short_Name));
function Label (Item : Node_Type) return Node_Label
is (Item.Label);
function Description (Item : Node_Type) return String
is (To_String (Item.Description));
function Attribute_Exists (Item : Node_Type;
Name : String)
return Boolean
is (Item.Attributes.Contains (Name));
function Get_Attribute (Item : Node_Type;
Name : String)
return String
is (Item.Attributes.Element (Name));
function Get_Attribute (Item : Node_Type;
Name : String;
Default : String)
return String
is (
if Item.Attribute_Exists (Name) then
Item.Attributes.Element (Name)
else
Default
);
-- Convenience function: this action is quite common in many
-- node instances and we "factor" it here
function Make_Short_Name (Short_Name : String;
Default : String)
return Unbounded_String
is (
if Short_Name = "" then
To_Unbounded_String (Default)
else
To_Unbounded_String (Short_Name)
);
end EU_Projects.Nodes;
|
-- Lumen.Binary.Endian.Words -- Byte re-ordering routines for "word"
-- (32-bit) values
--
--
-- Chip Richards, NiEstu, Phoenix AZ, Summer 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
-- Environment
with Ada.Unchecked_Conversion;
package body Lumen.Binary.Endian.Words is
---------------------------------------------------------------------------
type Four_Bytes is record
B0 : Byte;
B1 : Byte;
B2 : Byte;
B3 : Byte;
end record;
for Four_Bytes'Size use Word_Bits;
for Four_Bytes use record
B0 at 0 range 0 .. 7;
B1 at 1 range 0 .. 7;
B2 at 2 range 0 .. 7;
B3 at 3 range 0 .. 7;
end record;
---------------------------------------------------------------------------
-- Swap the bytes, no matter the host ordering
function Swap_Bytes (Value : Word_Type) return Word_Type is
W : Four_Bytes;
T : Four_Bytes;
function VTT is new Ada.Unchecked_Conversion (Word_Type, Four_Bytes);
function TTV is new Ada.Unchecked_Conversion (Four_Bytes, Word_Type);
begin -- Swap_Bytes
T := VTT (Value);
W.B0 := T.B3;
W.B1 := T.B2;
W.B2 := T.B1;
W.B3 := T.B0;
return TTV (W);
end Swap_Bytes;
---------------------------------------------------------------------------
-- Swap bytes if host is little-endian, or no-op if it's big-endian
function To_Big (Value : Word_Type) return Word_Type is
begin -- To_Big
if System_Byte_Order /= High_Order_First then
return Swap_Bytes (Value);
else
return Value;
end if;
end To_Big;
---------------------------------------------------------------------------
-- Swap bytes if host is big-endian, or no-op if it's little-endian
function To_Little (Value : Word_Type) return Word_Type is
begin -- To_Little
if System_Byte_Order /= Low_Order_First then
return Swap_Bytes (Value);
else
return Value;
end if;
end To_Little;
---------------------------------------------------------------------------
-- Swap the bytes, no matter the host ordering
procedure Swap_Bytes (Value : in out Word_Type) is
W : Four_Bytes;
T : Four_Bytes;
function VTT is new Ada.Unchecked_Conversion (Word_Type, Four_Bytes);
function TTV is new Ada.Unchecked_Conversion (Four_Bytes, Word_Type);
begin -- Swap_Bytes
T := VTT (Value);
W.B0 := T.B3;
W.B1 := T.B2;
W.B2 := T.B1;
W.B3 := T.B0;
Value := TTV (W);
end Swap_Bytes;
---------------------------------------------------------------------------
-- Swap bytes if host is little-endian, or no-op if it's big-endian
procedure To_Big (Value : in out Word_Type) is
begin -- To_Big
if System_Byte_Order /= High_Order_First then
Swap_Bytes (Value);
end if;
end To_Big;
---------------------------------------------------------------------------
-- Swap bytes if host is big-endian, or no-op if it's little-endian
procedure To_Little (Value : in out Word_Type) is
begin -- To_Little
if System_Byte_Order /= Low_Order_First then
Swap_Bytes (Value);
end if;
end To_Little;
---------------------------------------------------------------------------
end Lumen.Binary.Endian.Words;
|
-- Copyright 2018-2021 Bartek thindil Jasicki
--
-- This file is part of Steam Sky.
--
-- Steam Sky is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- Steam Sky is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Steam Sky. If not, see <http://www.gnu.org/licenses/>.
with Ada.Containers.Hashed_Maps; use Ada.Containers;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Hash;
with DOM.Readers; use DOM.Readers;
with Game; use Game;
-- ****h* Factions/Factions
-- FUNCTION
-- Provide code for factions
-- SOURCE
package Factions is
-- ****
-- ****t* Factions/Factions.NamesTypes
-- FUNCTION
-- Types of names of members and bases factions
-- SOURCE
type NamesTypes is (STANDARD, ROBOTIC) with
Default_Value => STANDARD;
-- ****
-- ****s* Factions/Factions.RelationsRecord
-- FUNCTION
-- Data structure for relations between factions
-- PARAMETERS
-- Reputation - Min and max value for starting reputation in bases owned
-- by target faction
-- Friendly - Did target faction is friendly or enemy to this faction
-- SOURCE
type RelationsRecord is record
Reputation: Reputation_Array;
Friendly: Boolean;
end record;
-- ****
-- ****t* Factions/Factions.Relations_Container
-- FUNCTION
-- Used to store relations data in faction
-- SOURCE
package Relations_Container is new Hashed_Maps
(Unbounded_String, RelationsRecord, Ada.Strings.Unbounded.Hash, "=");
-- ****
-- ****s* Factions/Factions.CareerRecord
-- FUNCTION
-- Data structure for player career in faction
-- PARAMETERS
-- ShipIndex - Index of proto ship which will be used as starting ship
-- for player
-- PlayerIndex - Index of mobile which will be used as starting character
-- for player
-- Description - Description of career, displayed to player
-- Name - Name of career, may be different for each faction
-- SOURCE
type CareerRecord is record
ShipIndex: Unbounded_String;
PlayerIndex: Unbounded_String;
Description: Unbounded_String;
Name: Unbounded_String;
end record;
-- ****
-- ****t* Factions/Factions.Careers_Container
-- FUNCTION
-- Used to store careers data in faction
-- SOURCE
package Careers_Container is new Hashed_Maps
(Unbounded_String, CareerRecord, Ada.Strings.Unbounded.Hash, "=");
-- ****
-- ****t* Factions/Factions.BaseType_Container
-- FUNCTION
-- Used to store bases types data in faction
-- SOURCE
package BaseType_Container is new Hashed_Maps
(Unbounded_String, Positive, Ada.Strings.Unbounded.Hash, "=");
-- ****
-- ****s* Factions/Factions.FactionRecord
-- FUNCTION
-- Data structure for faction
-- PARAMETERS
-- Name - Name of faction, displayed to player
-- MemberName - Name of single member of faction
-- PluralMemberName - Plural name of members of faction
-- SpawnChance - Chance that created at new game base will be owned by
-- this faction
-- Population - Min and max population for new bases with this
-- faction as owner
-- NamesTypes - Type of names of members of faction (used in
-- generating names of ships)
-- Relations - Relations of this faction with others factions
-- Description - Description on faction, displayed to player
-- FoodTypes - Types of items used as food for members of this
-- faction
-- DrinksTypes - Types of items used as drinks for members of this
-- faction
-- HealingTools - Name of item type used as tool in healing members of
-- this faction
-- HealingSkill - Vector index of skill used in healing members of this
-- faction
-- Flags - Various flags for faction (no gender, etc)
-- Careers - List of possible careers for that faction
-- BaseIcon - Character used as base icon on map for this faction
-- BasesTypes - List of available base types (with chances to spawn)
-- for this faction. If it is empty then all bases types
-- are available for this faction
-- WeaponSkill - Vector index of skill used by prefered weapon of
-- members of this faction
-- SOURCE
type FactionRecord is record
Name: Unbounded_String;
MemberName: Unbounded_String;
PluralMemberName: Unbounded_String;
SpawnChance: Natural := 0;
Population: Attributes_Array;
NamesType: NamesTypes;
Relations: Relations_Container.Map;
Description: Unbounded_String;
FoodTypes: UnboundedString_Container.Vector;
DrinksTypes: UnboundedString_Container.Vector;
HealingTools: Unbounded_String;
HealingSkill: SkillsData_Container.Extended_Index;
Flags: UnboundedString_Container.Vector;
Careers: Careers_Container.Map;
BaseIcon: Wide_Character;
BasesTypes: BaseType_Container.Map;
WeaponSkill: SkillsData_Container.Extended_Index;
end record;
-- ****
-- ****t* Factions/Factions.Factions_Container
-- FUNCTION
-- Used to store factions data
-- SOURCE
package Factions_Container is new Hashed_Maps
(Unbounded_String, FactionRecord, Ada.Strings.Unbounded.Hash, "=");
-- ****
-- ****v* Factions/Factions.Factions_List
-- SOURCE
Factions_List: Factions_Container.Map;
-- ****
-- ****f* Factions/Factions.LoadFactions
-- FUNCTION
-- Load NPC factions from file
-- PARAMETERS
-- Reader - XML Reader from which factions will be read
-- SOURCE
procedure LoadFactions(Reader: Tree_Reader);
-- ****
-- ****f* Factions/Factions.GetReputation
-- FUNCTION
-- Get reputation between SourceFaction and TargetFaction
-- PARAMETERS
-- SourceFaction - Index of first faction which reputation will be check
-- TargetFaction - Index of second faction which reputation will be check
-- RESULT
-- Numeric reputation level between both factions
-- SOURCE
function GetReputation
(SourceFaction, TargetFaction: Unbounded_String) return Integer with
Pre =>
(Factions_List.Contains(SourceFaction) and
Factions_List.Contains(TargetFaction)),
Test_Case => (Name => "Test_GetReputation", Mode => Nominal);
-- ****
-- ****f* Factions/Factions.IsFriendly
-- FUNCTION
-- Check if TargetFaction is friendly for SourceFaction. Returns true if yes, otherwise false.
-- PARAMETERS
-- SourceFaction - Index of base faction to which TargetFaction will be checked
-- TargetFaction - Index of faction to check
-- RESULT
-- True if factions are friendly between self, otherwise false
-- SOURCE
function IsFriendly
(SourceFaction, TargetFaction: Unbounded_String) return Boolean with
Pre =>
(Factions_List.Contains(SourceFaction) and
Factions_List.Contains(TargetFaction)),
Test_Case => (Name => "Test_IsFriendly", Mode => Nominal);
-- ****
-- ****f* Factions/Factions.GetRandomFaction
-- FUNCTION
-- Select random faction from list
-- RESULT
-- Random index of faction
-- SOURCE
function GetRandomFaction return Unbounded_String with
Test_Case => (Name => "Test_GetRandomFaction", Mode => Robustness);
-- ****
end Factions;
|
with Ada.Characters.Handling;
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Containers.Indefinite_Vectors;
procedure Generate is
use Ada.Characters.Handling;
use Ada.Text_IO;
package String_Vectors is new Ada.Containers.Indefinite_Vectors
(Element_Type => String,
Index_Type => Positive);
Languages : String_Vectors.Vector;
function Capitalize (S : in String) return String is
(To_Upper (S (S'First)) & S (S'First + 1 .. S'Last));
procedure Write_Spec is
File : File_Type;
I : Natural := 0;
begin
Create (File, Out_File, "stemmer-factory.ads");
Put_Line (File, "package Stemmer.Factory with SPARK_Mode is");
New_Line (File);
Put (File, " type Language_Type is (");
for Lang of Languages loop
Put (File, "L_" & To_Upper (Lang));
I := I + 1;
if I < Natural (Languages.Length) then
Put_Line (File, ",");
Put (File, " ");
end if;
end loop;
Put_Line (File, ");");
New_Line (File);
Put_Line (File, " function Stem (Language : in Language_Type;");
Put_Line (File, " Word : in String) return String;");
New_Line (File);
Put_Line (File, "end Stemmer.Factory;");
Close (File);
end Write_Spec;
procedure Write_Body is
File : File_Type;
begin
Create (File, Out_File, "stemmer-factory.adb");
for Lang of Languages loop
Put_Line (File, "with Stemmer." & Capitalize (Lang) & ";");
end loop;
Put_Line (File, "package body Stemmer.Factory with SPARK_Mode is");
New_Line (File);
Put_Line (File, " function Stem (Language : in Language_Type;");
Put_Line (File, " Word : in String) return String is");
Put_Line (File, " Result : Boolean := False;");
Put_Line (File, " begin");
Put_Line (File, " case Language is");
for Lang of Languages loop
Put_Line (File, " when L_" & To_Upper (Lang) & " =>");
Put_Line (File, " declare");
Put_Line (File, " C : Stemmer." & Capitalize (Lang) & ".Context_Type;");
Put_Line (File, " begin");
Put_Line (File, " C.Stem_Word (Word, Result);");
Put_Line (File, " return Get_Result (C);");
Put_Line (File, " end;");
New_Line (File);
end loop;
Put_Line (File, " end case;");
Put_Line (File, " end Stem;");
New_Line (File);
Put_Line (File, "end Stemmer.Factory;");
Close (File);
end Write_Body;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
for I in 1 .. Count loop
Languages.Append (To_Lower (Ada.Command_Line.Argument (I)));
end loop;
Write_Spec;
Write_Body;
end Generate;
|
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A006 is
use Ada.Integer_Text_IO;
N, Sum, Square_Of_Sum, Sum_Of_Square : Integer;
begin
N := 100;
Sum := Integer ((N * (N + 1)) / 2);
Square_Of_Sum := Sum * Sum;
Sum_Of_Square := (N * (N + 1) * ((2 * N) + 1)) / 6;
Put (Square_Of_Sum - Sum_Of_Square, Width => 0);
end A006;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T C M D --
-- --
-- B o d y --
-- --
-- Copyright (C) 1996-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Gnatvsn;
with Namet; use Namet;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
with Switch; use Switch;
with Table;
with Usage;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib; use GNAT.OS_Lib;
procedure GNATCmd is
Gprbuild : constant String := "gprbuild";
Gprclean : constant String := "gprclean";
Gprname : constant String := "gprname";
Gprls : constant String := "gprls";
Ada_Help_Switch : constant String := "--help-ada";
-- Flag to display available build switches
Error_Exit : exception;
-- Raise this exception if error detected
type Command_Type is
(Bind,
Chop,
Clean,
Compile,
Check,
Elim,
Find,
Krunch,
Link,
List,
Make,
Metric,
Name,
Preprocess,
Pretty,
Stack,
Stub,
Test,
Xref,
Undefined);
subtype Real_Command_Type is Command_Type range Bind .. Xref;
-- All real command types (excludes only Undefined).
type Alternate_Command is (Comp, Ls, Kr, Pp, Prep);
-- Alternate command label
Corresponding_To : constant array (Alternate_Command) of Command_Type :=
(Comp => Compile,
Ls => List,
Kr => Krunch,
Prep => Preprocess,
Pp => Pretty);
-- Mapping of alternate commands to commands
package First_Switches is new Table.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Gnatcmd.First_Switches");
-- A table to keep the switches from the project file
package Last_Switches is new Table.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Gnatcmd.Last_Switches");
----------------------------------
-- Declarations for GNATCMD use --
----------------------------------
The_Command : Command_Type;
-- The command specified in the invocation of the GNAT driver
Command_Arg : Positive := 1;
-- The index of the command in the arguments of the GNAT driver
My_Exit_Status : Exit_Status := Success;
-- The exit status of the spawned tool
type Command_Entry is record
Cname : String_Access;
-- Command name for GNAT xxx command
Unixcmd : String_Access;
-- Corresponding Unix command
Unixsws : Argument_List_Access;
-- List of switches to be used with the Unix command
end record;
Command_List : constant array (Real_Command_Type) of Command_Entry :=
(Bind =>
(Cname => new String'("BIND"),
Unixcmd => new String'("gnatbind"),
Unixsws => null),
Chop =>
(Cname => new String'("CHOP"),
Unixcmd => new String'("gnatchop"),
Unixsws => null),
Clean =>
(Cname => new String'("CLEAN"),
Unixcmd => new String'("gnatclean"),
Unixsws => null),
Compile =>
(Cname => new String'("COMPILE"),
Unixcmd => new String'("gnatmake"),
Unixsws => new Argument_List'(1 => new String'("-f"),
2 => new String'("-u"),
3 => new String'("-c"))),
Check =>
(Cname => new String'("CHECK"),
Unixcmd => new String'("gnatcheck"),
Unixsws => null),
Elim =>
(Cname => new String'("ELIM"),
Unixcmd => new String'("gnatelim"),
Unixsws => null),
Find =>
(Cname => new String'("FIND"),
Unixcmd => new String'("gnatfind"),
Unixsws => null),
Krunch =>
(Cname => new String'("KRUNCH"),
Unixcmd => new String'("gnatkr"),
Unixsws => null),
Link =>
(Cname => new String'("LINK"),
Unixcmd => new String'("gnatlink"),
Unixsws => null),
List =>
(Cname => new String'("LIST"),
Unixcmd => new String'("gnatls"),
Unixsws => null),
Make =>
(Cname => new String'("MAKE"),
Unixcmd => new String'("gnatmake"),
Unixsws => null),
Metric =>
(Cname => new String'("METRIC"),
Unixcmd => new String'("gnatmetric"),
Unixsws => null),
Name =>
(Cname => new String'("NAME"),
Unixcmd => new String'("gnatname"),
Unixsws => null),
Preprocess =>
(Cname => new String'("PREPROCESS"),
Unixcmd => new String'("gnatprep"),
Unixsws => null),
Pretty =>
(Cname => new String'("PRETTY"),
Unixcmd => new String'("gnatpp"),
Unixsws => null),
Stack =>
(Cname => new String'("STACK"),
Unixcmd => new String'("gnatstack"),
Unixsws => null),
Stub =>
(Cname => new String'("STUB"),
Unixcmd => new String'("gnatstub"),
Unixsws => null),
Test =>
(Cname => new String'("TEST"),
Unixcmd => new String'("gnattest"),
Unixsws => null),
Xref =>
(Cname => new String'("XREF"),
Unixcmd => new String'("gnatxref"),
Unixsws => null)
);
-----------------------
-- Local Subprograms --
-----------------------
procedure Output_Version;
-- Output the version of this program
procedure GNATCmd_Usage;
-- Display usage
--------------------
-- Output_Version --
--------------------
procedure Output_Version is
begin
Put ("GNAT ");
Put_Line (Gnatvsn.Gnat_Version_String);
Put_Line ("Copyright 1996-" & Gnatvsn.Current_Year
& ", Free Software Foundation, Inc.");
end Output_Version;
-------------------
-- GNATCmd_Usage --
-------------------
procedure GNATCmd_Usage is
begin
Output_Version;
New_Line;
Put_Line ("To list Ada build switches use " & Ada_Help_Switch);
New_Line;
Put_Line ("List of available commands");
New_Line;
for C in Command_List'Range loop
Put ("gnat ");
Put (To_Lower (Command_List (C).Cname.all));
Set_Col (25);
Put (Program_Name (Command_List (C).Unixcmd.all, "gnat").all);
declare
Sws : Argument_List_Access renames Command_List (C).Unixsws;
begin
if Sws /= null then
for J in Sws'Range loop
Put (' ');
Put (Sws (J).all);
end loop;
end if;
end;
New_Line;
end loop;
New_Line;
end GNATCmd_Usage;
procedure Check_Version_And_Help
is new Check_Version_And_Help_G (GNATCmd_Usage);
-- Start of processing for GNATCmd
begin
-- All output from GNATCmd is debugging or error output: send to stderr
Set_Standard_Error;
-- Initializations
Last_Switches.Init;
Last_Switches.Set_Last (0);
First_Switches.Init;
First_Switches.Set_Last (0);
-- Put the command line in environment variable GNAT_DRIVER_COMMAND_LINE,
-- so that the spawned tool may know the way the GNAT driver was invoked.
Name_Len := 0;
Add_Str_To_Name_Buffer (Command_Name);
for J in 1 .. Argument_Count loop
Add_Char_To_Name_Buffer (' ');
Add_Str_To_Name_Buffer (Argument (J));
end loop;
Setenv ("GNAT_DRIVER_COMMAND_LINE", Name_Buffer (1 .. Name_Len));
-- Add the directory where the GNAT driver is invoked in front of the path,
-- if the GNAT driver is invoked with directory information.
declare
Command : constant String := Command_Name;
begin
for Index in reverse Command'Range loop
if Command (Index) = Directory_Separator then
declare
Absolute_Dir : constant String :=
Normalize_Pathname (Command (Command'First .. Index));
PATH : constant String :=
Absolute_Dir & Path_Separator & Getenv ("PATH").all;
begin
Setenv ("PATH", PATH);
end;
exit;
end if;
end loop;
end;
-- Scan the command line
-- First, scan to detect --version and/or --help
Check_Version_And_Help ("GNAT", "1996");
begin
loop
if Command_Arg <= Argument_Count
and then Argument (Command_Arg) = "-v"
then
Verbose_Mode := True;
Command_Arg := Command_Arg + 1;
elsif Command_Arg <= Argument_Count
and then Argument (Command_Arg) = "-dn"
then
Keep_Temporary_Files := True;
Command_Arg := Command_Arg + 1;
elsif Command_Arg <= Argument_Count
and then Argument (Command_Arg) = Ada_Help_Switch
then
Usage;
Exit_Program (E_Success);
else
exit;
end if;
end loop;
-- If there is no command, just output the usage
if Command_Arg > Argument_Count then
GNATCmd_Usage;
-- Add the following so that output is consistent with or without the
-- --help flag.
Write_Eol;
Write_Line ("Report bugs to report@adacore.com");
return;
end if;
The_Command := Real_Command_Type'Value (Argument (Command_Arg));
exception
when Constraint_Error =>
-- Check if it is an alternate command
declare
Alternate : Alternate_Command;
begin
Alternate := Alternate_Command'Value (Argument (Command_Arg));
The_Command := Corresponding_To (Alternate);
exception
when Constraint_Error =>
GNATCmd_Usage;
Fail ("unknown command: " & Argument (Command_Arg));
end;
end;
-- Get the arguments from the command line and from the eventual
-- argument file(s) specified on the command line.
for Arg in Command_Arg + 1 .. Argument_Count loop
declare
The_Arg : constant String := Argument (Arg);
begin
-- Check if an argument file is specified
if The_Arg'Length > 0 and then The_Arg (The_Arg'First) = '@' then
declare
Arg_File : Ada.Text_IO.File_Type;
Line : String (1 .. 256);
Last : Natural;
begin
-- Open the file and fail if the file cannot be found
begin
Open (Arg_File, In_File,
The_Arg (The_Arg'First + 1 .. The_Arg'Last));
exception
when others =>
Put (Standard_Error, "Cannot open argument file """);
Put (Standard_Error,
The_Arg (The_Arg'First + 1 .. The_Arg'Last));
Put_Line (Standard_Error, """");
raise Error_Exit;
end;
-- Read line by line and put the content of each non-
-- empty line in the Last_Switches table.
while not End_Of_File (Arg_File) loop
Get_Line (Arg_File, Line, Last);
if Last /= 0 then
Last_Switches.Increment_Last;
Last_Switches.Table (Last_Switches.Last) :=
new String'(Line (1 .. Last));
end if;
end loop;
Close (Arg_File);
end;
elsif The_Arg'Length > 0 then
-- It is not an argument file; just put the argument in
-- the Last_Switches table.
Last_Switches.Increment_Last;
Last_Switches.Table (Last_Switches.Last) := new String'(The_Arg);
end if;
end;
end loop;
declare
Program : String_Access;
Exec_Path : String_Access;
Get_Target : Boolean := False;
begin
if The_Command = Stack then
-- Never call gnatstack with a prefix
Program := new String'(Command_List (The_Command).Unixcmd.all);
else
Program :=
Program_Name (Command_List (The_Command).Unixcmd.all, "gnat");
-- If we want to invoke gnatmake/gnatclean with -P, then check if
-- gprbuild/gprclean is available; if it is, use gprbuild/gprclean
-- instead of gnatmake/gnatclean.
-- Ditto for gnatname -> gprname and gnatls -> gprls.
if The_Command = Make
or else The_Command = Compile
or else The_Command = Bind
or else The_Command = Link
or else The_Command = Clean
or else The_Command = Name
or else The_Command = List
then
declare
Switch : String_Access;
Call_GPR_Tool : Boolean := False;
begin
for J in 1 .. Last_Switches.Last loop
Switch := Last_Switches.Table (J);
if Switch'Length >= 2
and then Switch (Switch'First .. Switch'First + 1) = "-P"
then
Call_GPR_Tool := True;
exit;
end if;
end loop;
if Call_GPR_Tool then
case The_Command is
when Bind
| Compile
| Link
| Make
=>
if Locate_Exec_On_Path (Gprbuild) /= null then
Program := new String'(Gprbuild);
Get_Target := True;
if The_Command = Bind then
First_Switches.Append (new String'("-b"));
elsif The_Command = Link then
First_Switches.Append (new String'("-l"));
end if;
elsif The_Command = Bind then
Fail
("'gnat bind -P' is no longer supported;" &
" use 'gprbuild -b' instead.");
elsif The_Command = Link then
Fail
("'gnat Link -P' is no longer supported;" &
" use 'gprbuild -l' instead.");
end if;
when Clean =>
if Locate_Exec_On_Path (Gprclean) /= null then
Program := new String'(Gprclean);
Get_Target := True;
end if;
when Name =>
if Locate_Exec_On_Path (Gprname) /= null then
Program := new String'(Gprname);
Get_Target := True;
end if;
when List =>
if Locate_Exec_On_Path (Gprls) /= null then
Program := new String'(Gprls);
Get_Target := True;
end if;
when others =>
null;
end case;
if Get_Target then
Find_Program_Name;
if Name_Len > 5 then
First_Switches.Append
(new String'
("--target=" & Name_Buffer (1 .. Name_Len - 5)));
end if;
end if;
end if;
end;
end if;
end if;
-- Locate the executable for the command
Exec_Path := Locate_Exec_On_Path (Program.all);
if Exec_Path = null then
Put_Line (Standard_Error, "could not locate " & Program.all);
raise Error_Exit;
end if;
-- If there are switches for the executable, put them as first switches
if Command_List (The_Command).Unixsws /= null then
for J in Command_List (The_Command).Unixsws'Range loop
First_Switches.Increment_Last;
First_Switches.Table (First_Switches.Last) :=
Command_List (The_Command).Unixsws (J);
end loop;
end if;
-- For FIND and XREF, look for switch -P. If it is specified, then
-- report an error indicating that the command is no longer supporting
-- project files.
if The_Command = Find or else The_Command = Xref then
declare
Argv : String_Access;
begin
for Arg_Num in 1 .. Last_Switches.Last loop
Argv := Last_Switches.Table (Arg_Num);
if Argv'Length >= 2 and then
Argv (Argv'First .. Argv'First + 1) = "-P"
then
if The_Command = Find then
Fail ("'gnat find -P' is no longer supported;");
else
Fail ("'gnat xref -P' is no longer supported;");
end if;
end if;
end loop;
end;
end if;
-- Gather all the arguments and invoke the executable
declare
The_Args : Argument_List
(1 .. First_Switches.Last + Last_Switches.Last);
Arg_Num : Natural := 0;
begin
for J in 1 .. First_Switches.Last loop
Arg_Num := Arg_Num + 1;
The_Args (Arg_Num) := First_Switches.Table (J);
end loop;
for J in 1 .. Last_Switches.Last loop
Arg_Num := Arg_Num + 1;
The_Args (Arg_Num) := Last_Switches.Table (J);
end loop;
if Verbose_Mode then
Put (Exec_Path.all);
for Arg in The_Args'Range loop
Put (" " & The_Args (Arg).all);
end loop;
New_Line;
end if;
My_Exit_Status := Exit_Status (Spawn (Exec_Path.all, The_Args));
Set_Exit_Status (My_Exit_Status);
end;
end;
exception
when Error_Exit =>
Set_Exit_Status (Failure);
end GNATCmd;
|
package Racionalisok is
type Racionalis is private;
function Szamlalo ( R: Racionalis ) return Integer;
function Nevezo ( R: Racionalis ) return Positive;
function "/" ( Szamlalo: Integer; Nevezo: Positive ) return Racionalis;
function "/" ( X, Y: Racionalis ) return Racionalis;
function "/" ( X: Racionalis; Y: Positive ) return Racionalis;
function "+" ( Szamlalo: Integer; Nevezo: Positive ) return Racionalis;
function "+" ( X, Y: Racionalis ) return Racionalis;
function "+" ( X: Racionalis; Y: Positive ) return Racionalis;
function "*" ( Szamlalo: Integer; Nevezo: Positive ) return Racionalis;
function "*" ( X, Y: Racionalis ) return Racionalis;
function "*" ( X: Racionalis; Y: Positive ) return Racionalis;
-- function "=" ( X, Y: Racionalis ) return Boolean;
private
type Racionalis is record
Szamlalo: Integer := 0;
Nevezo: Positive := 1;
end record;
end Racionalisok;
|
package dispatch2_p is
type Object is tagged null record;
type Object_Ptr is access all Object'CLASS;
--
function Impl_Of (Self : access Object) return Object_Ptr;
function Get_Ptr (Self : access Object) return Object_Ptr
renames Impl_Of;
end;
|
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Text_IO; use Ada.Text_IO;
with Strings_Edit; use Strings_Edit;
procedure Column_Aligner is
Text : constant String :=
"Given$a$text$file$of$many$lines,$where$fields$within$a$line$" & NUL &
"are$delineated$by$a$single$'dollar'$character,$write$a$program" & NUL &
"that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" & NUL &
"column$are$separated$by$at$least$one$space." & NUL &
"Further,$allow$for$each$word$in$a$column$to$be$either$left$" & NUL &
"justified,$right$justified,$or$center$justified$within$its$column." & NUL;
File : File_Type;
Width : array (1..1_000) of Natural := (others => 0);
Line : String (1..200);
Column : Positive := 1;
Start : Positive := 1;
Pointer : Positive;
begin
Create (File, Out_File, "columned.txt");
-- Determining the widths of columns
for I in Text'Range loop
case Text (I) is
when '$' | NUL =>
Width (Column) := Natural'Max (Width (Column), I - Start + 1);
Start := I + 1;
if Text (I) = NUL then
Column := 1;
else
Column := Column + 1;
end if;
when others =>
null;
end case;
end loop;
-- Formatting
for Align in Alignment loop
Column := 1;
Start := 1;
Pointer := 1;
for I in Text'Range loop
case Text (I) is
when '$' | NUL =>
Put -- Formatted output of a word
( Destination => Line,
Pointer => Pointer,
Value => Text (Start..I - 1),
Field => Width (Column),
Justify => Align
);
Start := I + 1;
if Text (I) = NUL then
Put_Line (File, Line (1..Pointer - 1));
Pointer := 1;
Column := 1;
else
Column := Column + 1;
end if;
when others =>
null;
end case;
end loop;
end loop;
Close (File);
end Column_Aligner;
|
procedure prueba is
function Minimo2 (a, b: Integer) return Integer is
X : Integer := 0;
begin
if a < b then return a;
else return b;
end if;
end Minimo2;
begin
put(Minimo2(1, 2));
end prueba; |
with Ada.Strings.Fixed;
package Project_Processor is
-- The result of function 'Image associated to discrete types has
-- a space at the beginning. That space is quite annoying and needs
-- to be trimmed. This function is here so that everyone can use it
function Chop (X : String) return String
is (Ada.Strings.Fixed.Trim (X, Ada.Strings.Both));
function Image (X : Integer) return String
is (Chop (Integer'Image (X)));
end Project_Processor;
|
-----------------------------------------------------------------------
-- net-dhcp -- DHCP client
-- Copyright (C) 2016, 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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; use Interfaces;
with Net.Headers;
with Net.Utils;
with Net.Protos.IPv4;
with Net.Protos.Arp;
package body Net.DHCP is
use type Ada.Real_Time.Time;
DEF_VENDOR_CLASS : constant String := "Ada Embedded Network";
DHCP_DISCOVER : constant Net.Uint8 := 1;
DHCP_OFFER : constant Net.Uint8 := 2;
DHCP_REQUEST : constant Net.Uint8 := 3;
DHCP_DECLINE : constant Net.Uint8 := 4;
DHCP_ACK : constant Net.Uint8 := 5;
DHCP_NACK : constant Net.Uint8 := 6;
DHCP_RELEASE : constant Net.Uint8 := 7;
OPT_PAD : constant Net.Uint8 := 0;
OPT_SUBNETMASK : constant Net.Uint8 := 1;
OPT_ROUTER : constant Net.Uint8 := 3;
OPT_DOMAIN_NAME_SERVER : constant Net.Uint8 := 6;
OPT_HOST_NAME : constant Net.Uint8 := 12;
OPT_DOMAIN_NAME : constant Net.Uint8 := 15;
OPT_MTU_SIZE : constant Net.Uint8 := 26;
OPT_BROADCAST_ADDR : constant Net.Uint8 := 28;
OPT_NTP_SERVER : constant Net.Uint8 := 42;
OPT_WWW_SERVER : constant Net.Uint8 := 72;
OPT_REQUESTED_IP : constant Net.Uint8 := 50;
OPT_LEASE_TIME : constant Net.Uint8 := 51;
OPT_MESSAGE_TYPE : constant Net.Uint8 := 53;
OPT_SERVER_IDENTIFIER : constant Net.Uint8 := 54;
OPT_PARAMETER_LIST : constant Net.Uint8 := 55;
OPT_RENEW_TIME : constant Net.Uint8 := 58;
OPT_REBIND_TIME : constant Net.Uint8 := 59;
OPT_VENDOR_CLASS : constant Net.Uint8 := 60;
OPT_CLIENT_IDENTIFIER : constant Net.Uint8 := 61;
OPT_END : constant Net.Uint8 := 255;
function Ellapsed (Request : in Client;
Now : in Ada.Real_Time.Time) return Net.Uint16;
protected body Machine is
function Get_State return State_Type is
begin
return State;
end Get_State;
-- ------------------------------
-- Set the new DHCP state.
-- ------------------------------
procedure Set_State (New_State : in State_Type) is
begin
State := New_State;
end Set_State;
-- ------------------------------
-- Set the DHCP options and the DHCP state to the STATE_BOUND.
-- ------------------------------
procedure Bind (Options : in Options_Type) is
begin
State := STATE_BOUND;
Config := Options;
end Bind;
-- ------------------------------
-- Get the DHCP options that were configured during the bind process.
-- ------------------------------
function Get_Config return Options_Type is
begin
return Config;
end Get_Config;
end Machine;
-- ------------------------------
-- Get the current DHCP client state.
-- ------------------------------
function Get_State (Request : in Client) return State_Type is
begin
return Request.Current;
end Get_State;
-- ------------------------------
-- Get the DHCP options that were configured during the bind process.
-- ------------------------------
function Get_Config (Request : in Client) return Options_Type is
begin
return Request.State.Get_Config;
end Get_Config;
-- ------------------------------
-- Initialize the DHCP request.
-- ------------------------------
procedure Initialize (Request : in out Client;
Ifnet : access Net.Interfaces.Ifnet_Type'Class) is
Addr : Net.Sockets.Sockaddr_In;
begin
Request.Ifnet := Ifnet;
Request.Mac := Ifnet.Mac;
Addr.Port := Net.Headers.To_Network (68);
Request.Bind (Ifnet, Addr);
-- Generate a XID for the DHCP process.
Request.Xid := Net.Utils.Random;
Request.Retry := 0;
Request.Configured := False;
Request.State.Set_State (STATE_INIT);
Request.Current := STATE_INIT;
end Initialize;
function Ellapsed (Request : in Client;
Now : in Ada.Real_Time.Time) return Net.Uint16 is
Dt : constant Ada.Real_Time.Time_Span := Now - Request.Start_Time;
begin
return Net.Uint16 (Ada.Real_Time.To_Duration (Dt));
end Ellapsed;
-- ------------------------------
-- Process the DHCP client. Depending on the DHCP state machine, proceed to the
-- discover, request, renew, rebind operations. Return in <tt>Next_Call</tt> the
-- deadline time before the next call.
-- ------------------------------
procedure Process (Request : in out Client;
Next_Call : out Ada.Real_Time.Time) is
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
New_State : constant State_Type := Request.State.Get_State;
begin
-- If the state machine has changed, we have received something from the server.
if Request.Current /= New_State then
case New_State is
-- We received a DHCPNACK. Wait 2 seconds before starting again the discovery.
when STATE_INIT =>
Request.Current := New_State;
Request.Timeout := Now + Ada.Real_Time.Seconds (Request.Pause_Delay);
Request.Xid := Net.Utils.Random;
Request.Retry := 0;
when STATE_REQUESTING =>
-- We received the DHCPOFFER, send the DHCPREQUEST.
Request.Current := New_State;
Request.Request;
when STATE_BOUND =>
-- We received the DHCPACK, configure and check that the address is not used.
if Request.Current = STATE_REQUESTING then
Request.Retry := 0;
Request.Timeout := Now;
Request.Current := STATE_DAD;
Client'Class (Request).Configure (Request.Ifnet.all, Request.State.Get_Config);
elsif Request.Current = STATE_RENEWING then
Client'Class (Request).Configure (Request.Ifnet.all, Request.State.Get_Config);
Request.Current := STATE_BOUND;
Request.Timeout := Request.Renew_Time;
end if;
when others =>
Request.Current := New_State;
end case;
end if;
case Request.Current is
when STATE_INIT | STATE_INIT_REBOOT =>
if Request.Timeout < Now then
Request.State.Set_State (STATE_SELECTING);
Request.Start_Time := Ada.Real_Time.Clock;
Request.Secs := 0;
Request.Current := STATE_SELECTING;
Request.Discover;
end if;
when STATE_SELECTING =>
if Request.Timeout < Now then
Request.Secs := Ellapsed (Request, Now);
Request.Discover;
end if;
when STATE_REQUESTING =>
if Request.Timeout < Now then
Request.Request;
end if;
when STATE_DAD =>
if Request.Timeout <= Now then
Request.Check_Address;
if Request.Get_State = STATE_BOUND then
Client'Class (Request).Bind (Request.Ifnet.all, Request.State.Get_Config);
end if;
end if;
when STATE_BOUND =>
if Request.Renew_Time < Now then
Request.Current := STATE_RENEWING;
Request.State.Set_State (STATE_RENEWING);
Request.Renew;
end if;
when STATE_RENEWING =>
if Request.Rebind_Time < Now then
Request.Current := STATE_REBINDING;
Request.State.Set_State (STATE_REBINDING);
end if;
when STATE_REBINDING =>
if Request.Expire_Time < Now then
Request.State.Set_State (STATE_INIT);
end if;
when others =>
null;
end case;
Next_Call := Request.Timeout;
end Process;
-- ------------------------------
-- Compute the next timeout according to the DHCP state.
-- ------------------------------
procedure Next_Timeout (Request : in out Client) is
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
case Request.Current is
when STATE_SELECTING | STATE_REQUESTING =>
-- Compute the timeout before sending the next discover.
if Request.Retry = Retry_Type'Last then
Request.Retry := 1;
else
Request.Retry := Request.Retry + 1;
end if;
Request.Timeout := Now + Ada.Real_Time.Seconds (Backoff (Request.Retry));
when STATE_DAD =>
Request.Retry := Request.Retry + 1;
Request.Timeout := Now + Ada.Real_Time.Seconds (1);
when others =>
Request.Timeout := Now + Ada.Real_Time.Seconds (1);
end case;
end Next_Timeout;
-- ------------------------------
-- Check for duplicate address on the network. If we find someone else using
-- the IP, send a DHCPDECLINE to the server. At the end of the DAD process,
-- switch to the STATE_BOUND state.
-- ------------------------------
procedure Check_Address (Request : in out Client) is
use type Net.Protos.Arp.Arp_Status;
Null_Packet : Net.Buffers.Buffer_Type;
Mac : Net.Ether_Addr;
Status : Net.Protos.Arp.Arp_Status;
begin
Net.Protos.Arp.Resolve (Ifnet => Request.Ifnet.all,
Target_Ip => Request.Ip,
Mac => Mac,
Packet => Null_Packet,
Status => Status);
if Status = Net.Protos.Arp.ARP_FOUND or Request.Retry = 5 then
Request.Decline;
elsif Request.Retry = 3 then
Request.State.Set_State (STATE_BOUND);
Request.Current := STATE_BOUND;
Request.Timeout := Request.Renew_Time;
else
Request.Next_Timeout;
end if;
end Check_Address;
-- ------------------------------
-- Fill the DHCP options in the request.
-- ------------------------------
procedure Fill_Options (Request : in Client;
Packet : in out Net.Buffers.Buffer_Type;
Kind : in Net.Uint8;
Mac : in Net.Ether_Addr) is
begin
-- DHCP magic cookie.
Packet.Put_Uint8 (99);
Packet.Put_Uint8 (130);
Packet.Put_Uint8 (83);
Packet.Put_Uint8 (99);
-- Option 53: DHCP message type
Packet.Put_Uint8 (OPT_MESSAGE_TYPE);
Packet.Put_Uint8 (1);
Packet.Put_Uint8 (Kind); -- Discover
-- Option 50: Requested IP Address
if not (Request.Current in STATE_SELECTING | STATE_RENEWING | STATE_REBINDING) then
Packet.Put_Uint8 (OPT_REQUESTED_IP);
Packet.Put_Uint8 (4);
Packet.Put_Ip (Request.Ip);
end if;
-- Option 54: DHCP Server Identifier.
if not (Request.Current in STATE_BOUND | STATE_RENEWING | STATE_REBINDING) then
Packet.Put_Uint8 (54);
Packet.Put_Uint8 (4);
Packet.Put_Ip (Request.Server_Ip);
end if;
if Kind /= DHCP_DECLINE then
-- Option 55: Parameter request List
Packet.Put_Uint8 (OPT_PARAMETER_LIST);
Packet.Put_Uint8 (12);
Packet.Put_Uint8 (OPT_SUBNETMASK);
Packet.Put_Uint8 (OPT_ROUTER);
Packet.Put_Uint8 (OPT_DOMAIN_NAME_SERVER);
Packet.Put_Uint8 (OPT_HOST_NAME);
Packet.Put_Uint8 (OPT_DOMAIN_NAME);
Packet.Put_Uint8 (OPT_MTU_SIZE);
Packet.Put_Uint8 (OPT_BROADCAST_ADDR);
Packet.Put_Uint8 (OPT_NTP_SERVER);
Packet.Put_Uint8 (OPT_WWW_SERVER);
Packet.Put_Uint8 (OPT_LEASE_TIME);
Packet.Put_Uint8 (OPT_RENEW_TIME);
Packet.Put_Uint8 (OPT_REBIND_TIME);
end if;
if Kind /= DHCP_DECLINE and Kind /= DHCP_RELEASE then
-- Option 60: Vendor class identifier.
Packet.Put_Uint8 (OPT_VENDOR_CLASS);
Packet.Put_Uint8 (DEF_VENDOR_CLASS'Length);
Packet.Put_String (DEF_VENDOR_CLASS);
end if;
-- Option 61: Client identifier;
Packet.Put_Uint8 (OPT_CLIENT_IDENTIFIER);
Packet.Put_Uint8 (7);
Packet.Put_Uint8 (1); -- Hardware type: Ethernet
for V of Mac loop
Packet.Put_Uint8 (V);
end loop;
-- Option 255: End
Packet.Put_Uint8 (OPT_END);
end Fill_Options;
-- ------------------------------
-- Extract the DHCP options from the DHCP packet.
-- ------------------------------
procedure Extract_Options (Packet : in out Net.Buffers.Buffer_Type;
Options : out Options_Type) is
Option : Net.Uint8;
Length : Net.Uint8;
Msg_Type : Net.Uint8;
begin
Options.Msg_Type := 0;
-- We must still have data to extract.
if Packet.Available <= 4 then
return;
end if;
if Packet.Get_Uint8 /= 99 then
return;
end if;
if Packet.Get_Uint8 /= 130 then
return;
end if;
if Packet.Get_Uint8 /= 83 then
return;
end if;
if Packet.Get_Uint8 /= 99 then
return;
end if;
while Packet.Available > 0 loop
Option := Packet.Get_Uint8;
if Option = OPT_END then
Options.Msg_Type := Msg_Type;
return;
elsif Option /= OPT_PAD and Packet.Available > 0 then
Length := Packet.Get_Uint8;
-- If there is not enough data in the packet, abort.
exit when Packet.Available < Net.Uint16 (Length);
case Option is
when OPT_MESSAGE_TYPE =>
exit when Length /= 1;
Msg_Type := Packet.Get_Uint8;
when OPT_SUBNETMASK =>
exit when Length /= 4;
Options.Netmask := Packet.Get_Ip;
when OPT_ROUTER =>
-- The length must be a multiple of 4.
exit when Length = 0 or (Length mod 4) /= 0;
Options.Router := Packet.Get_Ip;
if Length > 4 then
-- Still more IPv4 addresses, ignore them.
Packet.Skip (Net.Uint16 (Length - 4));
end if;
when OPT_REQUESTED_IP =>
exit when Length /= 4;
Options.Ip := Packet.Get_Ip;
when OPT_DOMAIN_NAME_SERVER =>
-- The length must be a multiple of 4.
exit when Length = 0 or (Length mod 4) /= 0;
Options.Dns1 := Packet.Get_Ip;
if Length > 4 then
Options.Dns2 := Packet.Get_Ip;
if Length > 8 then
-- Still more IPv4 addresses, ignore them.
Packet.Skip (Net.Uint16 (Length - 8));
end if;
end if;
when OPT_SERVER_IDENTIFIER =>
exit when Length /= 4;
Options.Server := Packet.Get_Ip;
when OPT_REBIND_TIME =>
exit when Length /= 4;
Options.Rebind_Time := Natural (Packet.Get_Uint32);
when OPT_RENEW_TIME =>
exit when Length /= 4;
Options.Renew_Time := Natural (Packet.Get_Uint32);
when OPT_LEASE_TIME =>
exit when Length /= 4;
Options.Lease_Time := Natural (Packet.Get_Uint32);
when OPT_NTP_SERVER =>
-- The length must be a multiple of 4.
exit when Length = 0 or (Length mod 4) /= 0;
Options.Ntp := Packet.Get_Ip;
if Length > 4 then
-- Still more IPv4 addresses, ignore them.
Packet.Skip (Net.Uint16 (Length - 4));
end if;
when OPT_WWW_SERVER =>
-- The length must be a multiple of 4.
exit when Length = 0 or (Length mod 4) /= 0;
Options.Www := Packet.Get_Ip;
if Length > 4 then
-- Still more IPv4 addresses, ignore them.
Packet.Skip (Net.Uint16 (Length - 4));
end if;
when OPT_MTU_SIZE =>
exit when Length /= 2;
Options.Mtu := Ip_Length (Packet.Get_Uint16);
when OPT_BROADCAST_ADDR =>
exit when Length /= 4;
Options.Broadcast := Packet.Get_Ip;
when OPT_HOST_NAME =>
Options.Hostname_Len := Natural (Length);
Packet.Get_String (Options.Hostname (1 .. Options.Hostname_Len));
when OPT_DOMAIN_NAME =>
Options.Domain_Len := Natural (Length);
Packet.Get_String (Options.Domain (1 .. Options.Domain_Len));
when others =>
Packet.Skip (Net.Uint16 (Length));
end case;
end if;
end loop;
-- This DHCP packet is invalid, return with a Msg_Type cleared.
end Extract_Options;
-- ------------------------------
-- Send the DHCP discover packet to initiate the DHCP discovery process.
-- ------------------------------
procedure Discover (Request : in out Client) is
Packet : Net.Buffers.Buffer_Type;
Hdr : Net.Headers.DHCP_Header_Access;
begin
Net.Buffers.Allocate (Packet);
Packet.Set_Type (Net.Buffers.DHCP_PACKET);
Hdr := Packet.DHCP;
-- Fill the DHCP header.
Hdr.Op := 1;
Hdr.Htype := 1;
Hdr.Hlen := 6;
Hdr.Hops := 0;
Hdr.Flags := 0;
Hdr.Xid1 := Net.Uint16 (Request.Xid and 16#0ffff#);
Hdr.Xid2 := Net.Uint16 (Shift_Right (Request.Xid, 16));
Hdr.Secs := Net.Headers.To_Network (Request.Secs);
Hdr.Ciaddr := (0, 0, 0, 0);
Hdr.Yiaddr := (0, 0, 0, 0);
Hdr.Siaddr := (0, 0, 0, 0);
Hdr.Giaddr := (0, 0, 0, 0);
Hdr.Chaddr := (others => Character'Val (0));
for I in 1 .. 6 loop
Hdr.Chaddr (I) := Character'Val (Request.Mac (I));
end loop;
Hdr.Sname := (others => Character'Val (0));
Hdr.File := (others => Character'Val (0));
Fill_Options (Request, Packet, DHCP_DISCOVER, Request.Mac);
-- Broadcast the DHCP packet.
Request.Send (Packet);
Request.Next_Timeout;
end Discover;
-- ------------------------------
-- Send the DHCP request packet after we received an offer.
-- ------------------------------
procedure Request (Request : in out Client) is
Packet : Net.Buffers.Buffer_Type;
Hdr : Net.Headers.DHCP_Header_Access;
State : constant State_Type := Request.Current;
begin
Net.Buffers.Allocate (Packet);
Packet.Set_Type (Net.Buffers.DHCP_PACKET);
Hdr := Packet.DHCP;
-- Fill the DHCP header.
Hdr.Op := 1;
Hdr.Htype := 1;
Hdr.Hlen := 6;
Hdr.Hops := 0;
Hdr.Flags := 0;
Hdr.Xid1 := Net.Uint16 (Request.Xid and 16#0ffff#);
Hdr.Xid2 := Net.Uint16 (Shift_Right (Request.Xid, 16));
Hdr.Secs := Net.Headers.To_Network (Request.Secs);
if State = STATE_RENEWING then
Hdr.Ciaddr := Request.Ip;
else
Hdr.Ciaddr := (0, 0, 0, 0);
end if;
Hdr.Yiaddr := (0, 0, 0, 0);
Hdr.Siaddr := (0, 0, 0, 0);
Hdr.Giaddr := (0, 0, 0, 0);
Hdr.Chaddr := (others => Character'Val (0));
for I in 1 .. 6 loop
Hdr.Chaddr (I) := Character'Val (Request.Mac (I));
end loop;
Hdr.Sname := (others => Character'Val (0));
Hdr.File := (others => Character'Val (0));
Fill_Options (Request, Packet, DHCP_REQUEST, Request.Mac);
-- Broadcast the DHCP packet.
Request.Send (Packet);
Request.Next_Timeout;
end Request;
-- ------------------------------
-- Send the DHCPDECLINE message to notify the DHCP server that we refuse the IP
-- because the DAD discovered that the address is used.
-- ------------------------------
procedure Decline (Request : in out Client) is
Packet : Net.Buffers.Buffer_Type;
Hdr : Net.Headers.DHCP_Header_Access;
To : Net.Sockets.Sockaddr_In;
Status : Error_Code;
begin
Net.Buffers.Allocate (Packet);
Packet.Set_Type (Net.Buffers.DHCP_PACKET);
Hdr := Packet.DHCP;
-- Fill the DHCP header.
Hdr.Op := 1;
Hdr.Htype := 1;
Hdr.Hlen := 6;
Hdr.Hops := 0;
Hdr.Flags := 0;
Hdr.Xid1 := Net.Uint16 (Request.Xid and 16#0ffff#);
Hdr.Xid2 := Net.Uint16 (Shift_Right (Request.Xid, 16));
Hdr.Secs := 0;
Hdr.Ciaddr := (0, 0, 0, 0);
Hdr.Yiaddr := (0, 0, 0, 0);
Hdr.Siaddr := (0, 0, 0, 0);
Hdr.Giaddr := (0, 0, 0, 0);
Hdr.Chaddr := (others => Character'Val (0));
for I in 1 .. 6 loop
Hdr.Chaddr (I) := Character'Val (Request.Mac (I));
end loop;
Hdr.Sname := (others => Character'Val (0));
Hdr.File := (others => Character'Val (0));
Fill_Options (Request, Packet, DHCP_DECLINE, Request.Mac);
-- Send the DHCP decline to the server (unicast).
To.Addr := Request.Server_Ip;
To.Port := Net.Headers.To_Network (67);
Request.Send (To, Packet, Status);
Request.State.Set_State (STATE_INIT);
end Decline;
-- ------------------------------
-- Send the DHCPREQUEST in unicast to the DHCP server to renew the DHCP lease.
-- ------------------------------
procedure Renew (Request : in out Client) is
Packet : Net.Buffers.Buffer_Type;
Hdr : Net.Headers.DHCP_Header_Access;
To : Net.Sockets.Sockaddr_In;
Status : Error_Code;
begin
Net.Buffers.Allocate (Packet);
Packet.Set_Type (Net.Buffers.DHCP_PACKET);
Hdr := Packet.DHCP;
-- Fill the DHCP header.
Hdr.Op := 1;
Hdr.Htype := 1;
Hdr.Hlen := 6;
Hdr.Hops := 0;
Hdr.Flags := 0;
Hdr.Xid1 := Net.Uint16 (Request.Xid and 16#0ffff#);
Hdr.Xid2 := Net.Uint16 (Shift_Right (Request.Xid, 16));
Hdr.Secs := 0;
Hdr.Ciaddr := Request.Ip;
Hdr.Yiaddr := (0, 0, 0, 0);
Hdr.Siaddr := (0, 0, 0, 0);
Hdr.Giaddr := (0, 0, 0, 0);
Hdr.Chaddr := (others => Character'Val (0));
for I in 1 .. 6 loop
Hdr.Chaddr (I) := Character'Val (Request.Mac (I));
end loop;
Hdr.Sname := (others => Character'Val (0));
Hdr.File := (others => Character'Val (0));
Fill_Options (Request, Packet, DHCP_REQUEST, Request.Mac);
-- Send the DHCP decline to the server (unicast).
To.Addr := Request.Server_Ip;
To.Port := Net.Headers.To_Network (67);
Request.Send (To, Packet, Status);
Request.Next_Timeout;
end Renew;
-- ------------------------------
-- Configure the IP stack and the interface after the DHCP ACK is received.
-- The interface is configured to use the IP address, the ARP cache is flushed
-- so that the duplicate address check can be made.
-- ------------------------------
procedure Configure (Request : in out Client;
Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Config : in Options_Type) is
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
Request.Expire_Time := Now + Ada.Real_Time.Seconds (Config.Lease_Time);
if Config.Renew_Time = 0 then
Request.Renew_Time := Now + Ada.Real_Time.Seconds (Config.Lease_Time / 2);
else
Request.Renew_Time := Now + Ada.Real_Time.Seconds (Config.Renew_Time);
end if;
if Config.Rebind_Time = 0 then
Request.Rebind_Time := Now + Ada.Real_Time.Seconds (3 * Config.Lease_Time / 2);
else
Request.Rebind_Time := Now + Ada.Real_Time.Seconds (Config.Rebind_Time);
end if;
Ifnet.Ip := Config.Ip;
Ifnet.Netmask := Config.Netmask;
Ifnet.Gateway := Config.Router;
Ifnet.Mtu := Config.Mtu;
Ifnet.Dns := Config.Dns1;
Request.Configured := True;
end Configure;
-- ------------------------------
-- Bind the interface with the DHCP configuration that was recieved by the DHCP ACK.
-- This operation is called by the <tt>Process</tt> procedure when the BOUND state
-- is entered. It can be overriden to perform specific actions.
-- ------------------------------
procedure Bind (Request : in out Client;
Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Config : in Options_Type) is
begin
null;
end Bind;
-- ------------------------------
-- Update the UDP header for the packet and send it.
-- ------------------------------
overriding
procedure Send (Request : in out Client;
Packet : in out Net.Buffers.Buffer_Type) is
Ether : constant Net.Headers.Ether_Header_Access := Packet.Ethernet;
Ip : constant Net.Headers.IP_Header_Access := Packet.IP;
Udp : constant Net.Headers.UDP_Header_Access := Packet.UDP;
Len : Net.Uint16;
begin
-- Get the packet length and setup the UDP header.
Len := Packet.Get_Data_Size (Net.Buffers.IP_PACKET);
Packet.Set_Length (Len + 20 + 14);
Udp.Uh_Sport := Net.Headers.To_Network (68);
Udp.Uh_Dport := Net.Headers.To_Network (67);
Udp.Uh_Ulen := Net.Headers.To_Network (Len);
Udp.Uh_Sum := 0;
-- Set the IP header to broadcast the packet.
Net.Protos.IPv4.Make_Header (Ip, (0, 0, 0, 0), (255, 255, 255, 255),
Net.Protos.IPv4.P_UDP, Uint16 (Len + 20));
-- And set the Ethernet header for the broadcast.
Ether.Ether_Shost := Request.Mac;
Ether.Ether_Dhost := (others => 16#ff#);
Ether.Ether_Type := Net.Headers.To_Network (Net.Protos.ETHERTYPE_IP);
-- Broadcast the DHCP packet.
Net.Sockets.Udp.Raw_Socket (Request).Send (Packet);
end Send;
-- ------------------------------
-- Receive the DHCP offer/ack/nak from the DHCP server and update the DHCP state machine.
-- It only updates the DHCP state machine (the DHCP request are only sent by
-- <tt>Process</tt>).
-- ------------------------------
overriding
procedure Receive (Request : in out Client;
From : in Net.Sockets.Sockaddr_In;
Packet : in out Net.Buffers.Buffer_Type) is
Hdr : constant Net.Headers.DHCP_Header_Access := Packet.DHCP;
Options : Options_Type;
State : constant State_Type := Request.Get_State;
begin
if Hdr.Op /= 2 or Hdr.Htype /= 1 or Hdr.Hlen /= 6 then
return;
end if;
if Hdr.Xid1 /= Net.Uint16 (Request.Xid and 16#0ffff#) then
return;
end if;
if Hdr.Xid2 /= Net.Uint16 (Shift_Right (Request.Xid, 16)) then
return;
end if;
for I in 1 .. 6 loop
if Character'Pos (Hdr.Chaddr (I)) /= Request.Mac (I) then
return;
end if;
end loop;
Packet.Set_Type (Net.Buffers.DHCP_PACKET);
Extract_Options (Packet, Options);
if Options.Msg_Type = DHCP_OFFER and State = STATE_SELECTING then
Request.Ip := Hdr.Yiaddr;
Request.Server_Ip := From.Addr;
Request.State.Set_State (STATE_REQUESTING);
elsif Options.Msg_Type = DHCP_ACK and State = STATE_REQUESTING then
Options.Ip := Hdr.Yiaddr;
Request.State.Bind (Options);
elsif Options.Msg_Type = DHCP_ACK and State = STATE_RENEWING then
Options.Ip := Hdr.Yiaddr;
Request.State.Bind (Options);
elsif Options.Msg_Type = DHCP_NACK and State = STATE_REQUESTING then
Request.State.Set_State (STATE_INIT);
end if;
end Receive;
end Net.DHCP;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Finalization;
with Yaml.Destination;
with Yaml.Stream_Concept;
with Yaml.Stacks;
package Yaml.Presenter is
type Instance is tagged limited private;
type Buffer_Type is access all String;
subtype Line_Length_Type is Integer range 20 .. Integer'Last;
Default_Line_Length : constant Line_Length_Type := 80;
type Flow_Style_Type is (Compact, Canonical);
procedure Configure (P : in out Instance; Max_Line_Length : Line_Length_Type;
Flow_Style : Flow_Style_Type);
procedure Set_Output (P : in out Instance;
D : not null Destination.Pointer);
procedure Set_Output (P : in out Instance;
Buffer : not null Buffer_Type);
procedure Put (P : in out Instance; E : Event);
generic
with package Stream is new Stream_Concept (<>);
procedure Consume (P : in out Instance;
S : in out Stream.Instance);
procedure Flush (P : in out Instance);
private
type Position_Type is
(Before_Stream_Start, After_Stream_End, Before_Doc_Start,
After_Directives_End, After_Implicit_Doc_Start, Before_Doc_End,
After_Implicit_Doc_End, After_Implicit_Map_Start, After_Map_Header,
After_Flow_Map_Start, After_Implicit_Block_Map_Key,
After_Explicit_Block_Map_Key, After_Block_Map_Value, After_Seq_Header,
After_Implicit_Seq_Start, After_Flow_Seq_Start, After_Block_Seq_Item,
After_Flow_Map_Key, After_Flow_Map_Value, After_Flow_Seq_Item,
After_Annotation_Name, After_Annotation_Param);
type Level is record
Position : Position_Type;
Indentation : Integer;
end record;
package Level_Stacks is new Yaml.Stacks (Level);
type Instance is new Ada.Finalization.Limited_Controlled with record
Max_Line_Length : Line_Length_Type := Default_Line_Length;
Flow_Style : Flow_Style_Type := Compact;
Cur_Column : Positive;
Cur_Max_Column : Positive;
Buffer_Pos : Positive;
Buffer : Buffer_Type;
Dest : Destination.Pointer;
Levels : Level_Stacks.Stack;
end record;
overriding procedure Finalize (Object : in out Instance);
end Yaml.Presenter;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . T R A C E B A C K --
-- (HP/UX Version) --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1999-2001 Ada Core Technologies, 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 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body System.Traceback is
-- This package implements the backtracing facility by way of a dedicated
-- HP library for stack unwinding described in the "Runtime Architecture
-- Document".
pragma Linker_Options ("/usr/lib/libcl.a");
-- The library basically offers services to fetch information about a
-- "previous" frame based on information about a "current" one.
type Current_Frame_Descriptor is record
cur_fsz : Address; -- Frame size of current routine.
cur_sp : Address; -- The current value of stack pointer.
cur_rls : Address; -- PC-space of the caller.
cur_rlo : Address; -- PC-offset of the caller.
cur_dp : Address; -- Data Pointer of the current routine.
top_rp : Address; -- Initial value of RP.
top_mrp : Address; -- Initial value of MRP.
top_sr0 : Address; -- Initial value of sr0.
top_sr4 : Address; -- Initial value of sr4.
top_r3 : Address; -- Initial value of gr3.
cur_r19 : Address; -- GR19 value of the calling routine.
top_r4 : Address; -- Initial value of gr4.
dummy : Address; -- Reserved.
out_rlo : Address; -- PC-offset of the caller after get_previous.
end record;
type Previous_Frame_Descriptor is record
prev_fsz : Address; -- frame size of calling routine.
prev_sp : Address; -- SP of calling routine.
prev_rls : Address; -- PC_space of calling routine's caller.
prev_rlo : Address; -- PC_offset of calling routine's caller.
prev_dp : Address; -- DP of calling routine.
udescr0 : Address; -- low word of calling routine's unwind desc.
udescr1 : Address; -- high word of calling routine's unwind desc.
ustart : Address; -- start of the unwind region.
uend : Address; -- end of the unwind region.
uw_index : Address; -- index into the unwind table.
prev_r19 : Address; -- GR19 value of the caller's caller.
top_r3 : Address; -- Caller's initial gr3.
top_r4 : Address; -- Caller's initial gr4.
end record;
-- Provide useful shortcuts for the names
subtype CFD is Current_Frame_Descriptor;
subtype PFD is Previous_Frame_Descriptor;
-- Frames with dynamic stack allocation are handled using the associated
-- frame pointer, but HP compilers and GCC setup this pointer differently.
-- HP compilers set it to point at the top (highest address) of the static
-- part of the frame, wheras GCC sets it to point at the bottom of this
-- region. We have to fake the unwinder to compensate for this difference,
-- for which we'll need to access some subprograms unwind descriptors.
type Bits_2_Value is mod 2 ** 2;
for Bits_2_Value'Size use 2;
type Bits_4_Value is mod 2 ** 4;
for Bits_4_Value'Size use 4;
type Bits_5_Value is mod 2 ** 5;
for Bits_5_Value'Size use 5;
type Bits_27_Value is mod 2 ** 27;
for Bits_27_Value'Size use 27;
type Unwind_Descriptor is record
cannot_unwind : Boolean;
mcode : Boolean;
mcode_save_restore : Boolean;
region_desc : Bits_2_Value;
reserved0 : Boolean;
entry_sr : Boolean;
entry_fr : Bits_4_Value;
entry_gr : Bits_5_Value;
args_stored : Boolean;
variable_frame : Boolean;
separate_package_body : Boolean;
frame_extension_mcode : Boolean;
stack_overflow_check : Boolean;
two_steps_sp_adjust : Boolean;
sr4_export : Boolean;
cxx_info : Boolean;
cxx_try_catch : Boolean;
sched_entry_seq : Boolean;
reserved1 : Boolean;
save_sp : Boolean;
save_rp : Boolean;
save_mrp : Boolean;
save_r19 : Boolean;
cleanups : Boolean;
hpe_interrupt_marker : Boolean;
hpux_interrupt_marker : Boolean;
large_frame : Boolean;
alloca_frame : Boolean;
reserved2 : Boolean;
frame_size : Bits_27_Value;
end record;
for Unwind_Descriptor'Size use 64;
for Unwind_Descriptor use record
cannot_unwind at 0 range 0 .. 0;
mcode at 0 range 1 .. 1;
mcode_save_restore at 0 range 2 .. 2;
region_desc at 0 range 3 .. 4;
reserved0 at 0 range 5 .. 5;
entry_sr at 0 range 6 .. 6;
entry_fr at 0 range 7 .. 10;
entry_gr at 1 range 3 .. 7;
args_stored at 2 range 0 .. 0;
variable_frame at 2 range 1 .. 1;
separate_package_body at 2 range 2 .. 2;
frame_extension_mcode at 2 range 3 .. 3;
stack_overflow_check at 2 range 4 .. 4;
two_steps_sp_adjust at 2 range 5 .. 5;
sr4_export at 2 range 6 .. 6;
cxx_info at 2 range 7 .. 7;
cxx_try_catch at 3 range 0 .. 0;
sched_entry_seq at 3 range 1 .. 1;
reserved1 at 3 range 2 .. 2;
save_sp at 3 range 3 .. 3;
save_rp at 3 range 4 .. 4;
save_mrp at 3 range 5 .. 5;
save_r19 at 3 range 6 .. 6;
cleanups at 3 range 7 .. 7;
hpe_interrupt_marker at 4 range 0 .. 0;
hpux_interrupt_marker at 4 range 1 .. 1;
large_frame at 4 range 2 .. 2;
alloca_frame at 4 range 3 .. 3;
reserved2 at 4 range 4 .. 4;
frame_size at 4 range 5 .. 31;
end record;
subtype UWD is Unwind_Descriptor;
type UWD_Ptr is access all UWD;
function To_UWD_Access is new Ada.Unchecked_Conversion (Address, UWD_Ptr);
-- The descriptor associated with a given code location is retrieved
-- using functions imported from the HP library, requiring the definition
-- of additional structures.
type Unwind_Table_Region is record
Table_Start : Address;
Table_End : Address;
end record;
-- An Unwind Table region, which is a memory area containing Unwind
-- Descriptors.
subtype UWT is Unwind_Table_Region;
type UWT_Ptr is access all UWT;
function To_UWT_Address is new Ada.Unchecked_Conversion (UWT_Ptr, Address);
-- The subprograms imported below are provided by the HP library
function U_get_unwind_table return UWT;
pragma Import (C, U_get_unwind_table, "U_get_unwind_table");
-- Get the unwind table region associated with the current executable.
-- This function is actually documented as having an argument, but which
-- is only used for the MPE/iX targets.
function U_get_shLib_unwind_table (r19 : Address) return UWT;
pragma Import (C, U_get_shLib_unwind_table, "U_get_shLib_unw_tbl");
-- Return the unwind table region associated with a possible shared
-- library, as determined by the provided r19 value.
function U_get_shLib_text_addr (r19 : Address) return Address;
pragma Import (C, U_get_shLib_text_addr, "U_get_shLib_text_addr");
-- Return the address at which the code for a shared library begins, or
-- -1 if the value provided for r19 does not identify shared library code.
function U_get_unwind_entry
(Pc : Address;
Space : Address;
Table_Start : Address;
Table_End : Address)
return Address;
pragma Import (C, U_get_unwind_entry, "U_get_unwind_entry");
-- Given the bounds of an unwind table, return the address of the
-- unwind descriptor associated with a code location/space. In the case
-- of shared library code, the offset from the beginning of the library
-- is expected as Pc.
procedure U_init_frame_record (Frame : access CFD);
pragma Import (C, U_init_frame_record, "U_init_frame_record");
procedure U_prep_frame_rec_for_unwind (Frame : access CFD);
pragma Import (C, U_prep_frame_rec_for_unwind,
"U_prep_frame_rec_for_unwind");
-- Fetch the description data of the frame in which these two procedures
-- are called.
function U_get_u_rlo (Cur : access CFD; Prev : access PFD) return Integer;
pragma Import (C, U_get_u_rlo, "U_IS_STUB_OR_CALLX");
-- From a complete current frame with a return location possibly located
-- into a linker generated stub, and basic information about the previous
-- frame, place the first non stub return location into the current frame.
-- Return -1 if something went wrong during the computation.
function U_is_shared_pc (rlo : Address; r19 : Address) return Address;
pragma Import (C, U_is_shared_pc, "U_is_shared_pc");
-- Return 0 if the provided return location does not correspond to code
-- in a shared library, or something non null otherwise.
function U_get_previous_frame_x
(current_frame : access CFD;
previous_frame : access PFD;
previous_size : Integer)
return Integer;
pragma Import (C, U_get_previous_frame_x, "U_get_previous_frame_x");
-- Fetch the data describing the "previous" frame relatively to the
-- "current" one. "previous_size" should be the size of the "previous"
-- frame descriptor provided.
--
-- The library provides a simpler interface without the size parameter
-- but it is not usable when frames with dynamically allocated space are
-- on the way.
------------------
-- C_Call_Chain --
------------------
function C_Call_Chain
(Traceback : System.Address;
Max_Len : Natural)
return Natural
is
Val : Natural;
begin
Call_Chain (Traceback, Max_Len, Val);
return Val;
end C_Call_Chain;
----------------
-- Call_Chain --
----------------
procedure Call_Chain
(Traceback : System.Address;
Max_Len : Natural;
Len : out Natural;
Exclude_Min : System.Address := System.Null_Address;
Exclude_Max : System.Address := System.Null_Address)
is
type Tracebacks_Array is array (1 .. Max_Len) of System.Address;
pragma Suppress_Initialization (Tracebacks_Array);
-- The code location returned by the unwinder is a return location but
-- what we need is a call point. Under HP-UX call instructions are 4
-- bytes long and the return point they specify is 4 bytes beyond the
-- next instruction because of the delay slot.
Call_Size : constant := 4;
DSlot_Size : constant := 4;
Rlo_Offset : constant := Call_Size + DSlot_Size;
-- Moreover, the return point is passed via a register which two least
-- significant bits specify a privilege level that we will have to mask.
Priv_Mask : constant := 16#00000003#;
Frame : aliased CFD;
Code : System.Address;
J : Natural := 1;
Pop_Success : Boolean;
Trace : Tracebacks_Array;
for Trace'Address use Traceback;
-- The backtracing process needs a set of subprograms :
function UWD_For_RLO_Of (Frame : access CFD) return UWD_Ptr;
-- Return an access to the unwind descriptor for the caller of
-- a given frame, using only the provided return location.
function UWD_For_Caller_Of (Frame : access CFD) return UWD_Ptr;
-- Return an access to the unwind descriptor for the user code caller
-- of a given frame, or null if the information is not available.
function Pop_Frame (Frame : access CFD) return Boolean;
-- Update the provided machine state structure so that it reflects
-- the state one call frame "above" the initial one.
--
-- Return True if the operation has been successful, False otherwise.
-- Failure typically occurs when the top of the call stack has been
-- reached.
function Prepare_For_Unwind_Of (Frame : access CFD) return Boolean;
-- Perform the necessary adaptations to the machine state before
-- calling the unwinder. Currently used for the specific case of
-- dynamically sized previous frames.
--
-- Return True if everything went fine, or False otherwise.
Program_UWT : constant UWT := U_get_unwind_table;
---------------
-- Pop_Frame --
---------------
function Pop_Frame (Frame : access CFD) return Boolean is
Up_Frame : aliased PFD;
State_Ready : Boolean;
begin
-- Check/adapt the state before calling the unwinder and return
-- if anything went wrong.
State_Ready := Prepare_For_Unwind_Of (Frame);
if not State_Ready then
return False;
end if;
-- Now, safely call the unwinder and use the results.
if U_get_previous_frame_x (Frame,
Up_Frame'Access,
Up_Frame'Size) /= 0
then
return False;
end if;
-- In case a stub is on the way, the usual previous return location
-- (the one in prev_rlo) is the one in the stub and the "real" one
-- is placed in the "current" record, so let's take this one into
-- account.
Frame.out_rlo := Frame.cur_rlo;
Frame.cur_fsz := Up_Frame.prev_fsz;
Frame.cur_sp := Up_Frame.prev_sp;
Frame.cur_rls := Up_Frame.prev_rls;
Frame.cur_rlo := Up_Frame.prev_rlo;
Frame.cur_dp := Up_Frame.prev_dp;
Frame.cur_r19 := Up_Frame.prev_r19;
Frame.top_r3 := Up_Frame.top_r3;
Frame.top_r4 := Up_Frame.top_r4;
return True;
end Pop_Frame;
---------------------------------
-- Prepare_State_For_Unwind_Of --
---------------------------------
function Prepare_For_Unwind_Of (Frame : access CFD) return Boolean
is
Caller_UWD : UWD_Ptr;
FP_Adjustment : Integer;
begin
-- No need to bother doing anything if the stack is already fully
-- unwound.
if Frame.cur_rlo = 0 then
return False;
end if;
-- When ALLOCA_FRAME is set in an unwind descriptor, the unwinder
-- uses the value provided in current.top_r3 or current.top_r4 as
-- a frame pointer to compute the size of the frame. What decides
-- between r3 or r4 is the unwind descriptor LARGE_FRAME bit, with
-- r4 chosen if the bit is set.
-- The size computed by the unwinder is STATIC_PART + (SP - FP),
-- which is correct with HP's frame pointer convention, but not
-- with GCC's one since we end up with the static part accounted
-- for twice.
-- We have to compute r4 when it is required because the unwinder
-- has looked for it at a place where it was not if we went through
-- GCC frames.
-- The size of the static part of a frame can be found in the
-- associated unwind descriptor.
Caller_UWD := UWD_For_Caller_Of (Frame);
-- If we cannot get it, we are unable to compute the potentially
-- necessary adjustments. We'd better not try to go on then.
if Caller_UWD = null then
return False;
end if;
-- If the caller frame is a GCC one, r3 is its frame pointer and
-- points to the bottom of the frame. The value to provide for r4
-- can then be computed directly from the one of r3, compensating
-- for the static part of the frame.
-- If the caller frame is an HP one, r3 is used to locate the
-- previous frame marker, that is it also points to the bottom of
-- the frame (this is why r3 cannot be used as the frame pointer in
-- the HP sense for large frames). The value to provide for r4 can
-- then also be computed from the one of r3 with the compensation
-- for the static part of the frame.
FP_Adjustment := Integer (Caller_UWD.frame_size * 8);
Frame.top_r4 := Address (Integer (Frame.top_r3) + FP_Adjustment);
return True;
end Prepare_For_Unwind_Of;
-----------------------
-- UWD_For_Caller_Of --
-----------------------
function UWD_For_Caller_Of (Frame : access CFD) return UWD_Ptr
is
UWD_Access : UWD_Ptr;
begin
-- First try the most direct path, using the return location data
-- associated with the frame.
UWD_Access := UWD_For_RLO_Of (Frame);
if UWD_Access /= null then
return UWD_Access;
end if;
-- If we did not get a result, we might face an in-stub return
-- address. In this case U_get_previous_frame can tell us what the
-- first not-in-stub return point is. We cannot call it directly,
-- though, because we haven't computed the potentially necessary
-- frame pointer adjustments, which might lead to SEGV in some
-- circumstances. Instead, we directly call the libcl routine which
-- is called by U_get_previous_frame and which only requires few
-- information. Take care, however, that the information is provided
-- in the "current" argument, so we need to work on a copy to avoid
-- disturbing our caller.
declare
U_Current : aliased CFD := Frame.all;
U_Previous : aliased PFD;
begin
U_Previous.prev_dp := U_Current.cur_dp;
U_Previous.prev_rls := U_Current.cur_rls;
U_Previous.prev_sp := U_Current.cur_sp - U_Current.cur_fsz;
if U_get_u_rlo (U_Current'Access, U_Previous'Access) /= -1 then
UWD_Access := UWD_For_RLO_Of (U_Current'Access);
end if;
end;
return UWD_Access;
end UWD_For_Caller_Of;
--------------------
-- UWD_For_RLO_Of --
--------------------
function UWD_For_RLO_Of (Frame : access CFD) return UWD_Ptr
is
UWD_Address : Address;
-- The addresses returned by the library point to full descriptors
-- including the frame information bits but also the applicable PC
-- range. We need to account for this.
Frame_Info_Offset : constant := 8;
begin
-- First try to locate the descriptor in the program's unwind table.
UWD_Address := U_get_unwind_entry (Frame.cur_rlo,
Frame.cur_rls,
Program_UWT.Table_Start,
Program_UWT.Table_End);
-- If we did not get it, we might have a frame from code in a
-- stub or shared library. For code in stub we would have to
-- compute the first non-stub return location but this is not
-- the role of this subprogram, so let's just try to see if we
-- can get a result from the tables in shared libraries.
if UWD_Address = -1
and then U_is_shared_pc (Frame.cur_rlo, Frame.cur_r19) /= 0
then
declare
Shlib_UWT : UWT := U_get_shLib_unwind_table (Frame.cur_r19);
Shlib_Start : Address := U_get_shLib_text_addr (Frame.cur_r19);
Rlo_Offset : Address := Frame.cur_rlo - Shlib_Start;
begin
UWD_Address := U_get_unwind_entry (Rlo_Offset,
Frame.cur_rls,
Shlib_UWT.Table_Start,
Shlib_UWT.Table_End);
end;
end if;
if UWD_Address /= -1 then
return To_UWD_Access (UWD_Address + Frame_Info_Offset);
else
return null;
end if;
end UWD_For_RLO_Of;
-- Start of processing for Call_Chain
begin
-- Fetch the state for this subprogram's frame and pop it so that the
-- backtrace starts at the right point for our caller, that is at its
-- own frame.
U_init_frame_record (Frame'Access);
Frame.top_sr0 := 0;
Frame.top_sr4 := 0;
U_prep_frame_rec_for_unwind (Frame'Access);
Pop_Success := Pop_Frame (Frame'Access);
-- Loop popping frames and storing locations until either a problem
-- occurs, or the top of the call chain is reached, or the provided
-- array is full.
loop
-- We have to test some conditions against the return location
-- as it is returned, so get it as is first.
Code := Frame.out_rlo;
exit when not Pop_Success or else Code = 0 or else J = Max_Len + 1;
-- Compute the call point from the retrieved return location :
-- Mask the privilege bits and account for the delta between the
-- call site and the return point.
Code := (Code and not Priv_Mask) - Rlo_Offset;
if Code < Exclude_Min or else Code > Exclude_Max then
Trace (J) := Code;
J := J + 1;
end if;
Pop_Success := Pop_Frame (Frame'Access);
end loop;
Len := J - 1;
end Call_Chain;
end System.Traceback;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2017, Vadim Godunko <vgodunko@gmail.com> --
-- 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 WebAPI.DOM.Event_Targets;
with WebAPI.HTML.Documents;
with WebAPI.HTML.Frame_Request_Callbacks;
package WebAPI.HTML.Windows is
pragma Preelaborate;
type Window is limited interface
and WebAPI.DOM.Event_Targets.Event_Target;
type Window_Access is access all Window'Class
with Storage_Size => 0;
not overriding function Get_Document
(Self : not null access Window)
return WebAPI.HTML.Documents.Document_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "document";
-- APIs for creating and navigating browsing contexts by name
not overriding function Open
(Self : not null access WebAPI.HTML.Windows.Window;
URL : WebAPI.DOM_String;
Name : WebAPI.DOM_String;
Features : WebAPI.DOM_String)
return WebAPI.HTML.Windows.Window_Access is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "open";
-- Opens a window to show url (defaults to about:blank), and returns it.
-- The target argument gives the name of the new window. If a window
-- exists with that name already, it is reused. The features argument
-- can be used to influence the rendering of the new window.
not overriding function Get_Name
(Self : not null access Window)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "name";
-- Returns the name of the window. Can be set, to change the name.
not overriding procedure Set_Name
(Self : not null access Window;
Value : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "name";
not overriding procedure Close
(Self : not null access WebAPI.HTML.Windows.Window) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "close";
-- Closes the window.
not overriding function Get_Closed
(Self : not null access Window)
return WebAPI.DOM_Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "closed";
-- Returns true if the window has been closed, false otherwise.
not overriding procedure Stop
(Self : not null access WebAPI.HTML.Windows.Window) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stop";
-- Cancels the document load.
-- other browsing contexts
not overriding function Get_Opener
(Self : not null access Window)
return WebAPI.HTML.Windows.Window_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "opener";
-- The opener IDL attribute on the Window object, on getting, must return
-- the WindowProxy object of the browsing context from which the current
-- browsing context was created (its opener browsing context), if there is
-- one, if it is still available, and if the current browsing context has
-- not disowned its opener; otherwise, it must return null.
not overriding procedure Set_Opener
(Self : not null access Window;
Value : WebAPI.HTML.Windows.Window_Access) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "opener";
-- On setting, if the new value is null then the current browsing context
-- must disown its opener;
function Request_Animation_Frame
(Self : not null access Window'Class;
Callback : not null access
WebAPI.HTML.Frame_Request_Callbacks.Frame_Request_Callback'Class)
return WebAPI.DOM_Long
with Import => True,
Convention => JavaScript_Function,
Link_Name => "_ec._requestAnimationFrame";
procedure Request_Animation_Frame
(Self : not null access Window'Class;
Callback : not null access
WebAPI.HTML.Frame_Request_Callbacks.Frame_Request_Callback'Class)
with Import => True,
Convention => JavaScript_Function,
Link_Name => "_ec._requestAnimationFrame";
-- This subprogram is used to signal to the user agent that a script-based
-- animation needs to be resampled.
not overriding procedure Cancel_Animation_Frame
(Self : not null access Window;
Handle : WebAPI.DOM_Long) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "cancelAnimationFrame";
-- This subprogram is used to cancel a previously made request to schedule
-- an animation frame update.
----------------------------------
-- CSSOM View Module extensions --
----------------------------------
-- [NewObject] MediaQueryList matchMedia(DOMString query);
-- [SameObject, Replaceable] readonly attribute Screen screen;
--
-- // browsing context
-- void moveTo(long x, long y);
-- void moveBy(long x, long y);
-- void resizeTo(long x, long y);
-- void resizeBy(long x, long y);
not overriding function Get_Inner_Width
(Self : not null access Window)
return WebAPI.DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "innerWidth";
not overriding function Get_Inner_Height
(Self : not null access Window)
return WebAPI.DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "innerHeight";
not overriding function Get_Scroll_X
(Self : not null access Window)
return WebAPI.DOM_Double is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "scrollX";
not overriding function Get_Page_X_Offset
(Self : not null access Window)
return WebAPI.DOM_Double is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "pageXOffset";
not overriding function Get_Scroll_Y
(Self : not null access Window)
return WebAPI.DOM_Double is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "scrollY";
not overriding function Get_Page_Y_Offset
(Self : not null access Window)
return WebAPI.DOM_Double is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "pageYOffset";
-- void scroll(optional ScrollToOptions options);
-- void scroll(unrestricted double x, unrestricted double y);
-- void scrollTo(optional ScrollToOptions options);
-- void scrollTo(unrestricted double x, unrestricted double y);
-- void scrollBy(optional ScrollToOptions options);
-- void scrollBy(unrestricted double x, unrestricted double y);
not overriding function Get_Screen_X
(Self : not null access Window)
return WebAPI.DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "screenX";
not overriding function Get_Screen_Y
(Self : not null access Window)
return WebAPI.DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "screenY";
not overriding function Get_Outer_Width
(Self : not null access Window)
return WebAPI.DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "outerWidth";
not overriding function Get_Outer_Height
(Self : not null access Window)
return WebAPI.DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "outerHeight";
not overriding function Get_Device_Pixel_Ratio
(Self : not null access Window)
return WebAPI.DOM_Double is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "devicePixelRatio";
end WebAPI.HTML.Windows;
|
with Ahven.Text_Runner;
with Ahven.Framework;
with Gilded_Rose_Tests;
procedure Gilded_Rose_Tester is
S : Ahven.Framework.Test_Suite := Ahven.Framework.Create_Suite("All");
begin
Ahven.Framework.Add_Test(S, new Gilded_Rose_Tests.Test);
Ahven.Text_Runner.Run(S);
end Gilded_Rose_Tester;
|
-----------------------------------------------------------------------
-- AWA.Countries.Models -- AWA.Countries.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off, "unit * is not referenced");
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic.Lists;
pragma Warnings (On, "unit * is not referenced");
package AWA.Countries.Models is
type Country_Ref is new ADO.Objects.Object_Ref with null record;
type City_Ref is new ADO.Objects.Object_Ref with null record;
type Country_Neighbor_Ref is new ADO.Objects.Object_Ref with null record;
type Region_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- The country model is a system data model for the application.
-- In theory, it never changes.
-- --------------------
-- Create an object key for Country.
function Country_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Country from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Country_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Country : constant Country_Ref;
function "=" (Left, Right : Country_Ref'Class) return Boolean;
-- Set the country identifier
procedure Set_Id (Object : in out Country_Ref;
Value : in ADO.Identifier);
-- Get the country identifier
function Get_Id (Object : in Country_Ref)
return ADO.Identifier;
-- Set the country name
procedure Set_Name (Object : in out Country_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Country_Ref;
Value : in String);
-- Get the country name
function Get_Name (Object : in Country_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Country_Ref)
return String;
-- Set the continent name
procedure Set_Continent (Object : in out Country_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Continent (Object : in out Country_Ref;
Value : in String);
-- Get the continent name
function Get_Continent (Object : in Country_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Continent (Object : in Country_Ref)
return String;
-- Set the currency used in the country
procedure Set_Currency (Object : in out Country_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Currency (Object : in out Country_Ref;
Value : in String);
-- Get the currency used in the country
function Get_Currency (Object : in Country_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Currency (Object : in Country_Ref)
return String;
-- Set the country ISO code
procedure Set_Iso_Code (Object : in out Country_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Iso_Code (Object : in out Country_Ref;
Value : in String);
-- Get the country ISO code
function Get_Iso_Code (Object : in Country_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Iso_Code (Object : in Country_Ref)
return String;
-- Set the country geoname id
procedure Set_Geonameid (Object : in out Country_Ref;
Value : in Integer);
-- Get the country geoname id
function Get_Geonameid (Object : in Country_Ref)
return Integer;
-- Set the country main language
procedure Set_Languages (Object : in out Country_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Languages (Object : in out Country_Ref;
Value : in String);
-- Get the country main language
function Get_Languages (Object : in Country_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Languages (Object : in Country_Ref)
return String;
-- Set the TLD associated with this country
procedure Set_Tld (Object : in out Country_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Tld (Object : in out Country_Ref;
Value : in String);
-- Get the TLD associated with this country
function Get_Tld (Object : in Country_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Tld (Object : in Country_Ref)
return String;
-- Set the currency code
procedure Set_Currency_Code (Object : in out Country_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Currency_Code (Object : in out Country_Ref;
Value : in String);
-- Get the currency code
function Get_Currency_Code (Object : in Country_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Currency_Code (Object : in Country_Ref)
return String;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Country_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Country_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Country_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Country_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Country_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Country_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
COUNTRY_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Country_Ref);
-- Copy of the object.
procedure Copy (Object : in Country_Ref;
Into : in out Country_Ref);
-- Create an object key for City.
function City_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for City from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function City_Key (Id : in String) return ADO.Objects.Object_Key;
Null_City : constant City_Ref;
function "=" (Left, Right : City_Ref'Class) return Boolean;
-- Set the city identifier
procedure Set_Id (Object : in out City_Ref;
Value : in ADO.Identifier);
-- Get the city identifier
function Get_Id (Object : in City_Ref)
return ADO.Identifier;
-- Set the city name
procedure Set_Name (Object : in out City_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out City_Ref;
Value : in String);
-- Get the city name
function Get_Name (Object : in City_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in City_Ref)
return String;
-- Set the city ZIP code
procedure Set_Zip_Code (Object : in out City_Ref;
Value : in Integer);
-- Get the city ZIP code
function Get_Zip_Code (Object : in City_Ref)
return Integer;
-- Set the city latitude
procedure Set_Latitude (Object : in out City_Ref;
Value : in Integer);
-- Get the city latitude
function Get_Latitude (Object : in City_Ref)
return Integer;
-- Set the city longitude
procedure Set_Longitude (Object : in out City_Ref;
Value : in Integer);
-- Get the city longitude
function Get_Longitude (Object : in City_Ref)
return Integer;
-- Set the region that this city belongs to
procedure Set_Region (Object : in out City_Ref;
Value : in AWA.Countries.Models.Region_Ref'Class);
-- Get the region that this city belongs to
function Get_Region (Object : in City_Ref)
return AWA.Countries.Models.Region_Ref'Class;
-- Set the country that this city belongs to
procedure Set_Country (Object : in out City_Ref;
Value : in AWA.Countries.Models.Country_Ref'Class);
-- Get the country that this city belongs to
function Get_Country (Object : in City_Ref)
return AWA.Countries.Models.Country_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out City_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out City_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out City_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out City_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out City_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in City_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
CITY_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out City_Ref);
-- Copy of the object.
procedure Copy (Object : in City_Ref;
Into : in out City_Ref);
-- --------------------
-- The country neighbor defines what countries
-- are neigbors with each other
-- --------------------
-- Create an object key for Country_Neighbor.
function Country_Neighbor_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Country_Neighbor from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Country_Neighbor_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Country_Neighbor : constant Country_Neighbor_Ref;
function "=" (Left, Right : Country_Neighbor_Ref'Class) return Boolean;
--
procedure Set_Id (Object : in out Country_Neighbor_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Country_Neighbor_Ref)
return ADO.Identifier;
--
procedure Set_Neighbor_Of (Object : in out Country_Neighbor_Ref;
Value : in AWA.Countries.Models.Country_Ref'Class);
--
function Get_Neighbor_Of (Object : in Country_Neighbor_Ref)
return AWA.Countries.Models.Country_Ref'Class;
--
procedure Set_Neighbor (Object : in out Country_Neighbor_Ref;
Value : in AWA.Countries.Models.Country_Ref'Class);
--
function Get_Neighbor (Object : in Country_Neighbor_Ref)
return AWA.Countries.Models.Country_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Country_Neighbor_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Country_Neighbor_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Country_Neighbor_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Country_Neighbor_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Country_Neighbor_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Country_Neighbor_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
COUNTRY_NEIGHBOR_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Country_Neighbor_Ref);
-- Copy of the object.
procedure Copy (Object : in Country_Neighbor_Ref;
Into : in out Country_Neighbor_Ref);
-- --------------------
-- Region defines an area within a country.
-- --------------------
-- Create an object key for Region.
function Region_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Region from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Region_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Region : constant Region_Ref;
function "=" (Left, Right : Region_Ref'Class) return Boolean;
-- Set the region identifier
procedure Set_Id (Object : in out Region_Ref;
Value : in ADO.Identifier);
-- Get the region identifier
function Get_Id (Object : in Region_Ref)
return ADO.Identifier;
-- Set the region name
procedure Set_Name (Object : in out Region_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Region_Ref;
Value : in String);
-- Get the region name
function Get_Name (Object : in Region_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Region_Ref)
return String;
-- Set the region geonameid
procedure Set_Geonameid (Object : in out Region_Ref;
Value : in Integer);
-- Get the region geonameid
function Get_Geonameid (Object : in Region_Ref)
return Integer;
-- Set the country that this region belongs to
procedure Set_Country (Object : in out Region_Ref;
Value : in AWA.Countries.Models.Country_Ref'Class);
-- Get the country that this region belongs to
function Get_Country (Object : in Region_Ref)
return AWA.Countries.Models.Country_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Region_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Region_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Region_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Region_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Region_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Region_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
REGION_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Region_Ref);
-- Copy of the object.
procedure Copy (Object : in Region_Ref;
Into : in out Region_Ref);
private
COUNTRY_NAME : aliased constant String := "awa_country";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "name";
COL_2_1_NAME : aliased constant String := "continent";
COL_3_1_NAME : aliased constant String := "currency";
COL_4_1_NAME : aliased constant String := "iso_code";
COL_5_1_NAME : aliased constant String := "geonameid";
COL_6_1_NAME : aliased constant String := "languages";
COL_7_1_NAME : aliased constant String := "tld";
COL_8_1_NAME : aliased constant String := "currency_code";
COUNTRY_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 9,
Table => COUNTRY_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access,
7 => COL_6_1_NAME'Access,
8 => COL_7_1_NAME'Access,
9 => COL_8_1_NAME'Access
)
);
COUNTRY_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= COUNTRY_DEF'Access;
Null_Country : constant Country_Ref
:= Country_Ref'(ADO.Objects.Object_Ref with others => <>);
type Country_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => COUNTRY_DEF'Access)
with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Continent : Ada.Strings.Unbounded.Unbounded_String;
Currency : Ada.Strings.Unbounded.Unbounded_String;
Iso_Code : Ada.Strings.Unbounded.Unbounded_String;
Geonameid : Integer;
Languages : Ada.Strings.Unbounded.Unbounded_String;
Tld : Ada.Strings.Unbounded.Unbounded_String;
Currency_Code : Ada.Strings.Unbounded.Unbounded_String;
end record;
type Country_Access is access all Country_Impl;
overriding
procedure Destroy (Object : access Country_Impl);
overriding
procedure Find (Object : in out Country_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Country_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Country_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Country_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Country_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Country_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Country_Ref'Class;
Impl : out Country_Access);
CITY_NAME : aliased constant String := "awa_city";
COL_0_2_NAME : aliased constant String := "id";
COL_1_2_NAME : aliased constant String := "name";
COL_2_2_NAME : aliased constant String := "zip_code";
COL_3_2_NAME : aliased constant String := "latitude";
COL_4_2_NAME : aliased constant String := "longitude";
COL_5_2_NAME : aliased constant String := "region_id";
COL_6_2_NAME : aliased constant String := "country_id";
CITY_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 7,
Table => CITY_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access,
4 => COL_3_2_NAME'Access,
5 => COL_4_2_NAME'Access,
6 => COL_5_2_NAME'Access,
7 => COL_6_2_NAME'Access
)
);
CITY_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= CITY_DEF'Access;
Null_City : constant City_Ref
:= City_Ref'(ADO.Objects.Object_Ref with others => <>);
type City_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => CITY_DEF'Access)
with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Zip_Code : Integer;
Latitude : Integer;
Longitude : Integer;
Region : AWA.Countries.Models.Region_Ref;
Country : AWA.Countries.Models.Country_Ref;
end record;
type City_Access is access all City_Impl;
overriding
procedure Destroy (Object : access City_Impl);
overriding
procedure Find (Object : in out City_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out City_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out City_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out City_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out City_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out City_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out City_Ref'Class;
Impl : out City_Access);
COUNTRY_NEIGHBOR_NAME : aliased constant String := "awa_country_neighbor";
COL_0_3_NAME : aliased constant String := "id";
COL_1_3_NAME : aliased constant String := "neighbor_of_id";
COL_2_3_NAME : aliased constant String := "neighbor_id";
COUNTRY_NEIGHBOR_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 3,
Table => COUNTRY_NEIGHBOR_NAME'Access,
Members => (
1 => COL_0_3_NAME'Access,
2 => COL_1_3_NAME'Access,
3 => COL_2_3_NAME'Access
)
);
COUNTRY_NEIGHBOR_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= COUNTRY_NEIGHBOR_DEF'Access;
Null_Country_Neighbor : constant Country_Neighbor_Ref
:= Country_Neighbor_Ref'(ADO.Objects.Object_Ref with others => <>);
type Country_Neighbor_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => COUNTRY_NEIGHBOR_DEF'Access)
with record
Neighbor_Of : AWA.Countries.Models.Country_Ref;
Neighbor : AWA.Countries.Models.Country_Ref;
end record;
type Country_Neighbor_Access is access all Country_Neighbor_Impl;
overriding
procedure Destroy (Object : access Country_Neighbor_Impl);
overriding
procedure Find (Object : in out Country_Neighbor_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Country_Neighbor_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Country_Neighbor_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Country_Neighbor_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Country_Neighbor_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Country_Neighbor_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Country_Neighbor_Ref'Class;
Impl : out Country_Neighbor_Access);
REGION_NAME : aliased constant String := "awa_region";
COL_0_4_NAME : aliased constant String := "id";
COL_1_4_NAME : aliased constant String := "name";
COL_2_4_NAME : aliased constant String := "geonameid";
COL_3_4_NAME : aliased constant String := "country_id";
REGION_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 4,
Table => REGION_NAME'Access,
Members => (
1 => COL_0_4_NAME'Access,
2 => COL_1_4_NAME'Access,
3 => COL_2_4_NAME'Access,
4 => COL_3_4_NAME'Access
)
);
REGION_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= REGION_DEF'Access;
Null_Region : constant Region_Ref
:= Region_Ref'(ADO.Objects.Object_Ref with others => <>);
type Region_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => REGION_DEF'Access)
with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Geonameid : Integer;
Country : AWA.Countries.Models.Country_Ref;
end record;
type Region_Access is access all Region_Impl;
overriding
procedure Destroy (Object : access Region_Impl);
overriding
procedure Find (Object : in out Region_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Region_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Region_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Region_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Region_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Region_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Region_Ref'Class;
Impl : out Region_Access);
end AWA.Countries.Models;
|
with Semaphores;
with Ada.Text_Io; use Ada.Text_Io;
procedure Semaphores_Main is
-- Create an instance of a Counting_Semaphore with Max set to 3
Lock : Semaphores.Counting_Semaphore(3);
-- Define a task type to interact with the Lock object declared above
task type Worker is
entry Start (Sleep : in Duration; Id : in Positive);
end Worker;
task body Worker is
Sleep_Time : Duration;
My_Id : Positive;
begin
accept Start(Sleep : in Duration; Id : in Positive) do
My_Id := Id;
Sleep_Time := Sleep;
end Start;
--Acquire the lock. The task will suspend until the Acquire call completes
Lock.Acquire;
Put_Line("Task #" & Positive'Image(My_Id) & " acquired the lock.");
-- Suspend the task for Sleep_Time seconds
delay Sleep_Time;
-- Release the lock. Release is unconditional and happens without suspension
Lock.Release;
end Worker;
-- Create an array of 5 Workers
type Staff is array(Positive range 1..5) of Worker;
Crew : Staff;
begin
for I in Crew'range loop
Crew(I).Start(2.0, I);
end loop;
end Semaphores_Main;
|
pragma Ada_2012;
package body Protypo.Api.Callback_Utilities is
---------------------
-- Match_Signature --
---------------------
function Match_Signature (Parameters : Engine_Value_Vectors.Vector;
Signature : Class_Array)
return Boolean
is
use Engine_Value_Vectors;
begin
if Natural (Parameters.Length) /= Signature'Length then
return False;
end if;
declare
Pos : Cursor := Parameters.First;
begin
for Class of Signature loop
if Class /= Element (Pos).Class then
return False;
end if;
Next (Pos);
end loop;
end;
return True;
end Match_Signature;
function Get (Parameters : Engine_Value_Vectors.Vector;
Index : Positive)
return Engine_Value
is (Parameters (Parameters.First_Index + Index - 1));
----------
-- Is_A --
----------
function Is_A
(Parameters : Engine_Value_Vectors.Vector; Index : Positive;
Class : Engine_Value_Class) return Boolean
is (Get (Parameters, Index).Class = Class);
-------------------
-- Get_Parameter --
-------------------
function Get_Parameter (Parameters : Engine_Value_Vectors.Vector;
Index : Positive)
return String
is (Get_String (Get (Parameters, Index)));
end Protypo.Api.Callback_Utilities;
|
with Ada.Strings.Unbounded;
with Ahven.Framework;
with Aircraft.Api;
package Test_Aircraft.Read is
use Aircraft;
use Aircraft.Api;
type Test is new Ahven.Framework.Test_Case with null record;
procedure Initialize (T : in out Test);
procedure Airplane_1;
procedure Airplane_2;
procedure Helicopter_1;
procedure Helicopter_2;
end Test_Aircraft.Read;
|
-- Ada_GUI version of Random_Int
--
-- Copyright (C) 2021 by PragmAda Software Engineering
--
-- Released under the terms of the 3-Clause BSD License. See https://opensource.org/licenses/BSD-3-Clause
--
-- The (application-specific) user interface
package Random_Int.UI is
type Event_ID is (Generate, Quit);
function Ended return Boolean;
-- Returns True when Next_Event has returned Quit; False otherwise
function Next_Event return Event_ID with Pre => not Ended;
-- Blocks until the next event ia available and returns it
-- If the result is Quit, further calls to operations of this package will raise Program_Error
function Min_Text return String with Pre => not Ended;
function Max_Text return String with Pre => not Ended;
-- Returns the text in the Min and Max input fields
procedure Set_Min (Value : in Integer) with Pre => not Ended;
procedure Set_Max (Value : in Integer) with Pre => not Ended;
-- Sets the text in the Min and Max input fields to Value
procedure Min_Error with Pre => not Ended;
procedure Max_Error with Pre => not Ended;
-- Displays an error message in the Min and Max input fields
procedure Show_Result (Value : in Integer) with Pre => not Ended;
-- Puts a value in the result display field
end Random_Int.UI;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
private with Ada.Containers.Indefinite_Holders;
private with Orka.Instances;
private with Orka.Rendering.Buffers.MDI;
private with Orka.Scenes.Singles.Trees;
private with Orka.Transforms.Singles.Matrices;
private with Orka.Types;
with Orka.Behaviors;
with Orka.Culling;
package Orka.Resources.Models is
pragma Preelaborate;
type Model_Instance is abstract limited new Behaviors.Behavior with private;
type Model_Instance_Ptr is not null access all Model_Instance'Class;
procedure Update_Transforms
(Object : in out Model_Instance;
View_Position : Behaviors.Vector4);
-----------------------------------------------------------------------------
type Model_Group is tagged limited private;
type Group_Access is access Model_Group;
procedure Add_Instance
(Object : access Model_Group;
Instance : in out Model_Instance_Ptr);
procedure Remove_Instance
(Object : in out Model_Group;
Instance : in out Model_Instance_Ptr);
procedure Cull (Object : in out Model_Group);
procedure Render (Object : in out Model_Group);
procedure After_Render (Object : in out Model_Group);
-----------------------------------------------------------------------------
type Model is limited new Resource with private;
type Model_Ptr is not null access all Model;
function Create_Group
(Object : aliased in out Model;
Culler : Culling.Culler_Ptr;
Capacity : Positive) return Group_Access;
Model_Load_Error : exception renames Resource_Load_Error;
private
package Trees renames Scenes.Singles.Trees;
package Transforms renames Orka.Transforms.Singles.Matrices;
type Cursor_Array is array (Positive range <>) of Trees.Cursor;
package Cursor_Array_Holder is new Ada.Containers.Indefinite_Holders
(Element_Type => Cursor_Array);
type Model_Scene is limited record
Scene : Trees.Tree;
Shapes : Cursor_Array_Holder.Holder;
end record;
type Model_Scene_Ptr is not null access Model_Scene;
type Model is limited new Resource with record
Scene : Model_Scene_Ptr;
Batch : Rendering.Buffers.MDI.Batch (Types.Half_Type, Types.UInt_Type);
Bounds : Rendering.Buffers.Buffer (Types.Single_Vector_Type);
end record;
type Partition_Index_Type is mod 4;
package Model_Instances is new Orka.Instances (Partition_Index_Type);
type Model_Group is tagged limited record
Model : access Orka.Resources.Models.Model;
Instances : Model_Instances.Manager;
Cull_Instance : Culling.Cull_Instance;
Compacted_Transforms : Rendering.Buffers.Buffer (Types.Single_Matrix_Type);
Compacted_Commands : Rendering.Buffers.Buffer (Types.Elements_Command_Type);
end record;
type Model_Instance is abstract limited new Behaviors.Behavior with record
Group : access Model_Group;
Scene : Trees.Tree;
Instance : Model_Instances.Cursor;
end record;
end Orka.Resources.Models;
|
package a_nodes_h.Support is
-- Records written in good Ada style should already have default values for
-- their components. a_nodes_h.ads is generated from C, so this package
-- supplies constant records for safe initialization.
package ICE renames Interfaces.C.Extensions;
package ICS renames Interfaces.C.Strings;
Invalid_bool : constant ICE.bool := ICE.False;
Invalid_chars_ptr : constant ICS.chars_ptr := ICS.Null_Ptr;
Invalid_ID : constant := -1;
Empty_ID : constant := 0;
function Is_Valid (This : in int) return Boolean is
(This /= Invalid_ID);
function Is_Empty (This : in int) return Boolean is
(This = Empty_ID);
-- Order below is same as in a_nodes.h:
Invalid_Program_Text : constant Program_Text := Program_Text(ICS.Null_Ptr);
Invalid_Element_ID : constant Element_ID := Invalid_ID;
Empty_Element_ID_List : constant Element_ID_List :=
(length => 0,
IDs => null);
Empty_Name_List : constant Name_List :=
Name_List (Empty_Element_ID_List);
Default_Context_Struct : constant Context_Struct :=
(name => Invalid_chars_ptr,
parameters => Invalid_chars_ptr,
debug_image => Invalid_chars_ptr);
-- Element union component default structs go here
Default_Pragma_Struct : constant Pragma_Struct :=
(Pragma_Kind => Not_A_Pragma,
Pragma_Name_Image => Invalid_Program_Text,
Pragma_Argument_Associations => Empty_Element_ID_List
);
Default_Defining_Name_Struct : constant Defining_Name_Struct :=
(Defining_Name_Kind => Not_A_Defining_Name,
Defining_Name_Image => Invalid_chars_ptr,
References => Empty_Name_List,
Is_Referenced => Invalid_bool,
Position_Number_Image => Invalid_chars_ptr,
Representation_Value_Image => Invalid_chars_ptr,
Defining_Prefix => Invalid_Element_ID,
Defining_Selector => Invalid_Element_ID,
Corresponding_Constant_Declaration => Invalid_Element_ID,
Operator_Kind => Not_An_Operator,
Corresponding_Generic_Element => Invalid_Element_ID);
Default_Declaration_Struct : constant Declaration_Struct :=
(Declaration_Kind => Not_A_Declaration,
Declaration_Origin => Not_A_Declaration_Origin,
Corresponding_Pragmas => Empty_Element_ID_List,
Names => Empty_Name_List,
Aspect_Specifications => Empty_Element_ID_List,
Corresponding_Representation_Clauses => Empty_Element_ID_List,
Has_Abstract => Invalid_bool,
Has_Aliased => Invalid_bool,
Has_Limited => Invalid_bool,
Has_Private => Invalid_bool,
Has_Protected => Invalid_bool,
Has_Reverse => Invalid_bool,
Has_Task => Invalid_bool,
Has_Null_Exclusion => Invalid_bool,
Is_Not_Null_Return => Invalid_bool,
Mode_Kind => Not_A_Mode,
Default_Kind => Not_A_Default,
Pragmas => Empty_Element_ID_List,
Corresponding_End_Name => Invalid_Element_ID,
Discriminant_Part => Invalid_Element_ID,
Type_Declaration_View => Invalid_Element_ID,
Object_Declaration_View => Invalid_Element_ID,
Initialization_Expression => Invalid_Element_ID,
Corresponding_Type_Declaration => Invalid_Element_ID,
Corresponding_Type_Completion => Invalid_Element_ID,
Corresponding_Type_Partial_View => Invalid_Element_ID,
Corresponding_First_Subtype => Invalid_Element_ID,
Corresponding_Last_Constraint => Invalid_Element_ID,
Corresponding_Last_Subtype => Invalid_Element_ID,
Specification_Subtype_Definition => Invalid_Element_ID,
Iteration_Scheme_Name => Invalid_Element_ID,
Subtype_Indication => Invalid_Element_ID,
Parameter_Profile => Empty_Element_ID_List,
Result_Profile => Invalid_Element_ID,
Result_Expression => Invalid_Element_ID,
Is_Overriding_Declaration => Invalid_bool,
Is_Not_Overriding_Declaration => Invalid_bool,
Body_Declarative_Items => Empty_Element_ID_List,
Body_Statements => Empty_Element_ID_List,
Body_Exception_Handlers => Empty_Element_ID_List,
Body_Block_Statement => Invalid_Element_ID,
Is_Name_Repeated => Invalid_bool,
Corresponding_Declaration => Invalid_Element_ID,
Corresponding_Body => Invalid_Element_ID,
Corresponding_Subprogram_Derivation => Invalid_Element_ID,
Corresponding_Type => Invalid_Element_ID,
Corresponding_Equality_Operator => Invalid_Element_ID,
Visible_Part_Declarative_Items => Empty_Element_ID_List,
Is_Private_Present => Invalid_bool,
Private_Part_Declarative_Items => Empty_Element_ID_List,
Declaration_Interface_List => Empty_Element_ID_List,
Renamed_Entity => Invalid_Element_ID,
Corresponding_Base_Entity => Invalid_Element_ID,
Protected_Operation_Items => Empty_Element_ID_List,
Entry_Family_Definition => Invalid_Element_ID,
Entry_Index_Specification => Invalid_Element_ID,
Entry_Barrier => Invalid_Element_ID,
Corresponding_Subunit => Invalid_Element_ID,
Is_Subunit => Invalid_bool,
Corresponding_Body_Stub => Invalid_Element_ID,
Generic_Formal_Part => Empty_Element_ID_List,
Generic_Unit_Name => Invalid_Element_ID,
Generic_Actual_Part => Empty_Element_ID_List,
Formal_Subprogram_Default => Invalid_Element_ID,
Is_Dispatching_Operation => Invalid_bool,
Corresponding_Type_Operators => Empty_Element_ID_List);
Default_Access_Type_Struct : constant Access_Type_Struct :=
(Access_Type_Kind => Not_An_Access_Type_Definition,
Has_Null_Exclusion => Invalid_bool,
Is_Not_Null_Return => Invalid_bool,
Access_To_Object_Definition => Invalid_Element_ID,
Access_To_Subprogram_Parameter_Profile => Empty_Element_ID_List,
Access_To_Function_Result_Profile => Invalid_Element_ID);
Default_Type_Definition_Struct : constant Type_Definition_Struct :=
(Type_Kind => Not_A_Type_Definition,
Has_Abstract => Invalid_bool,
Has_Limited => Invalid_bool,
Has_Private => Invalid_bool,
Corresponding_Type_Operators => Empty_Element_ID_List,
Has_Protected => Invalid_bool,
Has_Synchronized => Invalid_bool,
Has_Tagged => Invalid_bool,
Has_Task => Invalid_bool,
Has_Null_Exclusion => Invalid_bool,
Interface_Kind => Not_An_Interface,
Root_Type_Kind => Not_A_Root_Type_Definition,
Parent_Subtype_Indication => Invalid_Element_ID,
Record_Definition => Invalid_Element_ID,
Implicit_Inherited_Declarations => Empty_Element_ID_List,
Implicit_Inherited_Subprograms => Empty_Element_ID_List,
Corresponding_Parent_Subtype => Invalid_Element_ID,
Corresponding_Root_Type => Invalid_Element_ID,
Corresponding_Type_Structure => Invalid_Element_ID,
Enumeration_Literal_Declarations => Empty_Element_ID_List,
Integer_Constraint => Invalid_Element_ID,
Mod_Static_Expression => Invalid_Element_ID,
Digits_Expression => Invalid_Element_ID,
Delta_Expression => Invalid_Element_ID,
Real_Range_Constraint => Invalid_Element_ID,
Index_Subtype_Definitions => Empty_Element_ID_List,
Discrete_Subtype_Definitions => Empty_Element_ID_List,
Array_Component_Definition => Invalid_Element_ID,
Definition_Interface_List => Empty_Element_ID_List,
Access_Type => Default_Access_Type_Struct);
Default_Constraint_Struct : constant Constraint_Struct :=
(Constraint_Kind => Not_A_Constraint,
Digits_Expression => Invalid_Element_ID,
Delta_Expression => Invalid_Element_ID,
Real_Range_Constraint => Invalid_Element_ID,
Lower_Bound => Invalid_Element_ID,
Upper_Bound => Invalid_Element_ID,
Range_Attribute => Invalid_Element_ID,
Discrete_Ranges => Empty_Element_ID_List,
Discriminant_Associations => Empty_Element_ID_List);
Default_Subtype_Indication_Struct : constant Subtype_Indication_Struct :=
(Has_Null_Exclusion => Invalid_bool,
Subtype_Mark => Invalid_Element_ID,
Subtype_Constraint => Invalid_Element_ID);
Default_Component_Definition_Struct : constant Component_Definition_Struct :=
(Has_Aliased => Invalid_bool,
Component_Subtype_Indication => Invalid_Element_ID,
Component_Definition_View => Invalid_Element_ID);
Default_Discrete_Subtype_Definition_Struct :
constant Discrete_Subtype_Definition_Struct :=
(Discrete_Range_Kind => Not_A_Discrete_Range,
Subtype_Mark => Invalid_Element_ID,
Subtype_Constraint => Invalid_Element_ID,
Lower_Bound => Invalid_Element_ID,
Upper_Bound => Invalid_Element_ID,
Range_Attribute => Invalid_Element_ID);
Default_Discrete_Range_Struct : constant Discrete_Range_Struct :=
(Discrete_Range_Kind => Not_A_Discrete_Range,
Subtype_Mark => Invalid_Element_ID,
Subtype_Constraint => Invalid_Element_ID,
Lower_Bound => Invalid_Element_ID,
Upper_Bound => Invalid_Element_ID,
Range_Attribute => Invalid_Element_ID);
Default_Known_Discriminant_Part_Struct :
constant Known_Discriminant_Part_Struct :=
(Discriminants => Empty_Element_ID_List);
Default_Record_Definition_Struct : constant Record_Definition_Struct :=
(Record_Components => Empty_Element_ID_List,
Implicit_Components => Empty_Element_ID_List);
Default_Variant_Part_Struct : constant Variant_Part_Struct :=
(Discriminant_Direct_Name => Invalid_Element_ID,
Variants => Empty_Element_ID_List);
Default_Variant_Struct : constant Variant_Struct :=
(Record_Components => Empty_Element_ID_List,
Implicit_Components => Empty_Element_ID_List,
Variant_Choices => Empty_Element_ID_List);
Default_Access_Definition_Struct : constant Access_Definition_Struct :=
(Access_Definition_Kind => Not_An_Access_Definition,
Has_Null_Exclusion => Invalid_bool,
Is_Not_Null_Return => Invalid_bool,
Anonymous_Access_To_Object_Subtype_Mark => Invalid_Element_ID,
Access_To_Subprogram_Parameter_Profile => Empty_Element_ID_List,
Access_To_Function_Result_Profile => Invalid_Element_ID);
Default_Private_Type_Definition_Struct :
constant Private_Type_Definition_Struct :=
(Has_Abstract => Invalid_bool,
Has_Limited => Invalid_bool,
Has_Private => Invalid_bool,
Corresponding_Type_Operators => Empty_Element_ID_List);
Default_Tagged_Private_Type_Definition_Struct :
constant Tagged_Private_Type_Definition_Struct :=
(Has_Abstract => Invalid_bool,
Has_Limited => Invalid_bool,
Has_Private => Invalid_bool,
Has_Tagged => Invalid_bool,
Corresponding_Type_Operators => Empty_Element_ID_List);
Default_Private_Extension_Definition_Struct :
constant Private_Extension_Definition_Struct :=
(Has_Abstract => Invalid_bool,
Has_Limited => Invalid_bool,
Has_Private => Invalid_bool,
Has_Synchronized => Invalid_bool,
Implicit_Inherited_Declarations => Empty_Element_ID_List,
Implicit_Inherited_Subprograms => Empty_Element_ID_List,
Definition_Interface_List => Empty_Element_ID_List,
Ancestor_Subtype_Indication => Invalid_Element_ID,
Corresponding_Type_Operators => Empty_Element_ID_List);
Default_Task_Definition_Struct : constant Task_Definition_Struct :=
(Has_Task => Invalid_bool,
Visible_Part_Items => Empty_Element_ID_List,
Private_Part_Items => Empty_Element_ID_List,
Is_Private_Present => Invalid_bool,
Corresponding_Type_Operators => Empty_Element_ID_List);
Default_Protected_Definition_Struct : constant Protected_Definition_Struct :=
(Has_Protected => Invalid_bool,
Visible_Part_Items => Empty_Element_ID_List,
Private_Part_Items => Empty_Element_ID_List,
Is_Private_Present => Invalid_bool,
Corresponding_Type_Operators => Empty_Element_ID_List);
Default_Formal_Type_Definition_Struct :
constant Formal_Type_Definition_Struct :=
(Formal_Type_Kind => Not_A_Formal_Type_Definition,
Corresponding_Type_Operators => Empty_Element_ID_List,
Has_Abstract => Invalid_bool,
Has_Limited => Invalid_bool,
Has_Private => Invalid_bool,
Has_Synchronized => Invalid_bool,
Has_Tagged => Invalid_bool,
Interface_Kind => Not_An_Interface,
Implicit_Inherited_Declarations => Empty_Element_ID_List,
Implicit_Inherited_Subprograms => Empty_Element_ID_List,
Index_Subtype_Definitions => Empty_Element_ID_List,
Discrete_Subtype_Definitions => Empty_Element_ID_List,
Array_Component_Definition => Invalid_Element_ID,
Subtype_Mark => Invalid_Element_ID,
Definition_Interface_List => Empty_Element_ID_List,
Access_Type => Default_Access_Type_Struct);
Default_Aspect_Specification_Struct : constant Aspect_Specification_Struct :=
(Aspect_Mark => Invalid_Element_ID,
Aspect_Definition => Invalid_Element_ID);
Default_No_Struct : constant No_Struct := -1;
Default_Definition_Union : constant Definition_Union :=
(discr => 0,
Dummy_Member => -1);
Default_Definition_Struct : constant Definition_Struct :=
(Definition_Kind => Not_A_Definition,
The_Union => Default_Definition_Union);
Default_Expression_Struct : constant Expression_Struct :=
(Expression_Kind => Not_An_Expression,
Is_Prefix_Notation => Invalid_bool,
Corresponding_Expression_Type => Invalid_Element_ID,
Corresponding_Expression_Type_Definition => Invalid_Element_ID,
Operator_Kind => Not_An_Operator,
Attribute_Kind => Not_An_Attribute,
Value_Image => Invalid_chars_ptr,
Name_Image => Invalid_chars_ptr,
Corresponding_Name_Definition => Invalid_Element_ID,
Corresponding_Name_Definition_List => Empty_Element_ID_List,
Corresponding_Name_Declaration => Invalid_Element_ID,
Prefix => Invalid_Element_ID,
Index_Expressions => Empty_Element_ID_List,
Slice_Range => Invalid_Element_ID,
Selector => Invalid_Element_ID,
Attribute_Designator_Identifier => Invalid_Element_ID,
Attribute_Designator_Expressions => Empty_Element_ID_List,
Record_Component_Associations => Empty_Element_ID_List,
Extension_Aggregate_Expression => Invalid_Element_ID,
Array_Component_Associations => Empty_Element_ID_List,
Expression_Parenthesized => Invalid_Element_ID,
Is_Prefix_Call => Invalid_bool,
Corresponding_Called_Function => Invalid_Element_ID,
Function_Call_Parameters => Empty_Element_ID_List,
Short_Circuit_Operation_Left_Expression => Invalid_Element_ID,
Short_Circuit_Operation_Right_Expression => Invalid_Element_ID,
Membership_Test_Expression => Invalid_Element_ID,
Membership_Test_Choices => Empty_Element_ID_List,
Converted_Or_Qualified_Subtype_Mark => Invalid_Element_ID,
Converted_Or_Qualified_Expression => Invalid_Element_ID,
Allocator_Subtype_Indication => Invalid_Element_ID,
Allocator_Qualified_Expression => Invalid_Element_ID,
Expression_Paths => Empty_Element_ID_List,
Is_Generalized_Indexing => Invalid_bool,
Is_Generalized_Reference => Invalid_bool,
Iterator_Specification => Invalid_Element_ID,
Predicate => Invalid_Element_ID,
Subpool_Name => Invalid_Element_ID,
Corresponding_Generic_Element => Invalid_Element_ID,
Is_Dispatching_Call => Invalid_bool,
Is_Call_On_Dispatching_Operation => Invalid_bool);
Default_Association_Struct : constant Association_Struct :=
(Association_Kind => Not_An_Association,
Array_Component_Choices => Empty_Element_ID_List,
Record_Component_Choices => Empty_Element_ID_List,
Component_Expression => Invalid_Element_ID,
Formal_Parameter => Invalid_Element_ID,
Actual_Parameter => Invalid_Element_ID,
Discriminant_Selector_Names => Empty_Element_ID_List,
Discriminant_Expression => Invalid_Element_ID,
Is_Normalized => Invalid_bool,
Is_Defaulted_Association => Invalid_bool);
Default_Statement_Struct : constant Statement_Struct :=
(Statement_Kind => Not_A_Statement,
Corresponding_Pragmas => Empty_Element_ID_List,
Label_Names => Empty_Element_ID_List,
Is_Prefix_Notation => Invalid_bool,
Pragmas => Empty_Element_ID_List,
Corresponding_End_Name => Invalid_Element_ID,
Assignment_Variable_Name => Invalid_Element_ID,
Assignment_Expression => Invalid_Element_ID,
Statement_Paths => Empty_Element_ID_List,
Case_Expression => Invalid_Element_ID,
Statement_Identifier => Invalid_Element_ID,
Is_Name_Repeated => Invalid_bool,
While_Condition => Invalid_Element_ID,
For_Loop_Parameter_Specification => Invalid_Element_ID,
Loop_Statements => Empty_Element_ID_List,
Is_Declare_Block => Invalid_bool,
Block_Declarative_Items => Empty_Element_ID_List,
Block_Statements => Empty_Element_ID_List,
Block_Exception_Handlers => Empty_Element_ID_List,
Exit_Loop_Name => Invalid_Element_ID,
Exit_Condition => Invalid_Element_ID,
Corresponding_Loop_Exited => Invalid_Element_ID,
Return_Expression => Invalid_Element_ID,
Return_Object_Declaration => Invalid_Element_ID,
Extended_Return_Statements => Empty_Element_ID_List,
Extended_Return_Exception_Handlers => Empty_Element_ID_List,
Goto_Label => Invalid_Element_ID,
Corresponding_Destination_Statement => Invalid_Element_ID,
Called_Name => Invalid_Element_ID,
Corresponding_Called_Entity => Invalid_Element_ID,
Call_Statement_Parameters => Empty_Element_ID_List,
Accept_Entry_Index => Invalid_Element_ID,
Accept_Entry_Direct_Name => Invalid_Element_ID,
Accept_Parameters => Empty_Element_ID_List,
Accept_Body_Statements => Empty_Element_ID_List,
Accept_Body_Exception_Handlers => Empty_Element_ID_List,
Corresponding_Entry => Invalid_Element_ID,
Requeue_Entry_Name => Invalid_Element_ID,
Delay_Expression => Invalid_Element_ID,
Aborted_Tasks => Empty_Element_ID_List,
Raised_Exception => Invalid_Element_ID,
Associated_Message => Invalid_Element_ID,
Qualified_Expression => Invalid_Element_ID,
Is_Dispatching_Call => Invalid_bool,
Is_Call_On_Dispatching_Operation => Invalid_bool,
Corresponding_Called_Entity_Unwound => Invalid_Element_ID);
Default_Path_Struct : constant Path_Struct :=
(Path_Kind => Not_A_Path,
Sequence_Of_Statements => Empty_Element_ID_List,
Dependent_Expression => Invalid_Element_ID,
Condition_Expression => Invalid_Element_ID,
Case_Path_Alternative_Choices => Empty_Element_ID_List,
Guard => Invalid_Element_ID);
Default_Representation_Clause_Struct :
constant Representation_Clause_Struct :=
(Representation_Clause_Kind => Not_A_Representation_Clause,
Representation_Clause_Name => Invalid_Element_ID,
Pragmas => Empty_Element_ID_List,
Representation_Clause_Expression => Invalid_Element_ID,
Mod_Clause_Expression => Invalid_Element_ID,
Component_Clauses => Empty_Element_ID_List);
Default_Clause_Struct : constant Clause_Struct :=
(Clause_Kind => Not_A_Clause,
Has_Limited => Invalid_bool,
Clause_Names => Empty_Name_List,
Representation_Clause_Name => Invalid_Element_ID,
Component_Clause_Position => Invalid_Element_ID,
Component_Clause_Range => Invalid_Element_ID,
Representation_Clause => Default_Representation_Clause_Struct);
Default_Exception_Handler_Struct : constant Exception_Handler_Struct :=
(Pragmas => Empty_Element_ID_List,
Choice_Parameter_Specification => Invalid_Element_ID,
Exception_Choices => Empty_Element_ID_List,
Handler_Statements => Empty_Element_ID_List);
Default_Element_Union : constant Element_Union :=
(Discr => 0,
Dummy_Member => 0);
Default_Source_Location_Struct : constant Source_Location_Struct :=
(Unit_Name => Invalid_chars_ptr,
First_Line => -1,
First_Column => -1,
Last_Line => -1,
Last_Column => -1);
Invalid_Unit_ID : constant Unit_ID := Invalid_ID;
Default_Element_Struct : constant Element_Struct :=
(ID => Invalid_Element_ID,
Element_Kind => Not_An_Element,
Enclosing_Compilation_Unit => Invalid_Unit_ID,
Is_Part_Of_Implicit => Invalid_bool,
Is_Part_Of_Inherited => Invalid_bool,
Is_Part_Of_Instance => Invalid_bool,
Hash => -1,
Enclosing_Element_Id => Invalid_Element_ID,
Enclosing_Kind => Not_Enclosing,
Source_Location => Default_Source_Location_Struct,
Debug_Image => Invalid_chars_ptr,
The_Union => Default_Element_Union);
Empty_Unit_List : constant Unit_List :=
(length => 0,
IDs => null);
Default_Unit_Struct : constant Unit_Struct :=
(ID => Invalid_Unit_ID,
Unit_Kind => Not_A_Unit,
Unit_Class => Not_A_Class,
Unit_Origin => Not_An_Origin,
Unit_Full_Name => Invalid_chars_ptr,
Unique_Name => Invalid_chars_ptr,
Exists => Invalid_bool,
Can_Be_Main_Program => Invalid_bool,
Is_Body_Required => Invalid_bool,
Text_Name => Invalid_chars_ptr,
Text_Form => Invalid_chars_ptr,
Object_Name => Invalid_chars_ptr,
Object_Form => Invalid_chars_ptr,
Compilation_Command_Line_Options => Invalid_chars_ptr,
Debug_Image => Invalid_chars_ptr,
Unit_Declaration => Invalid_Element_ID,
Context_Clause_Elements => Empty_Element_ID_List,
Compilation_Pragmas => Empty_Element_ID_List,
Is_Standard => Invalid_bool,
Corresponding_Children => Empty_Unit_List,
Corresponding_Parent_Declaration => Invalid_Unit_ID,
Corresponding_Declaration => Invalid_Unit_ID,
Corresponding_Body => Invalid_Unit_ID,
Subunits => Empty_Unit_List,
Corresponding_Subunit_Parent_Body => Invalid_Unit_ID);
Default_Unit_Struct_List_Struct : constant Unit_Struct_List_Struct :=
(Unit => Default_Unit_Struct,
Next => null,
Next_count => 0);
Default_Element_Struct_List_Struct : constant Element_Struct_List_Struct :=
(Element => Default_Element_Struct,
Next => null,
Next_count => 0);
Default_Nodes_Struct : constant Nodes_Struct :=
(Context => Default_Context_Struct,
Units => null,
Elements => null);
-- Not in a_nodes.h:
function To_bool
(Item : in Boolean)
return ICE.bool
is
(if Item then ICE.True else ICE.False);
type Unit_ID_Array is array (Positive range <>) of aliased Unit_ID;
-- Not called _Ptr so we don't forget a pointer to this is not the same as a
-- pointer to a C array. We just need this to create the array on the heap:
type Unit_ID_Array_Access is access Unit_ID_Array;
function To_Unit_ID_Ptr
(Item : not null access Unit_ID_Array)
return Unit_ID_Ptr is
(if Item.all'Length = 0 then
null
else
Item.all (Item.all'First)'Unchecked_Access);
type Element_ID_Array is array (Positive range <>) of aliased Element_ID;
-- Not called _Ptr so we don't forget a pointer to this is not the same as a
-- pointer to a C array. We just need this to create the array on the heap:
type Element_ID_Array_Access is access Element_ID_Array;
function To_Element_ID_Ptr
(Item : not null access Element_ID_Array)
return Element_ID_Ptr is
(if Item.all'Length = 0 then
null
else
Item.all (Item.all'First)'Unchecked_Access);
end a_nodes_h.Support;
|
with
lace.Subject.local;
package gel.Keyboard.local
--
-- Provides a concrete keyboard.
--
is
type Item is limited new lace.Subject.local.item
and gel.Keyboard.item with private;
type View is access all Item'class;
package Forge
is
function to_Keyboard (of_Name : in String) return Item;
function new_Keyboard (of_Name : in String) return View;
end Forge;
procedure free (Self : in out View);
--------------
--- Attributes
--
overriding
function Modifiers (Self : in Item) return Modifier_Set;
--------------
--- Operations
--
overriding
procedure emit_key_press_Event (Self : in out Item; Key : in keyboard.Key;
key_Code : in Integer);
overriding
procedure emit_key_release_Event (Self : in out Item; Key : in keyboard.Key);
private
type Item is limited new lace.Subject.local.item
and gel.Keyboard.item with
record
Modifiers : Modifier_Set := no_Modifiers;
end record;
end gel.Keyboard.local;
|
with Types; use Types;
package Partial_Product_Impl_2 with
SPARK_Mode,
Ghost
is
function Partial_Product_Rec
(X, Y : Integer_255;
J : Product_Index_Type;
K : Index_Type)
return Long_Long_Integer
is
(if K = Extended_Index_Type'Max(J - 9, 0)
then
(if J mod 2 = 0 and then K mod 2 = 1 then 2 else 1) * X (K) * Y (J - K)
else
Partial_Product_Rec (X, Y, J, K - 1)
+ (if J mod 2 = 0 and then K mod 2 = 1 then 2 else 1) * X (K) * Y (J - K))
with
Pre =>
J - K in Index_Type'Range
and then All_In_Range (X, Y, Min_Multiply, Max_Multiply),
Post => Partial_Product_Rec'Result in
(-2) * Long_Long_Integer (K + 1) * (2**27 - 1)**2
..
2 * Long_Long_Integer (K + 1) * (2**27 - 1)**2;
pragma Annotate (GNATprove, Terminating, Partial_Product_Rec);
function Partial_Product
(X, Y : Integer_255;
J : Product_Index_Type;
K : Index_Type)
return Long_Long_Integer
is
(Partial_Product_Rec (X, Y, J, K))
with
Pre =>
J - K in Index_Type'Range
and then All_In_Range (X, Y, Min_Multiply, Max_Multiply),
Post => Partial_Product'Result in
(-2) * Long_Long_Integer (K + 1) * (2**27 - 1)**2
..
2 * Long_Long_Integer (K + 1) * (2**27 - 1)**2;
procedure Partial_Product_Def
(X, Y : Integer_255;
J : Product_Index_Type;
K : Index_Type)
with
Pre =>
J - K in Index_Type'Range
and then All_In_Range (X, Y, Min_Multiply, Max_Multiply),
Post => (if K = Extended_Index_Type'Max(J - 9, 0)
then
Partial_Product_Rec (X, Y, J, K)
= (if J mod 2 = 0 and then K mod 2 = 1 then 2 else 1) * X (K) * Y (J - K)
else
Partial_Product_Rec (X, Y, J, K)
= Partial_Product_Rec (X, Y, J, K - 1)
+ (if J mod 2 = 0 and then K mod 2 = 1 then 2 else 1) * X (K) * Y (J - K));
procedure Partial_Product_Def
(X, Y : Integer_255;
J : Product_Index_Type;
K : Index_Type)
is null;
function Partial_Product
(X, Y : Integer_255;
J : Product_Index_Type)
return Long_Long_Integer
is
(Partial_Product_Rec (X, Y, J, Extended_Index_Type'Min (9, J)))
with
Pre => All_In_Range (X, Y, Min_Multiply, Max_Multiply);
end Partial_Product_Impl_2;
|
with STM32_SVD; use STM32_SVD;
with Interfaces; use Interfaces;
generic
type Buffer_Size_Type is range <>;
type Buffer_Type is array (Buffer_Size_Type) of Byte;
type Tag_Type is (<>);
package TLV is
-- type Data_Types is (False, True, Byte, Short, Long, Float, Double,
-- String, Timestamp, Duration, Sequence);
procedure Encode (Tag : Tag_Type; Value : Integer;
Buffer : in out Buffer_Type; Position : in out Buffer_Size_Type);
procedure Encode (Tag : Tag_Type; Value : Short_Float;
Buffer : in out Buffer_Type; Position : in out Buffer_Size_Type);
procedure Encode (Tag : Tag_Type; Value : String;
Buffer : in out Buffer_Type; Position : in out Buffer_Size_Type);
procedure Start_Sequence (Tag : Tag_Type; Buffer : in out Buffer_Type;
Length_Position : out Buffer_Size_Type;
Position : in out Buffer_Size_Type);
procedure End_Sequence (Buffer : in out Buffer_Type;
Length_Position : in Buffer_Size_Type;
Position : in out Buffer_Size_Type);
end TLV;
|
-----------------------------------------------------------------------
-- Util.Beans.Objects.Datasets -- Datasets
-- Copyright (C) 2013, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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.Hash;
with Ada.Finalization;
with Ada.Containers.Indefinite_Hashed_Maps;
with Util.Beans.Basic;
-- == Datasets ==
-- The `Datasets` package implements the `Dataset` list bean which
-- defines a set of objects organized in rows and columns. The `Dataset`
-- implements the `List_Bean` interface and allows to iterate over its rows.
-- Each row defines a `Bean` instance and allows to access each column value.
-- Each column is associated with a unique name. The row `Bean` allows to
-- get or set the column by using the column name.
package Util.Beans.Objects.Datasets is
Invalid_State : exception;
-- An array of objects.
type Object_Array is array (Positive range <>) of Object;
type Dataset is new Util.Beans.Basic.List_Bean with private;
-- Get the number of elements in the list.
overriding
function Get_Count (From : in Dataset) return Natural;
-- Set the current row index. Valid row indexes start at 1.
overriding
procedure Set_Row_Index (From : in out Dataset;
Index : in Natural);
-- Get the element at the current row index.
overriding
function Get_Row (From : in Dataset) return 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 (From : in Dataset;
Name : in String) return Util.Beans.Objects.Object;
-- Append a row in the dataset and call the fill procedure to populate
-- the row content.
procedure Append (Into : in out Dataset;
Fill : not null access procedure (Data : in out Object_Array));
-- Add a column to the dataset. If the position is not specified,
-- the column count is incremented and the name associated with the last column.
-- Raises Invalid_State exception if the dataset contains some rows,
procedure Add_Column (Into : in out Dataset;
Name : in String;
Pos : in Natural := 0);
-- Clear the content of the dataset.
procedure Clear (Set : in out Dataset);
private
type Object_Array_Access is access all Object_Array;
type Dataset_Array is array (Positive range <>) of Object_Array_Access;
type Dataset_Array_Access is access all Dataset_Array;
package Dataset_Map is
new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => Positive,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");
type Row is new Util.Beans.Basic.Bean with record
Data : Object_Array_Access;
Map : access Dataset_Map.Map;
end record;
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
overriding
function Get_Value (From : in Row;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
overriding
procedure Set_Value (From : in out Row;
Name : in String;
Value : in Util.Beans.Objects.Object);
type Dataset is new Ada.Finalization.Controlled and Util.Beans.Basic.List_Bean with record
Data : Dataset_Array_Access;
Count : Natural := 0;
Columns : Natural := 0;
Map : aliased Dataset_Map.Map;
Current : aliased Row;
Current_Pos : Natural := 0;
Row : Util.Beans.Objects.Object;
end record;
-- Initialize the dataset and the row bean instance.
overriding
procedure Initialize (Set : in out Dataset);
-- Release the dataset storage.
overriding
procedure Finalize (Set : in out Dataset);
end Util.Beans.Objects.Datasets;
|
-- Ada_GUI implementation based on Gnoga. Adapted 2021
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . G U I . E L E M E N T . L I S T S --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2014 David Botton --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are --
-- granted additional permissions described in the GCC Runtime Library --
-- Exception, version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
with Ada_GUI.Gnoga.Gui.View;
package Ada_GUI.Gnoga.Gui.Element.List is
-- Lists are elements, implemented as views that comprise sub element
-- parts. Each list type has a different default display style.
--
-- To add elements just Item.Create the sub types.
-- To remove from list use Item.Remove
-- To place in a specific location use the standard Element.Place_*
-- methods.
-------------------------------------------------------------------------
-- Ordered_List_Types
-------------------------------------------------------------------------
type Ordered_List_Type is new Gnoga.Gui.View.View_Base_Type with private;
type Ordered_List_Access is access all Ordered_List_Type;
type Pointer_To_Ordered_List_Class is
access all Ordered_List_Type'Class;
-------------------------------------------------------------------------
-- Ordered_List_Types - Creation Methods
-------------------------------------------------------------------------
procedure Create
(List : in out Ordered_List_Type;
Parent : in out Gnoga.Gui.Base_Type'Class;
ID : in String := "");
-- Create an ordered (by default 1,2,3,4..) list
-------------------------------------------------------------------------
-- Ordered_List_Types - Properties
-------------------------------------------------------------------------
type List_Kind_Type is
(Disc, Armenian, Circle, Cjk_Ideographic, Decimal, Decimal_Leading_Zero,
Georgian, Hebrew, Hiragana, Hiragana_Iroha, Katakana, Katakana_Iroha,
Lower_Alpha, Lower_Greek, Lower_Latin, Lower_Roman, None, Square,
Upper_Alpha, Upper_Latin, Upper_Roman);
procedure List_Kind (List : in out Ordered_List_Type;
Value : in List_Kind_Type);
type List_Location_Type is (Inside, Outside);
procedure List_Location (List : in out Ordered_List_Type;
Value : in List_Location_Type);
-- Default is outside
-------------------------------------------------------------------------
-- Unordered_List_Types
-------------------------------------------------------------------------
type Unordered_List_Type is new Ordered_List_Type with private;
type Unordered_List_Access is access all Unordered_List_Type;
type Pointer_To_Unordered_List_Class is
access all Unordered_List_Type'Class;
-------------------------------------------------------------------------
-- Unordered_List_Types - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create
(List : in out Unordered_List_Type;
Parent : in out Gnoga.Gui.Base_Type'Class;
ID : in String := "");
-- Create an unordered (by default) bullet/disc list
-------------------------------------------------------------------------
-- List_Item_Types
-------------------------------------------------------------------------
type List_Item_Type is new Gnoga.Gui.Element.Element_Type with private;
type List_Item_Access is access all List_Item_Type;
type Pointer_To_List_Item_Class is access all List_Item_Type'Class;
-------------------------------------------------------------------------
-- List_Item_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Item : in out List_Item_Type;
Parent : in out Ordered_List_Type'Class;
Text : in String := "";
ID : in String := "");
-- To properly display parent should be an Ordered_List_Type or an
-- Unordered_List_Type
-------------------------------------------------------------------------
-- List_Item_Type - Properties
-------------------------------------------------------------------------
procedure Value (Element : in out List_Item_Type; Value : in String);
function Value (Element : List_Item_Type) return String;
-- Ordered list value, List_Item_Types added following set of Value will
-- follow in order.
-------------------------------------------------------------------------
-- Definition_List_Types
-------------------------------------------------------------------------
type Definition_List_Type is new Gnoga.Gui.View.View_Base_Type with private;
type Definition_List_Access is access all Definition_List_Type;
type Pointer_To_Definition_List_Class is
access all Definition_List_Type'Class;
-------------------------------------------------------------------------
-- Definition_List_Types - Creation Methods
-------------------------------------------------------------------------
procedure Create
(List : in out Definition_List_Type;
Parent : in out Gnoga.Gui.Base_Type'Class;
ID : in String := "");
-- Create a definition list of terms and descriptions
-------------------------------------------------------------------------
-- Term_Types
-------------------------------------------------------------------------
type Term_Type is new Gnoga.Gui.Element.Element_Type with private;
type Term_Access is access all Term_Type;
type Pointer_To_Term_Class is access all Term_Type'Class;
-------------------------------------------------------------------------
-- Term_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Item : in out Term_Type;
Parent : in out Definition_List_Type'Class;
Text : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Description_Types
-------------------------------------------------------------------------
type Description_Type is new Gnoga.Gui.Element.Element_Type with private;
type Description_Access is access all Description_Type;
type Pointer_To_Description_Class is access all Description_Type'Class;
-------------------------------------------------------------------------
-- Description_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Item : in out Description_Type;
Parent : in out Definition_List_Type'Class;
Text : in String := "";
ID : in String := "");
private
type Ordered_List_Type is
new Gnoga.Gui.View.View_Base_Type with null record;
type Unordered_List_Type is new Ordered_List_Type with null record;
type List_Item_Type is new Gnoga.Gui.Element.Element_Type with null record;
type Definition_List_Type is
new Gnoga.Gui.View.View_Base_Type with null record;
type Term_Type is new Gnoga.Gui.Element.Element_Type with null record;
type Description_Type is
new Gnoga.Gui.Element.Element_Type with null record;
end Ada_GUI.Gnoga.Gui.Element.List;
|
with Piles;
-- Programme de test du module Pile.
procedure Test_Piles is
package Pile_Caractere is
new Piles (Capacite => 3, T_Element => Character);
use Pile_Caractere;
-- Initialiser une pile avec 'O' puis 'K' empilés dans la pile vide.
procedure Initialiser_Avec_OK (Pile : out T_Pile) is
begin
Initialiser (Pile);
Empiler (Pile, 'O');
Empiler (Pile, 'K');
end Initialiser_Avec_OK;
procedure Tester_Est_Vide is
Pile1, Pile2 : T_Pile;
begin
Initialiser (Pile1);
pragma Assert (Est_Vide (Pile1));
Empiler (Pile1, 'A');
pragma Assert (not Est_Vide (Pile1));
Initialiser_Avec_OK (Pile2);
pragma Assert (not Est_Vide (Pile2));
end Tester_Est_Vide;
procedure Tester_Empiler is
Pile1 : T_Pile;
begin
Initialiser_Avec_OK (Pile1);
pragma Assert (not Est_Pleine (Pile1));
Empiler (Pile1, 'N');
pragma Assert ('N' = Sommet (Pile1));
pragma Assert (Est_Pleine (Pile1));
end Tester_Empiler;
procedure Tester_Depiler is
Pile1 : T_Pile;
begin
Initialiser_Avec_OK (Pile1);
Depiler (Pile1);
pragma Assert ('O' = Sommet (Pile1));
Depiler (Pile1);
pragma Assert (Est_Vide (Pile1));
end Tester_Depiler;
begin
Tester_Est_Vide;
Tester_Empiler;
Tester_Depiler;
end Test_Piles;
|
------------------------------------------------------------------------------
-- Copyright (c) 2013-2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.S_Expression declare basic types used in all children packages --
-- dealing with S-expressions. --
-- --
-- S-expressions here are defined as a half serialization mechanism, using --
-- standard syntax from http://people.csail.mit.edu/rivest/Sexp.txt --
-- --
-- Briefly, "atoms" are defined as a sequence of octets of any length, and --
-- "lists" are defined as a sequence of items, each of which being either --
-- an atom or another list. A S-expression is a sequence of octets that --
-- represents such a list. --
-- --
-- So atoms are unstructured blob of data, supposed to be the serialization --
-- of some lower-level object (e.g. a string), and they are structured as --
-- leaves in a tree. --
-- --
-- All S-expression code here assume that Stream_Element is actually an --
-- 8-bit byte. So Octet, Atom and related types are derived from --
-- Ada.Streams entries. --
------------------------------------------------------------------------------
with Ada.Streams;
package Natools.S_Expressions is
pragma Pure (Natools.S_Expressions);
-----------------
-- Basic Types --
-----------------
subtype Octet is Ada.Streams.Stream_Element;
subtype Offset is Ada.Streams.Stream_Element_Offset;
subtype Count is Ada.Streams.Stream_Element_Count;
subtype Atom is Ada.Streams.Stream_Element_Array;
Null_Atom : constant Atom (1 .. 0) := (others => <>);
function To_String (Data : in Atom) return String;
function To_Atom (Data : in String) return Atom;
function "=" (Left, Right : Atom) return Boolean
renames Ada.Streams."=";
function "<" (Left, Right : Atom) return Boolean
renames Ada.Streams."<";
function Less_Than (Left, Right : Atom) return Boolean;
-----------------------------
-- S-expression Descriptor --
-----------------------------
package Events is
type Event is
(Error,
Open_List,
Close_List,
Add_Atom,
End_Of_Input);
end Events;
type Descriptor is limited interface;
-- Descriptor interface can be implemented by objects that can
-- describe a S-expression to its holder, using an event-driven
-- interface. The current event reports error conditions, or whether
-- a beginning or end of list encountered, or whether a new atom is
-- available.
function Current_Event (Object : in Descriptor) return Events.Event
is abstract;
-- Return the current event in Object
function Current_Atom (Object : in Descriptor) return Atom is abstract;
-- Return the current atom in an Object whose state is Add_Atom
function Current_Level (Object : in Descriptor) return Natural is abstract;
-- Return the number of nested lists currently opened
procedure Query_Atom
(Object : in Descriptor;
Process : not null access procedure (Data : in Atom)) is abstract;
-- Read-in-place callback for the current atom in Object.
-- Must only be called when current event in Object is Add_Event.
procedure Read_Atom
(Object : in Descriptor;
Data : out Atom;
Length : out Count) is abstract;
-- Copy the current atom in Object to Data.
-- Must only be called when current event in Object is Add_Event.
procedure Next
(Object : in out Descriptor;
Event : out Events.Event) is abstract;
-- Update Object to reflect the next event in the S-expression
procedure Next (Object : in out Descriptor'Class);
-- Call Next discarding current event
procedure Close_Current_List (Object : in out Descriptor'Class);
-- Repeatedly call Next until reaching end-of-input or the Close_List
-- event matching the current list.
-- Note: if current event is Open_List, then this is the designated list
-- while for other events, including Close_List, the designated list
-- contains the current object or the just-closed list.
private
use type Ada.Streams.Stream_Element;
use type Ada.Streams.Stream_Element_Offset;
use type Ada.Streams.Stream_Element_Array;
use type Events.Event;
end Natools.S_Expressions;
|
with STM32_SVD; use STM32_SVD;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32GD.Startup;
with STM32GD.Vectors;
package body STM32GD.Board is
procedure Init is
begin
Clocks.Init;
RCC_Periph.AHBENR.IOPAEN := 1;
RCC_Periph.AHBENR.IOPBEN := 1;
RCC_Periph.AHBENR.IOPCEN := 1;
RCC_Periph.APB2ENR.SPI1EN := 1;
RCC_Periph.APB1ENR.USART2EN := 1;
RCC_Periph.APB2ENR.SYSCFGEN := 1;
LED.Init;
TX.Init;
RX.Init;
P1_IN.Init;
P2_IN.Init;
SCLK.Init;
MOSI.Init;
MISO.Init;
CSN.Init;
CSN.Set;
SPI.Init;
USART.Init;
RTC.Init;
STM32GD.Clear_Event;
end Init;
end STM32GD.Board;
|
package Version with Preelaborate is
Current : constant String := "0.0.1";
private
end Version; |
-- SPDX-License-Identifier: MIT
--
-- Copyright (c) 2000 - 2018 Gautier de Montmollin
-- SWITZERLAND
--
-- 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.
package body DCF.Zip.Headers is
use Ada.Streams;
-----------------------------------------------------------
-- Byte array <-> various integers, with Intel endianess --
-----------------------------------------------------------
-- Get numbers with correct trucmuche endian, to ensure
-- correct header loading on some non-Intel machines
generic
type Number is mod <>; -- range <> in Ada83 version (fake Interfaces)
function Intel_X86_Number (B : Stream_Element_Array) return Number;
function Intel_X86_Number (B : Stream_Element_Array) return Number is
N : Number := 0;
begin
for I in reverse B'Range loop
N := N * 256 + Number (B (I));
end loop;
return N;
end Intel_X86_Number;
function Intel_Nb is new Intel_X86_Number (Unsigned_16);
function Intel_Nb is new Intel_X86_Number (Unsigned_32);
-- Put numbers with correct endianess as bytes
generic
type Number is mod <>; -- range <> in Ada83 version (fake Interfaces)
Size : Stream_Element_Count;
function Intel_X86_Buffer (N : Number) return Stream_Element_Array;
function Intel_X86_Buffer (N : Number) return Stream_Element_Array is
B : Stream_Element_Array (1 .. Size);
M : Number := N;
begin
for I in B'Range loop
B (I) := Stream_Element (M and 255);
M := M / 256;
end loop;
return B;
end Intel_X86_Buffer;
function Intel_Bf is new Intel_X86_Buffer (Unsigned_16, 2);
function Intel_Bf is new Intel_X86_Buffer (Unsigned_32, 4);
---------------------
-- PK signatures --
---------------------
function Pk_Signature (Buf : Stream_Element_Array; Code : Stream_Element) return Boolean is
begin
return Buf (Buf'First .. Buf'First + 3) = (16#50#, 16#4B#, Code, Code + 1);
-- PK12, PK34, ...
end Pk_Signature;
procedure Pk_Signature (Buf : in out Stream_Element_Array; Code : Stream_Element) is
begin
Buf (1 .. 4) := (16#50#, 16#4B#, Code, Code + 1); -- PK12, PK34, ...
end Pk_Signature;
---------------------------------------------------------
-- PKZIP file header, as in central directory - PK12 --
---------------------------------------------------------
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
Header : out Central_File_Header)
is
Chb : Stream_Element_Array (1 .. 46);
begin
Blockread (Stream, Chb);
if not Pk_Signature (Chb, 1) then
raise Bad_Central_Header;
end if;
Header.Made_By_Version := Intel_Nb (Chb (5 .. 6));
Header.Short_Info.Needed_Extract_Version := Intel_Nb (Chb (7 .. 8));
Header.Short_Info.Bit_Flag := Intel_Nb (Chb (9 .. 10));
Header.Short_Info.Zip_Type := Intel_Nb (Chb (11 .. 12));
Header.Short_Info.File_Timedate :=
DCF.Streams.Convert (Unsigned_32'(Intel_Nb (Chb (13 .. 16))));
Header.Short_Info.Dd.Crc_32 := Intel_Nb (Chb (17 .. 20));
Header.Short_Info.Dd.Compressed_Size := Intel_Nb (Chb (21 .. 24));
Header.Short_Info.Dd.Uncompressed_Size := Intel_Nb (Chb (25 .. 28));
Header.Short_Info.Filename_Length := Intel_Nb (Chb (29 .. 30));
Header.Short_Info.Extra_Field_Length := Intel_Nb (Chb (31 .. 32));
Header.Comment_Length := Intel_Nb (Chb (33 .. 34));
Header.Disk_Number_Start := Intel_Nb (Chb (35 .. 36));
Header.Internal_Attributes := Intel_Nb (Chb (37 .. 38));
Header.External_Attributes := Intel_Nb (Chb (39 .. 42));
Header.Local_Header_Offset := Intel_Nb (Chb (43 .. 46));
if not Valid_Version (Header.Short_Info) then
raise Bad_Central_Header with "Archive needs invalid version to extract";
end if;
if Header.Disk_Number_Start /= 0 then
raise Bad_Central_Header with "Archive may not span multiple volumes";
end if;
if not Valid_Bitflag (Header.Short_Info) then
raise Bad_Central_Header with "Archive uses prohibited features";
end if;
end Read_And_Check;
procedure Write (Stream : in out Root_Zipstream_Type'Class; Header : in Central_File_Header) is
Chb : Stream_Element_Array (1 .. 46);
begin
Pk_Signature (Chb, 1);
Chb (5 .. 6) := Intel_Bf (Header.Made_By_Version);
Chb (7 .. 8) := Intel_Bf (Header.Short_Info.Needed_Extract_Version);
Chb (9 .. 10) := Intel_Bf (Header.Short_Info.Bit_Flag);
Chb (11 .. 12) := Intel_Bf (Header.Short_Info.Zip_Type);
Chb (13 .. 16) := Intel_Bf (DCF.Streams.Convert (Header.Short_Info.File_Timedate));
Chb (17 .. 20) := Intel_Bf (Header.Short_Info.Dd.Crc_32);
Chb (21 .. 24) := Intel_Bf (Header.Short_Info.Dd.Compressed_Size);
Chb (25 .. 28) := Intel_Bf (Header.Short_Info.Dd.Uncompressed_Size);
Chb (29 .. 30) := Intel_Bf (Header.Short_Info.Filename_Length);
Chb (31 .. 32) := Intel_Bf (Header.Short_Info.Extra_Field_Length);
Chb (33 .. 34) := Intel_Bf (Header.Comment_Length);
Chb (35 .. 36) := Intel_Bf (Header.Disk_Number_Start);
Chb (37 .. 38) := Intel_Bf (Header.Internal_Attributes);
Chb (39 .. 42) := Intel_Bf (Header.External_Attributes);
Chb (43 .. 46) := Intel_Bf (Header.Local_Header_Offset);
Stream.Write (Chb);
end Write;
-------------------------------------------------------------------------
-- PKZIP local file header, in front of every file in archive - PK34 --
-------------------------------------------------------------------------
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
Header : out Local_File_Header)
is
Lhb : Stream_Element_Array (1 .. 30);
begin
Blockread (Stream, Lhb);
if not Pk_Signature (Lhb, 3) then
raise Bad_Local_Header;
end if;
Header.Needed_Extract_Version := Intel_Nb (Lhb (5 .. 6));
Header.Bit_Flag := Intel_Nb (Lhb (7 .. 8));
Header.Zip_Type := Intel_Nb (Lhb (9 .. 10));
Header.File_Timedate :=
DCF.Streams.Convert (Unsigned_32'(Intel_Nb (Lhb (11 .. 14))));
Header.Dd.Crc_32 := Intel_Nb (Lhb (15 .. 18));
Header.Dd.Compressed_Size := Intel_Nb (Lhb (19 .. 22));
Header.Dd.Uncompressed_Size := Intel_Nb (Lhb (23 .. 26));
Header.Filename_Length := Intel_Nb (Lhb (27 .. 28));
Header.Extra_Field_Length := Intel_Nb (Lhb (29 .. 30));
if not Valid_Version (Header) then
raise Bad_Local_Header with "Archived file needs invalid version to extract";
end if;
if not Valid_Bitflag (Header) then
raise Bad_Local_Header with "Archived file uses prohibited features";
end if;
end Read_And_Check;
procedure Write (Stream : in out Root_Zipstream_Type'Class; Header : in Local_File_Header) is
Lhb : Stream_Element_Array (1 .. 30);
begin
Pk_Signature (Lhb, 3);
Lhb (5 .. 6) := Intel_Bf (Header.Needed_Extract_Version);
Lhb (7 .. 8) := Intel_Bf (Header.Bit_Flag);
Lhb (9 .. 10) := Intel_Bf (Header.Zip_Type);
Lhb (11 .. 14) := Intel_Bf (DCF.Streams.Convert (Header.File_Timedate));
Lhb (15 .. 18) := Intel_Bf (Header.Dd.Crc_32);
Lhb (19 .. 22) := Intel_Bf (Header.Dd.Compressed_Size);
Lhb (23 .. 26) := Intel_Bf (Header.Dd.Uncompressed_Size);
Lhb (27 .. 28) := Intel_Bf (Header.Filename_Length);
Lhb (29 .. 30) := Intel_Bf (Header.Extra_Field_Length);
Stream.Write (Lhb);
end Write;
---------------------------------------------
-- PKZIP end-of-central-directory - PK56 --
---------------------------------------------
procedure Copy_And_Check (Buffer : in Stream_Element_Array; The_End : out End_Of_Central_Dir) is
O : constant Stream_Element_Offset := Buffer'First - 1;
begin
if not Pk_Signature (Buffer, 5) then
raise Bad_End;
end if;
The_End.Disknum := Intel_Nb (Buffer (O + 5 .. O + 6));
The_End.Disknum_With_Start := Intel_Nb (Buffer (O + 7 .. O + 8));
The_End.Disk_Total_Entries := Intel_Nb (Buffer (O + 9 .. O + 10));
The_End.Total_Entries := Intel_Nb (Buffer (O + 11 .. O + 12));
The_End.Central_Dir_Size := Intel_Nb (Buffer (O + 13 .. O + 16));
The_End.Central_Dir_Offset := Intel_Nb (Buffer (O + 17 .. O + 20));
The_End.Main_Comment_Length := Intel_Nb (Buffer (O + 21 .. O + 22));
end Copy_And_Check;
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
The_End : out End_Of_Central_Dir)
is
Buffer : Stream_Element_Array (1 .. 22);
begin
Blockread (Stream, Buffer);
Copy_And_Check (Buffer, The_End);
end Read_And_Check;
procedure Load (Stream : in out Root_Zipstream_Type'Class; The_End : out End_Of_Central_Dir) is
Min_End_Start : Zs_Index_Type; -- min_end_start >= 1
Max_Comment : constant := 65_535;
-- In appnote.txt :
-- .ZIP file comment length 2 bytes
begin
if Size (Stream) < 22 then
raise Bad_End;
end if;
-- 20-Jun-2001: abandon search below min_end_start.
if Size (Stream) <= Max_Comment then
Min_End_Start := 1;
else
Min_End_Start := Size (Stream) - Max_Comment;
end if;
Set_Index (Stream, Min_End_Start);
declare
-- We copy a large chunk of the zip stream's tail into a buffer.
Large_Buffer : Stream_Element_Array
(0 .. Stream_Element_Count (Size (Stream) - Min_End_Start));
Ilb : Stream_Element_Offset;
X : Zs_Size_Type;
begin
Blockread (Stream, Large_Buffer);
for I in reverse Min_End_Start .. Size (Stream) - 21 loop
-- Yes, we must _search_ for the header...
-- because PKWARE put a variable-size comment _after_ it 8-(
Ilb := Stream_Element_Offset (I - Min_End_Start);
if Pk_Signature (Large_Buffer (Ilb .. Ilb + 3), 5) then
Copy_And_Check (Large_Buffer (Ilb .. Ilb + 21), The_End);
-- At this point, the buffer was successfully read, the_end is
-- is set with its standard contents.
--
-- This is the *real* position of the end-of-central-directory block to begin with:
X := I;
-- We subtract the *theoretical* (stored) position of the end-of-central-directory.
-- The theoretical position is equal to central_dir_offset + central_dir_size.
-- The theoretical position should be smaller or equal than the real position -
-- unless the archive is corrupted.
-- We do it step by step, because ZS_Size_Type was modular until rev. 644.
-- Now it's a signed 64 bits, but we don't want to change anything again...
X := X - 1;
-- i >= 1, so no dragons here. The "- 1" is for adapting
-- from the 1-based Ada index.
-- Fuzzy value, will trigger bad_end
exit when Zs_Size_Type (The_End.Central_Dir_Offset) > X;
-- Fuzzy value, will trigger bad_end
X := X - Zs_Size_Type (The_End.Central_Dir_Offset);
exit when Zs_Size_Type (The_End.Central_Dir_Size) > X;
X := X - Zs_Size_Type (The_End.Central_Dir_Size);
-- Now, x is the difference : real - theoretical.
-- x > 0 if the archive was appended to another file (typically an executable
-- for self-extraction purposes).
-- x = 0 if this is a "pure" Zip archive.
The_End.Offset_Shifting := X;
Set_Index (Stream, I + 22);
return; -- The_End found and filled -> exit
end if;
end loop;
raise Bad_End; -- Definitely no "end-of-central-directory" in this stream
end;
end Load;
procedure Write (Stream : in out Root_Zipstream_Type'Class; The_End : in End_Of_Central_Dir) is
Eb : Stream_Element_Array (1 .. 22);
begin
Pk_Signature (Eb, 5);
Eb (5 .. 6) := Intel_Bf (The_End.Disknum);
Eb (7 .. 8) := Intel_Bf (The_End.Disknum_With_Start);
Eb (9 .. 10) := Intel_Bf (The_End.Disk_Total_Entries);
Eb (11 .. 12) := Intel_Bf (The_End.Total_Entries);
Eb (13 .. 16) := Intel_Bf (The_End.Central_Dir_Size);
Eb (17 .. 20) := Intel_Bf (The_End.Central_Dir_Offset);
Eb (21 .. 22) := Intel_Bf (The_End.Main_Comment_Length);
Stream.Write (Eb);
end Write;
--------------------------------------------------------------------
-- PKZIP data descriptor, after streamed compressed data - PK78 --
--------------------------------------------------------------------
procedure Copy_And_Check
(Buffer : in Stream_Element_Array;
Descriptor : out Data_Descriptor) is
begin
if not Pk_Signature (Buffer, 7) then
raise Bad_Data_Descriptor;
end if;
Descriptor.Crc_32 := Intel_Nb (Buffer (5 .. 8));
Descriptor.Compressed_Size := Intel_Nb (Buffer (9 .. 12));
Descriptor.Uncompressed_Size := Intel_Nb (Buffer (13 .. 16));
end Copy_And_Check;
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
Descriptor : out Data_Descriptor)
is
Buffer : Stream_Element_Array (1 .. 16);
begin
Blockread (Stream, Buffer);
Copy_And_Check (Buffer, Descriptor);
end Read_And_Check;
procedure Write
(Stream : in out Root_Zipstream_Type'Class;
Descriptor : in Data_Descriptor)
is
Buffer : Stream_Element_Array (1 .. 16);
begin
Pk_Signature (Buffer, 7);
Buffer (5 .. 8) := Intel_Bf (Descriptor.Crc_32);
Buffer (9 .. 12) := Intel_Bf (Descriptor.Compressed_Size);
Buffer (13 .. 16) := Intel_Bf (Descriptor.Uncompressed_Size);
Stream.Write (Buffer);
end Write;
end DCF.Zip.Headers;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Time_Zones; use Ada.Calendar.Time_Zones;
package Apsepp.Calendar is
Time_First : constant Time := Time_Of (Year => Year_Number'First,
Month => Month_Number'First,
Day => Day_Number'First,
Seconds => Day_Duration'First);
function Unknown_Time_zone return Boolean;
function Default_Time_Offset return Time_Offset
is (if Unknown_Time_zone then
0
else
UTC_Time_Offset);
function To_ISO_8601
(Date : Time;
Time_Zone : Time_Offset := Default_Time_Offset;
Include_Time_Fraction : Boolean := False) return String;
end Apsepp.Calendar;
|
pragma Style_Checks (Off);
pragma Warnings (Off);
-------------------------------------------------------------------------
-- GLOBE_3D - GL - based, real - time, 3D engine
--
-- Copyright (c) Gautier de Montmollin/Rod Kay 2007
-- CH - 8810 Horgen
-- SWITZERLAND
-- Permission granted to use this software, without any warranty,
-- for any purpose, provided this copyright note remains attached
-- and unmodified if sources are distributed further.
-------------------------------------------------------------------------
with GL, GL.Geometry, GL.Textures, GL.Skins, GL.skinned_Geometry;
package GLOBE_3D.Impostor.Simple is -- tbd : rename 'GLOBE_3D.Impostor.standard' ?
-- can impostor any 'visual'.
type Impostor is new globe_3d.impostor.Impostor with private;
type p_Impostor is access all Impostor'Class;
procedure pre_Calculate (o : in out Impostor);
function update_Required (o : access Impostor; the_Camera : in globe_3d.p_Camera) return Boolean;
procedure update (o : in out Impostor; the_Camera : in p_Camera;
texture_Pool : in GL.textures.p_Pool);
procedure free (o : in out p_Impostor);
private
type Impostor is new globe_3d.impostor.Impostor with
record
current_Camera_look_at_Rotation : globe_3d.Matrix_33;
end record;
end GLOBE_3D.Impostor.Simple;
|
package body Multidimensional_Array is
procedure test(f: FullTime; p : PartTime; a : Afternoons) is
x : Fulltime := (others => (others => false));
y : Afternoons := ((false, false, false, false), (false, false, false, true), (false, false, true, false), (false, true, false, false));
z : Integer := Afternoons'Last(2);
begin
x(1,1) := f(2,2);
end test;
end Multidimensional_Array;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, 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. --
-- --
------------------------------------------------------------------------------
package body Message_Buffers is
-------------
-- Content --
-------------
function Content (This : Message) return String is
begin
return This.Content (1 .. This.Length);
end Content;
----------------
-- Content_At --
----------------
function Content_At (This : Message; Index : Positive) return Character is
begin
return This.Content (Index);
end Content_At;
------------
-- Length --
------------
function Length (This : Message) return Natural is
begin
return This.Length;
end Length;
-----------
-- Clear --
-----------
procedure Clear (This : in out Message) is
begin
This.Length := 0;
end Clear;
------------
-- Append --
------------
procedure Append (This : in out Message; Value : Character) is
begin
This.Length := This.Length + 1;
This.Content (This.Length) := Value;
end Append;
---------
-- Set --
---------
procedure Set (This : in out Message; To : String) is
begin
This.Content (1 .. To'Length) := To;
This.Length := To'Length;
end Set;
---------
-- Set --
---------
procedure Set (This : in out Message; To : Character) is
begin
This.Content (1) := To;
This.Length := 1;
end Set;
--------------------
-- Set_Terminator --
--------------------
procedure Set_Terminator (This : in out Message; To : Character) is
begin
This.Terminator := To;
end Set_Terminator;
----------------
-- Terminator --
----------------
function Terminator (This : Message) return Character is
begin
return This.Terminator;
end Terminator;
---------------------------------
-- Await_Transmission_Complete --
---------------------------------
procedure Await_Transmission_Complete (This : in out Message) is
begin
Suspend_Until_True (This.Transmission_Complete);
end Await_Transmission_Complete;
------------------------------
-- Await_Reception_Complete --
------------------------------
procedure Await_Reception_Complete (This : in out Message) is
begin
Suspend_Until_True (This.Reception_Complete);
end Await_Reception_Complete;
----------------------------------
-- Signal_Transmission_Complete --
----------------------------------
procedure Signal_Transmission_Complete (This : in out Message) is
begin
Set_True (This.Transmission_Complete);
end Signal_Transmission_Complete;
-------------------------------
-- Signal_Reception_Complete --
-------------------------------
procedure Signal_Reception_Complete (This : in out Message) is
begin
Set_True (This.Reception_Complete);
end Signal_Reception_Complete;
----------------
-- Note_Error --
----------------
procedure Note_Error (This : in out Message; Condition : Error_Conditions) is
begin
This.Error_Status := This.Error_Status or Condition;
end Note_Error;
---------------------
-- Errors_Detected --
---------------------
function Errors_Detected (This : Message) return Error_Conditions is
begin
return This.Error_Status;
end Errors_Detected;
------------------
-- Clear_Errors --
------------------
procedure Clear_Errors (This : in out Message) is
begin
This.Error_Status := No_Error_Detected;
end Clear_Errors;
---------------
-- Has_Error --
---------------
function Has_Error (This : Message; Condition : Error_Conditions) return Boolean is
begin
return (This.Error_Status and Condition) /= 0;
end Has_Error;
end Message_Buffers;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- N M A K E --
-- --
-- B o d y --
-- --
-- Generated by xnmake revision 1.2 using --
-- sinfo.ads revision 1.6 --
-- nmake.adt revision 1.1 --
-- --
-- Copyright (C) 1992-2001 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 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram order checking, since the routines here are
-- generated automatically in order.
with Atree; use Atree;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
package body Nmake is
function Make_Unused_At_Start (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Unused_At_Start, Sloc);
begin
return N;
end Make_Unused_At_Start;
function Make_Unused_At_End (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Unused_At_End, Sloc);
begin
return N;
end Make_Unused_At_End;
function Make_Identifier (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Identifier, Sloc);
begin
Set_Chars (N, Chars);
return N;
end Make_Identifier;
function Make_Integer_Literal (Sloc : Source_Ptr;
Intval : Uint)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Integer_Literal, Sloc);
begin
Set_Intval (N, Intval);
return N;
end Make_Integer_Literal;
function Make_Real_Literal (Sloc : Source_Ptr;
Realval : Ureal)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Real_Literal, Sloc);
begin
Set_Realval (N, Realval);
return N;
end Make_Real_Literal;
function Make_Character_Literal (Sloc : Source_Ptr;
Chars : Name_Id;
Char_Literal_Value : Char_Code)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Character_Literal, Sloc);
begin
Set_Chars (N, Chars);
Set_Char_Literal_Value (N, Char_Literal_Value);
return N;
end Make_Character_Literal;
function Make_String_Literal (Sloc : Source_Ptr;
Strval : String_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_String_Literal, Sloc);
begin
Set_Strval (N, Strval);
return N;
end Make_String_Literal;
function Make_Pragma (Sloc : Source_Ptr;
Chars : Name_Id;
Pragma_Argument_Associations : List_Id := No_List;
Debug_Statement : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Pragma, Sloc);
begin
Set_Chars (N, Chars);
Set_Pragma_Argument_Associations
(N, Pragma_Argument_Associations);
Set_Debug_Statement (N, Debug_Statement);
return N;
end Make_Pragma;
function Make_Pragma_Argument_Association (Sloc : Source_Ptr;
Chars : Name_Id := No_Name;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Pragma_Argument_Association, Sloc);
begin
Set_Chars (N, Chars);
Set_Expression (N, Expression);
return N;
end Make_Pragma_Argument_Association;
function Make_Defining_Identifier (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id
is
N : constant Node_Id :=
New_Entity (N_Defining_Identifier, Sloc);
begin
Set_Chars (N, Chars);
return N;
end Make_Defining_Identifier;
function Make_Full_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Type_Definition : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Full_Type_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discriminant_Specifications (N, Discriminant_Specifications);
Set_Type_Definition (N, Type_Definition);
return N;
end Make_Full_Type_Declaration;
function Make_Subtype_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Subtype_Indication : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subtype_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Subtype_Indication (N, Subtype_Indication);
return N;
end Make_Subtype_Declaration;
function Make_Subtype_Indication (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Constraint : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subtype_Indication, Sloc);
begin
Set_Subtype_Mark (N, Subtype_Mark);
Set_Constraint (N, Constraint);
return N;
end Make_Subtype_Indication;
function Make_Object_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Aliased_Present : Boolean := False;
Constant_Present : Boolean := False;
Object_Definition : Node_Id;
Expression : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Object_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Aliased_Present (N, Aliased_Present);
Set_Constant_Present (N, Constant_Present);
Set_Object_Definition (N, Object_Definition);
Set_Expression (N, Expression);
return N;
end Make_Object_Declaration;
function Make_Number_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Number_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Expression (N, Expression);
return N;
end Make_Number_Declaration;
function Make_Derived_Type_Definition (Sloc : Source_Ptr;
Abstract_Present : Boolean := False;
Subtype_Indication : Node_Id;
Record_Extension_Part : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Derived_Type_Definition, Sloc);
begin
Set_Abstract_Present (N, Abstract_Present);
Set_Subtype_Indication (N, Subtype_Indication);
Set_Record_Extension_Part (N, Record_Extension_Part);
return N;
end Make_Derived_Type_Definition;
function Make_Range_Constraint (Sloc : Source_Ptr;
Range_Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Range_Constraint, Sloc);
begin
Set_Range_Expression (N, Range_Expression);
return N;
end Make_Range_Constraint;
function Make_Range (Sloc : Source_Ptr;
Low_Bound : Node_Id;
High_Bound : Node_Id;
Includes_Infinities : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Range, Sloc);
begin
Set_Low_Bound (N, Low_Bound);
Set_High_Bound (N, High_Bound);
Set_Includes_Infinities (N, Includes_Infinities);
return N;
end Make_Range;
function Make_Enumeration_Type_Definition (Sloc : Source_Ptr;
Literals : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Enumeration_Type_Definition, Sloc);
begin
Set_Literals (N, Literals);
return N;
end Make_Enumeration_Type_Definition;
function Make_Defining_Character_Literal (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id
is
N : constant Node_Id :=
New_Entity (N_Defining_Character_Literal, Sloc);
begin
Set_Chars (N, Chars);
return N;
end Make_Defining_Character_Literal;
function Make_Signed_Integer_Type_Definition (Sloc : Source_Ptr;
Low_Bound : Node_Id;
High_Bound : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Signed_Integer_Type_Definition, Sloc);
begin
Set_Low_Bound (N, Low_Bound);
Set_High_Bound (N, High_Bound);
return N;
end Make_Signed_Integer_Type_Definition;
function Make_Modular_Type_Definition (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Modular_Type_Definition, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Modular_Type_Definition;
function Make_Floating_Point_Definition (Sloc : Source_Ptr;
Digits_Expression : Node_Id;
Real_Range_Specification : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Floating_Point_Definition, Sloc);
begin
Set_Digits_Expression (N, Digits_Expression);
Set_Real_Range_Specification (N, Real_Range_Specification);
return N;
end Make_Floating_Point_Definition;
function Make_Real_Range_Specification (Sloc : Source_Ptr;
Low_Bound : Node_Id;
High_Bound : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Real_Range_Specification, Sloc);
begin
Set_Low_Bound (N, Low_Bound);
Set_High_Bound (N, High_Bound);
return N;
end Make_Real_Range_Specification;
function Make_Ordinary_Fixed_Point_Definition (Sloc : Source_Ptr;
Delta_Expression : Node_Id;
Real_Range_Specification : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Ordinary_Fixed_Point_Definition, Sloc);
begin
Set_Delta_Expression (N, Delta_Expression);
Set_Real_Range_Specification (N, Real_Range_Specification);
return N;
end Make_Ordinary_Fixed_Point_Definition;
function Make_Decimal_Fixed_Point_Definition (Sloc : Source_Ptr;
Delta_Expression : Node_Id;
Digits_Expression : Node_Id;
Real_Range_Specification : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Decimal_Fixed_Point_Definition, Sloc);
begin
Set_Delta_Expression (N, Delta_Expression);
Set_Digits_Expression (N, Digits_Expression);
Set_Real_Range_Specification (N, Real_Range_Specification);
return N;
end Make_Decimal_Fixed_Point_Definition;
function Make_Digits_Constraint (Sloc : Source_Ptr;
Digits_Expression : Node_Id;
Range_Constraint : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Digits_Constraint, Sloc);
begin
Set_Digits_Expression (N, Digits_Expression);
Set_Range_Constraint (N, Range_Constraint);
return N;
end Make_Digits_Constraint;
function Make_Unconstrained_Array_Definition (Sloc : Source_Ptr;
Subtype_Marks : List_Id;
Aliased_Present : Boolean := False;
Subtype_Indication : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Unconstrained_Array_Definition, Sloc);
begin
Set_Subtype_Marks (N, Subtype_Marks);
Set_Aliased_Present (N, Aliased_Present);
Set_Subtype_Indication (N, Subtype_Indication);
return N;
end Make_Unconstrained_Array_Definition;
function Make_Constrained_Array_Definition (Sloc : Source_Ptr;
Discrete_Subtype_Definitions : List_Id;
Aliased_Present : Boolean := False;
Subtype_Indication : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Constrained_Array_Definition, Sloc);
begin
Set_Discrete_Subtype_Definitions
(N, Discrete_Subtype_Definitions);
Set_Aliased_Present (N, Aliased_Present);
Set_Subtype_Indication (N, Subtype_Indication);
return N;
end Make_Constrained_Array_Definition;
function Make_Discriminant_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Type : Node_Id;
Expression : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Discriminant_Specification, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discriminant_Type (N, Discriminant_Type);
Set_Expression (N, Expression);
return N;
end Make_Discriminant_Specification;
function Make_Index_Or_Discriminant_Constraint (Sloc : Source_Ptr;
Constraints : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Index_Or_Discriminant_Constraint, Sloc);
begin
Set_Constraints (N, Constraints);
return N;
end Make_Index_Or_Discriminant_Constraint;
function Make_Discriminant_Association (Sloc : Source_Ptr;
Selector_Names : List_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Discriminant_Association, Sloc);
begin
Set_Selector_Names (N, Selector_Names);
Set_Expression (N, Expression);
return N;
end Make_Discriminant_Association;
function Make_Record_Definition (Sloc : Source_Ptr;
End_Label : Node_Id := Empty;
Abstract_Present : Boolean := False;
Tagged_Present : Boolean := False;
Limited_Present : Boolean := False;
Component_List : Node_Id;
Null_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Record_Definition, Sloc);
begin
Set_End_Label (N, End_Label);
Set_Abstract_Present (N, Abstract_Present);
Set_Tagged_Present (N, Tagged_Present);
Set_Limited_Present (N, Limited_Present);
Set_Component_List (N, Component_List);
Set_Null_Present (N, Null_Present);
return N;
end Make_Record_Definition;
function Make_Component_List (Sloc : Source_Ptr;
Component_Items : List_Id;
Variant_Part : Node_Id := Empty;
Null_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Component_List, Sloc);
begin
Set_Component_Items (N, Component_Items);
Set_Variant_Part (N, Variant_Part);
Set_Null_Present (N, Null_Present);
return N;
end Make_Component_List;
function Make_Component_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Aliased_Present : Boolean := False;
Subtype_Indication : Node_Id;
Expression : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Component_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Aliased_Present (N, Aliased_Present);
Set_Subtype_Indication (N, Subtype_Indication);
Set_Expression (N, Expression);
return N;
end Make_Component_Declaration;
function Make_Variant_Part (Sloc : Source_Ptr;
Name : Node_Id;
Variants : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Variant_Part, Sloc);
begin
Set_Name (N, Name);
Set_Variants (N, Variants);
return N;
end Make_Variant_Part;
function Make_Variant (Sloc : Source_Ptr;
Discrete_Choices : List_Id;
Component_List : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Variant, Sloc);
begin
Set_Discrete_Choices (N, Discrete_Choices);
Set_Component_List (N, Component_List);
return N;
end Make_Variant;
function Make_Others_Choice (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Others_Choice, Sloc);
begin
return N;
end Make_Others_Choice;
function Make_Access_To_Object_Definition (Sloc : Source_Ptr;
All_Present : Boolean := False;
Subtype_Indication : Node_Id;
Constant_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Access_To_Object_Definition, Sloc);
begin
Set_All_Present (N, All_Present);
Set_Subtype_Indication (N, Subtype_Indication);
Set_Constant_Present (N, Constant_Present);
return N;
end Make_Access_To_Object_Definition;
function Make_Access_Function_Definition (Sloc : Source_Ptr;
Protected_Present : Boolean := False;
Parameter_Specifications : List_Id := No_List;
Subtype_Mark : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Access_Function_Definition, Sloc);
begin
Set_Protected_Present (N, Protected_Present);
Set_Parameter_Specifications (N, Parameter_Specifications);
Set_Subtype_Mark (N, Subtype_Mark);
return N;
end Make_Access_Function_Definition;
function Make_Access_Procedure_Definition (Sloc : Source_Ptr;
Protected_Present : Boolean := False;
Parameter_Specifications : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Access_Procedure_Definition, Sloc);
begin
Set_Protected_Present (N, Protected_Present);
Set_Parameter_Specifications (N, Parameter_Specifications);
return N;
end Make_Access_Procedure_Definition;
function Make_Access_Definition (Sloc : Source_Ptr;
Subtype_Mark : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Access_Definition, Sloc);
begin
Set_Subtype_Mark (N, Subtype_Mark);
return N;
end Make_Access_Definition;
function Make_Incomplete_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Incomplete_Type_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discriminant_Specifications (N, Discriminant_Specifications);
Set_Unknown_Discriminants_Present
(N, Unknown_Discriminants_Present);
return N;
end Make_Incomplete_Type_Declaration;
function Make_Explicit_Dereference (Sloc : Source_Ptr;
Prefix : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Explicit_Dereference, Sloc);
begin
Set_Prefix (N, Prefix);
return N;
end Make_Explicit_Dereference;
function Make_Indexed_Component (Sloc : Source_Ptr;
Prefix : Node_Id;
Expressions : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Indexed_Component, Sloc);
begin
Set_Prefix (N, Prefix);
Set_Expressions (N, Expressions);
return N;
end Make_Indexed_Component;
function Make_Slice (Sloc : Source_Ptr;
Prefix : Node_Id;
Discrete_Range : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Slice, Sloc);
begin
Set_Prefix (N, Prefix);
Set_Discrete_Range (N, Discrete_Range);
return N;
end Make_Slice;
function Make_Selected_Component (Sloc : Source_Ptr;
Prefix : Node_Id;
Selector_Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Selected_Component, Sloc);
begin
Set_Prefix (N, Prefix);
Set_Selector_Name (N, Selector_Name);
return N;
end Make_Selected_Component;
function Make_Attribute_Reference (Sloc : Source_Ptr;
Prefix : Node_Id;
Attribute_Name : Name_Id;
Expressions : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Attribute_Reference, Sloc);
begin
Set_Prefix (N, Prefix);
Set_Attribute_Name (N, Attribute_Name);
Set_Expressions (N, Expressions);
return N;
end Make_Attribute_Reference;
function Make_Aggregate (Sloc : Source_Ptr;
Expressions : List_Id := No_List;
Component_Associations : List_Id := No_List;
Null_Record_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Aggregate, Sloc);
begin
Set_Expressions (N, Expressions);
Set_Component_Associations (N, Component_Associations);
Set_Null_Record_Present (N, Null_Record_Present);
return N;
end Make_Aggregate;
function Make_Component_Association (Sloc : Source_Ptr;
Choices : List_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Component_Association, Sloc);
begin
Set_Choices (N, Choices);
Set_Expression (N, Expression);
return N;
end Make_Component_Association;
function Make_Extension_Aggregate (Sloc : Source_Ptr;
Ancestor_Part : Node_Id;
Expressions : List_Id := No_List;
Component_Associations : List_Id := No_List;
Null_Record_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Extension_Aggregate, Sloc);
begin
Set_Ancestor_Part (N, Ancestor_Part);
Set_Expressions (N, Expressions);
Set_Component_Associations (N, Component_Associations);
Set_Null_Record_Present (N, Null_Record_Present);
return N;
end Make_Extension_Aggregate;
function Make_Null (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Null, Sloc);
begin
return N;
end Make_Null;
function Make_And_Then (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_And_Then, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
return N;
end Make_And_Then;
function Make_Or_Else (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Or_Else, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
return N;
end Make_Or_Else;
function Make_In (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_In, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
return N;
end Make_In;
function Make_Not_In (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Not_In, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
return N;
end Make_Not_In;
function Make_Op_And (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_And, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_And);
Set_Entity (N, Standard_Op_And);
return N;
end Make_Op_And;
function Make_Op_Or (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Or, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Or);
Set_Entity (N, Standard_Op_Or);
return N;
end Make_Op_Or;
function Make_Op_Xor (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Xor, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Xor);
Set_Entity (N, Standard_Op_Xor);
return N;
end Make_Op_Xor;
function Make_Op_Eq (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Eq, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Eq);
Set_Entity (N, Standard_Op_Eq);
return N;
end Make_Op_Eq;
function Make_Op_Ne (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Ne, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Ne);
Set_Entity (N, Standard_Op_Ne);
return N;
end Make_Op_Ne;
function Make_Op_Lt (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Lt, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Lt);
Set_Entity (N, Standard_Op_Lt);
return N;
end Make_Op_Lt;
function Make_Op_Le (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Le, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Le);
Set_Entity (N, Standard_Op_Le);
return N;
end Make_Op_Le;
function Make_Op_Gt (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Gt, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Gt);
Set_Entity (N, Standard_Op_Gt);
return N;
end Make_Op_Gt;
function Make_Op_Ge (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Ge, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Ge);
Set_Entity (N, Standard_Op_Ge);
return N;
end Make_Op_Ge;
function Make_Op_Add (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Add, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Add);
Set_Entity (N, Standard_Op_Add);
return N;
end Make_Op_Add;
function Make_Op_Subtract (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Subtract, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Subtract);
Set_Entity (N, Standard_Op_Subtract);
return N;
end Make_Op_Subtract;
function Make_Op_Concat (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Concat, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Concat);
Set_Entity (N, Standard_Op_Concat);
return N;
end Make_Op_Concat;
function Make_Op_Multiply (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Multiply, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Multiply);
Set_Entity (N, Standard_Op_Multiply);
return N;
end Make_Op_Multiply;
function Make_Op_Divide (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Divide, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Divide);
Set_Entity (N, Standard_Op_Divide);
return N;
end Make_Op_Divide;
function Make_Op_Mod (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Mod, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Mod);
Set_Entity (N, Standard_Op_Mod);
return N;
end Make_Op_Mod;
function Make_Op_Rem (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Rem, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Rem);
Set_Entity (N, Standard_Op_Rem);
return N;
end Make_Op_Rem;
function Make_Op_Expon (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Expon, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Expon);
Set_Entity (N, Standard_Op_Expon);
return N;
end Make_Op_Expon;
function Make_Op_Plus (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Plus, Sloc);
begin
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Add);
Set_Entity (N, Standard_Op_Plus);
return N;
end Make_Op_Plus;
function Make_Op_Minus (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Minus, Sloc);
begin
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Subtract);
Set_Entity (N, Standard_Op_Minus);
return N;
end Make_Op_Minus;
function Make_Op_Abs (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Abs, Sloc);
begin
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Abs);
Set_Entity (N, Standard_Op_Abs);
return N;
end Make_Op_Abs;
function Make_Op_Not (Sloc : Source_Ptr;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Not, Sloc);
begin
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Op_Not);
Set_Entity (N, Standard_Op_Not);
return N;
end Make_Op_Not;
function Make_Type_Conversion (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Type_Conversion, Sloc);
begin
Set_Subtype_Mark (N, Subtype_Mark);
Set_Expression (N, Expression);
return N;
end Make_Type_Conversion;
function Make_Qualified_Expression (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Qualified_Expression, Sloc);
begin
Set_Subtype_Mark (N, Subtype_Mark);
Set_Expression (N, Expression);
return N;
end Make_Qualified_Expression;
function Make_Allocator (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Allocator, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Allocator;
function Make_Null_Statement (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Null_Statement, Sloc);
begin
return N;
end Make_Null_Statement;
function Make_Label (Sloc : Source_Ptr;
Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Label, Sloc);
begin
Set_Identifier (N, Identifier);
return N;
end Make_Label;
function Make_Assignment_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Assignment_Statement, Sloc);
begin
Set_Name (N, Name);
Set_Expression (N, Expression);
return N;
end Make_Assignment_Statement;
function Make_If_Statement (Sloc : Source_Ptr;
Condition : Node_Id;
Then_Statements : List_Id;
Elsif_Parts : List_Id := No_List;
Else_Statements : List_Id := No_List;
End_Span : Uint := No_Uint)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_If_Statement, Sloc);
begin
Set_Condition (N, Condition);
Set_Then_Statements (N, Then_Statements);
Set_Elsif_Parts (N, Elsif_Parts);
Set_Else_Statements (N, Else_Statements);
Set_End_Span (N, End_Span);
return N;
end Make_If_Statement;
function Make_Elsif_Part (Sloc : Source_Ptr;
Condition : Node_Id;
Then_Statements : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Elsif_Part, Sloc);
begin
Set_Condition (N, Condition);
Set_Then_Statements (N, Then_Statements);
return N;
end Make_Elsif_Part;
function Make_Case_Statement (Sloc : Source_Ptr;
Expression : Node_Id;
Alternatives : List_Id;
End_Span : Uint := No_Uint)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Case_Statement, Sloc);
begin
Set_Expression (N, Expression);
Set_Alternatives (N, Alternatives);
Set_End_Span (N, End_Span);
return N;
end Make_Case_Statement;
function Make_Case_Statement_Alternative (Sloc : Source_Ptr;
Discrete_Choices : List_Id;
Statements : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Case_Statement_Alternative, Sloc);
begin
Set_Discrete_Choices (N, Discrete_Choices);
Set_Statements (N, Statements);
return N;
end Make_Case_Statement_Alternative;
function Make_Loop_Statement (Sloc : Source_Ptr;
Identifier : Node_Id := Empty;
Iteration_Scheme : Node_Id := Empty;
Statements : List_Id;
End_Label : Node_Id;
Has_Created_Identifier : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Loop_Statement, Sloc);
begin
Set_Identifier (N, Identifier);
Set_Iteration_Scheme (N, Iteration_Scheme);
Set_Statements (N, Statements);
Set_End_Label (N, End_Label);
Set_Has_Created_Identifier (N, Has_Created_Identifier);
return N;
end Make_Loop_Statement;
function Make_Iteration_Scheme (Sloc : Source_Ptr;
Condition : Node_Id := Empty;
Loop_Parameter_Specification : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Iteration_Scheme, Sloc);
begin
Set_Condition (N, Condition);
Set_Loop_Parameter_Specification
(N, Loop_Parameter_Specification);
return N;
end Make_Iteration_Scheme;
function Make_Loop_Parameter_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Reverse_Present : Boolean := False;
Discrete_Subtype_Definition : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Loop_Parameter_Specification, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Reverse_Present (N, Reverse_Present);
Set_Discrete_Subtype_Definition (N, Discrete_Subtype_Definition);
return N;
end Make_Loop_Parameter_Specification;
function Make_Block_Statement (Sloc : Source_Ptr;
Identifier : Node_Id := Empty;
Declarations : List_Id := No_List;
Handled_Statement_Sequence : Node_Id;
Has_Created_Identifier : Boolean := False;
Is_Task_Allocation_Block : Boolean := False;
Is_Asynchronous_Call_Block : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Block_Statement, Sloc);
begin
Set_Identifier (N, Identifier);
Set_Declarations (N, Declarations);
Set_Handled_Statement_Sequence (N, Handled_Statement_Sequence);
Set_Has_Created_Identifier (N, Has_Created_Identifier);
Set_Is_Task_Allocation_Block (N, Is_Task_Allocation_Block);
Set_Is_Asynchronous_Call_Block (N, Is_Asynchronous_Call_Block);
return N;
end Make_Block_Statement;
function Make_Exit_Statement (Sloc : Source_Ptr;
Name : Node_Id := Empty;
Condition : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Exit_Statement, Sloc);
begin
Set_Name (N, Name);
Set_Condition (N, Condition);
return N;
end Make_Exit_Statement;
function Make_Goto_Statement (Sloc : Source_Ptr;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Goto_Statement, Sloc);
begin
Set_Name (N, Name);
return N;
end Make_Goto_Statement;
function Make_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subprogram_Declaration, Sloc);
begin
Set_Specification (N, Specification);
return N;
end Make_Subprogram_Declaration;
function Make_Abstract_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Abstract_Subprogram_Declaration, Sloc);
begin
Set_Specification (N, Specification);
return N;
end Make_Abstract_Subprogram_Declaration;
function Make_Function_Specification (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Parameter_Specifications : List_Id := No_List;
Subtype_Mark : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Function_Specification, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Parameter_Specifications (N, Parameter_Specifications);
Set_Subtype_Mark (N, Subtype_Mark);
return N;
end Make_Function_Specification;
function Make_Procedure_Specification (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Parameter_Specifications : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Procedure_Specification, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Parameter_Specifications (N, Parameter_Specifications);
return N;
end Make_Procedure_Specification;
function Make_Designator (Sloc : Source_Ptr;
Name : Node_Id;
Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Designator, Sloc);
begin
Set_Name (N, Name);
Set_Identifier (N, Identifier);
return N;
end Make_Designator;
function Make_Defining_Program_Unit_Name (Sloc : Source_Ptr;
Name : Node_Id;
Defining_Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Defining_Program_Unit_Name, Sloc);
begin
Set_Name (N, Name);
Set_Defining_Identifier (N, Defining_Identifier);
return N;
end Make_Defining_Program_Unit_Name;
function Make_Operator_Symbol (Sloc : Source_Ptr;
Chars : Name_Id;
Strval : String_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Operator_Symbol, Sloc);
begin
Set_Chars (N, Chars);
Set_Strval (N, Strval);
return N;
end Make_Operator_Symbol;
function Make_Defining_Operator_Symbol (Sloc : Source_Ptr;
Chars : Name_Id)
return Node_Id
is
N : constant Node_Id :=
New_Entity (N_Defining_Operator_Symbol, Sloc);
begin
Set_Chars (N, Chars);
return N;
end Make_Defining_Operator_Symbol;
function Make_Parameter_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
In_Present : Boolean := False;
Out_Present : Boolean := False;
Parameter_Type : Node_Id;
Expression : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Parameter_Specification, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_In_Present (N, In_Present);
Set_Out_Present (N, Out_Present);
Set_Parameter_Type (N, Parameter_Type);
Set_Expression (N, Expression);
return N;
end Make_Parameter_Specification;
function Make_Subprogram_Body (Sloc : Source_Ptr;
Specification : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id;
Bad_Is_Detected : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subprogram_Body, Sloc);
begin
Set_Specification (N, Specification);
Set_Declarations (N, Declarations);
Set_Handled_Statement_Sequence (N, Handled_Statement_Sequence);
Set_Bad_Is_Detected (N, Bad_Is_Detected);
return N;
end Make_Subprogram_Body;
function Make_Procedure_Call_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Parameter_Associations : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Procedure_Call_Statement, Sloc);
begin
Set_Name (N, Name);
Set_Parameter_Associations (N, Parameter_Associations);
return N;
end Make_Procedure_Call_Statement;
function Make_Function_Call (Sloc : Source_Ptr;
Name : Node_Id;
Parameter_Associations : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Function_Call, Sloc);
begin
Set_Name (N, Name);
Set_Parameter_Associations (N, Parameter_Associations);
return N;
end Make_Function_Call;
function Make_Parameter_Association (Sloc : Source_Ptr;
Selector_Name : Node_Id;
Explicit_Actual_Parameter : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Parameter_Association, Sloc);
begin
Set_Selector_Name (N, Selector_Name);
Set_Explicit_Actual_Parameter (N, Explicit_Actual_Parameter);
return N;
end Make_Parameter_Association;
function Make_Return_Statement (Sloc : Source_Ptr;
Expression : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Return_Statement, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Return_Statement;
function Make_Package_Declaration (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Package_Declaration, Sloc);
begin
Set_Specification (N, Specification);
return N;
end Make_Package_Declaration;
function Make_Package_Specification (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Visible_Declarations : List_Id;
Private_Declarations : List_Id := No_List;
End_Label : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Package_Specification, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Visible_Declarations (N, Visible_Declarations);
Set_Private_Declarations (N, Private_Declarations);
Set_End_Label (N, End_Label);
return N;
end Make_Package_Specification;
function Make_Package_Body (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Package_Body, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Declarations (N, Declarations);
Set_Handled_Statement_Sequence (N, Handled_Statement_Sequence);
return N;
end Make_Package_Body;
function Make_Private_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False;
Abstract_Present : Boolean := False;
Tagged_Present : Boolean := False;
Limited_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Private_Type_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discriminant_Specifications (N, Discriminant_Specifications);
Set_Unknown_Discriminants_Present
(N, Unknown_Discriminants_Present);
Set_Abstract_Present (N, Abstract_Present);
Set_Tagged_Present (N, Tagged_Present);
Set_Limited_Present (N, Limited_Present);
return N;
end Make_Private_Type_Declaration;
function Make_Private_Extension_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False;
Abstract_Present : Boolean := False;
Subtype_Indication : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Private_Extension_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discriminant_Specifications (N, Discriminant_Specifications);
Set_Unknown_Discriminants_Present
(N, Unknown_Discriminants_Present);
Set_Abstract_Present (N, Abstract_Present);
Set_Subtype_Indication (N, Subtype_Indication);
return N;
end Make_Private_Extension_Declaration;
function Make_Use_Package_Clause (Sloc : Source_Ptr;
Names : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Use_Package_Clause, Sloc);
begin
Set_Names (N, Names);
return N;
end Make_Use_Package_Clause;
function Make_Use_Type_Clause (Sloc : Source_Ptr;
Subtype_Marks : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Use_Type_Clause, Sloc);
begin
Set_Subtype_Marks (N, Subtype_Marks);
return N;
end Make_Use_Type_Clause;
function Make_Object_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Subtype_Mark : Node_Id;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Object_Renaming_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Subtype_Mark (N, Subtype_Mark);
Set_Name (N, Name);
return N;
end Make_Object_Renaming_Declaration;
function Make_Exception_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Exception_Renaming_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Name (N, Name);
return N;
end Make_Exception_Renaming_Declaration;
function Make_Package_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Package_Renaming_Declaration, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Name (N, Name);
return N;
end Make_Package_Renaming_Declaration;
function Make_Subprogram_Renaming_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subprogram_Renaming_Declaration, Sloc);
begin
Set_Specification (N, Specification);
Set_Name (N, Name);
return N;
end Make_Subprogram_Renaming_Declaration;
function Make_Generic_Package_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Generic_Package_Renaming_Declaration, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Name (N, Name);
return N;
end Make_Generic_Package_Renaming_Declaration;
function Make_Generic_Procedure_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Generic_Procedure_Renaming_Declaration, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Name (N, Name);
return N;
end Make_Generic_Procedure_Renaming_Declaration;
function Make_Generic_Function_Renaming_Declaration (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Generic_Function_Renaming_Declaration, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Name (N, Name);
return N;
end Make_Generic_Function_Renaming_Declaration;
function Make_Task_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Task_Definition : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Task_Type_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discriminant_Specifications (N, Discriminant_Specifications);
Set_Task_Definition (N, Task_Definition);
return N;
end Make_Task_Type_Declaration;
function Make_Single_Task_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Task_Definition : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Single_Task_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Task_Definition (N, Task_Definition);
return N;
end Make_Single_Task_Declaration;
function Make_Task_Definition (Sloc : Source_Ptr;
Visible_Declarations : List_Id;
Private_Declarations : List_Id := No_List;
End_Label : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Task_Definition, Sloc);
begin
Set_Visible_Declarations (N, Visible_Declarations);
Set_Private_Declarations (N, Private_Declarations);
Set_End_Label (N, End_Label);
return N;
end Make_Task_Definition;
function Make_Task_Body (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Task_Body, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Declarations (N, Declarations);
Set_Handled_Statement_Sequence (N, Handled_Statement_Sequence);
return N;
end Make_Task_Body;
function Make_Protected_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Protected_Definition : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Protected_Type_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discriminant_Specifications (N, Discriminant_Specifications);
Set_Protected_Definition (N, Protected_Definition);
return N;
end Make_Protected_Type_Declaration;
function Make_Single_Protected_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Protected_Definition : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Single_Protected_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Protected_Definition (N, Protected_Definition);
return N;
end Make_Single_Protected_Declaration;
function Make_Protected_Definition (Sloc : Source_Ptr;
Visible_Declarations : List_Id;
Private_Declarations : List_Id := No_List;
End_Label : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Protected_Definition, Sloc);
begin
Set_Visible_Declarations (N, Visible_Declarations);
Set_Private_Declarations (N, Private_Declarations);
Set_End_Label (N, End_Label);
return N;
end Make_Protected_Definition;
function Make_Protected_Body (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Declarations : List_Id;
End_Label : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Protected_Body, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Declarations (N, Declarations);
Set_End_Label (N, End_Label);
return N;
end Make_Protected_Body;
function Make_Entry_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discrete_Subtype_Definition : Node_Id := Empty;
Parameter_Specifications : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Entry_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discrete_Subtype_Definition (N, Discrete_Subtype_Definition);
Set_Parameter_Specifications (N, Parameter_Specifications);
return N;
end Make_Entry_Declaration;
function Make_Accept_Statement (Sloc : Source_Ptr;
Entry_Direct_Name : Node_Id;
Entry_Index : Node_Id := Empty;
Parameter_Specifications : List_Id := No_List;
Handled_Statement_Sequence : Node_Id;
Declarations : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Accept_Statement, Sloc);
begin
Set_Entry_Direct_Name (N, Entry_Direct_Name);
Set_Entry_Index (N, Entry_Index);
Set_Parameter_Specifications (N, Parameter_Specifications);
Set_Handled_Statement_Sequence (N, Handled_Statement_Sequence);
Set_Declarations (N, Declarations);
return N;
end Make_Accept_Statement;
function Make_Entry_Body (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Entry_Body_Formal_Part : Node_Id;
Declarations : List_Id;
Handled_Statement_Sequence : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Entry_Body, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Entry_Body_Formal_Part (N, Entry_Body_Formal_Part);
Set_Declarations (N, Declarations);
Set_Handled_Statement_Sequence (N, Handled_Statement_Sequence);
return N;
end Make_Entry_Body;
function Make_Entry_Body_Formal_Part (Sloc : Source_Ptr;
Entry_Index_Specification : Node_Id := Empty;
Parameter_Specifications : List_Id := No_List;
Condition : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Entry_Body_Formal_Part, Sloc);
begin
Set_Entry_Index_Specification (N, Entry_Index_Specification);
Set_Parameter_Specifications (N, Parameter_Specifications);
Set_Condition (N, Condition);
return N;
end Make_Entry_Body_Formal_Part;
function Make_Entry_Index_Specification (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Discrete_Subtype_Definition : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Entry_Index_Specification, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Discrete_Subtype_Definition (N, Discrete_Subtype_Definition);
return N;
end Make_Entry_Index_Specification;
function Make_Entry_Call_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Parameter_Associations : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Entry_Call_Statement, Sloc);
begin
Set_Name (N, Name);
Set_Parameter_Associations (N, Parameter_Associations);
return N;
end Make_Entry_Call_Statement;
function Make_Requeue_Statement (Sloc : Source_Ptr;
Name : Node_Id;
Abort_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Requeue_Statement, Sloc);
begin
Set_Name (N, Name);
Set_Abort_Present (N, Abort_Present);
return N;
end Make_Requeue_Statement;
function Make_Delay_Until_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Delay_Until_Statement, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Delay_Until_Statement;
function Make_Delay_Relative_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Delay_Relative_Statement, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Delay_Relative_Statement;
function Make_Selective_Accept (Sloc : Source_Ptr;
Select_Alternatives : List_Id;
Else_Statements : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Selective_Accept, Sloc);
begin
Set_Select_Alternatives (N, Select_Alternatives);
Set_Else_Statements (N, Else_Statements);
return N;
end Make_Selective_Accept;
function Make_Accept_Alternative (Sloc : Source_Ptr;
Accept_Statement : Node_Id;
Condition : Node_Id := Empty;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Accept_Alternative, Sloc);
begin
Set_Accept_Statement (N, Accept_Statement);
Set_Condition (N, Condition);
Set_Statements (N, Statements);
Set_Pragmas_Before (N, Pragmas_Before);
return N;
end Make_Accept_Alternative;
function Make_Delay_Alternative (Sloc : Source_Ptr;
Delay_Statement : Node_Id;
Condition : Node_Id := Empty;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Delay_Alternative, Sloc);
begin
Set_Delay_Statement (N, Delay_Statement);
Set_Condition (N, Condition);
Set_Statements (N, Statements);
Set_Pragmas_Before (N, Pragmas_Before);
return N;
end Make_Delay_Alternative;
function Make_Terminate_Alternative (Sloc : Source_Ptr;
Condition : Node_Id := Empty;
Pragmas_Before : List_Id := No_List;
Pragmas_After : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Terminate_Alternative, Sloc);
begin
Set_Condition (N, Condition);
Set_Pragmas_Before (N, Pragmas_Before);
Set_Pragmas_After (N, Pragmas_After);
return N;
end Make_Terminate_Alternative;
function Make_Timed_Entry_Call (Sloc : Source_Ptr;
Entry_Call_Alternative : Node_Id;
Delay_Alternative : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Timed_Entry_Call, Sloc);
begin
Set_Entry_Call_Alternative (N, Entry_Call_Alternative);
Set_Delay_Alternative (N, Delay_Alternative);
return N;
end Make_Timed_Entry_Call;
function Make_Entry_Call_Alternative (Sloc : Source_Ptr;
Entry_Call_Statement : Node_Id;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Entry_Call_Alternative, Sloc);
begin
Set_Entry_Call_Statement (N, Entry_Call_Statement);
Set_Statements (N, Statements);
Set_Pragmas_Before (N, Pragmas_Before);
return N;
end Make_Entry_Call_Alternative;
function Make_Conditional_Entry_Call (Sloc : Source_Ptr;
Entry_Call_Alternative : Node_Id;
Else_Statements : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Conditional_Entry_Call, Sloc);
begin
Set_Entry_Call_Alternative (N, Entry_Call_Alternative);
Set_Else_Statements (N, Else_Statements);
return N;
end Make_Conditional_Entry_Call;
function Make_Asynchronous_Select (Sloc : Source_Ptr;
Triggering_Alternative : Node_Id;
Abortable_Part : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Asynchronous_Select, Sloc);
begin
Set_Triggering_Alternative (N, Triggering_Alternative);
Set_Abortable_Part (N, Abortable_Part);
return N;
end Make_Asynchronous_Select;
function Make_Triggering_Alternative (Sloc : Source_Ptr;
Triggering_Statement : Node_Id;
Statements : List_Id := Empty_List;
Pragmas_Before : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Triggering_Alternative, Sloc);
begin
Set_Triggering_Statement (N, Triggering_Statement);
Set_Statements (N, Statements);
Set_Pragmas_Before (N, Pragmas_Before);
return N;
end Make_Triggering_Alternative;
function Make_Abortable_Part (Sloc : Source_Ptr;
Statements : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Abortable_Part, Sloc);
begin
Set_Statements (N, Statements);
return N;
end Make_Abortable_Part;
function Make_Abort_Statement (Sloc : Source_Ptr;
Names : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Abort_Statement, Sloc);
begin
Set_Names (N, Names);
return N;
end Make_Abort_Statement;
function Make_Compilation_Unit (Sloc : Source_Ptr;
Context_Items : List_Id;
Private_Present : Boolean := False;
Unit : Node_Id;
Aux_Decls_Node : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Compilation_Unit, Sloc);
begin
Set_Context_Items (N, Context_Items);
Set_Private_Present (N, Private_Present);
Set_Unit (N, Unit);
Set_Aux_Decls_Node (N, Aux_Decls_Node);
return N;
end Make_Compilation_Unit;
function Make_Compilation_Unit_Aux (Sloc : Source_Ptr;
Declarations : List_Id := No_List;
Actions : List_Id := No_List;
Pragmas_After : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Compilation_Unit_Aux, Sloc);
begin
Set_Declarations (N, Declarations);
Set_Actions (N, Actions);
Set_Pragmas_After (N, Pragmas_After);
return N;
end Make_Compilation_Unit_Aux;
function Make_With_Clause (Sloc : Source_Ptr;
Name : Node_Id;
First_Name : Boolean := True;
Last_Name : Boolean := True)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_With_Clause, Sloc);
begin
Set_Name (N, Name);
Set_First_Name (N, First_Name);
Set_Last_Name (N, Last_Name);
return N;
end Make_With_Clause;
function Make_With_Type_Clause (Sloc : Source_Ptr;
Name : Node_Id;
Tagged_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_With_Type_Clause, Sloc);
begin
Set_Name (N, Name);
Set_Tagged_Present (N, Tagged_Present);
return N;
end Make_With_Type_Clause;
function Make_Subprogram_Body_Stub (Sloc : Source_Ptr;
Specification : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subprogram_Body_Stub, Sloc);
begin
Set_Specification (N, Specification);
return N;
end Make_Subprogram_Body_Stub;
function Make_Package_Body_Stub (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Package_Body_Stub, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
return N;
end Make_Package_Body_Stub;
function Make_Task_Body_Stub (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Task_Body_Stub, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
return N;
end Make_Task_Body_Stub;
function Make_Protected_Body_Stub (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Protected_Body_Stub, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
return N;
end Make_Protected_Body_Stub;
function Make_Subunit (Sloc : Source_Ptr;
Name : Node_Id;
Proper_Body : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subunit, Sloc);
begin
Set_Name (N, Name);
Set_Proper_Body (N, Proper_Body);
return N;
end Make_Subunit;
function Make_Exception_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Exception_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
return N;
end Make_Exception_Declaration;
function Make_Handled_Sequence_Of_Statements (Sloc : Source_Ptr;
Statements : List_Id;
End_Label : Node_Id := Empty;
Exception_Handlers : List_Id := No_List;
At_End_Proc : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Handled_Sequence_Of_Statements, Sloc);
begin
Set_Statements (N, Statements);
Set_End_Label (N, End_Label);
Set_Exception_Handlers (N, Exception_Handlers);
Set_At_End_Proc (N, At_End_Proc);
return N;
end Make_Handled_Sequence_Of_Statements;
function Make_Exception_Handler (Sloc : Source_Ptr;
Choice_Parameter : Node_Id := Empty;
Exception_Choices : List_Id;
Statements : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Exception_Handler, Sloc);
begin
Set_Choice_Parameter (N, Choice_Parameter);
Set_Exception_Choices (N, Exception_Choices);
Set_Statements (N, Statements);
return N;
end Make_Exception_Handler;
function Make_Raise_Statement (Sloc : Source_Ptr;
Name : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Raise_Statement, Sloc);
begin
Set_Name (N, Name);
return N;
end Make_Raise_Statement;
function Make_Generic_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Generic_Formal_Declarations : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Generic_Subprogram_Declaration, Sloc);
begin
Set_Specification (N, Specification);
Set_Generic_Formal_Declarations (N, Generic_Formal_Declarations);
return N;
end Make_Generic_Subprogram_Declaration;
function Make_Generic_Package_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Generic_Formal_Declarations : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Generic_Package_Declaration, Sloc);
begin
Set_Specification (N, Specification);
Set_Generic_Formal_Declarations (N, Generic_Formal_Declarations);
return N;
end Make_Generic_Package_Declaration;
function Make_Package_Instantiation (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Package_Instantiation, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Name (N, Name);
Set_Generic_Associations (N, Generic_Associations);
return N;
end Make_Package_Instantiation;
function Make_Procedure_Instantiation (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Procedure_Instantiation, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Name (N, Name);
Set_Generic_Associations (N, Generic_Associations);
return N;
end Make_Procedure_Instantiation;
function Make_Function_Instantiation (Sloc : Source_Ptr;
Defining_Unit_Name : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Function_Instantiation, Sloc);
begin
Set_Defining_Unit_Name (N, Defining_Unit_Name);
Set_Name (N, Name);
Set_Generic_Associations (N, Generic_Associations);
return N;
end Make_Function_Instantiation;
function Make_Generic_Association (Sloc : Source_Ptr;
Selector_Name : Node_Id := Empty;
Explicit_Generic_Actual_Parameter : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Generic_Association, Sloc);
begin
Set_Selector_Name (N, Selector_Name);
Set_Explicit_Generic_Actual_Parameter
(N, Explicit_Generic_Actual_Parameter);
return N;
end Make_Generic_Association;
function Make_Formal_Object_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
In_Present : Boolean := False;
Out_Present : Boolean := False;
Subtype_Mark : Node_Id;
Expression : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Object_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_In_Present (N, In_Present);
Set_Out_Present (N, Out_Present);
Set_Subtype_Mark (N, Subtype_Mark);
Set_Expression (N, Expression);
return N;
end Make_Formal_Object_Declaration;
function Make_Formal_Type_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Formal_Type_Definition : Node_Id;
Discriminant_Specifications : List_Id := No_List;
Unknown_Discriminants_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Type_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Formal_Type_Definition (N, Formal_Type_Definition);
Set_Discriminant_Specifications (N, Discriminant_Specifications);
Set_Unknown_Discriminants_Present
(N, Unknown_Discriminants_Present);
return N;
end Make_Formal_Type_Declaration;
function Make_Formal_Private_Type_Definition (Sloc : Source_Ptr;
Abstract_Present : Boolean := False;
Tagged_Present : Boolean := False;
Limited_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Private_Type_Definition, Sloc);
begin
Set_Abstract_Present (N, Abstract_Present);
Set_Tagged_Present (N, Tagged_Present);
Set_Limited_Present (N, Limited_Present);
return N;
end Make_Formal_Private_Type_Definition;
function Make_Formal_Derived_Type_Definition (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Private_Present : Boolean := False;
Abstract_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Derived_Type_Definition, Sloc);
begin
Set_Subtype_Mark (N, Subtype_Mark);
Set_Private_Present (N, Private_Present);
Set_Abstract_Present (N, Abstract_Present);
return N;
end Make_Formal_Derived_Type_Definition;
function Make_Formal_Discrete_Type_Definition (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Discrete_Type_Definition, Sloc);
begin
return N;
end Make_Formal_Discrete_Type_Definition;
function Make_Formal_Signed_Integer_Type_Definition (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Signed_Integer_Type_Definition, Sloc);
begin
return N;
end Make_Formal_Signed_Integer_Type_Definition;
function Make_Formal_Modular_Type_Definition (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Modular_Type_Definition, Sloc);
begin
return N;
end Make_Formal_Modular_Type_Definition;
function Make_Formal_Floating_Point_Definition (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Floating_Point_Definition, Sloc);
begin
return N;
end Make_Formal_Floating_Point_Definition;
function Make_Formal_Ordinary_Fixed_Point_Definition (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Ordinary_Fixed_Point_Definition, Sloc);
begin
return N;
end Make_Formal_Ordinary_Fixed_Point_Definition;
function Make_Formal_Decimal_Fixed_Point_Definition (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Decimal_Fixed_Point_Definition, Sloc);
begin
return N;
end Make_Formal_Decimal_Fixed_Point_Definition;
function Make_Formal_Subprogram_Declaration (Sloc : Source_Ptr;
Specification : Node_Id;
Default_Name : Node_Id := Empty;
Box_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Subprogram_Declaration, Sloc);
begin
Set_Specification (N, Specification);
Set_Default_Name (N, Default_Name);
Set_Box_Present (N, Box_Present);
return N;
end Make_Formal_Subprogram_Declaration;
function Make_Formal_Package_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id;
Name : Node_Id;
Generic_Associations : List_Id := No_List;
Box_Present : Boolean := False)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Formal_Package_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
Set_Name (N, Name);
Set_Generic_Associations (N, Generic_Associations);
Set_Box_Present (N, Box_Present);
return N;
end Make_Formal_Package_Declaration;
function Make_Attribute_Definition_Clause (Sloc : Source_Ptr;
Name : Node_Id;
Chars : Name_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Attribute_Definition_Clause, Sloc);
begin
Set_Name (N, Name);
Set_Chars (N, Chars);
Set_Expression (N, Expression);
return N;
end Make_Attribute_Definition_Clause;
function Make_Enumeration_Representation_Clause (Sloc : Source_Ptr;
Identifier : Node_Id;
Array_Aggregate : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Enumeration_Representation_Clause, Sloc);
begin
Set_Identifier (N, Identifier);
Set_Array_Aggregate (N, Array_Aggregate);
return N;
end Make_Enumeration_Representation_Clause;
function Make_Record_Representation_Clause (Sloc : Source_Ptr;
Identifier : Node_Id;
Mod_Clause : Node_Id := Empty;
Component_Clauses : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Record_Representation_Clause, Sloc);
begin
Set_Identifier (N, Identifier);
Set_Mod_Clause (N, Mod_Clause);
Set_Component_Clauses (N, Component_Clauses);
return N;
end Make_Record_Representation_Clause;
function Make_Component_Clause (Sloc : Source_Ptr;
Component_Name : Node_Id;
Position : Node_Id;
First_Bit : Node_Id;
Last_Bit : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Component_Clause, Sloc);
begin
Set_Component_Name (N, Component_Name);
Set_Position (N, Position);
Set_First_Bit (N, First_Bit);
Set_Last_Bit (N, Last_Bit);
return N;
end Make_Component_Clause;
function Make_Code_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Code_Statement, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Code_Statement;
function Make_Op_Rotate_Left (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Rotate_Left, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Rotate_Left);
Set_Entity (N, Standard_Op_Rotate_Left);
return N;
end Make_Op_Rotate_Left;
function Make_Op_Rotate_Right (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Rotate_Right, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Rotate_Right);
Set_Entity (N, Standard_Op_Rotate_Right);
return N;
end Make_Op_Rotate_Right;
function Make_Op_Shift_Left (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Shift_Left, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Shift_Left);
Set_Entity (N, Standard_Op_Shift_Left);
return N;
end Make_Op_Shift_Left;
function Make_Op_Shift_Right_Arithmetic (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Shift_Right_Arithmetic, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Shift_Right_Arithmetic);
Set_Entity (N, Standard_Op_Shift_Right_Arithmetic);
return N;
end Make_Op_Shift_Right_Arithmetic;
function Make_Op_Shift_Right (Sloc : Source_Ptr;
Left_Opnd : Node_Id;
Right_Opnd : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Op_Shift_Right, Sloc);
begin
Set_Left_Opnd (N, Left_Opnd);
Set_Right_Opnd (N, Right_Opnd);
Set_Chars (N, Name_Shift_Right);
Set_Entity (N, Standard_Op_Shift_Right);
return N;
end Make_Op_Shift_Right;
function Make_Delta_Constraint (Sloc : Source_Ptr;
Delta_Expression : Node_Id;
Range_Constraint : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Delta_Constraint, Sloc);
begin
Set_Delta_Expression (N, Delta_Expression);
Set_Range_Constraint (N, Range_Constraint);
return N;
end Make_Delta_Constraint;
function Make_At_Clause (Sloc : Source_Ptr;
Identifier : Node_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_At_Clause, Sloc);
begin
Set_Identifier (N, Identifier);
Set_Expression (N, Expression);
return N;
end Make_At_Clause;
function Make_Mod_Clause (Sloc : Source_Ptr;
Expression : Node_Id;
Pragmas_Before : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Mod_Clause, Sloc);
begin
Set_Expression (N, Expression);
Set_Pragmas_Before (N, Pragmas_Before);
return N;
end Make_Mod_Clause;
function Make_Conditional_Expression (Sloc : Source_Ptr;
Expressions : List_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Conditional_Expression, Sloc);
begin
Set_Expressions (N, Expressions);
return N;
end Make_Conditional_Expression;
function Make_Expanded_Name (Sloc : Source_Ptr;
Chars : Name_Id;
Prefix : Node_Id;
Selector_Name : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Expanded_Name, Sloc);
begin
Set_Chars (N, Chars);
Set_Prefix (N, Prefix);
Set_Selector_Name (N, Selector_Name);
return N;
end Make_Expanded_Name;
function Make_Free_Statement (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Free_Statement, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Free_Statement;
function Make_Freeze_Entity (Sloc : Source_Ptr;
Actions : List_Id := No_List)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Freeze_Entity, Sloc);
begin
Set_Actions (N, Actions);
return N;
end Make_Freeze_Entity;
function Make_Implicit_Label_Declaration (Sloc : Source_Ptr;
Defining_Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Implicit_Label_Declaration, Sloc);
begin
Set_Defining_Identifier (N, Defining_Identifier);
return N;
end Make_Implicit_Label_Declaration;
function Make_Itype_Reference (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Itype_Reference, Sloc);
begin
return N;
end Make_Itype_Reference;
function Make_Raise_Constraint_Error (Sloc : Source_Ptr;
Condition : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Raise_Constraint_Error, Sloc);
begin
Set_Condition (N, Condition);
return N;
end Make_Raise_Constraint_Error;
function Make_Raise_Program_Error (Sloc : Source_Ptr;
Condition : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Raise_Program_Error, Sloc);
begin
Set_Condition (N, Condition);
return N;
end Make_Raise_Program_Error;
function Make_Raise_Storage_Error (Sloc : Source_Ptr;
Condition : Node_Id := Empty)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Raise_Storage_Error, Sloc);
begin
Set_Condition (N, Condition);
return N;
end Make_Raise_Storage_Error;
function Make_Reference (Sloc : Source_Ptr;
Prefix : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Reference, Sloc);
begin
Set_Prefix (N, Prefix);
return N;
end Make_Reference;
function Make_Subprogram_Info (Sloc : Source_Ptr;
Identifier : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Subprogram_Info, Sloc);
begin
Set_Identifier (N, Identifier);
return N;
end Make_Subprogram_Info;
function Make_Unchecked_Expression (Sloc : Source_Ptr;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Unchecked_Expression, Sloc);
begin
Set_Expression (N, Expression);
return N;
end Make_Unchecked_Expression;
function Make_Unchecked_Type_Conversion (Sloc : Source_Ptr;
Subtype_Mark : Node_Id;
Expression : Node_Id)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Unchecked_Type_Conversion, Sloc);
begin
Set_Subtype_Mark (N, Subtype_Mark);
Set_Expression (N, Expression);
return N;
end Make_Unchecked_Type_Conversion;
function Make_Validate_Unchecked_Conversion (Sloc : Source_Ptr)
return Node_Id
is
N : constant Node_Id :=
New_Node (N_Validate_Unchecked_Conversion, Sloc);
begin
return N;
end Make_Validate_Unchecked_Conversion;
end Nmake;
|
with ZMQ.Sockets;
with ZMQ.Contexts;
with ZMQ.Messages;
with Ada.Text_IO; use Ada.Text_IO;
with AVTAS.LMCP.Types; use AVTAS.LMCP.Types;
with AVTAS.LMCP.ByteBuffers; use AVTAS.LMCP.ByteBuffers;
with Avtas.Lmcp.Factory;
procedure Test_Msg_Decode is
Ctx : ZMQ.Contexts.Context;
Sub : ZMQ.Sockets.Socket;
Buffer : ByteBuffer (Capacity => 4*1024);
begin
Ctx.Set_Number_Of_IO_Threads (1);
Sub.Initialize (Ctx, ZMQ.Sockets.SUB);
Sub.Connect ("tcp://127.0.0.1:5560");
-- Accept all forwarded messages (filtering on PUB side via 'SubscribeToMessage' child elements)
Sub.Establish_Message_Filter ("");
loop
declare
ZmqMsg : ZMQ.Messages.Message;
begin
ZmqMsg.Initialize (0);
Buffer.Clear;
Sub.Recv (ZmqMsg);
-- Put_Line (ZmqMsg.GetData);
Buffer.Put_Raw_Bytes (ZmqMsg.GetData);
Buffer.Rewind;
declare
CtrlStr : Int32;
MsgSize : UInt32;
MsgExists : Boolean;
SeriesId : Int64;
MsgType : Uint32;
Version : Uint16;
LMCP_CONTROL_STR : constant Int32 := 1634103916;
begin
Buffer.Get_Int32 (CtrlStr);
if CtrlStr /= LMCP_CONTROL_STR then
Put_Line ("wrong LMCP_CONTROL_STR:" & CtrlStr'Image);
goto Continue;
end if;
Buffer.Get_UInt32 (MsgSize);
if Buffer.Capacity < MsgSize then
Put_Line ("wrong msgsize:" & MsgSize'Image);
goto Continue;
end if;
if not avtas.lmcp.factory.Validate (Buffer) then
Put_Line ("checksum not valid");
goto Continue;
end if;
Buffer.Get_Boolean (MsgExists);
if not MsgExists then
Put_Line ("msg not present");
goto Continue;
end if;
Buffer.Get_Int64 (SeriesId);
Buffer.Get_UInt32 (MsgType);
Buffer.Get_UInt16 (Version);
Put_Line ("SeriesId:" & SeriesId'Image);
Put_Line ("MsgType:" & MsgType'Image);
Put_Line ("Version:" & Version'Image);
end;
end;
<<Continue>>
end loop;
end Test_Msg_Decode;
|
procedure package_instantiation is
begin
begin
declare
generic package pkg is
x : integer := 0;
end pkg;
begin
declare
package p is new pkg;
begin
null;
end;
end;
end;
end package_instantiation;
|
-- Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
--
-- SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from rp2040.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
-- Testbench manager. Allows the programmer to know what platform their
-- software is running on.
package RP_SVD.TBMAN is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Indicates the type of platform in use
type PLATFORM_Register is record
-- Read-only. Indicates the platform is an ASIC
ASIC : Boolean;
-- Read-only. Indicates the platform is an FPGA
FPGA : Boolean;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PLATFORM_Register use record
ASIC at 0 range 0 .. 0;
FPGA at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Testbench manager. Allows the programmer to know what platform their
-- software is running on.
type TBMAN_Peripheral is record
-- Indicates the type of platform in use
PLATFORM : aliased PLATFORM_Register;
end record
with Volatile;
for TBMAN_Peripheral use record
PLATFORM at 0 range 0 .. 31;
end record;
-- Testbench manager. Allows the programmer to know what platform their
-- software is running on.
TBMAN_Periph : aliased TBMAN_Peripheral
with Import, Address => TBMAN_Base;
end RP_SVD.TBMAN;
|
with Interfaces.C;
package SDL_Ada_Sizes is
package C renames Interfaces.C;
-- SDL_Types.h
function Uint8_Size return C.int;
pragma Import (C, Uint8_Size, "Uint8_Size");
function Uint16_Size return C.int;
pragma Import (C, Uint16_Size, "Uint16_Size");
-- SDL_Events.h
function SDL_ActiveEvent_Size return C.int;
pragma Import (C, SDL_ActiveEvent_Size, "SDL_ActiveEvent_Size");
function SDL_KeyboardEvent_Size return C.int;
pragma Import (C, SDL_KeyboardEvent_Size, "SDL_KeyboardEvent_Size");
function SDL_keysym_Size return C.int;
pragma Import (C, SDL_keysym_Size, "SDL_keysym_Size");
function SDLKey_Size return C.int;
pragma Import (C, SDLKey_Size, "SDLKey_Size");
function SDLMode_Size return C.int;
pragma Import (C, SDLMode_Size, "SDLMode_Size");
function SDL_MouseMotionEvent_Size return C.int;
pragma Import (C, SDL_MouseMotionEvent_Size, "SDL_MouseMotionEvent_Size");
function SDL_MouseButtonEvent_Size return C.int;
pragma Import (C, SDL_MouseButtonEvent_Size, "SDL_MouseButtonEvent_Size");
function SDL_JoyAxisEvent_Size return C.int;
pragma Import (C, SDL_JoyAxisEvent_Size, "SDL_JoyAxisEvent_Size");
function SDL_JoyBallEvent_Size return C.int;
pragma Import (C, SDL_JoyBallEvent_Size, "SDL_JoyBallEvent_Size");
function SDL_JoyHatEvent_Size return C.int;
pragma Import (C, SDL_JoyHatEvent_Size, "SDL_JoyHatEvent_Size");
function SDL_JoyButtonEvent_Size return C.int;
pragma Import (C, SDL_JoyButtonEvent_Size, "SDL_JoyButtonEvent_Size");
function SDL_ResizeEvent_Size return C.int;
pragma Import (C, SDL_ResizeEvent_Size, "SDL_ResizeEvent_Size");
function SDL_QuitEvent_Size return C.int;
pragma Import (C, SDL_QuitEvent_Size, "SDL_QuitEvent_Size");
function SDL_UserEvent_Size return C.int;
pragma Import (C, SDL_UserEvent_Size, "SDL_UserEvent_Size");
function SDL_SysWMEvent_Size return C.int;
pragma Import (C, SDL_SysWMEvent_Size, "SDL_SysWMEvent_Size");
function SDL_Event_Size return C.int;
pragma Import (C, SDL_Event_Size, "SDL_Event_Size");
-- SDL_cdrom.h
function SDL_CDtrack_Size return C.int;
pragma Import (C, SDL_CDtrack_Size, "SDL_CDtrack_Size");
function SDL_CD_Size return C.int;
pragma Import (C, SDL_CD_Size, "SDL_CD_Size");
end SDL_Ada_Sizes;
|
-----------------------------------------------------------------------
-- net-utils -- Network utilities
-- Copyright (C) 2016 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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;
package body Net.Utils is
function Hex (Value : in Uint8) return String;
function Image (Value : in Uint8) return String;
Hex_String : constant String := "0123456789ABCDEF";
-- Get a 32-bit random number.
function Random return Uint32 is separate;
function Hex (Value : in Uint8) return String is
use Interfaces;
Result : String (1 .. 2);
begin
Result (1) := Hex_String (Positive (Shift_Right (Value, 4) + 1));
Result (2) := Hex_String (Positive ((Value and 16#0f#) + 1));
return Result;
end Hex;
function Image (Value : in Uint8) return String is
Result : constant String := Value'Image;
begin
return Result (Result'First + 1 .. Result'Last);
end Image;
-- ------------------------------
-- Convert the IPv4 address to a dot string representation.
-- ------------------------------
function To_String (Ip : in Ip_Addr) return String is
begin
return Image (Ip (Ip'First)) & "."
& Image (Ip (Ip'First + 1)) & "."
& Image (Ip (Ip'First + 2)) & "."
& Image (Ip (Ip'First + 3));
end To_String;
-- ------------------------------
-- Convert the Ethernet address to a string representation.
-- ------------------------------
function To_String (Mac : in Ether_Addr) return String is
begin
return Hex (Mac (Mac'First)) & ":"
& Hex (Mac (Mac'First + 1)) & ":"
& Hex (Mac (Mac'First + 2)) & ":"
& Hex (Mac (Mac'First + 3)) & ":"
& Hex (Mac (Mac'First + 4)) & ":"
& Hex (Mac (Mac'First + 5));
end To_String;
end Net.Utils;
|
-- Taken from #2925 submitted by @koenmeersman
package My_Package is
generic
type Num is digits <>;
package Conversions is
function From_Big_Real (Arg : Integer) return Num;
end Conversions;
type Missing_Tag is record
Num : Integer;
end record;
end My_Package;
|
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
--
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without modification,
-- are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form, except as embedded into a Nordic
-- Semiconductor ASA integrated circuit in a product or a software update for
-- such product, must reproduce the above copyright notice, this list of
-- conditions and the following disclaimer in the documentation and/or other
-- materials provided with the distribution.
--
-- 3. Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- 4. This software, with or without modification, must only be used with a
-- Nordic Semiconductor ASA integrated circuit.
--
-- 5. Any software provided in binary form under this license must not be reverse
-- engineered, decompiled, modified and/or disassembled.
--
-- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-- OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf52.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.SAADC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-----------------------------------
-- EVENTS_CH cluster's Registers --
-----------------------------------
-- Unspecified
type EVENTS_CH_Cluster is record
-- Description cluster[0]: Last results is equal or above
-- CH[0].LIMIT.HIGH
LIMITH : aliased HAL.UInt32;
-- Description cluster[0]: Last results is equal or below
-- CH[0].LIMIT.LOW
LIMITL : aliased HAL.UInt32;
end record
with Size => 64;
for EVENTS_CH_Cluster use record
LIMITH at 16#0# range 0 .. 31;
LIMITL at 16#4# range 0 .. 31;
end record;
-- Unspecified
type EVENTS_CH_Clusters is array (0 .. 7) of EVENTS_CH_Cluster;
-- Enable or disable interrupt for STARTED event
type INTEN_STARTED_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_STARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for END event
type INTEN_END_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_END_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for DONE event
type INTEN_DONE_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_DONE_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for RESULTDONE event
type INTEN_RESULTDONE_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_RESULTDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CALIBRATEDONE event
type INTEN_CALIBRATEDONE_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CALIBRATEDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for STOPPED event
type INTEN_STOPPED_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_STOPPED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[0].LIMITH event
type INTEN_CH0LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH0LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[0].LIMITL event
type INTEN_CH0LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH0LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[1].LIMITH event
type INTEN_CH1LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH1LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[1].LIMITL event
type INTEN_CH1LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH1LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[2].LIMITH event
type INTEN_CH2LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH2LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[2].LIMITL event
type INTEN_CH2LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH2LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[3].LIMITH event
type INTEN_CH3LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH3LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[3].LIMITL event
type INTEN_CH3LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH3LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[4].LIMITH event
type INTEN_CH4LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH4LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[4].LIMITL event
type INTEN_CH4LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH4LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[5].LIMITH event
type INTEN_CH5LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH5LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[5].LIMITL event
type INTEN_CH5LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH5LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[6].LIMITH event
type INTEN_CH6LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH6LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[6].LIMITL event
type INTEN_CH6LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH6LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[7].LIMITH event
type INTEN_CH7LIMITH_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH7LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for CH[7].LIMITL event
type INTEN_CH7LIMITL_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_CH7LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt
type INTEN_Register is record
-- Enable or disable interrupt for STARTED event
STARTED : INTEN_STARTED_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for END event
END_k : INTEN_END_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for DONE event
DONE : INTEN_DONE_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for RESULTDONE event
RESULTDONE : INTEN_RESULTDONE_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CALIBRATEDONE event
CALIBRATEDONE : INTEN_CALIBRATEDONE_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for STOPPED event
STOPPED : INTEN_STOPPED_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[0].LIMITH event
CH0LIMITH : INTEN_CH0LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[0].LIMITL event
CH0LIMITL : INTEN_CH0LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[1].LIMITH event
CH1LIMITH : INTEN_CH1LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[1].LIMITL event
CH1LIMITL : INTEN_CH1LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[2].LIMITH event
CH2LIMITH : INTEN_CH2LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[2].LIMITL event
CH2LIMITL : INTEN_CH2LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[3].LIMITH event
CH3LIMITH : INTEN_CH3LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[3].LIMITL event
CH3LIMITL : INTEN_CH3LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[4].LIMITH event
CH4LIMITH : INTEN_CH4LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[4].LIMITL event
CH4LIMITL : INTEN_CH4LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[5].LIMITH event
CH5LIMITH : INTEN_CH5LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[5].LIMITL event
CH5LIMITL : INTEN_CH5LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[6].LIMITH event
CH6LIMITH : INTEN_CH6LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[6].LIMITL event
CH6LIMITL : INTEN_CH6LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[7].LIMITH event
CH7LIMITH : INTEN_CH7LIMITH_Field := NRF_SVD.SAADC.Disabled;
-- Enable or disable interrupt for CH[7].LIMITL event
CH7LIMITL : INTEN_CH7LIMITL_Field := NRF_SVD.SAADC.Disabled;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTEN_Register use record
STARTED at 0 range 0 .. 0;
END_k at 0 range 1 .. 1;
DONE at 0 range 2 .. 2;
RESULTDONE at 0 range 3 .. 3;
CALIBRATEDONE at 0 range 4 .. 4;
STOPPED at 0 range 5 .. 5;
CH0LIMITH at 0 range 6 .. 6;
CH0LIMITL at 0 range 7 .. 7;
CH1LIMITH at 0 range 8 .. 8;
CH1LIMITL at 0 range 9 .. 9;
CH2LIMITH at 0 range 10 .. 10;
CH2LIMITL at 0 range 11 .. 11;
CH3LIMITH at 0 range 12 .. 12;
CH3LIMITL at 0 range 13 .. 13;
CH4LIMITH at 0 range 14 .. 14;
CH4LIMITL at 0 range 15 .. 15;
CH5LIMITH at 0 range 16 .. 16;
CH5LIMITL at 0 range 17 .. 17;
CH6LIMITH at 0 range 18 .. 18;
CH6LIMITL at 0 range 19 .. 19;
CH7LIMITH at 0 range 20 .. 20;
CH7LIMITL at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Write '1' to Enable interrupt for STARTED event
type INTENSET_STARTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_STARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for STARTED event
type INTENSET_STARTED_Field_1 is
(-- Reset value for the field
Intenset_Started_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_STARTED_Field_1 use
(Intenset_Started_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for END event
type INTENSET_END_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_END_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for END event
type INTENSET_END_Field_1 is
(-- Reset value for the field
Intenset_End_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_END_Field_1 use
(Intenset_End_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for DONE event
type INTENSET_DONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_DONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for DONE event
type INTENSET_DONE_Field_1 is
(-- Reset value for the field
Intenset_Done_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_DONE_Field_1 use
(Intenset_Done_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for RESULTDONE event
type INTENSET_RESULTDONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_RESULTDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for RESULTDONE event
type INTENSET_RESULTDONE_Field_1 is
(-- Reset value for the field
Intenset_Resultdone_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_RESULTDONE_Field_1 use
(Intenset_Resultdone_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CALIBRATEDONE event
type INTENSET_CALIBRATEDONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CALIBRATEDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CALIBRATEDONE event
type INTENSET_CALIBRATEDONE_Field_1 is
(-- Reset value for the field
Intenset_Calibratedone_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CALIBRATEDONE_Field_1 use
(Intenset_Calibratedone_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for STOPPED event
type INTENSET_STOPPED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_STOPPED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for STOPPED event
type INTENSET_STOPPED_Field_1 is
(-- Reset value for the field
Intenset_Stopped_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_STOPPED_Field_1 use
(Intenset_Stopped_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[0].LIMITH event
type INTENSET_CH0LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH0LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[0].LIMITH event
type INTENSET_CH0LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch0Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH0LIMITH_Field_1 use
(Intenset_Ch0Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[0].LIMITL event
type INTENSET_CH0LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH0LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[0].LIMITL event
type INTENSET_CH0LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch0Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH0LIMITL_Field_1 use
(Intenset_Ch0Limitl_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[1].LIMITH event
type INTENSET_CH1LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH1LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[1].LIMITH event
type INTENSET_CH1LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch1Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH1LIMITH_Field_1 use
(Intenset_Ch1Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[1].LIMITL event
type INTENSET_CH1LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH1LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[1].LIMITL event
type INTENSET_CH1LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch1Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH1LIMITL_Field_1 use
(Intenset_Ch1Limitl_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[2].LIMITH event
type INTENSET_CH2LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH2LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[2].LIMITH event
type INTENSET_CH2LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch2Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH2LIMITH_Field_1 use
(Intenset_Ch2Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[2].LIMITL event
type INTENSET_CH2LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH2LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[2].LIMITL event
type INTENSET_CH2LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch2Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH2LIMITL_Field_1 use
(Intenset_Ch2Limitl_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[3].LIMITH event
type INTENSET_CH3LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH3LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[3].LIMITH event
type INTENSET_CH3LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch3Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH3LIMITH_Field_1 use
(Intenset_Ch3Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[3].LIMITL event
type INTENSET_CH3LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH3LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[3].LIMITL event
type INTENSET_CH3LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch3Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH3LIMITL_Field_1 use
(Intenset_Ch3Limitl_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[4].LIMITH event
type INTENSET_CH4LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH4LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[4].LIMITH event
type INTENSET_CH4LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch4Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH4LIMITH_Field_1 use
(Intenset_Ch4Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[4].LIMITL event
type INTENSET_CH4LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH4LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[4].LIMITL event
type INTENSET_CH4LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch4Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH4LIMITL_Field_1 use
(Intenset_Ch4Limitl_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[5].LIMITH event
type INTENSET_CH5LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH5LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[5].LIMITH event
type INTENSET_CH5LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch5Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH5LIMITH_Field_1 use
(Intenset_Ch5Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[5].LIMITL event
type INTENSET_CH5LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH5LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[5].LIMITL event
type INTENSET_CH5LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch5Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH5LIMITL_Field_1 use
(Intenset_Ch5Limitl_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[6].LIMITH event
type INTENSET_CH6LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH6LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[6].LIMITH event
type INTENSET_CH6LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch6Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH6LIMITH_Field_1 use
(Intenset_Ch6Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[6].LIMITL event
type INTENSET_CH6LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH6LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[6].LIMITL event
type INTENSET_CH6LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch6Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH6LIMITL_Field_1 use
(Intenset_Ch6Limitl_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[7].LIMITH event
type INTENSET_CH7LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH7LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[7].LIMITH event
type INTENSET_CH7LIMITH_Field_1 is
(-- Reset value for the field
Intenset_Ch7Limith_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH7LIMITH_Field_1 use
(Intenset_Ch7Limith_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for CH[7].LIMITL event
type INTENSET_CH7LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CH7LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CH[7].LIMITL event
type INTENSET_CH7LIMITL_Field_1 is
(-- Reset value for the field
Intenset_Ch7Limitl_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CH7LIMITL_Field_1 use
(Intenset_Ch7Limitl_Field_Reset => 0,
Set => 1);
-- Enable interrupt
type INTENSET_Register is record
-- Write '1' to Enable interrupt for STARTED event
STARTED : INTENSET_STARTED_Field_1 :=
Intenset_Started_Field_Reset;
-- Write '1' to Enable interrupt for END event
END_k : INTENSET_END_Field_1 := Intenset_End_Field_Reset;
-- Write '1' to Enable interrupt for DONE event
DONE : INTENSET_DONE_Field_1 := Intenset_Done_Field_Reset;
-- Write '1' to Enable interrupt for RESULTDONE event
RESULTDONE : INTENSET_RESULTDONE_Field_1 :=
Intenset_Resultdone_Field_Reset;
-- Write '1' to Enable interrupt for CALIBRATEDONE event
CALIBRATEDONE : INTENSET_CALIBRATEDONE_Field_1 :=
Intenset_Calibratedone_Field_Reset;
-- Write '1' to Enable interrupt for STOPPED event
STOPPED : INTENSET_STOPPED_Field_1 :=
Intenset_Stopped_Field_Reset;
-- Write '1' to Enable interrupt for CH[0].LIMITH event
CH0LIMITH : INTENSET_CH0LIMITH_Field_1 :=
Intenset_Ch0Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[0].LIMITL event
CH0LIMITL : INTENSET_CH0LIMITL_Field_1 :=
Intenset_Ch0Limitl_Field_Reset;
-- Write '1' to Enable interrupt for CH[1].LIMITH event
CH1LIMITH : INTENSET_CH1LIMITH_Field_1 :=
Intenset_Ch1Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[1].LIMITL event
CH1LIMITL : INTENSET_CH1LIMITL_Field_1 :=
Intenset_Ch1Limitl_Field_Reset;
-- Write '1' to Enable interrupt for CH[2].LIMITH event
CH2LIMITH : INTENSET_CH2LIMITH_Field_1 :=
Intenset_Ch2Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[2].LIMITL event
CH2LIMITL : INTENSET_CH2LIMITL_Field_1 :=
Intenset_Ch2Limitl_Field_Reset;
-- Write '1' to Enable interrupt for CH[3].LIMITH event
CH3LIMITH : INTENSET_CH3LIMITH_Field_1 :=
Intenset_Ch3Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[3].LIMITL event
CH3LIMITL : INTENSET_CH3LIMITL_Field_1 :=
Intenset_Ch3Limitl_Field_Reset;
-- Write '1' to Enable interrupt for CH[4].LIMITH event
CH4LIMITH : INTENSET_CH4LIMITH_Field_1 :=
Intenset_Ch4Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[4].LIMITL event
CH4LIMITL : INTENSET_CH4LIMITL_Field_1 :=
Intenset_Ch4Limitl_Field_Reset;
-- Write '1' to Enable interrupt for CH[5].LIMITH event
CH5LIMITH : INTENSET_CH5LIMITH_Field_1 :=
Intenset_Ch5Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[5].LIMITL event
CH5LIMITL : INTENSET_CH5LIMITL_Field_1 :=
Intenset_Ch5Limitl_Field_Reset;
-- Write '1' to Enable interrupt for CH[6].LIMITH event
CH6LIMITH : INTENSET_CH6LIMITH_Field_1 :=
Intenset_Ch6Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[6].LIMITL event
CH6LIMITL : INTENSET_CH6LIMITL_Field_1 :=
Intenset_Ch6Limitl_Field_Reset;
-- Write '1' to Enable interrupt for CH[7].LIMITH event
CH7LIMITH : INTENSET_CH7LIMITH_Field_1 :=
Intenset_Ch7Limith_Field_Reset;
-- Write '1' to Enable interrupt for CH[7].LIMITL event
CH7LIMITL : INTENSET_CH7LIMITL_Field_1 :=
Intenset_Ch7Limitl_Field_Reset;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
STARTED at 0 range 0 .. 0;
END_k at 0 range 1 .. 1;
DONE at 0 range 2 .. 2;
RESULTDONE at 0 range 3 .. 3;
CALIBRATEDONE at 0 range 4 .. 4;
STOPPED at 0 range 5 .. 5;
CH0LIMITH at 0 range 6 .. 6;
CH0LIMITL at 0 range 7 .. 7;
CH1LIMITH at 0 range 8 .. 8;
CH1LIMITL at 0 range 9 .. 9;
CH2LIMITH at 0 range 10 .. 10;
CH2LIMITL at 0 range 11 .. 11;
CH3LIMITH at 0 range 12 .. 12;
CH3LIMITL at 0 range 13 .. 13;
CH4LIMITH at 0 range 14 .. 14;
CH4LIMITL at 0 range 15 .. 15;
CH5LIMITH at 0 range 16 .. 16;
CH5LIMITL at 0 range 17 .. 17;
CH6LIMITH at 0 range 18 .. 18;
CH6LIMITL at 0 range 19 .. 19;
CH7LIMITH at 0 range 20 .. 20;
CH7LIMITL at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Write '1' to Disable interrupt for STARTED event
type INTENCLR_STARTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_STARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for STARTED event
type INTENCLR_STARTED_Field_1 is
(-- Reset value for the field
Intenclr_Started_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_STARTED_Field_1 use
(Intenclr_Started_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for END event
type INTENCLR_END_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_END_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for END event
type INTENCLR_END_Field_1 is
(-- Reset value for the field
Intenclr_End_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_END_Field_1 use
(Intenclr_End_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for DONE event
type INTENCLR_DONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_DONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for DONE event
type INTENCLR_DONE_Field_1 is
(-- Reset value for the field
Intenclr_Done_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_DONE_Field_1 use
(Intenclr_Done_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for RESULTDONE event
type INTENCLR_RESULTDONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_RESULTDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for RESULTDONE event
type INTENCLR_RESULTDONE_Field_1 is
(-- Reset value for the field
Intenclr_Resultdone_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_RESULTDONE_Field_1 use
(Intenclr_Resultdone_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CALIBRATEDONE event
type INTENCLR_CALIBRATEDONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CALIBRATEDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CALIBRATEDONE event
type INTENCLR_CALIBRATEDONE_Field_1 is
(-- Reset value for the field
Intenclr_Calibratedone_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CALIBRATEDONE_Field_1 use
(Intenclr_Calibratedone_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for STOPPED event
type INTENCLR_STOPPED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_STOPPED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for STOPPED event
type INTENCLR_STOPPED_Field_1 is
(-- Reset value for the field
Intenclr_Stopped_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_STOPPED_Field_1 use
(Intenclr_Stopped_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[0].LIMITH event
type INTENCLR_CH0LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH0LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[0].LIMITH event
type INTENCLR_CH0LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch0Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH0LIMITH_Field_1 use
(Intenclr_Ch0Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[0].LIMITL event
type INTENCLR_CH0LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH0LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[0].LIMITL event
type INTENCLR_CH0LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch0Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH0LIMITL_Field_1 use
(Intenclr_Ch0Limitl_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[1].LIMITH event
type INTENCLR_CH1LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH1LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[1].LIMITH event
type INTENCLR_CH1LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch1Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH1LIMITH_Field_1 use
(Intenclr_Ch1Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[1].LIMITL event
type INTENCLR_CH1LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH1LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[1].LIMITL event
type INTENCLR_CH1LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch1Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH1LIMITL_Field_1 use
(Intenclr_Ch1Limitl_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[2].LIMITH event
type INTENCLR_CH2LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH2LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[2].LIMITH event
type INTENCLR_CH2LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch2Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH2LIMITH_Field_1 use
(Intenclr_Ch2Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[2].LIMITL event
type INTENCLR_CH2LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH2LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[2].LIMITL event
type INTENCLR_CH2LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch2Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH2LIMITL_Field_1 use
(Intenclr_Ch2Limitl_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[3].LIMITH event
type INTENCLR_CH3LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH3LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[3].LIMITH event
type INTENCLR_CH3LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch3Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH3LIMITH_Field_1 use
(Intenclr_Ch3Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[3].LIMITL event
type INTENCLR_CH3LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH3LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[3].LIMITL event
type INTENCLR_CH3LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch3Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH3LIMITL_Field_1 use
(Intenclr_Ch3Limitl_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[4].LIMITH event
type INTENCLR_CH4LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH4LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[4].LIMITH event
type INTENCLR_CH4LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch4Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH4LIMITH_Field_1 use
(Intenclr_Ch4Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[4].LIMITL event
type INTENCLR_CH4LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH4LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[4].LIMITL event
type INTENCLR_CH4LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch4Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH4LIMITL_Field_1 use
(Intenclr_Ch4Limitl_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[5].LIMITH event
type INTENCLR_CH5LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH5LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[5].LIMITH event
type INTENCLR_CH5LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch5Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH5LIMITH_Field_1 use
(Intenclr_Ch5Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[5].LIMITL event
type INTENCLR_CH5LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH5LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[5].LIMITL event
type INTENCLR_CH5LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch5Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH5LIMITL_Field_1 use
(Intenclr_Ch5Limitl_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[6].LIMITH event
type INTENCLR_CH6LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH6LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[6].LIMITH event
type INTENCLR_CH6LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch6Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH6LIMITH_Field_1 use
(Intenclr_Ch6Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[6].LIMITL event
type INTENCLR_CH6LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH6LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[6].LIMITL event
type INTENCLR_CH6LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch6Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH6LIMITL_Field_1 use
(Intenclr_Ch6Limitl_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[7].LIMITH event
type INTENCLR_CH7LIMITH_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH7LIMITH_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[7].LIMITH event
type INTENCLR_CH7LIMITH_Field_1 is
(-- Reset value for the field
Intenclr_Ch7Limith_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH7LIMITH_Field_1 use
(Intenclr_Ch7Limith_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for CH[7].LIMITL event
type INTENCLR_CH7LIMITL_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CH7LIMITL_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CH[7].LIMITL event
type INTENCLR_CH7LIMITL_Field_1 is
(-- Reset value for the field
Intenclr_Ch7Limitl_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CH7LIMITL_Field_1 use
(Intenclr_Ch7Limitl_Field_Reset => 0,
Clear => 1);
-- Disable interrupt
type INTENCLR_Register is record
-- Write '1' to Disable interrupt for STARTED event
STARTED : INTENCLR_STARTED_Field_1 :=
Intenclr_Started_Field_Reset;
-- Write '1' to Disable interrupt for END event
END_k : INTENCLR_END_Field_1 := Intenclr_End_Field_Reset;
-- Write '1' to Disable interrupt for DONE event
DONE : INTENCLR_DONE_Field_1 := Intenclr_Done_Field_Reset;
-- Write '1' to Disable interrupt for RESULTDONE event
RESULTDONE : INTENCLR_RESULTDONE_Field_1 :=
Intenclr_Resultdone_Field_Reset;
-- Write '1' to Disable interrupt for CALIBRATEDONE event
CALIBRATEDONE : INTENCLR_CALIBRATEDONE_Field_1 :=
Intenclr_Calibratedone_Field_Reset;
-- Write '1' to Disable interrupt for STOPPED event
STOPPED : INTENCLR_STOPPED_Field_1 :=
Intenclr_Stopped_Field_Reset;
-- Write '1' to Disable interrupt for CH[0].LIMITH event
CH0LIMITH : INTENCLR_CH0LIMITH_Field_1 :=
Intenclr_Ch0Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[0].LIMITL event
CH0LIMITL : INTENCLR_CH0LIMITL_Field_1 :=
Intenclr_Ch0Limitl_Field_Reset;
-- Write '1' to Disable interrupt for CH[1].LIMITH event
CH1LIMITH : INTENCLR_CH1LIMITH_Field_1 :=
Intenclr_Ch1Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[1].LIMITL event
CH1LIMITL : INTENCLR_CH1LIMITL_Field_1 :=
Intenclr_Ch1Limitl_Field_Reset;
-- Write '1' to Disable interrupt for CH[2].LIMITH event
CH2LIMITH : INTENCLR_CH2LIMITH_Field_1 :=
Intenclr_Ch2Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[2].LIMITL event
CH2LIMITL : INTENCLR_CH2LIMITL_Field_1 :=
Intenclr_Ch2Limitl_Field_Reset;
-- Write '1' to Disable interrupt for CH[3].LIMITH event
CH3LIMITH : INTENCLR_CH3LIMITH_Field_1 :=
Intenclr_Ch3Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[3].LIMITL event
CH3LIMITL : INTENCLR_CH3LIMITL_Field_1 :=
Intenclr_Ch3Limitl_Field_Reset;
-- Write '1' to Disable interrupt for CH[4].LIMITH event
CH4LIMITH : INTENCLR_CH4LIMITH_Field_1 :=
Intenclr_Ch4Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[4].LIMITL event
CH4LIMITL : INTENCLR_CH4LIMITL_Field_1 :=
Intenclr_Ch4Limitl_Field_Reset;
-- Write '1' to Disable interrupt for CH[5].LIMITH event
CH5LIMITH : INTENCLR_CH5LIMITH_Field_1 :=
Intenclr_Ch5Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[5].LIMITL event
CH5LIMITL : INTENCLR_CH5LIMITL_Field_1 :=
Intenclr_Ch5Limitl_Field_Reset;
-- Write '1' to Disable interrupt for CH[6].LIMITH event
CH6LIMITH : INTENCLR_CH6LIMITH_Field_1 :=
Intenclr_Ch6Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[6].LIMITL event
CH6LIMITL : INTENCLR_CH6LIMITL_Field_1 :=
Intenclr_Ch6Limitl_Field_Reset;
-- Write '1' to Disable interrupt for CH[7].LIMITH event
CH7LIMITH : INTENCLR_CH7LIMITH_Field_1 :=
Intenclr_Ch7Limith_Field_Reset;
-- Write '1' to Disable interrupt for CH[7].LIMITL event
CH7LIMITL : INTENCLR_CH7LIMITL_Field_1 :=
Intenclr_Ch7Limitl_Field_Reset;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
STARTED at 0 range 0 .. 0;
END_k at 0 range 1 .. 1;
DONE at 0 range 2 .. 2;
RESULTDONE at 0 range 3 .. 3;
CALIBRATEDONE at 0 range 4 .. 4;
STOPPED at 0 range 5 .. 5;
CH0LIMITH at 0 range 6 .. 6;
CH0LIMITL at 0 range 7 .. 7;
CH1LIMITH at 0 range 8 .. 8;
CH1LIMITL at 0 range 9 .. 9;
CH2LIMITH at 0 range 10 .. 10;
CH2LIMITL at 0 range 11 .. 11;
CH3LIMITH at 0 range 12 .. 12;
CH3LIMITL at 0 range 13 .. 13;
CH4LIMITH at 0 range 14 .. 14;
CH4LIMITL at 0 range 15 .. 15;
CH5LIMITH at 0 range 16 .. 16;
CH5LIMITL at 0 range 17 .. 17;
CH6LIMITH at 0 range 18 .. 18;
CH6LIMITL at 0 range 19 .. 19;
CH7LIMITH at 0 range 20 .. 20;
CH7LIMITL at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Status
type STATUS_STATUS_Field is
(-- ADC is ready. No on-going conversion.
Ready,
-- ADC is busy. Conversion in progress.
Busy)
with Size => 1;
for STATUS_STATUS_Field use
(Ready => 0,
Busy => 1);
-- Status
type STATUS_Register is record
-- Read-only. Status
STATUS : STATUS_STATUS_Field;
-- unspecified
Reserved_1_31 : HAL.UInt31;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for STATUS_Register use record
STATUS at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Enable or disable ADC
type ENABLE_ENABLE_Field is
(-- Disable ADC
Disabled,
-- Enable ADC
Enabled)
with Size => 1;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable ADC
type ENABLE_Register is record
-- Enable or disable ADC
ENABLE : ENABLE_ENABLE_Field := NRF_SVD.SAADC.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
----------------------------
-- CH cluster's Registers --
----------------------------
-- Analog positive input channel
type PSELP_PSELP_Field is
(-- Not connected
Nc,
-- AIN0
Analoginput0,
-- AIN1
Analoginput1,
-- AIN2
Analoginput2,
-- AIN3
Analoginput3,
-- AIN4
Analoginput4,
-- AIN5
Analoginput5,
-- AIN6
Analoginput6,
-- AIN7
Analoginput7,
-- VDD
Vdd)
with Size => 5;
for PSELP_PSELP_Field use
(Nc => 0,
Analoginput0 => 1,
Analoginput1 => 2,
Analoginput2 => 3,
Analoginput3 => 4,
Analoginput4 => 5,
Analoginput5 => 6,
Analoginput6 => 7,
Analoginput7 => 8,
Vdd => 9);
-- Description cluster[0]: Input positive pin selection for CH[0]
type PSELP_CH_Register is record
-- Analog positive input channel
PSELP : PSELP_PSELP_Field := NRF_SVD.SAADC.Nc;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PSELP_CH_Register use record
PSELP at 0 range 0 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Analog negative input, enables differential channel
type PSELN_PSELN_Field is
(-- Not connected
Nc,
-- AIN0
Analoginput0,
-- AIN1
Analoginput1,
-- AIN2
Analoginput2,
-- AIN3
Analoginput3,
-- AIN4
Analoginput4,
-- AIN5
Analoginput5,
-- AIN6
Analoginput6,
-- AIN7
Analoginput7,
-- VDD
Vdd)
with Size => 5;
for PSELN_PSELN_Field use
(Nc => 0,
Analoginput0 => 1,
Analoginput1 => 2,
Analoginput2 => 3,
Analoginput3 => 4,
Analoginput4 => 5,
Analoginput5 => 6,
Analoginput6 => 7,
Analoginput7 => 8,
Vdd => 9);
-- Description cluster[0]: Input negative pin selection for CH[0]
type PSELN_CH_Register is record
-- Analog negative input, enables differential channel
PSELN : PSELN_PSELN_Field := NRF_SVD.SAADC.Nc;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PSELN_CH_Register use record
PSELN at 0 range 0 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Positive channel resistor control
type CONFIG_RESP_Field is
(-- Bypass resistor ladder
Bypass,
-- Pull-down to GND
Pulldown,
-- Pull-up to VDD
Pullup,
-- Set input at VDD/2
Vdd1_2)
with Size => 2;
for CONFIG_RESP_Field use
(Bypass => 0,
Pulldown => 1,
Pullup => 2,
Vdd1_2 => 3);
-- Negative channel resistor control
type CONFIG_RESN_Field is
(-- Bypass resistor ladder
Bypass,
-- Pull-down to GND
Pulldown,
-- Pull-up to VDD
Pullup,
-- Set input at VDD/2
Vdd1_2)
with Size => 2;
for CONFIG_RESN_Field use
(Bypass => 0,
Pulldown => 1,
Pullup => 2,
Vdd1_2 => 3);
-- Gain control
type CONFIG_GAIN_Field is
(-- 1/6
Gain1_6,
-- 1/5
Gain1_5,
-- 1/4
Gain1_4,
-- 1/3
Gain1_3,
-- 1/2
Gain1_2,
-- 1
Gain1,
-- 2
Gain2,
-- 4
Gain4)
with Size => 3;
for CONFIG_GAIN_Field use
(Gain1_6 => 0,
Gain1_5 => 1,
Gain1_4 => 2,
Gain1_3 => 3,
Gain1_2 => 4,
Gain1 => 5,
Gain2 => 6,
Gain4 => 7);
-- Reference control
type CONFIG_REFSEL_Field is
(-- Internal reference (0.6 V)
Internal,
-- VDD/4 as reference
Vdd1_4)
with Size => 1;
for CONFIG_REFSEL_Field use
(Internal => 0,
Vdd1_4 => 1);
-- Acquisition time, the time the ADC uses to sample the input voltage
type CONFIG_TACQ_Field is
(-- 3 us
Val_3US,
-- 5 us
Val_5US,
-- 10 us
Val_10US,
-- 15 us
Val_15US,
-- 20 us
Val_20US,
-- 40 us
Val_40US)
with Size => 3;
for CONFIG_TACQ_Field use
(Val_3US => 0,
Val_5US => 1,
Val_10US => 2,
Val_15US => 3,
Val_20US => 4,
Val_40US => 5);
-- Enable differential mode
type CONFIG_MODE_Field is
(-- Single ended, PSELN will be ignored, negative input to ADC shorted to GND
Se,
-- Differential
Diff)
with Size => 1;
for CONFIG_MODE_Field use
(Se => 0,
Diff => 1);
-- Enable burst mode
type CONFIG_BURST_Field is
(-- Burst mode is disabled (normal operation)
Disabled,
-- Burst mode is enabled. SAADC takes 2^OVERSAMPLE number of samples as fast
-- as it can, and sends the average to Data RAM.
Enabled)
with Size => 1;
for CONFIG_BURST_Field use
(Disabled => 0,
Enabled => 1);
-- Description cluster[0]: Input configuration for CH[0]
type CONFIG_CH_Register is record
-- Positive channel resistor control
RESP : CONFIG_RESP_Field := NRF_SVD.SAADC.Bypass;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Negative channel resistor control
RESN : CONFIG_RESN_Field := NRF_SVD.SAADC.Bypass;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Gain control
GAIN : CONFIG_GAIN_Field := NRF_SVD.SAADC.Gain1_6;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- Reference control
REFSEL : CONFIG_REFSEL_Field := NRF_SVD.SAADC.Internal;
-- unspecified
Reserved_13_15 : HAL.UInt3 := 16#0#;
-- Acquisition time, the time the ADC uses to sample the input voltage
TACQ : CONFIG_TACQ_Field := NRF_SVD.SAADC.Val_10US;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#0#;
-- Enable differential mode
MODE : CONFIG_MODE_Field := NRF_SVD.SAADC.Se;
-- unspecified
Reserved_21_23 : HAL.UInt3 := 16#0#;
-- Enable burst mode
BURST : CONFIG_BURST_Field := NRF_SVD.SAADC.Disabled;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CONFIG_CH_Register use record
RESP at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
RESN at 0 range 4 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
GAIN at 0 range 8 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
REFSEL at 0 range 12 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
TACQ at 0 range 16 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
MODE at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
BURST at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype LIMIT_CH_LOW_Field is HAL.UInt16;
subtype LIMIT_CH_HIGH_Field is HAL.UInt16;
-- Description cluster[0]: High/low limits for event monitoring a channel
type LIMIT_CH_Register is record
-- Low level limit
LOW : LIMIT_CH_LOW_Field := 16#8000#;
-- High level limit
HIGH : LIMIT_CH_HIGH_Field := 16#7FFF#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for LIMIT_CH_Register use record
LOW at 0 range 0 .. 15;
HIGH at 0 range 16 .. 31;
end record;
-- Unspecified
type CH_Cluster is record
-- Description cluster[0]: Input positive pin selection for CH[0]
PSELP : aliased PSELP_CH_Register;
-- Description cluster[0]: Input negative pin selection for CH[0]
PSELN : aliased PSELN_CH_Register;
-- Description cluster[0]: Input configuration for CH[0]
CONFIG : aliased CONFIG_CH_Register;
-- Description cluster[0]: High/low limits for event monitoring a
-- channel
LIMIT : aliased LIMIT_CH_Register;
end record
with Size => 128;
for CH_Cluster use record
PSELP at 16#0# range 0 .. 31;
PSELN at 16#4# range 0 .. 31;
CONFIG at 16#8# range 0 .. 31;
LIMIT at 16#C# range 0 .. 31;
end record;
-- Unspecified
type CH_Clusters is array (0 .. 7) of CH_Cluster;
-- Set the resolution
type RESOLUTION_VAL_Field is
(-- 8 bit
Val_8BIT,
-- 10 bit
Val_10BIT,
-- 12 bit
Val_12BIT,
-- 14 bit
Val_14BIT)
with Size => 3;
for RESOLUTION_VAL_Field use
(Val_8BIT => 0,
Val_10BIT => 1,
Val_12BIT => 2,
Val_14BIT => 3);
-- Resolution configuration
type RESOLUTION_Register is record
-- Set the resolution
VAL : RESOLUTION_VAL_Field := NRF_SVD.SAADC.Val_10BIT;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RESOLUTION_Register use record
VAL at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Oversample control
type OVERSAMPLE_OVERSAMPLE_Field is
(-- Bypass oversampling
Bypass,
-- Oversample 2x
Over2X,
-- Oversample 4x
Over4X,
-- Oversample 8x
Over8X,
-- Oversample 16x
Over16X,
-- Oversample 32x
Over32X,
-- Oversample 64x
Over64X,
-- Oversample 128x
Over128X,
-- Oversample 256x
Over256X)
with Size => 4;
for OVERSAMPLE_OVERSAMPLE_Field use
(Bypass => 0,
Over2X => 1,
Over4X => 2,
Over8X => 3,
Over16X => 4,
Over32X => 5,
Over64X => 6,
Over128X => 7,
Over256X => 8);
-- Oversampling configuration. OVERSAMPLE should not be combined with SCAN.
-- The RESOLUTION is applied before averaging, thus for high OVERSAMPLE a
-- higher RESOLUTION should be used.
type OVERSAMPLE_Register is record
-- Oversample control
OVERSAMPLE : OVERSAMPLE_OVERSAMPLE_Field := NRF_SVD.SAADC.Bypass;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OVERSAMPLE_Register use record
OVERSAMPLE at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
subtype SAMPLERATE_CC_Field is HAL.UInt11;
-- Select mode for sample rate control
type SAMPLERATE_MODE_Field is
(-- Rate is controlled from SAMPLE task
Task_k,
-- Rate is controlled from local timer (use CC to control the rate)
Timers)
with Size => 1;
for SAMPLERATE_MODE_Field use
(Task_k => 0,
Timers => 1);
-- Controls normal or continuous sample rate
type SAMPLERATE_Register is record
-- Capture and compare value. Sample rate is 16 MHz/CC
CC : SAMPLERATE_CC_Field := 16#0#;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- Select mode for sample rate control
MODE : SAMPLERATE_MODE_Field := NRF_SVD.SAADC.Task_k;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SAMPLERATE_Register use record
CC at 0 range 0 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
MODE at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
--------------------------------
-- RESULT cluster's Registers --
--------------------------------
subtype MAXCNT_RESULT_MAXCNT_Field is HAL.UInt15;
-- Maximum number of buffer words to transfer
type MAXCNT_RESULT_Register is record
-- Maximum number of buffer words to transfer
MAXCNT : MAXCNT_RESULT_MAXCNT_Field := 16#0#;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MAXCNT_RESULT_Register use record
MAXCNT at 0 range 0 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
subtype AMOUNT_RESULT_AMOUNT_Field is HAL.UInt15;
-- Number of buffer words transferred since last START
type AMOUNT_RESULT_Register is record
-- Read-only. Number of buffer words transferred since last START. This
-- register can be read after an END or STOPPED event.
AMOUNT : AMOUNT_RESULT_AMOUNT_Field;
-- unspecified
Reserved_15_31 : HAL.UInt17;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AMOUNT_RESULT_Register use record
AMOUNT at 0 range 0 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-- RESULT EasyDMA channel
type RESULT_Cluster is record
-- Data pointer
PTR : aliased HAL.UInt32;
-- Maximum number of buffer words to transfer
MAXCNT : aliased MAXCNT_RESULT_Register;
-- Number of buffer words transferred since last START
AMOUNT : aliased AMOUNT_RESULT_Register;
end record
with Size => 96;
for RESULT_Cluster use record
PTR at 16#0# range 0 .. 31;
MAXCNT at 16#4# range 0 .. 31;
AMOUNT at 16#8# range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Analog to Digital Converter
type SAADC_Peripheral is record
-- Start the ADC and prepare the result buffer in RAM
TASKS_START : aliased HAL.UInt32;
-- Take one ADC sample, if scan is enabled all channels are sampled
TASKS_SAMPLE : aliased HAL.UInt32;
-- Stop the ADC and terminate any on-going conversion
TASKS_STOP : aliased HAL.UInt32;
-- Starts offset auto-calibration
TASKS_CALIBRATEOFFSET : aliased HAL.UInt32;
-- The ADC has started
EVENTS_STARTED : aliased HAL.UInt32;
-- The ADC has filled up the Result buffer
EVENTS_END : aliased HAL.UInt32;
-- A conversion task has been completed. Depending on the mode, multiple
-- conversions might be needed for a result to be transferred to RAM.
EVENTS_DONE : aliased HAL.UInt32;
-- A result is ready to get transferred to RAM.
EVENTS_RESULTDONE : aliased HAL.UInt32;
-- Calibration is complete
EVENTS_CALIBRATEDONE : aliased HAL.UInt32;
-- The ADC has stopped
EVENTS_STOPPED : aliased HAL.UInt32;
-- Unspecified
EVENTS_CH : aliased EVENTS_CH_Clusters;
-- Enable or disable interrupt
INTEN : aliased INTEN_Register;
-- Enable interrupt
INTENSET : aliased INTENSET_Register;
-- Disable interrupt
INTENCLR : aliased INTENCLR_Register;
-- Status
STATUS : aliased STATUS_Register;
-- Enable or disable ADC
ENABLE : aliased ENABLE_Register;
-- Unspecified
CH : aliased CH_Clusters;
-- Resolution configuration
RESOLUTION : aliased RESOLUTION_Register;
-- Oversampling configuration. OVERSAMPLE should not be combined with
-- SCAN. The RESOLUTION is applied before averaging, thus for high
-- OVERSAMPLE a higher RESOLUTION should be used.
OVERSAMPLE : aliased OVERSAMPLE_Register;
-- Controls normal or continuous sample rate
SAMPLERATE : aliased SAMPLERATE_Register;
-- RESULT EasyDMA channel
RESULT : aliased RESULT_Cluster;
end record
with Volatile;
for SAADC_Peripheral use record
TASKS_START at 16#0# range 0 .. 31;
TASKS_SAMPLE at 16#4# range 0 .. 31;
TASKS_STOP at 16#8# range 0 .. 31;
TASKS_CALIBRATEOFFSET at 16#C# range 0 .. 31;
EVENTS_STARTED at 16#100# range 0 .. 31;
EVENTS_END at 16#104# range 0 .. 31;
EVENTS_DONE at 16#108# range 0 .. 31;
EVENTS_RESULTDONE at 16#10C# range 0 .. 31;
EVENTS_CALIBRATEDONE at 16#110# range 0 .. 31;
EVENTS_STOPPED at 16#114# range 0 .. 31;
EVENTS_CH at 16#118# range 0 .. 511;
INTEN at 16#300# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
STATUS at 16#400# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
CH at 16#510# range 0 .. 1023;
RESOLUTION at 16#5F0# range 0 .. 31;
OVERSAMPLE at 16#5F4# range 0 .. 31;
SAMPLERATE at 16#5F8# range 0 .. 31;
RESULT at 16#62C# range 0 .. 95;
end record;
-- Analog to Digital Converter
SAADC_Periph : aliased SAADC_Peripheral
with Import, Address => SAADC_Base;
end NRF_SVD.SAADC;
|
with Tracks_Display; use Tracks_Display;
with Screen_Interface; use Screen_Interface;
with Drawing; use Drawing;
with Trains; use Trains;
with Fonts; use Fonts;
package body Railroad is
Block_Size : constant := 40; -- Pixels
-- Touch Areas
subtype Spawn_X is Screen_Interface.Width range
Width (Block_Size * 1.5) .. Width (Block_Size * 4.5);
subtype Spawn_Y is Height range
Height (Block_Size * 0.9) .. Height (Block_Size * 1.9);
subtype Sw1_X is Width range
Width (Block_Size * 5.0) .. Width (Block_Size * 6.0 - 1.0);
subtype Sw1_Y is Height range
Height (Block_Size * 5.0) .. Height (Block_Size * 6.0);
subtype Sw2_X is Width range
Width (Block_Size * 1.5) .. Width (Block_Size * 2.5);
subtype Sw2_Y is Height range
Height (Block_Size * 4.0) .. Height (Block_Size * 5.0);
subtype Sw3_X is Width range
Width (Block_Size * 3.5) .. Width (Block_Size * 4.5 - 1.0);
subtype Sw3_Y is Height range
Height (Block_Size * 2.0) .. Height (Block_Size * 3.3);
Out_Loop_Track_Nbr : constant Positive := (6 + 4 + 6 + 4);
In_Loop_Track_Nbr : constant Positive := (3 + 1 + 3 + 1);
Straight_Tracks : array (1 .. (Out_Loop_Track_Nbr + In_Loop_Track_Nbr)) of
aliased Track_T (20);
Curve_Tracks : array (1 .. 8) of aliased Track_T (16);
Switch_Tracks : array (1 .. 3) of aliased Track_Access;
Spawn_Tracks : array (1 .. 2) of aliased Track_T (20);
Connection_Tracks : array (1 .. 3) of aliased Track_T (50);
My_Trains : array (Trains.Train_Id) of Train_T (13);
type Location_Point is record
Coord : Point;
Used : Boolean := False;
end record;
Locations_coords : array (Trains.Location) of Location_Point;
procedure Create_Out_Loop is
WLast : constant := Width'Last + 1;
HLast : constant := Height'Last + 1;
Top_Line_First : constant Positive := 1;
Top_Line_Last : constant Positive := 6;
Left_Line_First : constant Positive := Top_Line_Last + 1;
Left_Line_Last : constant Positive := 10;
Bottom_Line_First : constant Positive := Left_Line_Last + 1;
Bottom_Line_Last : constant Positive := 16;
Right_Line_First : constant Positive := Bottom_Line_Last + 1;
Right_Line_Last : constant Positive := 20;
begin
-- Top Line
for Cnt in 1 .. 6 loop
declare
X : constant := Block_Size / 2;
Index : constant Positive := Cnt;
begin
Build_Straight_Track (Straight_Tracks (Index),
(X, Height (Block_Size * Cnt)),
(X, Height (Block_Size * (Cnt + 1))));
Set_Sign_Position (Straight_Tracks (Index), Top);
if Cnt > 1 then
Connect_Track (Straight_Tracks (Index - 1),
Straight_Tracks (Index)'Access,
null);
end if;
end;
end loop;
-- Left Line
for Cnt in 1 .. 4 loop
declare
Y : constant := HLast - (Block_Size / 2);
Index : constant Positive := Cnt + Top_Line_Last;
begin
Build_Straight_Track (Straight_Tracks (Index),
(Width (Block_Size * Cnt), Y),
(Width (Block_Size * (Cnt + 1)), Y));
Set_Sign_Position (Straight_Tracks (Index), Left);
if Cnt > 1 then
Connect_Track (Straight_Tracks (Index - 1),
Straight_Tracks (Index)'Access,
null);
end if;
end;
end loop;
-- Bottom Line
for Cnt in 1 .. 6 loop
declare
X : constant := WLast - (Block_Size / 2);
Index : constant Positive := Cnt + Left_Line_Last;
begin
Build_Straight_Track (Straight_Tracks (Index),
(X, HLast - Height (Block_Size * Cnt)),
(X, HLast - Height (Block_Size * (Cnt + 1))));
Set_Sign_Position (Straight_Tracks (Index), Bottom);
if Cnt > 1 then
Connect_Track (Straight_Tracks (Index - 1),
Straight_Tracks (Index)'Access,
null);
end if;
end;
end loop;
-- Right Line
for Cnt in 1 .. 4 loop
declare
Y : constant := Block_Size / 2;
Index : constant Positive := Cnt + Bottom_Line_Last;
begin
Build_Straight_Track (Straight_Tracks (Index),
(WLast - Width (Block_Size * Cnt), Y),
(WLast - Width (Block_Size * (Cnt + 1)), Y));
Set_Sign_Position (Straight_Tracks (Index), Right);
if Cnt > 1 then
Connect_Track (Straight_Tracks (Index - 1),
Straight_Tracks (Index)'Access,
null);
end if;
end;
end loop;
-- Top Right Curve
Build_Curve_Track (Curve_Tracks (1),
(Block_Size, Block_Size / 2),
(Block_Size / 2, Block_Size / 2),
(Block_Size / 2, Block_Size / 2),
(Block_Size / 2, Block_Size));
Set_Sign_Position (Curve_Tracks (1), Right);
Connect_Track (Straight_Tracks (Right_Line_Last),
Curve_Tracks (1)'Access, null);
Connect_Track (Curve_Tracks (1),
Straight_Tracks (Top_Line_First)'Access, null);
-- Top Left Curve
Build_Curve_Track (Curve_Tracks (2),
(Block_Size / 2, HLast - Block_Size),
(Block_Size / 2, HLast - Block_Size / 2),
(Block_Size / 2, HLast - Block_Size / 2),
(Block_Size, HLast - Block_Size / 2));
Set_Sign_Position (Curve_Tracks (2), Top);
Connect_Track (Straight_Tracks (Top_Line_Last),
Curve_Tracks (2)'Access, null);
Connect_Track (Curve_Tracks (2),
Straight_Tracks (Left_Line_First)'Access, null);
-- Bottom Left Curve
Build_Curve_Track (Curve_Tracks (3),
(WLast - Block_Size, HLast - Block_Size / 2),
(WLast - Block_Size/ 2, HLast - Block_Size / 2),
(WLast - Block_Size/ 2, HLast - Block_Size / 2),
(WLast - Block_Size / 2, HLast - Block_Size));
Set_Sign_Position (Curve_Tracks (3), Left);
Connect_Track (Straight_Tracks (Left_Line_Last),
Curve_Tracks (3)'Access, null);
Connect_Track (Curve_Tracks (3),
Straight_Tracks (Bottom_Line_First)'Access, null);
-- Bottom Right Curve
Build_Curve_Track (Curve_Tracks (4),
(WLast - Block_Size / 2, Block_Size),
(WLast - Block_Size / 2, Block_Size / 2),
(WLast - Block_Size / 2, Block_Size / 2),
(WLast - Block_Size, Block_Size / 2));
Set_Sign_Position (Curve_Tracks (4), Bottom);
Connect_Track (Straight_Tracks (Bottom_Line_Last),
Curve_Tracks (4)'Access, null);
Connect_Track (Curve_Tracks (4),
Straight_Tracks (Right_Line_First)'Access, null);
-- Spawn Track
Build_Straight_Track (Spawn_Tracks (1),
(Width (Block_Size), Height (2 * Block_Size)),
(Width (Block_Size), Height (3 * Block_Size)));
Build_Straight_Track (Spawn_Tracks (2),
(Width (Block_Size), Height (3 * Block_Size)),
(Width (Block_Size / 2), Height (4 * Block_Size)));
Connect_Track (Spawn_Tracks (1), Spawn_Tracks (2)'Access, null);
Connect_Track (Spawn_Tracks (2), Straight_Tracks (4)'Access, null);
end Create_Out_Loop;
procedure Create_In_Loop is
HLast : constant := Height'Last + 1;
Top_Line_First : constant Positive := Out_Loop_Track_Nbr + 1;
Top_Line_Last : constant Positive := Top_Line_First + 2;
Left_Line_First : constant Positive := Top_Line_Last + 1;
Left_Line_Last : constant Positive := Left_Line_First;
Bottom_Line_First : constant Positive := Left_Line_Last + 1;
Bottom_Line_Last : constant Positive := Bottom_Line_First + 2;
Right_Line_First : constant Positive := Bottom_Line_Last + 1;
Right_Line_Last : constant Positive := Right_Line_First;
begin
-- Top Line
for Cnt in 1 .. 3 loop
declare
X : constant Width := Width (Block_Size * 2);
Y_Base : constant := Block_Size * 2;
Index : constant Positive := Top_Line_First + Cnt - 1;
begin
Build_Straight_Track (Straight_Tracks (Index),
(X, Height (Y_Base + Block_Size * Cnt)),
(X, Height (Y_Base + Block_Size * (Cnt + 1))));
Set_Sign_Position (Straight_Tracks (Index), Top);
if Cnt > 1 then
Connect_Track (Straight_Tracks (Index - 1),
Straight_Tracks (Index)'Access,
null);
end if;
end;
end loop;
-- There is a switch here so we move the sign to the other side of the
-- track so that it won't overlap with switche's sign.
Set_Sign_Position (Straight_Tracks (Top_Line_First + 1), Bottom);
-- Left Line
declare
Index : constant Positive := Left_Line_First;
begin
Build_Straight_Track (Straight_Tracks (Index),
(Width (Block_Size * 2.5),
Height (Block_Size * 6.5)),
(Width (Block_Size * 3.5),
Height (Block_Size * 6.5)));
Set_Sign_Position (Straight_Tracks (Index), Left);
end;
-- Bottom Line
for Cnt in 1 .. 3 loop
declare
X : constant := Width (Block_Size * 4);
Y_Base : constant := Block_Size;
Index : constant Positive := Cnt + Left_Line_Last;
begin
Build_Straight_Track (Straight_Tracks (Index),
(X, HLast - Height (Y_Base + Block_Size * Cnt)),
(X, HLast
- Height (Y_Base + Block_Size * (Cnt + 1))));
Set_Sign_Position (Straight_Tracks (Index), Bottom);
if Cnt > 1 then
Connect_Track (Straight_Tracks (Index - 1),
Straight_Tracks (Index)'Access,
null);
end if;
end;
end loop;
-- Right Line
declare
Index : constant Positive := Right_Line_First;
begin
Build_Straight_Track (Straight_Tracks (Index),
(Width (Block_Size * 3.5),
Height (Block_Size * 2.5)),
(Width (Block_Size * 2.5),
Height (Block_Size * 2.5)));
Set_Sign_Position (Straight_Tracks (Index), Right);
end;
-- Top Right Curve
Build_Curve_Track (Curve_Tracks (5),
(Width (Block_Size * 2.5), Height (Block_Size * 2.5)),
(Width (Block_Size * 2.0), Height (Block_Size * 2.5)),
(Width (Block_Size * 2.0), Height (Block_Size * 2.5)),
(Width (Block_Size * 2.0), Height (Block_Size * 3.0)));
Set_Sign_Position (Curve_Tracks (5), Right);
Connect_Track (Straight_Tracks (Right_Line_Last),
Curve_Tracks (5)'Access, null);
Connect_Track (Curve_Tracks (5),
Straight_Tracks (Top_Line_First)'Access, null);
-- Top Left Curve
Build_Curve_Track (Curve_Tracks (6),
(Width (Block_Size * 2.0), Height (Block_Size * 6.0)),
(Width (Block_Size * 2.0), Height (Block_Size * 6.5)),
(Width (Block_Size * 2.0), Height (Block_Size * 6.5)),
(Width (Block_Size * 2.5), Height (Block_Size * 6.5)));
Set_Sign_Position (Curve_Tracks (6), Top);
Connect_Track (Straight_Tracks (Top_Line_Last),
Curve_Tracks (6)'Access, null);
Connect_Track (Curve_Tracks (6),
Straight_Tracks (Left_Line_First)'Access, null);
-- Bottom Left Curve
Build_Curve_Track (Curve_Tracks (7),
(Width (Block_Size * 3.5), Height (Block_Size * 6.5)),
(Width (Block_Size * 4.0), Height (Block_Size * 6.5)),
(Width (Block_Size * 4.0), Height (Block_Size * 6.5)),
(Width (Block_Size * 4.0), Height (Block_Size * 6.0)));
Set_Sign_Position (Curve_Tracks (7), Left);
Connect_Track (Straight_Tracks (Left_Line_Last),
Curve_Tracks (7)'Access, null);
Connect_Track (Curve_Tracks (7),
Straight_Tracks (Bottom_Line_First)'Access, null);
-- Bottom Right Curve
Build_Curve_Track (Curve_Tracks (8),
(Width (Block_Size * 4.0), Height (Block_Size * 3.0)),
(Width (Block_Size * 4.0), Height (Block_Size * 2.5)),
(Width (Block_Size * 4.0), Height (Block_Size * 2.5)),
(Width (Block_Size * 3.5), Height (Block_Size * 2.5)));
-- There is a switch here so we move the sign to the other side of the
-- track so that it won't overlap with switche's sign.
Set_Sign_Position (Curve_Tracks (8), Top);
Connect_Track (Straight_Tracks (Bottom_Line_Last),
Curve_Tracks (8)'Access, null);
Connect_Track (Curve_Tracks (8),
Straight_Tracks (Right_Line_First)'Access, null);
end Create_In_Loop;
procedure Create_Connection_Tracks is
begin
Build_Curve_Track (Connection_Tracks (1),
End_Coord (Straight_Tracks (11)),
End_Coord (Straight_Tracks (12)),
Start_Coord (Straight_Tracks (Out_Loop_Track_Nbr + 6)),
Start_Coord (Straight_Tracks (Out_Loop_Track_Nbr + 7)));
Connect_Track (Connection_Tracks (1),
Straight_Tracks (Out_Loop_Track_Nbr + 7)'Access,
null);
Connect_Track (Straight_Tracks (11),
Straight_Tracks (12)'Access,
Connection_Tracks (1)'Access);
Switch_Tracks (1) := Straight_Tracks (11)'Access;
Build_Curve_Track (Connection_Tracks (2),
End_Coord (Straight_Tracks (Out_Loop_Track_Nbr + 1)),
end_Coord (Straight_Tracks (Out_Loop_Track_Nbr + 2)),
Start_Coord (Straight_Tracks (5)),
Start_Coord (Straight_Tracks (6)));
Connect_Track (Connection_Tracks (2), Straight_Tracks (6)'Access, null);
Connect_Track (Straight_Tracks (Out_Loop_Track_Nbr + 1),
Straight_Tracks (Out_Loop_Track_Nbr + 2)'Access,
Connection_Tracks (2)'Access);
Set_Sign_Position (Connection_Tracks (2), Top);
Switch_Tracks (2) := Straight_Tracks (Out_Loop_Track_Nbr + 1)'Access;
Build_Curve_Track (Connection_Tracks (3),
End_Coord (Straight_Tracks (Out_Loop_Track_Nbr + 7)),
End_Coord (Straight_Tracks (Out_Loop_Track_Nbr + 7))
- (0, Block_Size),
Start_Coord (Curve_Tracks (4)) + (0, Block_Size),
Start_Coord (Curve_Tracks (4)));
Connect_Track (Connection_Tracks (3), Curve_Tracks (4)'Access, null);
Set_Sign_Position (Connection_Tracks (3), Bottom);
Connect_Track (Straight_Tracks (Out_Loop_Track_Nbr + 7),
Curve_Tracks (8)'Access,
Connection_Tracks (3)'Access);
Switch_Tracks (3) := Straight_Tracks (Out_Loop_Track_Nbr + 7)'Access;
end Create_Connection_Tracks;
function Can_Spawn_Train return Boolean is
begin
return Cur_Num_Trains < Train_Id'Last
and then Spawn_Tracks (1).Entry_Sign.Color /= Tracks_Display.Red;
end Can_Spawn_Train;
procedure Spawn_Train is
begin
if Can_Spawn_Train then
Init_Train (My_Trains (Cur_Num_Trains), Spawn_Tracks (1)'Access);
My_Trains (Cur_Num_Trains).Speed := 2;
Trains.Trains (Cur_Num_Trains) :=
(Spawn_Tracks (1).Id, 1, Spawn_Tracks (1).Id);
Trains.Cur_Num_Trains := Trains.Cur_Num_Trains + 1;
Trains.Track_Signals (Spawn_Tracks (1).Id) := Trains.Red;
end if;
end;
procedure Simulation_Step is
begin
for Index in Trains.Train_Id'First .. Trains.Cur_Num_Trains - 1 loop
Move_Train (My_Trains (Index));
end loop;
for Track of Straight_Tracks loop
Update_Sign (Track);
end loop;
for Track of Spawn_Tracks loop
Update_Sign (Track);
end loop;
for Track of Curve_Tracks loop
Update_Sign (Track);
end loop;
for Track of Connection_Tracks loop
Update_Sign (Track);
end loop;
end;
procedure Draw (Init : Boolean := False) is
begin
if Init then
-- Tracks
for Track of Straight_Tracks loop
Draw_Track (Track);
end loop;
for Track of Spawn_Tracks loop
Draw_Track (Track);
end loop;
for Track of Curve_Tracks loop
Draw_Track (Track);
end loop;
for Track of Connection_Tracks loop
Draw_Track (Track);
end loop;
end if;
-- Switches
for Track of Switch_Tracks loop
if Track /= null then
Draw_Switch (Track.all);
end if;
end loop;
-- Trains
for Index in Trains.Train_Id'First .. Trains.Cur_Num_Trains - 1 loop
Draw_Train (My_Trains (Index));
end loop;
-- Draw touch areas
Rect ((Sw1_X'First, Sw1_Y'First),
(Sw1_X'Last, Sw1_Y'Last),
White);
Rect ((Sw2_X'First, Sw2_Y'First),
(Sw2_X'Last, Sw2_Y'Last),
White);
Rect ((Sw3_X'First, Sw3_Y'First),
(Sw3_X'Last, Sw3_Y'Last),
White);
if Can_Spawn_Train then
Rect ((Spawn_X'First, Spawn_Y'First),
(Spawn_X'Last, Spawn_Y'Last),
White);
Fonts.Draw_String (P => (Spawn_X'First + 5,
Spawn_Y'First + 5),
Str => "Touch here to",
Font => Font8x8,
FG => Screen_Interface.White,
BG => Screen_Interface.Black);
Fonts.Draw_String (P => (Spawn_X'First + 5,
Spawn_Y'First + 22),
Str => "spawn a train",
Font => Font8x8,
FG => Screen_Interface.White,
BG => Screen_Interface.Black);
else
Rect_Fill ((Spawn_X'First, Spawn_Y'First),
(Spawn_X'Last, Spawn_Y'Last),
Screen_Interface.Black);
end if;
end Draw;
procedure Convert_Railway_Map is
Cur_Loc : Trains.Location := Trains.Location'First;
Cur_Track : Trains.Track_Id := Trains.Track_Id'First;
-- Return Location coresponding to a Point.
-- Create a new Locatio if needed.
function Get_Loc (P : Point) return Trains.Location is
begin
for Index in Trains.Location loop
exit when not Locations_coords (Index).Used;
if Locations_coords (Index).Coord = P then
return Index;
end if;
end loop;
Locations_coords (Cur_Loc).Used := True;
Locations_coords (Cur_Loc).Coord := P;
Cur_Loc := Cur_Loc + 1;
return Cur_Loc - 1;
end Get_Loc;
procedure Add_Track (Track : in out Track_T) is
begin
Track.Id := Cur_Track;
-- Define the tracks From and To locations
Trains.Tracks (Cur_Track) := (Get_Loc (Start_Coord (Track)),
Get_Loc (End_Coord (Track)),
Track.Points'Last);
Cur_Track := Cur_Track + 1;
end Add_Track;
procedure Add_Previous_Track (Loc : Trains.Location;
Id : Trains.Track_Id) is
begin
for Index in Trains.Prev_Id loop
if Trains.Previous_Tracks (Loc) (Index) = Trains.No_Track_Id then
Trains.Previous_Tracks (Loc) (Index) := Id;
return;
end if;
end loop;
end Add_Previous_Track;
begin
-- Create track map for Trains package
for Track of Straight_Tracks loop
Add_Track (Track);
Add_Previous_Track (Get_Loc (End_Coord (Track)), Track.Id);
end loop;
for Track of Curve_Tracks loop
Add_Track (Track);
Add_Previous_Track (Get_Loc (End_Coord (Track)), Track.Id);
end loop;
for Track of Connection_Tracks loop
Add_Track (Track);
Add_Previous_Track (Get_Loc (End_Coord (Track)), Track.Id);
end loop;
for Track of Spawn_Tracks loop
Add_Track (Track);
Add_Previous_Track (Get_Loc (End_Coord (Track)), Track.Id);
end loop;
end Convert_Railway_Map;
procedure Initialize is
begin
Create_Out_Loop;
Create_In_Loop;
Create_Connection_Tracks;
Convert_Railway_Map;
Draw (True);
end Initialize;
procedure On_Touch (P : Point) is
begin
if P.X in Spawn_X and then P.Y in Spawn_Y then
Spawn_Train;
end if;
if P.X in Sw1_X and then P.Y in Sw1_Y then
Change_Switch (Switch_Tracks (1).all);
end if;
if P.X in Sw2_X and then P.Y in Sw2_Y then
Change_Switch (Switch_Tracks (2).all);
end if;
if P.X in Sw3_X and then P.Y in Sw3_Y then
Change_Switch (Switch_Tracks (3).all);
end if;
end On_Touch;
end Railroad;
|
package body Global_Singleton is
--------------
-- Set_Data --
--------------
procedure Set_Data (Value : Integer) is
begin
Instance.Data := Value;
end Set_Data;
--------------
-- Get_Data --
--------------
function Get_Data return Integer is
begin
return Instance.Data;
end Get_Data;
end Global_Singleton;
|
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@heisenbug.eu)
--
-- 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. - A tree holding descendant objects of Entity.T.
--
------------------------------------------------------------------------------
with Ada.Containers.Indefinite_Multiway_Trees;
package SPAT.Entity.Tree is
package Implementation is
package Trees is new
Ada.Containers.Indefinite_Multiway_Trees (Element_Type => T'Class);
end Implementation;
type T is new Implementation.Trees.Tree with private;
subtype Forward_Iterator is
Implementation.Trees.Tree_Iterator_Interfaces.Forward_Iterator;
subtype Cursor is Implementation.Trees.Cursor;
No_Element : Cursor renames Implementation.Trees.No_Element;
function "=" (Left : in Cursor;
Right : in Cursor) return Boolean
renames Implementation.Trees."=";
function Child_Count (Parent : in Cursor) return Ada.Containers.Count_Type
renames Implementation.Trees.Child_Count;
function Child_Depth (Parent : in Cursor;
Child : in Cursor) return Ada.Containers.Count_Type
renames Implementation.Trees.Child_Depth;
function Element (Position : in Cursor) return Entity.T'Class
renames Implementation.Trees.Element;
function First_Child (Position : in Cursor) return Cursor
renames Implementation.Trees.First_Child;
function Last_Child (Position : in Cursor) return Cursor
renames Implementation.Trees.Last_Child;
function Next_Sibling (Position : in Cursor) return Cursor
renames Implementation.Trees.Next_Sibling;
procedure Next_Sibling (Position : in out Cursor)
renames Implementation.Trees.Next_Sibling;
function Previous_Sibling (Position : in Cursor) return Cursor
renames Implementation.Trees.Previous_Sibling;
procedure Previous_Sibling (Position : in out Cursor)
renames Implementation.Trees.Previous_Sibling;
function Iterate_Subtree (Position : Cursor) return Forward_Iterator'Class
renames Implementation.Trees.Iterate_Subtree;
-- Sort a subtree by sorting criteria of elements contained.
generic
with function Before (Left : in Entity.T'Class;
Right : in Entity.T'Class) return Boolean;
package Generic_Sorting is
procedure Sort (Tree : in out T;
Parent : in Cursor);
end Generic_Sorting;
private
type T is new Implementation.Trees.Tree with null record;
end SPAT.Entity.Tree;
|
with
openGL.conversions;
package body openGL.Light.directional
is
procedure inverse_view_Transform_is (Self : in out Item; Now : in Matrix_3x3)
is
use linear_Algebra;
begin
Self.Direction := Now * Normalised (Self.Site);
Self.halfplane_Vector := Normalised ( Normalised (Self.Direction (1 .. 3))
+ (0.0, 0.0, 1.0));
end inverse_view_Transform_is;
procedure Color_is (Self : in out Item; Ambient,
Diffuse,
Specular : in light_Color)
is
use openGL.conversions;
begin
Self. ambient_Color := to_Vector_4 (Ambient);
Self. diffuse_Color := to_Vector_4 (Diffuse);
Self.specular_Color := to_Vector_4 (Specular);
end Color_is;
function ambient_Color (Self : in Item) return Vector_4
is
begin
return Self.ambient_Color;
end ambient_Color;
function diffuse_Color (Self : in Item) return Vector_4
is
begin
return Self.diffuse_Color;
end diffuse_Color;
function specular_Color (Self : in Item) return Vector_4
is
begin
return Self.specular_Color;
end specular_Color;
function Direction (Self : in Item) return Vector_3
is
begin
return Self.Direction;
end Direction;
function halfplane_Vector (Self : in Item) return Vector_3
is
begin
return Self.halfplane_Vector;
end halfplane_Vector;
end openGL.Light.directional;
|
with System;
with Interfaces.C.Extensions;
package Lv.Anim is
type Path_T is access function (Arg1 : System.Address) return Int32_T;
pragma Convention (C, Path_T);
type Fp_T is access procedure (Arg1 : System.Address; Arg2 : Int32_T);
pragma Convention (C, Fp_T);
type Cb_T is access procedure (Arg1 : System.Address);
pragma Convention (C, Cb_T);
type U_Lv_Anim_T is record
Var : System.Address;
Fp : Fp_T;
End_Cb : Cb_T;
Path : Path_T;
Start : aliased Int32_T;
C_End : aliased Int32_T;
Time : aliased Uint16_T;
Act_Time : aliased Int16_T;
Playback_Pause : aliased Uint16_T;
Repeat_Pause : aliased Uint16_T;
Playback : Extensions.Unsigned_1;
Repeat : Extensions.Unsigned_1;
Playback_Now : Extensions.Unsigned_1;
Has_Run : Extensions.Unsigned_1;
end record;
pragma Convention (C_Pass_By_Copy, U_Lv_Anim_T);
pragma Pack (U_Lv_Anim_T);
subtype Anim_T is U_Lv_Anim_T;
-- Init. the animation module
procedure Init;
-- Create an animation
-- @param p an initialized 'anim_t' variable. Not required after call.
procedure Create (A : access Anim_T);
-- Delete an animation for a variable with a given animatior function
-- @param var pointer to variable
-- @param fp a function pointer which is animating 'var',
-- or NULL to ignore it and delete all animation with 'var
-- @return true: at least 1 animation is deleted, false: no animation is deleted
function Del (Var : System.Address; Fp : Fp_T) return U_Bool;
-- Calculate the time of an animation with a given speed and the start and end values
-- @param speed speed of animation in unit/sec
-- @param start start value of the animation
-- @param end end value of the animation
-- @return the required time [ms] for the animation with the given parameters
function Speed_To_Time
(Speed : Uint16_T;
Start : Int32_T;
End_P : Int32_T) return Uint16_T;
-- Calculate the current value of an animation applying linear characteristic
-- @param a pointer to an animation
-- @return the current value to set
function Path_Linear (A : access constant Anim_T) return Int32_T;
-- Calculate the current value of an animation applying an "S" characteristic (cosine)
-- @param a pointer to an animation
-- @return the current value to set
function Path_Ease_In_Out
(A : access constant Anim_T) return Int32_T;
-- Calculate the current value of an animation applying step characteristic.
-- (Set end value on the end of the animation)
-- @param a pointer to an animation
-- @return the current value to set
function Path_Step (A : access constant Anim_T) return Int32_T;
-------------
-- Imports --
-------------
pragma Import (C, Init, "lv_anim_init");
pragma Import (C, Create, "lv_anim_create");
pragma Import (C, Del, "lv_anim_del");
pragma Import (C, Speed_To_Time, "lv_anim_speed_to_time");
pragma Import (C, Path_Linear, "lv_anim_path_linear");
pragma Import (C, Path_Ease_In_Out, "lv_anim_path_ease_in_out");
pragma Import (C, Path_Step, "lv_anim_path_step");
end Lv.Anim;
|
pragma License (Unrestricted);
-- extended unit
package Ada.Formatting is
-- Generic formatting functions more powerful than Ada.Text_IO.*_IO.
-- Also, the root type of Type_Set is declared in here.
pragma Pure;
type Form_Type is (Simple, Ada);
type Sign_Marks is array (-1 .. 1) of Character;
type Unsign_Marks is array (0 .. 1) of Character;
No_Sign : constant Character := Character'Val (16#ff#);
Plus_Sign_Marks : constant Sign_Marks := ('-', '+', '+');
Spacing_Sign_Marks : constant Sign_Marks := ('-', ' ', ' ');
Triming_Sign_Marks : constant Sign_Marks := ('-', '["ff"]', '["ff"]');
Spacing_Unsign_Marks : constant Unsign_Marks := (' ', ' ');
Triming_Unsign_Marks : constant Unsign_Marks := ('["ff"]', '["ff"]');
subtype Number_Base is Integer range 2 .. 16; -- same as Text_IO.Number_Base
type Type_Set is (Lower_Case, Upper_Case);
generic
type T is range <>;
Form : Form_Type := Ada;
Signs : Sign_Marks := Spacing_Sign_Marks;
Base : Number_Base := 10;
Set : Type_Set := Upper_Case;
Digits_Width : Positive := 1;
Digits_Fill : Character := '0';
function Integer_Image (Item : T) return String;
generic
type T is mod <>;
Form : Form_Type := Ada;
Signs : Unsign_Marks := Spacing_Unsign_Marks;
Base : Number_Base := 10;
Set : Type_Set := Upper_Case;
Digits_Width : Positive := 1;
Digits_Fill : Character := '0';
function Modular_Image (Item : T) return String;
generic
type T is digits <>;
Form : Form_Type := Ada;
Signs : Sign_Marks := Spacing_Sign_Marks;
Base : Number_Base := 10;
Set : Type_Set := Upper_Case;
Fore_Digits_Width : Positive := 1;
Fore_Digits_Fill : Character := '0';
Aft_Width : Positive := T'Digits - 1;
Exponent_Mark : Character := 'E';
Exponent_Signs : Sign_Marks := Plus_Sign_Marks;
Exponent_Digits_Width : Positive := 2;
Exponent_Digits_Fill : Character := '0';
NaN : String := "NAN";
Infinity : String := "INF";
function Float_Image (Item : T) return String;
generic
type T is delta <>;
Form : Form_Type := Ada;
Exponent : Boolean := False;
Signs : Sign_Marks := Spacing_Sign_Marks;
Base : Number_Base := 10;
Set : Type_Set := Upper_Case;
Fore_Digits_Width : Positive := 1;
Fore_Digits_Fill : Character := '0';
Aft_Width : Positive := T'Aft;
Exponent_Mark : Character := 'E';
Exponent_Signs : Sign_Marks := Plus_Sign_Marks;
Exponent_Digits_Width : Positive := 2;
Exponent_Digits_Fill : Character := '0';
function Fixed_Image (Item : T) return String;
generic
type T is delta <> digits <>;
Form : Form_Type := Ada;
pragma Unreferenced (Form); -- 10-based only
Exponent : Boolean := False;
Signs : Sign_Marks := Spacing_Sign_Marks;
Fore_Digits_Width : Positive := 1;
Fore_Digits_Fill : Character := '0';
Aft_Width : Positive := T'Aft;
Exponent_Mark : Character := 'E';
Exponent_Signs : Sign_Marks := Plus_Sign_Marks;
Exponent_Digits_Width : Positive := 2;
Exponent_Digits_Fill : Character := '0';
function Decimal_Image (Item : T) return String;
end Ada.Formatting;
|
-- Copyright (c) 2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- 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; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with System;
with Tcl.Variables;
package body Tk.Wm is
procedure Set_Aspect
(Window: Tk_Toplevel;
Min_Numer, Min_Denom, Max_Numer, Max_Denom: Natural) is
begin
Tcl_Eval
(Tcl_Script =>
"wm aspect " & Tk_Path_Name(Widgt => Window) &
Natural'Image(Min_Numer) & Natural'Image(Min_Denom) &
Natural'Image(Max_Numer) & Natural'Image(Max_Denom),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Aspect;
function Get_Aspect(Window: Tk_Toplevel) return Aspect_Data is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm aspect " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
if Result = Empty_Array_List then
return Empty_Aspect_Data;
end if;
return Result_Value: Aspect_Data := Empty_Aspect_Data do
Result_Value.Min_Numer :=
Natural'Value(To_Ada_String(Source => Result(1)));
Result_Value.Min_Denom :=
Natural'Value(To_Ada_String(Source => Result(2)));
Result_Value.Max_Numer :=
Natural'Value(To_Ada_String(Source => Result(3)));
Result_Value.Max_Denom :=
Natural'Value(To_Ada_String(Source => Result(4)));
end return;
end Get_Aspect;
function Get_Attributes(Window: Tk_Widget) return Window_Attributes_Data is
use Tcl.Variables;
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm attributes " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
Index: Positive := 1;
Window_Manager: constant Window_Manager_Types :=
(if
Tcl_Get_Var2
(Var_Name => "tcl_platform", Index_Name => "os",
Interpreter => Interpreter) =
"Windows"
then WINDOWS
elsif
Tcl_Get_Var2
(Var_Name => "tcl_platform", Index_Name => "os",
Interpreter => Interpreter) =
"Darwin"
then MACOSX
else X_11);
Window_Attributes: Window_Attributes_Data (Wm_Type => Window_Manager) :=
Empty_Window_Attributes;
function Get_Boolean(Array_Index: Positive) return Extended_Boolean is
begin
if To_Ada_String(Source => Result(Array_Index + 1)) = "1" then
return TRUE;
end if;
return FALSE;
end Get_Boolean;
begin
Read_Attributes_Loop :
while Index < Result'Last loop
if Result(Index) = "-alpha" then
Window_Attributes.Alpha :=
Alpha_Type'Value(To_Ada_String(Source => Result(Index + 1)));
elsif Result(Index) = "-fullscreen" then
Window_Attributes.Full_Screen := Get_Boolean(Array_Index => Index);
elsif Result(Index) = "-topmost" then
Window_Attributes.Topmost := Get_Boolean(Array_Index => Index);
elsif Result(Index) = "-type" and Window_Manager = X_11 then
if To_Ada_String(Source => Result(Index + 1)) = "" then
Window_Attributes.Window_Type := NONE;
else
Window_Attributes.Window_Type :=
Window_Types'Value
(To_Ada_String(Source => Result(Index + 1)));
end if;
elsif Result(Index) = "-zoomed" and Window_Manager = X_11 then
Window_Attributes.Zoomed := Get_Boolean(Array_Index => Index);
elsif Result(Index) = "-disabled" and Window_Manager = WINDOWS then
Window_Attributes.Disabled := Get_Boolean(Array_Index => Index);
elsif Result(Index) = "-toolwindow" and Window_Manager = WINDOWS then
Window_Attributes.Tool_Window := Get_Boolean(Array_Index => Index);
elsif Result(Index) = "-transparentcolor" and
Window_Manager = WINDOWS then
Window_Attributes.Transparent_Color := Result(Index + 1);
elsif Result(Index) = "-modified" and Window_Manager = MACOSX then
Window_Attributes.Modified := Get_Boolean(Array_Index => Index);
elsif Result(Index) = "-notify" and Window_Manager = MACOSX then
Window_Attributes.Notify := Get_Boolean(Array_Index => Index);
elsif Result(Index) = "-titlepath" and Window_Manager = MACOSX then
Window_Attributes.Title_Path := Result(Index + 1);
elsif Result(Index) = "-transparent" and Window_Manager = MACOSX then
Window_Attributes.Transparent := Get_Boolean(Array_Index => Index);
end if;
Index := Index + 2;
end loop Read_Attributes_Loop;
return Window_Attributes;
end Get_Attributes;
procedure Set_Attributes
(Window: Tk_Widget; Attributes_Data: Window_Attributes_Data) is
Values_List: Unbounded_String := Null_Unbounded_String;
procedure Set_Boolean
(Name: String; Value: Extended_Boolean;
List: in out Unbounded_String) is
begin
case Value is
when TRUE =>
Append(Source => List, New_Item => "-" & Name & " 1 ");
when FALSE =>
Append(Source => List, New_Item => "-" & Name & " 0 ");
when NONE =>
null;
end case;
end Set_Boolean;
begin
if Attributes_Data.Alpha >= 0.0 then
Append
(Source => Values_List,
New_Item =>
"-alpha" & Alpha_Type'Image(Attributes_Data.Alpha) & " ");
end if;
Set_Boolean
(Name => "fullscreen", Value => Attributes_Data.Full_Screen,
List => Values_List);
Set_Boolean
(Name => "topmost", Value => Attributes_Data.Topmost,
List => Values_List);
case Attributes_Data.Wm_Type is
when X_11 =>
if Attributes_Data.Window_Type /= NONE then
Append
(Source => Values_List,
New_Item =>
"-type " &
To_Lower
(Item =>
Window_Types'Image(Attributes_Data.Window_Type)) &
" ");
end if;
Set_Boolean
(Name => "zoomed", Value => Attributes_Data.Zoomed,
List => Values_List);
when WINDOWS =>
Set_Boolean
(Name => "disabled", Value => Attributes_Data.Disabled,
List => Values_List);
Set_Boolean
(Name => "toolwindow", Value => Attributes_Data.Tool_Window,
List => Values_List);
if To_Ada_String(Source => Attributes_Data.Transparent_Color)'
Length >
0 then
Append
(Source => Values_List,
New_Item =>
"-transparentcolor " &
To_Ada_String
(Source => Attributes_Data.Transparent_Color) &
" ");
end if;
when MACOSX =>
Set_Boolean
(Name => "modified", Value => Attributes_Data.Modified,
List => Values_List);
Set_Boolean
(Name => "notify", Value => Attributes_Data.Notify,
List => Values_List);
if To_Ada_String(Source => Attributes_Data.Title_Path)'Length >
0 then
Append
(Source => Values_List,
New_Item =>
"-titlepath " &
To_Ada_String(Source => Attributes_Data.Title_Path) & " ");
end if;
Set_Boolean
(Name => "transparent", Value => Attributes_Data.Transparent,
List => Values_List);
end case;
Tcl_Eval
(Tcl_Script =>
"wm attributes " & Tk_Path_Name(Widgt => Window) & " " &
To_String(Source => Values_List),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Attributes;
function Get_Attribute
(Window: Tk_Widget; Name: Window_Atrributes_Type)
return Extended_Boolean is
begin
if Tcl_Eval
(Tcl_Script =>
"wm attributes " & Tk_Path_Name(Widgt => Window) & " -" &
To_Lower(Window_Atrributes_Type'Image(Name)),
Interpreter => Tk_Interp(Widgt => Window))
.Result =
"1" then
return TRUE;
end if;
return FALSE;
end Get_Attribute;
function Get_Attribute(Window: Tk_Widget) return Alpha_Type is
Result: constant String :=
Tcl_Eval
(Tcl_Script =>
"wm attributes " & Tk_Path_Name(Widgt => Window) & " -alpha",
Interpreter => Tk_Interp(Widgt => Window))
.Result;
begin
if Result'Length = 0 then
return 1.0;
end if;
return Alpha_Type'Value(Result);
end Get_Attribute;
function Get_Attribute(Window: Tk_Widget) return Window_Types is
Result: constant String :=
Tcl_Eval
(Tcl_Script =>
"wm attributes " & Tk_Path_Name(Widgt => Window) & " -type",
Interpreter => Tk_Interp(Widgt => Window))
.Result;
begin
if Result'Length = 0 then
return NONE;
end if;
return Window_Types'Value(Result);
end Get_Attribute;
procedure Set_Client(Window: Tk_Widget; Name: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm client " & Tk_Path_Name(Widgt => Window) & " " &
To_String(Source => Name),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Client;
function Get_Color_Map_Windows(Window: Tk_Widget) return Array_List is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
begin
return
Split_List
(List =>
Tcl_Eval
(Tcl_Script =>
"wm colormapwindows " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
end Get_Color_Map_Windows;
procedure Set_Color_Map_Windows
(Window: Tk_Widget; Widgets: Widgets_Array) is
Windows_List: Unbounded_String := Null_Unbounded_String;
begin
Convert_List_To_String_Loop :
for Widgt of Widgets loop
Append
(Source => Windows_List,
New_Item => " " & Tk_Path_Name(Widgt => Widgt));
end loop Convert_List_To_String_Loop;
Tcl_Eval
(Tcl_Script =>
"wm colormapwindows " & Tk_Path_Name(Widgt => Window) & " {" &
To_String(Source => Windows_List) & "}",
Interpreter => Tk_Interp(Widgt => Window));
end Set_Color_Map_Windows;
procedure Set_Command(Window: Tk_Widget; Wm_Command: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm command " & Tk_Path_Name(Widgt => Window) & " " &
To_String(Source => Wm_Command),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Command;
procedure Deiconify(Window: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script => "wm deiconify " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window));
end Deiconify;
function Get_Focus_Model(Window: Tk_Widget) return Focus_Model_Types is
begin
if Tcl_Eval
(Tcl_Script => "wm focusmodel " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result =
"passive" then
return PASSIVE;
end if;
return ACTIVE;
end Get_Focus_Model;
procedure Set_Focus_Model(Window: Tk_Widget; Model: Focus_Model_Types) is
begin
Tcl_Eval
(Tcl_Script =>
"wm focusmodel " & Tk_Path_Name(Widgt => Window) & " " &
To_Lower(Item => Focus_Model_Types'Image(Model)),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Focus_Model;
procedure Forget(Window: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script => "wm forget " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window));
end Forget;
function Get_Frame(Window: Tk_Widget) return Tk_Window is
Result: constant String :=
Tcl_Eval
(Tcl_Script => "wm frame " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result;
begin
if Result'Length > 0 then
return
Tk_Window
(System'To_Address
(Integer'Value("16#" & Result(3 .. Result'Last) & "#")));
end if;
return Null_Window;
end Get_Frame;
function Get_Geometry(Window: Tk_Widget) return Window_Geometry is
Result: constant String :=
Tcl_Eval
(Tcl_Script => "wm geometry " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result;
Start_Index, End_Index: Positive := 1;
begin
return Win_Geometry: Window_Geometry := Empty_Window_Geometry do
End_Index := Index(Source => Result, Pattern => "x");
Win_Geometry.Width := Natural'Value(Result(1 .. End_Index - 1));
Start_Index := End_Index + 1;
--## rule off ASSIGNMENTS
End_Index :=
Index(Source => Result, Pattern => "+", From => Start_Index);
Win_Geometry.Height :=
Natural'Value(Result(Start_Index .. End_Index - 1));
Start_Index := End_Index + 1;
End_Index :=
Index(Source => Result, Pattern => "+", From => Start_Index);
Win_Geometry.X := Natural'Value(Result(Start_Index .. End_Index - 1));
Start_Index := End_Index + 1;
--## rule on ASSIGNMENTS
Win_Geometry.Y := Natural'Value(Result(Start_Index .. Result'Last));
end return;
end Get_Geometry;
procedure Set_Geometry
(Window: Tk_Widget; Width, Height: Positive; X, Y: Natural) is
begin
Tcl_Eval
(Tcl_Script =>
"wm geometry " & Tk_Path_Name(Widgt => Window) & " " & "=" &
Trim(Source => Positive'Image(Width), Side => Left) & "x" &
Trim(Source => Positive'Image(Height), Side => Left) & "+" &
Trim(Source => Natural'Image(X), Side => Left) & "+" &
Trim(Source => Natural'Image(Y), Side => Left),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Geometry;
procedure Set_Geometry(Window: Tk_Widget; Width, Height: Positive) is
begin
Tcl_Eval
(Tcl_Script =>
"wm geometry " & Tk_Path_Name(Widgt => Window) & " " & "=" &
Trim(Source => Positive'Image(Width), Side => Left) & "x" &
Trim(Source => Positive'Image(Height), Side => Left),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Geometry;
procedure Set_Geometry_Position(Window: Tk_Widget; X, Y: Natural) is
begin
Tcl_Eval
(Tcl_Script =>
"wm geometry " & Tk_Path_Name(Widgt => Window) & " " & "+" &
Trim(Source => Natural'Image(X), Side => Left) & "+" &
Trim(Source => Natural'Image(Y), Side => Left),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Geometry_Position;
function Get_Grid(Window: Tk_Widget) return Window_Grid_Geometry is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm grid " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
if Result'Length = 0 then
return Empty_Window_Grid_Geometry;
end if;
return Win_Grid: Window_Grid_Geometry := Empty_Window_Grid_Geometry do
Win_Grid.Base_Width :=
Natural'Value(To_Ada_String(Source => Result(1)));
Win_Grid.Base_Height :=
Natural'Value(To_Ada_String(Source => Result(2)));
Win_Grid.Width_Inc :=
Natural'Value(To_Ada_String(Source => Result(3)));
Win_Grid.Height_Inc :=
Natural'Value(To_Ada_String(Source => Result(4)));
end return;
end Get_Grid;
procedure Set_Grid
(Window: Tk_Widget;
Base_Width, Base_Height, Width_Inc, Height_Inc: Positive) is
begin
Tcl_Eval
(Tcl_Script =>
"wm grid " & Tk_Path_Name(Widgt => Window) &
Positive'Image(Base_Width) & Positive'Image(Base_Height) &
Positive'Image(Width_Inc) & Positive'Image(Height_Inc),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Grid;
procedure Set_Group(Window: Tk_Widget; Path_Name: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm group " & Tk_Path_Name(Widgt => Window) & " " &
To_Ada_String(Source => Path_Name),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Group;
procedure Set_Icon_Bitmap(Window: Tk_Widget; Bitmap: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm iconbitmap " & Tk_Path_Name(Widgt => Window) & " " &
To_Ada_String(Source => Bitmap),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Icon_Bitmap;
procedure Iconify(Window: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script => "wm iconify " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window));
end Iconify;
procedure Set_Icon_Mask(Window: Tk_Widget; Bitmap: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm iconmask " & Tk_Path_Name(Widgt => Window) & " " &
To_Ada_String(Source => Bitmap),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Icon_Mask;
procedure Set_Icon_Name(Window: Tk_Widget; New_Name: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm iconname " & Tk_Path_Name(Widgt => Window) & " " &
To_Ada_String(Source => New_Name),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Icon_Name;
procedure Set_Icon_Photo
(Window: Tk_Widget; Images: Array_List; Default: Boolean := False) is
begin
Tcl_Eval
(Tcl_Script =>
"wm iconphoto " & Tk_Path_Name(Widgt => Window) & " " &
(if Default then "-default " else "") & Merge_List(List => Images),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Icon_Photo;
function Get_Icon_Position(Window: Tk_Widget) return Point_Position is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script =>
"wm iconposition " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
if Result'Length = 0 then
return Empty_Point_Position;
end if;
return Icon_Pos: Point_Position := Empty_Point_Position do
Icon_Pos.X :=
Extended_Natural'Value(To_Ada_String(Source => Result(1)));
Icon_Pos.Y :=
Extended_Natural'Value(To_Ada_String(Source => Result(2)));
end return;
end Get_Icon_Position;
procedure Set_Icon_Position(Window: Tk_Widget; X, Y: Natural) is
begin
Tcl_Eval
(Tcl_Script =>
"wm iconposition " & Tk_Path_Name(Widgt => Window) &
Natural'Image(X) & Natural'Image(Y),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Icon_Position;
procedure Reset_Icon_Position(Window: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script =>
"wm iconposition " & Tk_Path_Name(Widgt => Window) & " {} {}",
Interpreter => Tk_Interp(Widgt => Window));
end Reset_Icon_Position;
function Get_Icon_Window(Window: Tk_Widget) return Tk_Toplevel is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Path_Name: constant String :=
Tcl_Eval
(Tcl_Script => "wm iconwindow " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result;
begin
if Path_Name'Length = 0 then
return Null_Widget;
end if;
return
Get_Widget
(Path_Name =>
Tcl_Eval
(Tcl_Script => "wm iconwindow " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
end Get_Icon_Window;
procedure Set_Icon_Window(Window, New_Icon_Window: Tk_Toplevel) is
begin
Tcl_Eval
(Tcl_Script =>
"wm iconwindow " & Tk_Path_Name(Widgt => Window) & " " &
Tk_Path_Name(Widgt => New_Icon_Window),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Icon_Window;
procedure Manage(Window: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script => "wm manage " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window));
end Manage;
function Get_Max_Size(Window: Tk_Widget) return Window_Size is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm maxsize " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
return Current_Size: Window_Size := Empty_Window_Size do
Current_Size.Width := Natural'Value(To_String(Source => Result(1)));
Current_Size.Height := Natural'Value(To_String(Source => Result(2)));
end return;
end Get_Max_Size;
procedure Set_Max_Size(Window: Tk_Widget; Width, Height: Positive) is
begin
Tcl_Eval
(Tcl_Script =>
"wm maxsize " & Tk_Path_Name(Widgt => Window) &
Positive'Image(Width) & Positive'Image(Height),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Max_Size;
function Get_Min_Size(Window: Tk_Widget) return Window_Size is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm minsize " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
return Current_Size: Window_Size := Empty_Window_Size do
Current_Size.Width := Natural'Value(To_String(Source => Result(1)));
Current_Size.Height := Natural'Value(To_String(Source => Result(2)));
end return;
end Get_Min_Size;
procedure Set_Min_Size(Window: Tk_Widget; Width, Height: Positive) is
begin
Tcl_Eval
(Tcl_Script =>
"wm minsize " & Tk_Path_Name(Widgt => Window) &
Positive'Image(Width) & Positive'Image(Height),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Min_Size;
procedure Set_Override_Redirect(Window: Tk_Widget; Override: Boolean) is
begin
Tcl_Eval
(Tcl_Script =>
"wm overrideredirect " & Tk_Path_Name(Widgt => Window) & " " &
(if Override then "1" else "0"),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Override_Redirect;
function Get_Position_From(Window: Tk_Widget) return Position_From_Value is
Result: constant String :=
Tcl_Eval
(Tcl_Script => "wm positionfrom " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result;
begin
if Result'Length = 0 then
return Default_Position_From;
end if;
return Position_From_Value'Value(Result);
end Get_Position_From;
procedure Set_Position_From
(Window: Tk_Widget; Who: Position_From_Value := Default_Position_From) is
begin
Tcl_Eval
(Tcl_Script =>
"wm positionfrom " & Tk_Path_Name(Widgt => Window) & " " &
To_Lower(Item => Position_From_Value'Image(Who)),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Position_From;
function Get_Protocols(Window: Tk_Widget) return Array_List is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
begin
return
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm protocol " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
end Get_Protocols;
procedure Set_Protocol
(Window: Tk_Widget; Name: String; New_Command: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm protocol " & Tk_Path_Name(Widgt => Window) & " " & Name & " " &
To_String(Source => New_Command),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Protocol;
function Get_Resizable(Window: Tk_Widget) return Resizable_Data is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm resizable " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
return Resizable_Result: Resizable_Data := Default_Resizable_Data do
Resizable_Result.Width := (if Result(1) = "0" then False else True);
Resizable_Result.Height := (if Result(2) = "0" then False else True);
end return;
end Get_Resizable;
procedure Set_Resizable(Window: Tk_Widget; Width, Height: Boolean) is
begin
Tcl_Eval
(Tcl_Script =>
"wm resizable " & Tk_Path_Name(Widgt => Window) & " " &
(if Width then "1" else "0") & " " & (if Height then "1" else "0"),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Resizable;
function Get_Size_From(Window: Tk_Widget) return Position_From_Value is
Result: constant String :=
Tcl_Eval
(Tcl_Script => "wm sizefrom " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result;
begin
if Result'Length = 0 then
return Default_Position_From;
end if;
return Position_From_Value'Value(Result);
end Get_Size_From;
procedure Set_Size_From
(Window: Tk_Widget; Who: Position_From_Value := Default_Position_From) is
begin
Tcl_Eval
(Tcl_Script =>
"wm sizefrom " & Tk_Path_Name(Widgt => Window) & " " &
To_Lower(Item => Position_From_Value'Image(Who)),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Size_From;
function Get_Stack_Order(Window: Tk_Widget) return Widgets_Array is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "wm stackorder " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
return
Widgets: Widgets_Array (Result'Range) := (others => Null_Widget) do
Set_Widgets_Array_Loop :
for I in Result'Range loop
Widgets(I) :=
Get_Widget
(Path_Name => To_String(Source => Result(I)),
Interpreter => Interpreter);
end loop Set_Widgets_Array_Loop;
end return;
end Get_Stack_Order;
function Get_State(Window: Tk_Widget) return Window_States is
Result: constant String :=
Tcl_Eval
(Tcl_Script => "wm state " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window))
.Result;
begin
if Result'Length = 0 then
return NORMAL;
end if;
return Window_States'Value(Result);
end Get_State;
procedure Set_State
(Window: Tk_Widget; New_State: Window_States := Default_Window_State) is
begin
Tcl_Eval
(Tcl_Script =>
"wm state " & Tk_Path_Name(Widgt => Window) & " " &
To_Lower(Item => Window_States'Image(New_State)),
Interpreter => Tk_Interp(Widgt => Window));
end Set_State;
procedure Set_Title(Window: Tk_Widget; New_Title: Tcl_String) is
begin
Tcl_Eval
(Tcl_Script =>
"wm title " & Tk_Path_Name(Widgt => Window) & " " &
To_String(Source => New_Title),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Title;
function Get_Transient(Window: Tk_Widget) return Tk_Widget is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Window);
Result: constant String :=
Tcl_Eval
(Tcl_Script => "wm transient " & Tk_Path_Name(Widgt => Window),
Interpreter => Interpreter)
.Result;
begin
if Result'Length = 0 then
return Null_Widget;
end if;
return Get_Widget(Path_Name => Result, Interpreter => Interpreter);
end Get_Transient;
procedure Set_Transient(Window, Master: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script =>
"wm transient " & Tk_Path_Name(Widgt => Window) & " " &
Tk_Path_Name(Widgt => Master),
Interpreter => Tk_Interp(Widgt => Window));
end Set_Transient;
procedure Withdraw(Window: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script => "wm withdraw " & Tk_Path_Name(Widgt => Window),
Interpreter => Tk_Interp(Widgt => Window));
end Withdraw;
end Tk.Wm;
|
with
any_Math.any_Computational;
package float_Math.Computational is new float_Math.any_Computational;
pragma Pure (float_Math.Computational);
|
with GNAT.Source_Info;
package Missing.AUnit.Assertions is
-- See https://github.com/AdaCore/aunit/issues/31
generic
type Element_T is (<>);
procedure Generic_Assert
(Actual, Expected : Element_T; Message : String;
Source : String := GNAT.Source_Info.File;
Line : Natural := GNAT.Source_Info.Line);
-- Specialized versions of Assert, they call the general version that
-- takes a Condition as a parameter
end Missing.AUnit.Assertions;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ runtime field restriction handling --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
package body Skill.Field_Restrictions is
The_Nonnull : aliased Nonnull_T;
function Nonnull return Base is
(The_Nonnull'Access);
The_Constant_Length_Pointer : aliased Constant_Length_Pointer_T;
function Constant_Length_Pointer return Base is
(The_Constant_Length_Pointer'Access);
end Skill.Field_Restrictions;
|
-- { dg-do compile }
package body Discr20 is
function Get (X : Wrapper) return Def is
begin
return X.It;
end Get;
end Discr20;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Generic_Array_Sort;
procedure Demo_Array_Sort is
function "+" (S : String) return Unbounded_String renames To_Unbounded_String;
type A_Composite is
record
Name : Unbounded_String;
Value : Unbounded_String;
end record;
function "<" (L, R : A_Composite) return Boolean is
begin
return L.Name < R.Name;
end "<";
procedure Put_Line (C : A_Composite) is
begin
Put_Line (To_String (C.Name) & " " & To_String (C.Value));
end Put_Line;
type An_Array is array (Natural range <>) of A_Composite;
procedure Sort is new Ada.Containers.Generic_Array_Sort (Natural, A_Composite, An_Array);
Data : An_Array := (1 => (Name => +"Joe", Value => +"5531"),
2 => (Name => +"Adam", Value => +"2341"),
3 => (Name => +"Bernie", Value => +"122"),
4 => (Name => +"Walter", Value => +"1234"),
5 => (Name => +"David", Value => +"19"));
begin
Sort (Data);
for I in Data'Range loop
Put_Line (Data (I));
end loop;
end Demo_Array_Sort;
|
--===========================================================================
--
-- This package is the interface to the demo package showing examples
-- for the SH1107 OLED controller
--
--===========================================================================
--
-- Copyright 2022 (C) Holger Rodriguez
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with SH1107;
package Demos is
type Demos_Available is (Black_Background_White_Arrow,
White_Background_With_Black_Rectangle_Full_Screen,
Black_Background_With_White_Rectangle_Full_Screen,
White_Background_4_Black_Corners,
Black_Background_4_White_Corners,
Black_Background_White_Geometry,
White_Background_Black_Geometry,
White_Diagonal_Line_On_Black,
Black_Diagonal_Line_On_White
);
type Demo_Array is array (Demos_Available) of Boolean;
All_Demos : Demo_Array
:= (Black_Background_White_Arrow => True,
White_Background_With_Black_Rectangle_Full_Screen => True,
Black_Background_With_White_Rectangle_Full_Screen => True,
White_Background_4_Black_Corners => True,
Black_Background_4_White_Corners => True,
Black_Background_White_Geometry => True,
White_Background_Black_Geometry => True,
White_Diagonal_Line_On_Black => True,
Black_Diagonal_Line_On_White => True);
procedure Show_Multiple_Demos (S : in out SH1107.SH1107_Screen;
O : SH1107.SH1107_Orientation;
DA : Demo_Array);
procedure Show_1_Demo (S : in out SH1107.SH1107_Screen;
O : SH1107.SH1107_Orientation;
Demo : Demos_Available);
end Demos;
|
with OpenAL.Buffer;
with OpenAL.Types;
package OpenAL.Context.Capture is
--
-- API
--
type Buffer_Size_t is range 2 .. 65536;
-- proc_map : alcCaptureOpenDevice
function Open_Device
(Name : in String;
Frequency : in Types.Frequency_t;
Format : in OpenAL.Context.Request_Format_t;
Buffer_Size : in Buffer_Size_t) return Device_t;
-- proc_map : alcCaptureOpenDevice
function Open_Default_Device
(Frequency : in Types.Frequency_t;
Format : in OpenAL.Context.Request_Format_t;
Buffer_Size : in Buffer_Size_t) return Device_t;
-- proc_map : alcCaptureCloseDevice
procedure Close_Device (Device : in out Device_t);
-- proc_map : alcCaptureStart
procedure Start (Device : in Device_t);
-- proc_map : alcCaptureStop
procedure Stop (Device : in Device_t);
-- proc_map : alcCaptureSamples
procedure Samples_Mono_8
(Device : in Device_t;
Samples : out OpenAL.Buffer.Sample_Array_8_t);
-- proc_map : alcCaptureSamples
procedure Samples_Stereo_8
(Device : in Device_t;
Samples : out OpenAL.Buffer.Sample_Array_8_t);
-- proc_map : alcCaptureSamples
procedure Samples_Mono_16
(Device : in Device_t;
Samples : out OpenAL.Buffer.Sample_Array_16_t);
-- proc_map : alcCaptureSamples
procedure Samples_Stereo_16
(Device : in Device_t;
Samples : out OpenAL.Buffer.Sample_Array_16_t);
end OpenAL.Context.Capture;
|
package Modular3_Pkg is
type Int16_T is range -32768 .. 32767;
for Int16_T'Size use 16;
for Int16_T'Alignment use 1;
type Mod16_T is mod 2 ** 16;
for Mod16_T'Size use 16;
for Mod16_T'Alignment use 1;
end Modular3_Pkg;
|
-----------------------------------------------------------------------
-- AWA.Jobs.Models -- AWA.Jobs.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off, "unit * is not referenced");
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Objects.Enums;
with Util.Beans.Basic.Lists;
with AWA.Events.Models;
with AWA.Users.Models;
pragma Warnings (On, "unit * is not referenced");
package AWA.Jobs.Models is
type Job_Status_Type is (SCHEDULED, RUNNING, CANCELED, FAILED, TERMINATED);
for Job_Status_Type use (SCHEDULED => 0, RUNNING => 1, CANCELED => 2, FAILED => 3, TERMINATED => 4);
package Job_Status_Type_Objects is
new Util.Beans.Objects.Enums (Job_Status_Type);
type Job_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- The job is associated with a dispatching queue.
-- --------------------
-- Create an object key for Job.
function Job_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Job from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Job_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Job : constant Job_Ref;
function "=" (Left, Right : Job_Ref'Class) return Boolean;
-- Set the job identifier
procedure Set_Id (Object : in out Job_Ref;
Value : in ADO.Identifier);
-- Get the job identifier
function Get_Id (Object : in Job_Ref)
return ADO.Identifier;
-- Set the job status
procedure Set_Status (Object : in out Job_Ref;
Value : in AWA.Jobs.Models.Job_Status_Type);
-- Get the job status
function Get_Status (Object : in Job_Ref)
return AWA.Jobs.Models.Job_Status_Type;
-- Set the job name
procedure Set_Name (Object : in out Job_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Job_Ref;
Value : in String);
-- Get the job name
function Get_Name (Object : in Job_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Job_Ref)
return String;
-- Set the job start date
procedure Set_Start_Date (Object : in out Job_Ref;
Value : in ADO.Nullable_Time);
-- Get the job start date
function Get_Start_Date (Object : in Job_Ref)
return ADO.Nullable_Time;
-- Set the job creation date
procedure Set_Create_Date (Object : in out Job_Ref;
Value : in Ada.Calendar.Time);
-- Get the job creation date
function Get_Create_Date (Object : in Job_Ref)
return Ada.Calendar.Time;
-- Set the job finish date
procedure Set_Finish_Date (Object : in out Job_Ref;
Value : in ADO.Nullable_Time);
-- Get the job finish date
function Get_Finish_Date (Object : in Job_Ref)
return ADO.Nullable_Time;
-- Set the job progress indicator
procedure Set_Progress (Object : in out Job_Ref;
Value : in Integer);
-- Get the job progress indicator
function Get_Progress (Object : in Job_Ref)
return Integer;
-- Set the job parameters
procedure Set_Parameters (Object : in out Job_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Parameters (Object : in out Job_Ref;
Value : in String);
-- Get the job parameters
function Get_Parameters (Object : in Job_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Parameters (Object : in Job_Ref)
return String;
-- Set the job result
procedure Set_Results (Object : in out Job_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Results (Object : in out Job_Ref;
Value : in String);
-- Get the job result
function Get_Results (Object : in Job_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Results (Object : in Job_Ref)
return String;
--
function Get_Version (Object : in Job_Ref)
return Integer;
-- Set the job priority
procedure Set_Priority (Object : in out Job_Ref;
Value : in Integer);
-- Get the job priority
function Get_Priority (Object : in Job_Ref)
return Integer;
--
procedure Set_User (Object : in out Job_Ref;
Value : in AWA.Users.Models.User_Ref'Class);
--
function Get_User (Object : in Job_Ref)
return AWA.Users.Models.User_Ref'Class;
--
procedure Set_Event (Object : in out Job_Ref;
Value : in AWA.Events.Models.Message_Ref'Class);
--
function Get_Event (Object : in Job_Ref)
return AWA.Events.Models.Message_Ref'Class;
--
procedure Set_Session (Object : in out Job_Ref;
Value : in AWA.Users.Models.Session_Ref'Class);
--
function Get_Session (Object : in Job_Ref)
return AWA.Users.Models.Session_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Job_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Job_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Job_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Job_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Job_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Job_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
JOB_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Job_Ref);
-- Copy of the object.
procedure Copy (Object : in Job_Ref;
Into : in out Job_Ref);
private
JOB_NAME : aliased constant String := "awa_job";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "status";
COL_2_1_NAME : aliased constant String := "name";
COL_3_1_NAME : aliased constant String := "start_date";
COL_4_1_NAME : aliased constant String := "create_date";
COL_5_1_NAME : aliased constant String := "finish_date";
COL_6_1_NAME : aliased constant String := "progress";
COL_7_1_NAME : aliased constant String := "parameters";
COL_8_1_NAME : aliased constant String := "results";
COL_9_1_NAME : aliased constant String := "version";
COL_10_1_NAME : aliased constant String := "priority";
COL_11_1_NAME : aliased constant String := "user_id";
COL_12_1_NAME : aliased constant String := "event_id";
COL_13_1_NAME : aliased constant String := "session_id";
JOB_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 14,
Table => JOB_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access,
7 => COL_6_1_NAME'Access,
8 => COL_7_1_NAME'Access,
9 => COL_8_1_NAME'Access,
10 => COL_9_1_NAME'Access,
11 => COL_10_1_NAME'Access,
12 => COL_11_1_NAME'Access,
13 => COL_12_1_NAME'Access,
14 => COL_13_1_NAME'Access
)
);
JOB_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= JOB_DEF'Access;
Null_Job : constant Job_Ref
:= Job_Ref'(ADO.Objects.Object_Ref with others => <>);
type Job_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => JOB_DEF'Access)
with record
Status : AWA.Jobs.Models.Job_Status_Type;
Name : Ada.Strings.Unbounded.Unbounded_String;
Start_Date : ADO.Nullable_Time;
Create_Date : Ada.Calendar.Time;
Finish_Date : ADO.Nullable_Time;
Progress : Integer;
Parameters : Ada.Strings.Unbounded.Unbounded_String;
Results : Ada.Strings.Unbounded.Unbounded_String;
Version : Integer;
Priority : Integer;
User : AWA.Users.Models.User_Ref;
Event : AWA.Events.Models.Message_Ref;
Session : AWA.Users.Models.Session_Ref;
end record;
type Job_Access is access all Job_Impl;
overriding
procedure Destroy (Object : access Job_Impl);
overriding
procedure Find (Object : in out Job_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Job_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Job_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Job_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Job_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Job_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Job_Ref'Class;
Impl : out Job_Access);
end AWA.Jobs.Models;
|
package body agar.gui.widget.label is
package cbinds is
function allocate_polled
(parent : widget_access_t;
flags : flags_t;
fmt : cs.chars_ptr;
text : cs.chars_ptr) return label_access_t;
pragma import (c, allocate_polled, "AG_LabelNewPolled");
function allocate_polled_mutex
(parent : widget_access_t;
flags : flags_t;
mutex : agar.core.threads.mutex_t;
fmt : cs.chars_ptr;
text : cs.chars_ptr) return label_access_t;
pragma import (c, allocate_polled_mutex, "AG_LabelNewPolledMT");
procedure set_padding
(label : label_access_t;
left : c.int;
right : c.int;
top : c.int;
bottom : c.int);
pragma import (c, set_padding, "AG_LabelSetPadding");
procedure size_hint
(label : label_access_t;
num_lines : c.unsigned;
text : cs.chars_ptr);
pragma import (c, size_hint, "AG_LabelSizeHint");
procedure text
(label : label_access_t;
text : cs.chars_ptr);
pragma import (c, text, "AG_LabelTextS");
procedure flag
(label : label_access_t;
index : c.unsigned;
desc : cs.chars_ptr;
mask : mask_t);
pragma import (c, flag, "agar_gui_widget_label_flag");
procedure flag8
(label : label_access_t;
index : c.unsigned;
desc : cs.chars_ptr;
mask : agar.core.types.uint8_t);
pragma import (c, flag8, "agar_gui_widget_label_flag8");
procedure flag16
(label : label_access_t;
index : c.unsigned;
desc : cs.chars_ptr;
mask : agar.core.types.uint16_t);
pragma import (c, flag16, "agar_gui_widget_label_flag16");
procedure flag32
(label : label_access_t;
index : c.unsigned;
desc : cs.chars_ptr;
mask : agar.core.types.uint32_t);
pragma import (c, flag32, "agar_gui_widget_label_flag32");
end cbinds;
function allocate_polled
(parent : widget_access_t;
flags : flags_t;
text : string) return label_access_t
is
ca_text : aliased c.char_array := c.to_c (text);
ca_fmt : aliased c.char_array := c.to_c ("%s");
begin
return cbinds.allocate_polled
(parent => parent,
flags => flags,
fmt => cs.to_chars_ptr (ca_fmt'unchecked_access),
text => cs.to_chars_ptr (ca_text'unchecked_access));
end allocate_polled;
function allocate_polled_mutex
(parent : widget_access_t;
flags : flags_t;
mutex : agar.core.threads.mutex_t;
text : string) return label_access_t
is
ca_text : aliased c.char_array := c.to_c (text);
ca_fmt : aliased c.char_array := c.to_c ("%s");
begin
return cbinds.allocate_polled_mutex
(parent => parent,
flags => flags,
mutex => mutex,
fmt => cs.to_chars_ptr (ca_fmt'unchecked_access),
text => cs.to_chars_ptr (ca_text'unchecked_access));
end allocate_polled_mutex;
procedure set_padding
(label : label_access_t;
left : natural;
right : natural;
top : natural;
bottom : natural) is
begin
cbinds.set_padding
(label => label,
left => c.int (left),
right => c.int (right),
top => c.int (top),
bottom => c.int (bottom));
end set_padding;
procedure size_hint
(label : label_access_t;
num_lines : natural;
text : string)
is
ca_text : aliased c.char_array := c.to_c (text);
begin
cbinds.size_hint
(label => label,
num_lines => c.unsigned (num_lines),
text => cs.to_chars_ptr (ca_text'unchecked_access));
end size_hint;
-- static labels
procedure text
(label : label_access_t;
text : string)
is
ca_text : aliased c.char_array := c.to_c (text);
begin
cbinds.text (label, cs.to_chars_ptr (ca_text'unchecked_access));
end text;
-- flag descriptions
procedure flag
(label : label_access_t;
index : natural;
desc : string;
mask : mask_t)
is
ca_desc : aliased c.char_array := c.to_c (desc);
begin
cbinds.flag
(label => label,
index => c.unsigned (index),
desc => cs.to_chars_ptr (ca_desc'unchecked_access),
mask => mask);
end flag;
procedure flag8
(label : label_access_t;
index : natural;
desc : string;
mask : agar.core.types.uint8_t)
is
ca_desc : aliased c.char_array := c.to_c (desc);
begin
cbinds.flag8
(label => label,
index => c.unsigned (index),
desc => cs.to_chars_ptr (ca_desc'unchecked_access),
mask => mask);
end flag8;
procedure flag16
(label : label_access_t;
index : natural;
desc : string;
mask : agar.core.types.uint16_t)
is
ca_desc : aliased c.char_array := c.to_c (desc);
begin
cbinds.flag16
(label => label,
index => c.unsigned (index),
desc => cs.to_chars_ptr (ca_desc'unchecked_access),
mask => mask);
end flag16;
procedure flag32
(label : label_access_t;
index : natural;
desc : string;
mask : agar.core.types.uint32_t)
is
ca_desc : aliased c.char_array := c.to_c (desc);
begin
cbinds.flag32
(label => label,
index => c.unsigned (index),
desc => cs.to_chars_ptr (ca_desc'unchecked_access),
mask => mask);
end flag32;
function widget (label : label_access_t) return widget_access_t is
begin
return label.widget'access;
end widget;
end agar.gui.widget.label;
|
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
with Ada.Directories;
package body Dot is
------------
-- EXPORTED
------------
function To_ID_Type (Item : in Wide_String) return ID_Type is
begin
return To_ID_Type (Ada.Characters.Handling.To_String(Item));
end To_ID_Type;
-- NOT TASK SAFE:
Is_Digraph : Boolean := True;
package body Stmt is
------------
-- EXPORTED
------------
procedure Put
(These : in List_Of_Access_All_Class;
File : in ATI.File_Type)
is
First_Item : Boolean := True;
begin
Indented.Indent;
for Item of These loop
if First_Item Then
First_Item := False;
else
Indented.Put (File, ";");
end if;
Indented.End_Line_If_Needed (File);
Item.Put (File);
end loop;
Indented.Dedent;
end Put;
end Stmt;
package body Assign is
------------
-- EXPORTED
------------
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
Put (This.L, File);
Indented.Put (File, "=");
Put (This.R, File);
end Put;
------------
-- EXPORTED
------------
procedure Put
(These : in List_Of_Class;
File : in ATI.File_Type)
is
First_Item : Boolean := True;
begin
Indented.Indent;
for Item of These loop
if First_Item Then
First_Item := False;
else
Indented.Put (File, ",");
end if;
Indented.End_Line_If_Needed (File);
Item.Put (File);
end loop;
Indented.Dedent;
end Put;
------------
-- EXPORTED
------------
procedure Append
(These : in out List_Of_Class;
L, R : in String) is
begin
These.Append
((L => To_ID_Type (L),
R => To_ID_Type (R)));
end Append;
------------unction Empty_List return List_Of_Class
-- EXPORTED
------------
function Empty_List return List_Of_Class is
begin
return List_Of_Class'(Lists.Empty_List with null record);
end Empty_List;
end Assign;
package body Attr is
------------
-- EXPORTED
------------
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
Indented.Indent;
Indented.Put (File, "[");
This.A_List.Put (File);
Indented.Put (File, " ]");
Indented.Dedent;
end Put;
------------
-- EXPORTED
------------
procedure Put
(These : in List_Of_Class;
File : in ATI.File_Type)
is
begin
Indented.Indent;
for Item of These loop
Indented.End_Line_If_Needed (File);
Item.Put (File);
end loop;
Indented.Dedent;
end Put;
------------
-- EXPORTED
------------
procedure Add_Assign_To_First_Attr
(Attr_List : in out List_Of_Class;
Name : in String;
Value : in String)
is
procedure Add_Assign (Attr : in out Dot.Attr.Class) is
begin
Attr.A_List.Append (Name, Value);
end Add_Assign;
begin
if Attr_List.Is_Empty then
Attr_List.Append (Dot.Attr.Null_Class);
end if;
Attr_List.Update_Element
(Position => Dot.Attr.First(Attr_List),
Process => Add_Assign'Access);
end Add_Assign_To_First_Attr;
end Attr;
package body Attr_Stmt is
------------
-- EXPORTED
------------
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
case This.Kind is
when Graph =>
Indented.Put (File, "graph");
when Node =>
Indented.Put (File, "node");
when Edge =>
Indented.Put (File, "edge");
end case;
This.Attr_List.Put (File);
end Put;
------------
-- EXPORTED
------------
procedure Append_To
(This : in Class;
Stmt_List : in out Stmt.List_Of_Access_All_Class) is
begin
Stmt_List.Append (new Class'(This));
end Append_To;
end Attr_Stmt;
package body Node_ID is
------------
-- EXPORTED
------------
procedure Put
(This : in Port_Class;
File : in ATI.File_Type) is
begin
if This.Has_ID then
Indented.Put (File, ":");
Put (This.ID, File);
end if;
if This.Has_Compass_Pt then
Indented.Put (File, ":");
Indented.Put (File, To_String (This.Compass_Pt));
end if;
end Put;
------------
-- EXPORTED
------------
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
Put (This.ID, File);
This.Port.Put (File);
end Put;
end Node_ID;
package body Node_Stmt is
------------
-- EXPORTED:
------------
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
This.Node_Id.Put (File);
This.Attr_List.Put (File);
end Put;
------------
-- EXPORTED:
------------
procedure Append_To
(This : in Class;
Stmt_List : in out Stmt.List_Of_Access_All_Class) is
begin
Stmt_List.Append (new Class'(This));
end Append_To;
------------
-- EXPORTED:
------------
procedure Add_Label
(This : in out Class;
HL_Label : HTML_Like_Labels.Class) is
begin
This.Attr_List.Add_Assign_To_First_Attr ("label", HL_Label.To_String);
end Add_Label;
end Node_Stmt;
package body HTML_Like_Labels is
NL : constant String := (1 => ASCII.LF);
------------
-- EXPORTED:
------------
procedure Add_Eq_Row
(This : in out Class;
L, R : in String) is
begin
This.Rows.Append
((1 => To_Unbounded_String (L),
2 => To_Unbounded_String (R)));
end Add_Eq_Row;
------------
-- EXPORTED:c
------------
procedure Add_3_Col_Cell
(This : in out Class;
Text : in String) is
begin
-- To_Image omits the "=" when it sees this pattern:
This.Rows.Append
((1 => To_Unbounded_String (""),
2 => To_Unbounded_String (Text)));
end Add_3_Col_Cell;
function To_Left_TD
(LR : in Unbounded_String)
return Unbounded_String is
begin
return "<TD ALIGN=""LEFT"">" & LR & "</TD>";
end To_Left_TD;
function To_Center_TD
(LR : in String)
return Unbounded_String is
begin
return "<TD>" & To_Unbounded_String (LR) & "</TD>";
end To_Center_TD;
function To_Center_3_TD
(LR : in Unbounded_String)
return Unbounded_String is
begin
return "<TD COLSPAN=""3"">" & LR & "</TD>";
end To_Center_3_TD;
function To_Center_3_TD
(LR : in String)
return Unbounded_String is
begin
return To_Center_3_TD (To_Unbounded_String (LR));
end To_Center_3_TD;
function To_TR (This : in LR_Pair) return Unbounded_String is
-- In some dot file viewers, e.g. zgrviewer, the longest content
-- in a left cell overlaps the center cell. The extra spaces below
-- attempt to address this:
function Pad (Item : in Unbounded_String) return Unbounded_String is
begin
return Item & (1 .. (Length (Item) / 4) + 1=> ' ');
end Pad;
begin
if This (1) = "" then
return " <TR>" &
To_Center_3_TD (This (2)) & "</TR>" & NL;
else
return " <TR>" &
To_Left_TD (Pad (This (1))) & To_Center_TD (" = ") &
To_Left_TD (This (2)) & "</TR>" & NL;
end if;
end To_TR;
function To_Unbounded_String (This : in Class) return Unbounded_String is
begin
return
"<<TABLE BORDER=""0"" CELLBORDER=""0"" CELLSPACING=""0"" CELLPADDING=""0""> " & NL &
To_Unbounded_String (This.Rows) &
" </TABLE>>";
end To_Unbounded_String;
------------
-- EXPORTED:
------------
function To_String (This : in Class) return String is begin
return To_String (To_Unbounded_String (This));
end To_String;
------------
-- EXPORTED:
------------
function To_Unbounded_String (This : in LR_Pair_List) return Unbounded_String is
Result : Unbounded_String; -- Initialized
begin
for Pair of This loop
Result := Result & To_TR (Pair);
end loop;
return Result;
end To_Unbounded_String;
end HTML_Like_Labels;
package body Subgraphs is
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
if Length (This.ID) > 0 then
Indented.Put (File, "subgraph ");
Put (This.ID, File);
end if;
This.Stmt_List.Put (File);
end Put;
end Subgraphs;
package body Edges is
procedure Put_Edgeop
(File : in ATI.File_Type) is
begin
if Is_Digraph then
Indented.Put (File, " -> ");
else
Indented.Put (File, " -- ");
end if;
end Put_Edgeop;
------------
-- EXPORTED
------------
package body Terminals is
------------
-- EXPORTED
------------
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
case This.Kind is
when Node_Kind =>
This.Node_Id.Put (File);
when Subgraph_Kind =>
This.Subgraph.Put (File);
end case;
end Put;
------------
-- EXPORTED
------------
procedure Put
(These : in List_Of_Class;
File : in ATI.File_Type) is
begin
for This of These loop
Put_Edgeop (File);
-- Why doesn't this compile?
-- This.Put (File);
Put(This, File);
end loop;
end Put;
end Terminals;
------------
-- EXPORTED
------------
package body Stmts is
------------
-- EXPORTED
------------
procedure Put
(This : in Class;
File : in ATI.File_Type) is
begin
Terminals.Put (This.LHS, File);
Put_Edgeop (File);
Terminals.Put (This.RHS, File);
This.RHSs.Put (File);
This.Attr_List.Put (File);
end Put;
------------
-- EXPORTED
------------
procedure Append_To
(This : in Class;
Stmt_List : in out Stmt.List_Of_Access_All_Class) is
begin
Stmt_List.Append (new Class'(This));
end Append_To;
end Stmts;
end Edges;
package body Graphs is
------------
-- EXPORTED
------------
function Create
(Is_Digraph : in Boolean;
Is_Strict : in Boolean)
return Access_Class
is
Result : Access_Class;
begin
Result := new Dot.Graphs.Class;
Result.Set_Is_Digraph (Is_Digraph);
Result.Set_Is_Strict (Is_Strict);
return Result;
end Create;
------------
-- EXPORTED
------------
procedure Set_Is_Digraph
(This : access Class;
To : in Boolean) is
begin
This.Digraph := To;
end;
------------
-- EXPORTED
------------
procedure Set_Is_Strict
(This : access Class;
To : in Boolean) is
begin
This.Strict := To;
end;
------------
-- EXPORTED
------------
procedure Set_ID
(This : access Class;
To : in String) is
begin
This.ID := To_ID_Type (To);
end;
------------
-- EXPORTED
------------
procedure Append_Stmt
(This : access Class;
The_Stmt : in Stmt.Access_All_Class) is
begin
This.Stmt_List.Append (The_Stmt);
end;
------------
-- EXPORTED
------------
function Stmt_Count
(This : access Class)
return Natural is
begin
return Natural (This.Stmt_List.Length);
end;
------------
-- EXPORTED
------------
procedure Put
(This : access Class;
File : in ATI.File_Type) is
package AD renames Ada.Directories;
Full_File_Name : constant String := AD.Full_Name (To_String(This.ID));
-- Result has double quotes:
Simple_File_Name : aliased String := '"' & AD.Simple_Name (Full_File_Name);
begin
if This.Strict then
Indented.Put (File, "strict ");
end if;
if This.Digraph then
Indented.Put (File, "digraph ");
Is_Digraph := True;
else
Indented.Put (File, "graph ");
Is_Digraph := False;
end if;
Indented.Put_Spaced (File, Simple_File_Name);
Indented.Put (File, "{");
This.Stmt_List.Put (File);
Indented.New_Line (File);
Indented.Put (File, "}");
end Put;
------------
-- EXPORTED
------------
procedure Write_File
(This : access Class;
Name : in String;
Overwrite : in Boolean := False)
is
Output_File : ATI.File_Type;
procedure Log (Message : in String) is
begin
ATI.Put_Line ("Dot.Graphs.Write_File: " & Message);
end;
procedure Create is
File_Name : constant String := Name & ".dot";
begin
-- if Overwrite then
-- -- Delete the file if it already exists:
-- begin
-- ATI.Open (File => Output_File,
-- Mode => ATI.In_File,
-- Name => File_Name);
-- -- Only if there is such a file:
-- ATI.Delete (Output_File);
-- exception
-- when ATI.Name_Error =>
-- ATI.Put_Line ("Got Name_Error trying to open """ & File_Name & """");
-- null;
-- end;
-- end if;
begin
Log ("Creating """ & File_Name & """");
ATI.Create (File => Output_File,
Mode => ATI.Out_File,
Name => File_Name);
exception
when ATI.Use_Error =>
raise Usage_Error with
"Could not create file """ & File_Name & """.";
end;
end Create;
begin
Create;
This.Put (Output_File);
ATI.Close (Output_File);
end Write_File;
end Graphs;
-----------
-- PRIVATE:
-----------
package body Indented is
Indent_Size : constant Natural := 2;
Indent_Level : Natural := 0;
function Current_Indent_Col return ATI.Positive_Count is
(ATI.Positive_Count((Indent_Level * Indent_Size) + 1));
-----------
-- PRIVATE:
-----------
procedure Put_Indent (File : in ATI.File_Type) is
use type ATI.Positive_Count;
begin
if ATI.Col (File) < Current_Indent_Col then
ATI.Set_Col (File, Current_Indent_Col);
end if;
end Put_Indent;
------------
-- EXPORTED
------------
procedure Indent is
begin
Indent_Level := Indent_Level + 1;
end Indent;
------------
-- EXPORTED
------------
procedure Dedent is
begin
Indent_Level := Indent_Level - 1;
end Dedent;
------------
-- EXPORTED
------------
procedure Put
(File : in ATI.File_Type;
Item : in String) is
begin
Put_Indent (File);
ATI.Put (File, Item);
end Put;
------------
-- EXPORTED
------------
procedure New_Line (File : in ATI.File_Type) is
begin
ATI.New_Line (File);
end New_Line;
------------
-- EXPORTED
------------
procedure End_Line_If_Needed (File : in ATI.File_Type) is
use type ATI.Positive_Count;
begin
if ATI.Col (File) > Current_Indent_Col then
New_Line (File);
end if;
end End_Line_If_Needed;
------------
-- EXPORTED
------------
procedure Put_Spaced
(File : in ATI.File_Type;
Item : in String) is
begin
if Item'Length > 0 then
Put (File, Item & " ");
end if;
end Put_Spaced;
end Indented;
function Case_Insensitive_Equals (L, R : in String)
return Boolean is
begin
-- Prevents recursion in case this function is named "=":
return Standard."=" (Ada.Characters.Handling.To_Lower (L),
Ada.Characters.Handling.To_Lower (R));
end Case_Insensitive_Equals;
function Is_Reserved_Word (Item : in String)
return boolean is
function "=" (L, R : in String)
return Boolean
renames Case_Insensitive_Equals;
begin
return
Item = "node" or else
Item = "edge" or else
Item = "graph" or else
Item = "digraph" or else
Item = "subgraph" or else
Item = "strict";
end Is_Reserved_Word;
function Contains_Space (Item : in String)
return boolean is
begin
return Ada.Strings.Fixed.Index (Item, " ") > 0;
end Contains_Space;
function Is_Html_Like (Item : in String)
return boolean is
begin
return Item (Item'First) = '<';
end Is_Html_Like;
------------
-- PRIVATE:
------------
function To_String (Item : in ID_Type)
return String is
Item_String : constant String :=
ASU.To_String (ASU.Unbounded_String(Item));
function Quoted_Item_String return String is
begin
return '"' & Item_String & '"';
end Quoted_Item_String;
begin
if Item_String'Length = 0 then
return """""";
elsif Is_Reserved_Word (Item_String) then
return Quoted_Item_String;
elsif Is_Html_Like (Item_String) then
return Item_String;
elsif Contains_Space (Item_String) then
return Quoted_Item_String;
else
return Item_String;
end if;
end To_String;
------------
-- PRIVATE:
------------
function To_String (Item : in Compass_Pt_Type)
return String is
begin
case Item is
when Underscore =>
return "_";
when others =>
return Item'Image;
end case;
end To_String;
------------
-- PRIVATE:
------------
procedure Put
(This : in ID_Type;
File : in ATI.File_Type) is
begin
Indented.Put (File, To_String(This));
end Put;
end Dot;
|
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Ada.Containers.Ordered_Maps;
package body Config_Tables is
-- use Configs;
package Config_Maps is
new Ada.Containers.Ordered_Maps
("<" => Configs."<",
"=" => Configs."=",
Key_Type => Configs.Config_Access,
Element_Type => Configs.Config_Access);
Table : Config_Maps.Map := Config_Maps.Empty_Map;
procedure Init is
begin
null; -- Table.Capacity (64);
end Init;
procedure Insert (Config : in Configs.Config_Access)
is
begin
Table.Insert (Config, Config);
end Insert;
function Find (Config : in Configs.Config_Access)
return Configs.Config_Access
is
use Config_Maps;
Pos : constant Cursor := Table.Find (Config);
begin
return (if Pos = No_Element then null else Element (Pos));
end Find;
procedure Clear
is
begin
Table.Clear;
end Clear;
end Config_Tables;
|
with Ada.Text_IO;
procedure Hello is
package IO renames Ada.Text_IO;
digit: Integer := 4;
begin
if digit > 3 or else digit = 3 then
if digit < 5 then
IO.Put_Line("Hello, world!");
end if;
elsif digit < 2 then
IO.Put_Line("Hello, world!");
else
IO.Put_Line("Hello, world!");
end if;
end Hello;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ S E L --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, 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 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Routines used in Chapter 9 for the expansion of dispatching triggers in
-- select statements (Ada 2005: AI-345)
with Types; use Types;
package Exp_Sel is
function Build_Abort_Block
(Loc : Source_Ptr;
Abr_Blk_Ent : Entity_Id;
Cln_Blk_Ent : Entity_Id;
Blk : Node_Id) return Node_Id;
-- Generate:
-- begin
-- Blk
-- exception
-- when Abort_Signal => Abort_Undefer;
-- end;
-- Abr_Blk_Ent is the name of the generated block, Cln_Blk_Ent is the name
-- of the encapsulated cleanup block, Blk is the actual block name.
function Build_B
(Loc : Source_Ptr;
Decls : List_Id) return Entity_Id;
-- Generate:
-- B : Boolean := False;
-- Append the object declaration to the list and return its defining
-- identifier.
function Build_C
(Loc : Source_Ptr;
Decls : List_Id) return Entity_Id;
-- Generate:
-- C : Ada.Tags.Prim_Op_Kind;
-- Append the object declaration to the list and return its defining
-- identifier.
function Build_Cleanup_Block
(Loc : Source_Ptr;
Blk_Ent : Entity_Id;
Stmts : List_Id;
Clean_Ent : Entity_Id) return Node_Id;
-- Generate:
-- declare
-- procedure _clean is
-- begin
-- ...
-- end _clean;
-- begin
-- Stmts
-- at end
-- _clean;
-- end;
-- Blk_Ent is the name of the generated block, Stmts is the list of
-- encapsulated statements and Clean_Ent is the parameter to the
-- _clean procedure.
function Build_K
(Loc : Source_Ptr;
Decls : List_Id;
Obj : Entity_Id) return Entity_Id;
-- Generate
-- K : Ada.Tags.Tagged_Kind :=
-- Ada.Tags.Get_Tagged_Kind (Ada.Tags.Tag (Obj));
-- where Obj is the pointer to a secondary table. Append the object
-- declaration to the list and return its defining identifier.
function Build_S
(Loc : Source_Ptr;
Decls : List_Id) return Entity_Id;
-- Generate:
-- S : Integer;
-- Append the object declaration to the list and return its defining
-- identifier.
function Build_S_Assignment
(Loc : Source_Ptr;
S : Entity_Id;
Obj : Entity_Id;
Call_Ent : Entity_Id) return Node_Id;
-- Generate:
-- S := Ada.Tags.Get_Offset_Index (
-- Ada.Tags.Tag (Obj), DT_Position (Call_Ent));
-- where Obj is the pointer to a secondary table, Call_Ent is the entity
-- of the dispatching call name. Return the generated assignment.
end Exp_Sel;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Directories;
with Ada.Streams.Stream_IO;
with League.Stream_Element_Vectors.Internals;
with League.Text_Codecs;
with Matreshka.Internals.Stream_Element_Vectors;
with Matreshka.Internals.Unicode.Characters.Latin;
package body Matreshka.Internals.Settings.Ini_Files is
use Ada.Streams;
use League.Stream_Element_Vectors;
use League.Strings;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Unicode.Characters.Latin;
package Section_Maps is
new Ada.Containers.Hashed_Maps
(League.Strings.Universal_String,
Maps.Map,
League.Strings.Hash,
League.Strings."=",
Maps."=");
-- This map is used to group key/value pairs in sections for serialization.
Line_Delimiter : constant Stream_Element_Array := (0 => Line_Feed);
-- Line_Delimiter : constant Stream_Element_Array
-- := (0 => Carriage_Return, 1 => Line_Feed);
-- Operating system dependent delimiter of lines in the text file.
function To_Locale_String
(Item : League.Strings.Universal_String) return String;
-- Converts Universal_String to locale 8-bit string to use as file name for
-- standard Ada library subprograms.
procedure Load (Self : in out Ini_File_Settings'Class);
-- Loads data from the file.
procedure Parse
(Self : in out Ini_File_Settings'Class;
Data : League.Stream_Element_Vectors.Stream_Element_Vector);
-- Parses data.
function Serialize
(Self : Ini_File_Settings)
return League.Stream_Element_Vectors.Stream_Element_Vector;
-- Serializes data.
function Decode_Key
(Data : Ada.Streams.Stream_Element_Array)
return League.Strings.Universal_String;
-- Decodes key representation in the file into Universal_String.
function Decode_Value
(Data : Ada.Streams.Stream_Element_Array)
return League.Strings.Universal_String renames Decode_Key;
-- Decodes value representation in the file into Universal_String.
function Encode_Key
(Key : League.Strings.Universal_String)
return League.Stream_Element_Vectors.Stream_Element_Vector;
-- Encodes key to representation in the file.
function Encode_Value
(Key : League.Strings.Universal_String)
return League.Stream_Element_Vectors.Stream_Element_Vector
renames Encode_Key;
-- Encodes value to representation in the file.
function From_Hex
(Image : Ada.Streams.Stream_Element_Array)
return Matreshka.Internals.Unicode.Code_Unit_32;
-- Constructs Unicode code point from hexadecimal image. Returns
-- Code_Unit_32'Last when conversion failed.
--------------
-- Contains --
--------------
overriding function Contains
(Self : Ini_File_Settings;
Key : League.Strings.Universal_String) return Boolean is
begin
return Self.Values.Contains (Key);
end Contains;
------------
-- Create --
------------
function Create
(Manager : not null access Abstract_Manager'Class;
File_Name : League.Strings.Universal_String)
return not null Settings_Access is
begin
return Aux : constant not null Settings_Access
:= new Ini_File_Settings'
(Counter => <>,
Manager => Manager,
File_Name => File_Name,
Modified => False,
Values => Maps.Empty_Map)
do
declare
Self : Ini_File_Settings'Class
renames Ini_File_Settings'Class (Aux.all);
begin
Self.Load;
end;
end return;
end Create;
----------------
-- Decode_Key --
----------------
function Decode_Key
(Data : Ada.Streams.Stream_Element_Array)
return League.Strings.Universal_String
is
Key : League.Strings.Universal_String;
Index : Stream_Element_Offset := Data'First;
Code : Code_Unit_32;
begin
while Index <= Data'Last loop
Code := Code_Unit_32'Last;
if Data (Index) = Percent_Sign then
if Data (Index + 1) = Latin_Capital_Letter_U then
-- Unicode long format.
if Index + 7 <= Data'Last then
Code := From_Hex (Data (Index + 2 .. Index + 7));
end if;
Index := Index + 8;
elsif Data (Index + 1) = Latin_Small_Letter_U then
-- Unicode short format.
if Index + 5 <= Data'Last then
Code := From_Hex (Data (Index + 2 .. Index + 5));
end if;
Index := Index + 6;
else
-- Two digits format.
if Index + 2 <= Data'Last then
Code := From_Hex (Data (Index + 1 .. Index + 2));
end if;
Index := Index + 3;
end if;
else
Code := Code_Unit_32 (Data (Index));
Index := Index + 1;
end if;
if Is_Valid (Code) then
Key.Append (Wide_Wide_Character'Val (Code));
end if;
end loop;
return Key;
end Decode_Key;
----------------
-- Encode_Key --
----------------
function Encode_Key
(Key : League.Strings.Universal_String)
return League.Stream_Element_Vectors.Stream_Element_Vector
is
Aux : Stream_Element_Vector;
Code : Code_Point;
To_Hex : constant array (Code_Unit_32 range 0 .. 15) of Stream_Element
:= (Digit_Zero, Digit_One, Digit_Two, Digit_Three,
Digit_Four, Digit_Five, Digit_Six, Digit_Seven,
Digit_Eight, Digit_Nine, Latin_Capital_Letter_A,
Latin_Capital_Letter_B, Latin_Capital_Letter_C,
Latin_Capital_Letter_D, Latin_Capital_Letter_E,
Latin_Capital_Letter_F);
begin
for J in 1 .. Key.Length loop
Code :=
Wide_Wide_Character'Pos (Key.Element (J).To_Wide_Wide_Character);
if Code in Space .. Tilde then
Aux.Append (Stream_Element (Code));
elsif Code <= 16#FF# then
-- Two digits format.
Aux.Append (Percent_Sign);
Aux.Append (To_Hex ((Code / 16) mod 16));
Aux.Append (To_Hex (Code mod 16));
elsif Code <= 16#FFFF# then
-- Short Unicode form.
Aux.Append (Percent_Sign);
Aux.Append (Latin_Small_Letter_U);
Aux.Append (To_Hex ((Code / 4096) mod 16));
Aux.Append (To_Hex ((Code / 256) mod 16));
Aux.Append (To_Hex ((Code / 16) mod 16));
Aux.Append (To_Hex (Code mod 16));
else
-- Long Unicode form.
Aux.Append (Percent_Sign);
Aux.Append (Latin_Capital_Letter_U);
Aux.Append (To_Hex ((Code / 1048576) mod 16));
Aux.Append (To_Hex ((Code / 65536) mod 16));
Aux.Append (To_Hex ((Code / 4096) mod 16));
Aux.Append (To_Hex ((Code / 256) mod 16));
Aux.Append (To_Hex ((Code / 16) mod 16));
Aux.Append (To_Hex (Code mod 16));
end if;
end loop;
return Aux;
end Encode_Key;
--------------
-- Finalize --
--------------
overriding procedure Finalize
(Self : not null access Ini_File_Settings) is
begin
Self.Sync;
end Finalize;
--------------
-- From_Hex --
--------------
function From_Hex
(Image : Ada.Streams.Stream_Element_Array)
return Matreshka.Internals.Unicode.Code_Unit_32
is
Code : Code_Unit_32 := 0;
Index : Stream_Element_Offset := Image'First;
begin
while Index <= Image'Last loop
Code := Code * 16;
if Image (Index) in Digit_Zero .. Digit_Nine then
Code := Code + Code_Unit_32 (Image (Index)) - Digit_Zero;
elsif Image (Index)
in Latin_Capital_Letter_A .. Latin_Capital_Letter_F
then
Code :=
Code
+ Code_Unit_32 (Image (Index)) - Latin_Capital_Letter_A + 10;
elsif Image (Index)
in Latin_Small_Letter_A .. Latin_Small_Letter_F
then
Code :=
Code + Code_Unit_32 (Image (Index)) - Latin_Small_Letter_A + 10;
else
return Code_Unit_32'Last;
end if;
if Code not in Code_Point then
return Code_Unit_32'Last;
end if;
Index := Index + 1;
end loop;
return Code;
end From_Hex;
----------
-- Load --
----------
procedure Load (Self : in out Ini_File_Settings'Class) is
use Ada.Streams.Stream_IO;
File : File_Type;
Buffer : Stream_Element_Array (1 .. 1024);
Data : Stream_Element_Vector;
Last : Stream_Element_Offset;
begin
if Ada.Directories.Exists (To_Locale_String (Self.File_Name)) then
-- Load content of the file.
Open (File, In_File, To_Locale_String (Self.File_Name));
loop
Read (File, Buffer, Last);
exit when Last < Buffer'First;
Data.Append (Buffer (Buffer'First .. Last));
end loop;
Close (File);
-- Parse.
Self.Parse (Data);
end if;
end Load;
----------
-- Name --
----------
overriding function Name
(Self : not null access Ini_File_Settings)
return League.Strings.Universal_String is
begin
return Self.File_Name;
end Name;
-----------
-- Parse --
-----------
procedure Parse
(Self : in out Ini_File_Settings'Class;
Data : League.Stream_Element_Vectors.Stream_Element_Vector)
is
use Matreshka.Internals.Stream_Element_Vectors;
procedure Parse_Line;
-- Determine boundary of the next line.
Buffer : constant Shared_Stream_Element_Vector_Access
:= League.Stream_Element_Vectors.Internals.Internal (Data);
Line_First : Stream_Element_Offset;
Line_Last : Stream_Element_Offset;
Equal_Index : Stream_Element_Offset;
Key_Last : Stream_Element_Offset;
Value_First : Stream_Element_Offset;
Current_Section : Universal_String;
Key : Universal_String;
----------------
-- Parse_Line --
----------------
procedure Parse_Line is
begin
Line_First := Line_Last + 1;
-- Skip leading whitespaces.
while Line_First < Buffer.Length loop
exit when
Buffer.Value (Line_First) /= Space
and Buffer.Value (Line_First) /= Character_Tabulation
and Buffer.Value (Line_First) /= Carriage_Return
and Buffer.Value (Line_First) /= Line_Feed;
Line_First := Line_First + 1;
end loop;
Line_Last := Line_First;
Equal_Index := Line_First - 1;
-- Scan line.
while Line_Last < Buffer.Length loop
-- Exit when end of line is reached.
exit when
Buffer.Value (Line_Last) = Carriage_Return
or Buffer.Value (Line_Last) = Line_Feed;
-- Save position of first occurrence of equal sign.
if Buffer.Value (Line_Last) = Equals_Sign
and Equal_Index < Line_First
then
Equal_Index := Line_Last;
end if;
Line_Last := Line_Last + 1;
end loop;
Line_Last := Line_Last - 1;
-- Remove trailing whitespaces.
loop
exit when
Buffer.Value (Line_Last) /= Character_Tabulation
and Buffer.Value (Line_Last) /= Space;
Line_Last := Line_Last - 1;
end loop;
-- Determine key and value boundary.
if Equal_Index >= Line_First then
Key_Last := Equal_Index - 1;
while Key_Last >= Line_First loop
exit when
Buffer.Value (Key_Last) /= Character_Tabulation
and Buffer.Value (Key_Last) /= Space;
Key_Last := Key_Last - 1;
end loop;
Value_First := Equal_Index + 1;
while Value_First <= Line_Last loop
exit when
Buffer.Value (Value_First) /= Character_Tabulation
and Buffer.Value (Value_First) /= Space;
Value_First := Value_First + 1;
end loop;
end if;
end Parse_Line;
begin
Line_Last := -1;
loop
Parse_Line;
exit when Line_Last < Line_First;
if Buffer.Value (Line_First) = Semicolon then
-- This is a comment line.
null;
elsif Buffer.Value (Line_First) = Left_Square_Bracket then
-- Section.
Line_First := Line_First + 1;
if Buffer.Value (Line_Last) = Right_Square_Bracket then
Key_Last := Line_Last - 1;
else
Key_Last := Line_Last;
end if;
-- Strip leading whitespaces.
while Line_First <= Key_Last loop
exit when
Buffer.Value (Line_First) /= Character_Tabulation
and Buffer.Value (Line_First) /= Space;
Line_First := Line_First + 1;
end loop;
-- Strip trailing whitespaces.
while Key_Last >= Line_First loop
exit when
Buffer.Value (Key_Last) /= Character_Tabulation
and Buffer.Value (Key_Last) /= Space;
Key_Last := Key_Last - 1;
end loop;
Current_Section :=
Decode_Key (Buffer.Value (Line_First .. Key_Last));
elsif Equal_Index >= Line_First then
-- Key/value pair.
Key := Current_Section;
if not Key.Is_Empty then
Key.Append ('/');
end if;
Key.Append (Decode_Key (Buffer.Value (Line_First .. Key_Last)));
if not Self.Values.Contains (Key) then
Self.Values.Insert
(Key,
To_Stream_Element_Vector
(Buffer.Value (Value_First .. Line_Last)));
end if;
else
-- Incorrect line.
null;
end if;
end loop;
end Parse;
------------
-- Remove --
------------
overriding procedure Remove
(Self : in out Ini_File_Settings;
Key : League.Strings.Universal_String) is
begin
if Self.Values.Contains (Key) then
Self.Values.Delete (Key);
Self.Modified := True;
end if;
end Remove;
---------------
-- Serialize --
---------------
function Serialize
(Self : Ini_File_Settings)
return League.Stream_Element_Vectors.Stream_Element_Vector
is
procedure Group_Pair (Position : Maps.Cursor);
-- Add pair into sections map.
procedure Serialize_Section (Position : Section_Maps.Cursor);
-- Serialize specified section and its key/value pairs.
procedure Serialize_Pair (Position : Maps.Cursor);
-- Serialize specified key/value pair.
Aux : League.Stream_Element_Vectors.Stream_Element_Vector;
Sections : Section_Maps.Map;
----------------
-- Group_Pair --
----------------
procedure Group_Pair (Position : Maps.Cursor) is
procedure Insert_Pair
(Section_Key : Universal_String;
Section_Values : in out Maps.Map);
-- Insert current key/value pair into the specified section. It
-- removes first component of key name.
Key : constant Universal_String := Maps.Key (Position);
Value : constant Stream_Element_Vector
:= Maps.Element (Position);
Index : constant Natural := Key.Index ('/');
Section_Position : Section_Maps.Cursor;
-----------------
-- Insert_Pair --
-----------------
procedure Insert_Pair
(Section_Key : Universal_String;
Section_Values : in out Maps.Map) is
begin
if Index = 0 then
Section_Values.Insert (Key, Value);
else
Section_Values.Insert
(Key.Slice (Index + 1, Key.Length), Value);
end if;
end Insert_Pair;
begin
if Index = 0 then
Section_Position := Sections.Find (Empty_Universal_String);
if not Section_Maps.Has_Element (Section_Position) then
Sections.Insert (Empty_Universal_String, Maps.Empty_Map);
Section_Position := Sections.Find (Empty_Universal_String);
end if;
else
Section_Position := Sections.Find (Key.Slice (1, Index - 1));
if not Section_Maps.Has_Element (Section_Position) then
Sections.Insert (Key.Slice (1, Index - 1), Maps.Empty_Map);
Section_Position := Sections.Find (Key.Slice (1, Index - 1));
end if;
end if;
Sections.Update_Element (Section_Position, Insert_Pair'Access);
end Group_Pair;
--------------------
-- Serialize_Pair --
--------------------
procedure Serialize_Pair (Position : Maps.Cursor) is
Key : constant Universal_String := Maps.Key (Position);
Value : constant Stream_Element_Vector := Maps.Element (Position);
begin
Aux.Append (Encode_Key (Key));
Aux.Append (Equals_Sign);
Aux.Append (Value);
Aux.Append (Line_Delimiter);
end Serialize_Pair;
-----------------------
-- Serialize_Section --
-----------------------
procedure Serialize_Section (Position : Section_Maps.Cursor) is
Section : constant Universal_String := Section_Maps.Key (Position);
Values : constant Maps.Map := Section_Maps.Element (Position);
begin
Aux.Append (Left_Square_Bracket);
Aux.Append (Encode_Key (Section));
Aux.Append (Right_Square_Bracket);
Aux.Append (Line_Delimiter);
Values.Iterate (Serialize_Pair'Access);
Aux.Append (Line_Delimiter);
end Serialize_Section;
begin
-- Group key/value pair into sections.
Self.Values.Iterate (Group_Pair'Access);
-- Serialize sections and their key/value pairs.
Sections.Iterate (Serialize_Section'Access);
return Aux;
end Serialize;
---------------
-- Set_Value --
---------------
overriding procedure Set_Value
(Self : in out Ini_File_Settings;
Key : League.Strings.Universal_String;
Value : League.Holders.Holder) is
begin
Self.Modified := True;
Self.Values.Include (Key, Encode_Value (League.Holders.Element (Value)));
end Set_Value;
----------
-- Sync --
----------
overriding procedure Sync (Self : in out Ini_File_Settings) is
use Ada.Streams.Stream_IO;
use League.Stream_Element_Vectors.Internals;
Name : constant String := To_Locale_String (Self.File_Name);
File : File_Type;
Data : Stream_Element_Vector;
begin
if Self.Modified then
-- Serialize data.
Data := Serialize (Self);
-- Creates directory when necessary.
Ada.Directories.Create_Path
(Ada.Directories.Containing_Directory (Name));
-- Writes data into file.
Create (File, Out_File, Name);
Write (File, Internal (Data).Value (0 .. Internal (Data).Length - 1));
Close (File);
Self.Modified := False;
end if;
end Sync;
----------------------
-- To_Locale_String --
----------------------
function To_Locale_String
(Item : League.Strings.Universal_String) return String
is
Aux : constant Stream_Element_Array
:= League.Text_Codecs.Codec_For_Application_Locale.Encode
(Item).To_Stream_Element_Array;
Str : String (1 .. Aux'Length);
for Str'Address use Aux'Address;
pragma Import (Ada, Str);
begin
return Str;
end To_Locale_String;
-----------
-- Value --
-----------
overriding function Value
(Self : Ini_File_Settings;
Key : League.Strings.Universal_String)
return League.Holders.Holder is
begin
if Self.Values.Contains (Key) then
return
League.Holders.To_Holder
(Decode_Value (Self.Values.Element (Key).To_Stream_Element_Array));
else
return League.Holders.Empty_Holder;
end if;
end Value;
end Matreshka.Internals.Settings.Ini_Files;
|
package types is
type Percent is delta 10.0 ** (-2) digits 5;
type Index is range 1 .. 100;
type Rod_Array is array (Index) of Percent;
type Kilojoule is delta 10.0 ** (-4) digits 8;
end types;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . B O A R D _ S U P P O R T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
-- Copyright (C) 2003-2018, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
with System.Machine_Code;
with System.BB.Board_Parameters;
with System.BB.CPU_Primitives;
with Interfaces;
with Interfaces.M1AGL.CoreTimer; use Interfaces.M1AGL.CoreTimer;
with Interfaces.M1AGL.CoreInterrupt; use Interfaces.M1AGL.CoreInterrupt;
with Interfaces.M1AGL;
package body System.BB.Board_Support is
use CPU_Primitives, BB.Interrupts, Machine_Code, Time, Interfaces;
Interrupt_Request_Vector : constant Vector_Id := 16;
-- See vector definitions in ARMv6-M version of System.BB.CPU_Primitives.
-- Defined by ARMv6-M specifications.
----------------------------------------------
-- New Vectored Interrupt Controller (NVIC) --
----------------------------------------------
NVIC_Base : constant := 16#E000_E000#;
-- Nested Vectored Interrupt Controller (NVIC) base.
NVIC_ISER : Word with Volatile, Address => NVIC_Base + 16#100#;
-- Writing a bit mask to this register enables the corresponding interrupts
Alarm_Time : Time.Timer_Interval;
pragma Volatile (Alarm_Time);
pragma Export (C, Alarm_Time, "__gnat_alarm_time");
Alarm_Interrupt_ID : constant Interrupt_ID := 2;
-- Return the interrupt level to use for the alarm clock handler.
----------------------------
-- Test and set intrinsic --
----------------------------
-- The run-time package System.Multiprocessors.Spin_Locks is based on the
-- implementation of test and set intrinsic. The Cortex-M1 architecture
-- does not implement the machine instructions LDREX/STREX so these
-- intrinsic functions are not available. This is only a problem at link
-- time since the Spin_Locks are only used in multi-processor systems,
-- which is not the case here.
--
-- To workaround the linker error, we export here the required intrinsic
-- functions. As explained above, they should never be executed so the body
-- of the functions only raises an Program_Error.
function Lock_Test_And_Set
(Ptr : access Unsigned_8;
Value : Unsigned_8)
return Unsigned_8;
pragma Export (C, Lock_Test_And_Set, "__sync_lock_test_and_set_1");
procedure Lock_Release (Ptr : access Unsigned_8);
pragma Export (C, Lock_Release, "__sync_lock_release");
-----------------------
-- Lock_Test_And_Set --
-----------------------
function Lock_Test_And_Set
(Ptr : access Unsigned_8;
Value : Unsigned_8)
return Unsigned_8
is
begin
raise Program_Error;
return 0;
end Lock_Test_And_Set;
------------------
-- Lock_Release --
------------------
procedure Lock_Release (Ptr : access Unsigned_8) is
begin
raise Program_Error;
end Lock_Release;
--------------------
-- Timer Handling --
--------------------
-- We use the Microsemi CoreTime as a periodic timer with 1 kHz rate. This
-- is a trade-off between accurate delays, limited overhead and maximum
-- time that interrupts may be disabled.
Tick_Period : constant Time.Timer_Interval :=
System.BB.Board_Parameters.Timer_Frequency / 1000;
RVR_Last : constant := 2**24 - 1;
pragma Assert (Tick_Period <= RVR_Last + 1);
Next_Tick_Time : Timer_Interval with Volatile;
-- Time when systick will expire. This gives the high digits of the time
procedure Interrupt_Handler;
----------------------
-- Initialize_Board --
----------------------
procedure Initialize_Board is
begin
-- Mask interrupts
Disable_Interrupts;
-- Time --
-- Configure CoreTimer
CoreTimer_Periph.Control.Enable := False;
CoreTimer_Periph.Control.Interrupt_Enable := True;
CoreTimer_Periph.Control.Timer_Mode := Continuous;
CoreTimer_Periph.Prescale.Value := Divide_By_2;
CoreTimer_Periph.Load_Value :=
Interfaces.M1AGL.UInt32 (Tick_Period - 1);
-- We do not enable the timer until the handler is ready to receive the
-- interrupt, i.e. in Install_Alarm_Handler.
Next_Tick_Time := Tick_Period;
Time.Set_Alarm (Timer_Interval'Last);
Time.Clear_Alarm_Interrupt;
-- Interrupts --
Install_Trap_Handler
(Interrupt_Handler'Address, Interrupt_Request_Vector);
-- On the Microsemi Cortex-M1 only one IRQ line of the NVIC is used, the
-- real interrupt handling is done by another device: CoreInterrupt. So
-- on the NVIC, we always enable the IRQ corresponding to
-- Core_Interrupt.
NVIC_ISER := 1;
end Initialize_Board;
package body Time is
Upper_Alarm_Handler : BB.Interrupts.Interrupt_Handler := null;
procedure Pre_Alarm_Handler (Id : Interrupt_ID);
-----------------------
-- Pre_Alarm_Handler --
-----------------------
procedure Pre_Alarm_Handler (Id : Interrupt_ID) is
begin
-- Next_Tick_Time is usually updated in Read_Clock, but we can't do
-- that for CoreTimer because there's no way to know if we are
-- We need to update the Next_Tick_Time before calling the s.bb.time
-- alarm handler executes because it expects
Next_Tick_Time := Next_Tick_Time + Tick_Period;
pragma Assert (Upper_Alarm_Handler /= null);
Upper_Alarm_Handler (Id);
end Pre_Alarm_Handler;
------------------------
-- Max_Timer_Interval --
------------------------
function Max_Timer_Interval return Timer_Interval is (2**32 - 1);
----------------
-- Read_Clock --
----------------
function Read_Clock return BB.Time.Time is
PRIMASK : Word;
Flag : Boolean;
Count : Timer_Interval;
Res : Timer_Interval;
begin
-- As several registers and variables need to be read or modified, do
-- it atomically.
Asm ("mrs %0, PRIMASK",
Outputs => Word'Asm_Output ("=&r", PRIMASK),
Volatile => True);
Asm ("msr PRIMASK, %0",
Inputs => Word'Asm_Input ("r", 1),
Volatile => True);
-- We must read the counter register before the flag
Count := Timer_Interval (CoreTimer_Periph.Current_Value);
-- If we read the flag first, a reload can occur just after the read
-- and the count register would wrap around. We'd end up with a Count
-- value close to the Tick_Period value but a flag at zero and
-- therefore miss the reload and return a wrong clock value.
-- This flag is set when the counter has reached zero. Next_Tick_Time
-- has to be incremented. This will trigger an interrupt very soon
-- (or has just triggered the interrupt), so count is either zero or
-- not far from Tick_Period.
Flag := CoreTimer_Periph.Raw_Interrupt_Status.Pending;
if Flag then
-- CoreTimer counter has just reached zero, pretend it is still
-- zero.
Res := Next_Tick_Time;
-- The following is not applicable to CoreTimer, so we increase
-- Next_Tick_Time in the alarm handler (see below):
-- Note that reading the Control and Status
-- register (SYST_CSR) clears the COUNTFLAG bit, so even if we
-- have sequential calls to this function, the increment of
-- Next_Tick_Time will happen only once.
-- Next_Tick_Time := Next_Tick_Time + Tick_Period;
else
-- The counter is decremented, so compute the actual time
Res := Next_Tick_Time - Count;
end if;
-- Restore interrupt mask
Asm ("msr PRIMASK, %0",
Inputs => Word'Asm_Input ("r", PRIMASK),
Volatile => True);
return BB.Time.Time (Res);
end Read_Clock;
---------------------------
-- Clear_Alarm_Interrupt --
---------------------------
procedure Clear_Alarm_Interrupt is
begin
-- Any write to this register will clear the interrupt
CoreTimer_Periph.Interrupt_Clear := 42;
end Clear_Alarm_Interrupt;
---------------
-- Set_Alarm --
---------------
procedure Set_Alarm (Ticks : Timer_Interval) is
Now : constant Timer_Interval := Timer_Interval (Read_Clock);
begin
Alarm_Time :=
Now + Timer_Interval'Min (Timer_Interval'Last / 2, Ticks);
-- As we will have periodic interrupts for alarms regardless, the
-- only thing to do is force an interrupt if the alarm has already
-- expired.
-- NOTE: We can't do this with the CoreTimer
end Set_Alarm;
---------------------------
-- Install_Alarm_Handler --
---------------------------
procedure Install_Alarm_Handler
(Handler : BB.Interrupts.Interrupt_Handler) is
begin
pragma Assert (Upper_Alarm_Handler = null);
Upper_Alarm_Handler := Handler;
BB.Interrupts.Attach_Handler
(Pre_Alarm_Handler'Access,
Alarm_Interrupt_ID,
Interrupt_Priority'Last);
-- Now we are ready to handle the CoreTimer interrupt
CoreTimer_Periph.Control.Enable := True;
end Install_Alarm_Handler;
end Time;
package body Multiprocessors is separate;
-----------------------
-- Interrupt_Handler --
-----------------------
procedure Interrupt_Handler is
Status : constant IRQ_Status_IRQ_Field_Array :=
CoreInterrupt_Periph.IRQ_Status.IRQ.Arr;
begin
-- For each interrupt
for Index in Status'Range loop
-- Check if the interrupt is flagged
if Status (Index) then
-- Call the wrapper
Interrupt_Wrapper (Index);
end if;
end loop;
end Interrupt_Handler;
package body Interrupts is
procedure Enable_Interrupt_Request
(Interrupt : Interrupt_ID;
Prio : Interrupt_Priority);
-- Enable interrupt requests for the given interrupt
------------------------------
-- Enable_Interrupt_Request --
------------------------------
procedure Enable_Interrupt_Request
(Interrupt : Interrupt_ID;
Prio : Interrupt_Priority)
is
pragma Unreferenced (Prio);
begin
CoreInterrupt_Periph.IRQ_Enable.IRQ.Arr (Interrupt) := True;
end Enable_Interrupt_Request;
-------------------------------
-- Install_Interrupt_Handler --
-------------------------------
procedure Install_Interrupt_Handler
(Interrupt : Interrupt_ID;
Prio : Interrupt_Priority)
is
begin
Enable_Interrupt_Request (Interrupt, Prio);
end Install_Interrupt_Handler;
---------------------------
-- Priority_Of_Interrupt --
---------------------------
function Priority_Of_Interrupt
(Interrupt : Interrupt_ID) return Any_Priority
is (Interrupt_Priority'Last);
----------------
-- Power_Down --
----------------
procedure Power_Down is
begin
Asm ("wfi", Volatile => True);
end Power_Down;
--------------------------
-- Set_Current_Priority --
--------------------------
procedure Set_Current_Priority (Priority : Integer) is
begin
-- There's no interrupt priority support on this platform
null;
end Set_Current_Priority;
end Interrupts;
end System.BB.Board_Support;
|
--- libsrc/posix-unsafe_process_primitives.adb.orig 2017-05-16 10:40:58 UTC
+++ libsrc/posix-unsafe_process_primitives.adb
@@ -40,6 +40,7 @@ with POSIX.C,
POSIX.Implementation,
System,
System.Soft_Links,
+ System.Secondary_Stack,
Unchecked_Conversion;
package body POSIX.Unsafe_Process_Primitives is
@@ -88,9 +89,10 @@ package body POSIX.Unsafe_Process_Primit
function Fork return POSIX.Process_Identification.Process_ID is
Result : pid_t;
package SSL renames System.Soft_Links;
+ package SST renames System.Secondary_Stack;
-- save local values of soft-link data
- NT_Sec_Stack_Addr : constant System.Address :=
- SSL.Get_Sec_Stack_Addr.all;
+ NT_Sec_Stack : constant SST.SS_Stack_Ptr :=
+ SSL.Get_Sec_Stack.all;
NT_Jmpbuf_Address : constant System.Address :=
SSL.Get_Jmpbuf_Address.all;
begin
@@ -106,10 +108,10 @@ package body POSIX.Unsafe_Process_Primit
SSL.Unlock_Task := SSL.Task_Unlock_NT'Access;
SSL.Get_Jmpbuf_Address := SSL.Get_Jmpbuf_Address_NT'Access;
SSL.Set_Jmpbuf_Address := SSL.Set_Jmpbuf_Address_NT'Access;
- SSL.Get_Sec_Stack_Addr := SSL.Get_Sec_Stack_Addr_NT'Access;
- SSL.Set_Sec_Stack_Addr := SSL.Set_Sec_Stack_Addr_NT'Access;
+ SSL.Get_Sec_Stack := SSL.Get_Sec_Stack_NT'Access;
+ SSL.Set_Sec_Stack := SSL.Set_Sec_Stack_NT'Access;
-- reset global data to saved local values for this thread
- SSL.Set_Sec_Stack_Addr (NT_Sec_Stack_Addr);
+ SSL.Set_Sec_Stack (NT_Sec_Stack);
SSL.Set_Jmpbuf_Address (NT_Jmpbuf_Address);
end if;
return To_Process_ID (Result);
|
-- { dg-do run }
-- { dg-options "-O2" }
procedure Opt14 is
type Rec is record
I1, I2, I3 : Integer;
end record;
type Ptr is access Rec;
P : Ptr := new Rec'(0,0,0);
procedure Sub (R : In Out Rec) is
begin
R.I3 := R.I3 - 1;
end;
begin
P.all := (1,2,3);
Sub (P.all);
if P.all /= (1,2,2) then
raise Program_Error;
end if;
end;
|
--===========================================================================
--
-- This package is the interface to the SH1107 OLED controller
--
--===========================================================================
--
-- Copyright 2022 (C) Holger Rodriguez
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with HAL;
with HAL.Bitmap;
with HAL.Framebuffer;
with HAL.GPIO;
with HAL.I2C;
with HAL.SPI;
with Memory_Mapped_Bitmap;
package SH1107 is
--------------------------------------------------------------------------
-- Possible orientations of the OLED display
-- Think of it as, how you would see it, when the display itself
-- is laid out to the flat cable connector.
-- Up = The display is pointing UP relative to the cable
-- Right = The display is pointing RIGHT relative to the cable
-- Down = The display is pointing DOWN relative to the cable
-- Left = The display is pointing LEFT relative to the cable
type SH1107_Orientation is (Up, Right, Down, Left);
--------------------------------------------------------------------------
-- As this screen is black/white only, we only have one layer
THE_LAYER : constant Positive := 1;
--------------------------------------------------------------------------
-- This driver can only support 128 x 128 bits black/white
-- Therefore we declare those constants here
THE_WIDTH : constant Positive := 128;
THE_HEIGHT : constant Positive := 128;
--------------------------------------------------------------------------
-- Having the constants as above, and as one byte has 8 bits,
-- The buffer size is a constant as below
THE_BUFFER_SIZE_IN_BYTES : constant Positive
:= (THE_WIDTH * THE_HEIGHT) / 8;
--------------------------------------------------------------------------
-- The device can be connected via
-- - I2C
-- - SPI
type Connector is (Connect_I2C, Connect_SPI);
--------------------------------------------------------------------------
-- Our screen type definition.
-- Unlike other drivers, as this driver is constant, no discriminants
-- needed for different scenarions.
-- Connect_With : defines, how to connect to the display
type SH1107_Screen (Connect_With : Connector)
is limited new HAL.Framebuffer.Frame_Buffer_Display with private;
--------------------------------------------------------------------------
-- Our access screen type definition.
type Any_SH1107_Screen is not null access all SH1107_Screen'Class;
--------------------------------------------------------------------------
-- Initializes an OLED screen connected by I2C
-- This : the screen to use
-- Orientation : the initial orientation of *This*
-- Port : the I2C port, *This* is connnected to
-- Address : the I2C address of *This* on *Port*
procedure Initialize (This : in out SH1107_Screen;
Orientation : SH1107_Orientation;
Port : not null HAL.I2C.Any_I2C_Port;
Address : HAL.I2C.I2C_Address);
--------------------------------------------------------------------------
-- Initializes an OLED screen connected by SPI
-- This : the screen to use
-- Orientation : the initial orientation of *This*
-- Port : the SPI port, *This* is connnected to
-- DC_SPI : the GPIO, where the Data/Command control
-- for *This* is connected to
procedure Initialize (This : in out SH1107_Screen;
Orientation : SH1107_Orientation;
Port : not null HAL.SPI.Any_SPI_Port;
DC_SPI : not null HAL.GPIO.Any_GPIO_Point);
--------------------------------------------------------------------------
-- Turns on the display
procedure Turn_On (This : SH1107_Screen);
--------------------------------------------------------------------------
-- Turns off the display
procedure Turn_Off (This : SH1107_Screen);
--------------------------------------------------------------------------
-- Sets the logical orientation of the display
procedure Set_Orientation (This : in out SH1107_Screen;
Orientation : SH1107_Orientation);
--========================================================================
--
-- This section is the collection of overriding procedures/functions
-- from the parent class
--
--========================================================================
overriding
function Max_Layers
(This : SH1107_Screen) return Positive is (1);
overriding
function Supported
(This : SH1107_Screen;
Mode : HAL.Framebuffer.FB_Color_Mode) return Boolean;
overriding
procedure Set_Orientation
(This : in out SH1107_Screen;
Orientation : HAL.Framebuffer.Display_Orientation);
overriding
procedure Set_Mode
(This : in out SH1107_Screen;
Mode : HAL.Framebuffer.Wait_Mode);
overriding
function Initialized
(This : SH1107_Screen) return Boolean;
overriding
function Width
(This : SH1107_Screen) return Positive is (THE_WIDTH);
overriding
function Height
(This : SH1107_Screen) return Positive is (THE_HEIGHT);
overriding
function Swapped
(This : SH1107_Screen) return Boolean is (False);
overriding
procedure Set_Background
(This : SH1107_Screen; R, G, B : HAL.UInt8);
overriding
procedure Initialize_Layer
(This : in out SH1107_Screen;
Layer : Positive;
Mode : HAL.Framebuffer.FB_Color_Mode;
X : Natural := 0;
Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last);
overriding
function Initialized
(This : SH1107_Screen;
Layer : Positive) return Boolean;
overriding
procedure Update_Layer
(This : in out SH1107_Screen;
Layer : Positive;
Copy_Back : Boolean := False);
overriding
procedure Update_Layers
(This : in out SH1107_Screen);
pragma Warnings (Off, "formal parameter ""Layer"" is not referenced");
overriding
function Color_Mode
(This : SH1107_Screen;
Layer : Positive := THE_LAYER) return HAL.Framebuffer.FB_Color_Mode
is (HAL.Bitmap.M_1);
pragma Warnings (On, "formal parameter ""Layer"" is not referenced");
overriding
function Hidden_Buffer
(This : in out SH1107_Screen;
Layer : Positive := THE_LAYER)
return not null HAL.Bitmap.Any_Bitmap_Buffer;
overriding
function Pixel_Size
(Display : SH1107_Screen;
Layer : Positive := THE_LAYER) return Positive;
private
--------------------------------------------------------------------------
-- The bitmap buffer used for the display
type SH1107_Bitmap_Buffer is
new Memory_Mapped_Bitmap.Memory_Mapped_Bitmap_Buffer with record
Orientation : SH1107_Orientation;
Data : HAL.UInt8_Array (1 .. THE_BUFFER_SIZE_IN_BYTES);
end record;
type SH1107_Screen (Connect_With : Connector)
is limited new HAL.Framebuffer.Frame_Buffer_Display with
record
Buffer_Size_In_Byte : Positive := THE_BUFFER_SIZE_IN_BYTES;
Width : Positive := THE_WIDTH;
Height : Positive := THE_HEIGHT;
Orientation : SH1107_Orientation;
Memory_Layer : aliased SH1107_Bitmap_Buffer;
Layer_Initialized : Boolean := False;
Device_Initialized : Boolean := False;
case Connect_With is
when Connect_I2C =>
Port_I2C : HAL.I2C.Any_I2C_Port;
Address_I2C : HAL.I2C.I2C_Address;
when Connect_SPI =>
Port_SPI : HAL.SPI.Any_SPI_Port;
DC_SPI : HAL.GPIO.Any_GPIO_Point;
end case;
end record;
--========================================================================
--
-- This section is the collection of overriding procedures/functions
-- from the parent class for the Bitmap Buffer
--
--========================================================================
overriding
procedure Set_Pixel (Buffer : in out SH1107_Bitmap_Buffer;
Pt : HAL.Bitmap.Point);
overriding
procedure Set_Pixel (Buffer : in out SH1107_Bitmap_Buffer;
Pt : HAL.Bitmap.Point;
Color : HAL.Bitmap.Bitmap_Color);
overriding
procedure Set_Pixel (Buffer : in out SH1107_Bitmap_Buffer;
Pt : HAL.Bitmap.Point;
Raw : HAL.UInt32);
overriding
function Pixel (Buffer : SH1107_Bitmap_Buffer;
Pt : HAL.Bitmap.Point) return HAL.Bitmap.Bitmap_Color;
overriding
function Pixel (Buffer : SH1107_Bitmap_Buffer;
Pt : HAL.Bitmap.Point) return HAL.UInt32;
overriding
procedure Fill (Buffer : in out SH1107_Bitmap_Buffer);
end SH1107;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.