content
stringlengths 23
1.05M
|
|---|
-- Chip Richards, Phoenix AZ, April 2007
-- Lumen would not be possible without the support and contributions of a cast
-- of thousands, including and primarily Rod Kay.
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
-- For purposes of this package:
--
-- byte -- 8 bits (octet, C char, GNAT Character/Short_Short_Integer)
-- short -- 16 bits (C short, GNAT Short_Integer)
-- word -- 32 bits (C int/long(32), GNAT Integer/Long_Integer)
-- long -- 64 bits (C long(64), GNAT Long_Long_Integer)
--
-- Note that these are not identical to the names/definitions used on pretty
-- much any extant 32- or 64-bit platform, though they are somewhat biased to
-- early 21st-century 32-bit platforms.
package Lumen.Binary is
---------------------------------------------------------------------------
--
-- Public constants
--
---------------------------------------------------------------------------
-- Basic structure (sizes) of fundamental binary data types
Byte_Bits : constant := 8;
Short_Bits : constant := 16;
Word_Bits : constant := 32;
Long_Bits : constant := 64;
-- Derived sizes
Short_Bytes : constant := Short_Bits / Byte_Bits;
Word_Bytes : constant := Word_Bits / Byte_Bits;
Long_Bytes : constant := Long_Bits / Byte_Bits;
-- "Last-bit" values for use in rep clauses
Byte_LB : constant := Byte_Bits - 1;
Short_LB : constant := Short_Bits - 1;
Word_LB : constant := Word_Bits - 1;
Long_LB : constant := Long_Bits - 1;
---------------------------------------------------------------------------
--
-- Public types
--
---------------------------------------------------------------------------
-- Unsigned types
type Byte is mod 2 ** Byte_Bits;
type Short is mod 2 ** Short_Bits;
type Word is mod 2 ** Word_Bits;
type Long is mod 2 ** Long_Bits;
for Byte'Size use Byte_Bits;
for Short'Size use Short_Bits;
for Word'Size use Word_Bits;
for Long'Size use Long_Bits;
-- Signed types
Byte_Exp : constant := Byte_Bits - 1;
Short_Exp : constant := Short_Bits - 1;
Word_Exp : constant := Word_Bits - 1;
Long_Exp : constant := Long_Bits - 1;
type S_Byte is new Integer range -(2 ** Byte_Exp) .. (2 ** Byte_Exp) - 1;
type S_Short is new Integer range -(2 ** Short_Exp) .. (2 ** Short_Exp) - 1;
type S_Word is new Integer range -(2 ** Word_Exp) .. (2 ** Word_Exp) - 1;
type S_Long is new Long_Long_Integer; -- must use this for now; fixme later
for S_Byte'Size use Byte_Bits;
for S_Short'Size use Short_Bits;
for S_Word'Size use Word_Bits;
for S_Long'Size use Long_Bits;
-- Array types built from the above basic types
type Byte_String is array (Natural range <>) of Byte;
type Short_String is array (Natural range <>) of Short;
type Word_String is array (Natural range <>) of Word;
type Long_String is array (Natural range <>) of Long;
type S_Byte_String is array (Natural range <>) of S_Byte;
type S_Short_String is array (Natural range <>) of S_Short;
type S_Word_String is array (Natural range <>) of S_Word;
type S_Long_String is array (Natural range <>) of S_Long;
-- Useful byte-string types for data conversion
subtype Short_Byte_String is Byte_String (1 .. Short_Bytes);
subtype Word_Byte_String is Byte_String (1 .. Word_Bytes);
subtype Long_Byte_String is Byte_String (1 .. Long_Bytes);
---------------------------------------------------------------------------
end Lumen.Binary;
|
with System.Storage_Elements; use System.Storage_Elements;
with MSP430_SVD; use MSP430_SVD;
with MSP430_SVD.SYSTEM_CLOCK; use MSP430_SVD.SYSTEM_CLOCK;
with MSPGD.GPIO; use MSPGD.GPIO;
with MSPGD.GPIO.Pin;
with Startup;
package body Board is
CALDCO_1MHz : DCOCTL_Register with Import, Address => System'To_Address (16#10FE#);
CALBC1_1MHz : BCSCTL1_Register with Import, Address => System'To_Address (16#10FF#);
CALDCO_8MHz : DCOCTL_Register with Import, Address => System'To_Address (16#10FC#);
CALBC1_8MHz : BCSCTL1_Register with Import, Address => System'To_Address (16#10FD#);
package RX is new MSPGD.GPIO.Pin (Port => 1, Pin => 1, Alt_Func => Secondary);
package TX is new MSPGD.GPIO.Pin (Port => 1, Pin => 2, Alt_Func => Secondary);
procedure Init is
begin
-- SYSTEM_CLOCK_Periph.BCSCTL1 := CALBC1_8MHz;
-- SYSTEM_CLOCK_Periph.DCOCTL := CALDCO_8MHz;
Clock.Init;
RX.Init;
TX.Init;
UART.Init;
end Init;
end Board;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . H E A P _ S O R T _ A --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-2020, 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. --
-- --
------------------------------------------------------------------------------
-- Heapsort using access to procedure parameters
-- This package provides a heap sort routine that works with access to
-- subprogram parameters, so that it can be used with different types with
-- shared sorting code. It is considered obsoleted by GNAT.Heap_Sort which
-- offers a similar routine with a more convenient interface.
-- This heapsort algorithm uses approximately N*log(N) compares in the
-- worst case and is in place with no additional storage required. See
-- the body for exact details of the algorithm used.
pragma Compiler_Unit_Warning;
package GNAT.Heap_Sort_A is
pragma Preelaborate;
-- The data to be sorted is assumed to be indexed by integer values from
-- 1 to N, where N is the number of items to be sorted. In addition, the
-- index value zero is used for a temporary location used during the sort.
type Move_Procedure is access procedure (From : Natural; To : Natural);
-- A pointer to a procedure that moves the data item with index From to
-- the data item with index To. An index value of zero is used for moves
-- from and to the single temporary location used by the sort.
type Lt_Function is access function (Op1, Op2 : Natural) return Boolean;
-- A pointer to a function that compares two items and returns True if
-- the item with index Op1 is less than the item with index Op2, and False
-- if the Op1 item is greater than or equal to the Op2 item.
procedure Sort (N : Natural; Move : Move_Procedure; Lt : Lt_Function);
-- This procedures sorts items in the range from 1 to N into ascending
-- order making calls to Lt to do required comparisons, and Move to move
-- items around. Note that, as described above, both Move and Lt use a
-- single temporary location with index value zero. This sort is not
-- stable, i.e. the order of equal elements in the input is not preserved.
end GNAT.Heap_Sort_A;
|
-----------------------------------------------------------------------
-- gen-artifacts-xmi -- UML-XMI artifact for Code Generator
-- Copyright (C) 2012, 2013, 2014, 2016, 2021 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 DOM.Core;
with Gen.Model.Packages;
with Gen.Model.XMI;
with Util.Strings.Sets;
-- The <b>Gen.Artifacts.XMI</b> package is an artifact for the generation of Ada code
-- from an UML XMI description.
package Gen.Artifacts.XMI is
-- ------------------------------
-- UML XMI artifact
-- ------------------------------
type Artifact is new Gen.Artifacts.Artifact with private;
-- After the configuration file is read, processes the node whose root
-- is passed in <b>Node</b> and initializes the <b>Model</b> with the information.
overriding
procedure Initialize (Handler : in out Artifact;
Path : in String;
Node : in DOM.Core.Node;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Context : in out Generator'Class);
-- Prepare the model after all the configuration files have been read and before
-- actually invoking the generation.
overriding
procedure Prepare (Handler : in out Artifact;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Project : in out Gen.Model.Projects.Project_Definition'Class;
Context : in out Generator'Class);
-- Read the UML/XMI model file.
procedure Read_Model (Handler : in out Artifact;
File : in String;
Context : in out Generator'Class;
Is_Predefined : in Boolean := False);
private
-- Read the UML profiles that are referenced by the current models.
-- The UML profiles are installed in the UML config directory for dynamo's installation.
procedure Read_Profiles (Handler : in out Artifact;
Context : in out Generator'Class);
type Artifact is new Gen.Artifacts.Artifact with record
Nodes : aliased Gen.Model.XMI.UML_Model;
-- A set of profiles that are necessary for the model definitions.
Profiles : aliased Util.Strings.Sets.Set;
Has_Config : Boolean := False;
-- Stereotype which triggers the generation of database table.
Table_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
PK_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
FK_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
Data_Model_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
Nullable_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
Not_Null_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
Use_FK_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
Version_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
Auditable_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
-- Tag definitions which control the generation.
Has_List_Tag : Gen.Model.XMI.Tag_Definition_Element_Access;
Table_Name_Tag : Gen.Model.XMI.Tag_Definition_Element_Access;
Sql_Type_Tag : Gen.Model.XMI.Tag_Definition_Element_Access;
Generator_Tag : Gen.Model.XMI.Tag_Definition_Element_Access;
Literal_Tag : Gen.Model.XMI.Tag_Definition_Element_Access;
Sql_Length_Tag : Gen.Model.XMI.Tag_Definition_Element_Access;
-- Stereotype which triggers the generation of AWA bean types.
Bean_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
Limited_Bean_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
-- Stereotype which triggers the generation of serialization.
Serialize_Stereotype : Gen.Model.XMI.Stereotype_Element_Access;
end record;
end Gen.Artifacts.XMI;
|
-----------------------------------------------------------------------
-- awa-events -- AWA Events
-- Copyright (C) 2012, 2015, 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 ADO.Sessions.Entities;
package body AWA.Events is
-- ------------------------------
-- Set the event type which identifies the event.
-- ------------------------------
procedure Set_Event_Kind (Event : in out Module_Event;
Kind : in Event_Index) is
begin
Event.Kind := Kind;
end Set_Event_Kind;
-- ------------------------------
-- Get the event type which identifies the event.
-- ------------------------------
function Get_Event_Kind (Event : in Module_Event) return Event_Index is
begin
return Event.Kind;
end Get_Event_Kind;
-- ------------------------------
-- Set a parameter on the message.
-- ------------------------------
procedure Set_Parameter (Event : in out Module_Event;
Name : in String;
Value : in String) is
begin
Event.Props.Include (Name, Util.Beans.Objects.To_Object (Value));
end Set_Parameter;
procedure Set_Parameter (Event : in out Module_Event;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
Event.Props.Include (Name, Value);
end Set_Parameter;
-- ------------------------------
-- Get the parameter with the given name.
-- ------------------------------
function Get_Parameter (Event : in Module_Event;
Name : in String) return String is
Pos : constant Util.Beans.Objects.Maps.Cursor := Event.Props.Find (Name);
begin
if Util.Beans.Objects.Maps.Has_Element (Pos) then
return Util.Beans.Objects.To_String (Util.Beans.Objects.Maps.Element (Pos));
else
return "";
end if;
end Get_Parameter;
-- ------------------------------
-- Set the parameters of the message.
-- ------------------------------
procedure Set_Parameters (Event : in out Module_Event;
Parameters : in Util.Beans.Objects.Maps.Map) is
begin
Event.Props := Parameters;
end Set_Parameters;
-- ------------------------------
-- Get the value that corresponds to the parameter with the given name.
-- ------------------------------
function Get_Value (Event : in Module_Event;
Name : in String) return Util.Beans.Objects.Object is
begin
if Event.Props.Contains (Name) then
return Event.Props.Element (Name);
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Get the entity identifier associated with the event.
-- ------------------------------
function Get_Entity_Identifier (Event : in Module_Event) return ADO.Identifier is
begin
return Event.Entity;
end Get_Entity_Identifier;
-- ------------------------------
-- Set the entity identifier associated with the event.
-- ------------------------------
procedure Set_Entity_Identifier (Event : in out Module_Event;
Id : in ADO.Identifier) is
begin
Event.Entity := Id;
end Set_Entity_Identifier;
-- ------------------------------
-- Set the database entity associated with the event.
-- ------------------------------
procedure Set_Entity (Event : in out Module_Event;
Entity : in ADO.Objects.Object_Ref'Class;
Session : in ADO.Sessions.Session'Class) is
Key : constant ADO.Objects.Object_Key := Entity.Get_Key;
begin
Event.Entity := ADO.Objects.Get_Value (Key);
Event.Entity_Type := ADO.Sessions.Entities.Find_Entity_Type (Session, Key);
end Set_Entity;
-- ------------------------------
-- Copy the event properties to the map passed in <tt>Into</tt>.
-- ------------------------------
procedure Copy (Event : in Module_Event;
Into : in out Util.Beans.Objects.Maps.Map) is
begin
Into := Event.Props;
end Copy;
-- ------------------------------
-- Make and return a copy of the event.
-- ------------------------------
function Copy (Event : in Module_Event) return Module_Event_Access is
Result : constant Module_Event_Access := new Module_Event;
begin
Result.Kind := Event.Kind;
Result.Props := Event.Props;
return Result;
end Copy;
end AWA.Events;
|
pragma Ada_2012;
with Adventofcode.File_Line_Readers;
package body Adventofcode.Day_9 is
----------
-- Read --
----------
procedure Read (Self : in out Decoder; From_Path : String) is
begin
Self.Last := 0;
Self.Data := (others => 0);
for Line of Adventofcode.File_Line_Readers.Read_Lines (From_Path) loop
Self.Data (Self.Last + 1) := Long_Integer'Value (Line);
Self.Last := Self.Last + 1;
end loop;
end Read;
----------
-- Scan --
----------
procedure Scan
(Self : in out Decoder;
Premble_Size : Natural := 25;
Result : out Long_Integer)
is
Found : Boolean := False;
procedure Scan (Map : Data_Array; Target : Long_Integer) is
begin
for A in Map'Range loop
for B in Map'Range loop
if Map (A) /= Map (B) and then Map (A) + Map (B) = Target then
Found := True;
end if;
end loop;
end loop;
end;
begin
for Cursor in Premble_Size + 1 .. Self.Last loop
Found := False;
Scan (Self.Data (Cursor - Premble_Size .. Cursor - 1), Self.Data (Cursor));
if not Found then
Result := Self.Data (Cursor);
return;
end if;
end loop;
Result := -1;
end Scan;
procedure Scan2
(Self : in out Decoder;
Key : Long_Integer;
Result : out Long_Integer) is
begin
for Start_Cursor in Self.Data'First .. Self.Last loop
for End_Cursor in Start_Cursor + 1 .. Self.Last loop
declare
Sum : Long_Integer := 0;
begin
for Ix in Start_Cursor .. End_Cursor loop
Sum := Sum + Self.Data (Ix);
end loop;
if Sum = Key then
declare
Min : Long_Integer := Self.Data (Start_Cursor);
Max : Long_Integer := Self.Data (Start_Cursor);
begin
for I in Start_Cursor .. End_Cursor loop
Min := Long_Integer'Min (Min, Self.Data (I));
Max := Long_Integer'Max (Max, Self.Data (I));
end loop;
Result := Min + Max;
end;
end if;
end;
end loop;
end loop;
end Scan2;
end Adventofcode.Day_9;
|
function Grayscale (Picture : Image) return Grayscale_Image is
type Extended_Luminance is range 0..10_000_000;
Result : Grayscale_Image (Picture'Range (1), Picture'Range (2));
Color : Pixel;
begin
for I in Picture'Range (1) loop
for J in Picture'Range (2) loop
Color := Picture (I, J);
Result (I, J) :=
Luminance
( ( 2_126 * Extended_Luminance (Color.R)
+ 7_152 * Extended_Luminance (Color.G)
+ 722 * Extended_Luminance (Color.B)
)
/ 10_000
);
end loop;
end loop;
return Result;
end Grayscale;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
package body GL.Objects.Lists is
function Create (Raw : UInt_Array) return List is
begin
return List'(Count => Raw'Length, Contents => Raw);
end Create;
function First (Object : List) return Cursor is
begin
if Object.Count = 0 then
return No_Element;
else
return Cursor'(Object => Object'Unchecked_Access, Index => 1);
end if;
end First;
function Last (Object : List) return Cursor is
begin
if Object.Count = 0 then
return No_Element;
else
return Cursor'(Object => Object'Unchecked_Access,
Index => Object.Contents'Length);
end if;
end Last;
function Next (Current : Cursor) return Cursor is
begin
if Current = No_Element then
raise Constraint_Error;
elsif Current.Index = Current.Object.Contents'Length then
return No_Element;
else
return Cursor'(Current.Object, Current.Index + 1);
end if;
end Next;
function Previous (Current : Cursor) return Cursor is
begin
if Current = No_Element then
raise Constraint_Error;
elsif Current.Index = 1 then
return No_Element;
else
return Cursor'(Current.Object, Current.Index - 1);
end if;
end Previous;
function Has_Next (Current : Cursor) return Boolean is
begin
return Current /= No_Element and then
Current.Index /= Current.Object.Contents'Length;
end Has_Next;
function Has_Previous (Current : Cursor) return Boolean is
begin
return Current /= No_Element and then Current.Index /= 1;
end Has_Previous;
function Element (Current : Cursor) return Object_Type is
begin
if Current = No_Element then
raise Constraint_Error;
else
return Generate_From_Id (Current.Object.Contents (Current.Index));
end if;
end Element;
end GL.Objects.Lists;
|
with Ada.Text_IO;
with PrimeInstances;
package body Problem_41 is
package IO renames Ada.Text_IO;
package Positive_Primes renames PrimeInstances.Positive_Primes;
type Prime_Magnitude is new Positive range 1 .. 9;
procedure Solve is
gen : Positive_Primes.Prime_Generator := Positive_Primes.Make_Generator(Max_Prime => 7_654_321);
function Is_Pandigital_Prime(prime : Positive; magnitude : Prime_Magnitude) return Boolean is
type Used_Array is Array (1 .. magnitude) of Boolean;
used : Used_Array := (others => False);
all_used : constant Used_Array := (others => True);
quotient : Natural := Prime;
remainder : Natural range 0 .. 9;
begin
while quotient /= 0 loop
remainder := quotient mod 10;
quotient := quotient / 10;
if (remainder = 0 or remainder > Positive(magnitude)) or else used(Prime_Magnitude(remainder)) then
return False;
else
used(Prime_Magnitude(remainder)) := True;
end if;
exit when quotient = 0;
end loop;
return used = all_used;
end Is_Pandigital_Prime;
prime : Positive;
next_power_of_ten : Positive := 10;
magnitude : Prime_Magnitude := 1;
biggest : Positive := 1;
begin
loop
Positive_Primes.Next_Prime(gen, prime);
exit when prime = 1;
if prime >= next_power_of_ten then
next_power_of_ten := next_power_of_ten * 10;
magnitude := Prime_Magnitude'Succ(magnitude);
end if;
if Is_Pandigital_Prime(prime, magnitude) then
biggest := prime;
end if;
end loop;
IO.Put_Line(Positive'Image(biggest));
end Solve;
end Problem_41;
|
-- { dg-do compile }
-- { dg-options "-gnatws" }
with Discr15_Pkg; use Discr15_Pkg;
procedure Discr15 (History : in Rec_Multi_Moment_History) is
Sub: constant Rec_Multi_Moment_History := Sub_History_Of (History);
subtype Vec is String(0..Sub.Last);
Mmts : array(1..Sub.Size) of Vec;
begin
null;
end;
|
-----------------------------------------------------------------------
-- asf.beans -- Bean Registration and Factory
-- Copyright (C) 2009, 2010, 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 Util.Log.Loggers;
package body ASF.Beans is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Beans");
-- ------------------------------
-- Register under the name identified by <b>Name</b> the class instance <b>Class</b>.
-- ------------------------------
procedure Register_Class (Factory : in out Bean_Factory;
Name : in String;
Class : in Class_Binding_Access) is
begin
Log.Info ("Register bean class {0}", Name);
Factory.Registry.Include (Name, Class_Binding_Ref.Create (Class));
end Register_Class;
-- ------------------------------
-- Register under the name identified by <b>Name</b> a function to create a bean.
-- This is a simplified class registration.
-- ------------------------------
procedure Register_Class (Factory : in out Bean_Factory;
Name : in String;
Handler : in Create_Bean_Access) is
Class : constant Default_Class_Binding_Access := new Default_Class_Binding;
begin
Class.Create := Handler;
Register_Class (Factory, Name, Class.all'Access);
end Register_Class;
-- ------------------------------
-- Register the bean identified by <b>Name</b> and associated with the class <b>Class</b>.
-- The class must have been registered by using the <b>Register</b> class operation.
-- The scope defines the scope of the bean.
-- ------------------------------
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Class : in String;
Params : in Parameter_Bean_Ref.Ref;
Scope : in Scope_Type := REQUEST_SCOPE) is
begin
Log.Info ("Register bean '{0}' created by '{1}' in scope {2}",
Name, Class, Scope_Type'Image (Scope));
declare
Pos : constant Registry_Maps.Cursor := Factory.Registry.Find (Class);
Binding : Bean_Binding;
begin
if not Registry_Maps.Has_Element (Pos) then
Log.Error ("Class '{0}' does not exist. Cannot register bean '{1}'",
Class, Name);
return;
end if;
Binding.Create := Registry_Maps.Element (Pos);
Binding.Scope := Scope;
Binding.Params := Params;
Factory.Map.Include (Ada.Strings.Unbounded.To_Unbounded_String (Name), Binding);
end;
end Register;
-- ------------------------------
-- Register the bean identified by <b>Name</b> and associated with the class <b>Class</b>.
-- The class must have been registered by using the <b>Register</b> class operation.
-- The scope defines the scope of the bean.
-- ------------------------------
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Class : in Class_Binding_Access;
Params : in Parameter_Bean_Ref.Ref;
Scope : in Scope_Type := REQUEST_SCOPE) is
Binding : Bean_Binding;
begin
Log.Info ("Register bean '{0}' in scope {2}",
Name, Scope_Type'Image (Scope));
Binding.Create := Class_Binding_Ref.Create (Class);
Binding.Scope := Scope;
Binding.Params := Params;
Factory.Map.Include (Ada.Strings.Unbounded.To_Unbounded_String (Name), Binding);
end Register;
-- ------------------------------
-- Register all the definitions from a factory to a main factory.
-- ------------------------------
procedure Register (Factory : in out Bean_Factory;
From : in Bean_Factory) is
begin
declare
Pos : Registry_Maps.Cursor := From.Registry.First;
begin
while Registry_Maps.Has_Element (Pos) loop
Factory.Registry.Include (Key => Registry_Maps.Key (Pos),
New_Item => Registry_Maps.Element (Pos));
Registry_Maps.Next (Pos);
end loop;
end;
declare
Pos : Bean_Maps.Cursor := Bean_Maps.First (From.Map);
begin
while Bean_Maps.Has_Element (Pos) loop
Factory.Map.Include (Key => Bean_Maps.Key (Pos),
New_Item => Bean_Maps.Element (Pos));
Bean_Maps.Next (Pos);
end loop;
end;
end Register;
-- ------------------------------
-- Create a bean by using the create operation registered for the name
-- ------------------------------
procedure Create (Factory : in Bean_Factory;
Name : in Unbounded_String;
Context : in EL.Contexts.ELContext'Class;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Scope : out Scope_Type) is
use type Util.Beans.Basic.Readonly_Bean_Access;
Pos : constant Bean_Maps.Cursor := Factory.Map.Find (Name);
begin
if Bean_Maps.Has_Element (Pos) then
declare
Binding : constant Bean_Binding := Bean_Maps.Element (Pos);
begin
Binding.Create.Value.Create (Name, Result);
if Result /= null and then not Binding.Params.Is_Null then
if Result.all in Util.Beans.Basic.Bean'Class then
EL.Beans.Initialize (Util.Beans.Basic.Bean'Class (Result.all),
Binding.Params.Value.Params,
Context);
else
Log.Warn ("Bean {0} cannot be set with pre-defined properties as it does "
& "not implement the Bean interface", To_String (Name));
end if;
end if;
Scope := Binding.Scope;
end;
else
Result := null;
Scope := ANY_SCOPE;
end if;
end Create;
-- ------------------------------
-- Create a bean by using the registered create function.
-- ------------------------------
procedure Create (Factory : in Default_Class_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access) is
pragma Unreferenced (Name);
begin
Result := Factory.Create.all;
end Create;
end ASF.Beans;
|
package Opt9_Pkg is
N : integer := 15;
end Opt9_Pkg;
|
-- { dg-do compile }
package body Enclosing_Record_Reference is
R: aliased T;
function F1 (x: integer) return T is begin return R; end;
function F2 (x: T) return integer is begin return 0; end;
function F3 (x: T) return T is begin return R; end;
function F4 (x: integer) return access T is begin return R'access; end;
function F5 (x: access T) return integer is begin return 0; end;
function F6 (x: access T) return access T is begin return R'access; end;
function F7 (x: T) return access T is begin return R'access; end;
function F8 (x: access T) return T is begin return R; end;
begin
R.F1 := F1'Access;
R.F2 := F2'Access;
R.F3 := F3'Access;
R.F4 := F4'Access;
R.F5 := F5'Access;
R.F6 := F6'Access;
R.F7 := F7'Access;
R.F8 := F8'Access;
end Enclosing_Record_Reference;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Numerics.Big_Numbers.Big_Integers;
use Ada.Numerics.Big_Numbers.Big_Integers;
with Fibonacci;
with Perfect_Number;
with Primes;
with Aux_Image; use Aux_Image;
procedure Main is
package Fib renames Fibonacci;
package Pn renames Perfect_Number;
procedure Put_Elapsed (Tic : Time; Toc : Time := Clock) is
begin
Put_Line (" elapsed time: " & Duration'Image(Toc - Tic) & "s");
end Put_Elapsed;
Tic : Time;
begin
Put_Line ("Benchmark");
Put_Line ("=========");
New_Line;
Put_Line ("Fibonacci Numbers");
Put_Line ("-----------------");
Tic := Clock;
Put ("Fib_Naive (35) = " & Img (Fib.Fib_Naive (35)));
Put_Elapsed (Tic);
Tic := Clock;
Put ("Fib_Iter (1000) = " & Img (Fib.Fib_Iter (1000)));
Put_Elapsed (Tic);
Tic := Clock;
Put ("Fib_Recur (1000) = " & Img (Fib.Fib_Recur (1000)));
Put_Elapsed (Tic);
New_Line;
Put_Line ("Perfect Numbers");
Put_Line ("---------------");
Tic := Clock;
Put ("Perfect_Numbers (10000) = " & Img (Pn.Get_Perfect_Numbers (10000)));
Put_Elapsed (Tic);
New_line;
Put_Line ("Prime Numbers");
Put_Line ("-------------");
Tic := Clock;
Put ("Get_Primes (10000): (" & Img (Primes.Get_Primes (Integer (10_000))) & ")");
Put_Elapsed (Tic);
Tic := Clock;
Put ("Get_Primes (10000): (" & Img (Primes.Get_Primes (To_Big_Integer (10_000))) & ")");
Put_Elapsed (Tic);
New_Line;
end Main;
|
pragma Ada_2012;
with Brackelib.Stacks;
with Ada.Characters.Conversions;
package body Compiler.Parser is
type State is
(State_Start, State_Inside_Handlebars, State_Inside_Component_Declaration,
State_Inside_Complex_Comment, State_Inside_Simple_Comment);
package State_Stacks is new Brackelib.Stacks (T => State);
Parse_Error : exception;
procedure Raise_Error (TheNode : Node) is
Message : constant Wide_Wide_String :=
TheNode.TheToken'Wide_Wide_Image & " " & To_String (TheNode.TheValue);
Message2 : constant String :=
Ada.Characters.Conversions.To_String (Message);
begin
raise Parse_Error with Message2;
end Raise_Error;
-----------
-- Parse --
-----------
function Parse (AST_IN : List) return List is
State_Stack : State_Stacks.Stack;
Current_State : State := State_Start;
Current_Node : Node;
AST_Out : List;
procedure Restore_State is
Old_State : constant State := Current_State;
begin
if State_Stacks.Is_Empty (State_Stack) then
Current_State := State_Start;
else
Current_State := State_Stacks.Pop (State_Stack);
if Old_State = Current_State then
Current_State := State_Stacks.Pop (State_Stack);
else
null; --Raise_Error();
end if;
end if;
exception
when State_Stacks.Stack_Empty =>
Current_State := State_Start;
end Restore_State;
Inside_Comment_And_Not_Closing : Boolean := false;
begin
for E of AST_In loop
if Current_State = State_Inside_Complex_Comment and then
E.TheToken = Keyword_Complex_Comment_End then
Restore_State;
elsif Current_State = State_Inside_Simple_Comment
and then E.TheToken = Keyword_Identifier_Closing then
Restore_State;
else
case E.TheToken is
when Keyword_Web =>
AST_Out.Append (E);
when Keyword_Identifier_Opening =>
AST_Out.Append (E);
Current_Node := E;
Current_Node.Component := False;
State_Stacks.Push (State_Stack, State_Inside_Handlebars);
Current_State := State_Inside_Handlebars;
when Keyword_Tag_Start =>
AST_Out.Append (E);
State_Stacks.Push (State_Stack, State_Inside_Component_Declaration);
Current_Node := E;
Current_Node.Component := True;
Current_State := State_Inside_Component_Declaration;
when Keyword_Complex_Comment_Start =>
if Current_State = State_Inside_Handlebars then
AST_Out.Delete_Last;
State_Stacks.Push (State_Stack, State_Inside_Complex_Comment);
Current_State := State_Inside_Complex_Comment;
else
-- error
null;
end if;
when Keyword_Simple_Comment_Start =>
if Current_State = State_Inside_Handlebars then
AST_Out.Delete_Last;
State_Stacks.Push (State_Stack, State_Inside_Simple_Comment);
Current_State := State_Inside_Simple_Comment;
else
-- error
null;
end if;
when Attribute_Symbol =>
AST_Out.Append (E);
when Assignment_Symbol =>
AST_Out.Append (E);
when Quotation_Symbol =>
AST_Out.Append (E);
when Blockparam_Symbol =>
AST_Out.Append (E);
when Identifier =>
if Current_Node.TheToken /= No_Token and then Current_Node.TheName.Length = 0 then
Current_Node.TheName := E.TheValue;
else
AST_Out.Append (E);
end if;
when Keyword_Block_Start =>
if Current_Node.TheToken /= No_Token then
Current_Node.Block := true;
end if;
when Keyword_Identifier_Closing =>
if Current_Node.TheToken /= No_Token then
if not Current_Node.Block then
-- not a block helper - there is no need to remember state
Restore_State;
end if;
else
-- error
null;
end if;
Current_Node.TheToken := No_Token;
AST_Out.Append (E);
when Keyword_Tag_Closing_End =>
if Current_Node.TheToken /= No_Token then
-- Tag is closed - there is no need to remember state
Restore_State;
else
-- error
null;
end if;
AST_Out.Append (E);
when Keyword_Tag_Close =>
if Current_Node.TheToken /= No_Token then
Current_Node.Closing := True;
else
-- error
null;
end if;
when Keyword_Tag_End =>
if Current_Node.TheToken /= No_Token then
if not Current_Node.Component then
-- error
null;
end if;
end if;
Current_Node.TheToken := No_Token;
AST_Out.Append (E);
when KEYWORD_BLOCK_CLOSE =>
if Current_Node.TheToken /= No_Token then
Current_Node.BlockClosing := True;
else
-- error
null;
end if;
when KEYWORD_COMPLEX_COMMENT_END => null;
when Keyword_Comment => null;
when others =>
Raise_Error (E);
end case;
end if;
end loop;
return AST_Out;
end Parse;
end Compiler.Parser;
|
-----------------------------------------------------------------------
-- keystore-repository -- Repository management for the keystore
-- Copyright (C) 2019, 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.Calendar;
with Ada.Streams;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Strings.Hash;
with Util.Encoders.AES;
with Keystore.IO;
with Keystore.Keys;
with Keystore.Passwords;
with Util.Streams;
with Interfaces;
with Keystore.Buffers;
private with Keystore.Random;
private with Ada.Finalization;
limited private with Keystore.Repository.Workers;
private package Keystore.Repository is
type Wallet_Repository is tagged limited private;
function Get_Identifier (Repository : in Wallet_Repository) return Wallet_Identifier;
-- Open the wallet repository by reading the meta data block header from the wallet
-- IO stream. The wallet meta data is decrypted using AES-CTR using the given secret
-- key and initial vector.
procedure Open (Repository : in out Wallet_Repository;
Config : in Keystore.Wallet_Config;
Ident : in Wallet_Identifier;
Stream : in IO.Wallet_Stream_Access);
procedure Open (Repository : in out Wallet_Repository;
Name : in String;
Password : in out Keystore.Passwords.Provider'Class;
Keys : in out Keystore.Keys.Key_Manager;
Master_Block : in out Keystore.IO.Storage_Block;
Master_Ident : in out Wallet_Identifier;
Wallet : in out Wallet_Repository);
procedure Create (Repository : in out Wallet_Repository;
Password : in out Keystore.Passwords.Provider'Class;
Config : in Wallet_Config;
Block : in IO.Storage_Block;
Ident : in Wallet_Identifier;
Keys : in out Keystore.Keys.Key_Manager;
Stream : in IO.Wallet_Stream_Access);
procedure Unlock (Repository : in out Wallet_Repository;
Password : in out Keystore.Passwords.Provider'Class;
Block : in Keystore.IO.Storage_Block;
Keys : in out Keystore.Keys.Key_Manager);
procedure Add (Repository : in out Wallet_Repository;
Name : in String;
Kind : in Entry_Type;
Content : in Ada.Streams.Stream_Element_Array);
procedure Add (Repository : in out Wallet_Repository;
Name : in String;
Kind : in Entry_Type;
Input : in out Util.Streams.Input_Stream'Class);
procedure Add_Wallet (Repository : in out Wallet_Repository;
Name : in String;
Password : in out Keystore.Passwords.Provider'Class;
Keys : in out Keystore.Keys.Key_Manager;
Master_Block : in out Keystore.IO.Storage_Block;
Master_Ident : in out Wallet_Identifier;
Wallet : in out Wallet_Repository);
procedure Set (Repository : in out Wallet_Repository;
Name : in String;
Kind : in Entry_Type;
Content : in Ada.Streams.Stream_Element_Array);
procedure Set (Repository : in out Wallet_Repository;
Name : in String;
Kind : in Entry_Type;
Input : in out Util.Streams.Input_Stream'Class);
procedure Update (Repository : in out Wallet_Repository;
Name : in String;
Kind : in Entry_Type;
Content : in Ada.Streams.Stream_Element_Array);
procedure Update (Repository : in out Wallet_Repository;
Name : in String;
Kind : in Entry_Type;
Input : in out Util.Streams.Input_Stream'Class);
procedure Delete (Repository : in out Wallet_Repository;
Name : in String);
function Contains (Repository : in Wallet_Repository;
Name : in String) return Boolean;
procedure Find (Repository : in out Wallet_Repository;
Name : in String;
Result : out Entry_Info);
procedure Get_Data (Repository : in out Wallet_Repository;
Name : in String;
Result : out Entry_Info;
Output : out Ada.Streams.Stream_Element_Array);
-- Write in the output stream the named entry value from the wallet.
procedure Get_Data (Repository : in out Wallet_Repository;
Name : in String;
Output : in out Util.Streams.Output_Stream'Class);
procedure Read (Repository : in out Wallet_Repository;
Name : in String;
Offset : in Ada.Streams.Stream_Element_Offset;
Content : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write (Repository : in out Wallet_Repository;
Name : in String;
Offset : in Ada.Streams.Stream_Element_Offset;
Content : in Ada.Streams.Stream_Element_Array);
-- Get the list of entries contained in the wallet that correspond to the optional filter.
procedure List (Repository : in out Wallet_Repository;
Filter : in Filter_Type;
Content : out Entry_Map);
procedure List (Repository : in out Wallet_Repository;
Pattern : in GNAT.Regpat.Pattern_Matcher;
Filter : in Filter_Type;
Content : out Entry_Map);
-- Get the key slot number that was used to unlock the keystore.
function Get_Key_Slot (Repository : in Wallet_Repository) return Key_Slot;
-- Get stats information about the wallet (the number of entries, used key slots).
procedure Fill_Stats (Repository : in Wallet_Repository;
Stats : in out Wallet_Stats);
procedure Set_Work_Manager (Repository : in out Wallet_Repository;
Workers : in Keystore.Task_Manager_Access);
procedure Close (Repository : in out Wallet_Repository);
private
use Ada.Streams;
function AES_Align (Size : in Stream_Element_Offset) return Stream_Element_Offset
renames Util.Encoders.AES.Align;
ET_WALLET_ENTRY : constant := 16#0001#;
ET_STRING_ENTRY : constant := 16#0010#;
ET_BINARY_ENTRY : constant := 16#0200#;
WALLET_ENTRY_SIZE : constant := 4 + 2 + 8 + 32 + 16 + 4;
DATA_NAME_ENTRY_SIZE : constant := 4 + 2 + 2 + 8 + 8 + 8;
DATA_KEY_HEADER_SIZE : constant := 4 + 2 + 4;
DATA_KEY_ENTRY_SIZE : constant := 4 + 4 + 2 + 16 + 32;
DATA_KEY_SEPARATOR : constant := 4;
DATA_IV_OFFSET : constant := 32;
DATA_ENTRY_SIZE : constant := 4 + 2 + 2 + 8 + 32;
DATA_MAX_SIZE : constant := IO.Block_Size - IO.BT_HMAC_HEADER_SIZE
- IO.BT_TYPE_HEADER_SIZE - DATA_ENTRY_SIZE;
DATA_MAX_KEY_COUNT : constant := (DATA_MAX_SIZE - DATA_KEY_HEADER_SIZE) / DATA_KEY_ENTRY_SIZE;
function Hash (Value : in Wallet_Entry_Index) return Ada.Containers.Hash_Type;
type Wallet_Entry;
type Wallet_Entry_Access is access all Wallet_Entry;
type Wallet_Directory_Entry;
type Wallet_Directory_Entry_Access is access Wallet_Directory_Entry;
type Wallet_Data_Key_Entry is record
Directory : Wallet_Directory_Entry_Access;
Size : Stream_Element_Offset;
end record;
package Wallet_Data_Key_List is
new Ada.Containers.Doubly_Linked_Lists (Element_Type => Wallet_Data_Key_Entry,
"=" => "=");
type Wallet_Directory_Entry is record
Block : Keystore.IO.Storage_Block;
Available : IO.Buffer_Size := IO.Block_Index'Last - IO.BT_DATA_START - 4 - 2;
Last_Pos : IO.Block_Index := IO.BT_DATA_START + 4 + 2;
Key_Pos : IO.Block_Index := IO.Block_Index'Last;
Next_Block : Interfaces.Unsigned_32 := 0;
Count : Natural := 0;
Ready : Boolean := False;
end record;
type Wallet_Entry (Length : Natural;
Is_Wallet : Boolean) is
limited record
-- The block header that contains this entry.
Header : Wallet_Directory_Entry_Access;
Id : Wallet_Entry_Index;
Kind : Entry_Type := T_INVALID;
Create_Date : Ada.Calendar.Time;
Update_Date : Ada.Calendar.Time;
Access_Date : Ada.Calendar.Time;
Entry_Offset : IO.Block_Index := IO.Block_Index'First;
-- List of data key blocks.
Data_Blocks : Wallet_Data_Key_List.List;
Block_Count : Natural := 0;
Name : aliased String (1 .. Length);
case Is_Wallet is
when True =>
Wallet_Id : Wallet_Identifier;
Master : IO.Block_Number;
when False =>
Size : Interfaces.Unsigned_64 := 0;
end case;
end record;
package Wallet_Directory_List is
new Ada.Containers.Doubly_Linked_Lists (Element_Type => Wallet_Directory_Entry_Access,
"=" => "=");
package Wallet_Maps is
new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => Wallet_Entry_Access,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");
package Wallet_Indexs is
new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => Wallet_Entry_Index,
Element_Type => Wallet_Entry_Access,
Hash => Hash,
Equivalent_Keys => "=",
"=" => "=");
type Wallet_Worker_Access is access all Keystore.Repository.Workers.Wallet_Worker;
type Wallet_Repository is limited new Ada.Finalization.Limited_Controlled with record
Parent : access Wallet_Repository;
Id : Wallet_Identifier;
Next_Id : Wallet_Entry_Index;
Next_Wallet_Id : Wallet_Identifier;
Directory_List : Wallet_Directory_List.List;
Root : IO.Storage_Block;
IV : Util.Encoders.AES.Word_Block_Type;
Config : Keystore.Keys.Wallet_Config;
Map : Wallet_Maps.Map;
Entry_Indexes : Wallet_Indexs.Map;
Random : Keystore.Random.Generator;
Current : IO.Marshaller;
Workers : Wallet_Worker_Access;
Cache : Buffers.Buffer_Map;
Modified : Buffers.Buffer_Map;
Stream : Keystore.IO.Wallet_Stream_Access;
end record;
overriding
procedure Finalize (Manager : in out Wallet_Repository);
end Keystore.Repository;
|
procedure Ranges is
type Small is range 0E1 .. 1E2;
begin
null;
end Ranges;
|
package body Generic_Queue with SPARK_Mode is
-- Buffer Structure:
-- | 0:X | 1:– | 2:– | 3:– |
-- ^h ^t
-- head(h) points to oldest, tail(t) to next free,
-- empty: t=h, full: t=h => Flag Self.hasElements required
---------------
-- copy_array
---------------
procedure copy_array (Self : in Buffer_Tag; elements : out Element_Array) with
Pre'Class => Self.Length >= elements'Length,
Post'Class => Self.Length = Self.Length'Old,
Global => null;
-- copies n front elements from Self to elements, where n=elements'length
procedure copy_array (Self : in Buffer_Tag; elements : out Element_Array) is
pos : Index_Type := Self.index_head;
begin
for e in elements'Range loop
elements (e) := Self.Buffer (pos);
pos := pos + 1; -- mod type. Does the right thing.
end loop;
end copy_array;
-----------
-- Length
-----------
function Length( Self : in Buffer_Tag ) return Length_Type is
begin
if Self.Full then
return Length_Type'Last;
else
return Length_Type( Index_Type(Self.index_tail - Self.index_head) );
end if;
end Length;
--------
-- Full
--------
function Full( Self : in Buffer_Tag ) return Boolean is ((Self.index_tail = Self.index_head) and Self.hasElements);
---------
-- Empty
---------
function Empty( Self : in Buffer_Tag ) return Boolean is (not Self.hasElements);
----------
-- clear
----------
procedure clear( Self : in out Buffer_Tag ) is
begin
Self.index_head := Index_Type'First;
Self.index_tail := Index_Type'First;
Self.hasElements := False;
end clear;
----------
-- fill
----------
-- procedure fill( Self : in out Buffer_Tag ) is
-- begin
-- Self.index_tail := Self.index_head;
-- Self.hasElements := True;
-- end fill;
-------------
-- push_back
-------------
procedure push_back( Self : in out Buffer_Tag; element : Element_Type) is
begin
if Self.Full then -- overflow
Self.index_head := Index_Type'Succ( Self.index_head );
if Self.Num_Overflows < Natural'Last then
Self.Num_Overflows := Self.Num_Overflows + 1;
end if;
end if;
Self.Buffer( Self.index_tail) := element;
Self.index_tail := Index_Type'Succ( Self.index_tail );
Self.hasElements := True;
end push_back;
--------------
-- push_front
--------------
procedure push_front( Self : in out Buffer_Tag; element : Element_Type ) is
begin
if Self.Full then -- overflow
Self.index_tail := Index_Type'Pred( Self.index_tail );
if Self.Num_Overflows < Natural'Last then
Self.Num_Overflows := Self.Num_Overflows + 1;
end if;
end if;
Self.index_head := Index_Type'Pred( Self.index_head );
Self.Buffer( Self.index_head) := element;
Self.hasElements := True;
end push_front;
-------------
-- pop_front
-------------
procedure pop_front( Self : in out Buffer_Tag; element : out Element_Type) is
begin
element := Self.Buffer( Self.index_head);
Self.index_head := Index_Type'Succ( Self.index_head );
if Self.index_tail = Self.index_head then
Self.hasElements := False;
end if;
end pop_front;
procedure pop_front( Self : in out Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
Self.index_head := Self.index_head + Index_Type'Mod (elements'Length);
if Self.index_tail = Self.index_head then
Self.hasElements := False;
end if;
end pop_front;
-- entry pop_front_blocking( Self : in out Buffer_Tag; element : out Element_Type ) when Self.hasElements is
-- begin
-- element := Self.Buffer( Self.index_head);
-- Self.index_head := Index_Type'Succ( Self.index_head );
-- if Self.index_tail = Self.index_head then
-- Self.hasElements := False;
-- end if;
-- end pop_front_blocking;
------------
-- pop_back
------------
procedure pop_back( Self : in out Buffer_Tag; element : out Element_Type) is
begin
Self.index_tail := Index_Type'Pred( Self.index_tail );
element := Self.Buffer( Self.index_tail);
if Self.index_tail = Self.index_head then
Self.hasElements := False;
end if;
end pop_back;
-----------
-- pop_all
-----------
procedure pop_all( Self : in out Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
Self.index_tail := 0;
Self.index_head := 0;
Self.hasElements := False;
end pop_all;
-----------
-- get_all
-----------
procedure get_all( Self : in Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
end get_all;
-------------
-- get_front
-------------
procedure get_front( Self : in Buffer_Tag; element : out Element_Type ) is
begin
element := Self.Buffer( Self.index_head );
end get_front;
procedure get_front( Self : in Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
end get_front;
-------------
-- get_back
-------------
procedure get_back( Self : in Buffer_Tag; element : out Element_Type ) is
begin
element := Self.Buffer( Self.index_tail - 1 );
end get_back;
-- FIXME: remove this function?
-- function get_at( Self : in out Buffer_Tag; index : Index_Type ) return Element_Type is
-- begin
-- pragma Assert ( Self.index_head <= index and index < Self.index_tail );
-- return Self.Buffer( index );
-- end get_at;
-----------------
-- get_nth_first
-----------------
procedure get_nth_first( Self : in Buffer_Tag; nth : Index_Type; element : out Element_Type) is
begin
pragma Assert ( Self.index_head <= Self.index_tail-1 - nth );
element := Self.Buffer( Self.index_tail-1 - nth );
end get_nth_first;
----------------
-- get_nth_last
----------------
procedure get_nth_last( Self : in Buffer_Tag; nth : Index_Type; element : out Element_Type) is
begin
pragma Assert ( Self.index_head + nth <= Self.index_tail-1 );
element := Self.Buffer( Self.index_head + nth );
end get_nth_last;
function Overflows( Self : in Buffer_Tag ) return Natural is
begin
return Self.Num_Overflows;
end Overflows;
end Generic_Queue;
|
with Lv.Hal.Indev;
with Lv.Objx;
with Lv.Area;
with Lv.Group;
package Lv.Indev is
-- Initialize the display input device subsystem
procedure Init;
-- Get the currently processed input device. Can be used in action functions too.
-- @return pointer to the currently processed input device or NULL if no input device processing right now
function Get_Act return Lv.Hal.Indev.Indev_T;
-- Get the type of an input device
-- @param indev pointer to an input device
-- @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`)
function Get_Type
(Indev : Lv.Hal.Indev.Indev_T)
return Lv.Hal.Indev.Indev_Type_T;
-- Reset one or all input devices
-- @param indev pointer to an input device to reset or NULL to reset all of them
procedure Reset (Indev : Lv.Hal.Indev.Indev_T);
-- Reset the long press state of an input device
-- @param indev_proc pointer to an input device
procedure Reset_Lpr (Indev_Proc : Lv.Hal.Indev.Indev_T);
-- Enable input devices device by type
-- @param type Input device type
-- @param enable true: enable this type; false: disable this type
procedure Enable (Type_P : Lv.Hal.Indev.Indev_Type_T;
Enable : U_Bool); -- lv_indev.h:68
-- Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON)
-- @param indev pointer to an input device
-- @param cur_obj pointer to an object to be used as cursor
procedure Set_Cursor (Indev : Lv.Hal.Indev.Indev_T;
Cur_Obj : Lv.Objx.Obj_T);
-- Set a destination group for a keypad input device (for LV_INDEV_TYPE_KEYPAD)
-- @param indev pointer to an input device
-- @param group point to a group
procedure Set_Group (Indev : LV.HAL.Indev.Indev_T;
Group : LV.Group.Instance);
-- Set the an array of points for LV_INDEV_TYPE_BUTTON.
-- These points will be assigned to the buttons to press a specific point on the screen
-- @param indev pointer to an input device
-- @param group point to a group
procedure Set_Button_Points
(Indev : Lv.Hal.Indev.Indev_T;
Group : access Lv.Area.Point_T);
-- Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
-- @param indev pointer to an input device
-- @param point pointer to a point to store the result
procedure Get_Point
(Indev : Lv.Hal.Indev.Indev_T;
Point : access Lv.Area.Point_T);
-- Get the last key of an input device (for LV_INDEV_TYPE_KEYPAD)
-- @param indev pointer to an input device
-- @return the last pressed key (0 on error)
function Get_Key
(Indev : Lv.Hal.Indev.Indev_T) return Uint32_T;
-- Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
-- @param indev pointer to an input device
-- @return true: drag is in progress
function Is_Dragging
(Indev: Lv.Hal.Indev.Indev_T) return U_Bool;
-- Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
-- @param indev pointer to an input device
-- @param point pointer to a point to store the vector
procedure Get_Vect
(Indev : Lv.Hal.Indev.Indev_T;
Point : access Lv.Area.Point_T);
-- Get elapsed time since last press
-- @param indev pointer to an input device (NULL to get the overall smallest inactivity)
-- @return Elapsed ticks (milliseconds) since last press
function Get_Inactive_Time
(Indev : Lv.Hal.Indev.Indev_T) return Uint32_T;
-- Do nothing until the next release
-- @param indev pointer to an input device
procedure Wait_Release (Indev : Lv.Hal.Indev.Indev_T);
-------------
-- Imports --
-------------
pragma Import (C, Init, "lv_indev_init");
pragma Import (C, Get_Act, "lv_indev_get_act");
pragma Import (C, Get_Type, "lv_indev_get_type");
pragma Import (C, Reset, "lv_indev_reset");
pragma Import (C, Reset_Lpr, "lv_indev_reset_lpr");
pragma Import (C, Enable, "lv_indev_enable");
pragma Import (C, Set_Cursor, "lv_indev_set_cursor");
pragma Import (C, Set_Group, "lv_indev_set_group");
pragma Import (C, Set_Button_Points, "lv_indev_set_button_points");
pragma Import (C, Get_Point, "lv_indev_get_point");
pragma Import (C, Get_Key, "lv_indev_get_key");
pragma Import (C, Is_Dragging, "lv_indev_is_dragging");
pragma Import (C, Get_Vect, "lv_indev_get_vect");
pragma Import (C, Get_Inactive_Time, "lv_indev_get_inactive_time");
pragma Import (C, Wait_Release, "lv_indev_wait_release");
end Lv.Indev;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ C H 4 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. 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. --
-- --
------------------------------------------------------------------------------
-- Expand routines for chapter 4 constructs
with Types; use Types;
package Exp_Ch4 is
procedure Expand_N_Allocator (N : Node_Id);
procedure Expand_N_And_Then (N : Node_Id);
procedure Expand_N_Case_Expression (N : Node_Id);
procedure Expand_N_Explicit_Dereference (N : Node_Id);
procedure Expand_N_Expression_With_Actions (N : Node_Id);
procedure Expand_N_If_Expression (N : Node_Id);
procedure Expand_N_In (N : Node_Id);
procedure Expand_N_Indexed_Component (N : Node_Id);
procedure Expand_N_Not_In (N : Node_Id);
procedure Expand_N_Null (N : Node_Id);
procedure Expand_N_Op_Abs (N : Node_Id);
procedure Expand_N_Op_Add (N : Node_Id);
procedure Expand_N_Op_And (N : Node_Id);
procedure Expand_N_Op_Concat (N : Node_Id);
procedure Expand_N_Op_Divide (N : Node_Id);
procedure Expand_N_Op_Expon (N : Node_Id);
procedure Expand_N_Op_Eq (N : Node_Id);
procedure Expand_N_Op_Ge (N : Node_Id);
procedure Expand_N_Op_Gt (N : Node_Id);
procedure Expand_N_Op_Le (N : Node_Id);
procedure Expand_N_Op_Lt (N : Node_Id);
procedure Expand_N_Op_Minus (N : Node_Id);
procedure Expand_N_Op_Mod (N : Node_Id);
procedure Expand_N_Op_Multiply (N : Node_Id);
procedure Expand_N_Op_Ne (N : Node_Id);
procedure Expand_N_Op_Not (N : Node_Id);
procedure Expand_N_Op_Or (N : Node_Id);
procedure Expand_N_Op_Plus (N : Node_Id);
procedure Expand_N_Op_Rem (N : Node_Id);
procedure Expand_N_Op_Rotate_Left (N : Node_Id);
procedure Expand_N_Op_Rotate_Right (N : Node_Id);
procedure Expand_N_Op_Shift_Left (N : Node_Id);
procedure Expand_N_Op_Shift_Right (N : Node_Id);
procedure Expand_N_Op_Shift_Right_Arithmetic (N : Node_Id);
procedure Expand_N_Op_Subtract (N : Node_Id);
procedure Expand_N_Op_Xor (N : Node_Id);
procedure Expand_N_Or_Else (N : Node_Id);
procedure Expand_N_Qualified_Expression (N : Node_Id);
procedure Expand_N_Quantified_Expression (N : Node_Id);
procedure Expand_N_Selected_Component (N : Node_Id);
procedure Expand_N_Slice (N : Node_Id);
procedure Expand_N_Type_Conversion (N : Node_Id);
procedure Expand_N_Unchecked_Expression (N : Node_Id);
procedure Expand_N_Unchecked_Type_Conversion (N : Node_Id);
function Expand_Record_Equality
(Nod : Node_Id;
Typ : Entity_Id;
Lhs : Node_Id;
Rhs : Node_Id;
Bodies : List_Id)
return Node_Id;
-- Expand a record equality into an expression that compares the fields
-- individually to yield the required Boolean result. Loc is the
-- location for the generated nodes. Typ is the type of the record, and
-- Lhs, Rhs are the record expressions to be compared, these
-- expressions need not to be analyzed but have to be side-effect free.
-- Bodies is a list on which to attach bodies of local functions that
-- are created in the process. This is the responsibility of the caller
-- to insert those bodies at the right place. Nod provides the Sloc
-- value for generated code.
procedure Expand_Set_Membership (N : Node_Id);
-- For each choice of a set membership, we create a simple equality or
-- membership test. The whole membership is rewritten connecting these
-- with OR ELSE.
function Integer_Promotion_Possible (N : Node_Id) return Boolean;
-- Returns true if the node is a type conversion whose operand is an
-- arithmetic operation on signed integers, and the base type of the
-- signed integer type is smaller than Standard.Integer. In such case we
-- have special circuitry in Expand_N_Type_Conversion to promote both of
-- the operands to type Integer.
end Exp_Ch4;
|
with Ada.Numerics.Generic_Elementary_Functions;
package body Decomposition is
package Math is new Ada.Numerics.Generic_Elementary_Functions
(Matrix.Real);
procedure Decompose (A : Matrix.Real_Matrix; L : out Matrix.Real_Matrix) is
use type Matrix.Real_Matrix, Matrix.Real;
Order : constant Positive := A'Length (1);
S : Matrix.Real;
begin
L := (others => (others => 0.0));
for I in 0 .. Order - 1 loop
for K in 0 .. I loop
S := 0.0;
for J in 0 .. K - 1 loop
S := S +
L (L'First (1) + I, L'First (2) + J) *
L (L'First (1) + K, L'First (2) + J);
end loop;
-- diagonals
if K = I then
L (L'First (1) + K, L'First (2) + K) :=
Math.Sqrt (A (A'First (1) + K, A'First (2) + K) - S);
else
L (L'First (1) + I, L'First (2) + K) :=
1.0 / L (L'First (1) + K, L'First (2) + K) *
(A (A'First (1) + I, A'First (2) + K) - S);
end if;
end loop;
end loop;
end Decompose;
end Decomposition;
|
with Ada.Text_IO;
procedure Maze_Solver is
X_Size: constant Natural := 45;
Y_Size: constant Natural := 17;
subtype X_Range is Natural range 1 .. X_Size;
subtype Y_Range is Natural range 1 .. Y_Size;
East: constant X_Range := 2;
South: constant Y_Range := 1;
X_Start: constant X_Range := 3; -- start at the upper left
Y_Start: constant Y_Range := 1;
X_Finish: constant X_Range := X_Size-East; -- go to the lower right
Y_Finish: constant Y_Range := Y_Size;
type Maze_Type is array (Y_Range) of String(X_Range);
function Solved(X: X_Range; Y: Y_Range) return Boolean is
begin
return (X = X_Finish) and (Y = Y_Finish);
end Solved;
procedure Output_Maze(M: Maze_Type; Message: String := "") is
begin
if Message /= "" then
Ada.Text_IO.Put_Line(Message);
end if;
for I in M'Range loop
Ada.Text_IO.Put_Line(M(I));
end loop;
end Output_Maze;
procedure Search(M: in out Maze_Type; X: X_Range; Y:Y_Range) is
begin
M(Y)(X) := '*';
if Solved(X, Y) then
Output_Maze(M, "Solution found!");
else
if Integer(Y)-South >= 1 and then M(Y-South)(X) = ' ' then
Search(M, X, Y-South);
end if;
if Integer(Y)+South <= Y_Size and then M(Y+South)(X) = ' ' then
Search(M, X, Y+South);
end if;
if Integer(X)-East >= 1 and then M(Y)(X-East) = ' ' then
Search(M, X-East, Y);
end if;
if Integer(Y)+East <= Y_Size and then M(Y)(X+East) = ' ' then
Search(M, X+East, Y);
end if;
end if;
M(Y)(X) := ' ';
end Search;
Maze: Maze_Type;
X: X_Range := X_Start;
Y: Y_Range := Y_Start;
begin
for I in 1 .. Y_Size loop
Maze(I) := Ada.Text_IO.Get_Line;
end loop;
Maze(Y_Start)(X_Start) := ' '; -- Start from
Maze(Y_Finish)(X_Finish) := ' '; -- Go_To
Output_Maze(Maze, "The Maze:");
Ada.Text_IO.New_Line;
Search(Maze, X, Y) ; -- Will output *all* Solutions.
-- If there is no output, there is no solution.
end Maze_Solver;
|
with
openGL.Visual,
openGL.Demo,
openGL.Model.terrain;
procedure launch_Model_scaling
--
-- Exercise the scaling of models.
--
is
use openGL,
openGL.Math,
openGL.linear_Algebra_3d;
begin
Demo.print_Usage;
Demo.define ("openGL 'Model Scaling' Demo");
Demo.Camera.Position_is ((0.0, 0.0, 20.0),
y_Rotation_from (to_Radians (0.0)));
declare
-- The models.
--
the_Models : constant openGL.Model.views := openGL.Demo.Models;
-- The visuals.
--
the_Visuals : openGL.Visual.views (the_Models'Range);
ground_Id : Positive;
-- Scaling
--
scaling_Up : Boolean := True;
Scale : math.Vector_3 := (1.0, 1.0, 1.0);
begin
for i in the_Visuals'Range
loop
the_Visuals (i) := Visual.Forge.new_Visual (the_Models (i));
if the_Models (i).all in openGL.Model.terrain.item'Class
then
ground_Id := i;
end if;
end loop;
Demo.layout (the_Visuals);
the_Visuals (ground_Id).Site_is (the_Visuals (ground_Id).Site_of + (0.0, -15.0, 0.0));
-- Main loop.
--
while not Demo.Done
loop
if scaling_Up then Scale := Scale + (0.001, 0.001, 0.001);
else Scale := Scale - (0.001, 0.001, 0.001);
end if;
if Scale (1) > 2.0 then scaling_Up := False;
elsif Scale (1) < 0.002 then scaling_Up := True;
end if;
for Each of the_Visuals
loop
Each.Scale_is (Scale);
end loop;
-- Handle user commands.
--
Demo.Dolly.evolve;
Demo.Done := Demo.Dolly.quit_Requested;
-- Render the sprites.
--
Demo.Camera.render (the_Visuals);
while not Demo.Camera.cull_Completed
loop
delay Duration'Small;
end loop;
Demo.Renderer.render;
Demo.FPS_Counter.increment; -- Frames per second display.
end loop;
end;
Demo.destroy;
end launch_Model_scaling;
|
-- { dg-do compile }
-- { dg-options "-O -gnatn" }
package body Atomic4 is
procedure Next (Self : in out Reader'Class) is
begin
Self.Current_Reference := Self.Reference_Stack.Last_Element;
Self.Reference_Stack.Delete_Last;
end Next;
end Atomic4;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 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.
with Ada.Directories;
with DCF.Streams;
with DCF.Unzip.Streams;
with DCF.Zip;
package body Orka.Resources.Locations.Archives is
type Byte_Stream_Writer
(Bytes : Byte_Array_Access)
is new Ada.Streams.Root_Stream_Type with record
Index : Ada.Streams.Stream_Element_Offset := Bytes'First;
end record;
overriding procedure Read
(Stream : in out Byte_Stream_Writer;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is null;
overriding procedure Write
(Stream : in out Byte_Stream_Writer;
Item : in Ada.Streams.Stream_Element_Array)
is
use type Ada.Streams.Stream_Element_Offset;
begin
Stream.Bytes (Stream.Index .. Stream.Index + Item'Length - 1) := Item;
Stream.Index := Stream.Index + Item'Length;
end Write;
-----------------------------------------------------------------------------
type Archive_Location is limited new Location with record
Stream : aliased DCF.Streams.File_Zipstream;
Archive : DCF.Zip.Zip_Info;
end record;
overriding
function Exists (Object : Archive_Location; Path : String) return Boolean;
overriding
function Read_Data
(Object : Archive_Location;
Path : String) return Byte_Array_Pointers.Pointer;
-----------------------------------------------------------------------------
overriding
function Exists (Object : Archive_Location; Path : String) return Boolean is
begin
return Object.Archive.Exists (Path);
end Exists;
overriding
function Read_Data
(Object : Archive_Location;
Path : String) return Byte_Array_Pointers.Pointer is
begin
if Path (Path'Last) = '/' then
raise Name_Error with "Path '" & Path & "' is not a regular file";
end if;
if not Object.Exists (Path) then
raise Name_Error with "File '" & Path & "' not found in archive " & Object.Archive.Name;
end if;
declare
Pointer : Byte_Array_Pointers.Pointer;
procedure Extract_File (File : DCF.Zip.Archived_File) is
subtype File_Byte_Array
is Byte_Array (1 .. Ada.Streams.Stream_Element_Offset (File.Uncompressed_Size));
Raw_Contents : Byte_Array_Access := new File_Byte_Array;
begin
declare
Stream_Writer : Byte_Stream_Writer (Raw_Contents);
begin
DCF.Unzip.Streams.Extract
(Destination => Stream_Writer,
Archive_Info => Object.Archive,
File => File,
Verify_Integrity => False); -- Integrity can be verified offline
Pointer.Set (Raw_Contents);
end;
exception
when others =>
Free (Raw_Contents);
raise;
end Extract_File;
procedure Extract_One_File is new DCF.Zip.Traverse_One_File (Extract_File);
begin
Extract_One_File (Object.Archive, Path);
return Pointer;
end;
end Read_Data;
function Create_Location (Path : String) return Location_Ptr is
begin
if not Ada.Directories.Exists (Path) then
raise Name_Error with "Archive '" & Path & "' not found";
end if;
return Result : constant Location_Ptr := new Archive_Location'
(Stream => DCF.Streams.Open (Path), Archive => <>)
do
declare
Location : Archive_Location renames Archive_Location (Result.all);
begin
DCF.Zip.Load (Location.Archive, Location.Stream);
end;
end return;
end Create_Location;
end Orka.Resources.Locations.Archives;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . D E B U G _ P O O L S --
-- --
-- B o d y --
-- --
-- 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. --
-- --
-- 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. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Exceptions.Traceback;
with GNAT.IO; use GNAT.IO;
with System.Address_Image;
with System.Memory; use System.Memory;
with System.Soft_Links; use System.Soft_Links;
with System.Traceback_Entries; use System.Traceback_Entries;
with GNAT.HTable;
with GNAT.Traceback; use GNAT.Traceback;
with Ada.Unchecked_Conversion;
package body GNAT.Debug_Pools is
Default_Alignment : constant := Standard'Maximum_Alignment;
-- Alignment used for the memory chunks returned by Allocate. Using this
-- value garantees that this alignment will be compatible with all types
-- and at the same time makes it easy to find the location of the extra
-- header allocated for each chunk.
Initial_Memory_Size : constant Storage_Offset := 2 ** 26; -- 64 Mb
-- Initial size of memory that the debug pool can handle. This is used to
-- compute the size of the htable used to monitor the blocks, but this is
-- dynamic and will grow as needed. Having a bigger size here means a
-- longer setup time, but less time spent later on to grow the array.
Max_Ignored_Levels : constant Natural := 10;
-- Maximum number of levels that will be ignored in backtraces. This is so
-- that we still have enough significant levels in the tracebacks returned
-- to the user.
--
-- The value 10 is chosen as being greater than the maximum callgraph
-- in this package. Its actual value is not really relevant, as long as it
-- is high enough to make sure we still have enough frames to return to
-- the user after we have hidden the frames internal to this package.
---------------------------
-- Back Trace Hash Table --
---------------------------
-- This package needs to store one set of tracebacks for each allocation
-- point (when was it allocated or deallocated). This would use too much
-- memory, so the tracebacks are actually stored in a hash table, and
-- we reference elements in this hash table instead.
-- This hash-table will remain empty if the discriminant Stack_Trace_Depth
-- for the pools is set to 0.
-- This table is a global table, that can be shared among all debug pools
-- with no problems.
type Header is range 1 .. 1023;
-- Number of elements in the hash-table
type Tracebacks_Array_Access
is access GNAT.Traceback.Tracebacks_Array;
type Traceback_Kind is (Alloc, Dealloc, Indirect_Alloc, Indirect_Dealloc);
type Traceback_Htable_Elem;
type Traceback_Htable_Elem_Ptr
is access Traceback_Htable_Elem;
type Traceback_Htable_Elem is record
Traceback : Tracebacks_Array_Access;
Kind : Traceback_Kind;
Count : Natural;
Total : Byte_Count;
Next : Traceback_Htable_Elem_Ptr;
end record;
-- Subprograms used for the Backtrace_Htable instantiation
procedure Set_Next
(E : Traceback_Htable_Elem_Ptr;
Next : Traceback_Htable_Elem_Ptr);
pragma Inline (Set_Next);
function Next
(E : Traceback_Htable_Elem_Ptr) return Traceback_Htable_Elem_Ptr;
pragma Inline (Next);
function Get_Key
(E : Traceback_Htable_Elem_Ptr) return Tracebacks_Array_Access;
pragma Inline (Get_Key);
function Hash (T : Tracebacks_Array_Access) return Header;
pragma Inline (Hash);
function Equal (K1, K2 : Tracebacks_Array_Access) return Boolean;
-- Why is this not inlined???
-- The hash table for back traces
package Backtrace_Htable is new GNAT.HTable.Static_HTable
(Header_Num => Header,
Element => Traceback_Htable_Elem,
Elmt_Ptr => Traceback_Htable_Elem_Ptr,
Null_Ptr => null,
Set_Next => Set_Next,
Next => Next,
Key => Tracebacks_Array_Access,
Get_Key => Get_Key,
Hash => Hash,
Equal => Equal);
-----------------------
-- Allocations table --
-----------------------
type Allocation_Header;
type Allocation_Header_Access is access Allocation_Header;
type Traceback_Ptr_Or_Address is new System.Address;
-- A type that acts as a C union, and is either a System.Address or a
-- Traceback_Htable_Elem_Ptr.
-- The following record stores extra information that needs to be
-- memorized for each block allocated with the special debug pool.
type Allocation_Header is record
Allocation_Address : System.Address;
-- Address of the block returned by malloc, possibly unaligned
Block_Size : Storage_Offset;
-- Needed only for advanced freeing algorithms (traverse all allocated
-- blocks for potential references). This value is negated when the
-- chunk of memory has been logically freed by the application. This
-- chunk has not been physically released yet.
Alloc_Traceback : Traceback_Htable_Elem_Ptr;
-- ??? comment required
Dealloc_Traceback : Traceback_Ptr_Or_Address;
-- Pointer to the traceback for the allocation (if the memory chunk is
-- still valid), or to the first deallocation otherwise. Make sure this
-- is a thin pointer to save space.
--
-- Dealloc_Traceback is also for blocks that are still allocated to
-- point to the previous block in the list. This saves space in this
-- header, and make manipulation of the lists of allocated pointers
-- faster.
Next : System.Address;
-- Point to the next block of the same type (either allocated or
-- logically freed) in memory. This points to the beginning of the user
-- data, and does not include the header of that block.
end record;
function Header_Of (Address : System.Address)
return Allocation_Header_Access;
pragma Inline (Header_Of);
-- Return the header corresponding to a previously allocated address
function To_Address is new Ada.Unchecked_Conversion
(Traceback_Ptr_Or_Address, System.Address);
function To_Address is new Ada.Unchecked_Conversion
(System.Address, Traceback_Ptr_Or_Address);
function To_Traceback is new Ada.Unchecked_Conversion
(Traceback_Ptr_Or_Address, Traceback_Htable_Elem_Ptr);
function To_Traceback is new Ada.Unchecked_Conversion
(Traceback_Htable_Elem_Ptr, Traceback_Ptr_Or_Address);
Header_Offset : constant Storage_Count :=
Default_Alignment *
((Allocation_Header'Size / System.Storage_Unit
+ Default_Alignment - 1) / Default_Alignment);
-- Offset of user data after allocation header
Minimum_Allocation : constant Storage_Count :=
Default_Alignment - 1 + Header_Offset;
-- Minimal allocation: size of allocation_header rounded up to next
-- multiple of default alignment + worst-case padding.
-----------------------
-- Allocations table --
-----------------------
-- This table is indexed on addresses modulo Default_Alignment, and for
-- each index it indicates whether that memory block is valid. Its behavior
-- is similar to GNAT.Table, except that we need to pack the table to save
-- space, so we cannot reuse GNAT.Table as is.
-- This table is the reason why all alignments have to be forced to common
-- value (Default_Alignment), so that this table can be kept to a
-- reasonnable size.
type Byte is mod 2 ** System.Storage_Unit;
Big_Table_Size : constant Storage_Offset :=
(Storage_Offset'Last - 1) / Default_Alignment;
type Big_Table is array (0 .. Big_Table_Size) of Byte;
-- A simple, flat-array type used to access memory bytes (see the comment
-- for Valid_Blocks below).
--
-- It would be cleaner to represent this as a packed array of Boolean.
-- However, we cannot specify pragma Pack for such an array, since the
-- total size on a 64 bit machine would be too big (> Integer'Last).
--
-- Given an address, we know if it is under control of the debug pool if
-- the byte at index:
-- ((Address - Edata'Address) / Default_Alignment)
-- / Storage_unit
-- has the bit
-- ((Address - Edata'Address) / Default_Alignment)
-- mod Storage_Unit
-- set to 1.
--
-- See the subprograms Is_Valid and Set_Valid for proper manipulation of
-- this array.
type Table_Ptr is access Big_Table;
function To_Pointer is new Ada.Unchecked_Conversion
(System.Address, Table_Ptr);
Valid_Blocks : Table_Ptr := null;
Valid_Blocks_Size : Storage_Offset := 0;
-- These two variables represents a mapping of the currently allocated
-- memory. Every time the pool works on an address, we first check that the
-- index Address / Default_Alignment is True. If not, this means that this
-- address is not under control of the debug pool and thus this is probably
-- an invalid memory access (it could also be a general access type).
--
-- Note that in fact we never allocate the full size of Big_Table, only a
-- slice big enough to manage the currently allocated memory.
Edata : System.Address := System.Null_Address;
-- Address in memory that matches the index 0 in Valid_Blocks. It is named
-- after the symbol _edata, which, on most systems, indicate the lowest
-- possible address returned by malloc. Unfortunately, this symbol doesn't
-- exist on windows, so we cannot use it instead of this variable.
-----------------------
-- Local subprograms --
-----------------------
function Find_Or_Create_Traceback
(Pool : Debug_Pool;
Kind : Traceback_Kind;
Size : Storage_Count;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address) return Traceback_Htable_Elem_Ptr;
-- Return an element matching the current traceback (omitting the frames
-- that are in the current package). If this traceback already existed in
-- the htable, a pointer to this is returned to spare memory. Null is
-- returned if the pool is set not to store tracebacks. If the traceback
-- already existed in the table, the count is incremented so that
-- Dump_Tracebacks returns useful results. All addresses up to, and
-- including, an address between Ignored_Frame_Start .. Ignored_Frame_End
-- are ignored.
procedure Put_Line
(Depth : Natural;
Traceback : Tracebacks_Array_Access;
Ignored_Frame_Start : System.Address := System.Null_Address;
Ignored_Frame_End : System.Address := System.Null_Address);
-- Print Traceback to Standard_Output. If Traceback is null, print the
-- call_chain at the current location, up to Depth levels, ignoring all
-- addresses up to the first one in the range
-- Ignored_Frame_Start .. Ignored_Frame_End
function Is_Valid (Storage : System.Address) return Boolean;
pragma Inline (Is_Valid);
-- Return True if Storage is an address that the debug pool has under its
-- control.
procedure Set_Valid (Storage : System.Address; Value : Boolean);
pragma Inline (Set_Valid);
-- Mark the address Storage as being under control of the memory pool (if
-- Value is True), or not (if Value is False). This procedure will
-- reallocate the table Valid_Blocks as needed.
procedure Set_Dead_Beef
(Storage_Address : System.Address;
Size_In_Storage_Elements : Storage_Count);
-- Set the contents of the memory block pointed to by Storage_Address to
-- the 16#DEADBEEF# pattern. If Size_In_Storage_Elements is not a multiple
-- of the length of this pattern, the last instance may be partial.
procedure Free_Physically (Pool : in out Debug_Pool);
-- Start to physically release some memory to the system, until the amount
-- of logically (but not physically) freed memory is lower than the
-- expected amount in Pool.
procedure Allocate_End;
procedure Deallocate_End;
procedure Dereference_End;
-- These procedures are used as markers when computing the stacktraces,
-- so that addresses in the debug pool itself are not reported to the user.
Code_Address_For_Allocate_End : System.Address;
Code_Address_For_Deallocate_End : System.Address;
Code_Address_For_Dereference_End : System.Address;
-- Taking the address of the above procedures will not work on some
-- architectures (HPUX and VMS for instance). Thus we do the same thing
-- that is done in a-except.adb, and get the address of labels instead
procedure Skip_Levels
(Depth : Natural;
Trace : Tracebacks_Array;
Start : out Natural;
Len : in out Natural;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address);
-- Set Start .. Len to the range of values from Trace that should be output
-- to the user. This range of values exludes any address prior to the first
-- one in Ignored_Frame_Start .. Ignored_Frame_End (basically addresses
-- internal to this package). Depth is the number of levels that the user
-- is interested in.
---------------
-- Header_Of --
---------------
function Header_Of (Address : System.Address)
return Allocation_Header_Access
is
function Convert is new Ada.Unchecked_Conversion
(System.Address, Allocation_Header_Access);
begin
return Convert (Address - Header_Offset);
end Header_Of;
--------------
-- Set_Next --
--------------
procedure Set_Next
(E : Traceback_Htable_Elem_Ptr;
Next : Traceback_Htable_Elem_Ptr)
is
begin
E.Next := Next;
end Set_Next;
----------
-- Next --
----------
function Next
(E : Traceback_Htable_Elem_Ptr) return Traceback_Htable_Elem_Ptr is
begin
return E.Next;
end Next;
-----------
-- Equal --
-----------
function Equal (K1, K2 : Tracebacks_Array_Access) return Boolean is
use Ada.Exceptions.Traceback;
begin
return K1.all = K2.all;
end Equal;
-------------
-- Get_Key --
-------------
function Get_Key
(E : Traceback_Htable_Elem_Ptr) return Tracebacks_Array_Access
is
begin
return E.Traceback;
end Get_Key;
----------
-- Hash --
----------
function Hash (T : Tracebacks_Array_Access) return Header is
Result : Integer_Address := 0;
begin
for X in T'Range loop
Result := Result + To_Integer (PC_For (T (X)));
end loop;
return Header (1 + Result mod Integer_Address (Header'Last));
end Hash;
--------------
-- Put_Line --
--------------
procedure Put_Line
(Depth : Natural;
Traceback : Tracebacks_Array_Access;
Ignored_Frame_Start : System.Address := System.Null_Address;
Ignored_Frame_End : System.Address := System.Null_Address)
is
procedure Print (Tr : Tracebacks_Array);
-- Print the traceback to standard_output
-----------
-- Print --
-----------
procedure Print (Tr : Tracebacks_Array) is
begin
for J in Tr'Range loop
Put ("0x" & Address_Image (PC_For (Tr (J))) & ' ');
end loop;
Put (ASCII.LF);
end Print;
-- Start of processing for Put_Line
begin
if Traceback = null then
declare
Tr : aliased Tracebacks_Array (1 .. Depth + Max_Ignored_Levels);
Start, Len : Natural;
begin
Call_Chain (Tr, Len);
Skip_Levels (Depth, Tr, Start, Len,
Ignored_Frame_Start, Ignored_Frame_End);
Print (Tr (Start .. Len));
end;
else
Print (Traceback.all);
end if;
end Put_Line;
-----------------
-- Skip_Levels --
-----------------
procedure Skip_Levels
(Depth : Natural;
Trace : Tracebacks_Array;
Start : out Natural;
Len : in out Natural;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address)
is
begin
Start := Trace'First;
while Start <= Len
and then (PC_For (Trace (Start)) < Ignored_Frame_Start
or else PC_For (Trace (Start)) > Ignored_Frame_End)
loop
Start := Start + 1;
end loop;
Start := Start + 1;
-- Just in case: make sure we have a traceback even if Ignore_Till
-- wasn't found.
if Start > Len then
Start := 1;
end if;
if Len - Start + 1 > Depth then
Len := Depth + Start - 1;
end if;
end Skip_Levels;
------------------------------
-- Find_Or_Create_Traceback --
------------------------------
function Find_Or_Create_Traceback
(Pool : Debug_Pool;
Kind : Traceback_Kind;
Size : Storage_Count;
Ignored_Frame_Start : System.Address;
Ignored_Frame_End : System.Address) return Traceback_Htable_Elem_Ptr
is
begin
if Pool.Stack_Trace_Depth = 0 then
return null;
end if;
declare
Trace : aliased Tracebacks_Array
(1 .. Integer (Pool.Stack_Trace_Depth) + Max_Ignored_Levels);
Len, Start : Natural;
Elem : Traceback_Htable_Elem_Ptr;
begin
Call_Chain (Trace, Len);
Skip_Levels (Pool.Stack_Trace_Depth, Trace, Start, Len,
Ignored_Frame_Start, Ignored_Frame_End);
-- Check if the traceback is already in the table
Elem :=
Backtrace_Htable.Get (Trace (Start .. Len)'Unrestricted_Access);
-- If not, insert it
if Elem = null then
Elem := new Traceback_Htable_Elem'
(Traceback => new Tracebacks_Array'(Trace (Start .. Len)),
Count => 1,
Kind => Kind,
Total => Byte_Count (Size),
Next => null);
Backtrace_Htable.Set (Elem);
else
Elem.Count := Elem.Count + 1;
Elem.Total := Elem.Total + Byte_Count (Size);
end if;
return Elem;
end;
end Find_Or_Create_Traceback;
--------------
-- Is_Valid --
--------------
function Is_Valid (Storage : System.Address) return Boolean is
Offset : constant Storage_Offset :=
(Storage - Edata) / Default_Alignment;
Bit : constant Byte := 2 ** Natural (Offset mod System.Storage_Unit);
begin
return (Storage mod Default_Alignment) = 0
and then Offset >= 0
and then Offset < Valid_Blocks_Size * Storage_Unit
and then (Valid_Blocks (Offset / Storage_Unit) and Bit) /= 0;
end Is_Valid;
---------------
-- Set_Valid --
---------------
procedure Set_Valid (Storage : System.Address; Value : Boolean) is
Offset : Storage_Offset;
Bit : Byte;
Bytes : Storage_Offset;
Tmp : constant Table_Ptr := Valid_Blocks;
Edata_Align : constant Storage_Offset :=
Default_Alignment * Storage_Unit;
procedure Memset (A : Address; C : Integer; N : size_t);
pragma Import (C, Memset, "memset");
procedure Memmove (Dest, Src : Address; N : size_t);
pragma Import (C, Memmove, "memmove");
begin
-- Allocate, or reallocate, the valid blocks table as needed. We start
-- with a size big enough to handle Initial_Memory_Size bytes of memory,
-- to avoid too many reallocations. The table will typically be around
-- 16Mb in that case, which is still small enough.
if Valid_Blocks_Size = 0 then
Valid_Blocks_Size := (Initial_Memory_Size / Default_Alignment)
/ Storage_Unit;
Valid_Blocks := To_Pointer (Alloc (size_t (Valid_Blocks_Size)));
Edata := Storage;
-- Reset the memory using memset, which is much faster than the
-- standard Ada code with "when others"
Memset (Valid_Blocks.all'Address, 0, size_t (Valid_Blocks_Size));
end if;
-- First case : the new address is outside of the current scope of
-- Valid_Blocks, before the current start address. We need to reallocate
-- the table accordingly. This should be a rare occurence, since in most
-- cases, the first allocation will also have the lowest address. But
-- there is no garantee...
if Storage < Edata then
-- The difference between the new Edata and the current one must be
-- a multiple of Default_Alignment * Storage_Unit, so that the bit
-- representing an address in Valid_Blocks are kept the same.
Offset := ((Edata - Storage) / Edata_Align + 1) * Edata_Align;
Offset := Offset / Default_Alignment;
Bytes := Offset / Storage_Unit;
Valid_Blocks :=
To_Pointer (Alloc (Size => size_t (Valid_Blocks_Size + Bytes)));
Memmove (Dest => Valid_Blocks.all'Address + Bytes,
Src => Tmp.all'Address,
N => size_t (Valid_Blocks_Size));
Memset (A => Valid_Blocks.all'Address,
C => 0,
N => size_t (Bytes));
Free (Tmp.all'Address);
Valid_Blocks_Size := Valid_Blocks_Size + Bytes;
-- Take into the account the new start address
Edata := Storage - Edata_Align + (Edata - Storage) mod Edata_Align;
end if;
-- Second case : the new address is outside of the current scope of
-- Valid_Blocks, so we have to grow the table as appropriate.
-- Note: it might seem more natural for the following statement to
-- be written:
-- Offset := (Storage - Edata) / Default_Alignment;
-- but that won't work since Storage_Offset is signed, and it is
-- possible to subtract a small address from a large address and
-- get a negative value. This may seem strange, but it is quite
-- specifically allowed in the RM, and is what most implementations
-- including GNAT actually do. Hence the conversion to Integer_Address
-- which is a full range modular type, not subject to this glitch.
Offset := Storage_Offset ((To_Integer (Storage) - To_Integer (Edata)) /
Default_Alignment);
if Offset >= Valid_Blocks_Size * System.Storage_Unit then
Bytes := Valid_Blocks_Size;
loop
Bytes := 2 * Bytes;
exit when Offset <= Bytes * System.Storage_Unit;
end loop;
Valid_Blocks := To_Pointer
(Realloc (Ptr => Valid_Blocks.all'Address,
Size => size_t (Bytes)));
Memset
(Valid_Blocks.all'Address + Valid_Blocks_Size,
0,
size_t (Bytes - Valid_Blocks_Size));
Valid_Blocks_Size := Bytes;
end if;
Bit := 2 ** Natural (Offset mod System.Storage_Unit);
Bytes := Offset / Storage_Unit;
-- Then set the value as valid
if Value then
Valid_Blocks (Bytes) := Valid_Blocks (Bytes) or Bit;
else
Valid_Blocks (Bytes) := Valid_Blocks (Bytes) and (not Bit);
end if;
end Set_Valid;
--------------
-- Allocate --
--------------
procedure Allocate
(Pool : in out Debug_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count)
is
pragma Unreferenced (Alignment);
-- Ignored, we always force 'Default_Alignment
type Local_Storage_Array is new Storage_Array
(1 .. Size_In_Storage_Elements + Minimum_Allocation);
type Ptr is access Local_Storage_Array;
-- On some systems, we might want to physically protect pages
-- against writing when they have been freed (of course, this is
-- expensive in terms of wasted memory). To do that, all we should
-- have to do it to set the size of this array to the page size.
-- See mprotect().
P : Ptr;
Current : Byte_Count;
Trace : Traceback_Htable_Elem_Ptr;
begin
<<Allocate_Label>>
Lock_Task.all;
-- If necessary, start physically releasing memory. The reason this is
-- done here, although Pool.Logically_Deallocated has not changed above,
-- is so that we do this only after a series of deallocations (e.g a
-- loop that deallocates a big array). If we were doing that in
-- Deallocate, we might be physically freeing memory several times
-- during the loop, which is expensive.
if Pool.Logically_Deallocated >
Byte_Count (Pool.Maximum_Logically_Freed_Memory)
then
Free_Physically (Pool);
end if;
-- Use standard (ie through malloc) allocations. This automatically
-- raises Storage_Error if needed. We also try once more to physically
-- release memory, so that even marked blocks, in the advanced scanning,
-- are freed.
begin
P := new Local_Storage_Array;
exception
when Storage_Error =>
Free_Physically (Pool);
P := new Local_Storage_Array;
end;
Storage_Address :=
System.Null_Address + Default_Alignment
* (((P.all'Address + Default_Alignment - 1) - System.Null_Address)
/ Default_Alignment)
+ Header_Offset;
pragma Assert ((Storage_Address - System.Null_Address)
mod Default_Alignment = 0);
pragma Assert (Storage_Address + Size_In_Storage_Elements
<= P.all'Address + P'Length);
Trace := Find_Or_Create_Traceback
(Pool, Alloc, Size_In_Storage_Elements,
Allocate_Label'Address, Code_Address_For_Allocate_End);
pragma Warnings (Off);
-- Turn warning on alignment for convert call off. We know that in
-- fact this conversion is safe since P itself is always aligned on
-- Default_Alignment.
Header_Of (Storage_Address).all :=
(Allocation_Address => P.all'Address,
Alloc_Traceback => Trace,
Dealloc_Traceback => To_Traceback (null),
Next => Pool.First_Used_Block,
Block_Size => Size_In_Storage_Elements);
pragma Warnings (On);
-- Link this block in the list of used blocks. This will be used to list
-- memory leaks in Print_Info, and for the advanced schemes of
-- Physical_Free, where we want to traverse all allocated blocks and
-- search for possible references.
-- We insert in front, since most likely we'll be freeing the most
-- recently allocated blocks first (the older one might stay allocated
-- for the whole life of the application).
if Pool.First_Used_Block /= System.Null_Address then
Header_Of (Pool.First_Used_Block).Dealloc_Traceback :=
To_Address (Storage_Address);
end if;
Pool.First_Used_Block := Storage_Address;
-- Mark the new address as valid
Set_Valid (Storage_Address, True);
-- Update internal data
Pool.Allocated :=
Pool.Allocated + Byte_Count (Size_In_Storage_Elements);
Current := Pool.Allocated -
Pool.Logically_Deallocated -
Pool.Physically_Deallocated;
if Current > Pool.High_Water then
Pool.High_Water := Current;
end if;
Unlock_Task.all;
exception
when others =>
Unlock_Task.all;
raise;
end Allocate;
------------------
-- Allocate_End --
------------------
-- DO NOT MOVE, this must be right after Allocate. This is similar to
-- what is done in a-except, so that we can hide the traceback frames
-- internal to this package
procedure Allocate_End is
begin
<<Allocate_End_Label>>
Code_Address_For_Allocate_End := Allocate_End_Label'Address;
end Allocate_End;
-------------------
-- Set_Dead_Beef --
-------------------
procedure Set_Dead_Beef
(Storage_Address : System.Address;
Size_In_Storage_Elements : Storage_Count)
is
Dead_Bytes : constant := 4;
type Data is mod 2 ** (Dead_Bytes * 8);
for Data'Size use Dead_Bytes * 8;
Dead : constant Data := 16#DEAD_BEEF#;
type Dead_Memory is array
(1 .. Size_In_Storage_Elements / Dead_Bytes) of Data;
type Mem_Ptr is access Dead_Memory;
type Byte is mod 2 ** 8;
for Byte'Size use 8;
type Dead_Memory_Bytes is array (0 .. 2) of Byte;
type Dead_Memory_Bytes_Ptr is access Dead_Memory_Bytes;
function From_Ptr is new Ada.Unchecked_Conversion
(System.Address, Mem_Ptr);
function From_Ptr is new Ada.Unchecked_Conversion
(System.Address, Dead_Memory_Bytes_Ptr);
M : constant Mem_Ptr := From_Ptr (Storage_Address);
M2 : Dead_Memory_Bytes_Ptr;
Modulo : constant Storage_Count :=
Size_In_Storage_Elements mod Dead_Bytes;
begin
M.all := (others => Dead);
-- Any bytes left (up to three of them)
if Modulo /= 0 then
M2 := From_Ptr (Storage_Address + M'Length * Dead_Bytes);
M2 (0) := 16#DE#;
if Modulo >= 2 then
M2 (1) := 16#AD#;
if Modulo >= 3 then
M2 (2) := 16#BE#;
end if;
end if;
end if;
end Set_Dead_Beef;
---------------------
-- Free_Physically --
---------------------
procedure Free_Physically (Pool : in out Debug_Pool) is
type Byte is mod 256;
type Byte_Access is access Byte;
function To_Byte is new Ada.Unchecked_Conversion
(System.Address, Byte_Access);
type Address_Access is access System.Address;
function To_Address_Access is new Ada.Unchecked_Conversion
(System.Address, Address_Access);
In_Use_Mark : constant Byte := 16#D#;
Free_Mark : constant Byte := 16#F#;
Total_Freed : Storage_Count := 0;
procedure Reset_Marks;
-- Unmark all the logically freed blocks, so that they are considered
-- for physical deallocation
procedure Mark
(H : Allocation_Header_Access; A : System.Address; In_Use : Boolean);
-- Mark the user data block starting at A. For a block of size zero,
-- nothing is done. For a block with a different size, the first byte
-- is set to either "D" (in use) or "F" (free).
function Marked (A : System.Address) return Boolean;
-- Return true if the user data block starting at A might be in use
-- somewhere else
procedure Mark_Blocks;
-- Traverse all allocated blocks, and search for possible references
-- to logically freed blocks. Mark them appropriately
procedure Free_Blocks (Ignore_Marks : Boolean);
-- Physically release blocks. Only the blocks that haven't been marked
-- will be released, unless Ignore_Marks is true.
-----------------
-- Free_Blocks --
-----------------
procedure Free_Blocks (Ignore_Marks : Boolean) is
Header : Allocation_Header_Access;
Tmp : System.Address := Pool.First_Free_Block;
Next : System.Address;
Previous : System.Address := System.Null_Address;
begin
while Tmp /= System.Null_Address
and then Total_Freed < Pool.Minimum_To_Free
loop
Header := Header_Of (Tmp);
-- If we know, or at least assume, the block is no longer
-- reference anywhere, we can free it physically.
if Ignore_Marks or else not Marked (Tmp) then
declare
pragma Suppress (All_Checks);
-- Suppress the checks on this section. If they are overflow
-- errors, it isn't critical, and we'd rather avoid a
-- Constraint_Error in that case.
begin
-- Note that block_size < zero for freed blocks
Pool.Physically_Deallocated :=
Pool.Physically_Deallocated -
Byte_Count (Header.Block_Size);
Pool.Logically_Deallocated :=
Pool.Logically_Deallocated +
Byte_Count (Header.Block_Size);
Total_Freed := Total_Freed - Header.Block_Size;
end;
Next := Header.Next;
System.Memory.Free (Header.Allocation_Address);
Set_Valid (Tmp, False);
-- Remove this block from the list
if Previous = System.Null_Address then
Pool.First_Free_Block := Next;
else
Header_Of (Previous).Next := Next;
end if;
Tmp := Next;
else
Previous := Tmp;
Tmp := Header.Next;
end if;
end loop;
end Free_Blocks;
----------
-- Mark --
----------
procedure Mark
(H : Allocation_Header_Access;
A : System.Address;
In_Use : Boolean)
is
begin
if H.Block_Size /= 0 then
if In_Use then
To_Byte (A).all := In_Use_Mark;
else
To_Byte (A).all := Free_Mark;
end if;
end if;
end Mark;
-----------------
-- Mark_Blocks --
-----------------
procedure Mark_Blocks is
Tmp : System.Address := Pool.First_Used_Block;
Previous : System.Address;
Last : System.Address;
Pointed : System.Address;
Header : Allocation_Header_Access;
begin
-- For each allocated block, check its contents. Things that look
-- like a possible address are used to mark the blocks so that we try
-- and keep them, for better detection in case of invalid access.
-- This mechanism is far from being fool-proof: it doesn't check the
-- stacks of the threads, doesn't check possible memory allocated not
-- under control of this debug pool. But it should allow us to catch
-- more cases.
while Tmp /= System.Null_Address loop
Previous := Tmp;
Last := Tmp + Header_Of (Tmp).Block_Size;
while Previous < Last loop
-- ??? Should we move byte-per-byte, or consider that addresses
-- are always aligned on 4-bytes boundaries ? Let's use the
-- fastest for now.
Pointed := To_Address_Access (Previous).all;
if Is_Valid (Pointed) then
Header := Header_Of (Pointed);
-- Do not even attempt to mark blocks in use. That would
-- screw up the whole application, of course.
if Header.Block_Size < 0 then
Mark (Header, Pointed, In_Use => True);
end if;
end if;
Previous := Previous + System.Address'Size;
end loop;
Tmp := Header_Of (Tmp).Next;
end loop;
end Mark_Blocks;
------------
-- Marked --
------------
function Marked (A : System.Address) return Boolean is
begin
return To_Byte (A).all = In_Use_Mark;
end Marked;
-----------------
-- Reset_Marks --
-----------------
procedure Reset_Marks is
Current : System.Address := Pool.First_Free_Block;
Header : Allocation_Header_Access;
begin
while Current /= System.Null_Address loop
Header := Header_Of (Current);
Mark (Header, Current, False);
Current := Header.Next;
end loop;
end Reset_Marks;
-- Start of processing for Free_Physically
begin
Lock_Task.all;
if Pool.Advanced_Scanning then
Reset_Marks; -- Reset the mark for each freed block
Mark_Blocks;
end if;
Free_Blocks (Ignore_Marks => not Pool.Advanced_Scanning);
-- The contract is that we need to free at least Minimum_To_Free bytes,
-- even if this means freeing marked blocks in the advanced scheme
if Total_Freed < Pool.Minimum_To_Free
and then Pool.Advanced_Scanning
then
Pool.Marked_Blocks_Deallocated := True;
Free_Blocks (Ignore_Marks => True);
end if;
Unlock_Task.all;
exception
when others =>
Unlock_Task.all;
raise;
end Free_Physically;
----------------
-- Deallocate --
----------------
procedure Deallocate
(Pool : in out Debug_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count)
is
pragma Unreferenced (Alignment);
Header : constant Allocation_Header_Access :=
Header_Of (Storage_Address);
Valid : Boolean;
Previous : System.Address;
begin
<<Deallocate_Label>>
Lock_Task.all;
Valid := Is_Valid (Storage_Address);
if not Valid then
Unlock_Task.all;
if Pool.Raise_Exceptions then
raise Freeing_Not_Allocated_Storage;
else
Put ("error: Freeing not allocated storage, at ");
Put_Line (Pool.Stack_Trace_Depth, null,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End);
end if;
elsif Header.Block_Size < 0 then
Unlock_Task.all;
if Pool.Raise_Exceptions then
raise Freeing_Deallocated_Storage;
else
Put ("error: Freeing already deallocated storage, at ");
Put_Line (Pool.Stack_Trace_Depth, null,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End);
Put (" Memory already deallocated at ");
Put_Line (0, To_Traceback (Header.Dealloc_Traceback).Traceback);
Put (" Memory was allocated at ");
Put_Line (0, Header.Alloc_Traceback.Traceback);
end if;
else
-- Remove this block from the list of used blocks
Previous :=
To_Address (Header_Of (Storage_Address).Dealloc_Traceback);
if Previous = System.Null_Address then
Pool.First_Used_Block := Header_Of (Pool.First_Used_Block).Next;
if Pool.First_Used_Block /= System.Null_Address then
Header_Of (Pool.First_Used_Block).Dealloc_Traceback :=
To_Traceback (null);
end if;
else
Header_Of (Previous).Next := Header_Of (Storage_Address).Next;
if Header_Of (Storage_Address).Next /= System.Null_Address then
Header_Of
(Header_Of (Storage_Address).Next).Dealloc_Traceback :=
To_Address (Previous);
end if;
end if;
-- Update the header
Header.all :=
(Allocation_Address => Header.Allocation_Address,
Alloc_Traceback => Header.Alloc_Traceback,
Dealloc_Traceback => To_Traceback
(Find_Or_Create_Traceback
(Pool, Dealloc,
Size_In_Storage_Elements,
Deallocate_Label'Address,
Code_Address_For_Deallocate_End)),
Next => System.Null_Address,
Block_Size => -Size_In_Storage_Elements);
if Pool.Reset_Content_On_Free then
Set_Dead_Beef (Storage_Address, Size_In_Storage_Elements);
end if;
Pool.Logically_Deallocated :=
Pool.Logically_Deallocated +
Byte_Count (Size_In_Storage_Elements);
-- Link this free block with the others (at the end of the list, so
-- that we can start releasing the older blocks first later on).
if Pool.First_Free_Block = System.Null_Address then
Pool.First_Free_Block := Storage_Address;
Pool.Last_Free_Block := Storage_Address;
else
Header_Of (Pool.Last_Free_Block).Next := Storage_Address;
Pool.Last_Free_Block := Storage_Address;
end if;
-- Do not physically release the memory here, but in Alloc.
-- See comment there for details.
Unlock_Task.all;
end if;
exception
when others =>
Unlock_Task.all;
raise;
end Deallocate;
--------------------
-- Deallocate_End --
--------------------
-- DO NOT MOVE, this must be right after Deallocate
-- See Allocate_End
procedure Deallocate_End is
begin
<<Deallocate_End_Label>>
Code_Address_For_Deallocate_End := Deallocate_End_Label'Address;
end Deallocate_End;
-----------------
-- Dereference --
-----------------
procedure Dereference
(Pool : in out Debug_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Count;
Alignment : Storage_Count)
is
pragma Unreferenced (Alignment, Size_In_Storage_Elements);
Valid : constant Boolean := Is_Valid (Storage_Address);
Header : Allocation_Header_Access;
begin
-- Locking policy: we do not do any locking in this procedure. The
-- tables are only read, not written to, and although a problem might
-- appear if someone else is modifying the tables at the same time, this
-- race condition is not intended to be detected by this storage_pool (a
-- now invalid pointer would appear as valid). Instead, we prefer
-- optimum performance for dereferences.
<<Dereference_Label>>
if not Valid then
if Pool.Raise_Exceptions then
raise Accessing_Not_Allocated_Storage;
else
Put ("error: Accessing not allocated storage, at ");
Put_Line (Pool.Stack_Trace_Depth, null,
Dereference_Label'Address,
Code_Address_For_Dereference_End);
end if;
else
Header := Header_Of (Storage_Address);
if Header.Block_Size < 0 then
if Pool.Raise_Exceptions then
raise Accessing_Deallocated_Storage;
else
Put ("error: Accessing deallocated storage, at ");
Put_Line
(Pool.Stack_Trace_Depth, null,
Dereference_Label'Address,
Code_Address_For_Dereference_End);
Put (" First deallocation at ");
Put_Line (0, To_Traceback (Header.Dealloc_Traceback).Traceback);
Put (" Initial allocation at ");
Put_Line (0, Header.Alloc_Traceback.Traceback);
end if;
end if;
end if;
end Dereference;
---------------------
-- Dereference_End --
---------------------
-- DO NOT MOVE: this must be right after Dereference
-- See Allocate_End
procedure Dereference_End is
begin
<<Dereference_End_Label>>
Code_Address_For_Dereference_End := Dereference_End_Label'Address;
end Dereference_End;
----------------
-- Print_Info --
----------------
procedure Print_Info
(Pool : Debug_Pool;
Cumulate : Boolean := False;
Display_Slots : Boolean := False;
Display_Leaks : Boolean := False)
is
package Backtrace_Htable_Cumulate is new GNAT.HTable.Static_HTable
(Header_Num => Header,
Element => Traceback_Htable_Elem,
Elmt_Ptr => Traceback_Htable_Elem_Ptr,
Null_Ptr => null,
Set_Next => Set_Next,
Next => Next,
Key => Tracebacks_Array_Access,
Get_Key => Get_Key,
Hash => Hash,
Equal => Equal);
-- This needs a comment ??? probably some of the ones below do too???
Data : Traceback_Htable_Elem_Ptr;
Elem : Traceback_Htable_Elem_Ptr;
Current : System.Address;
Header : Allocation_Header_Access;
K : Traceback_Kind;
begin
Put_Line
("Total allocated bytes : " &
Byte_Count'Image (Pool.Allocated));
Put_Line
("Total logically deallocated bytes : " &
Byte_Count'Image (Pool.Logically_Deallocated));
Put_Line
("Total physically deallocated bytes : " &
Byte_Count'Image (Pool.Physically_Deallocated));
if Pool.Marked_Blocks_Deallocated then
Put_Line ("Marked blocks were physically deallocated. This is");
Put_Line ("potentially dangereous, and you might want to run");
Put_Line ("again with a lower value of Minimum_To_Free");
end if;
Put_Line
("Current Water Mark: " &
Byte_Count'Image
(Pool.Allocated - Pool.Logically_Deallocated
- Pool.Physically_Deallocated));
Put_Line
("High Water Mark: " &
Byte_Count'Image (Pool.High_Water));
Put_Line ("");
if Display_Slots then
Data := Backtrace_Htable.Get_First;
while Data /= null loop
if Data.Kind in Alloc .. Dealloc then
Elem :=
new Traceback_Htable_Elem'
(Traceback => new Tracebacks_Array'(Data.Traceback.all),
Count => Data.Count,
Kind => Data.Kind,
Total => Data.Total,
Next => null);
Backtrace_Htable_Cumulate.Set (Elem);
if Cumulate then
if Data.Kind = Alloc then
K := Indirect_Alloc;
else
K := Indirect_Dealloc;
end if;
-- Propagate the direct call to all its parents
for T in Data.Traceback'First + 1 .. Data.Traceback'Last loop
Elem := Backtrace_Htable_Cumulate.Get
(Data.Traceback
(T .. Data.Traceback'Last)'Unrestricted_Access);
-- If not, insert it
if Elem = null then
Elem := new Traceback_Htable_Elem'
(Traceback => new Tracebacks_Array'
(Data.Traceback (T .. Data.Traceback'Last)),
Count => Data.Count,
Kind => K,
Total => Data.Total,
Next => null);
Backtrace_Htable_Cumulate.Set (Elem);
-- Properly take into account that the subprograms
-- indirectly called might be doing either allocations
-- or deallocations. This needs to be reflected in the
-- counts.
else
Elem.Count := Elem.Count + Data.Count;
if K = Elem.Kind then
Elem.Total := Elem.Total + Data.Total;
elsif Elem.Total > Data.Total then
Elem.Total := Elem.Total - Data.Total;
else
Elem.Kind := K;
Elem.Total := Data.Total - Elem.Total;
end if;
end if;
end loop;
end if;
Data := Backtrace_Htable.Get_Next;
end if;
end loop;
Put_Line ("List of allocations/deallocations: ");
Data := Backtrace_Htable_Cumulate.Get_First;
while Data /= null loop
case Data.Kind is
when Alloc => Put ("alloc (count:");
when Indirect_Alloc => Put ("indirect alloc (count:");
when Dealloc => Put ("free (count:");
when Indirect_Dealloc => Put ("indirect free (count:");
end case;
Put (Natural'Image (Data.Count) & ", total:" &
Byte_Count'Image (Data.Total) & ") ");
for T in Data.Traceback'Range loop
Put ("0x" & Address_Image (PC_For (Data.Traceback (T))) & ' ');
end loop;
Put_Line ("");
Data := Backtrace_Htable_Cumulate.Get_Next;
end loop;
Backtrace_Htable_Cumulate.Reset;
end if;
if Display_Leaks then
Put_Line ("");
Put_Line ("List of not deallocated blocks:");
-- Do not try to group the blocks with the same stack traces
-- together. This is done by the gnatmem output.
Current := Pool.First_Used_Block;
while Current /= System.Null_Address loop
Header := Header_Of (Current);
Put ("Size: " & Storage_Count'Image (Header.Block_Size) & " at: ");
for T in Header.Alloc_Traceback.Traceback'Range loop
Put ("0x" & Address_Image
(PC_For (Header.Alloc_Traceback.Traceback (T))) & ' ');
end loop;
Put_Line ("");
Current := Header.Next;
end loop;
end if;
end Print_Info;
------------------
-- Storage_Size --
------------------
function Storage_Size (Pool : Debug_Pool) return Storage_Count is
pragma Unreferenced (Pool);
begin
return Storage_Count'Last;
end Storage_Size;
---------------
-- Configure --
---------------
procedure Configure
(Pool : in out Debug_Pool;
Stack_Trace_Depth : Natural := Default_Stack_Trace_Depth;
Maximum_Logically_Freed_Memory : SSC := Default_Max_Freed;
Minimum_To_Free : SSC := Default_Min_Freed;
Reset_Content_On_Free : Boolean := Default_Reset_Content;
Raise_Exceptions : Boolean := Default_Raise_Exceptions;
Advanced_Scanning : Boolean := Default_Advanced_Scanning)
is
begin
Pool.Stack_Trace_Depth := Stack_Trace_Depth;
Pool.Maximum_Logically_Freed_Memory := Maximum_Logically_Freed_Memory;
Pool.Reset_Content_On_Free := Reset_Content_On_Free;
Pool.Raise_Exceptions := Raise_Exceptions;
Pool.Minimum_To_Free := Minimum_To_Free;
Pool.Advanced_Scanning := Advanced_Scanning;
end Configure;
----------------
-- Print_Pool --
----------------
procedure Print_Pool (A : System.Address) is
Storage : constant Address := A;
Valid : constant Boolean := Is_Valid (Storage);
Header : Allocation_Header_Access;
begin
-- We might get Null_Address if the call from gdb was done
-- incorrectly. For instance, doing a "print_pool(my_var)" passes 0x0,
-- instead of passing the value of my_var
if A = System.Null_Address then
Put_Line ("Memory not under control of the storage pool");
return;
end if;
if not Valid then
Put_Line ("Memory not under control of the storage pool");
else
Header := Header_Of (Storage);
Put_Line ("0x" & Address_Image (A)
& " allocated at:");
Put_Line (0, Header.Alloc_Traceback.Traceback);
if To_Traceback (Header.Dealloc_Traceback) /= null then
Put_Line ("0x" & Address_Image (A)
& " logically freed memory, deallocated at:");
Put_Line (0, To_Traceback (Header.Dealloc_Traceback).Traceback);
end if;
end if;
end Print_Pool;
-----------------------
-- Print_Info_Stdout --
-----------------------
procedure Print_Info_Stdout
(Pool : Debug_Pool;
Cumulate : Boolean := False;
Display_Slots : Boolean := False;
Display_Leaks : Boolean := False)
is
procedure Internal is new Print_Info
(Put_Line => GNAT.IO.Put_Line,
Put => GNAT.IO.Put);
begin
Internal (Pool, Cumulate, Display_Slots, Display_Leaks);
end Print_Info_Stdout;
------------------
-- Dump_Gnatmem --
------------------
procedure Dump_Gnatmem (Pool : Debug_Pool; File_Name : String) is
type File_Ptr is new System.Address;
function fopen (Path : String; Mode : String) return File_Ptr;
pragma Import (C, fopen);
procedure fwrite
(Ptr : System.Address;
Size : size_t;
Nmemb : size_t;
Stream : File_Ptr);
procedure fwrite
(Str : String;
Size : size_t;
Nmemb : size_t;
Stream : File_Ptr);
pragma Import (C, fwrite);
procedure fputc (C : Integer; Stream : File_Ptr);
pragma Import (C, fputc);
procedure fclose (Stream : File_Ptr);
pragma Import (C, fclose);
Address_Size : constant size_t :=
System.Address'Max_Size_In_Storage_Elements;
-- Size in bytes of a pointer
File : File_Ptr;
Current : System.Address;
Header : Allocation_Header_Access;
Actual_Size : size_t;
Num_Calls : Integer;
Tracebk : Tracebacks_Array_Access;
begin
File := fopen (File_Name & ASCII.NUL, "wb" & ASCII.NUL);
fwrite ("GMEM DUMP" & ASCII.LF, 10, 1, File);
-- List of not deallocated blocks (see Print_Info)
Current := Pool.First_Used_Block;
while Current /= System.Null_Address loop
Header := Header_Of (Current);
Actual_Size := size_t (Header.Block_Size);
Tracebk := Header.Alloc_Traceback.Traceback;
Num_Calls := Tracebk'Length;
-- (Code taken from memtrack.adb in GNAT's sources)
-- Logs allocation call using the format:
-- 'A' <mem addr> <size chunk> <len backtrace> <addr1> ... <addrn>
fputc (Character'Pos ('A'), File);
fwrite (Current'Address, Address_Size, 1, File);
fwrite (Actual_Size'Address, size_t'Max_Size_In_Storage_Elements, 1,
File);
fwrite (Num_Calls'Address, Integer'Max_Size_In_Storage_Elements, 1,
File);
for J in Tracebk'First .. Tracebk'First + Num_Calls - 1 loop
declare
Ptr : System.Address := PC_For (Tracebk (J));
begin
fwrite (Ptr'Address, Address_Size, 1, File);
end;
end loop;
Current := Header.Next;
end loop;
fclose (File);
end Dump_Gnatmem;
begin
Allocate_End;
Deallocate_End;
Dereference_End;
end GNAT.Debug_Pools;
|
with Ada.Text_IO;
with Ada.Strings.Fixed;
with Emojis;
procedure Test is
use Emojis;
use Ada.Text_IO;
package SF renames Ada.Strings.Fixed;
begin
Put_Line ("Text emojis:");
for Pair of Emojis.Text_Emojis loop
Put_Line
(SF.Tail (+Pair.Text, 3) & " = " & Emojis.Replace (":" & (+Pair.Label) & ":"));
end loop;
Put_Line ("");
Put_Line ("Labels and text emojis:");
Put_Line ("'" & Emojis.Replace
("Ada is :heart_eyes: :sparkles:" & ", " &
"Rust is :crab::church::rocket::military_helmet:" & ", " &
"C++ is :woozy_face:" & ", " &
"C is :boom:" & ", " &
"Perl is XO= :p") & "'");
Put_Line ("");
Put_Line ("Input completions:");
Put_Line ("'" & Emojis.Replace
("XD :o :p", Completions => Emojis.Lower_Case_Text_Emojis) & "'");
Put_Line ("");
Put_Line ("1 codepoint:");
Put_Line ("'" & Emojis.Replace (":foot: :sparkles: :face_with_monocle:") & "'");
Put_Line ("'" & Emojis.Replace
(":bagel: :duck: :dango: :bacon: :crab: :sushi: :fried_shrimp:") & "'");
Put_Line ("'" & Emojis.Replace
(":fish_cake: :owl: :tumbler_glass: :unicorn_face: :pancakes:") & "'");
Put_Line ("'" & Emojis.Replace
(":lollipop: :mate_drink: :waffle: :ice_cube: :sandwich:") & "'");
Put_Line ("'" & Emojis.Replace (":telescope: :checkered_flag: :yum:") & "'");
Put_Line ("");
Put_Line ("2 codepoints:");
Put_Line ("'" & Emojis.Replace (":radioactive_sign: :alembic:") & "'");
Put_Line ("'" & Emojis.Replace
(":desktop_computer: :joystick: :ballot_box_with_ballot: :shield:") & "'");
Put_Line ("");
Put_Line ("3 codepoints:");
Put_Line ("'" &
Emojis.Replace (":female-scientist: :face_with_spiral_eyes: :male-astronaut:") & "'");
end Test;
|
with
eGL.Pointers;
package eGL.NativeDisplayType
is
subtype Item is eGL.Pointers.Display_Pointer;
type Item_array is array (C.size_t range <>) of aliased Item;
type Pointer is access all eGL.NativeDisplayType.Item;
type Pointer_array is array (C.size_t range <>) of aliased Pointer;
end eGL.NativeDisplayType;
|
-- C41201D.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- FOR SLICED COMPONENTS OF THE FORM F(...), CHECK THAT
-- THE REQUIREMENT FOR A ONE-DIMENSIONAL ARRAY AND THE
-- TYPE OF THE INDEX ARE USED TO RESOLVE AN OVERLOADING OF F.
-- WKB 8/11/81
-- JBG 10/12/81
-- SPS 11/1/82
WITH REPORT;
PROCEDURE C41201D IS
USE REPORT;
TYPE T IS ARRAY (INTEGER RANGE <> ) OF INTEGER;
SUBTYPE T1 IS T(1..10);
TYPE T2 IS ARRAY (1..10, 1..10) OF INTEGER;
TT : T(1..3);
SUBTYPE U1 IS T(1..10);
TYPE U2 IS (MON,TUE,WED,THU,FRI);
SUBTYPE SU2 IS U2 RANGE MON .. THU;
TYPE U3 IS ARRAY (SU2) OF INTEGER;
UU : T(1..3);
TYPE V IS ARRAY (INTEGER RANGE <> ) OF BOOLEAN;
SUBTYPE V1 IS V(1..10);
SUBTYPE V2 IS T(1..10);
VV : V(2..5);
FUNCTION F RETURN T1 IS
BEGIN
RETURN (1,1,1,1,5,6,7,8,9,10);
END F;
FUNCTION F RETURN T2 IS
BEGIN
RETURN (1..10 => (1,2,3,4,5,6,7,8,9,10));
END F;
FUNCTION G RETURN U1 IS
BEGIN
RETURN (3,3,3,3,5,6,7,8,9,10);
END G;
FUNCTION G RETURN U3 IS
BEGIN
RETURN (0,1,2,3);
END G;
FUNCTION H RETURN V1 IS
BEGIN
RETURN (1|3..10 => FALSE, 2 => IDENT_BOOL(TRUE));
END H;
FUNCTION H RETURN V2 IS
BEGIN
RETURN (1..10 => 5);
END H;
BEGIN
TEST ("C41201D", "WHEN SLICING FUNCTION RESULTS, TYPE OF " &
"RESULT IS USED FOR OVERLOADING RESOLUTION");
IF F(1..3) /=
F(IDENT_INT(2)..IDENT_INT(4)) THEN -- NUMBER OF DIMENSIONS.
FAILED ("WRONG VALUE - 1");
END IF;
IF G(1..3) /=
G(IDENT_INT(2)..IDENT_INT(4)) THEN -- INDEX TYPE.
FAILED ("WRONG VALUE - 2");
END IF;
IF NOT IDENT_BOOL(H(2..3)(2)) THEN -- COMPONENT TYPE.
FAILED ("WRONG VALUE - 3");
END IF;
RESULT;
END C41201D;
|
with VisitFailurePackage, VisitablePackage, EnvironmentPackage;
use VisitFailurePackage, VisitablePackage, EnvironmentPackage;
with Ada.Text_IO; use Ada.Text_IO;
package body MuVarStrategy is
----------------------------------------------------------------------------
-- Object implementation
----------------------------------------------------------------------------
overriding
function toString(c: MuVar) return String is
str : access String := new String'("[");
begin
if c.name = null then
str := new String'(str.all & "null,");
else
str := new String'(str.all & c.name.all & ",");
end if;
if c.instance = null then
str := new String'(str.all & "null]");
else
str := new String'(str.all & toString(Object'Class(c.instance.all)) & "]");
end if;
return str.all;
end;
----------------------------------------------------------------------------
-- Strategy implementation
----------------------------------------------------------------------------
overriding
function visitLight(str:access MuVar; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is
begin
if str.instance /= null then
return visitLight(str.instance, any, i);
else
raise VisitFailure;
end if;
end;
overriding
function visit(str: access MuVar; i: access Introspector'Class) return Integer is
begin
if str.instance /= null then
return visit(str.instance, i);
else
return EnvironmentPackage.FAILURE;
end if;
end;
----------------------------------------------------------------------------
procedure makeMuVar(c : in out MuVar; s: access String) is
begin
initSubterm(c);
if s /= null then
c.name := new String'(s.all);
else
c.name := null;
end if;
end;
function newMuVar(s : access String) return StrategyPtr is
ret : StrategyPtr := new MuVar;
begin
makeMuVar(MuVar(ret.all), s);
return ret;
end;
function newMuVar(s : String) return StrategyPtr is
begin
return newMuVar(new String'(s));
end;
function equals(m : access MuVar; o : ObjectPtr) return Boolean is
mptr : access MuVar := null;
begin
if o /= null then
if o.all in MuVar'Class then
mptr := MuVar(o.all)'Access;
if mptr.name /= null then
return m.name.all = mptr.name.all;
else
if mptr.name = m.name and then mptr.instance = m.instance then
return true;
end if;
end if;
end if;
end if;
return false;
end;
function hashCode(m : access MuVar) return Integer is
begin
return 0;
end;
function getInstance(m: access MuVar) return StrategyPtr is
begin
return m.instance;
end;
procedure setInstance(m: access MuVar; s: StrategyPtr) is
begin
m.instance := s;
end;
procedure setName(m: access MuVar; n: access String) is
begin
if n /= null then
m.name := new String'(n.all);
else
m.name := null;
end if;
end;
function isExpanded(m: access Muvar) return Boolean is
begin
if m.instance = null then
return false;
else
return true;
end if;
end;
function getName(m: access Muvar) return access String is
begin
return m.name;
end;
----------------------------------------------------------------------------
end MuVarStrategy;
|
-- Weather update server
-- Binds PUB socket to tcp://*:5556
-- Publishes random weather updates
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
with GNAT.Formatted_String;
with ZMQ;
procedure WUServer is
use type GNAT.Formatted_String.Formatted_String;
type Zip_Code_T is range 0 .. 100000;
type Temperature_T is range -80 .. 135;
type Rel_Humidity_T is range 10 .. 60;
package Random_Zip_Code is new Ada.Numerics.Discrete_Random (Zip_Code_T);
package Random_Temperature is new Ada.Numerics.Discrete_Random (Temperature_T);
package Random_Rel_Humidity is new Ada.Numerics.Discrete_Random (Rel_Humidity_T);
function Main return Ada.Command_Line.Exit_Status
is
Random_Zip_Code_Seed : Random_Zip_Code.Generator;
Random_Temperature_Seed : Random_Temperature.Generator;
Random_Rel_Humidity_Seed : Random_Rel_Humidity.Generator;
begin
-- Initialize random number generator
Random_Zip_Code.Reset (Random_Zip_Code_Seed);
Random_Temperature.Reset (Random_Temperature_Seed);
Random_Rel_Humidity.Reset (Random_Rel_Humidity_Seed);
declare
-- Prepare our context and publisher
Context : ZMQ.Context_Type := ZMQ.New_Context;
Publisher : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUB);
begin
Publisher.Bind ("tcp://*:5556");
loop
-- Get values that will fool the boss
declare
Zip_Code : constant Zip_Code_T := Random_Zip_Code.Random (Random_Zip_Code_Seed);
Temperature : constant Temperature_T := Random_Temperature.Random (Random_Temperature_Seed);
Rel_Humidity : constant Rel_Humidity_T := Random_Rel_Humidity.Random (Random_Rel_Humidity_Seed);
begin
-- Send message to all subscribers
Publisher.Send (-(+"%05d %d %d"&Integer (Zip_Code) & Integer (Temperature) & Integer (Rel_Humidity)));
end;
end loop;
Publisher.Close;
Context.Term;
end;
return 0;
end Main;
begin
Ada.Command_Line.Set_Exit_Status (Main);
end WUServer;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2018, 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.Exceptions;
with Ada.Tags.Generic_Dispatching_Constructor;
with Ada.Text_IO;
with Servlet.Container_Initializers;
with Servlet.Generic_Servlets;
with XML.SAX.File_Input_Sources;
with XML.SAX.Simple_Readers;
with Matreshka.Servlet_Defaults;
with Matreshka.Spikedog_Deployment_Descriptors.Parsers;
package body Matreshka.Servlet_Containers is
use type League.Strings.Universal_String;
function Instantiate_Servlet is
new Ada.Tags.Generic_Dispatching_Constructor
(Servlet.Generic_Servlets.Generic_Servlet,
Servlet.Generic_Servlets.Instantiation_Parameters'Class,
Servlet.Generic_Servlets.Instantiate);
package Loader is
procedure Load
(Container : in out Servlet_Container'Class;
Initializer : out
Servlet.Container_Initializers.Servlet_Container_Initializer_Access);
end Loader;
package body Loader is separate;
------------------
-- Add_Listener --
------------------
overriding procedure Add_Listener
(Self : not null access Servlet_Container;
Listener : not null Servlet.Event_Listeners.Event_Listener_Access)
is
Success : Boolean := False;
begin
if Self.State = Initialized then
raise Servlet.Illegal_State_Exception
with "servlet context has already been initialized";
end if;
-- Check for support of Servlet_Context_Listener interface and register
-- listener in appropriate state of servlet context.
if Listener.all
in Servlet.Context_Listeners.Servlet_Context_Listener'Class
then
if Self.State = Uninitialized then
Self.Context_Listeners.Append
(Servlet.Context_Listeners.Servlet_Context_Listener_Access
(Listener));
Success := True;
else
raise Servlet.Illegal_State_Exception
with "Servlet_Container_Listener can't be added";
end if;
end if;
if not Success then
raise Servlet.Illegal_Argument_Exception
with "listener doesn't supports any of expected interfaces";
end if;
end Add_Listener;
-----------------
-- Add_Servlet --
-----------------
overriding function Add_Servlet
(Self : not null access Servlet_Container;
Name : League.Strings.Universal_String;
Instance : not null access Servlet.Servlets.Servlet'Class)
return access Servlet.Servlet_Registrations.Servlet_Registration'Class
is
use type Matreshka.Servlet_Registrations.Servlet_Access;
Object : constant Matreshka.Servlet_Registrations.Servlet_Access
:= Matreshka.Servlet_Registrations.Servlet_Access (Instance);
Registration :
Matreshka.Servlet_Registrations.Servlet_Registration_Access;
begin
if Self.State = Initialized then
raise Servlet.Illegal_State_Exception
with "servlet context has already been initialized";
end if;
if Name.Is_Empty then
raise Servlet.Illegal_Argument_Exception with "servlet name is empty";
end if;
if Instance.all
not in Servlet.Generic_Servlets.Generic_Servlet'Class
then
raise Servlet.Illegal_Argument_Exception
with "not descedant of base servlet type";
end if;
-- Check whether servlet instance or servlet name was registered.
for Registration of Self.Servlets loop
if Registration.Servlet = Object or Registration.Name = Name then
return null;
end if;
end loop;
Registration :=
new Matreshka.Servlet_Registrations.Servlet_Registration'
(Context => Self,
Name => Name,
Servlet => Object);
Self.Servlets.Insert (Name, Registration);
-- Initialize servlet.
begin
Registration.Servlet.Initialize (Registration);
exception
when X : others =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"Exception during servlet '"
& Name.To_UTF_8_String
& "' initialization:");
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
Ada.Exceptions.Exception_Information (X));
raise;
end;
return Registration;
end Add_Servlet;
--------------
-- Dispatch --
--------------
procedure Dispatch
(Self : not null access Servlet_Container'Class;
Request : not null
Matreshka.Servlet_HTTP_Requests.HTTP_Servlet_Request_Access;
Response : not null
Matreshka.Servlet_HTTP_Responses.HTTP_Servlet_Response_Access)
is
Servlet : Matreshka.Servlet_Registrations.Servlet_Registration_Access;
begin
Self.Dispatch (Request.all, Request.Get_Path, 1, Servlet);
Request.Set_Session_Manager (Self.Session_Manager);
Request.Set_Servlet_Context (Self);
Servlet.Servlet.Service (Request.all, Response.all);
end Dispatch;
--------------
-- Finalize --
--------------
procedure Finalize (Self : not null access Servlet_Container'Class) is
begin
for Listener of reverse Self.Context_Listeners loop
Listener.Context_Destroyed (Self);
end loop;
Self.State := Uninitialized;
end Finalize;
-------------------
-- Get_MIME_Type --
-------------------
overriding function Get_MIME_Type
(Self : Servlet_Container;
Path : League.Strings.Universal_String)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
if Path.Ends_With (".atom") then
return League.Strings.To_Universal_String ("application/atom+xml");
elsif Path.Ends_With (".css") then
return League.Strings.To_Universal_String ("text/css");
elsif Path.Ends_With (".frag") then
return League.Strings.To_Universal_String ("x-shader/x-fragment");
elsif Path.Ends_With (".gif") then
return League.Strings.To_Universal_String ("image/gif");
elsif Path.Ends_With (".html") then
return League.Strings.To_Universal_String ("text/html");
elsif Path.Ends_With (".jpeg") then
return League.Strings.To_Universal_String ("image/jpeg");
elsif Path.Ends_With (".js") then
return League.Strings.To_Universal_String ("text/javascript");
elsif Path.Ends_With (".pdf") then
return League.Strings.To_Universal_String ("application/pdf");
elsif Path.Ends_With (".png") then
return League.Strings.To_Universal_String ("image/png");
elsif Path.Ends_With (".svg") then
return League.Strings.To_Universal_String ("image/svg+xml");
elsif Path.Ends_With (".tiff") then
return League.Strings.To_Universal_String ("image/tiff");
elsif Path.Ends_With (".txt") then
return League.Strings.To_Universal_String ("text/plain");
elsif Path.Ends_With (".vert") then
return League.Strings.To_Universal_String ("x-shader/x-vertex");
elsif Path.Ends_With (".xml") then
-- "text/xml" requires to specify character encoding in Content-Type
-- header, otherwise US-ASCII is used. "application/xml" doesn't
-- require to provide character encoding in Content-Type header, in
-- this case XML processor uses encoding from document.
return League.Strings.To_Universal_String ("application/xml");
else
return League.Strings.Empty_Universal_String;
end if;
end Get_MIME_Type;
-------------------
-- Get_Real_Path --
-------------------
overriding function Get_Real_Path
(Self : Servlet_Container;
Path : League.Strings.Universal_String)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return "install" & Path;
end Get_Real_Path;
------------------------------
-- Get_Servlet_Registration --
------------------------------
overriding function Get_Servlet_Registration
(Self : not null access Servlet_Container;
Servlet_Name : League.Strings.Universal_String)
return access Servlet.Servlet_Registrations.Servlet_Registration'Class is
begin
for Registration of Self.Servlets loop
if Registration.Name = Servlet_Name then
return Registration;
end if;
end loop;
return null;
end Get_Servlet_Registration;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Servlet_Container'Class;
Server : not null Matreshka.Servlet_Servers.Server_Access;
Success : out Boolean)
is
Source : aliased XML.SAX.File_Input_Sources.File_Input_Source;
Reader : XML.SAX.Simple_Readers.Simple_Reader;
Parser : aliased
Matreshka.Spikedog_Deployment_Descriptors.Parsers
.Deployment_Descriptor_Parser;
Descriptor :
Matreshka.Spikedog_Deployment_Descriptors.Deployment_Descriptor_Access;
Initializer :
Servlet.Container_Initializers.Servlet_Container_Initializer_Access;
Aux : Boolean;
begin
Success := False;
-- Load deployment descriptor.
Descriptor :=
new Matreshka.Spikedog_Deployment_Descriptors.Deployment_Descriptor;
Reader.Set_Input_Source (Source'Unchecked_Access);
Reader.Set_Content_Handler (Parser'Unchecked_Access);
Parser.Set_Deployment_Descriptor (Descriptor);
Source.Open_By_File_Name
(League.Strings.To_Universal_String ("install/WEB-INF/web.xml"));
Reader.Parse;
Source.Close;
-- Start initialization of container.
Self.State := Initialization;
Self.Descriptor := Descriptor;
Server.Set_Container (Self);
-- XXX Can container be connected to server later, after successful
-- initialization?
-- Load and startup application.
begin
Loader.Load (Self.all, Initializer);
Initializer.On_Startup (Self.all);
exception
when X : others =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"Exception during application load/startup:");
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
Ada.Exceptions.Exception_Information (X));
return;
end;
-- Notify ServletContextListeners about initialization of context
for Listener of Self.Context_Listeners loop
Listener.Context_Initialized (Self);
end loop;
-- Instantiate servlets defined by deployment descriptor
for Descriptor of Self.Descriptor.Servlets loop
declare
P : aliased Servlet.Generic_Servlets.Instantiation_Parameters;
S : constant Matreshka.Servlet_Registrations.Servlet_Access
:= new Servlet.Generic_Servlets.Generic_Servlet'Class'
(Instantiate_Servlet
(Ada.Tags.Internal_Tag
(Descriptor.Tag.To_UTF_8_String),
P'Access));
begin
Self.Add_Servlet (Descriptor.Name, S);
end;
end loop;
-- Add URL mappings
for Descriptor of Self.Descriptor.Servlet_Mappings loop
Self.Get_Servlet_Registration
(Descriptor.Name).Add_Mapping (Descriptor.URL_Patterns);
end loop;
Self.State := Initialized;
-- Setup default servlet for context.
Self.Add_Mapping
(new Matreshka.Servlet_Registrations.Servlet_Registration'
(Context => Self,
Name => League.Strings.Empty_Universal_String,
Servlet => new Matreshka.Servlet_Defaults.Default_Servlet),
League.Strings.To_Universal_String ("/"),
Aux);
Success := True;
end Initialize;
-------------------------
-- Set_Session_Manager --
-------------------------
overriding procedure Set_Session_Manager
(Self : in out Servlet_Container;
Manager :
not null Spikedog.HTTP_Session_Managers.HTTP_Session_Manager_Access) is
begin
Self.Session_Manager := Manager;
end Set_Session_Manager;
end Matreshka.Servlet_Containers;
|
-- part of ParserTools, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package body Text.Builder is
procedure Init (Object : in out Reference; Pool : Text.Pool.Reference;
Initial_Size : Positive := 255) is
begin
null;
end Init;
function Create (Pool : Text.Pool.Reference;
Initial_Size : Positive := 255) return Reference is
begin
return Ret : Reference do
Init (Ret, Pool, Initial_Size);
end return;
end Create;
function Initialized (Object : Reference) return Boolean is
(True);
procedure Append (Object : in out Reference; Value : String) is
begin
Ada.Strings.Unbounded.Append (Object.Buffer, Value);
end Append;
procedure Append (Object : in out Reference; Value : Character) is
begin
Ada.Strings.Unbounded.Append (Object.Buffer, Value);
end Append;
procedure Append (Object : in out Reference; Value : Text.Reference) is
begin
Ada.Strings.Unbounded.Append (Object.Buffer, Value);
end Append;
function Lock (Object : in out Reference) return Text.Reference is
begin
return Object.Buffer;
end Lock;
function Length (Object : Reference) return Natural is
(Ada.Strings.Unbounded.Length (Object.Buffer));
end Text.Builder;
|
-- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
-- // Headers
-- ////////////////////////////////////////////////////////////
with Sf.Config;
with Sf.Network.Types;
package Sf.Network.Http is
use Sf.Config;
use Sf.Network.Types;
-- ////////////////////////////////////////////////////////////
-- /// Enumerate the available HTTP methods for a request
-- ////////////////////////////////////////////////////////////
type sfHttpMethod is (sfHttpGet, sfHttpPost, sfHttpHead);
-- ////////////////////////////////////////////////////////////
-- /// Enumerate all the valid status codes returned in
-- /// a HTTP response
-- ////////////////////////////////////////////////////////////
subtype sfHttpStatus is sfUint32;
sfHttpOk : constant sfHttpStatus := 200;
sfHttpCreated : constant sfHttpStatus := 201;
sfHttpAccepted : constant sfHttpStatus := 202;
sfHttpNoContent : constant sfHttpStatus := 204;
sfHttpMultipleChoices : constant sfHttpStatus := 300;
sfHttpMovedPermanently : constant sfHttpStatus := 301;
sfHttpMovedTemporarily : constant sfHttpStatus := 302;
sfHttpNotModified : constant sfHttpStatus := 304;
sfHttpBadRequest : constant sfHttpStatus := 400;
sfHttpUnauthorized : constant sfHttpStatus := 401;
sfHttpForbidden : constant sfHttpStatus := 403;
sfHttpNotFound : constant sfHttpStatus := 404;
sfHttpInternalServerError : constant sfHttpStatus := 500;
sfHttpNotImplemented : constant sfHttpStatus := 501;
sfHttpBadGateway : constant sfHttpStatus := 502;
sfHttpServiceNotAvailable : constant sfHttpStatus := 503;
sfHttpInvalidResponse : constant sfHttpStatus := 1000;
sfHttpConnectionFailed : constant sfHttpStatus := 1001;
-- ////////////////////////////////////////////////////////////
-- /// Construct a new Http request
-- ///
-- /// \return Pointer to the new Http request
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttpRequest_Create return sfHttpRequest_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing Http request
-- ///
-- /// \param HttpRequest : Http request to destroy
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttpRequest_Destroy (HttpRequest : sfHttpRequest_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Set the value of a field; the field is added if it doesn't exist
-- ///
-- /// \param HttpRequest : Http request to modify
-- /// \param Field : Name of the field to set (case-insensitive)
-- /// \param Value : Value of the field
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttpRequest_SetField (HttpRequest : sfHttpRequest_Ptr; Field : String; Value : String);
-- ////////////////////////////////////////////////////////////
-- /// Set the request method.
-- /// This parameter is sfHttpGet by default
-- ///
-- /// \param HttpRequest : Http request to modify
-- /// \param RequestMethod : Method to use for the request
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttpRequest_SetMethod (HttpRequest : sfHttpRequest_Ptr; Method : sfHttpMethod);
-- ////////////////////////////////////////////////////////////
-- /// Set the target URI of the request.
-- /// This parameter is "/" by default
-- ///
-- /// \param HttpRequest : Http request to modify
-- /// \param URI : URI to request, local to the host
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttpRequest_SetURI (HttpRequest : sfHttpRequest_Ptr; URI : String);
-- ////////////////////////////////////////////////////////////
-- /// Set the HTTP version of the request.
-- /// This parameter is 1.0 by default
-- ///
-- /// \param HttpRequest : Http request to modify
-- /// \param Major : Major version number
-- /// \param Minor : Minor version number
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttpRequest_SetHttpVersion (HttpRequest : sfHttpRequest_Ptr; Major : sfUint32; Minor : sfUint32);
-- ////////////////////////////////////////////////////////////
-- /// Set the body of the request. This parameter is optional and
-- /// makes sense only for POST requests.
-- /// This parameter is empty by default
-- ///
-- /// \param HttpRequest : Http request to modify
-- /// \param Body : Content of the request body
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttpRequest_SetBody (HttpRequest : sfHttpRequest_Ptr; The_Body : String);
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing Http response
-- ///
-- /// \param HttpResponse : Http response to destroy
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttpResponse_Destroy (HttpResponse : sfHttpResponse_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Get the value of a field; returns NULL if the field doesn't exist
-- ///
-- /// \param HttpResponse : Http response
-- /// \param Field : Field to get
-- ///
-- /// \return Value of the field (NULL if it doesn't exist)
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttpResponse_GetField (HttpResponse : sfHttpResponse_Ptr; Field : String) return String;
-- ////////////////////////////////////////////////////////////
-- /// Get the status of a response
-- ///
-- /// \param HttpResponse : Http response
-- ///
-- /// \return Status of the response
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttpResponse_GetStatus (HttpResponse : sfHttpResponse_Ptr) return sfHttpStatus;
-- ////////////////////////////////////////////////////////////
-- /// Get the major HTTP version of a response
-- ///
-- /// \param HttpResponse : Http response
-- ///
-- /// \return HTTP major version of the response
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttpResponse_GetMajorVersion (HttpResponse : sfHttpResponse_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the minor HTTP version of a response
-- ///
-- /// \param HttpResponse : Http response
-- ///
-- /// \return HTTP minor version of the response
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttpResponse_GetMinorVersion (HttpResponse : sfHttpResponse_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the body of the response. The body can contain :
-- /// - the requested page (for GET requests)
-- /// - a response from the server (for POST requests)
-- /// - nothing (for HEAD requests)
-- /// - an error message (in case of an error)
-- ///
-- /// \param HttpResponse : Http response
-- ///
-- /// \return Body of the response (empty string if no body)
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttpResponse_GetBody (HttpResponse : sfHttpResponse_Ptr) return String;
-- ////////////////////////////////////////////////////////////
-- /// Construct a new Http object
-- ///
-- /// \return Pointer to the new Http
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttp_Create return sfHttp_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing Http object
-- ///
-- /// \param Http : Http to destroy
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttp_Destroy (Http : sfHttp_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Set the target host of a Http server
-- ///
-- /// \param Http : Http object
-- /// \param Host : Web server to connect to
-- /// \param Port : Port to use for connection (0 to use the standard port of the protocol used)
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfHttp_SetHost (Http : sfHttp_Ptr; Host : String; Port : sfUint16);
-- ////////////////////////////////////////////////////////////
-- /// Send a HTTP request and return the server's response.
-- /// You must be connected to a host before sending requests.
-- /// Any missing mandatory header field will be added with an appropriate value.
-- /// Warning : this function waits for the server's response and may
-- /// not return instantly; use a thread if you don't want to block your
-- /// application.
-- ///
-- /// \param Http : Http object
-- /// \param Request : Request to send
-- /// \param Timeout : Maximum time to wait (0 to use no timeout)
-- ///
-- /// \return Server's response, or NULL if request is invalid
-- ///
-- ////////////////////////////////////////////////////////////
function sfHttp_SendRequest
(Http : sfHttp_Ptr;
Request : sfHttpRequest_Ptr;
Timeout : Float)
return sfHttpResponse_Ptr;
private
pragma Convention (C, sfHttpMethod);
pragma Import (C, sfHttpRequest_Create, "sfHttpRequest_Create");
pragma Import (C, sfHttpRequest_Destroy, "sfHttpRequest_Destroy");
pragma Import (C, sfHttpRequest_SetMethod, "sfHttpRequest_SetMethod");
pragma Import (C, sfHttpRequest_SetHttpVersion, "sfHttpRequest_SetHttpVersion");
pragma Import (C, sfHttpResponse_Destroy, "sfHttpResponse_Destroy");
pragma Import (C, sfHttpResponse_GetStatus, "sfHttpResponse_GetStatus");
pragma Import (C, sfHttpResponse_GetMajorVersion, "sfHttpResponse_GetMajorVersion");
pragma Import (C, sfHttpResponse_GetMinorVersion, "sfHttpResponse_GetMinorVersion");
pragma Import (C, sfHttp_Create, "sfHttp_Create");
pragma Import (C, sfHttp_Destroy, "sfHttp_Destroy");
pragma Import (C, sfHttp_SendRequest, "sfHttp_SendRequest");
end Sf.Network.Http;
|
--Alvaro Fernandez Velazquez (a_fernandez@usal.es)
--Francisco Blazquez Matias (fran_blm@usal.es)
with Ada.Real_Time;
with Ada.Real_Time.Timing_Events;
use Ada.Real_Time;
package Monitor is
protected type Reactor is
procedure leer(temp : out Integer);
procedure incrementar(incremento:Integer);
procedure decrementar(decremento:Integer);
procedure abrirPuerta;
procedure cerrarPuerta;
procedure Timer(event: in out Ada.Real_Time.Timing_Events.Timing_Event);
private
temperatura:Integer := 1450;
bajarJitterControl:Ada.Real_Time.Timing_Events.Timing_Event;
bajarPeriodo:Ada.Real_Time.Time_Span:= Ada.Real_Time.Seconds(1);
nextTime:Ada.Real_Time.Time;
end Reactor;
end Monitor;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . A S I S _ T A B L E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-2012, 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, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, 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 AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
-- This package contains definitions of tables and related auxilary resources
-- needed in more than one ASIS implementation package
with Asis;
with Sinfo; use Sinfo;
with Table;
with Types; use Types;
package A4G.Asis_Tables is
package Internal_Asis_Element_Table is new Table.Table (
Table_Component_Type => Asis.Element,
Table_Index_Type => Asis.ASIS_Natural,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Internal Element_List");
-- This table contains ASIS Elements. It is supposed to be used only for
-- creating the result Element lists in ASIS structural queries. Note that
-- many ASIS queries use instantiations of Traverse_Elements to create
-- result lists, so we have to make sure that ASIS structural queries
-- used in the implementation of Traverse_Element use another table to
-- create result lists
package Asis_Element_Table is new Table.Table (
Table_Component_Type => Asis.Element,
Table_Index_Type => Asis.ASIS_Natural,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Element_List");
-- This table contains ASIS Elements. It is supposed to be used for any
-- purpose except creating the result Element lists in ASIS structural
-- queries.
procedure Add_New_Element (Element : Asis.Element);
-- Differs from Asis_Element_Table.Append that checks if the argument
-- Element already is in the table, and appends the new element only if the
-- check fails. Note that the implementation is based on a simple array
-- search, so it can result in performance penalties if there are too
-- many elements in the table.
type Node_Trace_Rec is record
Kind : Node_Kind;
Node_Line : Physical_Line_Number;
Node_Col : Column_Number;
end record;
-- This record represents a Node in the node trace used to find the same
-- construct in another tree
package Node_Trace is new Table.Table (
Table_Component_Type => Node_Trace_Rec,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Node_Trace");
-- This table is used to create the node trace needed to compare elements
-- from nested instances
function Is_Equal
(N : Node_Id;
Trace_Rec : Node_Trace_Rec)
return Boolean;
-- Checks if N (in the currently accessed tree corresponds to the node
-- for which Trace_Rec was created
procedure Create_Node_Trace (N : Node_Id);
-- Creates the Node trace which is supposed to be used to find the node
-- representing the same construct in another tree. The trace is also used
-- to check is two nodes from different trees, each belonging to expanded
-- generics both denote the same thing. This trace contains the record
-- about N itself and all the enclosing constructs such as package bodies
-- and package specs. For the package which is an expanded generic, the
-- next element in the trace is the corresponding instantiation node.
function Enclosing_Scope (N : Node_Id) return Node_Id;
-- Given a node somewhere from expanded generic, returnes its enclosing
-- "scope" which can be N_Package_Declaration, N_Package_Body or
-- N_Generic_Declaration node. The idea is to use this function to create
-- the node trace either for storing it in the Note Trace table or for
-- creating the trace on the fly to compare it with the stored trace.
end A4G.Asis_Tables;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Handling; use Ada.Characters.Handling; -- définit is_digit
with Piles;
package body Integer_IO is
procedure Afficher (N : in Integer) is
package Pile_Integer is
new Piles (Integer'Width, Integer);
use Pile_Integer;
Nombre : Integer; -- le nombre à afficher (copie de N)
Chiffre : Integer; -- un chiffre de Nombre
Chiffres : T_Pile; -- les chiffres de Nombre
Caractere : Character; -- le caractère correspondant à Chiffre.
begin
-- Empiler les chiffres de l'entier
Initialiser (Chiffres);
Nombre := N;
loop
-- récupérer le chiffre des unités
Chiffre := Nombre Mod 10;
-- l'empiler
pragma Assert (not Est_Pleine (Chiffres));
Empiler (Chiffres, Chiffre);
-- réduire le nombre en supprimant les unités
Nombre := Nombre / 10;
exit when Nombre = 0;
end loop;
pragma Assert (Nombre = 0);
pragma Assert (not Est_Vide (Chiffres));
-- Afficher les chiffres de la pile
loop
-- Obtenir le chiffre en sommet de pile
Chiffre := Sommet (Chiffres);
-- le convertir en un caractère
caractere := Character'Val (Character'Pos('0') + Chiffre);
-- afficher le caractère
Put (caractere);
-- supprimer le caractère de la pile
Depiler (Chiffres);
exit when Est_Vide (Chiffres);
end loop;
end;
-- Consommer les caratères blancs et indiquer le prochain caractère sur
-- l'entrée standard.
-- Assure : C /= ' '
procedure Consommer_Blancs (Prochain_Caractere : out Character) with
Post => Prochain_Caractere /= ' '
is
Fin_De_Ligne : Boolean; -- fin de ligne atteinte ?
begin
Look_Ahead (Prochain_Caractere, Fin_De_Ligne); -- consulter le caractère suivant
while Fin_De_Ligne or else Prochain_Caractere = ' ' loop
-- consommer le caractère consulté
if Fin_De_Ligne then
Skip_Line;
else
Get (Prochain_Caractere);
end if;
-- Consulter le prochain caractère
Look_Ahead (Prochain_Caractere, Fin_De_Ligne);
end loop;
pragma Assert (not Fin_De_Ligne and Prochain_Caractere /= ' ');
end;
procedure Saisir (N : out Integer) is
C : Character; -- un caractère lu au clavier
Fin_De_Ligne : Boolean; -- fin de ligne atteinte ?
Chiffre : Integer; -- le chiffre correspondant à C
begin
Consommer_Blancs (C);
if Is_Digit (C) then --{ Un chiffre, donc un entier }--
-- reconnaître l'entier à partir des caractères de l'entrée standard
N := 0;
loop
-- Mettre à jour N avec C
Chiffre := Character'Pos (C) - Character'Pos ('0');
N := N * 10 + Chiffre;
-- Consulter le caractère suivant
Get (C);
Look_Ahead (C, Fin_De_Ligne);
exit when Fin_De_Ligne or else not Is_Digit (C);
end loop;
else --{ Pas d'entier }--
N := -1;
end if;
end;
end Integer_IO;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package mmintrin_h is
-- Copyright (C) 2002-2017 Free Software Foundation, Inc.
-- This file is part of GCC.
-- GCC is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3, or (at your option)
-- any later version.
-- GCC is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- Under Section 7 of GPL version 3, you are granted additional
-- permissions described in the GCC Runtime Library Exception, version
-- 3.1, as published by the Free Software Foundation.
-- You should have received a copy of the GNU General Public License and
-- a copy of the GCC Runtime Library Exception along with this program;
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-- <http://www.gnu.org/licenses/>.
-- Implemented from the specification included in the Intel C++ Compiler
-- User Guide and Reference, version 9.0.
-- The Intel API is flexible enough that we must allow aliasing with other
-- vector types, and their scalar components.
subtype uu_m64 is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\mmintrin.h:42
-- Unaligned version of the same type
subtype uu_m64_u is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\mmintrin.h:45
-- Internal data types for implementing the intrinsics.
subtype uu_v2si is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\mmintrin.h:48
subtype uu_v4hi is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\mmintrin.h:49
subtype uu_v8qi is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\mmintrin.h:50
subtype uu_v1di is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\mmintrin.h:51
subtype uu_v2sf is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\mmintrin.h:52
-- Empty the multimedia state.
-- skipped func _mm_empty
-- skipped func _m_empty
-- Convert I to a __m64 object. The integer is zero-extended to 64-bits.
-- skipped func _mm_cvtsi32_si64
-- skipped func _m_from_int
-- Convert I to a __m64 object.
-- Intel intrinsic.
-- skipped func _m_from_int64
-- skipped func _mm_cvtsi64_m64
-- Microsoft intrinsic.
-- skipped func _mm_cvtsi64x_si64
-- skipped func _mm_set_pi64x
-- Convert the lower 32 bits of the __m64 object into an integer.
-- skipped func _mm_cvtsi64_si32
-- skipped func _m_to_int
-- Convert the __m64 object to a 64bit integer.
-- Intel intrinsic.
-- skipped func _m_to_int64
-- skipped func _mm_cvtm64_si64
-- Microsoft intrinsic.
-- skipped func _mm_cvtsi64_si64x
-- Pack the four 16-bit values from M1 into the lower four 8-bit values of
-- the result, and the four 16-bit values from M2 into the upper four 8-bit
-- values of the result, all with signed saturation.
-- skipped func _mm_packs_pi16
-- skipped func _m_packsswb
-- Pack the two 32-bit values from M1 in to the lower two 16-bit values of
-- the result, and the two 32-bit values from M2 into the upper two 16-bit
-- values of the result, all with signed saturation.
-- skipped func _mm_packs_pi32
-- skipped func _m_packssdw
-- Pack the four 16-bit values from M1 into the lower four 8-bit values of
-- the result, and the four 16-bit values from M2 into the upper four 8-bit
-- values of the result, all with unsigned saturation.
-- skipped func _mm_packs_pu16
-- skipped func _m_packuswb
-- Interleave the four 8-bit values from the high half of M1 with the four
-- 8-bit values from the high half of M2.
-- skipped func _mm_unpackhi_pi8
-- skipped func _m_punpckhbw
-- Interleave the two 16-bit values from the high half of M1 with the two
-- 16-bit values from the high half of M2.
-- skipped func _mm_unpackhi_pi16
-- skipped func _m_punpckhwd
-- Interleave the 32-bit value from the high half of M1 with the 32-bit
-- value from the high half of M2.
-- skipped func _mm_unpackhi_pi32
-- skipped func _m_punpckhdq
-- Interleave the four 8-bit values from the low half of M1 with the four
-- 8-bit values from the low half of M2.
-- skipped func _mm_unpacklo_pi8
-- skipped func _m_punpcklbw
-- Interleave the two 16-bit values from the low half of M1 with the two
-- 16-bit values from the low half of M2.
-- skipped func _mm_unpacklo_pi16
-- skipped func _m_punpcklwd
-- Interleave the 32-bit value from the low half of M1 with the 32-bit
-- value from the low half of M2.
-- skipped func _mm_unpacklo_pi32
-- skipped func _m_punpckldq
-- Add the 8-bit values in M1 to the 8-bit values in M2.
-- skipped func _mm_add_pi8
-- skipped func _m_paddb
-- Add the 16-bit values in M1 to the 16-bit values in M2.
-- skipped func _mm_add_pi16
-- skipped func _m_paddw
-- Add the 32-bit values in M1 to the 32-bit values in M2.
-- skipped func _mm_add_pi32
-- skipped func _m_paddd
-- Add the 64-bit values in M1 to the 64-bit values in M2.
-- skipped func _mm_add_si64
-- Add the 8-bit values in M1 to the 8-bit values in M2 using signed
-- saturated arithmetic.
-- skipped func _mm_adds_pi8
-- skipped func _m_paddsb
-- Add the 16-bit values in M1 to the 16-bit values in M2 using signed
-- saturated arithmetic.
-- skipped func _mm_adds_pi16
-- skipped func _m_paddsw
-- Add the 8-bit values in M1 to the 8-bit values in M2 using unsigned
-- saturated arithmetic.
-- skipped func _mm_adds_pu8
-- skipped func _m_paddusb
-- Add the 16-bit values in M1 to the 16-bit values in M2 using unsigned
-- saturated arithmetic.
-- skipped func _mm_adds_pu16
-- skipped func _m_paddusw
-- Subtract the 8-bit values in M2 from the 8-bit values in M1.
-- skipped func _mm_sub_pi8
-- skipped func _m_psubb
-- Subtract the 16-bit values in M2 from the 16-bit values in M1.
-- skipped func _mm_sub_pi16
-- skipped func _m_psubw
-- Subtract the 32-bit values in M2 from the 32-bit values in M1.
-- skipped func _mm_sub_pi32
-- skipped func _m_psubd
-- Add the 64-bit values in M1 to the 64-bit values in M2.
-- skipped func _mm_sub_si64
-- Subtract the 8-bit values in M2 from the 8-bit values in M1 using signed
-- saturating arithmetic.
-- skipped func _mm_subs_pi8
-- skipped func _m_psubsb
-- Subtract the 16-bit values in M2 from the 16-bit values in M1 using
-- signed saturating arithmetic.
-- skipped func _mm_subs_pi16
-- skipped func _m_psubsw
-- Subtract the 8-bit values in M2 from the 8-bit values in M1 using
-- unsigned saturating arithmetic.
-- skipped func _mm_subs_pu8
-- skipped func _m_psubusb
-- Subtract the 16-bit values in M2 from the 16-bit values in M1 using
-- unsigned saturating arithmetic.
-- skipped func _mm_subs_pu16
-- skipped func _m_psubusw
-- Multiply four 16-bit values in M1 by four 16-bit values in M2 producing
-- four 32-bit intermediate results, which are then summed by pairs to
-- produce two 32-bit results.
-- skipped func _mm_madd_pi16
-- skipped func _m_pmaddwd
-- Multiply four signed 16-bit values in M1 by four signed 16-bit values in
-- M2 and produce the high 16 bits of the 32-bit results.
-- skipped func _mm_mulhi_pi16
-- skipped func _m_pmulhw
-- Multiply four 16-bit values in M1 by four 16-bit values in M2 and produce
-- the low 16 bits of the results.
-- skipped func _mm_mullo_pi16
-- skipped func _m_pmullw
-- Shift four 16-bit values in M left by COUNT.
-- skipped func _mm_sll_pi16
-- skipped func _m_psllw
-- skipped func _mm_slli_pi16
-- skipped func _m_psllwi
-- Shift two 32-bit values in M left by COUNT.
-- skipped func _mm_sll_pi32
-- skipped func _m_pslld
-- skipped func _mm_slli_pi32
-- skipped func _m_pslldi
-- Shift the 64-bit value in M left by COUNT.
-- skipped func _mm_sll_si64
-- skipped func _m_psllq
-- skipped func _mm_slli_si64
-- skipped func _m_psllqi
-- Shift four 16-bit values in M right by COUNT; shift in the sign bit.
-- skipped func _mm_sra_pi16
-- skipped func _m_psraw
-- skipped func _mm_srai_pi16
-- skipped func _m_psrawi
-- Shift two 32-bit values in M right by COUNT; shift in the sign bit.
-- skipped func _mm_sra_pi32
-- skipped func _m_psrad
-- skipped func _mm_srai_pi32
-- skipped func _m_psradi
-- Shift four 16-bit values in M right by COUNT; shift in zeros.
-- skipped func _mm_srl_pi16
-- skipped func _m_psrlw
-- skipped func _mm_srli_pi16
-- skipped func _m_psrlwi
-- Shift two 32-bit values in M right by COUNT; shift in zeros.
-- skipped func _mm_srl_pi32
-- skipped func _m_psrld
-- skipped func _mm_srli_pi32
-- skipped func _m_psrldi
-- Shift the 64-bit value in M left by COUNT; shift in zeros.
-- skipped func _mm_srl_si64
-- skipped func _m_psrlq
-- skipped func _mm_srli_si64
-- skipped func _m_psrlqi
-- Bit-wise AND the 64-bit values in M1 and M2.
-- skipped func _mm_and_si64
-- skipped func _m_pand
-- Bit-wise complement the 64-bit value in M1 and bit-wise AND it with the
-- 64-bit value in M2.
-- skipped func _mm_andnot_si64
-- skipped func _m_pandn
-- Bit-wise inclusive OR the 64-bit values in M1 and M2.
-- skipped func _mm_or_si64
-- skipped func _m_por
-- Bit-wise exclusive OR the 64-bit values in M1 and M2.
-- skipped func _mm_xor_si64
-- skipped func _m_pxor
-- Compare eight 8-bit values. The result of the comparison is 0xFF if the
-- test is true and zero if false.
-- skipped func _mm_cmpeq_pi8
-- skipped func _m_pcmpeqb
-- skipped func _mm_cmpgt_pi8
-- skipped func _m_pcmpgtb
-- Compare four 16-bit values. The result of the comparison is 0xFFFF if
-- the test is true and zero if false.
-- skipped func _mm_cmpeq_pi16
-- skipped func _m_pcmpeqw
-- skipped func _mm_cmpgt_pi16
-- skipped func _m_pcmpgtw
-- Compare two 32-bit values. The result of the comparison is 0xFFFFFFFF if
-- the test is true and zero if false.
-- skipped func _mm_cmpeq_pi32
-- skipped func _m_pcmpeqd
-- skipped func _mm_cmpgt_pi32
-- skipped func _m_pcmpgtd
-- Creates a 64-bit zero.
-- skipped func _mm_setzero_si64
-- Creates a vector of two 32-bit values; I0 is least significant.
-- skipped func _mm_set_pi32
-- Creates a vector of four 16-bit values; W0 is least significant.
-- skipped func _mm_set_pi16
-- Creates a vector of eight 8-bit values; B0 is least significant.
-- skipped func _mm_set_pi8
-- Similar, but with the arguments in reverse order.
-- skipped func _mm_setr_pi32
-- skipped func _mm_setr_pi16
-- skipped func _mm_setr_pi8
-- Creates a vector of two 32-bit values, both elements containing I.
-- skipped func _mm_set1_pi32
-- Creates a vector of four 16-bit values, all elements containing W.
-- skipped func _mm_set1_pi16
-- Creates a vector of eight 8-bit values, all elements containing B.
-- skipped func _mm_set1_pi8
end mmintrin_h;
|
-- C34002C.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- FOR DERIVED INTEGER TYPES:
-- CHECK THAT ALL VALUES OF THE PARENT (BASE) TYPE ARE PRESENT FOR THE
-- DERIVED (BASE) TYPE WHEN THE DERIVED TYPE DEFINITION IS
-- CONSTRAINED.
-- CHECK THAT ANY CONSTRAINT IMPOSED ON THE PARENT SUBTYPE IS ALSO
-- IMPOSED ON THE DERIVED SUBTYPE.
-- JRK 8/21/86
WITH REPORT; USE REPORT;
PROCEDURE C34002C IS
TYPE PARENT IS RANGE -100 .. 100;
TYPE T IS NEW PARENT RANGE
PARENT'VAL (IDENT_INT (-30)) ..
PARENT'VAL (IDENT_INT ( 30));
SUBTYPE SUBPARENT IS PARENT RANGE -30 .. 30;
TYPE S IS NEW SUBPARENT;
X : T;
Y : S;
BEGIN
TEST ("C34002C", "CHECK THAT ALL VALUES OF THE PARENT (BASE) " &
"TYPE ARE PRESENT FOR THE DERIVED (BASE) TYPE " &
"WHEN THE DERIVED TYPE DEFINITION IS " &
"CONSTRAINED. ALSO CHECK THAT ANY CONSTRAINT " &
"IMPOSED ON THE PARENT SUBTYPE IS ALSO IMPOSED " &
"ON THE DERIVED SUBTYPE. CHECK FOR DERIVED " &
"INTEGER TYPES");
-- CHECK THAT BASE TYPE VALUES NOT IN THE SUBTYPE ARE PRESENT.
IF T'POS (T'BASE'FIRST) /= PARENT'POS (PARENT'BASE'FIRST) OR
S'POS (S'BASE'FIRST) /= PARENT'POS (PARENT'BASE'FIRST) OR
T'POS (T'BASE'LAST) /= PARENT'POS (PARENT'BASE'LAST) OR
S'POS (S'BASE'LAST) /= PARENT'POS (PARENT'BASE'LAST) THEN
FAILED ("INCORRECT 'BASE'FIRST OR 'BASE'LAST");
END IF;
IF T'PRED (100) /= 99 OR T'SUCC (99) /= 100 OR
S'PRED (100) /= 99 OR S'SUCC (99) /= 100 THEN
FAILED ("INCORRECT 'PRED OR 'SUCC");
END IF;
-- CHECK THE DERIVED SUBTYPE CONSTRAINT.
IF T'FIRST /= -30 OR T'LAST /= 30 OR
S'FIRST /= -30 OR S'LAST /= 30 THEN
FAILED ("INCORRECT 'FIRST OR 'LAST");
END IF;
BEGIN
X := -30;
Y := -30;
IF PARENT (X) /= PARENT (Y) THEN -- USE X AND Y.
FAILED ("INCORRECT CONVERSION TO PARENT - 1");
END IF;
X := 30;
Y := 30;
IF PARENT (X) /= PARENT (Y) THEN -- USE X AND Y.
FAILED ("INCORRECT CONVERSION TO PARENT - 2");
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED BY OK ASSIGNMENT");
END;
BEGIN
X := -31;
FAILED ("CONSTRAINT_ERROR NOT RAISED -- X := -31");
IF X = -31 THEN -- USE X.
COMMENT ("X ALTERED -- X := -31");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- X := -31");
END;
BEGIN
X := 31;
FAILED ("CONSTRAINT_ERROR NOT RAISED -- X := 31");
IF X = 31 THEN -- USE X.
COMMENT ("X ALTERED -- X := 31");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- X := 31");
END;
BEGIN
Y := -31;
FAILED ("CONSTRAINT_ERROR NOT RAISED -- Y := -31");
IF Y = -31 THEN -- USE Y.
COMMENT ("Y ALTERED -- Y := -31");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- Y := -31");
END;
BEGIN
Y := 31;
FAILED ("CONSTRAINT_ERROR NOT RAISED -- Y := 31");
IF Y = 31 THEN -- USE Y.
COMMENT ("Y ALTERED -- Y := 31");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED -- Y := 31");
END;
RESULT;
END C34002C;
|
-----------------------------------------------------------------------
-- Generic Quick_Sort procedure
-----------------------------------------------------------------------
generic
type Element is private;
type Index is (<>);
type Element_Array is array(Index range <>) of Element;
with function "<" (Left, Right : Element) return Boolean is <>;
procedure Quick_Sort(A : in out Element_Array);
|
with
Interfaces.C.Strings,
System;
use type
System.Address;
package body FLTK.Widgets.Clocks.Updated is
procedure clock_set_draw_hook
(W, D : in System.Address);
pragma Import (C, clock_set_draw_hook, "clock_set_draw_hook");
pragma Inline (clock_set_draw_hook);
procedure clock_set_handle_hook
(W, H : in System.Address);
pragma Import (C, clock_set_handle_hook, "clock_set_handle_hook");
pragma Inline (clock_set_handle_hook);
function new_fl_clock
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_clock, "new_fl_clock");
pragma Inline (new_fl_clock);
function new_fl_clock2
(K : in Interfaces.C.unsigned_char;
X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_clock2, "new_fl_clock2");
pragma Inline (new_fl_clock2);
procedure free_fl_clock
(F : in System.Address);
pragma Import (C, free_fl_clock, "free_fl_clock");
pragma Inline (free_fl_clock);
procedure fl_clock_draw
(W : in System.Address);
pragma Import (C, fl_clock_draw, "fl_clock_draw");
pragma Inline (fl_clock_draw);
procedure fl_clock_draw2
(C : in System.Address;
X, Y, W, H : in Interfaces.C.int);
pragma Import (C, fl_clock_draw2, "fl_clock_draw2");
pragma Inline (fl_clock_draw2);
function fl_clock_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_clock_handle, "fl_clock_handle");
pragma Inline (fl_clock_handle);
procedure Finalize
(This : in out Updated_Clock) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Updated_Clock'Class
then
free_fl_clock (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Clock (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Updated_Clock is
begin
return This : Updated_Clock do
This.Void_Ptr := new_fl_clock
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
clock_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
clock_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
function Create
(Kind : in Box_Kind;
X, Y, W, H : in Integer;
Text : in String)
return Updated_Clock is
begin
return This : Updated_Clock do
This.Void_Ptr := new_fl_clock2
(Box_Kind'Pos (Kind),
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
clock_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
clock_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Draw
(This : in out Updated_Clock) is
begin
fl_clock_draw (This.Void_Ptr);
end Draw;
procedure Draw
(This : in out Clock;
X, Y, W, H : in Integer) is
begin
fl_clock_draw2
(This.Void_Ptr,
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H));
end Draw;
function Handle
(This : in out Updated_Clock;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_clock_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Clocks.Updated;
|
------------------------------------------------------------------------------
-- --
-- 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.Internals.Elements;
with AMF.Internals.Extents;
with AMF.Internals.Helpers;
with AMF.Internals.Links;
with AMF.Internals.Listener_Registry;
with AMF.Internals.Tables.UML_Constructors;
with AMF.Internals.Tables.UML_Metamodel;
with AMF.UML.Holders.Aggregation_Kinds;
with AMF.UML.Holders.Call_Concurrency_Kinds;
with AMF.UML.Holders.Connector_Kinds;
with AMF.UML.Holders.Expansion_Kinds;
with AMF.UML.Holders.Interaction_Operator_Kinds;
with AMF.UML.Holders.Message_Kinds;
with AMF.UML.Holders.Message_Sorts;
with AMF.UML.Holders.Object_Node_Ordering_Kinds;
with AMF.UML.Holders.Parameter_Direction_Kinds;
with AMF.UML.Holders.Parameter_Effect_Kinds;
with AMF.UML.Holders.Pseudostate_Kinds;
with AMF.UML.Holders.Transition_Kinds;
with AMF.UML.Holders.Visibility_Kinds;
package body AMF.Internals.Factories.UML_Factories is
None_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("none");
Shared_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("shared");
Composite_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("composite");
Sequential_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("sequential");
Guarded_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("guarded");
Concurrent_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("concurrent");
Assembly_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("assembly");
Delegation_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("delegation");
Parallel_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("parallel");
Iterative_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("iterative");
Stream_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("stream");
Seq_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("seq");
Alt_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("alt");
Opt_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("opt");
Break_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("break");
Par_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("par");
Strict_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("strict");
Loop_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("loop");
Critical_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("critical");
Neg_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("neg");
Assert_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("assert");
Ignore_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("ignore");
Consider_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("consider");
Complete_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("complete");
Lost_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("lost");
Found_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("found");
Unknown_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("unknown");
Synch_Call_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("synchCall");
Asynch_Call_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("asynchCall");
Asynch_Signal_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("asynchSignal");
Create_Message_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("createMessage");
Delete_Message_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("deleteMessage");
Reply_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("reply");
Unordered_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("unordered");
Ordered_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("ordered");
LIFO_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("LIFO");
FIFO_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("FIFO");
In_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("in");
Inout_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("inout");
Out_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("out");
Return_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("return");
Create_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("create");
Read_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("read");
Update_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("update");
Delete_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("delete");
Initial_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("initial");
Deep_History_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("deepHistory");
Shallow_History_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("shallowHistory");
Join_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("join");
Fork_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("fork");
Junction_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("junction");
Choice_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("choice");
Entry_Point_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("entryPoint");
Exit_Point_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("exitPoint");
Terminate_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("terminate");
Internal_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("internal");
Local_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("local");
External_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("external");
Public_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("public");
Private_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("private");
Protected_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("protected");
Package_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("package");
-----------------
-- Constructor --
-----------------
function Constructor
(Extent : AMF.Internals.AMF_Extent)
return not null AMF.Factories.Factory_Access is
begin
return new UML_Factory'(Extent => Extent);
end Constructor;
-----------------------
-- Convert_To_String --
-----------------------
overriding function Convert_To_String
(Self : not null access UML_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Value : League.Holders.Holder) return League.Strings.Universal_String
is
pragma Unreferenced (Self);
DT : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element;
begin
if DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Aggregation_Kind then
declare
Item : constant AMF.UML.UML_Aggregation_Kind
:= AMF.UML.Holders.Aggregation_Kinds.Element (Value);
begin
case Item is
when AMF.UML.None =>
return None_Img;
when AMF.UML.Shared =>
return Shared_Img;
when AMF.UML.Composite =>
return Composite_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Concurrency_Kind then
declare
Item : constant AMF.UML.UML_Call_Concurrency_Kind
:= AMF.UML.Holders.Call_Concurrency_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Sequential =>
return Sequential_Img;
when AMF.UML.Guarded =>
return Guarded_Img;
when AMF.UML.Concurrent =>
return Concurrent_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Connector_Kind then
declare
Item : constant AMF.UML.UML_Connector_Kind
:= AMF.UML.Holders.Connector_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Assembly =>
return Assembly_Img;
when AMF.UML.Delegation =>
return Delegation_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Expansion_Kind then
declare
Item : constant AMF.UML.UML_Expansion_Kind
:= AMF.UML.Holders.Expansion_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Parallel =>
return Parallel_Img;
when AMF.UML.Iterative =>
return Iterative_Img;
when AMF.UML.Stream =>
return Stream_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Operator_Kind then
declare
Item : constant AMF.UML.UML_Interaction_Operator_Kind
:= AMF.UML.Holders.Interaction_Operator_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Seq_Operator =>
return Seq_Img;
when AMF.UML.Alt_Operator =>
return Alt_Img;
when AMF.UML.Opt_Operator =>
return Opt_Img;
when AMF.UML.Break_Operator =>
return Break_Img;
when AMF.UML.Par_Operator =>
return Par_Img;
when AMF.UML.Strict_Operator =>
return Strict_Img;
when AMF.UML.Loop_Operator =>
return Loop_Img;
when AMF.UML.Critical_Operator =>
return Critical_Img;
when AMF.UML.Neg_Operator =>
return Neg_Img;
when AMF.UML.Assert_Operator =>
return Assert_Img;
when AMF.UML.Ignore_Operator =>
return Ignore_Img;
when AMF.UML.Consider_Operator =>
return Consider_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Message_Kind then
declare
Item : constant AMF.UML.UML_Message_Kind
:= AMF.UML.Holders.Message_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Complete =>
return Complete_Img;
when AMF.UML.Lost =>
return Lost_Img;
when AMF.UML.Found =>
return Found_Img;
when AMF.UML.Unknown =>
return Unknown_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Message_Sort then
declare
Item : constant AMF.UML.UML_Message_Sort
:= AMF.UML.Holders.Message_Sorts.Element (Value);
begin
case Item is
when AMF.UML.Synch_Call =>
return Synch_Call_Img;
when AMF.UML.Asynch_Call =>
return Asynch_Call_Img;
when AMF.UML.Asynch_Signal =>
return Asynch_Signal_Img;
when AMF.UML.Create_Message =>
return Create_Message_Img;
when AMF.UML.Delete_Message =>
return Delete_Message_Img;
when AMF.UML.Reply =>
return Reply_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Object_Node_Ordering_Kind then
declare
Item : constant AMF.UML.UML_Object_Node_Ordering_Kind
:= AMF.UML.Holders.Object_Node_Ordering_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Unordered =>
return Unordered_Img;
when AMF.UML.Ordered =>
return Ordered_Img;
when AMF.UML.LIFO =>
return LIFO_Img;
when AMF.UML.FIFO =>
return FIFO_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter_Direction_Kind then
declare
Item : constant AMF.UML.UML_Parameter_Direction_Kind
:= AMF.UML.Holders.Parameter_Direction_Kinds.Element (Value);
begin
case Item is
when AMF.UML.In_Parameter =>
return In_Img;
when AMF.UML.In_Out_Parameter =>
return Inout_Img;
when AMF.UML.Out_Parameter =>
return Out_Img;
when AMF.UML.Return_Parameter =>
return Return_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter_Effect_Kind then
declare
Item : constant AMF.UML.UML_Parameter_Effect_Kind
:= AMF.UML.Holders.Parameter_Effect_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Create =>
return Create_Img;
when AMF.UML.Read =>
return Read_Img;
when AMF.UML.Update =>
return Update_Img;
when AMF.UML.Delete =>
return Delete_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Pseudostate_Kind then
declare
Item : constant AMF.UML.UML_Pseudostate_Kind
:= AMF.UML.Holders.Pseudostate_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Initial_Pseudostate =>
return Initial_Img;
when AMF.UML.Deep_History_Pseudostate =>
return Deep_History_Img;
when AMF.UML.Shallow_History_Pseudostate =>
return Shallow_History_Img;
when AMF.UML.Join_Pseudostate =>
return Join_Img;
when AMF.UML.Fork_Pseudostate =>
return Fork_Img;
when AMF.UML.Junction_Pseudostate =>
return Junction_Img;
when AMF.UML.Choice_Pseudostate =>
return Choice_Img;
when AMF.UML.Entry_Point_Pseudostate =>
return Entry_Point_Img;
when AMF.UML.Exit_Point_Pseudostate =>
return Exit_Point_Img;
when AMF.UML.Terminate_Pseudostate =>
return Terminate_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Transition_Kind then
declare
Item : constant AMF.UML.UML_Transition_Kind
:= AMF.UML.Holders.Transition_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Internal =>
return Internal_Img;
when AMF.UML.Local =>
return Local_Img;
when AMF.UML.External =>
return External_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Visibility_Kind then
declare
Item : constant AMF.UML.UML_Visibility_Kind
:= AMF.UML.Holders.Visibility_Kinds.Element (Value);
begin
case Item is
when AMF.UML.Public_Visibility =>
return Public_Img;
when AMF.UML.Private_Visibility =>
return Private_Img;
when AMF.UML.Protected_Visibility =>
return Protected_Img;
when AMF.UML.Package_Visibility =>
return Package_Img;
end case;
end;
else
raise Program_Error;
end if;
end Convert_To_String;
------------
-- Create --
------------
overriding function Create
(Self : not null access UML_Factory;
Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class)
return not null AMF.Elements.Element_Access
is
MC : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Meta_Class.all).Element;
Element : AMF.Internals.AMF_Element;
begin
if MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Abstraction then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Abstraction;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Accept_Call_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Accept_Call_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Accept_Event_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Accept_Event_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Action_Execution_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Action_Execution_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Action_Input_Pin then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Action_Input_Pin;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Activity;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity_Final_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Activity_Final_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity_Parameter_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Activity_Parameter_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity_Partition then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Activity_Partition;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Actor then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Actor;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Add_Structural_Feature_Value_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Add_Structural_Feature_Value_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Add_Variable_Value_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Add_Variable_Value_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Any_Receive_Event then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Any_Receive_Event;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Artifact then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Artifact;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Association then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Association;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Association_Class then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Association_Class;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Behavior_Execution_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Behavior_Execution_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Broadcast_Signal_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Broadcast_Signal_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Behavior_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Call_Behavior_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Event then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Call_Event;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Operation_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Call_Operation_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Central_Buffer_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Central_Buffer_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Change_Event then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Change_Event;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Class then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Class;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Classifier_Template_Parameter then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Classifier_Template_Parameter;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Clause then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Clause;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Clear_Association_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Clear_Association_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Clear_Structural_Feature_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Clear_Structural_Feature_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Clear_Variable_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Clear_Variable_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Collaboration then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Collaboration;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Collaboration_Use then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Collaboration_Use;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Combined_Fragment then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Combined_Fragment;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Comment then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Comment;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Communication_Path then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Communication_Path;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Component then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Component;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Component_Realization then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Component_Realization;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Conditional_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Conditional_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Connectable_Element_Template_Parameter then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Connectable_Element_Template_Parameter;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Connection_Point_Reference then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Connection_Point_Reference;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Connector then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Connector;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Connector_End then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Connector_End;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Consider_Ignore_Fragment then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Consider_Ignore_Fragment;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Constraint then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Constraint;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Continuation then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Continuation;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Control_Flow then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Control_Flow;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Create_Link_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Create_Link_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Create_Link_Object_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Create_Link_Object_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Create_Object_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Create_Object_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Data_Store_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Data_Store_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Data_Type then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Data_Type;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Decision_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Decision_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Dependency then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Dependency;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Deployment then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Deployment;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Deployment_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Deployment_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Destroy_Link_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Destroy_Link_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Destroy_Object_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Destroy_Object_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Destruction_Occurrence_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Destruction_Occurrence_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Device then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Device;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Duration;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration_Constraint then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Duration_Constraint;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration_Interval then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Duration_Interval;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration_Observation then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Duration_Observation;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Element_Import then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Element_Import;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Enumeration then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Enumeration;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Enumeration_Literal then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Enumeration_Literal;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Exception_Handler then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Exception_Handler;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Execution_Environment then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Execution_Environment;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Execution_Occurrence_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Execution_Occurrence_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Expansion_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Expansion_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Expansion_Region then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Expansion_Region;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Expression then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Expression;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Extend then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Extend;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Extension then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Extension;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Extension_End then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Extension_End;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Extension_Point then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Extension_Point;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Final_State then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Final_State;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Flow_Final_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Flow_Final_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Fork_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Fork_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Function_Behavior then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Function_Behavior;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Gate then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Gate;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_General_Ordering then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_General_Ordering;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Generalization then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Generalization;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Generalization_Set then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Generalization_Set;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Image then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Image;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Include then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Include;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Information_Flow then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Information_Flow;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Information_Item then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Information_Item;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Initial_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Initial_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Input_Pin then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Input_Pin;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Instance_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Instance_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Instance_Value then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Instance_Value;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interaction;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Constraint then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interaction_Constraint;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Operand then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interaction_Operand;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Use then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interaction_Use;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interface then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interface;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interface_Realization then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interface_Realization;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interruptible_Activity_Region then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interruptible_Activity_Region;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interval then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interval;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interval_Constraint then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Interval_Constraint;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Join_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Join_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Lifeline then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Lifeline;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Link_End_Creation_Data then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Link_End_Creation_Data;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Link_End_Data then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Link_End_Data;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Link_End_Destruction_Data then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Link_End_Destruction_Data;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Boolean then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Literal_Boolean;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Integer then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Literal_Integer;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Null then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Literal_Null;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Real then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Literal_Real;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_String then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Literal_String;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Unlimited_Natural then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Literal_Unlimited_Natural;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Loop_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Loop_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Manifestation then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Manifestation;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Merge_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Merge_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Message then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Message;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Message_Occurrence_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Message_Occurrence_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Model then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Model;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Object_Flow then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Object_Flow;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Occurrence_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Occurrence_Specification;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Opaque_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Opaque_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Opaque_Behavior then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Opaque_Behavior;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Opaque_Expression then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Opaque_Expression;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Operation then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Operation;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Operation_Template_Parameter then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Operation_Template_Parameter;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Output_Pin then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Output_Pin;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Package then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Package;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Package_Import then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Package_Import;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Package_Merge then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Package_Merge;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Parameter;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter_Set then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Parameter_Set;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Part_Decomposition then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Part_Decomposition;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Port then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Port;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Primitive_Type then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Primitive_Type;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Profile then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Profile;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Profile_Application then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Profile_Application;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Property then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Property;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Protocol_Conformance then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Protocol_Conformance;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Protocol_State_Machine then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Protocol_State_Machine;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Protocol_Transition then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Protocol_Transition;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Pseudostate then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Pseudostate;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Qualifier_Value then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Qualifier_Value;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Raise_Exception_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Raise_Exception_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Extent_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Extent_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Is_Classified_Object_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Is_Classified_Object_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Link_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Link_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Link_Object_End_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Link_Object_End_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Link_Object_End_Qualifier_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Link_Object_End_Qualifier_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Self_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Self_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Structural_Feature_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Structural_Feature_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Variable_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Read_Variable_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Realization then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Realization;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Reception then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Reception;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Reclassify_Object_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Reclassify_Object_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Redefinable_Template_Signature then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Redefinable_Template_Signature;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Reduce_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Reduce_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Region then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Region;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Remove_Structural_Feature_Value_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Remove_Structural_Feature_Value_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Remove_Variable_Value_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Remove_Variable_Value_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Reply_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Reply_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Send_Object_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Send_Object_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Send_Signal_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Send_Signal_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Sequence_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Sequence_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Signal then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Signal;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Signal_Event then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Signal_Event;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Slot then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Slot;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Start_Classifier_Behavior_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Start_Classifier_Behavior_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Start_Object_Behavior_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Start_Object_Behavior_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_State then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_State;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_State_Invariant then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_State_Invariant;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_State_Machine then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_State_Machine;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Stereotype then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Stereotype;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_String_Expression then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_String_Expression;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Structured_Activity_Node then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Structured_Activity_Node;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Substitution then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Substitution;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Binding then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Template_Binding;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Parameter then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Template_Parameter;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Parameter_Substitution then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Template_Parameter_Substitution;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Signature then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Template_Signature;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Test_Identity_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Test_Identity_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Constraint then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Time_Constraint;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Event then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Time_Event;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Expression then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Time_Expression;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Interval then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Time_Interval;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Observation then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Time_Observation;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Transition then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Transition;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Trigger then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Trigger;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Unmarshall_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Unmarshall_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Usage then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Usage;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Use_Case then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Use_Case;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Value_Pin then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Value_Pin;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Value_Specification_Action then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Value_Specification_Action;
elsif MC = AMF.Internals.Tables.UML_Metamodel.MC_UML_Variable then
Element := AMF.Internals.Tables.UML_Constructors.Create_UML_Variable;
else
raise Program_Error;
end if;
AMF.Internals.Extents.Internal_Append (Self.Extent, Element);
AMF.Internals.Listener_Registry.Notify_Instance_Create
(AMF.Internals.Helpers.To_Element (Element));
return AMF.Internals.Helpers.To_Element (Element);
end Create;
------------------------
-- Create_From_String --
------------------------
overriding function Create_From_String
(Self : not null access UML_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Image : League.Strings.Universal_String) return League.Holders.Holder
is
pragma Unreferenced (Self);
use type League.Strings.Universal_String;
DT : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element;
begin
if DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Aggregation_Kind then
if Image = None_Img then
return
AMF.UML.Holders.Aggregation_Kinds.To_Holder
(AMF.UML.None);
elsif Image = Shared_Img then
return
AMF.UML.Holders.Aggregation_Kinds.To_Holder
(AMF.UML.Shared);
elsif Image = Composite_Img then
return
AMF.UML.Holders.Aggregation_Kinds.To_Holder
(AMF.UML.Composite);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Concurrency_Kind then
if Image = Sequential_Img then
return
AMF.UML.Holders.Call_Concurrency_Kinds.To_Holder
(AMF.UML.Sequential);
elsif Image = Guarded_Img then
return
AMF.UML.Holders.Call_Concurrency_Kinds.To_Holder
(AMF.UML.Guarded);
elsif Image = Concurrent_Img then
return
AMF.UML.Holders.Call_Concurrency_Kinds.To_Holder
(AMF.UML.Concurrent);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Connector_Kind then
if Image = Assembly_Img then
return
AMF.UML.Holders.Connector_Kinds.To_Holder
(AMF.UML.Assembly);
elsif Image = Delegation_Img then
return
AMF.UML.Holders.Connector_Kinds.To_Holder
(AMF.UML.Delegation);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Expansion_Kind then
if Image = Parallel_Img then
return
AMF.UML.Holders.Expansion_Kinds.To_Holder
(AMF.UML.Parallel);
elsif Image = Iterative_Img then
return
AMF.UML.Holders.Expansion_Kinds.To_Holder
(AMF.UML.Iterative);
elsif Image = Stream_Img then
return
AMF.UML.Holders.Expansion_Kinds.To_Holder
(AMF.UML.Stream);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Operator_Kind then
if Image = Seq_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Seq_Operator);
elsif Image = Alt_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Alt_Operator);
elsif Image = Opt_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Opt_Operator);
elsif Image = Break_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Break_Operator);
elsif Image = Par_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Par_Operator);
elsif Image = Strict_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Strict_Operator);
elsif Image = Loop_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Loop_Operator);
elsif Image = Critical_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Critical_Operator);
elsif Image = Neg_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Neg_Operator);
elsif Image = Assert_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Assert_Operator);
elsif Image = Ignore_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Ignore_Operator);
elsif Image = Consider_Img then
return
AMF.UML.Holders.Interaction_Operator_Kinds.To_Holder
(AMF.UML.Consider_Operator);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Message_Kind then
if Image = Complete_Img then
return
AMF.UML.Holders.Message_Kinds.To_Holder
(AMF.UML.Complete);
elsif Image = Lost_Img then
return
AMF.UML.Holders.Message_Kinds.To_Holder
(AMF.UML.Lost);
elsif Image = Found_Img then
return
AMF.UML.Holders.Message_Kinds.To_Holder
(AMF.UML.Found);
elsif Image = Unknown_Img then
return
AMF.UML.Holders.Message_Kinds.To_Holder
(AMF.UML.Unknown);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Message_Sort then
if Image = Synch_Call_Img then
return
AMF.UML.Holders.Message_Sorts.To_Holder
(AMF.UML.Synch_Call);
elsif Image = Asynch_Call_Img then
return
AMF.UML.Holders.Message_Sorts.To_Holder
(AMF.UML.Asynch_Call);
elsif Image = Asynch_Signal_Img then
return
AMF.UML.Holders.Message_Sorts.To_Holder
(AMF.UML.Asynch_Signal);
elsif Image = Create_Message_Img then
return
AMF.UML.Holders.Message_Sorts.To_Holder
(AMF.UML.Create_Message);
elsif Image = Delete_Message_Img then
return
AMF.UML.Holders.Message_Sorts.To_Holder
(AMF.UML.Delete_Message);
elsif Image = Reply_Img then
return
AMF.UML.Holders.Message_Sorts.To_Holder
(AMF.UML.Reply);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Object_Node_Ordering_Kind then
if Image = Unordered_Img then
return
AMF.UML.Holders.Object_Node_Ordering_Kinds.To_Holder
(AMF.UML.Unordered);
elsif Image = Ordered_Img then
return
AMF.UML.Holders.Object_Node_Ordering_Kinds.To_Holder
(AMF.UML.Ordered);
elsif Image = LIFO_Img then
return
AMF.UML.Holders.Object_Node_Ordering_Kinds.To_Holder
(AMF.UML.LIFO);
elsif Image = FIFO_Img then
return
AMF.UML.Holders.Object_Node_Ordering_Kinds.To_Holder
(AMF.UML.FIFO);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter_Direction_Kind then
if Image = In_Img then
return
AMF.UML.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.UML.In_Parameter);
elsif Image = Inout_Img then
return
AMF.UML.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.UML.In_Out_Parameter);
elsif Image = Out_Img then
return
AMF.UML.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.UML.Out_Parameter);
elsif Image = Return_Img then
return
AMF.UML.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.UML.Return_Parameter);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter_Effect_Kind then
if Image = Create_Img then
return
AMF.UML.Holders.Parameter_Effect_Kinds.To_Holder
(AMF.UML.Create);
elsif Image = Read_Img then
return
AMF.UML.Holders.Parameter_Effect_Kinds.To_Holder
(AMF.UML.Read);
elsif Image = Update_Img then
return
AMF.UML.Holders.Parameter_Effect_Kinds.To_Holder
(AMF.UML.Update);
elsif Image = Delete_Img then
return
AMF.UML.Holders.Parameter_Effect_Kinds.To_Holder
(AMF.UML.Delete);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Pseudostate_Kind then
if Image = Initial_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Initial_Pseudostate);
elsif Image = Deep_History_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Deep_History_Pseudostate);
elsif Image = Shallow_History_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Shallow_History_Pseudostate);
elsif Image = Join_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Join_Pseudostate);
elsif Image = Fork_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Fork_Pseudostate);
elsif Image = Junction_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Junction_Pseudostate);
elsif Image = Choice_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Choice_Pseudostate);
elsif Image = Entry_Point_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Entry_Point_Pseudostate);
elsif Image = Exit_Point_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Exit_Point_Pseudostate);
elsif Image = Terminate_Img then
return
AMF.UML.Holders.Pseudostate_Kinds.To_Holder
(AMF.UML.Terminate_Pseudostate);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Transition_Kind then
if Image = Internal_Img then
return
AMF.UML.Holders.Transition_Kinds.To_Holder
(AMF.UML.Internal);
elsif Image = Local_Img then
return
AMF.UML.Holders.Transition_Kinds.To_Holder
(AMF.UML.Local);
elsif Image = External_Img then
return
AMF.UML.Holders.Transition_Kinds.To_Holder
(AMF.UML.External);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.UML_Metamodel.MC_UML_Visibility_Kind then
if Image = Public_Img then
return
AMF.UML.Holders.Visibility_Kinds.To_Holder
(AMF.UML.Public_Visibility);
elsif Image = Private_Img then
return
AMF.UML.Holders.Visibility_Kinds.To_Holder
(AMF.UML.Private_Visibility);
elsif Image = Protected_Img then
return
AMF.UML.Holders.Visibility_Kinds.To_Holder
(AMF.UML.Protected_Visibility);
elsif Image = Package_Img then
return
AMF.UML.Holders.Visibility_Kinds.To_Holder
(AMF.UML.Package_Visibility);
else
raise Constraint_Error;
end if;
else
raise Program_Error;
end if;
end Create_From_String;
-----------------
-- Create_Link --
-----------------
overriding function Create_Link
(Self : not null access UML_Factory;
Association :
not null access AMF.CMOF.Associations.CMOF_Association'Class;
First_Element : not null AMF.Elements.Element_Access;
Second_Element : not null AMF.Elements.Element_Access)
return not null AMF.Links.Link_Access
is
pragma Unreferenced (Self);
begin
return
AMF.Internals.Links.Proxy
(AMF.Internals.Links.Create_Link
(AMF.Internals.Elements.Element_Base'Class
(Association.all).Element,
AMF.Internals.Helpers.To_Element (First_Element),
AMF.Internals.Helpers.To_Element (Second_Element)));
end Create_Link;
-----------------
-- Get_Package --
-----------------
overriding function Get_Package
(Self : not null access constant UML_Factory)
return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package
is
pragma Unreferenced (Self);
begin
return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do
Result.Add (Get_Package);
end return;
end Get_Package;
-----------------
-- Get_Package --
-----------------
function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is
begin
return
AMF.CMOF.Packages.CMOF_Package_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MM_UML_UML));
end Get_Package;
------------------------
-- Create_Abstraction --
------------------------
overriding function Create_Abstraction
(Self : not null access UML_Factory)
return AMF.UML.Abstractions.UML_Abstraction_Access is
begin
return
AMF.UML.Abstractions.UML_Abstraction_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Abstraction))));
end Create_Abstraction;
-------------------------------
-- Create_Accept_Call_Action --
-------------------------------
overriding function Create_Accept_Call_Action
(Self : not null access UML_Factory)
return AMF.UML.Accept_Call_Actions.UML_Accept_Call_Action_Access is
begin
return
AMF.UML.Accept_Call_Actions.UML_Accept_Call_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Accept_Call_Action))));
end Create_Accept_Call_Action;
--------------------------------
-- Create_Accept_Event_Action --
--------------------------------
overriding function Create_Accept_Event_Action
(Self : not null access UML_Factory)
return AMF.UML.Accept_Event_Actions.UML_Accept_Event_Action_Access is
begin
return
AMF.UML.Accept_Event_Actions.UML_Accept_Event_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Accept_Event_Action))));
end Create_Accept_Event_Action;
-------------------------------------------
-- Create_Action_Execution_Specification --
-------------------------------------------
overriding function Create_Action_Execution_Specification
(Self : not null access UML_Factory)
return AMF.UML.Action_Execution_Specifications.UML_Action_Execution_Specification_Access is
begin
return
AMF.UML.Action_Execution_Specifications.UML_Action_Execution_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Action_Execution_Specification))));
end Create_Action_Execution_Specification;
-----------------------------
-- Create_Action_Input_Pin --
-----------------------------
overriding function Create_Action_Input_Pin
(Self : not null access UML_Factory)
return AMF.UML.Action_Input_Pins.UML_Action_Input_Pin_Access is
begin
return
AMF.UML.Action_Input_Pins.UML_Action_Input_Pin_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Action_Input_Pin))));
end Create_Action_Input_Pin;
---------------------
-- Create_Activity --
---------------------
overriding function Create_Activity
(Self : not null access UML_Factory)
return AMF.UML.Activities.UML_Activity_Access is
begin
return
AMF.UML.Activities.UML_Activity_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity))));
end Create_Activity;
--------------------------------
-- Create_Activity_Final_Node --
--------------------------------
overriding function Create_Activity_Final_Node
(Self : not null access UML_Factory)
return AMF.UML.Activity_Final_Nodes.UML_Activity_Final_Node_Access is
begin
return
AMF.UML.Activity_Final_Nodes.UML_Activity_Final_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity_Final_Node))));
end Create_Activity_Final_Node;
------------------------------------
-- Create_Activity_Parameter_Node --
------------------------------------
overriding function Create_Activity_Parameter_Node
(Self : not null access UML_Factory)
return AMF.UML.Activity_Parameter_Nodes.UML_Activity_Parameter_Node_Access is
begin
return
AMF.UML.Activity_Parameter_Nodes.UML_Activity_Parameter_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity_Parameter_Node))));
end Create_Activity_Parameter_Node;
-------------------------------
-- Create_Activity_Partition --
-------------------------------
overriding function Create_Activity_Partition
(Self : not null access UML_Factory)
return AMF.UML.Activity_Partitions.UML_Activity_Partition_Access is
begin
return
AMF.UML.Activity_Partitions.UML_Activity_Partition_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Activity_Partition))));
end Create_Activity_Partition;
------------------
-- Create_Actor --
------------------
overriding function Create_Actor
(Self : not null access UML_Factory)
return AMF.UML.Actors.UML_Actor_Access is
begin
return
AMF.UML.Actors.UML_Actor_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Actor))));
end Create_Actor;
------------------------------------------------
-- Create_Add_Structural_Feature_Value_Action --
------------------------------------------------
overriding function Create_Add_Structural_Feature_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Add_Structural_Feature_Value_Actions.UML_Add_Structural_Feature_Value_Action_Access is
begin
return
AMF.UML.Add_Structural_Feature_Value_Actions.UML_Add_Structural_Feature_Value_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Add_Structural_Feature_Value_Action))));
end Create_Add_Structural_Feature_Value_Action;
--------------------------------------
-- Create_Add_Variable_Value_Action --
--------------------------------------
overriding function Create_Add_Variable_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Add_Variable_Value_Actions.UML_Add_Variable_Value_Action_Access is
begin
return
AMF.UML.Add_Variable_Value_Actions.UML_Add_Variable_Value_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Add_Variable_Value_Action))));
end Create_Add_Variable_Value_Action;
------------------------------
-- Create_Any_Receive_Event --
------------------------------
overriding function Create_Any_Receive_Event
(Self : not null access UML_Factory)
return AMF.UML.Any_Receive_Events.UML_Any_Receive_Event_Access is
begin
return
AMF.UML.Any_Receive_Events.UML_Any_Receive_Event_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Any_Receive_Event))));
end Create_Any_Receive_Event;
---------------------
-- Create_Artifact --
---------------------
overriding function Create_Artifact
(Self : not null access UML_Factory)
return AMF.UML.Artifacts.UML_Artifact_Access is
begin
return
AMF.UML.Artifacts.UML_Artifact_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Artifact))));
end Create_Artifact;
------------------------
-- Create_Association --
------------------------
overriding function Create_Association
(Self : not null access UML_Factory)
return AMF.UML.Associations.UML_Association_Access is
begin
return
AMF.UML.Associations.UML_Association_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Association))));
end Create_Association;
------------------------------
-- Create_Association_Class --
------------------------------
overriding function Create_Association_Class
(Self : not null access UML_Factory)
return AMF.UML.Association_Classes.UML_Association_Class_Access is
begin
return
AMF.UML.Association_Classes.UML_Association_Class_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Association_Class))));
end Create_Association_Class;
---------------------------------------------
-- Create_Behavior_Execution_Specification --
---------------------------------------------
overriding function Create_Behavior_Execution_Specification
(Self : not null access UML_Factory)
return AMF.UML.Behavior_Execution_Specifications.UML_Behavior_Execution_Specification_Access is
begin
return
AMF.UML.Behavior_Execution_Specifications.UML_Behavior_Execution_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Behavior_Execution_Specification))));
end Create_Behavior_Execution_Specification;
------------------------------------
-- Create_Broadcast_Signal_Action --
------------------------------------
overriding function Create_Broadcast_Signal_Action
(Self : not null access UML_Factory)
return AMF.UML.Broadcast_Signal_Actions.UML_Broadcast_Signal_Action_Access is
begin
return
AMF.UML.Broadcast_Signal_Actions.UML_Broadcast_Signal_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Broadcast_Signal_Action))));
end Create_Broadcast_Signal_Action;
---------------------------------
-- Create_Call_Behavior_Action --
---------------------------------
overriding function Create_Call_Behavior_Action
(Self : not null access UML_Factory)
return AMF.UML.Call_Behavior_Actions.UML_Call_Behavior_Action_Access is
begin
return
AMF.UML.Call_Behavior_Actions.UML_Call_Behavior_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Behavior_Action))));
end Create_Call_Behavior_Action;
-----------------------
-- Create_Call_Event --
-----------------------
overriding function Create_Call_Event
(Self : not null access UML_Factory)
return AMF.UML.Call_Events.UML_Call_Event_Access is
begin
return
AMF.UML.Call_Events.UML_Call_Event_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Event))));
end Create_Call_Event;
----------------------------------
-- Create_Call_Operation_Action --
----------------------------------
overriding function Create_Call_Operation_Action
(Self : not null access UML_Factory)
return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access is
begin
return
AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Call_Operation_Action))));
end Create_Call_Operation_Action;
--------------------------------
-- Create_Central_Buffer_Node --
--------------------------------
overriding function Create_Central_Buffer_Node
(Self : not null access UML_Factory)
return AMF.UML.Central_Buffer_Nodes.UML_Central_Buffer_Node_Access is
begin
return
AMF.UML.Central_Buffer_Nodes.UML_Central_Buffer_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Central_Buffer_Node))));
end Create_Central_Buffer_Node;
-------------------------
-- Create_Change_Event --
-------------------------
overriding function Create_Change_Event
(Self : not null access UML_Factory)
return AMF.UML.Change_Events.UML_Change_Event_Access is
begin
return
AMF.UML.Change_Events.UML_Change_Event_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Change_Event))));
end Create_Change_Event;
------------------
-- Create_Class --
------------------
overriding function Create_Class
(Self : not null access UML_Factory)
return AMF.UML.Classes.UML_Class_Access is
begin
return
AMF.UML.Classes.UML_Class_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Class))));
end Create_Class;
------------------------------------------
-- Create_Classifier_Template_Parameter --
------------------------------------------
overriding function Create_Classifier_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access is
begin
return
AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Classifier_Template_Parameter))));
end Create_Classifier_Template_Parameter;
-------------------
-- Create_Clause --
-------------------
overriding function Create_Clause
(Self : not null access UML_Factory)
return AMF.UML.Clauses.UML_Clause_Access is
begin
return
AMF.UML.Clauses.UML_Clause_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Clause))));
end Create_Clause;
-------------------------------------
-- Create_Clear_Association_Action --
-------------------------------------
overriding function Create_Clear_Association_Action
(Self : not null access UML_Factory)
return AMF.UML.Clear_Association_Actions.UML_Clear_Association_Action_Access is
begin
return
AMF.UML.Clear_Association_Actions.UML_Clear_Association_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Clear_Association_Action))));
end Create_Clear_Association_Action;
--------------------------------------------
-- Create_Clear_Structural_Feature_Action --
--------------------------------------------
overriding function Create_Clear_Structural_Feature_Action
(Self : not null access UML_Factory)
return AMF.UML.Clear_Structural_Feature_Actions.UML_Clear_Structural_Feature_Action_Access is
begin
return
AMF.UML.Clear_Structural_Feature_Actions.UML_Clear_Structural_Feature_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Clear_Structural_Feature_Action))));
end Create_Clear_Structural_Feature_Action;
----------------------------------
-- Create_Clear_Variable_Action --
----------------------------------
overriding function Create_Clear_Variable_Action
(Self : not null access UML_Factory)
return AMF.UML.Clear_Variable_Actions.UML_Clear_Variable_Action_Access is
begin
return
AMF.UML.Clear_Variable_Actions.UML_Clear_Variable_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Clear_Variable_Action))));
end Create_Clear_Variable_Action;
--------------------------
-- Create_Collaboration --
--------------------------
overriding function Create_Collaboration
(Self : not null access UML_Factory)
return AMF.UML.Collaborations.UML_Collaboration_Access is
begin
return
AMF.UML.Collaborations.UML_Collaboration_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Collaboration))));
end Create_Collaboration;
------------------------------
-- Create_Collaboration_Use --
------------------------------
overriding function Create_Collaboration_Use
(Self : not null access UML_Factory)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access is
begin
return
AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Collaboration_Use))));
end Create_Collaboration_Use;
------------------------------
-- Create_Combined_Fragment --
------------------------------
overriding function Create_Combined_Fragment
(Self : not null access UML_Factory)
return AMF.UML.Combined_Fragments.UML_Combined_Fragment_Access is
begin
return
AMF.UML.Combined_Fragments.UML_Combined_Fragment_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Combined_Fragment))));
end Create_Combined_Fragment;
--------------------
-- Create_Comment --
--------------------
overriding function Create_Comment
(Self : not null access UML_Factory)
return AMF.UML.Comments.UML_Comment_Access is
begin
return
AMF.UML.Comments.UML_Comment_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Comment))));
end Create_Comment;
-------------------------------
-- Create_Communication_Path --
-------------------------------
overriding function Create_Communication_Path
(Self : not null access UML_Factory)
return AMF.UML.Communication_Paths.UML_Communication_Path_Access is
begin
return
AMF.UML.Communication_Paths.UML_Communication_Path_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Communication_Path))));
end Create_Communication_Path;
----------------------
-- Create_Component --
----------------------
overriding function Create_Component
(Self : not null access UML_Factory)
return AMF.UML.Components.UML_Component_Access is
begin
return
AMF.UML.Components.UML_Component_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Component))));
end Create_Component;
----------------------------------
-- Create_Component_Realization --
----------------------------------
overriding function Create_Component_Realization
(Self : not null access UML_Factory)
return AMF.UML.Component_Realizations.UML_Component_Realization_Access is
begin
return
AMF.UML.Component_Realizations.UML_Component_Realization_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Component_Realization))));
end Create_Component_Realization;
-----------------------------
-- Create_Conditional_Node --
-----------------------------
overriding function Create_Conditional_Node
(Self : not null access UML_Factory)
return AMF.UML.Conditional_Nodes.UML_Conditional_Node_Access is
begin
return
AMF.UML.Conditional_Nodes.UML_Conditional_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Conditional_Node))));
end Create_Conditional_Node;
---------------------------------------------------
-- Create_Connectable_Element_Template_Parameter --
---------------------------------------------------
overriding function Create_Connectable_Element_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access is
begin
return
AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Connectable_Element_Template_Parameter))));
end Create_Connectable_Element_Template_Parameter;
---------------------------------------
-- Create_Connection_Point_Reference --
---------------------------------------
overriding function Create_Connection_Point_Reference
(Self : not null access UML_Factory)
return AMF.UML.Connection_Point_References.UML_Connection_Point_Reference_Access is
begin
return
AMF.UML.Connection_Point_References.UML_Connection_Point_Reference_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Connection_Point_Reference))));
end Create_Connection_Point_Reference;
----------------------
-- Create_Connector --
----------------------
overriding function Create_Connector
(Self : not null access UML_Factory)
return AMF.UML.Connectors.UML_Connector_Access is
begin
return
AMF.UML.Connectors.UML_Connector_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Connector))));
end Create_Connector;
--------------------------
-- Create_Connector_End --
--------------------------
overriding function Create_Connector_End
(Self : not null access UML_Factory)
return AMF.UML.Connector_Ends.UML_Connector_End_Access is
begin
return
AMF.UML.Connector_Ends.UML_Connector_End_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Connector_End))));
end Create_Connector_End;
-------------------------------------
-- Create_Consider_Ignore_Fragment --
-------------------------------------
overriding function Create_Consider_Ignore_Fragment
(Self : not null access UML_Factory)
return AMF.UML.Consider_Ignore_Fragments.UML_Consider_Ignore_Fragment_Access is
begin
return
AMF.UML.Consider_Ignore_Fragments.UML_Consider_Ignore_Fragment_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Consider_Ignore_Fragment))));
end Create_Consider_Ignore_Fragment;
-----------------------
-- Create_Constraint --
-----------------------
overriding function Create_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Constraints.UML_Constraint_Access is
begin
return
AMF.UML.Constraints.UML_Constraint_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Constraint))));
end Create_Constraint;
-------------------------
-- Create_Continuation --
-------------------------
overriding function Create_Continuation
(Self : not null access UML_Factory)
return AMF.UML.Continuations.UML_Continuation_Access is
begin
return
AMF.UML.Continuations.UML_Continuation_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Continuation))));
end Create_Continuation;
-------------------------
-- Create_Control_Flow --
-------------------------
overriding function Create_Control_Flow
(Self : not null access UML_Factory)
return AMF.UML.Control_Flows.UML_Control_Flow_Access is
begin
return
AMF.UML.Control_Flows.UML_Control_Flow_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Control_Flow))));
end Create_Control_Flow;
-------------------------------
-- Create_Create_Link_Action --
-------------------------------
overriding function Create_Create_Link_Action
(Self : not null access UML_Factory)
return AMF.UML.Create_Link_Actions.UML_Create_Link_Action_Access is
begin
return
AMF.UML.Create_Link_Actions.UML_Create_Link_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Create_Link_Action))));
end Create_Create_Link_Action;
--------------------------------------
-- Create_Create_Link_Object_Action --
--------------------------------------
overriding function Create_Create_Link_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Create_Link_Object_Actions.UML_Create_Link_Object_Action_Access is
begin
return
AMF.UML.Create_Link_Object_Actions.UML_Create_Link_Object_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Create_Link_Object_Action))));
end Create_Create_Link_Object_Action;
---------------------------------
-- Create_Create_Object_Action --
---------------------------------
overriding function Create_Create_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Create_Object_Actions.UML_Create_Object_Action_Access is
begin
return
AMF.UML.Create_Object_Actions.UML_Create_Object_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Create_Object_Action))));
end Create_Create_Object_Action;
----------------------------
-- Create_Data_Store_Node --
----------------------------
overriding function Create_Data_Store_Node
(Self : not null access UML_Factory)
return AMF.UML.Data_Store_Nodes.UML_Data_Store_Node_Access is
begin
return
AMF.UML.Data_Store_Nodes.UML_Data_Store_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Data_Store_Node))));
end Create_Data_Store_Node;
----------------------
-- Create_Data_Type --
----------------------
overriding function Create_Data_Type
(Self : not null access UML_Factory)
return AMF.UML.Data_Types.UML_Data_Type_Access is
begin
return
AMF.UML.Data_Types.UML_Data_Type_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Data_Type))));
end Create_Data_Type;
--------------------------
-- Create_Decision_Node --
--------------------------
overriding function Create_Decision_Node
(Self : not null access UML_Factory)
return AMF.UML.Decision_Nodes.UML_Decision_Node_Access is
begin
return
AMF.UML.Decision_Nodes.UML_Decision_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Decision_Node))));
end Create_Decision_Node;
-----------------------
-- Create_Dependency --
-----------------------
overriding function Create_Dependency
(Self : not null access UML_Factory)
return AMF.UML.Dependencies.UML_Dependency_Access is
begin
return
AMF.UML.Dependencies.UML_Dependency_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Dependency))));
end Create_Dependency;
-----------------------
-- Create_Deployment --
-----------------------
overriding function Create_Deployment
(Self : not null access UML_Factory)
return AMF.UML.Deployments.UML_Deployment_Access is
begin
return
AMF.UML.Deployments.UML_Deployment_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Deployment))));
end Create_Deployment;
-------------------------------------
-- Create_Deployment_Specification --
-------------------------------------
overriding function Create_Deployment_Specification
(Self : not null access UML_Factory)
return AMF.UML.Deployment_Specifications.UML_Deployment_Specification_Access is
begin
return
AMF.UML.Deployment_Specifications.UML_Deployment_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Deployment_Specification))));
end Create_Deployment_Specification;
--------------------------------
-- Create_Destroy_Link_Action --
--------------------------------
overriding function Create_Destroy_Link_Action
(Self : not null access UML_Factory)
return AMF.UML.Destroy_Link_Actions.UML_Destroy_Link_Action_Access is
begin
return
AMF.UML.Destroy_Link_Actions.UML_Destroy_Link_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Destroy_Link_Action))));
end Create_Destroy_Link_Action;
----------------------------------
-- Create_Destroy_Object_Action --
----------------------------------
overriding function Create_Destroy_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Destroy_Object_Actions.UML_Destroy_Object_Action_Access is
begin
return
AMF.UML.Destroy_Object_Actions.UML_Destroy_Object_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Destroy_Object_Action))));
end Create_Destroy_Object_Action;
-------------------------------------------------
-- Create_Destruction_Occurrence_Specification --
-------------------------------------------------
overriding function Create_Destruction_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Destruction_Occurrence_Specifications.UML_Destruction_Occurrence_Specification_Access is
begin
return
AMF.UML.Destruction_Occurrence_Specifications.UML_Destruction_Occurrence_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Destruction_Occurrence_Specification))));
end Create_Destruction_Occurrence_Specification;
-------------------
-- Create_Device --
-------------------
overriding function Create_Device
(Self : not null access UML_Factory)
return AMF.UML.Devices.UML_Device_Access is
begin
return
AMF.UML.Devices.UML_Device_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Device))));
end Create_Device;
---------------------
-- Create_Duration --
---------------------
overriding function Create_Duration
(Self : not null access UML_Factory)
return AMF.UML.Durations.UML_Duration_Access is
begin
return
AMF.UML.Durations.UML_Duration_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration))));
end Create_Duration;
--------------------------------
-- Create_Duration_Constraint --
--------------------------------
overriding function Create_Duration_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Duration_Constraints.UML_Duration_Constraint_Access is
begin
return
AMF.UML.Duration_Constraints.UML_Duration_Constraint_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration_Constraint))));
end Create_Duration_Constraint;
------------------------------
-- Create_Duration_Interval --
------------------------------
overriding function Create_Duration_Interval
(Self : not null access UML_Factory)
return AMF.UML.Duration_Intervals.UML_Duration_Interval_Access is
begin
return
AMF.UML.Duration_Intervals.UML_Duration_Interval_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration_Interval))));
end Create_Duration_Interval;
---------------------------------
-- Create_Duration_Observation --
---------------------------------
overriding function Create_Duration_Observation
(Self : not null access UML_Factory)
return AMF.UML.Duration_Observations.UML_Duration_Observation_Access is
begin
return
AMF.UML.Duration_Observations.UML_Duration_Observation_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Duration_Observation))));
end Create_Duration_Observation;
---------------------------
-- Create_Element_Import --
---------------------------
overriding function Create_Element_Import
(Self : not null access UML_Factory)
return AMF.UML.Element_Imports.UML_Element_Import_Access is
begin
return
AMF.UML.Element_Imports.UML_Element_Import_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Element_Import))));
end Create_Element_Import;
------------------------
-- Create_Enumeration --
------------------------
overriding function Create_Enumeration
(Self : not null access UML_Factory)
return AMF.UML.Enumerations.UML_Enumeration_Access is
begin
return
AMF.UML.Enumerations.UML_Enumeration_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Enumeration))));
end Create_Enumeration;
--------------------------------
-- Create_Enumeration_Literal --
--------------------------------
overriding function Create_Enumeration_Literal
(Self : not null access UML_Factory)
return AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access is
begin
return
AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Enumeration_Literal))));
end Create_Enumeration_Literal;
------------------------------
-- Create_Exception_Handler --
------------------------------
overriding function Create_Exception_Handler
(Self : not null access UML_Factory)
return AMF.UML.Exception_Handlers.UML_Exception_Handler_Access is
begin
return
AMF.UML.Exception_Handlers.UML_Exception_Handler_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Exception_Handler))));
end Create_Exception_Handler;
----------------------------------
-- Create_Execution_Environment --
----------------------------------
overriding function Create_Execution_Environment
(Self : not null access UML_Factory)
return AMF.UML.Execution_Environments.UML_Execution_Environment_Access is
begin
return
AMF.UML.Execution_Environments.UML_Execution_Environment_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Execution_Environment))));
end Create_Execution_Environment;
-----------------------------------------------
-- Create_Execution_Occurrence_Specification --
-----------------------------------------------
overriding function Create_Execution_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Execution_Occurrence_Specifications.UML_Execution_Occurrence_Specification_Access is
begin
return
AMF.UML.Execution_Occurrence_Specifications.UML_Execution_Occurrence_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Execution_Occurrence_Specification))));
end Create_Execution_Occurrence_Specification;
---------------------------
-- Create_Expansion_Node --
---------------------------
overriding function Create_Expansion_Node
(Self : not null access UML_Factory)
return AMF.UML.Expansion_Nodes.UML_Expansion_Node_Access is
begin
return
AMF.UML.Expansion_Nodes.UML_Expansion_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Expansion_Node))));
end Create_Expansion_Node;
-----------------------------
-- Create_Expansion_Region --
-----------------------------
overriding function Create_Expansion_Region
(Self : not null access UML_Factory)
return AMF.UML.Expansion_Regions.UML_Expansion_Region_Access is
begin
return
AMF.UML.Expansion_Regions.UML_Expansion_Region_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Expansion_Region))));
end Create_Expansion_Region;
-----------------------
-- Create_Expression --
-----------------------
overriding function Create_Expression
(Self : not null access UML_Factory)
return AMF.UML.Expressions.UML_Expression_Access is
begin
return
AMF.UML.Expressions.UML_Expression_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Expression))));
end Create_Expression;
-------------------
-- Create_Extend --
-------------------
overriding function Create_Extend
(Self : not null access UML_Factory)
return AMF.UML.Extends.UML_Extend_Access is
begin
return
AMF.UML.Extends.UML_Extend_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Extend))));
end Create_Extend;
----------------------
-- Create_Extension --
----------------------
overriding function Create_Extension
(Self : not null access UML_Factory)
return AMF.UML.Extensions.UML_Extension_Access is
begin
return
AMF.UML.Extensions.UML_Extension_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Extension))));
end Create_Extension;
--------------------------
-- Create_Extension_End --
--------------------------
overriding function Create_Extension_End
(Self : not null access UML_Factory)
return AMF.UML.Extension_Ends.UML_Extension_End_Access is
begin
return
AMF.UML.Extension_Ends.UML_Extension_End_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Extension_End))));
end Create_Extension_End;
----------------------------
-- Create_Extension_Point --
----------------------------
overriding function Create_Extension_Point
(Self : not null access UML_Factory)
return AMF.UML.Extension_Points.UML_Extension_Point_Access is
begin
return
AMF.UML.Extension_Points.UML_Extension_Point_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Extension_Point))));
end Create_Extension_Point;
------------------------
-- Create_Final_State --
------------------------
overriding function Create_Final_State
(Self : not null access UML_Factory)
return AMF.UML.Final_States.UML_Final_State_Access is
begin
return
AMF.UML.Final_States.UML_Final_State_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Final_State))));
end Create_Final_State;
----------------------------
-- Create_Flow_Final_Node --
----------------------------
overriding function Create_Flow_Final_Node
(Self : not null access UML_Factory)
return AMF.UML.Flow_Final_Nodes.UML_Flow_Final_Node_Access is
begin
return
AMF.UML.Flow_Final_Nodes.UML_Flow_Final_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Flow_Final_Node))));
end Create_Flow_Final_Node;
----------------------
-- Create_Fork_Node --
----------------------
overriding function Create_Fork_Node
(Self : not null access UML_Factory)
return AMF.UML.Fork_Nodes.UML_Fork_Node_Access is
begin
return
AMF.UML.Fork_Nodes.UML_Fork_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Fork_Node))));
end Create_Fork_Node;
------------------------------
-- Create_Function_Behavior --
------------------------------
overriding function Create_Function_Behavior
(Self : not null access UML_Factory)
return AMF.UML.Function_Behaviors.UML_Function_Behavior_Access is
begin
return
AMF.UML.Function_Behaviors.UML_Function_Behavior_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Function_Behavior))));
end Create_Function_Behavior;
-----------------
-- Create_Gate --
-----------------
overriding function Create_Gate
(Self : not null access UML_Factory)
return AMF.UML.Gates.UML_Gate_Access is
begin
return
AMF.UML.Gates.UML_Gate_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Gate))));
end Create_Gate;
-----------------------------
-- Create_General_Ordering --
-----------------------------
overriding function Create_General_Ordering
(Self : not null access UML_Factory)
return AMF.UML.General_Orderings.UML_General_Ordering_Access is
begin
return
AMF.UML.General_Orderings.UML_General_Ordering_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_General_Ordering))));
end Create_General_Ordering;
---------------------------
-- Create_Generalization --
---------------------------
overriding function Create_Generalization
(Self : not null access UML_Factory)
return AMF.UML.Generalizations.UML_Generalization_Access is
begin
return
AMF.UML.Generalizations.UML_Generalization_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Generalization))));
end Create_Generalization;
-------------------------------
-- Create_Generalization_Set --
-------------------------------
overriding function Create_Generalization_Set
(Self : not null access UML_Factory)
return AMF.UML.Generalization_Sets.UML_Generalization_Set_Access is
begin
return
AMF.UML.Generalization_Sets.UML_Generalization_Set_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Generalization_Set))));
end Create_Generalization_Set;
------------------
-- Create_Image --
------------------
overriding function Create_Image
(Self : not null access UML_Factory)
return AMF.UML.Images.UML_Image_Access is
begin
return
AMF.UML.Images.UML_Image_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Image))));
end Create_Image;
--------------------
-- Create_Include --
--------------------
overriding function Create_Include
(Self : not null access UML_Factory)
return AMF.UML.Includes.UML_Include_Access is
begin
return
AMF.UML.Includes.UML_Include_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Include))));
end Create_Include;
-----------------------------
-- Create_Information_Flow --
-----------------------------
overriding function Create_Information_Flow
(Self : not null access UML_Factory)
return AMF.UML.Information_Flows.UML_Information_Flow_Access is
begin
return
AMF.UML.Information_Flows.UML_Information_Flow_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Information_Flow))));
end Create_Information_Flow;
-----------------------------
-- Create_Information_Item --
-----------------------------
overriding function Create_Information_Item
(Self : not null access UML_Factory)
return AMF.UML.Information_Items.UML_Information_Item_Access is
begin
return
AMF.UML.Information_Items.UML_Information_Item_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Information_Item))));
end Create_Information_Item;
-------------------------
-- Create_Initial_Node --
-------------------------
overriding function Create_Initial_Node
(Self : not null access UML_Factory)
return AMF.UML.Initial_Nodes.UML_Initial_Node_Access is
begin
return
AMF.UML.Initial_Nodes.UML_Initial_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Initial_Node))));
end Create_Initial_Node;
----------------------
-- Create_Input_Pin --
----------------------
overriding function Create_Input_Pin
(Self : not null access UML_Factory)
return AMF.UML.Input_Pins.UML_Input_Pin_Access is
begin
return
AMF.UML.Input_Pins.UML_Input_Pin_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Input_Pin))));
end Create_Input_Pin;
-----------------------------------
-- Create_Instance_Specification --
-----------------------------------
overriding function Create_Instance_Specification
(Self : not null access UML_Factory)
return AMF.UML.Instance_Specifications.UML_Instance_Specification_Access is
begin
return
AMF.UML.Instance_Specifications.UML_Instance_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Instance_Specification))));
end Create_Instance_Specification;
---------------------------
-- Create_Instance_Value --
---------------------------
overriding function Create_Instance_Value
(Self : not null access UML_Factory)
return AMF.UML.Instance_Values.UML_Instance_Value_Access is
begin
return
AMF.UML.Instance_Values.UML_Instance_Value_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Instance_Value))));
end Create_Instance_Value;
------------------------
-- Create_Interaction --
------------------------
overriding function Create_Interaction
(Self : not null access UML_Factory)
return AMF.UML.Interactions.UML_Interaction_Access is
begin
return
AMF.UML.Interactions.UML_Interaction_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction))));
end Create_Interaction;
-----------------------------------
-- Create_Interaction_Constraint --
-----------------------------------
overriding function Create_Interaction_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Interaction_Constraints.UML_Interaction_Constraint_Access is
begin
return
AMF.UML.Interaction_Constraints.UML_Interaction_Constraint_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Constraint))));
end Create_Interaction_Constraint;
--------------------------------
-- Create_Interaction_Operand --
--------------------------------
overriding function Create_Interaction_Operand
(Self : not null access UML_Factory)
return AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access is
begin
return
AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Operand))));
end Create_Interaction_Operand;
----------------------------
-- Create_Interaction_Use --
----------------------------
overriding function Create_Interaction_Use
(Self : not null access UML_Factory)
return AMF.UML.Interaction_Uses.UML_Interaction_Use_Access is
begin
return
AMF.UML.Interaction_Uses.UML_Interaction_Use_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interaction_Use))));
end Create_Interaction_Use;
----------------------
-- Create_Interface --
----------------------
overriding function Create_Interface
(Self : not null access UML_Factory)
return AMF.UML.Interfaces.UML_Interface_Access is
begin
return
AMF.UML.Interfaces.UML_Interface_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interface))));
end Create_Interface;
----------------------------------
-- Create_Interface_Realization --
----------------------------------
overriding function Create_Interface_Realization
(Self : not null access UML_Factory)
return AMF.UML.Interface_Realizations.UML_Interface_Realization_Access is
begin
return
AMF.UML.Interface_Realizations.UML_Interface_Realization_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interface_Realization))));
end Create_Interface_Realization;
------------------------------------------
-- Create_Interruptible_Activity_Region --
------------------------------------------
overriding function Create_Interruptible_Activity_Region
(Self : not null access UML_Factory)
return AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access is
begin
return
AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interruptible_Activity_Region))));
end Create_Interruptible_Activity_Region;
---------------------
-- Create_Interval --
---------------------
overriding function Create_Interval
(Self : not null access UML_Factory)
return AMF.UML.Intervals.UML_Interval_Access is
begin
return
AMF.UML.Intervals.UML_Interval_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interval))));
end Create_Interval;
--------------------------------
-- Create_Interval_Constraint --
--------------------------------
overriding function Create_Interval_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Interval_Constraints.UML_Interval_Constraint_Access is
begin
return
AMF.UML.Interval_Constraints.UML_Interval_Constraint_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Interval_Constraint))));
end Create_Interval_Constraint;
----------------------
-- Create_Join_Node --
----------------------
overriding function Create_Join_Node
(Self : not null access UML_Factory)
return AMF.UML.Join_Nodes.UML_Join_Node_Access is
begin
return
AMF.UML.Join_Nodes.UML_Join_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Join_Node))));
end Create_Join_Node;
---------------------
-- Create_Lifeline --
---------------------
overriding function Create_Lifeline
(Self : not null access UML_Factory)
return AMF.UML.Lifelines.UML_Lifeline_Access is
begin
return
AMF.UML.Lifelines.UML_Lifeline_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Lifeline))));
end Create_Lifeline;
-----------------------------------
-- Create_Link_End_Creation_Data --
-----------------------------------
overriding function Create_Link_End_Creation_Data
(Self : not null access UML_Factory)
return AMF.UML.Link_End_Creation_Datas.UML_Link_End_Creation_Data_Access is
begin
return
AMF.UML.Link_End_Creation_Datas.UML_Link_End_Creation_Data_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Link_End_Creation_Data))));
end Create_Link_End_Creation_Data;
--------------------------
-- Create_Link_End_Data --
--------------------------
overriding function Create_Link_End_Data
(Self : not null access UML_Factory)
return AMF.UML.Link_End_Datas.UML_Link_End_Data_Access is
begin
return
AMF.UML.Link_End_Datas.UML_Link_End_Data_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Link_End_Data))));
end Create_Link_End_Data;
--------------------------------------
-- Create_Link_End_Destruction_Data --
--------------------------------------
overriding function Create_Link_End_Destruction_Data
(Self : not null access UML_Factory)
return AMF.UML.Link_End_Destruction_Datas.UML_Link_End_Destruction_Data_Access is
begin
return
AMF.UML.Link_End_Destruction_Datas.UML_Link_End_Destruction_Data_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Link_End_Destruction_Data))));
end Create_Link_End_Destruction_Data;
----------------------------
-- Create_Literal_Boolean --
----------------------------
overriding function Create_Literal_Boolean
(Self : not null access UML_Factory)
return AMF.UML.Literal_Booleans.UML_Literal_Boolean_Access is
begin
return
AMF.UML.Literal_Booleans.UML_Literal_Boolean_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Boolean))));
end Create_Literal_Boolean;
----------------------------
-- Create_Literal_Integer --
----------------------------
overriding function Create_Literal_Integer
(Self : not null access UML_Factory)
return AMF.UML.Literal_Integers.UML_Literal_Integer_Access is
begin
return
AMF.UML.Literal_Integers.UML_Literal_Integer_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Integer))));
end Create_Literal_Integer;
-------------------------
-- Create_Literal_Null --
-------------------------
overriding function Create_Literal_Null
(Self : not null access UML_Factory)
return AMF.UML.Literal_Nulls.UML_Literal_Null_Access is
begin
return
AMF.UML.Literal_Nulls.UML_Literal_Null_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Null))));
end Create_Literal_Null;
-------------------------
-- Create_Literal_Real --
-------------------------
overriding function Create_Literal_Real
(Self : not null access UML_Factory)
return AMF.UML.Literal_Reals.UML_Literal_Real_Access is
begin
return
AMF.UML.Literal_Reals.UML_Literal_Real_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Real))));
end Create_Literal_Real;
---------------------------
-- Create_Literal_String --
---------------------------
overriding function Create_Literal_String
(Self : not null access UML_Factory)
return AMF.UML.Literal_Strings.UML_Literal_String_Access is
begin
return
AMF.UML.Literal_Strings.UML_Literal_String_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_String))));
end Create_Literal_String;
--------------------------------------
-- Create_Literal_Unlimited_Natural --
--------------------------------------
overriding function Create_Literal_Unlimited_Natural
(Self : not null access UML_Factory)
return AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural_Access is
begin
return
AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Literal_Unlimited_Natural))));
end Create_Literal_Unlimited_Natural;
----------------------
-- Create_Loop_Node --
----------------------
overriding function Create_Loop_Node
(Self : not null access UML_Factory)
return AMF.UML.Loop_Nodes.UML_Loop_Node_Access is
begin
return
AMF.UML.Loop_Nodes.UML_Loop_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Loop_Node))));
end Create_Loop_Node;
--------------------------
-- Create_Manifestation --
--------------------------
overriding function Create_Manifestation
(Self : not null access UML_Factory)
return AMF.UML.Manifestations.UML_Manifestation_Access is
begin
return
AMF.UML.Manifestations.UML_Manifestation_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Manifestation))));
end Create_Manifestation;
-----------------------
-- Create_Merge_Node --
-----------------------
overriding function Create_Merge_Node
(Self : not null access UML_Factory)
return AMF.UML.Merge_Nodes.UML_Merge_Node_Access is
begin
return
AMF.UML.Merge_Nodes.UML_Merge_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Merge_Node))));
end Create_Merge_Node;
--------------------
-- Create_Message --
--------------------
overriding function Create_Message
(Self : not null access UML_Factory)
return AMF.UML.Messages.UML_Message_Access is
begin
return
AMF.UML.Messages.UML_Message_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Message))));
end Create_Message;
---------------------------------------------
-- Create_Message_Occurrence_Specification --
---------------------------------------------
overriding function Create_Message_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Message_Occurrence_Specifications.UML_Message_Occurrence_Specification_Access is
begin
return
AMF.UML.Message_Occurrence_Specifications.UML_Message_Occurrence_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Message_Occurrence_Specification))));
end Create_Message_Occurrence_Specification;
------------------
-- Create_Model --
------------------
overriding function Create_Model
(Self : not null access UML_Factory)
return AMF.UML.Models.UML_Model_Access is
begin
return
AMF.UML.Models.UML_Model_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Model))));
end Create_Model;
-----------------
-- Create_Node --
-----------------
overriding function Create_Node
(Self : not null access UML_Factory)
return AMF.UML.Nodes.UML_Node_Access is
begin
return
AMF.UML.Nodes.UML_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Node))));
end Create_Node;
------------------------
-- Create_Object_Flow --
------------------------
overriding function Create_Object_Flow
(Self : not null access UML_Factory)
return AMF.UML.Object_Flows.UML_Object_Flow_Access is
begin
return
AMF.UML.Object_Flows.UML_Object_Flow_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Object_Flow))));
end Create_Object_Flow;
-------------------------------------
-- Create_Occurrence_Specification --
-------------------------------------
overriding function Create_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Occurrence_Specifications.UML_Occurrence_Specification_Access is
begin
return
AMF.UML.Occurrence_Specifications.UML_Occurrence_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Occurrence_Specification))));
end Create_Occurrence_Specification;
--------------------------
-- Create_Opaque_Action --
--------------------------
overriding function Create_Opaque_Action
(Self : not null access UML_Factory)
return AMF.UML.Opaque_Actions.UML_Opaque_Action_Access is
begin
return
AMF.UML.Opaque_Actions.UML_Opaque_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Opaque_Action))));
end Create_Opaque_Action;
----------------------------
-- Create_Opaque_Behavior --
----------------------------
overriding function Create_Opaque_Behavior
(Self : not null access UML_Factory)
return AMF.UML.Opaque_Behaviors.UML_Opaque_Behavior_Access is
begin
return
AMF.UML.Opaque_Behaviors.UML_Opaque_Behavior_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Opaque_Behavior))));
end Create_Opaque_Behavior;
------------------------------
-- Create_Opaque_Expression --
------------------------------
overriding function Create_Opaque_Expression
(Self : not null access UML_Factory)
return AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access is
begin
return
AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Opaque_Expression))));
end Create_Opaque_Expression;
----------------------
-- Create_Operation --
----------------------
overriding function Create_Operation
(Self : not null access UML_Factory)
return AMF.UML.Operations.UML_Operation_Access is
begin
return
AMF.UML.Operations.UML_Operation_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Operation))));
end Create_Operation;
-----------------------------------------
-- Create_Operation_Template_Parameter --
-----------------------------------------
overriding function Create_Operation_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Operation_Template_Parameters.UML_Operation_Template_Parameter_Access is
begin
return
AMF.UML.Operation_Template_Parameters.UML_Operation_Template_Parameter_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Operation_Template_Parameter))));
end Create_Operation_Template_Parameter;
-----------------------
-- Create_Output_Pin --
-----------------------
overriding function Create_Output_Pin
(Self : not null access UML_Factory)
return AMF.UML.Output_Pins.UML_Output_Pin_Access is
begin
return
AMF.UML.Output_Pins.UML_Output_Pin_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Output_Pin))));
end Create_Output_Pin;
--------------------
-- Create_Package --
--------------------
overriding function Create_Package
(Self : not null access UML_Factory)
return AMF.UML.Packages.UML_Package_Access is
begin
return
AMF.UML.Packages.UML_Package_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Package))));
end Create_Package;
---------------------------
-- Create_Package_Import --
---------------------------
overriding function Create_Package_Import
(Self : not null access UML_Factory)
return AMF.UML.Package_Imports.UML_Package_Import_Access is
begin
return
AMF.UML.Package_Imports.UML_Package_Import_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Package_Import))));
end Create_Package_Import;
--------------------------
-- Create_Package_Merge --
--------------------------
overriding function Create_Package_Merge
(Self : not null access UML_Factory)
return AMF.UML.Package_Merges.UML_Package_Merge_Access is
begin
return
AMF.UML.Package_Merges.UML_Package_Merge_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Package_Merge))));
end Create_Package_Merge;
----------------------
-- Create_Parameter --
----------------------
overriding function Create_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Parameters.UML_Parameter_Access is
begin
return
AMF.UML.Parameters.UML_Parameter_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter))));
end Create_Parameter;
--------------------------
-- Create_Parameter_Set --
--------------------------
overriding function Create_Parameter_Set
(Self : not null access UML_Factory)
return AMF.UML.Parameter_Sets.UML_Parameter_Set_Access is
begin
return
AMF.UML.Parameter_Sets.UML_Parameter_Set_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Parameter_Set))));
end Create_Parameter_Set;
-------------------------------
-- Create_Part_Decomposition --
-------------------------------
overriding function Create_Part_Decomposition
(Self : not null access UML_Factory)
return AMF.UML.Part_Decompositions.UML_Part_Decomposition_Access is
begin
return
AMF.UML.Part_Decompositions.UML_Part_Decomposition_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Part_Decomposition))));
end Create_Part_Decomposition;
-----------------
-- Create_Port --
-----------------
overriding function Create_Port
(Self : not null access UML_Factory)
return AMF.UML.Ports.UML_Port_Access is
begin
return
AMF.UML.Ports.UML_Port_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Port))));
end Create_Port;
---------------------------
-- Create_Primitive_Type --
---------------------------
overriding function Create_Primitive_Type
(Self : not null access UML_Factory)
return AMF.UML.Primitive_Types.UML_Primitive_Type_Access is
begin
return
AMF.UML.Primitive_Types.UML_Primitive_Type_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Primitive_Type))));
end Create_Primitive_Type;
--------------------
-- Create_Profile --
--------------------
overriding function Create_Profile
(Self : not null access UML_Factory)
return AMF.UML.Profiles.UML_Profile_Access is
begin
return
AMF.UML.Profiles.UML_Profile_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Profile))));
end Create_Profile;
--------------------------------
-- Create_Profile_Application --
--------------------------------
overriding function Create_Profile_Application
(Self : not null access UML_Factory)
return AMF.UML.Profile_Applications.UML_Profile_Application_Access is
begin
return
AMF.UML.Profile_Applications.UML_Profile_Application_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Profile_Application))));
end Create_Profile_Application;
---------------------
-- Create_Property --
---------------------
overriding function Create_Property
(Self : not null access UML_Factory)
return AMF.UML.Properties.UML_Property_Access is
begin
return
AMF.UML.Properties.UML_Property_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Property))));
end Create_Property;
---------------------------------
-- Create_Protocol_Conformance --
---------------------------------
overriding function Create_Protocol_Conformance
(Self : not null access UML_Factory)
return AMF.UML.Protocol_Conformances.UML_Protocol_Conformance_Access is
begin
return
AMF.UML.Protocol_Conformances.UML_Protocol_Conformance_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Protocol_Conformance))));
end Create_Protocol_Conformance;
-----------------------------------
-- Create_Protocol_State_Machine --
-----------------------------------
overriding function Create_Protocol_State_Machine
(Self : not null access UML_Factory)
return AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access is
begin
return
AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Protocol_State_Machine))));
end Create_Protocol_State_Machine;
--------------------------------
-- Create_Protocol_Transition --
--------------------------------
overriding function Create_Protocol_Transition
(Self : not null access UML_Factory)
return AMF.UML.Protocol_Transitions.UML_Protocol_Transition_Access is
begin
return
AMF.UML.Protocol_Transitions.UML_Protocol_Transition_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Protocol_Transition))));
end Create_Protocol_Transition;
------------------------
-- Create_Pseudostate --
------------------------
overriding function Create_Pseudostate
(Self : not null access UML_Factory)
return AMF.UML.Pseudostates.UML_Pseudostate_Access is
begin
return
AMF.UML.Pseudostates.UML_Pseudostate_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Pseudostate))));
end Create_Pseudostate;
----------------------------
-- Create_Qualifier_Value --
----------------------------
overriding function Create_Qualifier_Value
(Self : not null access UML_Factory)
return AMF.UML.Qualifier_Values.UML_Qualifier_Value_Access is
begin
return
AMF.UML.Qualifier_Values.UML_Qualifier_Value_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Qualifier_Value))));
end Create_Qualifier_Value;
-----------------------------------
-- Create_Raise_Exception_Action --
-----------------------------------
overriding function Create_Raise_Exception_Action
(Self : not null access UML_Factory)
return AMF.UML.Raise_Exception_Actions.UML_Raise_Exception_Action_Access is
begin
return
AMF.UML.Raise_Exception_Actions.UML_Raise_Exception_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Raise_Exception_Action))));
end Create_Raise_Exception_Action;
-------------------------------
-- Create_Read_Extent_Action --
-------------------------------
overriding function Create_Read_Extent_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Extent_Actions.UML_Read_Extent_Action_Access is
begin
return
AMF.UML.Read_Extent_Actions.UML_Read_Extent_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Extent_Action))));
end Create_Read_Extent_Action;
---------------------------------------------
-- Create_Read_Is_Classified_Object_Action --
---------------------------------------------
overriding function Create_Read_Is_Classified_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Is_Classified_Object_Actions.UML_Read_Is_Classified_Object_Action_Access is
begin
return
AMF.UML.Read_Is_Classified_Object_Actions.UML_Read_Is_Classified_Object_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Is_Classified_Object_Action))));
end Create_Read_Is_Classified_Object_Action;
-----------------------------
-- Create_Read_Link_Action --
-----------------------------
overriding function Create_Read_Link_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Link_Actions.UML_Read_Link_Action_Access is
begin
return
AMF.UML.Read_Link_Actions.UML_Read_Link_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Link_Action))));
end Create_Read_Link_Action;
----------------------------------------
-- Create_Read_Link_Object_End_Action --
----------------------------------------
overriding function Create_Read_Link_Object_End_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Link_Object_End_Actions.UML_Read_Link_Object_End_Action_Access is
begin
return
AMF.UML.Read_Link_Object_End_Actions.UML_Read_Link_Object_End_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Link_Object_End_Action))));
end Create_Read_Link_Object_End_Action;
--------------------------------------------------
-- Create_Read_Link_Object_End_Qualifier_Action --
--------------------------------------------------
overriding function Create_Read_Link_Object_End_Qualifier_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Link_Object_End_Qualifier_Actions.UML_Read_Link_Object_End_Qualifier_Action_Access is
begin
return
AMF.UML.Read_Link_Object_End_Qualifier_Actions.UML_Read_Link_Object_End_Qualifier_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Link_Object_End_Qualifier_Action))));
end Create_Read_Link_Object_End_Qualifier_Action;
-----------------------------
-- Create_Read_Self_Action --
-----------------------------
overriding function Create_Read_Self_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Self_Actions.UML_Read_Self_Action_Access is
begin
return
AMF.UML.Read_Self_Actions.UML_Read_Self_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Self_Action))));
end Create_Read_Self_Action;
-------------------------------------------
-- Create_Read_Structural_Feature_Action --
-------------------------------------------
overriding function Create_Read_Structural_Feature_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Structural_Feature_Actions.UML_Read_Structural_Feature_Action_Access is
begin
return
AMF.UML.Read_Structural_Feature_Actions.UML_Read_Structural_Feature_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Structural_Feature_Action))));
end Create_Read_Structural_Feature_Action;
---------------------------------
-- Create_Read_Variable_Action --
---------------------------------
overriding function Create_Read_Variable_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Variable_Actions.UML_Read_Variable_Action_Access is
begin
return
AMF.UML.Read_Variable_Actions.UML_Read_Variable_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Read_Variable_Action))));
end Create_Read_Variable_Action;
------------------------
-- Create_Realization --
------------------------
overriding function Create_Realization
(Self : not null access UML_Factory)
return AMF.UML.Realizations.UML_Realization_Access is
begin
return
AMF.UML.Realizations.UML_Realization_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Realization))));
end Create_Realization;
----------------------
-- Create_Reception --
----------------------
overriding function Create_Reception
(Self : not null access UML_Factory)
return AMF.UML.Receptions.UML_Reception_Access is
begin
return
AMF.UML.Receptions.UML_Reception_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Reception))));
end Create_Reception;
-------------------------------------
-- Create_Reclassify_Object_Action --
-------------------------------------
overriding function Create_Reclassify_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Reclassify_Object_Actions.UML_Reclassify_Object_Action_Access is
begin
return
AMF.UML.Reclassify_Object_Actions.UML_Reclassify_Object_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Reclassify_Object_Action))));
end Create_Reclassify_Object_Action;
-------------------------------------------
-- Create_Redefinable_Template_Signature --
-------------------------------------------
overriding function Create_Redefinable_Template_Signature
(Self : not null access UML_Factory)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access is
begin
return
AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Redefinable_Template_Signature))));
end Create_Redefinable_Template_Signature;
--------------------------
-- Create_Reduce_Action --
--------------------------
overriding function Create_Reduce_Action
(Self : not null access UML_Factory)
return AMF.UML.Reduce_Actions.UML_Reduce_Action_Access is
begin
return
AMF.UML.Reduce_Actions.UML_Reduce_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Reduce_Action))));
end Create_Reduce_Action;
-------------------
-- Create_Region --
-------------------
overriding function Create_Region
(Self : not null access UML_Factory)
return AMF.UML.Regions.UML_Region_Access is
begin
return
AMF.UML.Regions.UML_Region_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Region))));
end Create_Region;
---------------------------------------------------
-- Create_Remove_Structural_Feature_Value_Action --
---------------------------------------------------
overriding function Create_Remove_Structural_Feature_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Remove_Structural_Feature_Value_Actions.UML_Remove_Structural_Feature_Value_Action_Access is
begin
return
AMF.UML.Remove_Structural_Feature_Value_Actions.UML_Remove_Structural_Feature_Value_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Remove_Structural_Feature_Value_Action))));
end Create_Remove_Structural_Feature_Value_Action;
-----------------------------------------
-- Create_Remove_Variable_Value_Action --
-----------------------------------------
overriding function Create_Remove_Variable_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Remove_Variable_Value_Actions.UML_Remove_Variable_Value_Action_Access is
begin
return
AMF.UML.Remove_Variable_Value_Actions.UML_Remove_Variable_Value_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Remove_Variable_Value_Action))));
end Create_Remove_Variable_Value_Action;
-------------------------
-- Create_Reply_Action --
-------------------------
overriding function Create_Reply_Action
(Self : not null access UML_Factory)
return AMF.UML.Reply_Actions.UML_Reply_Action_Access is
begin
return
AMF.UML.Reply_Actions.UML_Reply_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Reply_Action))));
end Create_Reply_Action;
-------------------------------
-- Create_Send_Object_Action --
-------------------------------
overriding function Create_Send_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access is
begin
return
AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Send_Object_Action))));
end Create_Send_Object_Action;
-------------------------------
-- Create_Send_Signal_Action --
-------------------------------
overriding function Create_Send_Signal_Action
(Self : not null access UML_Factory)
return AMF.UML.Send_Signal_Actions.UML_Send_Signal_Action_Access is
begin
return
AMF.UML.Send_Signal_Actions.UML_Send_Signal_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Send_Signal_Action))));
end Create_Send_Signal_Action;
--------------------------
-- Create_Sequence_Node --
--------------------------
overriding function Create_Sequence_Node
(Self : not null access UML_Factory)
return AMF.UML.Sequence_Nodes.UML_Sequence_Node_Access is
begin
return
AMF.UML.Sequence_Nodes.UML_Sequence_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Sequence_Node))));
end Create_Sequence_Node;
-------------------
-- Create_Signal --
-------------------
overriding function Create_Signal
(Self : not null access UML_Factory)
return AMF.UML.Signals.UML_Signal_Access is
begin
return
AMF.UML.Signals.UML_Signal_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Signal))));
end Create_Signal;
-------------------------
-- Create_Signal_Event --
-------------------------
overriding function Create_Signal_Event
(Self : not null access UML_Factory)
return AMF.UML.Signal_Events.UML_Signal_Event_Access is
begin
return
AMF.UML.Signal_Events.UML_Signal_Event_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Signal_Event))));
end Create_Signal_Event;
-----------------
-- Create_Slot --
-----------------
overriding function Create_Slot
(Self : not null access UML_Factory)
return AMF.UML.Slots.UML_Slot_Access is
begin
return
AMF.UML.Slots.UML_Slot_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Slot))));
end Create_Slot;
---------------------------------------------
-- Create_Start_Classifier_Behavior_Action --
---------------------------------------------
overriding function Create_Start_Classifier_Behavior_Action
(Self : not null access UML_Factory)
return AMF.UML.Start_Classifier_Behavior_Actions.UML_Start_Classifier_Behavior_Action_Access is
begin
return
AMF.UML.Start_Classifier_Behavior_Actions.UML_Start_Classifier_Behavior_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Start_Classifier_Behavior_Action))));
end Create_Start_Classifier_Behavior_Action;
-----------------------------------------
-- Create_Start_Object_Behavior_Action --
-----------------------------------------
overriding function Create_Start_Object_Behavior_Action
(Self : not null access UML_Factory)
return AMF.UML.Start_Object_Behavior_Actions.UML_Start_Object_Behavior_Action_Access is
begin
return
AMF.UML.Start_Object_Behavior_Actions.UML_Start_Object_Behavior_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Start_Object_Behavior_Action))));
end Create_Start_Object_Behavior_Action;
------------------
-- Create_State --
------------------
overriding function Create_State
(Self : not null access UML_Factory)
return AMF.UML.States.UML_State_Access is
begin
return
AMF.UML.States.UML_State_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_State))));
end Create_State;
----------------------------
-- Create_State_Invariant --
----------------------------
overriding function Create_State_Invariant
(Self : not null access UML_Factory)
return AMF.UML.State_Invariants.UML_State_Invariant_Access is
begin
return
AMF.UML.State_Invariants.UML_State_Invariant_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_State_Invariant))));
end Create_State_Invariant;
--------------------------
-- Create_State_Machine --
--------------------------
overriding function Create_State_Machine
(Self : not null access UML_Factory)
return AMF.UML.State_Machines.UML_State_Machine_Access is
begin
return
AMF.UML.State_Machines.UML_State_Machine_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_State_Machine))));
end Create_State_Machine;
-----------------------
-- Create_Stereotype --
-----------------------
overriding function Create_Stereotype
(Self : not null access UML_Factory)
return AMF.UML.Stereotypes.UML_Stereotype_Access is
begin
return
AMF.UML.Stereotypes.UML_Stereotype_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Stereotype))));
end Create_Stereotype;
------------------------------
-- Create_String_Expression --
------------------------------
overriding function Create_String_Expression
(Self : not null access UML_Factory)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_String_Expression))));
end Create_String_Expression;
-------------------------------------
-- Create_Structured_Activity_Node --
-------------------------------------
overriding function Create_Structured_Activity_Node
(Self : not null access UML_Factory)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is
begin
return
AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Structured_Activity_Node))));
end Create_Structured_Activity_Node;
-------------------------
-- Create_Substitution --
-------------------------
overriding function Create_Substitution
(Self : not null access UML_Factory)
return AMF.UML.Substitutions.UML_Substitution_Access is
begin
return
AMF.UML.Substitutions.UML_Substitution_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Substitution))));
end Create_Substitution;
-----------------------------
-- Create_Template_Binding --
-----------------------------
overriding function Create_Template_Binding
(Self : not null access UML_Factory)
return AMF.UML.Template_Bindings.UML_Template_Binding_Access is
begin
return
AMF.UML.Template_Bindings.UML_Template_Binding_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Binding))));
end Create_Template_Binding;
-------------------------------
-- Create_Template_Parameter --
-------------------------------
overriding function Create_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Parameter))));
end Create_Template_Parameter;
--------------------------------------------
-- Create_Template_Parameter_Substitution --
--------------------------------------------
overriding function Create_Template_Parameter_Substitution
(Self : not null access UML_Factory)
return AMF.UML.Template_Parameter_Substitutions.UML_Template_Parameter_Substitution_Access is
begin
return
AMF.UML.Template_Parameter_Substitutions.UML_Template_Parameter_Substitution_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Parameter_Substitution))));
end Create_Template_Parameter_Substitution;
-------------------------------
-- Create_Template_Signature --
-------------------------------
overriding function Create_Template_Signature
(Self : not null access UML_Factory)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access is
begin
return
AMF.UML.Template_Signatures.UML_Template_Signature_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Template_Signature))));
end Create_Template_Signature;
---------------------------------
-- Create_Test_Identity_Action --
---------------------------------
overriding function Create_Test_Identity_Action
(Self : not null access UML_Factory)
return AMF.UML.Test_Identity_Actions.UML_Test_Identity_Action_Access is
begin
return
AMF.UML.Test_Identity_Actions.UML_Test_Identity_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Test_Identity_Action))));
end Create_Test_Identity_Action;
----------------------------
-- Create_Time_Constraint --
----------------------------
overriding function Create_Time_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Time_Constraints.UML_Time_Constraint_Access is
begin
return
AMF.UML.Time_Constraints.UML_Time_Constraint_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Constraint))));
end Create_Time_Constraint;
-----------------------
-- Create_Time_Event --
-----------------------
overriding function Create_Time_Event
(Self : not null access UML_Factory)
return AMF.UML.Time_Events.UML_Time_Event_Access is
begin
return
AMF.UML.Time_Events.UML_Time_Event_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Event))));
end Create_Time_Event;
----------------------------
-- Create_Time_Expression --
----------------------------
overriding function Create_Time_Expression
(Self : not null access UML_Factory)
return AMF.UML.Time_Expressions.UML_Time_Expression_Access is
begin
return
AMF.UML.Time_Expressions.UML_Time_Expression_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Expression))));
end Create_Time_Expression;
--------------------------
-- Create_Time_Interval --
--------------------------
overriding function Create_Time_Interval
(Self : not null access UML_Factory)
return AMF.UML.Time_Intervals.UML_Time_Interval_Access is
begin
return
AMF.UML.Time_Intervals.UML_Time_Interval_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Interval))));
end Create_Time_Interval;
-----------------------------
-- Create_Time_Observation --
-----------------------------
overriding function Create_Time_Observation
(Self : not null access UML_Factory)
return AMF.UML.Time_Observations.UML_Time_Observation_Access is
begin
return
AMF.UML.Time_Observations.UML_Time_Observation_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Time_Observation))));
end Create_Time_Observation;
-----------------------
-- Create_Transition --
-----------------------
overriding function Create_Transition
(Self : not null access UML_Factory)
return AMF.UML.Transitions.UML_Transition_Access is
begin
return
AMF.UML.Transitions.UML_Transition_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Transition))));
end Create_Transition;
--------------------
-- Create_Trigger --
--------------------
overriding function Create_Trigger
(Self : not null access UML_Factory)
return AMF.UML.Triggers.UML_Trigger_Access is
begin
return
AMF.UML.Triggers.UML_Trigger_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Trigger))));
end Create_Trigger;
------------------------------
-- Create_Unmarshall_Action --
------------------------------
overriding function Create_Unmarshall_Action
(Self : not null access UML_Factory)
return AMF.UML.Unmarshall_Actions.UML_Unmarshall_Action_Access is
begin
return
AMF.UML.Unmarshall_Actions.UML_Unmarshall_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Unmarshall_Action))));
end Create_Unmarshall_Action;
------------------
-- Create_Usage --
------------------
overriding function Create_Usage
(Self : not null access UML_Factory)
return AMF.UML.Usages.UML_Usage_Access is
begin
return
AMF.UML.Usages.UML_Usage_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Usage))));
end Create_Usage;
---------------------
-- Create_Use_Case --
---------------------
overriding function Create_Use_Case
(Self : not null access UML_Factory)
return AMF.UML.Use_Cases.UML_Use_Case_Access is
begin
return
AMF.UML.Use_Cases.UML_Use_Case_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Use_Case))));
end Create_Use_Case;
----------------------
-- Create_Value_Pin --
----------------------
overriding function Create_Value_Pin
(Self : not null access UML_Factory)
return AMF.UML.Value_Pins.UML_Value_Pin_Access is
begin
return
AMF.UML.Value_Pins.UML_Value_Pin_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Value_Pin))));
end Create_Value_Pin;
---------------------------------------
-- Create_Value_Specification_Action --
---------------------------------------
overriding function Create_Value_Specification_Action
(Self : not null access UML_Factory)
return AMF.UML.Value_Specification_Actions.UML_Value_Specification_Action_Access is
begin
return
AMF.UML.Value_Specification_Actions.UML_Value_Specification_Action_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Value_Specification_Action))));
end Create_Value_Specification_Action;
---------------------
-- Create_Variable --
---------------------
overriding function Create_Variable
(Self : not null access UML_Factory)
return AMF.UML.Variables.UML_Variable_Access is
begin
return
AMF.UML.Variables.UML_Variable_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Metamodel.MC_UML_Variable))));
end Create_Variable;
end AMF.Internals.Factories.UML_Factories;
|
-- Abstract :
--
-- Type and operations for building grammar productions.
--
-- Copyright (C) 2018 - 2020 Free Software Foundation, Inc.
--
-- This file is part of the WisiToken package.
--
-- The WisiToken package is free software; you can redistribute it
-- and/or modify it under terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or
-- (at your option) any later version. This library is distributed in
-- the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-- even the implied warranty of MERCHAN- TABILITY or FITNESS FOR A
-- PARTICULAR PURPOSE.
--
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
with SAL.Gen_Unbounded_Definite_Vectors;
with WisiToken.Semantic_Checks;
with WisiToken.Syntax_Trees;
package WisiToken.Productions is
use all type Ada.Containers.Count_Type;
package Recursion_Arrays is new SAL.Gen_Unbounded_Definite_Vectors
(Positive, Recursion_Class, Default_Element => None);
function Image (Item : in Recursion_Arrays.Vector) return String;
-- For parse_table
type Right_Hand_Side is record
Tokens : Token_ID_Arrays.Vector;
Recursion : Recursion_Arrays.Vector;
-- Recursion for each token. There may be more than one recursion cycle for any token,
-- but we don't track that.
Action : WisiToken.Syntax_Trees.Semantic_Action;
Check : WisiToken.Semantic_Checks.Semantic_Check;
end record
with Dynamic_Predicate =>
(Tokens.Length = 0 or Tokens.First_Index = 1) and
(Recursion.Length = 0 or
(Recursion.First_Index = Tokens.First_Index and Recursion.Last_Index = Tokens.Last_Index));
package RHS_Arrays is new SAL.Gen_Unbounded_Definite_Vectors
(Natural, Right_Hand_Side, Default_Element => (others => <>));
type Instance is record
LHS : Token_ID := Invalid_Token_ID;
RHSs : RHS_Arrays.Vector;
end record;
package Prod_Arrays is new SAL.Gen_Unbounded_Definite_Vectors
(Token_ID, Instance, Default_Element => (others => <>));
function Constant_Ref_RHS
(Grammar : in Prod_Arrays.Vector;
ID : in Production_ID)
return RHS_Arrays.Constant_Reference_Type;
function Image
(LHS : in Token_ID;
RHS_Index : in Natural;
RHS : in Token_ID_Arrays.Vector;
Descriptor : in WisiToken.Descriptor)
return String;
-- For comments in generated code, diagnostic messages.
procedure Put (Grammar : Prod_Arrays.Vector; Descriptor : in WisiToken.Descriptor);
-- Put Image of each production to Ada.Text_IO.Current_Output, for parse_table.
package Line_Number_Arrays is new SAL.Gen_Unbounded_Definite_Vectors
(Natural, Line_Number_Type, Default_Element => Invalid_Line_Number);
type Prod_Source_Line_Map is record
Line : Line_Number_Type := Invalid_Line_Number;
RHS_Map : Line_Number_Arrays.Vector;
end record;
package Source_Line_Maps is new SAL.Gen_Unbounded_Definite_Vectors
(Token_ID, Prod_Source_Line_Map, Default_Element => (others => <>));
-- For line numbers of productions in source files.
end WisiToken.Productions;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
begin
Put_Line ("ABC123")
end Test;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Slim.Messages.ANIC;
with Slim.Messages.BUTN;
with Slim.Messages.DSCO;
with Slim.Messages.HELO;
with Slim.Messages.IR;
with Slim.Messages.META;
with Slim.Messages.RESP;
with Slim.Messages.SETD;
with Slim.Messages.STAT;
with Slim.Messages.aude;
with Slim.Messages.audg;
with Slim.Messages.audp;
with Slim.Messages.bdac;
with Slim.Messages.bled;
with Slim.Messages.cont;
with Slim.Messages.grfb;
with Slim.Messages.grfe;
with Slim.Messages.grfg;
with Slim.Messages.grfs;
with Slim.Messages.rtcs;
with Slim.Messages.Server_setd;
with Slim.Messages.strm;
with Slim.Messages.vers;
with Slim.Messages.visu;
package Slim.Message_Visiters is
type Visiter is limited interface;
not overriding procedure ANIC
(Self : in out Visiter;
Message : not null access Slim.Messages.ANIC.ANIC_Message) is null;
not overriding procedure BUTN
(Self : in out Visiter;
Message : not null access Slim.Messages.BUTN.BUTN_Message) is null;
not overriding procedure DSCO
(Self : in out Visiter;
Message : not null access Slim.Messages.DSCO.DSCO_Message) is null;
not overriding procedure HELO
(Self : in out Visiter;
Message : not null access Slim.Messages.HELO.HELO_Message) is null;
not overriding procedure IR
(Self : in out Visiter;
Message : not null access Slim.Messages.IR.IR_Message) is null;
not overriding procedure META
(Self : in out Visiter;
Message : not null access Slim.Messages.META.META_Message) is null;
not overriding procedure RESP
(Self : in out Visiter;
Message : not null access Slim.Messages.RESP.RESP_Message) is null;
not overriding procedure SETD
(Self : in out Visiter;
Message : not null access Slim.Messages.SETD.SETD_Message) is null;
not overriding procedure STAT
(Self : in out Visiter;
Message : not null access Slim.Messages.STAT.STAT_Message) is null;
not overriding procedure aude
(Self : in out Visiter;
Message : not null access Slim.Messages.aude.Aude_Message) is null;
not overriding procedure audg
(Self : in out Visiter;
Message : not null access Slim.Messages.audg.Audg_Message) is null;
not overriding procedure audp
(Self : in out Visiter;
Message : not null access Slim.Messages.audp.Audp_Message) is null;
not overriding procedure bdac
(Self : in out Visiter;
Message : not null access Slim.Messages.bdac.Bdac_Message) is null;
not overriding procedure bled
(Self : in out Visiter;
Message : not null access Slim.Messages.bled.Bled_Message) is null;
not overriding procedure cont
(Self : in out Visiter;
Message : not null access Slim.Messages.cont.Cont_Message) is null;
not overriding procedure grfb
(Self : in out Visiter;
Message : not null access Slim.Messages.grfb.Grfb_Message) is null;
not overriding procedure grfe
(Self : in out Visiter;
Message : not null access Slim.Messages.grfe.Grfe_Message) is null;
not overriding procedure grfg
(Self : in out Visiter;
Message : not null access Slim.Messages.grfg.Grfg_Message) is null;
not overriding procedure grfs
(Self : in out Visiter;
Message : not null access Slim.Messages.grfs.Grfs_Message) is null;
not overriding procedure rtcs
(Self : in out Visiter;
Message : not null access Slim.Messages.rtcs.Rtcs_Message) is null;
not overriding procedure setd
(Self : in out Visiter;
Message : not null access Slim.Messages.Server_setd.Setd_Message)
is null;
not overriding procedure strm
(Self : in out Visiter;
Message : not null access Slim.Messages.strm.Strm_Message) is null;
not overriding procedure vers
(Self : in out Visiter;
Message : not null access Slim.Messages.vers.Vers_Message) is null;
not overriding procedure visu
(Self : in out Visiter;
Message : not null access Slim.Messages.visu.Visu_Message) is null;
end Slim.Message_Visiters;
|
pragma Check_Policy (Validate => Disable);
-- with Ada.Strings.Naked_Maps.Debug;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.UTF_Conversions.From_8_To_32;
with System.UTF_Conversions.From_16_To_32;
with System.UTF_Conversions.From_32_To_8;
with System.UTF_Conversions.From_32_To_16;
package body Ada.Strings.Maps is
use type Naked_Maps.Character_Ranges;
-- sets
subtype Nonnull_Set_Data_Access is not null Set_Data_Access;
function Upcast is
new Unchecked_Conversion (
Nonnull_Set_Data_Access,
System.Reference_Counting.Container);
function Downcast is
new Unchecked_Conversion (
System.Reference_Counting.Container,
Nonnull_Set_Data_Access);
type Set_Data_Access_Access is access all Nonnull_Set_Data_Access;
type Container_Access is access all System.Reference_Counting.Container;
function Upcast is
new Unchecked_Conversion (Set_Data_Access_Access, Container_Access);
procedure Free is new Unchecked_Deallocation (Set_Data, Set_Data_Access);
procedure Free_Set_Data (
Data : in out System.Reference_Counting.Data_Access);
procedure Free_Set_Data (
Data : in out System.Reference_Counting.Data_Access)
is
X : Set_Data_Access := Downcast (Data);
begin
Free (X);
Data := null;
end Free_Set_Data;
function Copy_Set_Data (Items : Naked_Maps.Character_Ranges)
return not null Set_Data_Access;
function Copy_Set_Data (Items : Naked_Maps.Character_Ranges)
return not null Set_Data_Access
is
Result : Set_Data_Access;
begin
if Items'Length = 0 then
Result := Empty_Set_Data'Unrestricted_Access;
else
Result := new Set_Data'(
Length => Items'Length,
Reference_Count => 1,
Items => Items);
end if;
return Result;
end Copy_Set_Data;
-- "-" operation
procedure Sub (
Result : in out Naked_Maps.Character_Ranges;
Last : out Natural;
Left, Right : Naked_Maps.Character_Ranges);
procedure Sub (
Result : in out Naked_Maps.Character_Ranges;
Last : out Natural;
Left, Right : Naked_Maps.Character_Ranges)
is
I : Positive := Left'First;
J : Positive := Right'First;
begin
Last := Result'First - 1;
while I <= Left'Last and then J <= Right'Last loop
if Left (I).High < Right (I).Low then
Last := Last + 1;
Result (Last) := Left (I);
I := I + 1;
elsif Left (J).Low > Right (I).High then
J := J + 1;
else
declare
L : Wide_Wide_Character := Left (I).Low;
begin
while L <= Left (I).High and then J <= Right'Last loop
if L < Right (J).Low then
Last := Last + 1;
Result (Last).Low := L;
Result (Last).High :=
Wide_Wide_Character'Pred (Right (J).Low);
end if;
L := Wide_Wide_Character'Succ (Right (J).High);
if Right (J).High <= Left (I).High then
J := J + 1;
end if;
end loop;
if L <= Left (I).High then
Last := Last + 1;
Result (Last).Low := L;
Result (Last).High := Left (I).High;
end if;
I := I + 1;
end;
end if;
end loop;
-- right is over
while I <= Left'Last loop
Last := Last + 1;
Result (Last) := Left (I);
I := I + 1;
end loop;
end Sub;
Full_Set_Data : aliased constant Set_Data := (
Length => 1,
Reference_Count => System.Reference_Counting.Static,
Items => (1 => (Wide_Wide_Character'First, Wide_Wide_Character'Last)));
-- implementation of sets
function Null_Set return Character_Set is
begin
return Create (Empty_Set_Data'Unrestricted_Access);
end Null_Set;
function Is_Null (Set : Character_Set) return Boolean is
begin
return Controlled_Sets.Reference (Set).Length = 0;
end Is_Null;
function Overloaded_To_Set (Ranges : Character_Ranges)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (1 .. Ranges'Length);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
for I in Ranges'Range loop
declare
E : Character_Range renames Ranges (I);
begin
if E.Low <= E.High then
Naked_Maps.Add (
Items,
Last,
Naked_Maps.To_Wide_Wide_Character (E.Low),
Naked_Maps.To_Wide_Wide_Character (E.High));
end if;
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Ranges : Wide_Character_Ranges)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (1 .. Ranges'Length);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
for I in Ranges'Range loop
declare
E : Wide_Character_Range renames Ranges (I);
begin
if E.Low <= E.High then
Naked_Maps.Add (
Items,
Last,
Naked_Maps.To_Wide_Wide_Character (E.Low),
Naked_Maps.To_Wide_Wide_Character (E.High));
end if;
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Ranges : Wide_Wide_Character_Ranges)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (1 .. Ranges'Length);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
for I in Ranges'Range loop
declare
E : Wide_Wide_Character_Range renames Ranges (I);
begin
if E.Low <= E.High then
Naked_Maps.Add (Items, Last, E.Low, E.High);
end if;
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Span : Character_Range)
return Character_Set is
begin
return Overloaded_To_Set (
Wide_Wide_Character_Range'(
Naked_Maps.To_Wide_Wide_Character (Span.Low),
Naked_Maps.To_Wide_Wide_Character (Span.High)));
end Overloaded_To_Set;
function Overloaded_To_Set (Span : Wide_Character_Range)
return Character_Set is
begin
return Overloaded_To_Set (
Wide_Wide_Character_Range'(
Naked_Maps.To_Wide_Wide_Character (Span.Low),
Naked_Maps.To_Wide_Wide_Character (Span.High)));
end Overloaded_To_Set;
function Overloaded_To_Set (Span : Wide_Wide_Character_Range)
return Character_Set
is
Data : Set_Data_Access;
begin
if Span.Low > Span.High then
Data := Empty_Set_Data'Unrestricted_Access;
else
Data := new Set_Data'(
Length => 1,
Reference_Count => 1,
Items => <>);
Data.Items (Data.Items'First).Low := Span.Low;
Data.Items (Data.Items'First).High := Span.High;
end if;
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Ranges (Set : Character_Set)
return Character_Ranges
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Result : Character_Ranges (Set_Data.Items'Range) do
for I in Result'Range loop
Result (I).Low :=
Naked_Maps.To_Character (Set_Data.Items (I).Low);
Result (I).High :=
Naked_Maps.To_Character (Set_Data.Items (I).High);
end loop;
end return;
end Overloaded_To_Ranges;
function Overloaded_To_Ranges (Set : Character_Set)
return Wide_Character_Ranges
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Result : Wide_Character_Ranges (Set_Data.Items'Range) do
for I in Result'Range loop
Result (I).Low :=
Naked_Maps.To_Wide_Character (Set_Data.Items (I).Low);
Result (I).High :=
Naked_Maps.To_Wide_Character (Set_Data.Items (I).High);
end loop;
end return;
end Overloaded_To_Ranges;
function Overloaded_To_Ranges (Set : Character_Set)
return Wide_Wide_Character_Ranges
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Result : Wide_Wide_Character_Ranges (Set_Data.Items'Range) do
for I in Result'Range loop
Result (I).Low := Set_Data.Items (I).Low;
Result (I).High := Set_Data.Items (I).High;
end loop;
end return;
end Overloaded_To_Ranges;
overriding function "=" (Left, Right : Character_Set) return Boolean is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
begin
return Left_Data = Right_Data or else Left_Data.Items = Right_Data.Items;
end "=";
function "not" (Right : Character_Set) return Character_Set is
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Right_Data.Length = 0 then
Data := Full_Set_Data'Unrestricted_Access;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Full_Set_Data.Length + Right_Data.Length);
Last : Natural;
begin
Sub (Items, Last, Full_Set_Data.Items, Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "not";
function "and" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 or else Right_Data.Length = 0 then
Data := Empty_Set_Data'Unrestricted_Access;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Left_Data.Length + Right_Data.Length);
Last : Natural;
begin
Naked_Maps.Intersection (
Items,
Last,
Left_Data.Items,
Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "and";
function "or" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 then
Data := Right_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
elsif Right_Data.Length = 0 then
Data := Left_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Left_Data.Length + Right_Data.Length);
Last : Natural;
begin
Naked_Maps.Union (
Items,
Last,
Left_Data.Items,
Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last)); -- Length > 0
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "or";
function "xor" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 then
Data := Right_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
elsif Right_Data.Length = 0 then
Data := Left_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
else
declare
Max : constant Natural := Left_Data.Length + Right_Data.Length;
X : Naked_Maps.Character_Ranges (1 .. Max);
X_Last : Natural;
Y : Naked_Maps.Character_Ranges (1 .. Max);
Y_Last : Natural;
Items : Naked_Maps.Character_Ranges (1 .. Max);
Last : Natural;
begin
Naked_Maps.Union (
X,
X_Last,
Left_Data.Items,
Right_Data.Items);
Naked_Maps.Intersection (
Y,
Y_Last,
Left_Data.Items,
Right_Data.Items);
Sub (Items, Last, X (1 .. X_Last), Y (1 .. Y_Last));
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "xor";
function "-" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 then
Data := Empty_Set_Data'Unrestricted_Access;
elsif Right_Data.Length = 0 then
Data := Left_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Left_Data.Length + Right_Data.Length);
Last : Natural;
begin
Sub (Items, Last, Left_Data.Items, Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "-";
function Overloaded_Is_In (
Element : Character;
Set : Character_Set)
return Boolean is
begin
return Overloaded_Is_In (
Naked_Maps.To_Wide_Wide_Character (Element),
Set);
end Overloaded_Is_In;
function Overloaded_Is_In (
Element : Wide_Character;
Set : Character_Set)
return Boolean is
begin
return Overloaded_Is_In (
Naked_Maps.To_Wide_Wide_Character (Element),
Set);
end Overloaded_Is_In;
function Overloaded_Is_In (
Element : Wide_Wide_Character;
Set : Character_Set)
return Boolean
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Naked_Maps.Is_In (Element, Set_Data.all);
end Overloaded_Is_In;
function Is_Subset (Elements : Character_Set; Set : Character_Set)
return Boolean
is
Elements_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Elements);
pragma Check (Validate, Naked_Maps.Debug.Valid (Elements_Data.all));
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
if Set_Data.Length = 0 then
return False;
else
declare
J : Positive := Set_Data.Items'First;
begin
for I in Elements_Data.Items'Range loop
declare
E : Naked_Maps.Character_Range
renames Elements_Data.Items (I);
begin
loop
if E.Low < Set_Data.Items (J).Low then
return False;
elsif E.High > Set_Data.Items (J).High then
J := J + 1;
if J > Set_Data.Items'Last then
return False;
end if;
else
exit; -- ok for E
end if;
end loop;
end;
end loop;
return True;
end;
end if;
end Is_Subset;
function Overloaded_To_Set (Sequence : Character_Sequence)
return Character_Set
is
-- Should it raise Constraint_Error for illegal sequence ?
U_Sequence : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_8_To_32 * Sequence'Length);
U_Sequence_Last : Natural;
begin
System.UTF_Conversions.From_8_To_32.Convert (
Sequence,
U_Sequence,
U_Sequence_Last,
Substitute => "");
return Overloaded_To_Set (U_Sequence (1 .. U_Sequence_Last));
end Overloaded_To_Set;
function Overloaded_To_Set (Sequence : Wide_Character_Sequence)
return Character_Set
is
-- Should it raise Constraint_Error for illegal sequence ?
U_Sequence : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_16_To_32 * Sequence'Length);
U_Sequence_Last : Natural;
begin
System.UTF_Conversions.From_16_To_32.Convert (
Sequence,
U_Sequence,
U_Sequence_Last,
Substitute => "");
return Overloaded_To_Set (U_Sequence (1 .. U_Sequence_Last));
end Overloaded_To_Set;
function Overloaded_To_Set (Sequence : Wide_Wide_Character_Sequence)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (Sequence'Range);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
-- it should be more optimized...
for I in Sequence'Range loop
declare
E : Wide_Wide_Character renames Sequence (I);
begin
Naked_Maps.Add (Items, Last, E, E);
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Singleton : Character)
return Character_Set is
begin
return Overloaded_To_Set (Naked_Maps.To_Wide_Wide_Character (Singleton));
end Overloaded_To_Set;
function Overloaded_To_Set (Singleton : Wide_Character)
return Character_Set is
begin
return Overloaded_To_Set (Naked_Maps.To_Wide_Wide_Character (Singleton));
end Overloaded_To_Set;
function Overloaded_To_Set (Singleton : Wide_Wide_Character)
return Character_Set is
begin
return Create (
new Set_Data'(
Length => 1,
Reference_Count => 1,
Items => (1 => (Singleton, Singleton))));
end Overloaded_To_Set;
function Overloaded_To_Sequence (Set : Character_Set)
return Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence ?
return System.UTF_Conversions.From_32_To_8.Convert (
Overloaded_To_Sequence (Set),
Substitute => "");
end Overloaded_To_Sequence;
function Overloaded_To_Sequence (Set : Character_Set)
return Wide_Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence or unmappable ?
return System.UTF_Conversions.From_32_To_16.Convert (
Overloaded_To_Sequence (Set),
Substitute => "");
end Overloaded_To_Sequence;
function Overloaded_To_Sequence (Set : Character_Set)
return Wide_Wide_Character_Sequence
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
Length : Natural := 0;
begin
for I in Set_Data.Items'Range loop
Length := Length
+ (
Wide_Wide_Character'Pos (Set_Data.Items (I).High)
- Wide_Wide_Character'Pos (Set_Data.Items (I).Low)
+ 1);
end loop;
return Result : Wide_Wide_String (1 .. Length) do
declare
Last : Natural := 0;
begin
for I in Set_Data.Items'Range loop
for J in Set_Data.Items (I).Low .. Set_Data.Items (I).High loop
Last := Last + 1;
Result (Last) := J;
end loop;
end loop;
end;
end return;
end Overloaded_To_Sequence;
package body Controlled_Sets is
function Create (Data : not null Set_Data_Access)
return Character_Set is
begin
return (Finalization.Controlled with Data => Data);
end Create;
function Reference (Object : Maps.Character_Set)
return not null Set_Data_Access is
begin
return Character_Set (Object).Data;
end Reference;
overriding procedure Adjust (Object : in out Character_Set) is
begin
System.Reference_Counting.Adjust (
Upcast (Object.Data'Unchecked_Access));
end Adjust;
overriding procedure Finalize (Object : in out Character_Set) is
begin
System.Reference_Counting.Clear (
Upcast (Object.Data'Unchecked_Access),
Free => Free_Set_Data'Access);
end Finalize;
package body Streaming is
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Character_Set)
is
Length : Integer;
begin
Integer'Read (Stream, Length);
Finalize (Item);
Item.Data := Empty_Set_Data'Unrestricted_Access;
if Length > 0 then
Item.Data := new Set_Data'(
Length => Length,
Reference_Count => 1,
Items => <>);
Naked_Maps.Character_Ranges'Read (Stream, Item.Data.Items);
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
end if;
end Read;
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Character_Set)
is
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
Data : constant not null Set_Data_Access := Item.Data;
begin
Integer'Write (Stream, Data.Length);
Naked_Maps.Character_Ranges'Write (Stream, Data.Items);
end Write;
end Streaming;
end Controlled_Sets;
-- maps
subtype Nonnull_Map_Data_Access is not null Map_Data_Access;
function Downcast is
new Unchecked_Conversion (
System.Reference_Counting.Container,
Nonnull_Map_Data_Access);
type Map_Data_Access_Access is access all Nonnull_Map_Data_Access;
function Upcast is
new Unchecked_Conversion (Map_Data_Access_Access, Container_Access);
procedure Free is new Unchecked_Deallocation (Map_Data, Map_Data_Access);
procedure Free_Map_Data (
Data : in out System.Reference_Counting.Data_Access);
procedure Free_Map_Data (
Data : in out System.Reference_Counting.Data_Access)
is
X : Map_Data_Access := Downcast (Data);
begin
Free (X);
Data := null;
end Free_Map_Data;
-- implementation of maps
function Overloaded_Value (
Map : Character_Mapping;
Element : Character)
return Character is
begin
return Naked_Maps.To_Character (
Overloaded_Value (Map, Naked_Maps.To_Wide_Wide_Character (Element)));
end Overloaded_Value;
function Overloaded_Value (
Map : Character_Mapping;
Element : Wide_Character)
return Wide_Character is
begin
return Naked_Maps.To_Wide_Character (
Overloaded_Value (Map, Naked_Maps.To_Wide_Wide_Character (Element)));
end Overloaded_Value;
function Overloaded_Value (
Map : Character_Mapping;
Element : Wide_Wide_Character)
return Wide_Wide_Character
is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Naked_Maps.Value (Map_Data.all, Element);
end Overloaded_Value;
function Identity return Character_Mapping is
begin
return Create (Empty_Map_Data'Unrestricted_Access);
end Identity;
function Is_Identity (Map : Character_Mapping) return Boolean is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Map_Data.Length = 0;
end Is_Identity;
function Overloaded_To_Mapping (From, To : Character_Sequence)
return Character_Mapping
is
-- Should it raise Constraint_Error for illegal sequence ?
U_From : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_8_To_32 * From'Length);
U_From_Last : Natural;
U_To : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_8_To_32 * To'Length);
U_To_Last : Natural;
begin
System.UTF_Conversions.From_8_To_32.Convert (From, U_From, U_From_Last,
Substitute => "");
System.UTF_Conversions.From_8_To_32.Convert (To, U_To, U_To_Last,
Substitute => "");
return Overloaded_To_Mapping (
From => U_From (1 .. U_From_Last),
To => U_To (1 .. U_To_Last));
end Overloaded_To_Mapping;
function Overloaded_To_Mapping (From, To : Wide_Character_Sequence)
return Character_Mapping
is
-- Should it raise Constraint_Error for illegal sequence ?
U_From : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_16_To_32 * From'Length);
U_From_Last : Natural;
U_To : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_16_To_32 * To'Length);
U_To_Last : Natural;
begin
System.UTF_Conversions.From_16_To_32.Convert (From, U_From, U_From_Last,
Substitute => "");
System.UTF_Conversions.From_16_To_32.Convert (To, U_To, U_To_Last,
Substitute => "");
return Overloaded_To_Mapping (
From => U_From (1 .. U_From_Last),
To => U_To (1 .. U_To_Last));
end Overloaded_To_Mapping;
function Overloaded_To_Mapping (From, To : Wide_Wide_Character_Sequence)
return Character_Mapping
is
Sorted_From, Sorted_To : Wide_Wide_Character_Sequence (1 .. From'Length);
Sorted_Last : Natural;
New_Data : Map_Data_Access;
begin
Naked_Maps.To_Mapping (
From => From,
To => To,
Out_From => Sorted_From,
Out_To => Sorted_To,
Out_Last => Sorted_Last);
if Sorted_Last = 0 then
New_Data := Empty_Map_Data'Unrestricted_Access;
else
New_Data := new Map_Data'(
Length => Sorted_Last,
Reference_Count => 1,
From => Sorted_From (1 .. Sorted_Last),
To => Sorted_To (1 .. Sorted_Last));
end if;
pragma Check (Validate, Naked_Maps.Debug.Valid (New_Data.all));
return Create (New_Data);
end Overloaded_To_Mapping;
function Overloaded_To_Domain (Map : Character_Mapping)
return Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence ?
return System.UTF_Conversions.From_32_To_8.Convert (
Overloaded_To_Domain (Map),
Substitute => "");
end Overloaded_To_Domain;
function Overloaded_To_Domain (Map : Character_Mapping)
return Wide_Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence or unmappable ?
return System.UTF_Conversions.From_32_To_16.Convert (
Overloaded_To_Domain (Map),
Substitute => "");
end Overloaded_To_Domain;
function Overloaded_To_Domain (Map : Character_Mapping)
return Wide_Wide_Character_Sequence
is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Map_Data.From;
end Overloaded_To_Domain;
function Overloaded_To_Range (Map : Character_Mapping)
return Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence ?
return System.UTF_Conversions.From_32_To_8.Convert (
Overloaded_To_Range (Map),
Substitute => "");
end Overloaded_To_Range;
function Overloaded_To_Range (Map : Character_Mapping)
return Wide_Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence or unmappable ?
return System.UTF_Conversions.From_32_To_16.Convert (
Overloaded_To_Range (Map),
Substitute => "");
end Overloaded_To_Range;
function Overloaded_To_Range (Map : Character_Mapping)
return Wide_Wide_Character_Sequence
is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Map_Data.To;
end Overloaded_To_Range;
overriding function "=" (Left, Right : Character_Mapping) return Boolean is
Left_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
begin
return Left_Data = Right_Data
or else (
Left_Data.From = Right_Data.From
and then Left_Data.To = Right_Data.To);
end "=";
package body Controlled_Maps is
function Create (Data : not null Map_Data_Access)
return Character_Mapping is
begin
return (Finalization.Controlled with Data => Data);
end Create;
function Reference (Object : Maps.Character_Mapping)
return not null Map_Data_Access is
begin
return Character_Mapping (Object).Data;
end Reference;
overriding procedure Adjust (Object : in out Character_Mapping) is
begin
System.Reference_Counting.Adjust (
Upcast (Object.Data'Unchecked_Access));
end Adjust;
overriding procedure Finalize (Object : in out Character_Mapping) is
begin
System.Reference_Counting.Clear (
Upcast (Object.Data'Unchecked_Access),
Free => Free_Map_Data'Access);
end Finalize;
package body Streaming is
-- compatibility with
-- Ordered_Maps (Wide_Wide_Character, Wide_Wide_Character)
-- and Hashed_Maps (Wide_Wide_Character, Wide_Wide_Character, ...)
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Character_Mapping)
is
Length : Integer;
begin
Integer'Read (Stream, Length);
Finalize (Item);
Item.Data := Empty_Map_Data'Unrestricted_Access;
if Length > 0 then
Item.Data := new Map_Data'(
Length => Length,
Reference_Count => 1,
From => <>,
To => <>);
declare
Data : constant not null Map_Data_Access := Item.Data;
begin
for I in 1 .. Length loop
Wide_Wide_Character'Read (Stream, Data.From (I));
Wide_Wide_Character'Read (Stream, Data.To (I));
end loop;
end;
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
end if;
end Read;
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Character_Mapping)
is
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
Data : constant not null Map_Data_Access := Item.Data;
begin
Integer'Write (Stream, Data.Length);
for I in 1 .. Data.Length loop
Wide_Wide_Character'Write (Stream, Data.From (I));
Wide_Wide_Character'Write (Stream, Data.To (I));
end loop;
end Write;
end Streaming;
end Controlled_Maps;
end Ada.Strings.Maps;
|
-- 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;
package RP_SVD.RESETS is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- RESET_i2c array
type RESET_i2c_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_i2c
type RESET_i2c_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- i2c as a value
Val : HAL.UInt2;
when True =>
-- i2c as an array
Arr : RESET_i2c_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_i2c_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- RESET_pio array
type RESET_pio_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_pio
type RESET_pio_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- pio as a value
Val : HAL.UInt2;
when True =>
-- pio as an array
Arr : RESET_pio_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_pio_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- RESET_spi array
type RESET_spi_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_spi
type RESET_spi_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- spi as a value
Val : HAL.UInt2;
when True =>
-- spi as an array
Arr : RESET_spi_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_spi_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- RESET_uart array
type RESET_uart_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_uart
type RESET_uart_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- uart as a value
Val : HAL.UInt2;
when True =>
-- uart as an array
Arr : RESET_uart_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_uart_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Reset control. If a bit is set it means the peripheral is in reset. 0
-- means the peripheral's reset is deasserted.
type RESET_Register is record
adc : Boolean := True;
busctrl : Boolean := True;
dma : Boolean := True;
i2c : RESET_i2c_Field := (As_Array => False, Val => 16#1#);
io_bank0 : Boolean := True;
io_qspi : Boolean := True;
jtag : Boolean := True;
pads_bank0 : Boolean := True;
pads_qspi : Boolean := True;
pio : RESET_pio_Field := (As_Array => False, Val => 16#1#);
pll_sys : Boolean := True;
pll_usb : Boolean := True;
pwm : Boolean := True;
rtc : Boolean := True;
spi : RESET_spi_Field := (As_Array => False, Val => 16#1#);
syscfg : Boolean := True;
sysinfo : Boolean := True;
tbman : Boolean := True;
timer : Boolean := True;
uart : RESET_uart_Field := (As_Array => False, Val => 16#1#);
usbctrl : Boolean := True;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RESET_Register use record
adc at 0 range 0 .. 0;
busctrl at 0 range 1 .. 1;
dma at 0 range 2 .. 2;
i2c at 0 range 3 .. 4;
io_bank0 at 0 range 5 .. 5;
io_qspi at 0 range 6 .. 6;
jtag at 0 range 7 .. 7;
pads_bank0 at 0 range 8 .. 8;
pads_qspi at 0 range 9 .. 9;
pio at 0 range 10 .. 11;
pll_sys at 0 range 12 .. 12;
pll_usb at 0 range 13 .. 13;
pwm at 0 range 14 .. 14;
rtc at 0 range 15 .. 15;
spi at 0 range 16 .. 17;
syscfg at 0 range 18 .. 18;
sysinfo at 0 range 19 .. 19;
tbman at 0 range 20 .. 20;
timer at 0 range 21 .. 21;
uart at 0 range 22 .. 23;
usbctrl at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- WDSEL_i2c array
type WDSEL_i2c_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for WDSEL_i2c
type WDSEL_i2c_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- i2c as a value
Val : HAL.UInt2;
when True =>
-- i2c as an array
Arr : WDSEL_i2c_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for WDSEL_i2c_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- WDSEL_pio array
type WDSEL_pio_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for WDSEL_pio
type WDSEL_pio_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- pio as a value
Val : HAL.UInt2;
when True =>
-- pio as an array
Arr : WDSEL_pio_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for WDSEL_pio_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- WDSEL_spi array
type WDSEL_spi_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for WDSEL_spi
type WDSEL_spi_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- spi as a value
Val : HAL.UInt2;
when True =>
-- spi as an array
Arr : WDSEL_spi_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for WDSEL_spi_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- WDSEL_uart array
type WDSEL_uart_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for WDSEL_uart
type WDSEL_uart_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- uart as a value
Val : HAL.UInt2;
when True =>
-- uart as an array
Arr : WDSEL_uart_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for WDSEL_uart_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Watchdog select. If a bit is set then the watchdog will reset this
-- peripheral when the watchdog fires.
type WDSEL_Register is record
adc : Boolean := False;
busctrl : Boolean := False;
dma : Boolean := False;
i2c : WDSEL_i2c_Field := (As_Array => False, Val => 16#0#);
io_bank0 : Boolean := False;
io_qspi : Boolean := False;
jtag : Boolean := False;
pads_bank0 : Boolean := False;
pads_qspi : Boolean := False;
pio : WDSEL_pio_Field := (As_Array => False, Val => 16#0#);
pll_sys : Boolean := False;
pll_usb : Boolean := False;
pwm : Boolean := False;
rtc : Boolean := False;
spi : WDSEL_spi_Field := (As_Array => False, Val => 16#0#);
syscfg : Boolean := False;
sysinfo : Boolean := False;
tbman : Boolean := False;
timer : Boolean := False;
uart : WDSEL_uart_Field := (As_Array => False, Val => 16#0#);
usbctrl : Boolean := False;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for WDSEL_Register use record
adc at 0 range 0 .. 0;
busctrl at 0 range 1 .. 1;
dma at 0 range 2 .. 2;
i2c at 0 range 3 .. 4;
io_bank0 at 0 range 5 .. 5;
io_qspi at 0 range 6 .. 6;
jtag at 0 range 7 .. 7;
pads_bank0 at 0 range 8 .. 8;
pads_qspi at 0 range 9 .. 9;
pio at 0 range 10 .. 11;
pll_sys at 0 range 12 .. 12;
pll_usb at 0 range 13 .. 13;
pwm at 0 range 14 .. 14;
rtc at 0 range 15 .. 15;
spi at 0 range 16 .. 17;
syscfg at 0 range 18 .. 18;
sysinfo at 0 range 19 .. 19;
tbman at 0 range 20 .. 20;
timer at 0 range 21 .. 21;
uart at 0 range 22 .. 23;
usbctrl at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- RESET_DONE_i2c array
type RESET_DONE_i2c_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_DONE_i2c
type RESET_DONE_i2c_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- i2c as a value
Val : HAL.UInt2;
when True =>
-- i2c as an array
Arr : RESET_DONE_i2c_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_DONE_i2c_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- RESET_DONE_pio array
type RESET_DONE_pio_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_DONE_pio
type RESET_DONE_pio_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- pio as a value
Val : HAL.UInt2;
when True =>
-- pio as an array
Arr : RESET_DONE_pio_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_DONE_pio_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- RESET_DONE_spi array
type RESET_DONE_spi_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_DONE_spi
type RESET_DONE_spi_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- spi as a value
Val : HAL.UInt2;
when True =>
-- spi as an array
Arr : RESET_DONE_spi_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_DONE_spi_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- RESET_DONE_uart array
type RESET_DONE_uart_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for RESET_DONE_uart
type RESET_DONE_uart_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- uart as a value
Val : HAL.UInt2;
when True =>
-- uart as an array
Arr : RESET_DONE_uart_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RESET_DONE_uart_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Reset done. If a bit is set then a reset done signal has been returned
-- by the peripheral. This indicates that the peripheral's registers are
-- ready to be accessed.
type RESET_DONE_Register is record
-- Read-only.
adc : Boolean;
-- Read-only.
busctrl : Boolean;
-- Read-only.
dma : Boolean;
-- Read-only.
i2c : RESET_DONE_i2c_Field;
-- Read-only.
io_bank0 : Boolean;
-- Read-only.
io_qspi : Boolean;
-- Read-only.
jtag : Boolean;
-- Read-only.
pads_bank0 : Boolean;
-- Read-only.
pads_qspi : Boolean;
-- Read-only.
pio : RESET_DONE_pio_Field;
-- Read-only.
pll_sys : Boolean;
-- Read-only.
pll_usb : Boolean;
-- Read-only.
pwm : Boolean;
-- Read-only.
rtc : Boolean;
-- Read-only.
spi : RESET_DONE_spi_Field;
-- Read-only.
syscfg : Boolean;
-- Read-only.
sysinfo : Boolean;
-- Read-only.
tbman : Boolean;
-- Read-only.
timer : Boolean;
-- Read-only.
uart : RESET_DONE_uart_Field;
-- Read-only.
usbctrl : Boolean;
-- unspecified
Reserved_25_31 : HAL.UInt7;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RESET_DONE_Register use record
adc at 0 range 0 .. 0;
busctrl at 0 range 1 .. 1;
dma at 0 range 2 .. 2;
i2c at 0 range 3 .. 4;
io_bank0 at 0 range 5 .. 5;
io_qspi at 0 range 6 .. 6;
jtag at 0 range 7 .. 7;
pads_bank0 at 0 range 8 .. 8;
pads_qspi at 0 range 9 .. 9;
pio at 0 range 10 .. 11;
pll_sys at 0 range 12 .. 12;
pll_usb at 0 range 13 .. 13;
pwm at 0 range 14 .. 14;
rtc at 0 range 15 .. 15;
spi at 0 range 16 .. 17;
syscfg at 0 range 18 .. 18;
sysinfo at 0 range 19 .. 19;
tbman at 0 range 20 .. 20;
timer at 0 range 21 .. 21;
uart at 0 range 22 .. 23;
usbctrl at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type RESETS_Peripheral is record
-- Reset control. If a bit is set it means the peripheral is in reset. 0
-- means the peripheral's reset is deasserted.
RESET : aliased RESET_Register;
-- Watchdog select. If a bit is set then the watchdog will reset this
-- peripheral when the watchdog fires.
WDSEL : aliased WDSEL_Register;
-- Reset done. If a bit is set then a reset done signal has been
-- returned by the peripheral. This indicates that the peripheral's
-- registers are ready to be accessed.
RESET_DONE : aliased RESET_DONE_Register;
end record
with Volatile;
for RESETS_Peripheral use record
RESET at 16#0# range 0 .. 31;
WDSEL at 16#4# range 0 .. 31;
RESET_DONE at 16#8# range 0 .. 31;
end record;
RESETS_Periph : aliased RESETS_Peripheral
with Import, Address => RESETS_Base;
end RP_SVD.RESETS;
|
with Gprslaves.DB;
with GNAT.Spitbol.Table_VString;
package GPR_Tools.Gprslaves.Nameserver.Client is
procedure Register (Server : DB.Info_Struct);
function Find (Keys : GNAT.Spitbol.Table_VString.Table) return DB.Host_Info_Vectors.Vector;
end GPR_Tools.Gprslaves.Nameserver.Client;
|
with HAL;
generic
with package I2C is new HAL.I2C (<>);
package Drivers.Si7006 is
subtype Temperature_Type is Integer range -10000 .. 10000;
subtype Humidity_Type is Natural range 0 .. 100;
function Temperature_x100 return Temperature_Type;
function Humidity return Humidity_Type;
end Drivers.Si7006;
|
-- Handle Foreign Command
--
-- 2.9.92 sjw; orig
with Lib;
with Condition_Handling;
with System;
procedure Handle_Foreign_Command is
function Get_Foreign return String;
function To_Lower (C : Character) return Character;
function Get_Foreign return String is
Status : Condition_Handling.Cond_Value_Type;
S : String (1 .. 255);
L : System.Unsigned_Word;
begin
Lib.Get_Foreign (Status, Resultant_String => S, Resultant_Length => L);
return S (1 .. Natural (L));
end Get_Foreign;
function To_Lower (C : Character) return Character is
Lower_Case : constant array ('A' .. 'Z') of Character
:= ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
begin
if C in Lower_Case'Range then
return Lower_Case (C);
end if;
return C;
end To_Lower;
begin
declare
Raw_Command : constant String := Get_Foreign;
subtype String_Position is Natural range 0 .. Raw_Command'Last + 1;
subtype Substring is String (Raw_Command'Range);
Raw_Position : String_Position := Raw_Command'First;
Argument : Substring;
Arg_Position : String_Position;
Arg_Count : Argument_Count := Argument_Count'First;
begin
Arguments :
loop
exit Arguments when not (Raw_Position in Raw_Command'Range);
if Raw_Command (Raw_Position) = ' ' then
Raw_Position := Raw_Position + 1; -- DCL removes tabs
else
Arg_Position := 0;
One_Argument :
loop
exit One_Argument when not (Raw_Position in Raw_Command'Range);
exit One_Argument when Raw_Command (Raw_Position) = ' ';
if Raw_Command (Raw_Position) /= '"' then
Arg_Position := Arg_Position + 1;
Argument (Arg_Position) :=
To_Lower (Raw_Command (Raw_Position));
Raw_Position := Raw_Position + 1;
else
Raw_Position := Raw_Position + 1;
Quoted_Part :
loop
exit One_Argument
when not (Raw_Position in Raw_Command'Range);
if Raw_Command (Raw_Position) /= '"' then
Arg_Position := Arg_Position + 1;
Argument (Arg_Position) := Raw_Command (Raw_Position);
Raw_Position := Raw_Position + 1;
elsif Raw_Position + 1 in Raw_Command'Range
and then Raw_Command (Raw_Position + 1) = '"' then
-- double quote, -> one
Arg_Position := Arg_Position + 1;
Argument (Arg_Position) := '"';
Raw_Position := Raw_Position + 2;
else
-- terminating '"'
Raw_Position := Raw_Position + 1;
exit Quoted_Part;
end if;
end loop Quoted_Part;
end if;
end loop One_Argument;
Handle_Argument
(Count => Arg_Count,
Argument => Argument (Argument'First .. Arg_Position));
exit Arguments when Arg_Count = Argument_Count'Last;
-- Maybe an exception would be more appropriate here!
Arg_Count := Arg_Count + 1;
end if;
end loop Arguments;
end;
end Handle_Foreign_Command;
|
-- This spec has been automatically generated from STM32L5x2.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.TAMP is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- control register 1
type CR1_Register is record
-- TAMP1E
TAMP1E : Boolean := False;
-- TAMP2E
TAMP2E : Boolean := False;
-- TAMP3E
TAMP3E : Boolean := False;
-- TAMP4E
TAMP4E : Boolean := False;
-- TAMP5E
TAMP5E : Boolean := False;
-- TAMP6E
TAMP6E : Boolean := False;
-- TAMP7E
TAMP7E : Boolean := False;
-- TAMP8E
TAMP8E : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- ITAMP1E
ITAMP1E : Boolean := True;
-- ITAMP2E
ITAMP2E : Boolean := True;
-- ITAMP3E
ITAMP3E : Boolean := True;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#1#;
-- ITAMP5E
ITAMP5E : Boolean := True;
-- unspecified
Reserved_21_22 : HAL.UInt2 := 16#3#;
-- ITAMP5E
ITAMP8E : Boolean := True;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#FF#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
TAMP1E at 0 range 0 .. 0;
TAMP2E at 0 range 1 .. 1;
TAMP3E at 0 range 2 .. 2;
TAMP4E at 0 range 3 .. 3;
TAMP5E at 0 range 4 .. 4;
TAMP6E at 0 range 5 .. 5;
TAMP7E at 0 range 6 .. 6;
TAMP8E at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
ITAMP1E at 0 range 16 .. 16;
ITAMP2E at 0 range 17 .. 17;
ITAMP3E at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
ITAMP5E at 0 range 20 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
ITAMP8E at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- control register 2
type CR2_Register is record
-- TAMP1NOER
TAMP1NOER : Boolean := False;
-- TAMP2NOER
TAMP2NOER : Boolean := False;
-- TAMP3NOER
TAMP3NOER : Boolean := False;
-- TAMP4NOER
TAMP4NOER : Boolean := False;
-- TAMP5NOER
TAMP5NOER : Boolean := False;
-- TAMP6NOER
TAMP6NOER : Boolean := False;
-- TAMP7NOER
TAMP7NOER : Boolean := False;
-- TAMP8NOER
TAMP8NOER : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- TAMP1MSK
TAMP1MSK : Boolean := False;
-- TAMP2MSK
TAMP2MSK : Boolean := False;
-- TAMP3MSK
TAMP3MSK : Boolean := False;
-- unspecified
Reserved_19_22 : HAL.UInt4 := 16#0#;
-- BKERASE
BKERASE : Boolean := False;
-- TAMP1TRG
TAMP1TRG : Boolean := False;
-- TAMP2TRG
TAMP2TRG : Boolean := False;
-- TAMP3TRG
TAMP3TRG : Boolean := False;
-- TAMP4TRG
TAMP4TRG : Boolean := False;
-- TAMP5TRG
TAMP5TRG : Boolean := False;
-- TAMP6TRG
TAMP6TRG : Boolean := False;
-- TAMP7TRG
TAMP7TRG : Boolean := False;
-- TAMP8TRG
TAMP8TRG : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
TAMP1NOER at 0 range 0 .. 0;
TAMP2NOER at 0 range 1 .. 1;
TAMP3NOER at 0 range 2 .. 2;
TAMP4NOER at 0 range 3 .. 3;
TAMP5NOER at 0 range 4 .. 4;
TAMP6NOER at 0 range 5 .. 5;
TAMP7NOER at 0 range 6 .. 6;
TAMP8NOER at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
TAMP1MSK at 0 range 16 .. 16;
TAMP2MSK at 0 range 17 .. 17;
TAMP3MSK at 0 range 18 .. 18;
Reserved_19_22 at 0 range 19 .. 22;
BKERASE at 0 range 23 .. 23;
TAMP1TRG at 0 range 24 .. 24;
TAMP2TRG at 0 range 25 .. 25;
TAMP3TRG at 0 range 26 .. 26;
TAMP4TRG at 0 range 27 .. 27;
TAMP5TRG at 0 range 28 .. 28;
TAMP6TRG at 0 range 29 .. 29;
TAMP7TRG at 0 range 30 .. 30;
TAMP8TRG at 0 range 31 .. 31;
end record;
-- control register 3
type CR3_Register is record
-- ITAMP1NOER
ITAMP1NOER : Boolean := False;
-- ITAMP2NOER
ITAMP2NOER : Boolean := False;
-- ITAMP3NOER
ITAMP3NOER : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- ITAMP5NOER
ITAMP5NOER : Boolean := False;
-- unspecified
Reserved_5_6 : HAL.UInt2 := 16#0#;
-- ITAMP8NOER
ITAMP8NOER : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR3_Register use record
ITAMP1NOER at 0 range 0 .. 0;
ITAMP2NOER at 0 range 1 .. 1;
ITAMP3NOER at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
ITAMP5NOER at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
ITAMP8NOER at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype FLTCR_TAMPFREQ_Field is HAL.UInt3;
subtype FLTCR_TAMPFLT_Field is HAL.UInt2;
subtype FLTCR_TAMPPRCH_Field is HAL.UInt2;
-- TAMP filter control register
type FLTCR_Register is record
-- TAMPFREQ
TAMPFREQ : FLTCR_TAMPFREQ_Field := 16#0#;
-- TAMPFLT
TAMPFLT : FLTCR_TAMPFLT_Field := 16#0#;
-- TAMPPRCH
TAMPPRCH : FLTCR_TAMPPRCH_Field := 16#0#;
-- TAMPPUDIS
TAMPPUDIS : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FLTCR_Register use record
TAMPFREQ at 0 range 0 .. 2;
TAMPFLT at 0 range 3 .. 4;
TAMPPRCH at 0 range 5 .. 6;
TAMPPUDIS at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- ATCR1_ATOSEL array element
subtype ATCR1_ATOSEL_Element is HAL.UInt2;
-- ATCR1_ATOSEL array
type ATCR1_ATOSEL_Field_Array is array (1 .. 4) of ATCR1_ATOSEL_Element
with Component_Size => 2, Size => 8;
-- Type definition for ATCR1_ATOSEL
type ATCR1_ATOSEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ATOSEL as a value
Val : HAL.UInt8;
when True =>
-- ATOSEL as an array
Arr : ATCR1_ATOSEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for ATCR1_ATOSEL_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
subtype ATCR1_ATCKSEL_Field is HAL.UInt2;
subtype ATCR1_ATPER_Field is HAL.UInt2;
-- TAMP active tamper control register 1
type ATCR1_Register is record
-- TAMP1AM
TAMP1AM : Boolean := False;
-- TAMP2AM
TAMP2AM : Boolean := False;
-- TAMP3AM
TAMP3AM : Boolean := False;
-- TAMP4AM
TAMP4AM : Boolean := False;
-- TAMP5AM
TAMP5AM : Boolean := False;
-- TAMP6AM
TAMP6AM : Boolean := False;
-- TAMP7AM
TAMP7AM : Boolean := False;
-- TAMP8AM
TAMP8AM : Boolean := False;
-- ATOSEL1
ATOSEL : ATCR1_ATOSEL_Field :=
(As_Array => False, Val => 16#0#);
-- ATCKSEL
ATCKSEL : ATCR1_ATCKSEL_Field := 16#3#;
-- unspecified
Reserved_18_23 : HAL.UInt6 := 16#1#;
-- ATPER
ATPER : ATCR1_ATPER_Field := 16#0#;
-- unspecified
Reserved_26_29 : HAL.UInt4 := 16#0#;
-- ATOSHARE
ATOSHARE : Boolean := False;
-- FLTEN
FLTEN : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ATCR1_Register use record
TAMP1AM at 0 range 0 .. 0;
TAMP2AM at 0 range 1 .. 1;
TAMP3AM at 0 range 2 .. 2;
TAMP4AM at 0 range 3 .. 3;
TAMP5AM at 0 range 4 .. 4;
TAMP6AM at 0 range 5 .. 5;
TAMP7AM at 0 range 6 .. 6;
TAMP8AM at 0 range 7 .. 7;
ATOSEL at 0 range 8 .. 15;
ATCKSEL at 0 range 16 .. 17;
Reserved_18_23 at 0 range 18 .. 23;
ATPER at 0 range 24 .. 25;
Reserved_26_29 at 0 range 26 .. 29;
ATOSHARE at 0 range 30 .. 30;
FLTEN at 0 range 31 .. 31;
end record;
subtype ATOR_PRNG_Field is HAL.UInt8;
-- TAMP active tamper output register
type ATOR_Register is record
-- Read-only. Pseudo-random generator value
PRNG : ATOR_PRNG_Field;
-- unspecified
Reserved_8_13 : HAL.UInt6;
-- Read-only. Seed running flag
SEEDF : Boolean;
-- Read-only. Active tamper initialization status
INITS : Boolean;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ATOR_Register use record
PRNG at 0 range 0 .. 7;
Reserved_8_13 at 0 range 8 .. 13;
SEEDF at 0 range 14 .. 14;
INITS at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- ATCR2_ATOSEL array element
subtype ATCR2_ATOSEL_Element is HAL.UInt3;
-- ATCR2_ATOSEL array
type ATCR2_ATOSEL_Field_Array is array (1 .. 8) of ATCR2_ATOSEL_Element
with Component_Size => 3, Size => 24;
-- Type definition for ATCR2_ATOSEL
type ATCR2_ATOSEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ATOSEL as a value
Val : HAL.UInt24;
when True =>
-- ATOSEL as an array
Arr : ATCR2_ATOSEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 24;
for ATCR2_ATOSEL_Field use record
Val at 0 range 0 .. 23;
Arr at 0 range 0 .. 23;
end record;
-- TAMP active tamper control register 2
type ATCR2_Register is record
-- unspecified
Reserved_0_7 : HAL.UInt8 := 16#0#;
-- ATOSEL1
ATOSEL : ATCR2_ATOSEL_Field := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ATCR2_Register use record
Reserved_0_7 at 0 range 0 .. 7;
ATOSEL at 0 range 8 .. 31;
end record;
subtype SMCR_BKPRWDPROT_Field is HAL.UInt8;
subtype SMCR_BKPWDPROT_Field is HAL.UInt8;
-- TAMP secure mode register
type SMCR_Register is record
-- Backup registers read/write protection offset
BKPRWDPROT : SMCR_BKPRWDPROT_Field := 16#0#;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- Backup registers write protection offset
BKPWDPROT : SMCR_BKPWDPROT_Field := 16#0#;
-- unspecified
Reserved_24_30 : HAL.UInt7 := 16#0#;
-- Tamper protection
TAMPDPROT : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMCR_Register use record
BKPRWDPROT at 0 range 0 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
BKPWDPROT at 0 range 16 .. 23;
Reserved_24_30 at 0 range 24 .. 30;
TAMPDPROT at 0 range 31 .. 31;
end record;
-- TAMP privilege mode control register
type PRIVCR_Register is record
-- unspecified
Reserved_0_28 : HAL.UInt29 := 16#0#;
-- Backup registers zone 1 privilege protection
BKPRWPRIV : Boolean := False;
-- Backup registers zone 2 privilege protection
BKPWPRIV : Boolean := False;
-- Tamper privilege protection
TAMPPRIV : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PRIVCR_Register use record
Reserved_0_28 at 0 range 0 .. 28;
BKPRWPRIV at 0 range 29 .. 29;
BKPWPRIV at 0 range 30 .. 30;
TAMPPRIV at 0 range 31 .. 31;
end record;
-- TAMP interrupt enable register
type IER_Register is record
-- TAMP1IE
TAMP1IE : Boolean := False;
-- TAMP2IE
TAMP2IE : Boolean := False;
-- TAMP3IE
TAMP3IE : Boolean := False;
-- TAMP4IE
TAMP4IE : Boolean := False;
-- TAMP5IE
TAMP5IE : Boolean := False;
-- TAMP6IE
TAMP6IE : Boolean := False;
-- TAMP7IE
TAMP7IE : Boolean := False;
-- TAMP8IE
TAMP8IE : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- ITAMP1IE
ITAMP1IE : Boolean := False;
-- ITAMP2IE
ITAMP2IE : Boolean := False;
-- ITAMP3IE
ITAMP3IE : Boolean := False;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#0#;
-- ITAMP5IE
ITAMP5IE : Boolean := False;
-- unspecified
Reserved_21_22 : HAL.UInt2 := 16#0#;
-- ITAMP8IE
ITAMP8IE : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IER_Register use record
TAMP1IE at 0 range 0 .. 0;
TAMP2IE at 0 range 1 .. 1;
TAMP3IE at 0 range 2 .. 2;
TAMP4IE at 0 range 3 .. 3;
TAMP5IE at 0 range 4 .. 4;
TAMP6IE at 0 range 5 .. 5;
TAMP7IE at 0 range 6 .. 6;
TAMP8IE at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
ITAMP1IE at 0 range 16 .. 16;
ITAMP2IE at 0 range 17 .. 17;
ITAMP3IE at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
ITAMP5IE at 0 range 20 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
ITAMP8IE at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- TAMP status register
type SR_Register is record
-- Read-only. TAMP1F
TAMP1F : Boolean;
-- Read-only. TAMP2F
TAMP2F : Boolean;
-- Read-only. TAMP3F
TAMP3F : Boolean;
-- Read-only. TAMP4F
TAMP4F : Boolean;
-- Read-only. TAMP5F
TAMP5F : Boolean;
-- Read-only. TAMP6F
TAMP6F : Boolean;
-- Read-only. TAMP7F
TAMP7F : Boolean;
-- Read-only. TAMP8F
TAMP8F : Boolean;
-- unspecified
Reserved_8_15 : HAL.UInt8;
-- Read-only. ITAMP1F
ITAMP1F : Boolean;
-- Read-only. ITAMP2F
ITAMP2F : Boolean;
-- Read-only. ITAMP3F
ITAMP3F : Boolean;
-- unspecified
Reserved_19_19 : HAL.Bit;
-- Read-only. ITAMP5F
ITAMP5F : Boolean;
-- unspecified
Reserved_21_22 : HAL.UInt2;
-- Read-only. ITAMP8F
ITAMP8F : Boolean;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
TAMP1F at 0 range 0 .. 0;
TAMP2F at 0 range 1 .. 1;
TAMP3F at 0 range 2 .. 2;
TAMP4F at 0 range 3 .. 3;
TAMP5F at 0 range 4 .. 4;
TAMP6F at 0 range 5 .. 5;
TAMP7F at 0 range 6 .. 6;
TAMP8F at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
ITAMP1F at 0 range 16 .. 16;
ITAMP2F at 0 range 17 .. 17;
ITAMP3F at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
ITAMP5F at 0 range 20 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
ITAMP8F at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- TAMP masked interrupt status register
type MISR_Register is record
-- Read-only. TAMP1MF:
TAMP1MF : Boolean;
-- Read-only. TAMP2MF
TAMP2MF : Boolean;
-- Read-only. TAMP3MF
TAMP3MF : Boolean;
-- Read-only. TAMP4MF
TAMP4MF : Boolean;
-- Read-only. TAMP5MF
TAMP5MF : Boolean;
-- Read-only. TAMP6MF
TAMP6MF : Boolean;
-- Read-only. TAMP7MF:
TAMP7MF : Boolean;
-- Read-only. TAMP8MF
TAMP8MF : Boolean;
-- unspecified
Reserved_8_15 : HAL.UInt8;
-- Read-only. ITAMP1MF
ITAMP1MF : Boolean;
-- Read-only. ITAMP2MF
ITAMP2MF : Boolean;
-- Read-only. ITAMP3MF
ITAMP3MF : Boolean;
-- unspecified
Reserved_19_19 : HAL.Bit;
-- Read-only. ITAMP5MF
ITAMP5MF : Boolean;
-- unspecified
Reserved_21_22 : HAL.UInt2;
-- Read-only. ITAMP8MF
ITAMP8MF : Boolean;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MISR_Register use record
TAMP1MF at 0 range 0 .. 0;
TAMP2MF at 0 range 1 .. 1;
TAMP3MF at 0 range 2 .. 2;
TAMP4MF at 0 range 3 .. 3;
TAMP5MF at 0 range 4 .. 4;
TAMP6MF at 0 range 5 .. 5;
TAMP7MF at 0 range 6 .. 6;
TAMP8MF at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
ITAMP1MF at 0 range 16 .. 16;
ITAMP2MF at 0 range 17 .. 17;
ITAMP3MF at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
ITAMP5MF at 0 range 20 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
ITAMP8MF at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- TAMP secure masked interrupt status register
type SMISR_Register is record
-- Read-only. TAMP1MF:
TAMP1MF : Boolean;
-- Read-only. TAMP2MF
TAMP2MF : Boolean;
-- Read-only. TAMP3MF
TAMP3MF : Boolean;
-- Read-only. TAMP4MF
TAMP4MF : Boolean;
-- Read-only. TAMP5MF
TAMP5MF : Boolean;
-- Read-only. TAMP6MF
TAMP6MF : Boolean;
-- Read-only. TAMP7MF:
TAMP7MF : Boolean;
-- Read-only. TAMP8MF
TAMP8MF : Boolean;
-- unspecified
Reserved_8_15 : HAL.UInt8;
-- Read-only. ITAMP1MF
ITAMP1MF : Boolean;
-- Read-only. ITAMP2MF
ITAMP2MF : Boolean;
-- Read-only. ITAMP3MF
ITAMP3MF : Boolean;
-- unspecified
Reserved_19_19 : HAL.Bit;
-- Read-only. ITAMP5MF
ITAMP5MF : Boolean;
-- unspecified
Reserved_21_22 : HAL.UInt2;
-- Read-only. ITAMP8MF
ITAMP8MF : Boolean;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMISR_Register use record
TAMP1MF at 0 range 0 .. 0;
TAMP2MF at 0 range 1 .. 1;
TAMP3MF at 0 range 2 .. 2;
TAMP4MF at 0 range 3 .. 3;
TAMP5MF at 0 range 4 .. 4;
TAMP6MF at 0 range 5 .. 5;
TAMP7MF at 0 range 6 .. 6;
TAMP8MF at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
ITAMP1MF at 0 range 16 .. 16;
ITAMP2MF at 0 range 17 .. 17;
ITAMP3MF at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
ITAMP5MF at 0 range 20 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
ITAMP8MF at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- TAMP status clear register
type SCR_Register is record
-- Write-only. CTAMP1F
CTAMP1F : Boolean := False;
-- Write-only. CTAMP2F
CTAMP2F : Boolean := False;
-- Write-only. CTAMP3F
CTAMP3F : Boolean := False;
-- Write-only. CTAMP4F
CTAMP4F : Boolean := False;
-- Write-only. CTAMP5F
CTAMP5F : Boolean := False;
-- Write-only. CTAMP6F
CTAMP6F : Boolean := False;
-- Write-only. CTAMP7F
CTAMP7F : Boolean := False;
-- Write-only. CTAMP8F
CTAMP8F : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- Write-only. CITAMP1F
CITAMP1F : Boolean := False;
-- Write-only. CITAMP2F
CITAMP2F : Boolean := False;
-- Write-only. CITAMP3F
CITAMP3F : Boolean := False;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#0#;
-- Write-only. CITAMP5F
CITAMP5F : Boolean := False;
-- unspecified
Reserved_21_22 : HAL.UInt2 := 16#0#;
-- Write-only. CITAMP8F
CITAMP8F : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SCR_Register use record
CTAMP1F at 0 range 0 .. 0;
CTAMP2F at 0 range 1 .. 1;
CTAMP3F at 0 range 2 .. 2;
CTAMP4F at 0 range 3 .. 3;
CTAMP5F at 0 range 4 .. 4;
CTAMP6F at 0 range 5 .. 5;
CTAMP7F at 0 range 6 .. 6;
CTAMP8F at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
CITAMP1F at 0 range 16 .. 16;
CITAMP2F at 0 range 17 .. 17;
CITAMP3F at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
CITAMP5F at 0 range 20 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
CITAMP8F at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- TAMP configuration register
type CFGR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- TMONEN
TMONEN : Boolean := False;
-- VMONEN
VMONEN : Boolean := False;
-- WUTMONEN
WUTMONEN : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
TMONEN at 0 range 1 .. 1;
VMONEN at 0 range 2 .. 2;
WUTMONEN at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Tamper and backup registers
type TAMP_Peripheral is record
-- control register 1
CR1 : aliased CR1_Register;
-- control register 2
CR2 : aliased CR2_Register;
-- control register 3
CR3 : aliased CR3_Register;
-- TAMP filter control register
FLTCR : aliased FLTCR_Register;
-- TAMP active tamper control register 1
ATCR1 : aliased ATCR1_Register;
-- TAMP active tamper seed register
ATSEEDR : aliased HAL.UInt32;
-- TAMP active tamper output register
ATOR : aliased ATOR_Register;
-- TAMP active tamper control register 2
ATCR2 : aliased ATCR2_Register;
-- TAMP secure mode register
SMCR : aliased SMCR_Register;
-- TAMP privilege mode control register
PRIVCR : aliased PRIVCR_Register;
-- TAMP interrupt enable register
IER : aliased IER_Register;
-- TAMP status register
SR : aliased SR_Register;
-- TAMP masked interrupt status register
MISR : aliased MISR_Register;
-- TAMP secure masked interrupt status register
SMISR : aliased SMISR_Register;
-- TAMP status clear register
SCR : aliased SCR_Register;
-- TAMP monotonic counter register
COUNTR : aliased HAL.UInt32;
-- TAMP configuration register
CFGR : aliased CFGR_Register;
-- TAMP backup register
BKP0R : aliased HAL.UInt32;
-- TAMP backup register
BKP1R : aliased HAL.UInt32;
-- TAMP backup register
BKP2R : aliased HAL.UInt32;
-- TAMP backup register
BKP3R : aliased HAL.UInt32;
-- TAMP backup register
BKP4R : aliased HAL.UInt32;
-- TAMP backup register
BKP5R : aliased HAL.UInt32;
-- TAMP backup register
BKP6R : aliased HAL.UInt32;
-- TAMP backup register
BKP7R : aliased HAL.UInt32;
-- TAMP backup register
BKP8R : aliased HAL.UInt32;
-- TAMP backup register
BKP9R : aliased HAL.UInt32;
-- TAMP backup register
BKP10R : aliased HAL.UInt32;
-- TAMP backup register
BKP11R : aliased HAL.UInt32;
-- TAMP backup register
BKP12R : aliased HAL.UInt32;
-- TAMP backup register
BKP13R : aliased HAL.UInt32;
-- TAMP backup register
BKP14R : aliased HAL.UInt32;
-- TAMP backup register
BKP15R : aliased HAL.UInt32;
-- TAMP backup register
BKP16R : aliased HAL.UInt32;
-- TAMP backup register
BKP17R : aliased HAL.UInt32;
-- TAMP backup register
BKP18R : aliased HAL.UInt32;
-- TAMP backup register
BKP19R : aliased HAL.UInt32;
-- TAMP backup register
BKP20R : aliased HAL.UInt32;
-- TAMP backup register
BKP21R : aliased HAL.UInt32;
-- TAMP backup register
BKP22R : aliased HAL.UInt32;
-- TAMP backup register
BKP23R : aliased HAL.UInt32;
-- TAMP backup register
BKP24R : aliased HAL.UInt32;
-- TAMP backup register
BKP25R : aliased HAL.UInt32;
-- TAMP backup register
BKP26R : aliased HAL.UInt32;
-- TAMP backup register
BKP27R : aliased HAL.UInt32;
-- TAMP backup register
BKP28R : aliased HAL.UInt32;
-- TAMP backup register
BKP29R : aliased HAL.UInt32;
-- TAMP backup register
BKP30R : aliased HAL.UInt32;
-- TAMP backup register
BKP31R : aliased HAL.UInt32;
end record
with Volatile;
for TAMP_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CR2 at 16#4# range 0 .. 31;
CR3 at 16#8# range 0 .. 31;
FLTCR at 16#C# range 0 .. 31;
ATCR1 at 16#10# range 0 .. 31;
ATSEEDR at 16#14# range 0 .. 31;
ATOR at 16#18# range 0 .. 31;
ATCR2 at 16#1C# range 0 .. 31;
SMCR at 16#20# range 0 .. 31;
PRIVCR at 16#24# range 0 .. 31;
IER at 16#2C# range 0 .. 31;
SR at 16#30# range 0 .. 31;
MISR at 16#34# range 0 .. 31;
SMISR at 16#38# range 0 .. 31;
SCR at 16#3C# range 0 .. 31;
COUNTR at 16#40# range 0 .. 31;
CFGR at 16#50# range 0 .. 31;
BKP0R at 16#100# range 0 .. 31;
BKP1R at 16#104# range 0 .. 31;
BKP2R at 16#108# range 0 .. 31;
BKP3R at 16#10C# range 0 .. 31;
BKP4R at 16#110# range 0 .. 31;
BKP5R at 16#114# range 0 .. 31;
BKP6R at 16#118# range 0 .. 31;
BKP7R at 16#11C# range 0 .. 31;
BKP8R at 16#120# range 0 .. 31;
BKP9R at 16#124# range 0 .. 31;
BKP10R at 16#128# range 0 .. 31;
BKP11R at 16#12C# range 0 .. 31;
BKP12R at 16#130# range 0 .. 31;
BKP13R at 16#134# range 0 .. 31;
BKP14R at 16#138# range 0 .. 31;
BKP15R at 16#13C# range 0 .. 31;
BKP16R at 16#140# range 0 .. 31;
BKP17R at 16#144# range 0 .. 31;
BKP18R at 16#148# range 0 .. 31;
BKP19R at 16#14C# range 0 .. 31;
BKP20R at 16#150# range 0 .. 31;
BKP21R at 16#154# range 0 .. 31;
BKP22R at 16#158# range 0 .. 31;
BKP23R at 16#15C# range 0 .. 31;
BKP24R at 16#160# range 0 .. 31;
BKP25R at 16#164# range 0 .. 31;
BKP26R at 16#168# range 0 .. 31;
BKP27R at 16#16C# range 0 .. 31;
BKP28R at 16#170# range 0 .. 31;
BKP29R at 16#174# range 0 .. 31;
BKP30R at 16#178# range 0 .. 31;
BKP31R at 16#17C# range 0 .. 31;
end record;
-- Tamper and backup registers
TAMP_Periph : aliased TAMP_Peripheral
with Import, Address => System'To_Address (16#50003400#);
end STM32_SVD.TAMP;
|
limited with WebIDL.Scanners;
with WebIDL.Tokens;
with WebIDL.Scanner_Types;
package WebIDL.Scanner_Handlers is
pragma Preelaborate;
type Handler is abstract tagged limited null record;
procedure Delimiter
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Ellipsis
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Integer
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Decimal
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Identifier
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure String
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Whitespace
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Line_Comment
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Comment_Start
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Comment_End
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
procedure Comment_Text
(Self : not null access Handler;
Scanner : not null access WebIDL.Scanners.Scanner'Class;
Rule : WebIDL.Scanner_Types.Rule_Index;
Token : out WebIDL.Tokens.Token_Kind;
Skip : in out Boolean) is abstract;
type Handler_Access is access all Handler'Class;
end WebIDL.Scanner_Handlers;
|
package body Opt15_Pkg is
procedure Trace_Non_Inlined is
begin
raise Program_Error;
end;
procedure Trace_Inlined is
begin
Trace_Non_Inlined;
end;
end Opt15_Pkg;
|
------------------------------------------------------------------------
--
-- Copyright (c) 2018, Brendan T Malone All Rights Reserved.
--
-- 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.
--
------------------------------------------------------------------------
------------------------------------------------------------------------
--
-- Ada support for leveled logs. Based on Google's glog
--
-- TODO Usage Stuff
--
------------------------------------------------------------------------
with Ada.Calendar;
with Ada.Calendar.Formatting;
with Ada.Command_Line;
with Ada.Environment_Variables;
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with GNAT.Sockets;
package body Alog is
package AC renames Ada.Calendar;
package ACF renames Ada.Calendar.Formatting;
package ACL renames Ada.Command_Line;
package TIO renames Ada.Text_IO;
package AEV renames Ada.Environment_Variables;
---------------------------------------------------------------------
-- Private method declarations
---------------------------------------------------------------------
procedure Create_Files;
function Format_Output (Lvl : Level; Msg : String) return String;
procedure Output (Lvl : Level; Msg : String);
procedure Output_Stdout (Lvl : Level; Msg : String);
procedure Output_File (Lvl : Level; Msg : String);
---------------------------------------------------------------------
-- Import C menthods
---------------------------------------------------------------------
-- Import getpid so that we can have the log files name be distinct
-- per process.
function Get_PID return Integer;
pragma Import
(Convention => C,
Entity => Get_PID,
External_Name => "getpid");
---------------------------------------------------------------------
-- Package variables
---------------------------------------------------------------------
-- By default only log to the console if the log message is an Error
-- or greater.
Stdout_Threshold : Level := ERROR;
-- Defeault Vlog level is one.
Vlog_Threshold : Natural := 1;
-- By default write both to the log files and the console.
Log_Location : LogTo := BOTH;
-- By default write all log files to the tmp directory.
File_Location : ASU.Unbounded_String;
-- Array of a file handler for each log level.
type Log_Files is array (Level) of TIO.File_Type;
Files : Log_Files;
-- Mutex so the log can be multithreaded.
protected type Mutex is
entry Seize;
procedure Release;
private
Owned : Boolean := False;
end Mutex;
protected body Mutex is
entry Seize when not Owned is
begin
Owned := True;
end Seize;
procedure Release is
begin
Owned := False;
end Release;
end Mutex;
-- Instance of the lock.
Lock : Mutex;
function Equivalent_Strings (Left, Right : ASU.Unbounded_String)
return Boolean is
use ASU;
begin
return Left = Right;
end Equivalent_Strings;
---------------------------------------------------------------------
-- Private method
---------------------------------------------------------------------
-- Create the log file in the form of:
-- <program name>.<host>.<user>.log.<LEVEL>.<time>.<pid>
-- in the defined file location.
procedure Create_Files is
Cmd : constant String := Program_Name (ACL.Command_Name);
Host : constant String := GNAT.Sockets.Host_Name;
User : constant String := AEV.Value ("USER");
Time : constant String := Program_Time (ACF.Image (AC.Clock));
Pid : constant String := Integer'Image (Get_PID);
Prefix : constant String := Cmd & "." &
Host & "." & User & ".log.";
Suffix : constant String := "." & Time & "." &
(Pid (Pid'First + 1 .. Pid'Last));
begin
if not Files_Location_Set then
File_Location := ASU.To_Unbounded_String ("/tmp/");
end if;
for Lvl in Files'Range loop
begin
TIO.Create (File => Files (Lvl),
Mode => TIO.Out_File,
Name => ASU.To_String (File_Location) &
Prefix & Level'Image (Lvl) & Suffix);
exception
when others =>
raise Program_Error with "UNABLE TO CREATE LOGS";
end;
end loop;
Files_Created := True;
end Create_Files;
-- Take the time the program was run and create a file friendly
-- representation of the string.
-- e.g 2018-12-01 08:08:20 -> 20181201.080820
function Program_Time (Time : String) return String is
Str : String (1 .. 15);
Pos : Natural := Str'First;
begin
for i in Time'Range loop
case Time (i) is
when '-' =>
null;
when ':' =>
null;
when ' ' =>
Str (Pos) := '.';
Pos := Pos + 1;
when others =>
Str (Pos) := Time (i);
Pos := Pos + 1;
end case;
end loop;
return Str;
end Program_Time;
-- Take the time the command name and remove all the dots and slashes
-- so the program name can be used in the log file name.
function Program_Name (Cmd : String) return String is
Pos : Integer := 0;
begin
for i in Cmd'Range loop
-- Go backwards through the string till a / is found
if Cmd (Cmd'Last - i) = '/' then
Pos := i;
exit;
end if;
end loop;
return (Cmd (Cmd'Last - Pos + 1 .. Cmd'Last));
end Program_Name;
-- Method to format the log message for both the console and file.
function Format_Output (Lvl : Level; Msg : String) return String is
begin
return ACF.Image (AC.Clock) & " " & Level'Image (Lvl) & " " & Msg;
end Format_Output;
-- Output the log message to the console if it is at or above the log
-- threshold.
procedure Output_Stdout (Lvl : Level; Msg : String) is
begin
-- Only output to StdOut if the level of the message is
-- higher than the threshold.
if Lvl >= Stdout_Threshold then
TIO.Put_Line (Format_Output (Lvl, Msg));
end if;
end Output_Stdout;
-- Output the log message to the files.
procedure Output_File (Lvl : Level; Msg : String) is
begin
-- Create the files if this is the first call.
if not Files_Created then
Create_Files;
end if;
-- Start at INFO log and add the Msg then step up to the
-- next log checking everytime if you are now above
-- your amount.
for i in Level'Range loop
if i <= Lvl then
TIO.Put_Line (Files (i), Format_Output (Lvl, Msg));
Stats (i).Lines := Stats (i).Lines + 1;
end if;
end loop;
-- If the message recieved is FATAL throw a error to
-- terminate the program.
if Lvl = FATAL then
raise Program_Error with "FATAL ERROR OCCURED";
end if;
end Output_File;
-- Common output method that logs based on the log location.
-- Lock surrounding.
procedure Output (Lvl : Level; Msg : String) is
begin
Lock.Seize;
case Log_Location is
when NONE =>
null;
when STDOUT =>
Output_Stdout (Lvl, Msg);
when FILE =>
Output_File (Lvl, Msg);
when BOTH =>
Output_Stdout (Lvl, Msg);
Output_File (Lvl, Msg);
end case;
Lock.Release;
end Output;
procedure Vmodule_Setup (Mods : String) is
First : Natural := Mods'First;
Equal_Pos : Natural;
Failed : Boolean := True;
Module : ASU.Unbounded_String;
Temp : ASU.Unbounded_String;
Value : Natural;
begin
for i in Mods'Range loop
case Mods (i) is
when '=' =>
-- Saw an equal sign so the string was okay.
-- If something else is messed up it will throw an error
Failed := False;
Equal_Pos := i;
Module := ASU.To_Unbounded_String (Mods (First .. (i - 1)));
when ',' =>
Temp := ASU.To_Unbounded_String
(Mods ((Equal_Pos + 1) .. (i - 1)));
Value := Natural'Value (ASU.To_String (Temp));
Modules_Map.Insert (Module, Value);
First := i + 1;
when others =>
null;
end case;
end loop;
-- Add the last module and number here since the loop broke.
Temp := ASU.To_Unbounded_String (Mods ((Equal_Pos + 1) .. Mods'Last));
Value := Natural'Value (ASU.To_String (Temp));
Modules_Map.Insert (Module, Value);
if Failed then
raise Program_Error with "VMODULE STRING INCORRECT";
end if;
end Vmodule_Setup;
function Format_Module (Source : String) return String is
Temp : ASU.Unbounded_String;
begin
for i in Source'Range loop
case Source (i) is
when '.' =>
Temp := ASU.To_Unbounded_String
(Source (Source'First .. (i - 1)));
when others =>
null;
end case;
end loop;
return ASU.To_String (Temp);
end Format_Module;
---------------------------------------------------------------------
-- Public methods
---------------------------------------------------------------------
---------------------------------------------------------------------
-- Logging
---------------------------------------------------------------------
procedure Info (Msg : String) is
begin
Output (INFO, Msg);
end Info;
procedure Warn (Msg : String) is
begin
Output (WARN, Msg);
end Warn;
procedure Error (Msg : String) is
begin
Output (ERROR, Msg);
end Error;
procedure Fatal (Msg : String) is
begin
Output (FATAL, Msg);
end Fatal;
procedure Vlog (Lvl : Natural;
Msg : String;
Source : String := GNAT.Source_Info.Source_Location) is
Temp : ASU.Unbounded_String;
begin
if Modules_Map.Is_Empty then
if Lvl <= Vlog_Threshold then
TIO.Put_Line (Format_Output (INFO, Source & " " & Msg));
end if;
else
Temp := ASU.To_Unbounded_String (Format_Module (Source));
if Lvl <= Modules_Map.Element (Temp) then
TIO.Put_Line (Format_Output (INFO, Source & " " & Msg));
end if;
end if;
exception
when others =>
null;
end Vlog;
---------------------------------------------------------------------
-- Configuration
---------------------------------------------------------------------
procedure Set_LogTo (Output : LogTo) is
begin
Log_Location := Output;
end Set_LogTo;
procedure Set_LogTo (Output : String) is
begin
Set_LogTo (LogTo'Value (Output));
end Set_LogTo;
procedure Set_Stdout_Threshold (Lvl : Level) is
begin
Stdout_Threshold := Lvl;
end Set_Stdout_Threshold;
procedure Set_Stdout_Threshold (Lvl : String) is
begin
Set_Stdout_Threshold (Level'Value (Lvl));
end Set_Stdout_Threshold;
procedure Set_File_Path (Path : String) is
begin
File_Location := ASU.To_Unbounded_String (Path);
Files_Location_Set := True;
end Set_File_Path;
procedure Set_Vlog_Threshold (Lvl : Natural) is
begin
Vlog_Threshold := Lvl;
end Set_Vlog_Threshold;
procedure Set_Vlog_Modules (Mods : String) is
begin
Vmodule_Setup (Mods);
end Set_Vlog_Modules;
---------------------------------------------------------------------
-- Statistics
---------------------------------------------------------------------
function Lines (Lvl : Level) return Natural is
begin
return Stats (Lvl).Lines;
end Lines;
end Alog;
|
with Numerics, Numerics.Sparse_Matrices;
use Numerics, Numerics.Sparse_Matrices;
package Auto_Differentiation is
type Evaluation_Level is (Value, Gradient, Hessian);
Level : Evaluation_Level := Hessian;
type AD_Type is private;
type AD_2D is array (1 .. 2) of AD_Type;
type AD_Vector is array (Nat range <>) of AD_Type;
function Var (X : in Real;
I, N : in Nat;
Dx : in Real := 1.0) return AD_Type;
function Const (X : in Real;
N : in Nat) return AD_Type;
function Zero (N : in Nat) return AD_Type;
function Var (X : in Real_Vector;
Length : in Nat;
Start : in Nat := 1) return AD_Vector;
function Var (X : in Real_Vector) return AD_Vector is
(Var (X => X, Length => X'Length));
function Val (X : in AD_Type) return Real;
function Grad (X : in AD_Type) return Sparse_Vector;
-- function Grad (X : in AD_Type) return Real_Vector;
function Hessian (X : in AD_Type) return Sparse_Matrix;
function Length (X : in AD_Type) return Pos;
function "+" (X : in Real; Y : in AD_Type) return AD_Type;
function "+" (X : in AD_Type; Y : in Real) return AD_Type is (Y + X);
function "-" (X : in Real; Y : in AD_Type) return AD_Type;
function "-" (X : in AD_Type; Y : in Real) return AD_Type;
function "*" (Y : in Real; X : in AD_Type) return AD_Type;
function "*" (X : in AD_Type; Y : in Real) return AD_Type is (Y * X);
function "/" (X : in Real; Y : in AD_Type) return AD_Type;
function "/" (X : in AD_Type; Y : in Real) return AD_Type is ((1.0 / Y) * X)
with Pre => Y /= 0.0;
function "+" (X, Y : in AD_Type) return AD_Type;
function "-" (X, Y : in AD_Type) return AD_Type;
function "*" (X, Y : in AD_Type) return AD_Type;
function "/" (X, Y : in AD_Type) return AD_Type;
function "**" (X : in AD_Type; N : in Integer) return AD_Type;
function Sin (X : in AD_Type) return AD_Type;
function Cos (X : in AD_Type) return AD_Type;
function Tan (X : in AD_Type) return AD_Type;
function Exp (X : in AD_Type) return AD_Type;
function Log (X : in AD_Type) return AD_Type;
function "+" (X : in AD_Type) return AD_Type is (X);
function "-" (X : in AD_Type) return AD_Type;
function "+" (X, Y : in AD_2D) return AD_2D;
function "-" (X, Y : in AD_2D) return AD_2D;
function Dot (X, Y : in AD_2D) return AD_Type;
------------- procedures ----------------------
procedure Print (X : in AD_Type);
private
type AD_Type is
record
N : Pos := 0;
Val : Real;
Grad : Sparse_Vector;
Hessian : Sparse_Matrix;
end record;
G0 : constant Sparse_Vector := Zero (1);
H0 : constant Sparse_Matrix := Zero (1);
end Auto_Differentiation;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . O S _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-2005 Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL 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 GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, 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. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides low level primitives used to implement clock and
-- delays in non tasking applications on Alpha/VMS
-- The choice of the real clock/delay implementation (depending on whether
-- tasking is involved or not) is done via soft links (see s-soflin.ads)
-- NEVER add any dependency to tasking packages here
package System.OS_Primitives is
pragma Preelaborate;
subtype OS_Time is Long_Integer;
-- System time on VMS is used for performance reasons.
-- Note that OS_Time is *not* the same as Ada.Calendar.Time, the
-- difference being that relative OS_Time is negative, but relative
-- Calendar.Time is positive.
-- See Ada.Calendar.Delays for more information on VMS Time.
Max_Sensible_Delay : constant Duration :=
Duration'Min (183 * 24 * 60 * 60.0,
Duration'Last);
-- Max of half a year delay, needed to prevent exceptions for large
-- delay values. It seems unlikely that any test will notice this
-- restriction, except in the case of applications setting the clock at
-- at run time (see s-tastim.adb). Also note that a larger value might
-- cause problems (e.g overflow, or more likely OS limitation in the
-- primitives used). In the case where half a year is too long (which
-- occurs in high integrity mode with 32-bit words, and possibly on
-- some specific ports of GNAT), Duration'Last is used instead.
function OS_Clock return OS_Time;
-- Returns "absolute" time, represented as an offset
-- relative to "the Epoch", which is Nov 17, 1858 on VMS.
function Clock return Duration;
pragma Inline (Clock);
-- Returns "absolute" time, represented as an offset
-- relative to "the Epoch", which is Jan 1, 1970 on unixes.
-- This implementation is affected by system's clock changes.
function Monotonic_Clock return Duration;
pragma Inline (Monotonic_Clock);
-- Returns "absolute" time, represented as an offset
-- relative to "the Epoch", which is Jan 1, 1970.
-- This clock implementation is immune to the system's clock changes.
Relative : constant := 0;
Absolute_Calendar : constant := 1;
Absolute_RT : constant := 2;
-- Values for Mode call below. Note that the compiler (exp_ch9.adb)
-- relies on these values. So any change here must be reflected in
-- corresponding changes in the compiler.
procedure Timed_Delay (Time : Duration; Mode : Integer);
-- Implements the semantics of the delay statement when no tasking is
-- used in the application.
--
-- Mode is one of the three values above
--
-- Time is a relative or absolute duration value, depending on Mode.
--
-- Note that currently Ada.Real_Time always uses the tasking run time, so
-- this procedure should never be called with Mode set to Absolute_RT.
-- This may change in future or bare board implementations.
function To_Duration (T : OS_Time; Mode : Integer) return Duration;
-- Convert VMS system time to Duration
-- Mode is one of the three values above
function To_OS_Time (D : Duration; Mode : Integer) return OS_Time;
-- Convert Duration to VMS system time
-- Mode is one of the three values above
end System.OS_Primitives;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . D E C L _ S E M --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-2012, 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). --
-- --
------------------------------------------------------------------------------
-- This package contains routines needed for semantic queries from
-- the Asis.Declarations package
with Asis; use Asis;
with Types; use Types;
package A4G.Decl_Sem is
-- All the routines defined in this package do not check their
-- arguments - a caller is responcible for the proper use of these
-- routines
-------------------------------------------------
-- Routines for Corresponding_Type_Definition --
-------------------------------------------------
function Serach_First_View (Type_Entity : Entity_Id) return Entity_Id;
-- taking the node representing the type entity, this function looks
-- for the first occurence of this name in the corresponding declarative
-- region. The idea is to find the declaration of the private or incomplete
-- type for which this type defines the full view. If there is no private
-- or incomplete view, the function returns its argument as a result.
--
-- Note, that Type_Entity should not represent an implicit type created
-- by the compiler.
--
-- The reason why we need this function is that some functions from Sinfo
-- and Einfo needed for semantic queries from Asis.Declarations do not
-- correspond to their documentation or/and have irregular behaviour. If
-- and when the corresponding problems in Einfo and Sinfo are fixed, it
-- would be very nice to get rid of this function, which in fact is no
-- more than ad hoc solution.
---------------------------------------------
-- Routines for Corresponding_Declaration --
---------------------------------------------
function Get_Expanded_Spec (Instance_Node : Node_Id) return Node_Id;
-- For Instance_Node, which should represent a generic instantiation,
-- this function returns the node representing the expanded generic
-- specification. This function never returns an Empty node.
--
-- Note, that in case of subprogram instantiation GNAT creates an
-- artificial package enclosing the resulted subprogram declaration
--
-- This is an error to call this function for argument which does not
-- represent an instantiation, or for a node representing a library
-- unit declaration
function Corresponding_Decl_Node (Body_Node : Node_Id) return Node_Id;
-- For Body_Node representing a body, renaming-as-body or a body stub, this
-- function returns the node representing the corresponding declaration.
--
-- It is an error to call this function in case when no explicit separate
-- declaration exists (that is, in case of renaming-as-declaration or
-- a subprogram body (stub) for which no explicit separate declaration is
-- presented.
--
-- It is also an error to call this function for a node representing a
-- library unit declaration or for a node representing generic
-- instantiation.
--------------------------------------
-- Routines for Corresponding_Body --
--------------------------------------
function Corresponding_Body_Node (Decl_Node : Node_Id) return Node_Id;
-- For Decl_Node representing a declaration of a program unit,
-- this function returns the node representing the corresponding
-- body or renaming-as-body. In is an error to call this function,
-- if a completion of the declaration represented by the argument is
-- located in another compilation unit, and the tree being accessed
-- does not contain this unit (this is the case for subprograms declared
-- immediately within a library package/library generic package).
function Get_Renaming_As_Body
(Node : Node_Id;
Spec_Only : Boolean := False)
return Node_Id;
-- This function tries to find for Node (which should be of
-- N_Subprogram_Declaration kind, otherwise this is an error to call
-- this function) the node representing renaming-as-body which is
-- the completion of this subprogram declaration. The Spec_Only
-- flag should be set to limit the search by a package spec only
-------------------------------------------------
-- Routines for Corresponding_Generic_Element --
-------------------------------------------------
function Get_Corresponding_Generic_Element
(Gen_Unit : Asis.Declaration;
Def_Name : Asis.Element)
return Asis.Element;
-- This function traverses the declaration of a generic package
-- Gen_Unit (by applying an instance of Traverce_Element) in order
-- to find A_Defining_Name Element which represents the corresponding
-- generic element for Def_Name; Def_Name should represent
-- A_Defining_Name element which Is_Part_Of_Instance
end A4G.Decl_Sem;
|
with Ada.Exception_Identification.From_Here;
with Ada.Exceptions.Finally;
with Ada.Unchecked_Conversion;
with System.Formatting;
with System.Long_Long_Integer_Types;
with System.Once;
with System.Termination;
with System.Zero_Terminated_WStrings;
with System.Debug; -- assertions
with C.psdk_inc.qwsadata;
with C.winnt;
with C.winsock2;
package body System.Native_IO.Sockets is
use Ada.Exception_Identification.From_Here;
use type C.signed_int;
use type C.size_t;
use type C.psdk_inc.qsocket_types.SOCKET;
use type C.ws2tcpip.struct_addrinfoW_ptr;
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
Flag : aliased Once.Flag := 0;
Failed_To_Initialize : Boolean;
Data : aliased C.psdk_inc.qwsadata.WSADATA := (others => <>);
procedure Finalize;
procedure Finalize is
R : C.signed_int;
begin
R := C.winsock2.WSACleanup;
pragma Check (Debug,
Check => R = 0 or else Debug.Runtime_Error ("WSACleanup failed"));
end Finalize;
procedure Initialize;
procedure Initialize is
begin
Termination.Register_Exit (Finalize'Access);
if C.winsock2.WSAStartup (16#0202#, Data'Access) /= 0 then
Failed_To_Initialize := True;
end if;
end Initialize;
procedure Check_Initialize;
procedure Check_Initialize is
begin
Once.Initialize (Flag'Access, Initialize'Access);
if Failed_To_Initialize then
raise Program_Error; -- ??
end if;
end Check_Initialize;
function To_Handle is
new Ada.Unchecked_Conversion (
C.psdk_inc.qsocket_types.SOCKET,
C.winnt.HANDLE);
function To_SOCKET is
new Ada.Unchecked_Conversion (
C.winnt.HANDLE,
C.psdk_inc.qsocket_types.SOCKET);
-- implementation
procedure Close_Socket (Handle : Handle_Type; Raise_On_Error : Boolean) is
R : C.signed_int;
begin
R := C.winsock2.closesocket (To_SOCKET (Handle));
if R /= 0 and then Raise_On_Error then
Raise_Exception (Use_Error'Identity);
end if;
end Close_Socket;
-- client
function Get (
Host_Name : not null access constant C.winnt.WCHAR;
Service : not null access constant C.winnt.WCHAR;
Hints : not null access constant C.ws2tcpip.struct_addrinfoW)
return End_Point;
function Get (
Host_Name : not null access constant C.winnt.WCHAR;
Service : not null access constant C.winnt.WCHAR;
Hints : not null access constant C.ws2tcpip.struct_addrinfoW)
return End_Point
is
Data : aliased C.ws2tcpip.struct_addrinfoW_ptr;
R : C.signed_int;
begin
R := C.ws2tcpip.GetAddrInfoW (Host_Name, Service, Hints, Data'Access);
if R /= 0 then
Raise_Exception (Use_Error'Identity);
else
return Data;
end if;
end Get;
-- implementation of client
function Resolve (Host_Name : String; Service : String)
return End_Point is
begin
Check_Initialize;
declare
Hints : aliased constant C.ws2tcpip.struct_addrinfoW := (
ai_flags => 0,
ai_family => C.winsock2.AF_UNSPEC,
ai_socktype => C.winsock2.SOCK_STREAM,
ai_protocol => C.winsock2.IPPROTO_TCP,
ai_addrlen => 0,
ai_canonname => null,
ai_addr => null,
ai_next => null);
W_Host_Name : C.winnt.WCHAR_array (
0 ..
Host_Name'Length * Zero_Terminated_WStrings.Expanding);
W_Service : C.winnt.WCHAR_array (
0 ..
Service'Length * Zero_Terminated_WStrings.Expanding);
begin
Zero_Terminated_WStrings.To_C (
Host_Name,
W_Host_Name (0)'Access);
Zero_Terminated_WStrings.To_C (
Service,
W_Service (0)'Access);
return Get (
W_Host_Name (0)'Access,
W_Service (0)'Access,
Hints'Access);
end;
end Resolve;
function Resolve (Host_Name : String; Port : Port_Number)
return End_Point is
begin
Check_Initialize;
declare
Hints : aliased constant C.ws2tcpip.struct_addrinfoW := (
ai_flags => 0, -- mingw-w64 header does not have AI_NUMERICSERV
ai_family => C.winsock2.AF_UNSPEC,
ai_socktype => C.winsock2.SOCK_STREAM,
ai_protocol => C.winsock2.IPPROTO_TCP,
ai_addrlen => 0,
ai_canonname => null,
ai_addr => null,
ai_next => null);
W_Host_Name : C.winnt.WCHAR_array (
0 ..
Host_Name'Length * Zero_Terminated_WStrings.Expanding);
Service : String (1 .. 5);
Service_Last : Natural;
W_Service : C.winnt.WCHAR_array (
0 ..
Service'Length * Zero_Terminated_WStrings.Expanding);
Error : Boolean;
begin
Zero_Terminated_WStrings.To_C (
Host_Name,
W_Host_Name (0)'Access);
Formatting.Image (
Word_Unsigned (Port),
Service,
Service_Last,
Base => 10,
Error => Error);
Zero_Terminated_WStrings.To_C (
Service (1 .. Service_Last),
W_Service (0)'Access);
return Get (
W_Host_Name (0)'Access,
W_Service (0)'Access,
Hints'Access);
end;
end Resolve;
procedure Connect (Handle : aliased out Handle_Type; Peer : End_Point) is
I : C.ws2tcpip.struct_addrinfoW_ptr := Peer;
begin
while I /= null loop
Handle := To_Handle (
C.winsock2.WSASocket (
I.ai_family,
I.ai_socktype,
I.ai_protocol,
null,
0,
0));
if To_SOCKET (Handle) /= C.psdk_inc.qsocket_types.INVALID_SOCKET then
if C.winsock2.WSAConnect (
To_SOCKET (Handle),
I.ai_addr,
C.signed_int (I.ai_addrlen),
null,
null,
null,
null) = 0
then
-- connected
return;
end if;
declare
Closing_Handle : constant Handle_Type := Handle;
begin
Handle := Invalid_Handle;
Close_Socket (Closing_Handle, Raise_On_Error => True);
end;
end if;
I := I.ai_next;
end loop;
Raise_Exception (Use_Error'Identity);
end Connect;
procedure Finalize (Item : End_Point) is
begin
C.ws2tcpip.FreeAddrInfoW (Item);
end Finalize;
-- implementation of server
procedure Listen (Server : aliased out Listener; Port : Port_Number) is
function To_char_const_ptr is
new Ada.Unchecked_Conversion (
C.signed_int_ptr, -- pointer to BOOL
C.char_const_ptr);
Hints : aliased constant C.ws2tcpip.struct_addrinfoW := (
ai_flags => C.ws2tcpip.AI_PASSIVE, -- or AI_NUMERICSERV
ai_family => C.winsock2.AF_UNSPEC,
ai_socktype => C.winsock2.SOCK_STREAM,
ai_protocol => C.winsock2.IPPROTO_TCP,
ai_addrlen => 0,
ai_canonname => null,
ai_addr => null,
ai_next => null);
Data : aliased C.ws2tcpip.struct_addrinfoW_ptr;
W_Service : C.winnt.WCHAR_array (0 .. 5); -- "65535" & NUL
begin
Check_Initialize;
declare
Service : String (1 .. 5);
Service_Last : Natural;
Error : Boolean;
begin
Formatting.Image (
Word_Unsigned (Port),
Service,
Service_Last,
Base => 10,
Error => Error);
Zero_Terminated_WStrings.To_C (
Service (1 .. Service_Last),
W_Service (0)'Access);
end;
if C.ws2tcpip.GetAddrInfoW (
null,
W_Service (0)'Access,
Hints'Access,
Data'Access) /= 0
then
Raise_Exception (Use_Error'Identity);
end if;
declare
procedure Finally (X : in out C.ws2tcpip.struct_addrinfoW_ptr);
procedure Finally (X : in out C.ws2tcpip.struct_addrinfoW_ptr) is
begin
C.ws2tcpip.FreeAddrInfoW (X);
end Finally;
package Holder is
new Ada.Exceptions.Finally.Scoped_Holder (
C.ws2tcpip.struct_addrinfoW_ptr,
Finally);
Reuse_Addr_Option : aliased C.windef.BOOL;
begin
Holder.Assign (Data);
Server := C.winsock2.WSASocket (
Data.ai_family,
Data.ai_socktype,
Data.ai_protocol,
null,
0,
0);
-- set SO_REUSEADDR
Reuse_Addr_Option := 1;
if C.winsock2.setsockopt (
Server,
C.winsock2.SOL_SOCKET,
C.winsock2.SO_REUSEADDR,
To_char_const_ptr (Reuse_Addr_Option'Unchecked_Access),
Reuse_Addr_Option'Size / Standard'Storage_Unit) /= 0
then
Raise_Exception (Use_Error'Identity);
end if;
-- bind
if C.winsock2.bind (
Server,
Data.ai_addr,
C.signed_int (Data.ai_addrlen)) /= 0
then
Raise_Exception (Use_Error'Identity);
end if;
-- listen
if C.winsock2.listen (Server, C.winsock2.SOMAXCONN) /= 0 then
Raise_Exception (Use_Error'Identity);
end if;
end;
end Listen;
procedure Accept_Socket (
Server : Listener;
Handle : aliased out Handle_Type;
Remote_Address : out Socket_Address)
is
Len : aliased C.windef.INT :=
Socket_Address'Size / Standard'Storage_Unit;
New_Socket : C.psdk_inc.qsocket_types.SOCKET;
begin
New_Socket :=
C.winsock2.WSAAccept (
Server,
Remote_Address'Unrestricted_Access,
Len'Access,
lpfnCondition => null,
dwCallbackData => 0);
if New_Socket = C.psdk_inc.qsocket_types.INVALID_SOCKET then
Raise_Exception (Use_Error'Identity);
else
Handle := To_Handle (New_Socket);
end if;
end Accept_Socket;
procedure Close_Listener (Server : Listener; Raise_On_Error : Boolean) is
begin
Close_Socket (To_Handle (Server), Raise_On_Error => Raise_On_Error);
end Close_Listener;
end System.Native_IO.Sockets;
|
separate (Numerics.Sparse_Matrices)
function Norm2 (Item : in Sparse_Matrix) return Real is
Sum, Result : Real := 0.0;
X : RVector renames Item.X;
P : IVector renames Item.P;
-- use Real_Functions;
begin
if Item.N_Col = 1 or else Item.N_Row = 1 then
-- 2-norm for vectors
for Item of X loop
Result := Result + Item ** 2;
end loop;
return (Result);
else
-- 1-norm for matrices
for J in 1 .. Item.N_Col loop
Sum := 0.0;
for I in Item.P (J) .. Item.P (J + 1) - 1 loop
Sum := abs (X (I));
end loop;
Result := Real'Max (Result, Sum);
end loop;
return Result ** 2;
end if;
end Norm2;
|
with Ada.Text_IO;
with Ada.Streams.Stream_IO;
package body NeuralNet.IO is
file_magic_mark: constant Integer := 16#666DEAD#;
file_format_version: constant Integer := 1;
procedure save(nn: in NeuralNet.Net; path: in String) is
output_file: Ada.Streams.Stream_IO.File_Type;
output_stream: Ada.Streams.Stream_IO.Stream_Access;
begin
Ada.Streams.Stream_IO.Create(File => output_file,
Mode => Ada.Streams.Stream_IO.Out_File,
Name => path);
output_stream := Ada.Streams.Stream_IO.Stream(output_file);
Integer'Write(output_stream, file_magic_mark);
Integer'Write(output_stream, file_format_version);
Positive'Write(output_stream, nn.conf.size);
NeuralNet.Config'Write(output_stream, nn.conf);
NeuralNet.Net'Write(output_stream, nn);
Ada.Streams.Stream_IO.Close(output_file);
end save;
function load(path: in String; status: out Boolean) return NeuralNet.Net is
null_net_config: NeuralNet.Config(1);
input_file: Ada.Streams.Stream_IO.File_Type;
input_stream: Ada.Streams.Stream_IO.Stream_Access;
begin
ADa.Streams.Stream_IO.Open(File => input_file,
Mode => Ada.Streams.Stream_IO.In_File,
Name => path);
input_stream := Ada.Streams.Stream_IO.Stream(input_file);
status := not Ada.Streams.Stream_IO.End_Of_File(input_file);
if status then
declare
magic_mark: Integer;
format_ver: Integer;
conf_size: Positive;
begin
Integer'Read(input_stream, magic_mark);
Integer'Read(input_stream, format_ver);
Positive'Read(input_stream, conf_size);
if magic_mark = file_magic_mark and format_ver = file_format_version then
declare
conf: NeuralNet.Config(conf_size);
begin
NeuralNet.Config'Read(input_stream, conf);
return nn: NeuralNet.Net := NeuralNet.create(conf) do
NeuralNet.Net'Read(input_stream, nn);
Ada.Streams.Stream_IO.Close(input_file);
end return;
end;
end if;
end;
Ada.Streams.Stream_IO.Close(input_file);
end if;
null_net_config.sizes := (1 => 1);
return NeuralNet.create(null_net_config);
end load;
end NeuralNet.IO;
|
with Units; use Units;
package unav with SPARK_Mode is
EARTH_RADIUS : constant Length_Type := 6378.137 * Kilo * Meter;
function Get_Distance return Length_Type with
Post => Get_Distance'Result in 0.0 * Meter .. 2.0*EARTH_RADIUS*180.0*Degree;
end unav;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- B U T I L --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-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. --
-- --
------------------------------------------------------------------------------
-- This package contains utility routines for the binder
with Namet; use Namet;
with Types; use Types;
package Butil is
function Is_Predefined_Unit return Boolean;
-- Given a unit name stored in Name_Buffer with length in Name_Len,
-- returns True if this is the name of a predefined unit or a child of
-- a predefined unit (including the obsolescent renamings). This is used
-- in the preference selection (see Better_Choice in body of Binde).
function Is_Internal_Unit return Boolean;
-- Given a unit name stored in Name_Buffer with length in Name_Len,
-- returns True if this is the name of an internal unit or a child of
-- an internal unit. Similar in usage to Is_Predefined_Unit.
-- Note: the following functions duplicate functionality in Uname, but
-- we want to avoid bringing Uname into the binder since it generates
-- to many unnecessary dependencies, and makes the binder too large.
function Uname_Less (U1, U2 : Unit_Name_Type) return Boolean;
-- Determines if the unit name U1 is alphabetically before U2
procedure Write_Unit_Name (U : Unit_Name_Type);
-- Output unit name with (body) or (spec) after as required. On return
-- Name_Len is set to the number of characters which were output.
---------------
-- Iterators --
---------------
-- The following type represents an iterator over all units that are
-- specified in the forced-elaboration-order file supplied by the binder
-- via switch -f.
type Forced_Units_Iterator is private;
function Has_Next (Iter : Forced_Units_Iterator) return Boolean;
pragma Inline (Has_Next);
-- Determine whether iterator Iter has more units to examine
function Iterate_Forced_Units return Forced_Units_Iterator;
pragma Inline (Iterate_Forced_Units);
-- Obtain an iterator over all units in the forced-elaboration-order file
procedure Next
(Iter : in out Forced_Units_Iterator;
Unit_Name : out Unit_Name_Type;
Unit_Line : out Logical_Line_Number);
pragma Inline (Next);
-- Return the current unit referenced by iterator Iter along with the
-- line number it appears on, and advance to the next available unit.
private
First_Line_Number : constant Logical_Line_Number := No_Line_Number + 1;
type Forced_Units_Iterator is record
Order : String_Ptr := null;
-- A reference to the contents of the forced-elaboration-order file,
-- read in as a string.
Order_Index : Positive := 1;
-- Index into the order string
Order_Line : Logical_Line_Number := First_Line_Number;
-- Logical line number within the order string
Unit_Line : Logical_Line_Number := No_Line_Number;
-- The logical line number of the current unit name within the order
-- string.
Unit_Name : Unit_Name_Type := No_Unit_Name;
-- The current unit name parsed from the order string
end record;
end Butil;
|
with Ada.Containers.Indefinite_Ordered_Maps;
with kv.avm.Instructions;
with kv.avm.Registers;
with kv.avm.Memories;
with kv.avm.Methods; use kv.avm.Methods;
package kv.avm.Actors is
use kv.avm.Instructions;
package Subroutines is new Ada.Containers.Indefinite_Ordered_Maps
(Key_Type => String,
Element_Type => kv.avm.Methods.Method_Access);
type Actor_Type;
type Actor_Access is access all Actor_Type;
type Actor_Type is tagged
record
Parent : Actor_Access;
Name : kv.avm.Registers.Constant_String_Access;
Methods : Subroutines.Map;
Attribute_Count : Natural;
Fixed : kv.avm.Memories.Register_Array_Type;
end record;
function New_Actor
(Name : in String;
Constructor : in kv.avm.Instructions.Code_Access;
Attribute_Count : in Natural := 0;
Fixed_Registers : in kv.avm.Memories.Register_Array_Type;
Parent : in Actor_Access := null) return Actor_Access;
procedure Initialize
(Self : in out Actor_Type;
Name : in kv.avm.Registers.Constant_String_Access;
Constructor : in kv.avm.Instructions.Code_Access;
Attribute_Count : in Natural := 0;
Parent : in Actor_Access := null;
Fixed_Registers : in kv.avm.Memories.Register_Array_Type);
procedure Add_Method
(Self : in out Actor_Type;
Method : in kv.avm.Methods.Method_Access);
procedure Add_Parent
(Self : in out Actor_Type;
Parent : in Actor_Access);
function Get_Method
(Self : Actor_Type;
Name : String) return kv.avm.Methods.Method_Access;
function Get_Constants
(Self : Actor_Type) return kv.avm.Memories.Register_Array_Type;
function Get_Parent
(Self : Actor_Type) return Actor_Access;
function Get_Name
(Self : Actor_Type) return String;
function Get_Actor_By_Name(Name : String) return Actor_Access;
function Image(Self : Actor_Type) return String;
procedure Empty_Actor_Map;
end kv.avm.Actors;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T D L L --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1997-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. --
-- --
------------------------------------------------------------------------------
-- GNATDLL is a Windows specific tool for building a DLL.
-- Both relocatable and non-relocatable DLL's are supported
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Exceptions;
with Ada.Command_Line;
with GNAT.OS_Lib;
with GNAT.Command_Line;
with Gnatvsn;
with MDLL.Files;
with MDLL.Tools;
procedure Gnatdll is
use GNAT;
use Ada;
use MDLL;
use Ada.Strings.Unbounded;
use type OS_Lib.Argument_List;
procedure Syntax;
-- Print out usage
procedure Check (Filename : String);
-- Check that the file whose name is Filename exists
procedure Parse_Command_Line;
-- Parse the command line arguments passed to gnatdll
procedure Check_Context;
-- Check the context before runing any commands to build the library
Syntax_Error : exception;
Context_Error : exception;
-- What are these for ???
Help : Boolean := False;
-- What is this for ???
Version : constant String := Gnatvsn.Gnat_Version_String;
-- Why should it be necessary to make a copy of this
Default_DLL_Address : constant String := "0x11000000";
-- Default address for non relocatable DLL (Win32)
Lib_Filename : Unbounded_String := Null_Unbounded_String;
Def_Filename : Unbounded_String := Null_Unbounded_String;
List_Filename : Unbounded_String := Null_Unbounded_String;
DLL_Address : Unbounded_String :=
To_Unbounded_String (Default_DLL_Address);
-- What are the above ???
Objects_Files : Argument_List_Access := Null_Argument_List_Access;
-- List of objects to put inside the library
Ali_Files : Argument_List_Access := Null_Argument_List_Access;
-- For each Ada file specified, we keep arecord of the corresponding
-- ALI file. This list of SLI files is used to build the binder program.
Options : Argument_List_Access := Null_Argument_List_Access;
-- A list of options set in the command line.
Largs_Options : Argument_List_Access := Null_Argument_List_Access;
Bargs_Options : Argument_List_Access := Null_Argument_List_Access;
-- GNAT linker and binder args options
type Build_Mode_State is (Import_Lib, Dynamic_Lib, Nil);
-- Comments needed ???
Build_Mode : Build_Mode_State := Nil;
Must_Build_Relocatable : Boolean := True;
Build_Import : Boolean := True;
-- Comments needed
------------
-- Syntax --
------------
procedure Syntax is
use Text_IO;
procedure P (Str : in String) renames Text_IO.Put_Line;
begin
P ("Usage : gnatdll [options] [list-of-files]");
New_Line;
P ("[list-of-files] a list of Ada libraries (.ali) and/or " &
"foreign object files");
New_Line;
P ("[options] can be");
P (" -h Help - display this message");
P (" -v Verbose");
P (" -q Quiet");
P (" -k Remove @nn suffix from exported names");
P (" -g Generate debugging information");
P (" -Idir Specify source and object files search path");
P (" -l file File contains a list-of-files to be added to "
& "the library");
P (" -e file Definition file containing exports");
P (" -d file Put objects in the relocatable dynamic "
& "library <file>");
P (" -a[addr] Build non-relocatable DLL at address <addr>");
P (" if <addr> is not specified use "
& Default_DLL_Address);
P (" -n No-import - do not create the import library");
P (" -bargs opts opts are passed to the binder");
P (" -largs opts opts are passed to the linker");
end Syntax;
-----------
-- Check --
-----------
procedure Check (Filename : in String) is
begin
if not OS_Lib.Is_Regular_File (Filename) then
Exceptions.Raise_Exception (Context_Error'Identity,
"Error: " & Filename & " not found.");
end if;
end Check;
------------------------
-- Parse_Command_Line --
------------------------
procedure Parse_Command_Line is
use GNAT.Command_Line;
procedure Add_File (Filename : in String);
-- add one file to the list of file to handle
procedure Add_Files_From_List (List_Filename : in String);
-- add the files listed in List_Filename (one by line) to the list
-- of file to handle
procedure Ali_To_Object_List;
-- for each ali file in Afiles set put a corresponding object file in
-- Ofiles set.
Max_Files : constant := 5_000;
Max_Options : constant := 100;
-- These are arbitrary limits, a better way will be to use linked list.
-- No, a better choice would be to use tables ???
-- Limits on what???
Ofiles : OS_Lib.Argument_List (1 .. Max_Files);
O : Positive := Ofiles'First;
-- List of object files to put in the library. O is the next entry
-- to be used.
Afiles : OS_Lib.Argument_List (1 .. Max_Files);
A : Positive := Afiles'First;
-- List of ALI files. A is the next entry to be used.
Gopts : OS_Lib.Argument_List (1 .. Max_Options);
G : Positive := Gopts'First;
-- List of gcc options. G is the next entry to be used.
Lopts : OS_Lib.Argument_List (1 .. Max_Options);
L : Positive := Lopts'First;
-- A list of -largs options (L is next entry to be used)
Bopts : OS_Lib.Argument_List (1 .. Max_Options);
B : Positive := Bopts'First;
-- A list of -bargs options (B is next entry to be used)
--------------
-- Add_File --
--------------
procedure Add_File (Filename : in String) is
begin
-- others files are to be put inside the dynamic library
-- ??? this makes no sense, should it be "Other files ..."
if Files.Is_Ali (Filename) then
Check (Filename);
-- Record it to generate the binder program when
-- building dynamic library
Afiles (A) := new String'(Filename);
A := A + 1;
elsif Files.Is_Obj (Filename) then
Check (Filename);
-- Just record this object file
Ofiles (O) := new String'(Filename);
O := O + 1;
else
-- Unknown file type
Exceptions.Raise_Exception
(Syntax_Error'Identity,
"don't know what to do with " & Filename & " !");
end if;
end Add_File;
-------------------------
-- Add_Files_From_List --
-------------------------
procedure Add_Files_From_List (List_Filename : in String) is
File : Text_IO.File_Type;
Buffer : String (1 .. 500);
Last : Natural;
begin
Text_IO.Open (File, Text_IO.In_File, List_Filename);
while not Text_IO.End_Of_File (File) loop
Text_IO.Get_Line (File, Buffer, Last);
Add_File (Buffer (1 .. Last));
end loop;
Text_IO.Close (File);
end Add_Files_From_List;
------------------------
-- Ali_To_Object_List --
------------------------
procedure Ali_To_Object_List is
begin
for K in 1 .. A - 1 loop
Ofiles (O) := new String'(Files.Ext_To (Afiles (K).all, "o"));
O := O + 1;
end loop;
end Ali_To_Object_List;
-- Start of processing for Parse_Command_Line
begin
Initialize_Option_Scan ('-', False, "bargs largs");
-- scan gnatdll switches
loop
case Getopt ("g h v q k a? d: e: l: n I:") is
when ASCII.Nul =>
exit;
when 'h' =>
Help := True;
when 'g' =>
Gopts (G) := new String'("-g");
G := G + 1;
when 'v' =>
-- Turn verbose mode on
MDLL.Verbose := True;
if MDLL.Quiet then
Exceptions.Raise_Exception
(Syntax_Error'Identity,
"impossible to use -q and -v together.");
end if;
when 'q' =>
-- Turn quiet mode on
MDLL.Quiet := True;
if MDLL.Verbose then
Exceptions.Raise_Exception
(Syntax_Error'Identity,
"impossible to use -v and -q together.");
end if;
when 'k' =>
MDLL.Kill_Suffix := True;
when 'a' =>
if Parameter = "" then
-- Default address for a relocatable dynamic library.
-- address for a non relocatable dynamic library.
DLL_Address := To_Unbounded_String (Default_DLL_Address);
else
DLL_Address := To_Unbounded_String (Parameter);
end if;
Must_Build_Relocatable := False;
when 'e' =>
Def_Filename := To_Unbounded_String (Parameter);
when 'd' =>
-- Build a non relocatable DLL
Lib_Filename := To_Unbounded_String (Parameter);
if Def_Filename = Null_Unbounded_String then
Def_Filename := To_Unbounded_String
(Files.Ext_To (Parameter, "def"));
end if;
Build_Mode := Dynamic_Lib;
when 'n' =>
Build_Import := False;
when 'l' =>
List_Filename := To_Unbounded_String (Parameter);
when 'I' =>
Gopts (G) := new String'("-I" & Parameter);
G := G + 1;
when others =>
raise Invalid_Switch;
end case;
end loop;
-- Get parameters
loop
declare
File : constant String := Get_Argument (Do_Expansion => True);
begin
exit when File'Length = 0;
Add_File (File);
end;
end loop;
-- Get largs parameters
Goto_Section ("largs");
loop
case Getopt ("*") is
when ASCII.Nul =>
exit;
when others =>
Lopts (L) := new String'(Full_Switch);
L := L + 1;
end case;
end loop;
-- Get bargs parameters
Goto_Section ("bargs");
loop
case Getopt ("*") is
when ASCII.Nul =>
exit;
when others =>
Bopts (B) := new String'(Full_Switch);
B := B + 1;
end case;
end loop;
-- if list filename has been specified, parse it
if List_Filename /= Null_Unbounded_String then
Add_Files_From_List (To_String (List_Filename));
end if;
-- Check if the set of parameters are compatible.
if Build_Mode = Nil and then not Help and then not Verbose then
Exceptions.Raise_Exception
(Syntax_Error'Identity,
"nothing to do.");
end if;
-- Check if we want to build an import library (option -e and
-- no file specified)
if Build_Mode = Dynamic_Lib
and then A = Afiles'First
and then O = Ofiles'First
then
Build_Mode := Import_Lib;
end if;
if O /= Ofiles'First then
Objects_Files := new OS_Lib.Argument_List'(Ofiles (1 .. O - 1));
end if;
if A /= Afiles'First then
Ali_Files := new OS_Lib.Argument_List'(Afiles (1 .. A - 1));
end if;
if G /= Gopts'First then
Options := new OS_Lib.Argument_List'(Gopts (1 .. G - 1));
end if;
if L /= Lopts'First then
Largs_Options := new OS_Lib.Argument_List'(Lopts (1 .. L - 1));
end if;
if B /= Bopts'First then
Bargs_Options := new OS_Lib.Argument_List'(Bopts (1 .. B - 1));
end if;
exception
when Invalid_Switch =>
Exceptions.Raise_Exception
(Syntax_Error'Identity,
Message => "Invalid Switch " & Full_Switch);
when Invalid_Parameter =>
Exceptions.Raise_Exception
(Syntax_Error'Identity,
Message => "No parameter for " & Full_Switch);
end Parse_Command_Line;
-------------------
-- Check_Context --
-------------------
procedure Check_Context is
begin
Check (To_String (Def_Filename));
-- Check that each object file specified exists and raise exception
-- Context_Error if it does not.
for F in Objects_Files'Range loop
Check (Objects_Files (F).all);
end loop;
end Check_Context;
-- Start of processing for Gnatdll
begin
if Ada.Command_Line.Argument_Count = 0 then
Help := True;
else
Parse_Command_Line;
end if;
if MDLL.Verbose or else Help then
Text_IO.New_Line;
Text_IO.Put_Line ("GNATDLL " & Version & " - Dynamic Libraries Builder");
Text_IO.New_Line;
end if;
MDLL.Tools.Locate;
if Help
or else (MDLL.Verbose and then Ada.Command_Line.Argument_Count = 1)
then
Syntax;
else
Check_Context;
case Build_Mode is
when Import_Lib =>
MDLL.Build_Import_Library
(To_String (Lib_Filename),
To_String (Def_Filename));
when Dynamic_Lib =>
MDLL.Build_Dynamic_Library
(Objects_Files.all,
Ali_Files.all,
Options.all,
Bargs_Options.all,
Largs_Options.all,
To_String (Lib_Filename),
To_String (Def_Filename),
To_String (DLL_Address),
Build_Import,
Must_Build_Relocatable);
when Nil =>
null;
end case;
end if;
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success);
exception
when SE : Syntax_Error =>
Text_IO.Put_Line ("Syntax error : " & Exceptions.Exception_Message (SE));
Text_IO.New_Line;
Syntax;
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
when E : Tools_Error | Context_Error =>
Text_IO.Put_Line (Exceptions.Exception_Message (E));
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
when others =>
Text_IO.Put_Line ("gnatdll: INTERNAL ERROR. Please report");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end Gnatdll;
|
pragma License (Unrestricted);
with Ada.Strings.Generic_Unbounded.Generic_Hash;
with Ada.Strings.Wide_Hash;
function Ada.Strings.Wide_Unbounded.Wide_Hash is
new Unbounded_Wide_Strings.Generic_Hash (Wide_Hash);
pragma Preelaborate (Ada.Strings.Wide_Unbounded.Wide_Hash);
|
-- { dg-do compile }
procedure parameterlessfunc is
type Byte is mod 256;
type Byte_Array is array(Byte range <>) of Byte;
subtype Index is Byte range 0..7;
subtype Small_Array is Byte_Array(Index);
function F return Byte_Array is
begin
return (0..255=>0);
end F;
B5: Small_Array := F(Index);
begin
null;
end parameterlessfunc;
|
package Tail_Call_P is
type T is new Natural;
type Index is (First, Second);
type A is array (Index) of T;
My_Array : A := (0, 0);
procedure Insert (Into : A; Element : T; Value : T);
end Tail_Call_P;
|
with A_Stack; use A_Stack;
package Reverser with
SPARK_Mode
is
subtype Array_Range is Natural range 1 .. 10_000;
type Array_Of_Items is array (Array_Range range <>) of Item;
procedure Reverse_Array (A : in out Array_Of_Items) with
Global => (In_Out => The_Stack),
Pre => A'Length > 0 and then A'Length <= Stack_Size;
end Reverser;
|
-- { dg-do compile }
package body Class_Wide2 is
procedure Initialize is
Var_Acc : Class_Acc := new Grand_Child;
Var : Grand_Child'Class := Grand_Child'Class (Var_Acc.all);
begin
Var := Grand_Child'Class (Var_Acc.all);
end Initialize;
end Class_Wide2;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Upg3 is
function Count
return Integer is
S : String(1..3);
C : Character;
A, B : Integer;
begin
Get(S);
Get(A);
Get(C); Get(C);
Get(B);
return (B - A + 1);
end;
function Read
return Integer is
C : Character;
Temp: Integer;
begin
Get(C);
if C = 's' then
return Count;
else
Temp := Read;
Get(C); Get(C);
return Temp + Read;
end if;
end;
Temp: Integer;
begin
Put("Mata in sidhänvisningar: ");
Temp := Read;
Put("Totalt antal sidor: "); Put(Temp,1);
end;
|
-- { dg-do compile }
-- { dg-options "-gnatws -fdump-tree-gimple" }
procedure Alignment4 is
type Stream is array (1..3) of Character;
S1, S2 : Stream;
begin
S1 := S2;
end;
-- { dg-final { scan-tree-dump-not ".\F" "gimple" } }
|
with Libtcod.Color, Interfaces.C;
private with console_h, context_h, Ada.Finalization;
use Libtcod, Libtcod.Color;
package Libtcod.Console is
-- Basic types --
type X_Pos is new Interfaces.C.int range 0 .. Interfaces.C.int'Last;
type Y_Pos is new Interfaces.C.int range 0 .. Interfaces.C.int'Last;
Error : exception;
type Renderer_Type is
(Renderer_GLSL,
Renderer_OPENGL,
Renderer_SDL,
Renderer_SDL2,
Renderer_OpenGL2)
with Convention => C;
-- Background color blend modes
type Background_Mode is
(Background_None,
Background_Set,
Background_Multiply,
Background_Lighten,
Background_Darken,
Background_Screen,
Background_Color_Dodge,
Background_Color_Burn,
Background_Add,
Background_Adda,
Background_Burn,
Background_Overlay,
Background_Alpha,
Background_Default)
with Convention => C;
-- Justification options
type Alignment_Type is
(Alignment_Left,
Alignment_Right,
Alignment_Center)
with Convention => C;
-- Root (Manages rendering)
type Context is tagged limited private;
-- Screen --
type Screen is tagged limited private;
-- Constructors --
function make_context(w : Width; h : Height; title : String;
resizable : Boolean := True; fullscreen : Boolean := False;
renderer : Renderer_Type := Renderer_SDL2) return Context;
function make_screen(w : Width; h : Height) return Screen;
-- Operations --
-- Global Operations (affect current window)
procedure set_title(title : String);
procedure set_fullscreen(val : Boolean) with Inline;
function is_fullscreen return Boolean with Inline;
function is_window_closed return Boolean with Inline;
-- Context Operations
procedure present(cxt : in out Context'Class; s : Screen);
-- Screen Operations
function get_width(s : Screen) return Width with Inline;
function get_height(s : Screen) return Height with Inline;
function has_key_color(s : Screen) return Boolean with Inline;
procedure set_key_color(s : in out Screen; key_color : RGB_Color) with Inline;
function get_key_color(s : Screen) return RGB_Color with Inline;
procedure set_default_fg(s : in out Screen; fg : RGB_Color) with Inline;
function get_default_fg(s : Screen) return RGB_Color with Inline;
procedure set_default_bg(s : in out Screen; bg : RGB_Color) with Inline;
function get_default_bg(s : Screen) return RGB_Color with Inline;
procedure clear(s : in out Screen) with Inline;
procedure resize(s : in out Screen; w : Width; h : Height) with Inline;
procedure blit(s : Screen; src_x : X_Pos; src_y : Y_Pos;
w : Width; h : Height; dest : in out Screen;
dest_x : X_Pos; dest_y : Y_Pos)
with Inline;
procedure put_char(s : in out Screen; x : X_Pos; y : Y_Pos; ch : Wide_Character)
with Inline;
procedure put_char(s : in out Screen; x : X_Pos; y : Y_Pos; ch : Wide_Character;
mode : Background_Mode) with Inline;
procedure put_char(s : in out Screen; x : X_Pos; y : Y_Pos; ch : Wide_Character;
fg_color, bg_color : RGB_Color) with Inline;
procedure print(s : in out Screen; x : X_Pos; y : Y_Pos; text : String);
function get_char(s : Screen; x : X_Pos; y : Y_Pos) return Wide_Character with Inline;
procedure set_char_fg(s : in out Screen; x : X_Pos; y : Y_Pos; color : RGB_Color)
with Inline;
function get_char_fg(s : Screen; x : X_Pos; y : Y_Pos) return RGB_Color with Inline;
procedure set_char_bg(s : in out Screen; x : X_Pos; y : Y_Pos; color : RGB_Color;
mode : Background_Mode := Background_Set) with Inline;
function get_char_bg(s : Screen; x : X_Pos; y : Y_Pos) return RGB_Color with Inline;
procedure set_bg_mode(s : in out Screen; mode : Background_Mode) with Inline;
function get_bg_mode(s : Screen) return Background_Mode with Inline;
procedure set_alignment(s : in out Screen; alignment : Alignment_Type) with Inline;
function get_alignment(s : Screen) return Alignment_Type with Inline;
-- Shape drawing
procedure rect(s : in out Screen; x : X_Pos; y : Y_Pos; w : Width; h : Height;
clear : Boolean := False; bg_flag : Background_Mode := Background_Set)
with Inline;
private
type Context is new Ada.Finalization.Limited_Controlled with record
data : aliased access context_h.TCOD_Context;
end record;
overriding procedure Finalize(self : in out Context);
type Screen is new Ada.Finalization.Limited_Controlled with record
data : access console_h.TCOD_Console;
end record;
overriding procedure Finalize(self : in out Screen);
end Libtcod.Console;
|
-- 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.NFCT is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Shortcut between FIELDDETECTED event and ACTIVATE task
type SHORTS_FIELDDETECTED_ACTIVATE_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_FIELDDETECTED_ACTIVATE_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between FIELDLOST event and SENSE task
type SHORTS_FIELDLOST_SENSE_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_FIELDLOST_SENSE_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut register
type SHORTS_Register is record
-- Shortcut between FIELDDETECTED event and ACTIVATE task
FIELDDETECTED_ACTIVATE : SHORTS_FIELDDETECTED_ACTIVATE_Field :=
NRF_SVD.NFCT.Disabled;
-- Shortcut between FIELDLOST event and SENSE task
FIELDLOST_SENSE : SHORTS_FIELDLOST_SENSE_Field :=
NRF_SVD.NFCT.Disabled;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
FIELDDETECTED_ACTIVATE at 0 range 0 .. 0;
FIELDLOST_SENSE at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Enable or disable interrupt for READY event
type INTEN_READY_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_READY_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for FIELDDETECTED event
type INTEN_FIELDDETECTED_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_FIELDDETECTED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for FIELDLOST event
type INTEN_FIELDLOST_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_FIELDLOST_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for TXFRAMESTART event
type INTEN_TXFRAMESTART_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_TXFRAMESTART_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for TXFRAMEEND event
type INTEN_TXFRAMEEND_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_TXFRAMEEND_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for RXFRAMESTART event
type INTEN_RXFRAMESTART_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_RXFRAMESTART_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for RXFRAMEEND event
type INTEN_RXFRAMEEND_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_RXFRAMEEND_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for ERROR event
type INTEN_ERROR_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for RXERROR event
type INTEN_RXERROR_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_RXERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for ENDRX event
type INTEN_ENDRX_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_ENDRX_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for ENDTX event
type INTEN_ENDTX_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_ENDTX_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for AUTOCOLRESSTARTED event
type INTEN_AUTOCOLRESSTARTED_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_AUTOCOLRESSTARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for COLLISION event
type INTEN_COLLISION_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_COLLISION_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for SELECTED event
type INTEN_SELECTED_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_SELECTED_Field use
(Disabled => 0,
Enabled => 1);
-- 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
type INTEN_Register is record
-- Enable or disable interrupt for READY event
READY : INTEN_READY_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for FIELDDETECTED event
FIELDDETECTED : INTEN_FIELDDETECTED_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for FIELDLOST event
FIELDLOST : INTEN_FIELDLOST_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for TXFRAMESTART event
TXFRAMESTART : INTEN_TXFRAMESTART_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for TXFRAMEEND event
TXFRAMEEND : INTEN_TXFRAMEEND_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for RXFRAMESTART event
RXFRAMESTART : INTEN_RXFRAMESTART_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for RXFRAMEEND event
RXFRAMEEND : INTEN_RXFRAMEEND_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for ERROR event
ERROR : INTEN_ERROR_Field := NRF_SVD.NFCT.Disabled;
-- unspecified
Reserved_8_9 : HAL.UInt2 := 16#0#;
-- Enable or disable interrupt for RXERROR event
RXERROR : INTEN_RXERROR_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for ENDRX event
ENDRX : INTEN_ENDRX_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for ENDTX event
ENDTX : INTEN_ENDTX_Field := NRF_SVD.NFCT.Disabled;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- Enable or disable interrupt for AUTOCOLRESSTARTED event
AUTOCOLRESSTARTED : INTEN_AUTOCOLRESSTARTED_Field :=
NRF_SVD.NFCT.Disabled;
-- unspecified
Reserved_15_17 : HAL.UInt3 := 16#0#;
-- Enable or disable interrupt for COLLISION event
COLLISION : INTEN_COLLISION_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for SELECTED event
SELECTED : INTEN_SELECTED_Field := NRF_SVD.NFCT.Disabled;
-- Enable or disable interrupt for STARTED event
STARTED : INTEN_STARTED_Field := NRF_SVD.NFCT.Disabled;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTEN_Register use record
READY at 0 range 0 .. 0;
FIELDDETECTED at 0 range 1 .. 1;
FIELDLOST at 0 range 2 .. 2;
TXFRAMESTART at 0 range 3 .. 3;
TXFRAMEEND at 0 range 4 .. 4;
RXFRAMESTART at 0 range 5 .. 5;
RXFRAMEEND at 0 range 6 .. 6;
ERROR at 0 range 7 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
RXERROR at 0 range 10 .. 10;
ENDRX at 0 range 11 .. 11;
ENDTX at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
AUTOCOLRESSTARTED at 0 range 14 .. 14;
Reserved_15_17 at 0 range 15 .. 17;
COLLISION at 0 range 18 .. 18;
SELECTED at 0 range 19 .. 19;
STARTED at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- Write '1' to Enable interrupt for READY event
type INTENSET_READY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_READY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for READY event
type INTENSET_READY_Field_1 is
(-- Reset value for the field
Intenset_Ready_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_READY_Field_1 use
(Intenset_Ready_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for FIELDDETECTED event
type INTENSET_FIELDDETECTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_FIELDDETECTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for FIELDDETECTED event
type INTENSET_FIELDDETECTED_Field_1 is
(-- Reset value for the field
Intenset_Fielddetected_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_FIELDDETECTED_Field_1 use
(Intenset_Fielddetected_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for FIELDLOST event
type INTENSET_FIELDLOST_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_FIELDLOST_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for FIELDLOST event
type INTENSET_FIELDLOST_Field_1 is
(-- Reset value for the field
Intenset_Fieldlost_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_FIELDLOST_Field_1 use
(Intenset_Fieldlost_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for TXFRAMESTART event
type INTENSET_TXFRAMESTART_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_TXFRAMESTART_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for TXFRAMESTART event
type INTENSET_TXFRAMESTART_Field_1 is
(-- Reset value for the field
Intenset_Txframestart_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_TXFRAMESTART_Field_1 use
(Intenset_Txframestart_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for TXFRAMEEND event
type INTENSET_TXFRAMEEND_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_TXFRAMEEND_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for TXFRAMEEND event
type INTENSET_TXFRAMEEND_Field_1 is
(-- Reset value for the field
Intenset_Txframeend_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_TXFRAMEEND_Field_1 use
(Intenset_Txframeend_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for RXFRAMESTART event
type INTENSET_RXFRAMESTART_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_RXFRAMESTART_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for RXFRAMESTART event
type INTENSET_RXFRAMESTART_Field_1 is
(-- Reset value for the field
Intenset_Rxframestart_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_RXFRAMESTART_Field_1 use
(Intenset_Rxframestart_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for RXFRAMEEND event
type INTENSET_RXFRAMEEND_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_RXFRAMEEND_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for RXFRAMEEND event
type INTENSET_RXFRAMEEND_Field_1 is
(-- Reset value for the field
Intenset_Rxframeend_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_RXFRAMEEND_Field_1 use
(Intenset_Rxframeend_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for ERROR event
type INTENSET_ERROR_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for ERROR event
type INTENSET_ERROR_Field_1 is
(-- Reset value for the field
Intenset_Error_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_ERROR_Field_1 use
(Intenset_Error_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for RXERROR event
type INTENSET_RXERROR_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_RXERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for RXERROR event
type INTENSET_RXERROR_Field_1 is
(-- Reset value for the field
Intenset_Rxerror_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_RXERROR_Field_1 use
(Intenset_Rxerror_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for ENDRX event
type INTENSET_ENDRX_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_ENDRX_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for ENDRX event
type INTENSET_ENDRX_Field_1 is
(-- Reset value for the field
Intenset_Endrx_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_ENDRX_Field_1 use
(Intenset_Endrx_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for ENDTX event
type INTENSET_ENDTX_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_ENDTX_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for ENDTX event
type INTENSET_ENDTX_Field_1 is
(-- Reset value for the field
Intenset_Endtx_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_ENDTX_Field_1 use
(Intenset_Endtx_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for AUTOCOLRESSTARTED event
type INTENSET_AUTOCOLRESSTARTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_AUTOCOLRESSTARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for AUTOCOLRESSTARTED event
type INTENSET_AUTOCOLRESSTARTED_Field_1 is
(-- Reset value for the field
Intenset_Autocolresstarted_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_AUTOCOLRESSTARTED_Field_1 use
(Intenset_Autocolresstarted_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for COLLISION event
type INTENSET_COLLISION_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_COLLISION_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for COLLISION event
type INTENSET_COLLISION_Field_1 is
(-- Reset value for the field
Intenset_Collision_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_COLLISION_Field_1 use
(Intenset_Collision_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for SELECTED event
type INTENSET_SELECTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_SELECTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for SELECTED event
type INTENSET_SELECTED_Field_1 is
(-- Reset value for the field
Intenset_Selected_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_SELECTED_Field_1 use
(Intenset_Selected_Field_Reset => 0,
Set => 1);
-- 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);
-- Enable interrupt
type INTENSET_Register is record
-- Write '1' to Enable interrupt for READY event
READY : INTENSET_READY_Field_1 :=
Intenset_Ready_Field_Reset;
-- Write '1' to Enable interrupt for FIELDDETECTED event
FIELDDETECTED : INTENSET_FIELDDETECTED_Field_1 :=
Intenset_Fielddetected_Field_Reset;
-- Write '1' to Enable interrupt for FIELDLOST event
FIELDLOST : INTENSET_FIELDLOST_Field_1 :=
Intenset_Fieldlost_Field_Reset;
-- Write '1' to Enable interrupt for TXFRAMESTART event
TXFRAMESTART : INTENSET_TXFRAMESTART_Field_1 :=
Intenset_Txframestart_Field_Reset;
-- Write '1' to Enable interrupt for TXFRAMEEND event
TXFRAMEEND : INTENSET_TXFRAMEEND_Field_1 :=
Intenset_Txframeend_Field_Reset;
-- Write '1' to Enable interrupt for RXFRAMESTART event
RXFRAMESTART : INTENSET_RXFRAMESTART_Field_1 :=
Intenset_Rxframestart_Field_Reset;
-- Write '1' to Enable interrupt for RXFRAMEEND event
RXFRAMEEND : INTENSET_RXFRAMEEND_Field_1 :=
Intenset_Rxframeend_Field_Reset;
-- Write '1' to Enable interrupt for ERROR event
ERROR : INTENSET_ERROR_Field_1 :=
Intenset_Error_Field_Reset;
-- unspecified
Reserved_8_9 : HAL.UInt2 := 16#0#;
-- Write '1' to Enable interrupt for RXERROR event
RXERROR : INTENSET_RXERROR_Field_1 :=
Intenset_Rxerror_Field_Reset;
-- Write '1' to Enable interrupt for ENDRX event
ENDRX : INTENSET_ENDRX_Field_1 :=
Intenset_Endrx_Field_Reset;
-- Write '1' to Enable interrupt for ENDTX event
ENDTX : INTENSET_ENDTX_Field_1 :=
Intenset_Endtx_Field_Reset;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- Write '1' to Enable interrupt for AUTOCOLRESSTARTED event
AUTOCOLRESSTARTED : INTENSET_AUTOCOLRESSTARTED_Field_1 :=
Intenset_Autocolresstarted_Field_Reset;
-- unspecified
Reserved_15_17 : HAL.UInt3 := 16#0#;
-- Write '1' to Enable interrupt for COLLISION event
COLLISION : INTENSET_COLLISION_Field_1 :=
Intenset_Collision_Field_Reset;
-- Write '1' to Enable interrupt for SELECTED event
SELECTED : INTENSET_SELECTED_Field_1 :=
Intenset_Selected_Field_Reset;
-- Write '1' to Enable interrupt for STARTED event
STARTED : INTENSET_STARTED_Field_1 :=
Intenset_Started_Field_Reset;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
READY at 0 range 0 .. 0;
FIELDDETECTED at 0 range 1 .. 1;
FIELDLOST at 0 range 2 .. 2;
TXFRAMESTART at 0 range 3 .. 3;
TXFRAMEEND at 0 range 4 .. 4;
RXFRAMESTART at 0 range 5 .. 5;
RXFRAMEEND at 0 range 6 .. 6;
ERROR at 0 range 7 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
RXERROR at 0 range 10 .. 10;
ENDRX at 0 range 11 .. 11;
ENDTX at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
AUTOCOLRESSTARTED at 0 range 14 .. 14;
Reserved_15_17 at 0 range 15 .. 17;
COLLISION at 0 range 18 .. 18;
SELECTED at 0 range 19 .. 19;
STARTED at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- Write '1' to Disable interrupt for READY event
type INTENCLR_READY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_READY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for READY event
type INTENCLR_READY_Field_1 is
(-- Reset value for the field
Intenclr_Ready_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_READY_Field_1 use
(Intenclr_Ready_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for FIELDDETECTED event
type INTENCLR_FIELDDETECTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_FIELDDETECTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for FIELDDETECTED event
type INTENCLR_FIELDDETECTED_Field_1 is
(-- Reset value for the field
Intenclr_Fielddetected_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_FIELDDETECTED_Field_1 use
(Intenclr_Fielddetected_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for FIELDLOST event
type INTENCLR_FIELDLOST_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_FIELDLOST_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for FIELDLOST event
type INTENCLR_FIELDLOST_Field_1 is
(-- Reset value for the field
Intenclr_Fieldlost_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_FIELDLOST_Field_1 use
(Intenclr_Fieldlost_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for TXFRAMESTART event
type INTENCLR_TXFRAMESTART_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_TXFRAMESTART_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for TXFRAMESTART event
type INTENCLR_TXFRAMESTART_Field_1 is
(-- Reset value for the field
Intenclr_Txframestart_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_TXFRAMESTART_Field_1 use
(Intenclr_Txframestart_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for TXFRAMEEND event
type INTENCLR_TXFRAMEEND_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_TXFRAMEEND_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for TXFRAMEEND event
type INTENCLR_TXFRAMEEND_Field_1 is
(-- Reset value for the field
Intenclr_Txframeend_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_TXFRAMEEND_Field_1 use
(Intenclr_Txframeend_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for RXFRAMESTART event
type INTENCLR_RXFRAMESTART_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_RXFRAMESTART_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for RXFRAMESTART event
type INTENCLR_RXFRAMESTART_Field_1 is
(-- Reset value for the field
Intenclr_Rxframestart_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_RXFRAMESTART_Field_1 use
(Intenclr_Rxframestart_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for RXFRAMEEND event
type INTENCLR_RXFRAMEEND_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_RXFRAMEEND_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for RXFRAMEEND event
type INTENCLR_RXFRAMEEND_Field_1 is
(-- Reset value for the field
Intenclr_Rxframeend_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_RXFRAMEEND_Field_1 use
(Intenclr_Rxframeend_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for ERROR event
type INTENCLR_ERROR_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for ERROR event
type INTENCLR_ERROR_Field_1 is
(-- Reset value for the field
Intenclr_Error_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_ERROR_Field_1 use
(Intenclr_Error_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for RXERROR event
type INTENCLR_RXERROR_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_RXERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for RXERROR event
type INTENCLR_RXERROR_Field_1 is
(-- Reset value for the field
Intenclr_Rxerror_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_RXERROR_Field_1 use
(Intenclr_Rxerror_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for ENDRX event
type INTENCLR_ENDRX_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_ENDRX_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for ENDRX event
type INTENCLR_ENDRX_Field_1 is
(-- Reset value for the field
Intenclr_Endrx_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_ENDRX_Field_1 use
(Intenclr_Endrx_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for ENDTX event
type INTENCLR_ENDTX_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_ENDTX_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for ENDTX event
type INTENCLR_ENDTX_Field_1 is
(-- Reset value for the field
Intenclr_Endtx_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_ENDTX_Field_1 use
(Intenclr_Endtx_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for AUTOCOLRESSTARTED event
type INTENCLR_AUTOCOLRESSTARTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_AUTOCOLRESSTARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for AUTOCOLRESSTARTED event
type INTENCLR_AUTOCOLRESSTARTED_Field_1 is
(-- Reset value for the field
Intenclr_Autocolresstarted_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_AUTOCOLRESSTARTED_Field_1 use
(Intenclr_Autocolresstarted_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for COLLISION event
type INTENCLR_COLLISION_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_COLLISION_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for COLLISION event
type INTENCLR_COLLISION_Field_1 is
(-- Reset value for the field
Intenclr_Collision_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_COLLISION_Field_1 use
(Intenclr_Collision_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for SELECTED event
type INTENCLR_SELECTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_SELECTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for SELECTED event
type INTENCLR_SELECTED_Field_1 is
(-- Reset value for the field
Intenclr_Selected_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_SELECTED_Field_1 use
(Intenclr_Selected_Field_Reset => 0,
Clear => 1);
-- 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);
-- Disable interrupt
type INTENCLR_Register is record
-- Write '1' to Disable interrupt for READY event
READY : INTENCLR_READY_Field_1 :=
Intenclr_Ready_Field_Reset;
-- Write '1' to Disable interrupt for FIELDDETECTED event
FIELDDETECTED : INTENCLR_FIELDDETECTED_Field_1 :=
Intenclr_Fielddetected_Field_Reset;
-- Write '1' to Disable interrupt for FIELDLOST event
FIELDLOST : INTENCLR_FIELDLOST_Field_1 :=
Intenclr_Fieldlost_Field_Reset;
-- Write '1' to Disable interrupt for TXFRAMESTART event
TXFRAMESTART : INTENCLR_TXFRAMESTART_Field_1 :=
Intenclr_Txframestart_Field_Reset;
-- Write '1' to Disable interrupt for TXFRAMEEND event
TXFRAMEEND : INTENCLR_TXFRAMEEND_Field_1 :=
Intenclr_Txframeend_Field_Reset;
-- Write '1' to Disable interrupt for RXFRAMESTART event
RXFRAMESTART : INTENCLR_RXFRAMESTART_Field_1 :=
Intenclr_Rxframestart_Field_Reset;
-- Write '1' to Disable interrupt for RXFRAMEEND event
RXFRAMEEND : INTENCLR_RXFRAMEEND_Field_1 :=
Intenclr_Rxframeend_Field_Reset;
-- Write '1' to Disable interrupt for ERROR event
ERROR : INTENCLR_ERROR_Field_1 :=
Intenclr_Error_Field_Reset;
-- unspecified
Reserved_8_9 : HAL.UInt2 := 16#0#;
-- Write '1' to Disable interrupt for RXERROR event
RXERROR : INTENCLR_RXERROR_Field_1 :=
Intenclr_Rxerror_Field_Reset;
-- Write '1' to Disable interrupt for ENDRX event
ENDRX : INTENCLR_ENDRX_Field_1 :=
Intenclr_Endrx_Field_Reset;
-- Write '1' to Disable interrupt for ENDTX event
ENDTX : INTENCLR_ENDTX_Field_1 :=
Intenclr_Endtx_Field_Reset;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- Write '1' to Disable interrupt for AUTOCOLRESSTARTED event
AUTOCOLRESSTARTED : INTENCLR_AUTOCOLRESSTARTED_Field_1 :=
Intenclr_Autocolresstarted_Field_Reset;
-- unspecified
Reserved_15_17 : HAL.UInt3 := 16#0#;
-- Write '1' to Disable interrupt for COLLISION event
COLLISION : INTENCLR_COLLISION_Field_1 :=
Intenclr_Collision_Field_Reset;
-- Write '1' to Disable interrupt for SELECTED event
SELECTED : INTENCLR_SELECTED_Field_1 :=
Intenclr_Selected_Field_Reset;
-- Write '1' to Disable interrupt for STARTED event
STARTED : INTENCLR_STARTED_Field_1 :=
Intenclr_Started_Field_Reset;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
READY at 0 range 0 .. 0;
FIELDDETECTED at 0 range 1 .. 1;
FIELDLOST at 0 range 2 .. 2;
TXFRAMESTART at 0 range 3 .. 3;
TXFRAMEEND at 0 range 4 .. 4;
RXFRAMESTART at 0 range 5 .. 5;
RXFRAMEEND at 0 range 6 .. 6;
ERROR at 0 range 7 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
RXERROR at 0 range 10 .. 10;
ENDRX at 0 range 11 .. 11;
ENDTX at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
AUTOCOLRESSTARTED at 0 range 14 .. 14;
Reserved_15_17 at 0 range 15 .. 17;
COLLISION at 0 range 18 .. 18;
SELECTED at 0 range 19 .. 19;
STARTED at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- NFC Error Status register
type ERRORSTATUS_Register is record
-- No STARTTX task triggered before expiration of the time set in
-- FRAMEDELAYMAX
FRAMEDELAYTIMEOUT : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Field level is too high at max load resistance
NFCFIELDTOOSTRONG : Boolean := False;
-- Field level is too low at min load resistance
NFCFIELDTOOWEAK : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ERRORSTATUS_Register use record
FRAMEDELAYTIMEOUT at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
NFCFIELDTOOSTRONG at 0 range 2 .. 2;
NFCFIELDTOOWEAK at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-------------------------------------
-- FRAMESTATUS cluster's Registers --
-------------------------------------
-- No valid End of Frame detected
type RX_CRCERROR_Field is
(-- Valid CRC detected
Crccorrect,
-- CRC received does not match local check
Crcerror)
with Size => 1;
for RX_CRCERROR_Field use
(Crccorrect => 0,
Crcerror => 1);
-- Parity status of received frame
type RX_PARITYSTATUS_Field is
(-- Frame received with parity OK
Parityok,
-- Frame received with parity error
Parityerror)
with Size => 1;
for RX_PARITYSTATUS_Field use
(Parityok => 0,
Parityerror => 1);
-- Overrun detected
type RX_OVERRUN_Field is
(-- No overrun detected
Nooverrun,
-- Overrun error
Overrun)
with Size => 1;
for RX_OVERRUN_Field use
(Nooverrun => 0,
Overrun => 1);
-- Result of last incoming frames
type RX_FRAMESTATUS_Register is record
-- No valid End of Frame detected
CRCERROR : RX_CRCERROR_Field := NRF_SVD.NFCT.Crccorrect;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Parity status of received frame
PARITYSTATUS : RX_PARITYSTATUS_Field := NRF_SVD.NFCT.Parityok;
-- Overrun detected
OVERRUN : RX_OVERRUN_Field := NRF_SVD.NFCT.Nooverrun;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RX_FRAMESTATUS_Register use record
CRCERROR at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
PARITYSTATUS at 0 range 2 .. 2;
OVERRUN at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Unspecified
type FRAMESTATUS_Cluster is record
-- Result of last incoming frames
RX : aliased RX_FRAMESTATUS_Register;
end record
with Size => 32;
for FRAMESTATUS_Cluster use record
RX at 0 range 0 .. 31;
end record;
subtype CURRENTLOADCTRL_CURRENTLOADCTRL_Field is HAL.UInt6;
-- Current value driven to the NFC Load Control
type CURRENTLOADCTRL_Register is record
-- Read-only. Current value driven to the NFC Load Control
CURRENTLOADCTRL : CURRENTLOADCTRL_CURRENTLOADCTRL_Field;
-- unspecified
Reserved_6_31 : HAL.UInt26;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CURRENTLOADCTRL_Register use record
CURRENTLOADCTRL at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- Indicates the presence or not of a valid field. Available only in the
-- activated state.
type FIELDPRESENT_FIELDPRESENT_Field is
(-- No valid field detected
Nofield,
-- Valid field detected
Fieldpresent)
with Size => 1;
for FIELDPRESENT_FIELDPRESENT_Field use
(Nofield => 0,
Fieldpresent => 1);
-- Indicates if the low level has locked to the field
type FIELDPRESENT_LOCKDETECT_Field is
(-- Not locked to field
Notlocked,
-- Locked to field
Locked)
with Size => 1;
for FIELDPRESENT_LOCKDETECT_Field use
(Notlocked => 0,
Locked => 1);
-- Indicates the presence or not of a valid field
type FIELDPRESENT_Register is record
-- Read-only. Indicates the presence or not of a valid field. Available
-- only in the activated state.
FIELDPRESENT : FIELDPRESENT_FIELDPRESENT_Field;
-- Read-only. Indicates if the low level has locked to the field
LOCKDETECT : FIELDPRESENT_LOCKDETECT_Field;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIELDPRESENT_Register use record
FIELDPRESENT at 0 range 0 .. 0;
LOCKDETECT at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype FRAMEDELAYMIN_FRAMEDELAYMIN_Field is HAL.UInt16;
-- Minimum frame delay
type FRAMEDELAYMIN_Register is record
-- Minimum frame delay in number of 13.56 MHz clocks
FRAMEDELAYMIN : FRAMEDELAYMIN_FRAMEDELAYMIN_Field := 16#480#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FRAMEDELAYMIN_Register use record
FRAMEDELAYMIN at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FRAMEDELAYMAX_FRAMEDELAYMAX_Field is HAL.UInt16;
-- Maximum frame delay
type FRAMEDELAYMAX_Register is record
-- Maximum frame delay in number of 13.56 MHz clocks
FRAMEDELAYMAX : FRAMEDELAYMAX_FRAMEDELAYMAX_Field := 16#1000#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FRAMEDELAYMAX_Register use record
FRAMEDELAYMAX at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Configuration register for the Frame Delay Timer
type FRAMEDELAYMODE_FRAMEDELAYMODE_Field is
(-- Transmission is independent of frame timer and will start when the STARTTX
-- task is triggered. No timeout.
Freerun,
-- Frame is transmitted between FRAMEDELAYMIN and FRAMEDELAYMAX
Window,
-- Frame is transmitted exactly at FRAMEDELAYMAX
Exactval,
-- Frame is transmitted on a bit grid between FRAMEDELAYMIN and FRAMEDELAYMAX
Windowgrid)
with Size => 2;
for FRAMEDELAYMODE_FRAMEDELAYMODE_Field use
(Freerun => 0,
Window => 1,
Exactval => 2,
Windowgrid => 3);
-- Configuration register for the Frame Delay Timer
type FRAMEDELAYMODE_Register is record
-- Configuration register for the Frame Delay Timer
FRAMEDELAYMODE : FRAMEDELAYMODE_FRAMEDELAYMODE_Field :=
NRF_SVD.NFCT.Window;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FRAMEDELAYMODE_Register use record
FRAMEDELAYMODE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype MAXLEN_MAXLEN_Field is HAL.UInt9;
-- Size of allocated for TXD and RXD data storage buffer in Data RAM
type MAXLEN_Register is record
-- Size of allocated for TXD and RXD data storage buffer in Data RAM
MAXLEN : MAXLEN_MAXLEN_Field := 16#0#;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MAXLEN_Register use record
MAXLEN at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------------------
-- TXD cluster's Registers --
-----------------------------
-- Adding parity or not in the frame
type FRAMECONFIG_PARITY_Field is
(-- Parity is not added in TX frames
Noparity,
-- Parity is added TX frames
Parity)
with Size => 1;
for FRAMECONFIG_PARITY_Field use
(Noparity => 0,
Parity => 1);
-- Discarding unused bits in start or at end of a Frame
type FRAMECONFIG_DISCARDMODE_Field is
(-- Unused bits is discarded at end of frame
Discardend,
-- Unused bits is discarded at start of frame
Discardstart)
with Size => 1;
for FRAMECONFIG_DISCARDMODE_Field use
(Discardend => 0,
Discardstart => 1);
-- Adding SoF or not in TX frames
type FRAMECONFIG_SOF_Field is
(-- Start of Frame symbol not added
Nosof,
-- Start of Frame symbol added
Sof)
with Size => 1;
for FRAMECONFIG_SOF_Field use
(Nosof => 0,
Sof => 1);
-- CRC mode for outgoing frames
type FRAMECONFIG_CRCMODETX_Field is
(-- CRC is not added to the frame
Nocrctx,
-- 16 bit CRC added to the frame based on all the data read from RAM that is
-- used in the frame
Crc16Tx)
with Size => 1;
for FRAMECONFIG_CRCMODETX_Field use
(Nocrctx => 0,
Crc16Tx => 1);
-- Configuration of outgoing frames
type FRAMECONFIG_TXD_Register is record
-- Adding parity or not in the frame
PARITY : FRAMECONFIG_PARITY_Field := NRF_SVD.NFCT.Parity;
-- Discarding unused bits in start or at end of a Frame
DISCARDMODE : FRAMECONFIG_DISCARDMODE_Field :=
NRF_SVD.NFCT.Discardstart;
-- Adding SoF or not in TX frames
SOF : FRAMECONFIG_SOF_Field := NRF_SVD.NFCT.Sof;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- CRC mode for outgoing frames
CRCMODETX : FRAMECONFIG_CRCMODETX_Field := NRF_SVD.NFCT.Crc16Tx;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FRAMECONFIG_TXD_Register use record
PARITY at 0 range 0 .. 0;
DISCARDMODE at 0 range 1 .. 1;
SOF at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
CRCMODETX at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype AMOUNT_TXD_TXDATABITS_Field is HAL.UInt3;
subtype AMOUNT_TXD_TXDATABYTES_Field is HAL.UInt9;
-- Size of outgoing frame
type AMOUNT_TXD_Register is record
-- Number of bits in the last or first byte read from RAM that shall be
-- included in the frame (excluding parity bit).
TXDATABITS : AMOUNT_TXD_TXDATABITS_Field := 16#0#;
-- Number of complete bytes that shall be included in the frame,
-- excluding CRC, parity and framing
TXDATABYTES : AMOUNT_TXD_TXDATABYTES_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AMOUNT_TXD_Register use record
TXDATABITS at 0 range 0 .. 2;
TXDATABYTES at 0 range 3 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- Unspecified
type TXD_Cluster is record
-- Configuration of outgoing frames
FRAMECONFIG : aliased FRAMECONFIG_TXD_Register;
-- Size of outgoing frame
AMOUNT : aliased AMOUNT_TXD_Register;
end record
with Size => 64;
for TXD_Cluster use record
FRAMECONFIG at 16#0# range 0 .. 31;
AMOUNT at 16#4# range 0 .. 31;
end record;
-----------------------------
-- RXD cluster's Registers --
-----------------------------
-- CRC mode for incoming frames
type FRAMECONFIG_CRCMODERX_Field is
(-- CRC is not expected in RX frames
Nocrcrx,
-- Last 16 bits in RX frame is CRC, CRC is checked and CRCSTATUS updated
Crc16Rx)
with Size => 1;
for FRAMECONFIG_CRCMODERX_Field use
(Nocrcrx => 0,
Crc16Rx => 1);
-- Configuration of incoming frames
type FRAMECONFIG_RXD_Register is record
-- Parity expected or not in RX frame
PARITY : FRAMECONFIG_PARITY_Field := NRF_SVD.NFCT.Parity;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- SoF expected or not in RX frames
SOF : FRAMECONFIG_SOF_Field := NRF_SVD.NFCT.Sof;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- CRC mode for incoming frames
CRCMODERX : FRAMECONFIG_CRCMODERX_Field := NRF_SVD.NFCT.Crc16Rx;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FRAMECONFIG_RXD_Register use record
PARITY at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
SOF at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
CRCMODERX at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype AMOUNT_RXD_RXDATABITS_Field is HAL.UInt3;
subtype AMOUNT_RXD_RXDATABYTES_Field is HAL.UInt9;
-- Size of last incoming frame
type AMOUNT_RXD_Register is record
-- Read-only. Number of bits in the last byte in the frame, if less than
-- 8 (including CRC, but excluding parity and SoF/EoF framing).
RXDATABITS : AMOUNT_RXD_RXDATABITS_Field;
-- Read-only. Number of complete bytes received in the frame (including
-- CRC, but excluding parity and SoF/EoF framing)
RXDATABYTES : AMOUNT_RXD_RXDATABYTES_Field;
-- unspecified
Reserved_12_31 : HAL.UInt20;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AMOUNT_RXD_Register use record
RXDATABITS at 0 range 0 .. 2;
RXDATABYTES at 0 range 3 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- Unspecified
type RXD_Cluster is record
-- Configuration of incoming frames
FRAMECONFIG : aliased FRAMECONFIG_RXD_Register;
-- Size of last incoming frame
AMOUNT : aliased AMOUNT_RXD_Register;
end record
with Size => 64;
for RXD_Cluster use record
FRAMECONFIG at 16#0# range 0 .. 31;
AMOUNT at 16#4# range 0 .. 31;
end record;
subtype NFCID1_LAST_NFCID1_Z_Field is HAL.UInt8;
subtype NFCID1_LAST_NFCID1_Y_Field is HAL.UInt8;
subtype NFCID1_LAST_NFCID1_X_Field is HAL.UInt8;
subtype NFCID1_LAST_NFCID1_W_Field is HAL.UInt8;
-- Last NFCID1 part (4, 7 or 10 bytes ID)
type NFCID1_LAST_Register is record
-- NFCID1 byte Z (very last byte sent)
NFCID1_Z : NFCID1_LAST_NFCID1_Z_Field := 16#63#;
-- NFCID1 byte Y
NFCID1_Y : NFCID1_LAST_NFCID1_Y_Field := 16#63#;
-- NFCID1 byte X
NFCID1_X : NFCID1_LAST_NFCID1_X_Field := 16#0#;
-- NFCID1 byte W
NFCID1_W : NFCID1_LAST_NFCID1_W_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NFCID1_LAST_Register use record
NFCID1_Z at 0 range 0 .. 7;
NFCID1_Y at 0 range 8 .. 15;
NFCID1_X at 0 range 16 .. 23;
NFCID1_W at 0 range 24 .. 31;
end record;
subtype NFCID1_2ND_LAST_NFCID1_V_Field is HAL.UInt8;
subtype NFCID1_2ND_LAST_NFCID1_U_Field is HAL.UInt8;
subtype NFCID1_2ND_LAST_NFCID1_T_Field is HAL.UInt8;
-- Second last NFCID1 part (7 or 10 bytes ID)
type NFCID1_2ND_LAST_Register is record
-- NFCID1 byte V
NFCID1_V : NFCID1_2ND_LAST_NFCID1_V_Field := 16#0#;
-- NFCID1 byte U
NFCID1_U : NFCID1_2ND_LAST_NFCID1_U_Field := 16#0#;
-- NFCID1 byte T
NFCID1_T : NFCID1_2ND_LAST_NFCID1_T_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NFCID1_2ND_LAST_Register use record
NFCID1_V at 0 range 0 .. 7;
NFCID1_U at 0 range 8 .. 15;
NFCID1_T at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype NFCID1_3RD_LAST_NFCID1_S_Field is HAL.UInt8;
subtype NFCID1_3RD_LAST_NFCID1_R_Field is HAL.UInt8;
subtype NFCID1_3RD_LAST_NFCID1_Q_Field is HAL.UInt8;
-- Third last NFCID1 part (10 bytes ID)
type NFCID1_3RD_LAST_Register is record
-- NFCID1 byte S
NFCID1_S : NFCID1_3RD_LAST_NFCID1_S_Field := 16#0#;
-- NFCID1 byte R
NFCID1_R : NFCID1_3RD_LAST_NFCID1_R_Field := 16#0#;
-- NFCID1 byte Q
NFCID1_Q : NFCID1_3RD_LAST_NFCID1_Q_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NFCID1_3RD_LAST_Register use record
NFCID1_S at 0 range 0 .. 7;
NFCID1_R at 0 range 8 .. 15;
NFCID1_Q at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- Bit frame SDD as defined by the b5:b1 of byte 1 in SENS_RES response in
-- the NFC Forum, NFC Digital Protocol Technical Specification
type SENSRES_BITFRAMESDD_Field is
(-- SDD pattern 00000
Sdd00000,
-- SDD pattern 00001
Sdd00001,
-- SDD pattern 00010
Sdd00010,
-- SDD pattern 00100
Sdd00100,
-- SDD pattern 01000
Sdd01000,
-- SDD pattern 10000
Sdd10000)
with Size => 5;
for SENSRES_BITFRAMESDD_Field use
(Sdd00000 => 0,
Sdd00001 => 1,
Sdd00010 => 2,
Sdd00100 => 4,
Sdd01000 => 8,
Sdd10000 => 16);
-- NFCID1 size. This value is used by the Auto collision resolution engine.
type SENSRES_NFCIDSIZE_Field is
(-- NFCID1 size: single (4 bytes)
Nfcid1Single,
-- NFCID1 size: double (7 bytes)
Nfcid1Double,
-- NFCID1 size: triple (10 bytes)
Nfcid1Triple)
with Size => 2;
for SENSRES_NFCIDSIZE_Field use
(Nfcid1Single => 0,
Nfcid1Double => 1,
Nfcid1Triple => 2);
subtype SENSRES_PLATFCONFIG_Field is HAL.UInt4;
subtype SENSRES_RFU74_Field is HAL.UInt4;
-- NFC-A SENS_RES auto-response settings
type SENSRES_Register is record
-- Bit frame SDD as defined by the b5:b1 of byte 1 in SENS_RES response
-- in the NFC Forum, NFC Digital Protocol Technical Specification
BITFRAMESDD : SENSRES_BITFRAMESDD_Field := NRF_SVD.NFCT.Sdd00001;
-- Reserved for future use. Shall be 0.
RFU5 : Boolean := False;
-- NFCID1 size. This value is used by the Auto collision resolution
-- engine.
NFCIDSIZE : SENSRES_NFCIDSIZE_Field := NRF_SVD.NFCT.Nfcid1Single;
-- Tag platform configuration as defined by the b4:b1 of byte 2 in
-- SENS_RES response in the NFC Forum, NFC Digital Protocol Technical
-- Specification
PLATFCONFIG : SENSRES_PLATFCONFIG_Field := 16#0#;
-- Reserved for future use. Shall be 0.
RFU74 : SENSRES_RFU74_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SENSRES_Register use record
BITFRAMESDD at 0 range 0 .. 4;
RFU5 at 0 range 5 .. 5;
NFCIDSIZE at 0 range 6 .. 7;
PLATFCONFIG at 0 range 8 .. 11;
RFU74 at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype SELRES_RFU10_Field is HAL.UInt2;
-- Cascade bit (controlled by hardware, write has no effect)
type SELRES_CASCADE_Field is
(-- NFCID1 complete
Complete,
-- NFCID1 not complete
Notcomplete)
with Size => 1;
for SELRES_CASCADE_Field use
(Complete => 0,
Notcomplete => 1);
subtype SELRES_RFU43_Field is HAL.UInt2;
subtype SELRES_PROTOCOL_Field is HAL.UInt2;
-- NFC-A SEL_RES auto-response settings
type SELRES_Register is record
-- Reserved for future use. Shall be 0.
RFU10 : SELRES_RFU10_Field := 16#0#;
-- Cascade bit (controlled by hardware, write has no effect)
CASCADE : SELRES_CASCADE_Field := NRF_SVD.NFCT.Complete;
-- Reserved for future use. Shall be 0.
RFU43 : SELRES_RFU43_Field := 16#0#;
-- Protocol as defined by the b7:b6 of SEL_RES response in the NFC
-- Forum, NFC Digital Protocol Technical Specification
PROTOCOL : SELRES_PROTOCOL_Field := 16#0#;
-- Reserved for future use. Shall be 0.
RFU7 : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SELRES_Register use record
RFU10 at 0 range 0 .. 1;
CASCADE at 0 range 2 .. 2;
RFU43 at 0 range 3 .. 4;
PROTOCOL at 0 range 5 .. 6;
RFU7 at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- NFC-A compatible radio
type NFCT_Peripheral is record
-- Activate NFC peripheral for incoming and outgoing frames, change
-- state to activated
TASKS_ACTIVATE : aliased HAL.UInt32;
-- Disable NFC peripheral
TASKS_DISABLE : aliased HAL.UInt32;
-- Enable NFC sense field mode, change state to sense mode
TASKS_SENSE : aliased HAL.UInt32;
-- Start transmission of a outgoing frame, change state to transmit
TASKS_STARTTX : aliased HAL.UInt32;
-- Initializes the EasyDMA for receive.
TASKS_ENABLERXDATA : aliased HAL.UInt32;
-- Force state machine to IDLE state
TASKS_GOIDLE : aliased HAL.UInt32;
-- Force state machine to SLEEP_A state
TASKS_GOSLEEP : aliased HAL.UInt32;
-- The NFC peripheral is ready to receive and send frames
EVENTS_READY : aliased HAL.UInt32;
-- Remote NFC field detected
EVENTS_FIELDDETECTED : aliased HAL.UInt32;
-- Remote NFC field lost
EVENTS_FIELDLOST : aliased HAL.UInt32;
-- Marks the start of the first symbol of a transmitted frame
EVENTS_TXFRAMESTART : aliased HAL.UInt32;
-- Marks the end of the last transmitted on-air symbol of a frame
EVENTS_TXFRAMEEND : aliased HAL.UInt32;
-- Marks the end of the first symbol of a received frame
EVENTS_RXFRAMESTART : aliased HAL.UInt32;
-- Received data have been checked (CRC, parity) and transferred to RAM,
-- and EasyDMA has ended accessing the RX buffer
EVENTS_RXFRAMEEND : aliased HAL.UInt32;
-- NFC error reported. The ERRORSTATUS register contains details on the
-- source of the error.
EVENTS_ERROR : aliased HAL.UInt32;
-- NFC RX frame error reported. The FRAMESTATUS.RX register contains
-- details on the source of the error.
EVENTS_RXERROR : aliased HAL.UInt32;
-- RX buffer (as defined by PACKETPTR and MAXLEN) in Data RAM full.
EVENTS_ENDRX : aliased HAL.UInt32;
-- Transmission of data in RAM has ended, and EasyDMA has ended
-- accessing the TX buffer
EVENTS_ENDTX : aliased HAL.UInt32;
-- Auto collision resolution process has started
EVENTS_AUTOCOLRESSTARTED : aliased HAL.UInt32;
-- NFC Auto collision resolution error reported.
EVENTS_COLLISION : aliased HAL.UInt32;
-- NFC Auto collision resolution successfully completed
EVENTS_SELECTED : aliased HAL.UInt32;
-- EasyDMA is ready to receive or send frames.
EVENTS_STARTED : aliased HAL.UInt32;
-- Shortcut register
SHORTS : aliased SHORTS_Register;
-- Enable or disable interrupt
INTEN : aliased INTEN_Register;
-- Enable interrupt
INTENSET : aliased INTENSET_Register;
-- Disable interrupt
INTENCLR : aliased INTENCLR_Register;
-- NFC Error Status register
ERRORSTATUS : aliased ERRORSTATUS_Register;
-- Unspecified
FRAMESTATUS : aliased FRAMESTATUS_Cluster;
-- Current value driven to the NFC Load Control
CURRENTLOADCTRL : aliased CURRENTLOADCTRL_Register;
-- Indicates the presence or not of a valid field
FIELDPRESENT : aliased FIELDPRESENT_Register;
-- Minimum frame delay
FRAMEDELAYMIN : aliased FRAMEDELAYMIN_Register;
-- Maximum frame delay
FRAMEDELAYMAX : aliased FRAMEDELAYMAX_Register;
-- Configuration register for the Frame Delay Timer
FRAMEDELAYMODE : aliased FRAMEDELAYMODE_Register;
-- Packet pointer for TXD and RXD data storage in Data RAM
PACKETPTR : aliased HAL.UInt32;
-- Size of allocated for TXD and RXD data storage buffer in Data RAM
MAXLEN : aliased MAXLEN_Register;
-- Unspecified
TXD : aliased TXD_Cluster;
-- Unspecified
RXD : aliased RXD_Cluster;
-- Last NFCID1 part (4, 7 or 10 bytes ID)
NFCID1_LAST : aliased NFCID1_LAST_Register;
-- Second last NFCID1 part (7 or 10 bytes ID)
NFCID1_2ND_LAST : aliased NFCID1_2ND_LAST_Register;
-- Third last NFCID1 part (10 bytes ID)
NFCID1_3RD_LAST : aliased NFCID1_3RD_LAST_Register;
-- NFC-A SENS_RES auto-response settings
SENSRES : aliased SENSRES_Register;
-- NFC-A SEL_RES auto-response settings
SELRES : aliased SELRES_Register;
end record
with Volatile;
for NFCT_Peripheral use record
TASKS_ACTIVATE at 16#0# range 0 .. 31;
TASKS_DISABLE at 16#4# range 0 .. 31;
TASKS_SENSE at 16#8# range 0 .. 31;
TASKS_STARTTX at 16#C# range 0 .. 31;
TASKS_ENABLERXDATA at 16#1C# range 0 .. 31;
TASKS_GOIDLE at 16#24# range 0 .. 31;
TASKS_GOSLEEP at 16#28# range 0 .. 31;
EVENTS_READY at 16#100# range 0 .. 31;
EVENTS_FIELDDETECTED at 16#104# range 0 .. 31;
EVENTS_FIELDLOST at 16#108# range 0 .. 31;
EVENTS_TXFRAMESTART at 16#10C# range 0 .. 31;
EVENTS_TXFRAMEEND at 16#110# range 0 .. 31;
EVENTS_RXFRAMESTART at 16#114# range 0 .. 31;
EVENTS_RXFRAMEEND at 16#118# range 0 .. 31;
EVENTS_ERROR at 16#11C# range 0 .. 31;
EVENTS_RXERROR at 16#128# range 0 .. 31;
EVENTS_ENDRX at 16#12C# range 0 .. 31;
EVENTS_ENDTX at 16#130# range 0 .. 31;
EVENTS_AUTOCOLRESSTARTED at 16#138# range 0 .. 31;
EVENTS_COLLISION at 16#148# range 0 .. 31;
EVENTS_SELECTED at 16#14C# range 0 .. 31;
EVENTS_STARTED at 16#150# range 0 .. 31;
SHORTS at 16#200# range 0 .. 31;
INTEN at 16#300# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
ERRORSTATUS at 16#404# range 0 .. 31;
FRAMESTATUS at 16#40C# range 0 .. 31;
CURRENTLOADCTRL at 16#430# range 0 .. 31;
FIELDPRESENT at 16#43C# range 0 .. 31;
FRAMEDELAYMIN at 16#504# range 0 .. 31;
FRAMEDELAYMAX at 16#508# range 0 .. 31;
FRAMEDELAYMODE at 16#50C# range 0 .. 31;
PACKETPTR at 16#510# range 0 .. 31;
MAXLEN at 16#514# range 0 .. 31;
TXD at 16#518# range 0 .. 63;
RXD at 16#520# range 0 .. 63;
NFCID1_LAST at 16#590# range 0 .. 31;
NFCID1_2ND_LAST at 16#594# range 0 .. 31;
NFCID1_3RD_LAST at 16#598# range 0 .. 31;
SENSRES at 16#5A0# range 0 .. 31;
SELRES at 16#5A4# range 0 .. 31;
end record;
-- NFC-A compatible radio
NFCT_Periph : aliased NFCT_Peripheral
with Import, Address => NFCT_Base;
end NRF_SVD.NFCT;
|
-- { dg-do compile }
with Volatile5_Pkg; use Volatile5_Pkg;
procedure Volatile5 is
A : Rec;
procedure Proc is
begin
A := F;
end;
begin
Proc;
end;
|
-- { dg-do run }
with Discr42_Pkg; use Discr42_Pkg;
procedure Discr42 is
R : Rec;
Pos : Natural := 1;
begin
R := F (Pos);
if Pos /= 2 then
raise Program_Error;
end if;
if R /= (D => True, N => 4) then
raise Program_Error;
end if;
end;
|
--
-- Copyright (C) 2021, AdaCore
--
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32H743x.svd
with System;
package Interfaces.STM32.PWR is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
subtype CR1_LPDS_Field is Interfaces.STM32.Bit;
subtype CR1_PVDE_Field is Interfaces.STM32.Bit;
subtype CR1_PLS_Field is Interfaces.STM32.UInt3;
subtype CR1_DBP_Field is Interfaces.STM32.Bit;
subtype CR1_FLPS_Field is Interfaces.STM32.Bit;
subtype CR1_SVOS_Field is Interfaces.STM32.UInt2;
subtype CR1_AVDEN_Field is Interfaces.STM32.Bit;
subtype CR1_ALS_Field is Interfaces.STM32.UInt2;
-- PWR control register 1
type CR1_Register is record
-- Low-power Deepsleep with SVOS3 (SVOS4 and SVOS5 always use low-power,
-- regardless of the setting of this bit)
LPDS : CR1_LPDS_Field := 16#0#;
-- unspecified
Reserved_1_3 : Interfaces.STM32.UInt3 := 16#0#;
-- Programmable voltage detector enable
PVDE : CR1_PVDE_Field := 16#0#;
-- Programmable voltage detector level selection These bits select the
-- voltage threshold detected by the PVD. Note: Refer to Section
-- Electrical characteristics of the product datasheet for more details.
PLS : CR1_PLS_Field := 16#0#;
-- Disable backup domain write protection In reset state, the RCC_BDCR
-- register, the RTC registers (including the backup registers), BREN
-- and MOEN bits in PWR_CR2 register, are protected against parasitic
-- write access. This bit must be set to enable write access to these
-- registers.
DBP : CR1_DBP_Field := 16#0#;
-- Flash low-power mode in DStop mode This bit allows to obtain the best
-- trade-off between low-power consumption and restart time when exiting
-- from DStop mode. When it is set, the Flash memory enters low-power
-- mode when D1 domain is in DStop mode.
FLPS : CR1_FLPS_Field := 16#0#;
-- unspecified
Reserved_10_13 : Interfaces.STM32.UInt4 := 16#0#;
-- System Stop mode voltage scaling selection These bits control the
-- VCORE voltage level in system Stop mode, to obtain the best trade-off
-- between power consumption and performance.
SVOS : CR1_SVOS_Field := 16#3#;
-- Peripheral voltage monitor on VDDA enable
AVDEN : CR1_AVDEN_Field := 16#0#;
-- Analog voltage detector level selection These bits select the voltage
-- threshold detected by the AVD.
ALS : CR1_ALS_Field := 16#0#;
-- unspecified
Reserved_19_31 : Interfaces.STM32.UInt13 := 16#1E00#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
LPDS at 0 range 0 .. 0;
Reserved_1_3 at 0 range 1 .. 3;
PVDE at 0 range 4 .. 4;
PLS at 0 range 5 .. 7;
DBP at 0 range 8 .. 8;
FLPS at 0 range 9 .. 9;
Reserved_10_13 at 0 range 10 .. 13;
SVOS at 0 range 14 .. 15;
AVDEN at 0 range 16 .. 16;
ALS at 0 range 17 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype CSR1_PVDO_Field is Interfaces.STM32.Bit;
subtype CSR1_ACTVOSRDY_Field is Interfaces.STM32.Bit;
subtype CSR1_ACTVOS_Field is Interfaces.STM32.UInt2;
subtype CSR1_AVDO_Field is Interfaces.STM32.Bit;
-- PWR control status register 1
type CSR1_Register is record
-- unspecified
Reserved_0_3 : Interfaces.STM32.UInt4;
-- Read-only. Programmable voltage detect output This bit is set and
-- cleared by hardware. It is valid only if the PVD has been enabled by
-- the PVDE bit. Note: since the PVD is disabled in Standby mode, this
-- bit is equal to 0 after Standby or reset until the PVDE bit is set.
PVDO : CSR1_PVDO_Field;
-- unspecified
Reserved_5_12 : Interfaces.STM32.Byte;
-- Read-only. Voltage levels ready bit for currently used VOS and
-- SDLEVEL This bit is set to 1 by hardware when the voltage regulator
-- and the SD converter are both disabled and Bypass mode is selected in
-- PWR control register 3 (PWR_CR3).
ACTVOSRDY : CSR1_ACTVOSRDY_Field;
-- Read-only. VOS currently applied for VCORE voltage scaling selection.
-- These bits reflect the last VOS value applied to the PMU.
ACTVOS : CSR1_ACTVOS_Field;
-- Read-only. Analog voltage detector output on VDDA This bit is set and
-- cleared by hardware. It is valid only if AVD on VDDA is enabled by
-- the AVDEN bit. Note: Since the AVD is disabled in Standby mode, this
-- bit is equal to 0 after Standby or reset until the AVDEN bit is set.
AVDO : CSR1_AVDO_Field;
-- unspecified
Reserved_17_31 : Interfaces.STM32.UInt15;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CSR1_Register use record
Reserved_0_3 at 0 range 0 .. 3;
PVDO at 0 range 4 .. 4;
Reserved_5_12 at 0 range 5 .. 12;
ACTVOSRDY at 0 range 13 .. 13;
ACTVOS at 0 range 14 .. 15;
AVDO at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype CR2_BREN_Field is Interfaces.STM32.Bit;
subtype CR2_MONEN_Field is Interfaces.STM32.Bit;
subtype CR2_BRRDY_Field is Interfaces.STM32.Bit;
subtype CR2_VBATL_Field is Interfaces.STM32.Bit;
subtype CR2_VBATH_Field is Interfaces.STM32.Bit;
subtype CR2_TEMPL_Field is Interfaces.STM32.Bit;
subtype CR2_TEMPH_Field is Interfaces.STM32.Bit;
-- This register is not reset by wakeup from Standby mode, RESET signal and
-- VDD POR. It is only reset by VSW POR and VSWRST reset. This register
-- shall not be accessed when VSWRST bit in RCC_BDCR register resets the
-- VSW domain.After reset, PWR_CR2 register is write-protected. Prior to
-- modifying its content, the DBP bit in PWR_CR1 register must be set to
-- disable the write protection.
type CR2_Register is record
-- Backup regulator enable When set, the Backup regulator (used to
-- maintain the backup RAM content in Standby and VBAT modes) is
-- enabled. If BREN is reset, the backup regulator is switched off. The
-- backup RAM can still be used in Run and Stop modes. However, its
-- content will be lost in Standby and VBAT modes. If BREN is set, the
-- application must wait till the Backup Regulator Ready flag (BRRDY) is
-- set to indicate that the data written into the SRAM will be
-- maintained in Standby and VBAT modes.
BREN : CR2_BREN_Field := 16#0#;
-- unspecified
Reserved_1_3 : Interfaces.STM32.UInt3 := 16#0#;
-- VBAT and temperature monitoring enable When set, the VBAT supply and
-- temperature monitoring is enabled.
MONEN : CR2_MONEN_Field := 16#0#;
-- unspecified
Reserved_5_15 : Interfaces.STM32.UInt11 := 16#0#;
-- Read-only. Backup regulator ready This bit is set by hardware to
-- indicate that the Backup regulator is ready.
BRRDY : CR2_BRRDY_Field := 16#0#;
-- unspecified
Reserved_17_19 : Interfaces.STM32.UInt3 := 16#0#;
-- Read-only. VBAT level monitoring versus low threshold
VBATL : CR2_VBATL_Field := 16#0#;
-- Read-only. VBAT level monitoring versus high threshold
VBATH : CR2_VBATH_Field := 16#0#;
-- Read-only. Temperature level monitoring versus low threshold
TEMPL : CR2_TEMPL_Field := 16#0#;
-- Read-only. Temperature level monitoring versus high threshold
TEMPH : CR2_TEMPH_Field := 16#0#;
-- unspecified
Reserved_24_31 : Interfaces.STM32.Byte := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
BREN at 0 range 0 .. 0;
Reserved_1_3 at 0 range 1 .. 3;
MONEN at 0 range 4 .. 4;
Reserved_5_15 at 0 range 5 .. 15;
BRRDY at 0 range 16 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
VBATL at 0 range 20 .. 20;
VBATH at 0 range 21 .. 21;
TEMPL at 0 range 22 .. 22;
TEMPH at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype CR3_BYPASS_Field is Interfaces.STM32.Bit;
subtype CR3_LDOEN_Field is Interfaces.STM32.Bit;
subtype CR3_SCUEN_Field is Interfaces.STM32.Bit;
subtype CR3_VBE_Field is Interfaces.STM32.Bit;
subtype CR3_VBRS_Field is Interfaces.STM32.Bit;
subtype CR3_USB33DEN_Field is Interfaces.STM32.Bit;
subtype CR3_USBREGEN_Field is Interfaces.STM32.Bit;
subtype CR3_USB33RDY_Field is Interfaces.STM32.Bit;
-- Reset only by POR only, not reset by wakeup from Standby mode and RESET
-- pad. The lower byte of this register is written once after POR and shall
-- be written before changing VOS level or ck_sys clock frequency. No
-- limitation applies to the upper bytes.Programming data corresponding to
-- an invalid combination of SDLEVEL, SDEXTHP, SDEN, LDOEN and BYPASS bits
-- (see Table9) will be ignored: data will not be written, the written-once
-- mechanism will lock the register and any further write access will be
-- ignored. The default supply configuration will be kept and the ACTVOSRDY
-- bit in PWR control status register 1 (PWR_CSR1) will go on indicating
-- invalid voltage levels. The system shall be power cycled before writing
-- a new value.
type CR3_Register is record
-- Power management unit bypass
BYPASS : CR3_BYPASS_Field := 16#0#;
-- Low drop-out regulator enable
LDOEN : CR3_LDOEN_Field := 16#1#;
-- SD converter Enable
SCUEN : CR3_SCUEN_Field := 16#1#;
-- unspecified
Reserved_3_7 : Interfaces.STM32.UInt5 := 16#0#;
-- VBAT charging enable
VBE : CR3_VBE_Field := 16#0#;
-- VBAT charging resistor selection
VBRS : CR3_VBRS_Field := 16#0#;
-- unspecified
Reserved_10_23 : Interfaces.STM32.UInt14 := 16#0#;
-- VDD33USB voltage level detector enable.
USB33DEN : CR3_USB33DEN_Field := 16#0#;
-- USB regulator enable.
USBREGEN : CR3_USBREGEN_Field := 16#0#;
-- Read-only. USB supply ready.
USB33RDY : CR3_USB33RDY_Field := 16#0#;
-- unspecified
Reserved_27_31 : Interfaces.STM32.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR3_Register use record
BYPASS at 0 range 0 .. 0;
LDOEN at 0 range 1 .. 1;
SCUEN at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
VBE at 0 range 8 .. 8;
VBRS at 0 range 9 .. 9;
Reserved_10_23 at 0 range 10 .. 23;
USB33DEN at 0 range 24 .. 24;
USBREGEN at 0 range 25 .. 25;
USB33RDY at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-- CPUCR_PDDS_D array element
subtype CPUCR_PDDS_D_Element is Interfaces.STM32.Bit;
-- CPUCR_PDDS_D array
type CPUCR_PDDS_D_Field_Array is array (1 .. 3) of CPUCR_PDDS_D_Element
with Component_Size => 1, Size => 3;
-- Type definition for CPUCR_PDDS_D
type CPUCR_PDDS_D_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PDDS_D as a value
Val : Interfaces.STM32.UInt3;
when True =>
-- PDDS_D as an array
Arr : CPUCR_PDDS_D_Field_Array;
end case;
end record
with Unchecked_Union, Size => 3;
for CPUCR_PDDS_D_Field use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
subtype CPUCR_STOPF_Field is Interfaces.STM32.Bit;
subtype CPUCR_SBF_Field is Interfaces.STM32.Bit;
-- CPUCR_SBF_D array element
subtype CPUCR_SBF_D_Element is Interfaces.STM32.Bit;
-- CPUCR_SBF_D array
type CPUCR_SBF_D_Field_Array is array (1 .. 2) of CPUCR_SBF_D_Element
with Component_Size => 1, Size => 2;
-- Type definition for CPUCR_SBF_D
type CPUCR_SBF_D_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SBF_D as a value
Val : Interfaces.STM32.UInt2;
when True =>
-- SBF_D as an array
Arr : CPUCR_SBF_D_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for CPUCR_SBF_D_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
subtype CPUCR_CSSF_Field is Interfaces.STM32.Bit;
subtype CPUCR_RUN_D3_Field is Interfaces.STM32.Bit;
-- This register allows controlling CPU1 power.
type CPUCR_Register is record
-- D1 domain Power Down Deepsleep selection. This bit allows CPU1 to
-- define the Deepsleep mode for D1 domain.
PDDS_D : CPUCR_PDDS_D_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_3_4 : Interfaces.STM32.UInt2 := 16#0#;
-- Read-only. STOP flag This bit is set by hardware and cleared only by
-- any reset or by setting the CPU1 CSSF bit.
STOPF : CPUCR_STOPF_Field := 16#0#;
-- Read-only. System Standby flag This bit is set by hardware and
-- cleared only by a POR (Power-on Reset) or by setting the CPU1 CSSF
-- bit
SBF : CPUCR_SBF_Field := 16#0#;
-- Read-only. D1 domain DStandby flag This bit is set by hardware and
-- cleared by any system reset or by setting the CPU1 CSSF bit. Once
-- set, this bit can be cleared only when the D1 domain is no longer in
-- DStandby mode.
SBF_D : CPUCR_SBF_D_Field := (As_Array => False, Val => 16#0#);
-- Clear D1 domain CPU1 Standby, Stop and HOLD flags (always read as 0)
-- This bit is cleared to 0 by hardware.
CSSF : CPUCR_CSSF_Field := 16#0#;
-- unspecified
Reserved_10_10 : Interfaces.STM32.Bit := 16#0#;
-- Keep system D3 domain in Run mode regardless of the CPU sub-systems
-- modes
RUN_D3 : CPUCR_RUN_D3_Field := 16#0#;
-- unspecified
Reserved_12_31 : Interfaces.STM32.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CPUCR_Register use record
PDDS_D at 0 range 0 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
STOPF at 0 range 5 .. 5;
SBF at 0 range 6 .. 6;
SBF_D at 0 range 7 .. 8;
CSSF at 0 range 9 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
RUN_D3 at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype D3CR_VOSRDY_Field is Interfaces.STM32.Bit;
subtype D3CR_VOS_Field is Interfaces.STM32.UInt2;
-- This register allows controlling D3 domain power.Following reset VOSRDY
-- will be read 1 by software
type D3CR_Register is record
-- unspecified
Reserved_0_12 : Interfaces.STM32.UInt13 := 16#0#;
-- Read-only. VOS Ready bit for VCORE voltage scaling output selection.
-- This bit is set to 1 by hardware when Bypass mode is selected in PWR
-- control register 3 (PWR_CR3).
VOSRDY : D3CR_VOSRDY_Field := 16#0#;
-- Voltage scaling selection according to performance These bits control
-- the VCORE voltage level and allow to obtains the best trade-off
-- between power consumption and performance: When increasing the
-- performance, the voltage scaling shall be changed before increasing
-- the system frequency. When decreasing performance, the system
-- frequency shall first be decreased before changing the voltage
-- scaling.
VOS : D3CR_VOS_Field := 16#1#;
-- unspecified
Reserved_16_31 : Interfaces.STM32.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for D3CR_Register use record
Reserved_0_12 at 0 range 0 .. 12;
VOSRDY at 0 range 13 .. 13;
VOS at 0 range 14 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- WKUPCR_WKUPC array element
subtype WKUPCR_WKUPC_Element is Interfaces.STM32.Bit;
-- WKUPCR_WKUPC array
type WKUPCR_WKUPC_Field_Array is array (1 .. 6) of WKUPCR_WKUPC_Element
with Component_Size => 1, Size => 6;
-- Type definition for WKUPCR_WKUPC
type WKUPCR_WKUPC_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPC as a value
Val : Interfaces.STM32.UInt6;
when True =>
-- WKUPC as an array
Arr : WKUPCR_WKUPC_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for WKUPCR_WKUPC_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- reset only by system reset, not reset by wakeup from Standby mode5 wait
-- states are required when writing this register (when clearing a WKUPF
-- bit in PWR_WKUPFR, the AHB write access will complete after the WKUPF
-- has been cleared).
type WKUPCR_Register is record
-- Clear Wakeup pin flag for WKUP. These bits are always read as 0.
WKUPC : WKUPCR_WKUPC_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_31 : Interfaces.STM32.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for WKUPCR_Register use record
WKUPC at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- WKUPFR_WKUPF array element
subtype WKUPFR_WKUPF_Element is Interfaces.STM32.Bit;
-- WKUPFR_WKUPF array
type WKUPFR_WKUPF_Field_Array is array (1 .. 6) of WKUPFR_WKUPF_Element
with Component_Size => 1, Size => 6;
-- Type definition for WKUPFR_WKUPF
type WKUPFR_WKUPF_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPF as a value
Val : Interfaces.STM32.UInt6;
when True =>
-- WKUPF as an array
Arr : WKUPFR_WKUPF_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for WKUPFR_WKUPF_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- reset only by system reset, not reset by wakeup from Standby mode
type WKUPFR_Register is record
-- Wakeup pin WKUPF flag. This bit is set by hardware and cleared only
-- by a Reset pin or by setting the WKUPCn+1 bit in the PWR wakeup clear
-- register (PWR_WKUPCR).
WKUPF : WKUPFR_WKUPF_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_31 : Interfaces.STM32.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for WKUPFR_Register use record
WKUPF at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- WKUPEPR_WKUPEN array element
subtype WKUPEPR_WKUPEN_Element is Interfaces.STM32.Bit;
-- WKUPEPR_WKUPEN array
type WKUPEPR_WKUPEN_Field_Array is array (1 .. 6)
of WKUPEPR_WKUPEN_Element
with Component_Size => 1, Size => 6;
-- Type definition for WKUPEPR_WKUPEN
type WKUPEPR_WKUPEN_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPEN as a value
Val : Interfaces.STM32.UInt6;
when True =>
-- WKUPEN as an array
Arr : WKUPEPR_WKUPEN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for WKUPEPR_WKUPEN_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- WKUPEPR_WKUPP array element
subtype WKUPEPR_WKUPP_Element is Interfaces.STM32.Bit;
-- WKUPEPR_WKUPP array
type WKUPEPR_WKUPP_Field_Array is array (1 .. 6) of WKUPEPR_WKUPP_Element
with Component_Size => 1, Size => 6;
-- Type definition for WKUPEPR_WKUPP
type WKUPEPR_WKUPP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPP as a value
Val : Interfaces.STM32.UInt6;
when True =>
-- WKUPP as an array
Arr : WKUPEPR_WKUPP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for WKUPEPR_WKUPP_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- WKUPEPR_WKUPPUPD array element
subtype WKUPEPR_WKUPPUPD_Element is Interfaces.STM32.UInt2;
-- WKUPEPR_WKUPPUPD array
type WKUPEPR_WKUPPUPD_Field_Array is array (1 .. 6)
of WKUPEPR_WKUPPUPD_Element
with Component_Size => 2, Size => 12;
-- Type definition for WKUPEPR_WKUPPUPD
type WKUPEPR_WKUPPUPD_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPPUPD as a value
Val : Interfaces.STM32.UInt12;
when True =>
-- WKUPPUPD as an array
Arr : WKUPEPR_WKUPPUPD_Field_Array;
end case;
end record
with Unchecked_Union, Size => 12;
for WKUPEPR_WKUPPUPD_Field use record
Val at 0 range 0 .. 11;
Arr at 0 range 0 .. 11;
end record;
-- Reset only by system reset, not reset by wakeup from Standby mode
type WKUPEPR_Register is record
-- Enable Wakeup Pin WKUPn+1 Each bit is set and cleared by software.
-- Note: An additional wakeup event is detected if WKUPn+1 pin is
-- enabled (by setting the WKUPENn+1 bit) when WKUPn+1 pin level is
-- already high when WKUPPn+1 selects rising edge, or low when WKUPPn+1
-- selects falling edge.
WKUPEN : WKUPEPR_WKUPEN_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_7 : Interfaces.STM32.UInt2 := 16#0#;
-- Wakeup pin polarity bit for WKUPn-7 These bits define the polarity
-- used for event detection on WKUPn-7 external wakeup pin.
WKUPP : WKUPEPR_WKUPP_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_15 : Interfaces.STM32.UInt2 := 16#0#;
-- Wakeup pin pull configuration
WKUPPUPD : WKUPEPR_WKUPPUPD_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_28_31 : Interfaces.STM32.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for WKUPEPR_Register use record
WKUPEN at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
WKUPP at 0 range 8 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
WKUPPUPD at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- PWR
type PWR_Peripheral is record
-- PWR control register 1
CR1 : aliased CR1_Register;
-- PWR control status register 1
CSR1 : aliased CSR1_Register;
-- This register is not reset by wakeup from Standby mode, RESET signal
-- and VDD POR. It is only reset by VSW POR and VSWRST reset. This
-- register shall not be accessed when VSWRST bit in RCC_BDCR register
-- resets the VSW domain.After reset, PWR_CR2 register is
-- write-protected. Prior to modifying its content, the DBP bit in
-- PWR_CR1 register must be set to disable the write protection.
CR2 : aliased CR2_Register;
-- Reset only by POR only, not reset by wakeup from Standby mode and
-- RESET pad. The lower byte of this register is written once after POR
-- and shall be written before changing VOS level or ck_sys clock
-- frequency. No limitation applies to the upper bytes.Programming data
-- corresponding to an invalid combination of SDLEVEL, SDEXTHP, SDEN,
-- LDOEN and BYPASS bits (see Table9) will be ignored: data will not be
-- written, the written-once mechanism will lock the register and any
-- further write access will be ignored. The default supply
-- configuration will be kept and the ACTVOSRDY bit in PWR control
-- status register 1 (PWR_CSR1) will go on indicating invalid voltage
-- levels. The system shall be power cycled before writing a new value.
CR3 : aliased CR3_Register;
-- This register allows controlling CPU1 power.
CPUCR : aliased CPUCR_Register;
-- This register allows controlling D3 domain power.Following reset
-- VOSRDY will be read 1 by software
D3CR : aliased D3CR_Register;
-- reset only by system reset, not reset by wakeup from Standby mode5
-- wait states are required when writing this register (when clearing a
-- WKUPF bit in PWR_WKUPFR, the AHB write access will complete after the
-- WKUPF has been cleared).
WKUPCR : aliased WKUPCR_Register;
-- reset only by system reset, not reset by wakeup from Standby mode
WKUPFR : aliased WKUPFR_Register;
-- Reset only by system reset, not reset by wakeup from Standby mode
WKUPEPR : aliased WKUPEPR_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;
CR3 at 16#C# range 0 .. 31;
CPUCR at 16#10# range 0 .. 31;
D3CR at 16#18# range 0 .. 31;
WKUPCR at 16#20# range 0 .. 31;
WKUPFR at 16#24# range 0 .. 31;
WKUPEPR at 16#28# range 0 .. 31;
end record;
-- PWR
PWR_Periph : aliased PWR_Peripheral
with Import, Address => PWR_Base;
end Interfaces.STM32.PWR;
|
-- PACKAGE Runge_5th
--
-- Package implements the 5th order Runge Kutta of Prince and Dormand.
--
-- The program integrates dY/dt = F (t, Y) where t is the
-- independent variable (e.g. time), vector Y is the dependent
-- variable, and F is some function.
--
-- When high accuracy is required, higher order routines
-- are a good idea; but if very low accuracy is fine, then the 5th order
-- (6 stage) Runge-Kutta might be better. If the equation is
-- is stiff, or if you are forced to take very small step sizes for
-- any other reason, then the lower order method is probably faster.
--
-- NOTES ON USE
--
-- (see runge_8th.ads)
generic
type Real is digits <>;
-- The independent variable has type Real. It's called Time
-- throughout the package as though the differential
-- equation dY/dt = F (t, Y) were time dependent.
type Dyn_Index is range <>;
type Dynamical_Variable is array(Dyn_Index) of Real;
-- The dependent variable.
--
-- To use this routine, reduce higher order differential
-- equations to 1st order.
-- For example a 3rd order equation in X becomes a first order
-- equation in the vector Y = (X, dX/dt, d/dt(dX/dt)).
with function F
(Time : Real;
Y : Dynamical_Variable)
return Dynamical_Variable is <>;
-- Defines the equation to be integrated: dY/dt = F (t, Y).
-- Even if the equation is t or Y
-- independent, it must be entered in this form.
with function "*"
(Left : Real;
Right : Dynamical_Variable)
return Dynamical_Variable is <>;
-- Defines multiplication of the independent by the
-- dependent variable. An operation of this sort must exist by
-- definition of the derivative, dY/dt = (Y(t+dt) - Y(t)) / dt,
-- which requires multiplication of the (inverse) independent
-- variable t, by the Dynamical variable Y (the dependent variable).
with function "+"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable is <>;
-- Defines summation of the dependent variable. Again, this
-- operation must exist by the definition of the derivative,
-- dY/dt = (Y(t+dt) - Y(t)) / dt = (Y(t+dt) + (-1)*Y(t)) / dt.
with function "-"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable is <>;
with function Norm
(Y1: in Dynamical_Variable) return Real is <>;
-- For error control we need to know the distance between two objects.
-- Norm define a distance between the two vector, Y1 and Y2
-- using: distance = Norm (Y1 - Y2),
-- For example, if Dynamical_Variable is complex, then Norm can
-- be Sqrt (Real (Y1(1)) * Conjugate (Y1(1))));
-- If it is a vector then the metric may be
-- Sqrt (Transpose(Y1(1)) * Y1(1)), etc.
--
-- Recommended: Sum the absolute values of the components of the vector.
package Runge_5th is
type Step_Integer is range 1 .. 2**31-1;
-- The step size Delta_t is never input. Instead
-- you input Starting_Time, Final_Time, and No_Of_Steps.
-- If there is no error control then Delta_t is
-- (Final_Time - Starting_Time) / No_Of_Steps. If there is
-- error control, then the Delta_t given above is the
-- initial choice of Delta_t, but after the first step Delta_t
-- becomes variable.
procedure Integrate
(Final_State : out Dynamical_Variable;
Final_Time : in Real;
Initial_State : in Dynamical_Variable;
Initial_Time : in Real;
No_Of_Steps : in Step_Integer;
Error_Control_Desired : in Boolean := False;
Error_Tolerance : in Real := 1.0E-6);
private
Zero : constant := +0.0;
Half : constant := +0.5;
One : constant := +1.0;
Two : constant := +2.0;
Four : constant := +4.0;
One_Sixteenth : constant := +0.0625;
One_Eighth : constant := +0.125;
One_Fifth : constant := +0.2;
Four_Fifths : constant := +0.8;
Test_of_Runge_Coeffs_Desired : constant Boolean := False;
-- Test exported by Runge_Coeffs_pd_5 prints error msg if failure detected.
-- Make true during testing.
end Runge_5th;
|
with HAL.Bitmap; use HAL.Bitmap;
with Ada.Containers.Doubly_Linked_Lists;
with BMP_Fonts; use BMP_Fonts;
with Ada.Strings.Bounded;
package Menus is
-- Actual package
-- Tick freeze when menu is displayed, to prevent mistouches
WaitTicks : constant Natural := 100;
BorderSize : constant Natural := 10;
MaxStrLen : constant Natural := 12;
package BoundedStr is new Ada.Strings.Bounded.Generic_Bounded_Length(MaxStrLen);
use BoundedStr;
type Menu;
type MenuAction is access procedure(This : in out Menu);
type MenuTypes is (Menu_Default, Menu_Static);
-- Holds the position of a menu item
type MenuItemPos is record
X1, X2, Y1, Y2 : Natural := 0;
end record
with
Dynamic_Predicate => MenuItemPos.X2 <= 240
and MenuItemPos.Y2 <= 320;
pragma Pack(MenuItemPos);
-- Holds data about a menu item
type MenuItem is record
Text : Bounded_String;
Pos : MenuItemPos;
Action : MenuAction;
end record;
pragma Pack(MenuItem);
-- Holds the menu items
package MenuItemsList is new Ada.Containers.Doubly_Linked_Lists(MenuItem);
type MenuListAcc is access MenuItemsList.List;
-- Hold all the menu data required, tagged for the lovely dot notation
type Menu is tagged record
Items : MenuListAcc := null;
Background : MenuItemPos;
BackgroundColor : Bitmap_Color;
ForegroundColor : Bitmap_Color;
Font : BMP_Font;
MenuType : MenuTypes;
end record;
pragma Pack(Menu);
-- Contracts ghosts
StoredLen : Integer := 0 with Ghost;
StoredLastPos : MenuItemPos with Ghost;
function StoreAndReturnLen(Len : Integer) return Integer with Ghost;
function CheckOverflow(Pos : MenuItemPos) return Boolean with Ghost;
function GetItemStr(This : Menu; Index : Natural) return String with Ghost;
-- Menu Primitives
-- Init a menu
procedure Init(This : in out Menu; Back, Fore : Bitmap_Color; Font : BMP_Font; MenuType : MenuTypes := Menu_Default)
with
Post => This.Items /= null;
-- Add item to menu
procedure AddItem(This : in out Menu; That : MenuItem)
with
Pre => This.Items /= null
and StoreAndReturnLen(Integer(This.Items.Length)) >= 0
and That.Action /= null,
Post => This.Items /= null
and StoredLen + 1 = Integer(This.Items.Length)
and This.Items.Last_Element.Pos = That.Pos
and This.Items.Last_Element.Action = That.Action
and This.Items.Last_Element.Text = That.Text;
-- Same, but more flexible
procedure AddItem(This : in out Menu; Text : String; Pos : MenuItemPos; Action : MenuAction)
with
Pre => This.Items /= null
and StoreAndReturnLen(Integer(This.Items.Length)) >= 0
and Action /= null,
Post => This.Items /= null
and StoredLen + 1 = Integer(This.Items.Length)
and This.Items.Last_Element.Pos = Pos
and This.Items.Last_Element.Action = Action
and This.Items.Last_Element.Text = Text;
-- Add item to menu, copying the first item
procedure AddItem(This : in out Menu; Text : String; Action : MenuAction)
with
Global => (Proof_In => (StoredLen),
Input => (BorderSize, MaxStrLen)),
Pre => This.Items /= null
and StoreAndReturnLen(Integer(This.Items.Length)) >= 1
and CheckOverflow(This.Items.Last_Element.Pos)
and Action /= null,
Post => This.Items /= null
and StoredLen + 1 = Integer(This.Items.Length)
and This.Items.Last_Element.Action = Action
and This.Items.Last_Element.Text = Text,
Depends => (This => +(Text, Action, BorderSize, MaxStrLen));
-- Displays the menu
procedure Show(This : in out Menu)
with
Pre => This.Items /= null;
-- Wait for user choice
-- Will call the relevant MenuAction with a parameter : This (the menu)
-- It MUST be freed manually in case of a Menu_Default
-- It is freed automatically for a Menu_Static with Desroy = True
procedure Listen(This : in out Menu; Destroy : Boolean := True; WaitFor : Natural := WaitTicks);
-- Cleans the menu
procedure Free(This : in out Menu)
with
Pre => This.Items /= null,
Post => This.Items = null;
-- Update the text of the Index'th menu item (in order at the creation)
procedure ChangeText(This : in out Menu; Index : Natural; Text : String)
with
Pre => This.Items /= null
and Index < Integer(This.Items.Length),
Post => GetItemStr(This, Index) = Text,
Depends => (This => +(Index, Text));
private
procedure DrawRect(Item : MenuItemPos; Fill : Boolean; Color : Bitmap_Color);
procedure DrawText(Item : MenuItemPos; Text : Bounded_String; Font : BMP_Font; Back, Fore : Bitmap_Color);
end Menus;
|
package Single_protected_Declaration is
protected Shared_Array is
private
The_Variable : Integer;
end Shared_Array;
end Single_protected_Declaration;
|
with kv.avm.References;
with kv.avm.Registers;
with kv.avm.Instructions;
package kv.avm.Methods is
type Method_Type is tagged private;
type Method_Access is access Method_Type;
function New_Method(Name : String; Code : kv.avm.Instructions.Code_Access) return Method_Access;
procedure Initialize
(Self : in out Method_Type;
Name : in String;
Code : in kv.avm.Instructions.Code_Access);
procedure Add_Predicate
(Self : in out Method_Type;
Predicate : in kv.avm.References.Offset_Type);
function Has_Predicate(Self : Method_Type) return Boolean;
function Get_Predicate(Self : Method_Type) return kv.avm.References.Offset_Type;
function Get_Predicate(Self : Method_Type) return kv.avm.References.Reference_Type;
function Get_Name(Self : Method_Type) return String;
function Get_Code(Self : Method_Type) return kv.avm.Instructions.Code_Access;
private
type Method_Type is tagged
record
Name : kv.avm.Registers.Constant_String_Access;
Code : kv.avm.Instructions.Code_Access;
Gated : Boolean := False;
Predicate : kv.avm.References.Offset_Type;
end record;
end kv.avm.Methods;
|
with
Shell.Commands.Safe,
Ada.Text_IO,
Ada.Exceptions;
procedure Test_Concurrent_Commands
is
use Ada.Text_IO,
Ada.Exceptions;
task Task_1;
task body Task_1
is
begin
for i in 1 .. 50_000
loop
declare
use Shell,
Shell.Commands,
Shell.Commands.Forge;
The_Command : Command := To_Command ("ls /home");
-- Output : constant String := +Output_Of (Safe.Runn (The_Command));
begin
Safe.Run (The_Command);
declare
Output : constant String := +Output_Of (Results_Of (The_Command));
begin
Put_Line ("Task 1 i =" & i'Image & " => " & Output);
if Output = ""
then
raise Program_Error with "Task 1: NO OUTPUT";
end if;
end;
end;
delay 0.01; -- Allow other task a turn.
end loop;
exception
when E : others =>
Put_Line ("Task 1: Fatal Error");
Put_Line (Exception_Information (E));
end Task_1;
task Task_2;
task body Task_2
is
begin
for i in 1 .. 50_000
loop
declare
use Shell,
Shell.Commands,
Shell.Commands.Forge;
The_Command : Command := To_Command ("pwd");
-- The_Command : Command := To_Command ("sleep 2");
-- Output : constant String := +Output_Of (Safe.Runn (The_Command));
begin
Safe.Run (The_Command);
declare
Output : constant String := +Output_Of (Results_Of (The_Command));
begin
Put_Line ("Task 2 i =" & i'Image & " => " & Output);
if Output = ""
then
raise Program_Error with "Task 2: NO OUTPUT";
end if;
end;
end;
delay 0.01; -- Allow other task a turn.
end loop;
exception
when E : others =>
Put_Line ("Task 2: Fatal Error");
Put_Line (Exception_Information (E));
end Task_2;
begin
Shell.Open_Log ("aShell_spawn_Client.log");
loop
exit when Task_1'Terminated
and Task_2'Terminated;
delay 0.1;
end loop;
New_Line (2);
Put_Line ("Main Task has terminated.");
Shell.Commands.Safe.Stop_Spawn_Client;
delay 0.2;
Shell.Close_Log;
-- Put_Line ("Delaying for 5 minutes.");
-- delay 25.0; -- * 60.0; -- Allow time to check for open pipes and zombie processes.
end Test_Concurrent_Commands;
|
with CSV;
with Ada.Text_IO; use Ada.Text_IO;
package Simulation is
package CSV_here is new CSV (filename => "../rawdata.csv");
have_data : Boolean := False;
csv_file : File_Type;
Finished : Boolean := False;
procedure init;
procedure update;
procedure close;
end Simulation;
|
package Components is
-- Stats
type Health is range 0 .. 1000;
type Defense is range 0 .. 25;
end Components;
|
with
AdaM.a_Type,
AdaM.Environment;
package AdaM.Assist
is
-- function known_Types return AdaM.a_Type.Vector;
-- function known_Environment return AdaM.Environment.item;
function known_Entities return AdaM.Environment.item;
function Tail_of (the_full_Name : in String) return String;
function strip_Tail_of (the_full_Name : in String) return String;
function type_button_Name_of (the_full_Name : in String) return String;
function Split (the_Text : in String) return text_Lines;
end AdaM.Assist;
|
-- -----------------------------------------------------------------------------
-- smk, the smart make
-- © 2018 Lionel Draghi <lionel.draghi@free.fr>
-- SPDX-License-Identifier: APSL-2.0
-- -----------------------------------------------------------------------------
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
-- http://www.apache.org/licenses/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- -----------------------------------------------------------------------------
with Ada.Directories;
with GNAT.OS_Lib;
with Smk.IO;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed;
separate (Smk.Main)
-- -----------------------------------------------------------------------------
procedure Run_Command (E : in out Makefiles.Makefile_Entry;
The_Run_List : in out Run_Files.Run_Lists.Map)
is
-- --------------------------------------------------------------------------
procedure Run (Cmd : in Run_Files.Command_Lines;
OK : out Boolean) is
-- Spawn the Cmd under strace.
-- OK is set to True if the spawn did it well.
use type Run_Files.Command_Lines;
use GNAT.OS_Lib;
use Ada.Directories;
Debug : constant Boolean := False;
Prefix : constant String := "Run";
Opt : constant String
:= Settings.Strace_Opt & Settings.Strace_Outfile_Name & " " & (+Cmd);
Initial_Dir : constant String := Current_Directory;
begin
-- IO.Put_Line ("cd " & Settings.Run_Dir_Name, Level => Verbose);
Set_Directory (Settings.Run_Dir_Name);
IO.Put_Debug_Line
(Msg => " Spawn " & Strace_Cmd & " " & (Opt) & "...",
Debug => Debug,
Prefix => Prefix);
IO.Put_Line ((+Cmd));
Spawn (Program_Name => Strace_Cmd,
Args => Argument_String_To_List (Opt).all,
Success => OK);
if not OK then
IO.Put_Error (Msg => "Spawn failed for " & Strace_Cmd & " " & (Opt));
end if;
Set_Directory (Initial_Dir);
-- Fixme : ensure turning to Initial_Dir even in case of exception?
end Run;
use Smk.Run_Files;
OK : Boolean;
Source_Files,
Target_Files : File_Lists.Map;
New_Run_Time : Ada.Calendar.Time;
begin
if Must_Be_Run (E.Command, The_Run_List) then
if Dry_Run then
-- don't run, just print the command
IO.Put_Line ("> " & (+E.Command));
E.Already_Run := True;
else
-- 1. Run the command
New_Run_Time := Ada.Calendar.Clock;
-- New_Run_Time := Time_Of
-- (Year => Year (Tmp),
-- Month => Month (Tmp),
-- Day => Day (Tmp),
-- Seconds => Day_Duration (Float'Floor (Float (Seconds (Tmp)))));
-- This pretty ridiculous code is here to avoid the sub_second
-- part that is return by Calendar.Clock, but always set
-- to 0.0 in the Time returned by the Directories.Modification_Time.
-- This cause files created by a command to be seeing as older than
-- this command, and prevent the evaluation of the need to re-run a
-- command.
-- It's better described in Analyze_Run code.
-- =================================================================
-- NB: this method IS CLEARLY NOT RELIABLE
-- =================================================================
Run (E.Command, OK);
E.Already_Run := True;
if not OK and not Ignore_Errors then
return;
end if;
-- 2. Analyze the run log
Analyze_Run (Source_Files, Target_Files);
-- 3. Store the results
Insert_Or_Update (The_Command => E.Command,
The_Run => (Section => E.Section,
Run_Time => New_Run_Time,
Sources => Source_Files,
Targets => Target_Files),
In_Run_List => The_Run_List);
end if;
else
E.Already_Run := False;
IO.Put_Line ("No need to run " & (+E.Command),
Level => IO.Verbose);
end if;
end Run_Command;
|
with AUnit.Assertions; use AUnit.Assertions;
with Ada.Containers;
use type Ada.Containers.Count_Type;
package body FMS.Test is
procedure Test_Load (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
begin
null;
load("R8,U5,L5,D3", "U7,R6,D4,L4");
Assert(wire_1.Length = 4, "Expected wire_1 to have 4 elements");
Assert(wire_2.Length = 4, "Expected wire_2 to have 4 elements");
Assert(wire_points_1.Length = 21, "Expected wire_1 points to have 21 elements");
Assert(wire_points_2.Length = 21, "Expected wire_1 points to have 21 elements");
load("R75,D30,R83,U83,L12,D49,R71,U7,L72", "U62,R66,U55,R34,D71,R55,D58,R83");
Assert(wire_1.Length = 9, "Expected wire_1 to have 9 elements");
Assert(wire_2.Length = 8, "Expected wire_2 to have 8 elements");
load("R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51", "U98,R91,D20,R16,D67,R40,U7,R15,U6,R7");
Assert(wire_1.Length = 11, "Expected wire_1 to have 11 elements");
Assert(wire_2.Length = 10, "Expected wire_2 to have 10 elements");
end Test_Load;
procedure Test_Closest (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
begin
load("R8,U5,L5,D3", "U7,R6,D4,L4");
Assert(closest_intersection = 6, "Expected closest intersection at distance 6");
load("R75,D30,R83,U83,L12,D49,R71,U7,L72", "U62,R66,U55,R34,D71,R55,D58,R83");
Assert(closest_intersection = 159, "Expected closest intersection at distance 159");
load("R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51", "U98,R91,D20,R16,D67,R40,U7,R15,U6,R7");
Assert(closest_intersection = 135, "Expected closest intersection at distance 135");
end Test_Closest;
procedure Test_Shortest (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
begin
load("R8,U5,L5,D3", "U7,R6,D4,L4");
Assert(shortest_intersection = 30, "Expected shortest intersection at distance 30");
load("R75,D30,R83,U83,L12,D49,R71,U7,L72", "U62,R66,U55,R34,D71,R55,D58,R83");
Assert(shortest_intersection = 610, "Expected shortest intersection at distance 610");
load("R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51", "U98,R91,D20,R16,D67,R40,U7,R15,U6,R7");
Assert(shortest_intersection = 410, "Expected shortest intersection at distance 410");
end Test_Shortest;
function Name (T : Test) return AUnit.Message_String is
pragma Unreferenced (T);
begin
return AUnit.Format ("FMS Package");
end Name;
procedure Register_Tests (T : in out Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Load'Access, "Loading");
Register_Routine (T, Test_Closest'Access, "Closest Point");
Register_Routine (T, Test_Shortest'Access, "Shortest Distance Point");
end Register_Tests;
end FMS.Test;
|
-- { dg-do compile }
-- { dg-options "-O" }
with Varsize_Return2_Pkg; use Varsize_Return2_Pkg;
package Varsize_Return2 is
package My_G is new G (0);
Result : constant T := My_G.Get;
end Varsize_Return2;
|
package body impact.d3.Space.dynamic
is
--- Forge
--
package body Forge
is
procedure define (Self : out Item; dispatcher : access impact.d3.Dispatcher.item'Class;
broadphase : access impact.d3.collision.Broadphase.item'Class;
collisionConfiguration : access impact.d3.collision.Configuration.item'Class)
is
begin
impact.d3.Space.Forge.define (impact.d3.Space.item (Self), dispatcher, broadphase, collisionConfiguration);
Self.m_solverInfo := impact.d3.contact_solver_Info.to_solver_Info;
end define;
end Forge;
--- Attributes
--
procedure addConstraint (Self : in out Item;
constraint : access impact.d3.Joint.Item'Class;
disableCollisionsBetweenLinkedBodies : Boolean )
is
begin
null;
end addConstraint;
procedure removeConstraint (Self : in out Item;
constraint : access impact.d3.Joint.Item'Class)
is
begin
null;
end removeConstraint;
function getNumConstraints (Self : Item) return Integer
is
pragma Unreferenced (Self);
begin
return 0;
end getNumConstraints;
function getConstraint (Self : Item;
index : Integer) return access impact.d3.Joint.Item'Class
is
pragma Unreferenced (Self, index);
begin
return null;
end getConstraint;
procedure getWorldUserInfo (Self : in out Item)
is
begin
null;
end getWorldUserInfo;
procedure setInternalTickCallback (Self : in out Item;
cb : in btInternalTickCallback;
worldUserInfo : access lace.Any.item'Class := null;
isPreTick : in Boolean := False)
is
begin
if isPreTick then
Self.m_internalPreTickCallback := cb;
else
Self.m_internalTickCallback := cb;
end if;
Self.m_worldUserInfo := worldUserInfo;
end setInternalTickCallback;
procedure setWorldUserInfo (Self : in out Item;
worldUserInfo : access lace.Any.item'Class)
is
begin
Self.m_worldUserInfo := worldUserInfo;
end setWorldUserInfo;
function getSolverInfo (Self : access Item) return access impact.d3.contact_solver_Info.item
is
begin
return Self.m_solverInfo'Unchecked_Access;
end getSolverInfo;
--- 'Protected'
--
function m_internalPreTickCallback (Self : in Item) return btInternalTickCallback
is
begin
return Self.m_internalPreTickCallback;
end m_internalPreTickCallback;
function m_internalTickCallback (Self : in Item) return btInternalTickCallback
is
begin
return Self.m_internalTickCallback;
end m_internalTickCallback;
end impact.d3.Space.dynamic;
|
with Libadalang.Analysis; use Libadalang.Analysis;
package Shared is
function Nr_Of_Parameters (S_S : Subp_Spec) return Integer;
function Is_Part_Of_Subp_Def (S_S : Subp_Spec) return Boolean;
function Inside_Private_Part (Node : Ada_Node'Class) return Boolean;
end Shared;
|
-- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
generic
type Float_Type is digits <>;
package Ada.Numerics.Generic_Elementary_Functions is
pragma Pure (Generic_Elementary_Functions);
function Sqrt
(X : Float_Type'Base) return Float_Type'Base;
function Log
(X : Float_Type'Base) return Float_Type'Base;
function Log
(X, Base : Float_Type'Base) return Float_Type'Base;
function Exp
(X : Float_Type'Base) return Float_Type'Base;
function "**" (Left, Right : Float_Type'Base) return Float_Type'Base;
function Sin
(X : Float_Type'Base) return Float_Type'Base;
function Sin
(X, Cycle : Float_Type'Base) return Float_Type'Base;
function Cos
(X : Float_Type'Base) return Float_Type'Base;
function Cos
(X, Cycle : Float_Type'Base) return Float_Type'Base;
function Tan
(X : Float_Type'Base) return Float_Type'Base;
function Tan
(X, Cycle : Float_Type'Base) return Float_Type'Base;
function Cot
(X : Float_Type'Base) return Float_Type'Base;
function Cot
(X, Cycle : Float_Type'Base) return Float_Type'Base;
function Arcsin
(X : Float_Type'Base) return Float_Type'Base;
function Arcsin
(X, Cycle : Float_Type'Base) return Float_Type'Base;
function Arccos
(X : Float_Type'Base) return Float_Type'Base;
function Arccos
(X, Cycle : Float_Type'Base) return Float_Type'Base;
function Arctan (Y : Float_Type'Base;
X : Float_Type'Base := 1.0)
return Float_Type'Base;
function Arctan (Y : Float_Type'Base;
X : Float_Type'Base := 1.0;
Cycle : Float_Type'Base) return Float_Type'Base;
function Arccot (X : Float_Type'Base;
Y : Float_Type'Base := 1.0)
return Float_Type'Base;
function Arccot (X : Float_Type'Base;
Y : Float_Type'Base := 1.0;
Cycle : Float_Type'Base) return Float_Type'Base;
function Sinh
(X : Float_Type'Base) return Float_Type'Base;
function Cosh
(X : Float_Type'Base) return Float_Type'Base;
function Tanh
(X : Float_Type'Base) return Float_Type'Base;
function Coth
(X : Float_Type'Base) return Float_Type'Base;
function Arcsinh
(X : Float_Type'Base) return Float_Type'Base;
function Arccosh
(X : Float_Type'Base) return Float_Type'Base;
function Arctanh
(X : Float_Type'Base) return Float_Type'Base;
function Arccoth
(X : Float_Type'Base) return Float_Type'Base;
end Ada.Numerics.Generic_Elementary_Functions;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Compilation_Units;
with Program.Compilation_Unit_Vectors;
package Program.Subunits is
pragma Pure;
type Subunit is limited interface
and Program.Compilation_Units.Compilation_Unit;
-- Subunits are like child units, with these (important) differences:
-- subunits support the separate compilation of bodies only (not
-- declarations); the parent contains a body_stub to indicate the existence
-- and place of each of its subunits; declarations appearing in the
-- parent's body can be visible within the subunits
type Subunit_Access is access all Subunit'Class
with Storage_Size => 0;
not overriding function Subunits (Self : access Subunit)
return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access
is abstract;
-- with Post'Class =>
-- (Subunits'Result.Is_Empty
-- or else (for all X in Subunits'Result.Each_Unit => X.Unit.Is_Subunit));
-- Returns a complete list of subunit values, with one value for each body
-- stub that appears in the given Subunit. Returns an empty list if the
-- parent unit does not contain any body stubs.
not overriding function Parent_Body (Self : access Subunit)
return not null Program.Compilation_Units.Compilation_Unit_Access
is abstract
with Post'Class =>
(Parent_Body'Result.Is_Subunit
or Parent_Body'Result.Is_Library_Unit_Body);
-- Returns the Compilation_Unit containing the body stub of the given
-- Subunit.
end Program.Subunits;
|
with Ada.Text_IO;
procedure Euler12 is
Triangle_Num : Positive := 1;
I : Positive := 1;
J : Positive;
Num_Divisors : Natural;
begin
loop
Num_Divisors := 0;
J := 1;
while J * J <= Triangle_Num loop
if Triangle_Num mod J = 0 then
Num_Divisors := Num_Divisors + 2;
end if;
J := J + 1;
end loop;
Ada.Text_IO.Put_Line(Positive'Image(Triangle_Num) & Natural'Image(Num_Divisors));
exit when Num_Divisors > 500;
I := I + 1;
Triangle_Num := Triangle_Num + I;
end loop;
end Euler12;
|
with Prime_Numbers, Ada.Text_IO, Ada.Command_Line;
procedure Sequence_Of_Primes is
package Integer_Numbers is new
Prime_Numbers (Natural, 0, 1, 2);
use Integer_Numbers;
Start: Natural := Natural'Value(Ada.Command_Line.Argument(1));
Stop: Natural := Natural'Value(Ada.Command_Line.Argument(2));
begin
for I in Start .. Stop loop
if Is_Prime(I) then
Ada.Text_IO.Put(Natural'Image(I));
end if;
end loop;
end Sequence_Of_Primes;
|
-- 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 GL.Objects.Programs;
with GL.Types.Compute;
with Orka.Rendering.Buffers;
limited with Orka.Rendering.Programs.Modules;
limited with Orka.Rendering.Programs.Uniforms;
package Orka.Rendering.Programs is
pragma Preelaborate;
type Program is tagged private;
function Create_Program (Module : Programs.Modules.Module;
Separable : Boolean := False) return Program;
function Create_Program (Modules : Programs.Modules.Module_Array;
Separable : Boolean := False) return Program;
procedure Use_Program (Object : in out Program);
-- Use the program during rendering
function Compute_Work_Group_Size
(Object : Program) return GL.Types.Compute.Dimension_Size_Array;
function Uniform_Sampler (Object : Program; Name : String) return Uniforms.Uniform_Sampler;
-- Return the uniform sampler that has the given name
--
-- This function is only needed in order to call procedure Verify_Compatibility
-- to verify that the kind and format of the sampler and texture are
-- compatible.
--
-- To bind a texture to a sampler, call Orka.Rendering.Textures.Bind.
--
-- Name must be a GLSL uniform sampler. A Uniforms.Uniform_Inactive_Error
-- exception is raised if the name is not defined in any of the attached shaders.
function Uniform_Image (Object : Program; Name : String) return Uniforms.Uniform_Image;
-- Return the uniform image that has the given name
--
-- This function is only needed in order to call procedure Verify_Compatibility
-- to verify that the kind and format of the image sampler and texture are
-- compatible.
--
-- To bind a texture to a image sampler, call Orka.Rendering.Textures.Bind.
--
-- Name must be a GLSL uniform image. A Uniforms.Uniform_Inactive_Error
-- exception is raised if the name is not defined in any of the attached shaders.
function Uniform (Object : Program; Name : String) return Uniforms.Uniform;
-- Return the uniform that has the given name
--
-- Name must be a GLSL uniform. A Uniforms.Uniform_Inactive_Error exception
-- is raised if the name is not defined in any of the attached shaders.
function Binding
(Object : Program;
Target : Buffers.Indexed_Buffer_Target;
Name : String) return Natural;
-- Return the index of the binding point of a shader storage block (SSBO),
-- uniform block (UBO), or an atomic counter buffer
--
-- Name must be a GLSL shader storage block, uniform block, or atomic
-- uniform. A Uniforms.Uniform_Inactive_Error exception is raised if
-- the name is not defined in any of the attached shaders.
Program_Link_Error : exception;
private
type Program is tagged record
GL_Program : GL.Objects.Programs.Program;
end record;
end Orka.Rendering.Programs;
|
pragma Ada_2012;
with Ada.Unchecked_Deallocation;
use Ada;
package body Pulsada is
---------------
-- New_Block --
---------------
function New_Block
(N_Channels : Channel_Index;
N_Frames : Frame_Counter)
return Frame_Block
is
N : constant Positive := Positive (N_Channels) * Positive (N_Frames);
begin
return Frame_Block'(Finalization.Limited_Controlled with
Data => new Block_Buffer (1 .. N),
N_Frames => N_Frames,
N_Channels => N_Channels);
end New_Block;
---------
-- Get --
---------
function Get
(Block : Frame_Block;
N : Frame_Counter)
return Frame
is
First : constant Natural :=
Block.Data'First + (Natural (N) - Natural (Frame_Counter'First)) * Natural (Block.N_Channels);
Last : constant Positive := First + Natural (Block.N_Channels)-1;
begin
return Frame (Block.Data (First .. Last));
end Get;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Object : in out Frame_Block) is
procedure Free is
new Unchecked_Deallocation (Object => Block_Buffer,
Name => Block_Buffer_Access);
begin
Free (Object.Data);
end Finalize;
end Pulsada;
|
with Ada.Exceptions;
with TOML.Generic_Dump;
with TOML.Generic_Parse;
package body TOML.File_IO is
procedure Get
(Stream : in out Ada.Text_IO.File_Type;
EOF : out Boolean;
Byte : out Character);
-- Callback for Parse_File
function Parse_File is new TOML.Generic_Parse
(Input_Stream => Ada.Text_IO.File_Type,
Get => Get);
procedure Put_To_File (File : in out Ada.Text_IO.File_Type; Bytes : String);
-- Callback for TOML.Generic_Dump
procedure Dump_To_File is new TOML.Generic_Dump
(Output_Stream => Ada.Text_IO.File_Type,
Put => Put_To_File);
---------
-- Get --
---------
procedure Get
(Stream : in out Ada.Text_IO.File_Type;
EOF : out Boolean;
Byte : out Character) is
begin
EOF := False;
Ada.Text_IO.Get_Immediate (Stream, Byte);
exception
when Ada.Text_IO.End_Error =>
EOF := True;
end Get;
-----------------
-- Put_To_File --
-----------------
procedure Put_To_File (File : in out Ada.Text_IO.File_Type; Bytes : String)
is
begin
Ada.Text_IO.Put (File, Bytes);
end Put_To_File;
---------------
-- Load_File --
---------------
function Load_File (Filename : String) return Read_Result is
use Ada.Exceptions, Ada.Text_IO;
File : File_Type;
begin
begin
Open (File, In_File, Filename);
exception
when Exc : Name_Error | Use_Error =>
return Create_Error
("cannot open " & Filename & ": " & Exception_Message (Exc),
No_Location);
end;
return Result : constant Read_Result := Parse_File (File) do
Close (File);
end return;
end Load_File;
------------------
-- Dump_To_File --
------------------
procedure Dump_To_File
(Value : TOML_Value; File : in out Ada.Text_IO.File_Type) is
begin
Dump_To_File (File, Value);
end Dump_To_File;
end TOML.File_IO;
|
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000,2001,2004 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
-- Version Control
-- $Revision: 1.5 $
-- $Date: 2004/08/21 21:37:00 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with ncurses2.util; use ncurses2.util;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Terminfo;
use Terminal_Interface.Curses.Terminfo;
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
procedure ncurses2.attr_test is
function subset (super, sub : Character_Attribute_Set) return Boolean;
function intersect (b, a : Character_Attribute_Set) return Boolean;
function has_A_COLOR (attr : Attributed_Character) return Boolean;
function show_attr (row : Line_Position;
skip : Natural;
attr : Character_Attribute_Set;
name : String;
once : Boolean) return Line_Position;
procedure attr_getc (skip : out Integer;
fg, bg : in out Color_Number;
result : out Boolean);
function subset (super, sub : Character_Attribute_Set) return Boolean is
begin
if
(super.Stand_Out or not sub.Stand_Out) and
(super.Under_Line or not sub.Under_Line) and
(super.Reverse_Video or not sub.Reverse_Video) and
(super.Blink or not sub.Blink) and
(super.Dim_Character or not sub.Dim_Character) and
(super.Bold_Character or not sub.Bold_Character) and
(super.Alternate_Character_Set or not sub.Alternate_Character_Set) and
(super.Invisible_Character or not sub.Invisible_Character) -- and
-- (super.Protected_Character or not sub.Protected_Character) and
-- (super.Horizontal or not sub.Horizontal) and
-- (super.Left or not sub.Left) and
-- (super.Low or not sub.Low) and
-- (super.Right or not sub.Right) and
-- (super.Top or not sub.Top) and
-- (super.Vertical or not sub.Vertical)
then
return True;
else
return False;
end if;
end subset;
function intersect (b, a : Character_Attribute_Set) return Boolean is
begin
if
(a.Stand_Out and b.Stand_Out) or
(a.Under_Line and b.Under_Line) or
(a.Reverse_Video and b.Reverse_Video) or
(a.Blink and b.Blink) or
(a.Dim_Character and b.Dim_Character) or
(a.Bold_Character and b.Bold_Character) or
(a.Alternate_Character_Set and b.Alternate_Character_Set) or
(a.Invisible_Character and b.Invisible_Character) -- or
-- (a.Protected_Character and b.Protected_Character) or
-- (a.Horizontal and b.Horizontal) or
-- (a.Left and b.Left) or
-- (a.Low and b.Low) or
-- (a.Right and b.Right) or
-- (a.Top and b.Top) or
-- (a.Vertical and b.Vertical)
then
return True;
else
return False;
end if;
end intersect;
function has_A_COLOR (attr : Attributed_Character) return Boolean is
begin
if attr.Color /= Color_Pair (0) then
return True;
else
return False;
end if;
end has_A_COLOR;
-- Print some text with attributes.
function show_attr (row : Line_Position;
skip : Natural;
attr : Character_Attribute_Set;
name : String;
once : Boolean) return Line_Position is
function make_record (n : Integer) return Character_Attribute_Set;
function make_record (n : Integer) return Character_Attribute_Set is
-- unsupported means true
a : Character_Attribute_Set := (others => False);
m : Integer;
rest : Integer;
begin
-- ncv is a bitmap with these fields
-- A_STANDOUT,
-- A_UNDERLINE,
-- A_REVERSE,
-- A_BLINK,
-- A_DIM,
-- A_BOLD,
-- A_INVIS,
-- A_PROTECT,
-- A_ALTCHARSET
-- It means no_color_video,
-- video attributes that can't be used with colors
-- see man terminfo.5
m := n mod 2;
rest := n / 2;
if 1 = m then
a.Stand_Out := True;
end if;
m := rest mod 2;
rest := rest / 2;
if 1 = m then
a.Under_Line := True;
end if;
m := rest mod 2;
rest := rest / 2;
if 1 = m then
a.Reverse_Video := True;
end if;
m := rest mod 2;
rest := rest / 2;
if 1 = m then
a.Blink := True;
end if;
m := rest mod 2;
rest := rest / 2;
if 1 = m then
a.Bold_Character := True;
end if;
m := rest mod 2;
rest := rest / 2;
if 1 = m then
a.Invisible_Character := True;
end if;
m := rest mod 2;
rest := rest / 2;
-- if 1 = m then
-- a.Protected_Character := True;
-- end if;
m := rest mod 2;
rest := rest / 2;
if 1 = m then
a.Alternate_Character_Set := True;
end if;
return a;
end make_record;
ncv : constant Integer := Get_Number ("ncv");
begin
Move_Cursor (Line => row, Column => 8);
Add (Str => name & " mode:");
Move_Cursor (Line => row, Column => 24);
Add (Ch => '|');
if skip /= 0 then
-- printw("%*s", skip, " ")
Add (Str => Ada.Strings.Fixed."*" (skip, ' '));
end if;
if once then
Switch_Character_Attribute (Attr => attr);
else
Set_Character_Attributes (Attr => attr);
end if;
Add (Str => "abcde fghij klmno pqrst uvwxy z");
if once then
Switch_Character_Attribute (Attr => attr, On => False);
end if;
if skip /= 0 then
Add (Str => Ada.Strings.Fixed."*" (skip, ' '));
end if;
Add (Ch => '|');
if attr /= Normal_Video then
declare begin
if not subset (super => Supported_Attributes, sub => attr) then
Add (Str => " (N/A)");
elsif ncv > 0 and has_A_COLOR (Get_Background) then
declare
Color_Supported_Attributes :
constant Character_Attribute_Set := make_record (ncv);
begin
if intersect (Color_Supported_Attributes, attr) then
Add (Str => " (NCV) ");
end if;
end;
end if;
end;
end if;
return row + 2;
end show_attr;
procedure attr_getc (skip : out Integer; fg, bg : in out Color_Number;
result : out Boolean) is
ch : constant Key_Code := Getchar;
nc : constant Color_Number := Color_Number (Number_Of_Colors);
curscr : Window;
pragma Import (C, curscr, "curscr");
-- curscr is not implemented in the Ada binding
begin
result := True;
if Ada.Characters.Handling.Is_Digit (Character'Val (ch)) then
skip := ctoi (Code_To_Char (ch));
elsif ch = CTRL ('L') then
Touch;
Touch (curscr);
Refresh;
elsif Has_Colors then
case ch is
-- Note the mathematical elegance compared to the C version.
when Character'Pos ('f') => fg := (fg + 1) mod nc;
when Character'Pos ('F') => fg := (fg - 1) mod nc;
when Character'Pos ('b') => bg := (bg + 1) mod nc;
when Character'Pos ('B') => bg := (bg - 1) mod nc;
when others =>
result := False;
end case;
else
result := False;
end if;
end attr_getc;
-- pairs could be defined as array ( Color_Number(0) .. colors - 1) of
-- array (Color_Number(0).. colors - 1) of Boolean;
pairs : array (Color_Pair'Range) of Boolean := (others => False);
fg, bg : Color_Number := Black; -- = 0;
xmc : constant Integer := Get_Number ("xmc");
skip : Integer := xmc;
n : Integer;
use Int_IO;
begin
pairs (0) := True;
if skip < 0 then
skip := 0;
end if;
n := skip;
loop
declare
row : Line_Position := 2;
normal : Attributed_Character := Blank2;
-- ???
begin
-- row := 2; -- weird, row is set to 0 without this.
-- TODO delete the above line, it was a gdb quirk that confused me
if Has_Colors then declare
pair : constant Color_Pair :=
Color_Pair (fg * Color_Number (Number_Of_Colors) + bg);
begin
-- Go though each color pair. Assume that the number of
-- Redefinable_Color_Pairs is 8*8 with predefined Colors 0..7
if not pairs (pair) then
Init_Pair (pair, fg, bg);
pairs (pair) := True;
end if;
normal.Color := pair;
end;
end if;
Set_Background (Ch => normal);
Erase;
Add (Line => 0, Column => 20,
Str => "Character attribute test display");
row := show_attr (row, n, (Stand_Out => True, others => False),
"STANDOUT", True);
row := show_attr (row, n, (Reverse_Video => True, others => False),
"REVERSE", True);
row := show_attr (row, n, (Bold_Character => True, others => False),
"BOLD", True);
row := show_attr (row, n, (Under_Line => True, others => False),
"UNDERLINE", True);
row := show_attr (row, n, (Dim_Character => True, others => False),
"DIM", True);
row := show_attr (row, n, (Blink => True, others => False),
"BLINK", True);
-- row := show_attr (row, n, (Protected_Character => True,
-- others => False), "PROTECT", True);
row := show_attr (row, n, (Invisible_Character => True,
others => False), "INVISIBLE", True);
row := show_attr (row, n, Normal_Video, "NORMAL", False);
Move_Cursor (Line => row, Column => 8);
if xmc > -1 then
Add (Str => "This terminal does have the magic-cookie glitch");
else
Add (Str => "This terminal does not have the magic-cookie glitch");
end if;
Move_Cursor (Line => row + 1, Column => 8);
Add (Str => "Enter a digit to set gaps on each side of " &
"displayed attributes");
Move_Cursor (Line => row + 2, Column => 8);
Add (Str => "^L = repaint");
if Has_Colors then
declare tmp1 : String (1 .. 1);
begin
Add (Str => ". f/F/b/F toggle colors (");
Put (tmp1, Integer (fg));
Add (Str => tmp1);
Add (Ch => '/');
Put (tmp1, Integer (bg));
Add (Str => tmp1);
Add (Ch => ')');
end;
end if;
Refresh;
end;
declare result : Boolean; begin
attr_getc (n, fg, bg, result);
exit when not result;
end;
end loop;
Set_Background (Ch => Blank2);
Erase;
End_Windows;
end ncurses2.attr_test;
|
with ada.characters.latin_1;
with logger;
use logger;
package body box_info is
function initialize_box(t, w, l, h, q, b : integer) return box_info_t is
box : constant box_info_t := (thickness => t,
height => h,
width => w,
length => l,
queue_length => q,
inner_height => b);
begin
debug("Initialisation de la boite");
debug(to_string(box));
return box;
end;
-- requiert :
-- t, l, w, q, h, b, q > 0
-- l >= w
-- l-2t, w-2t > 0
-- b < h-2t
-- q <= l-4t (Test aussi sur la inner boite d'où le 4)
-- q <= w-4t (Test aussi sur la inner boite d'où le 4)
-- q <= h-2t
-- q <= b-2t
procedure validate_box_measurements(box : box_info_t) is
begin
debug("Verification des mesures entrées");
if not (box.thickness > 0) then
raise invalid_args with "t > 0";
end if;
if not (box.length > 0) then
raise invalid_args with "l > 0";
end if;
if not (box.width > 0) then
raise invalid_args with "w > 0";
end if;
if not (box.queue_length > 0) then
raise invalid_args with "q > 0";
end if;
if not (box.height > 0) then
raise invalid_args with "h > 0";
end if;
if not (box.inner_height > 0) then
raise invalid_args with "b > 0";
end if;
if not (box.queue_length > 0) then
raise invalid_args with "q > 0";
end if;
if not (box.length >= box.width) then
raise invalid_args with "l >= w";
end if;
if not (box.length - 2 * box.thickness > 0) then
raise invalid_args with "l - 2 * t > 0";
end if;
if not (box.width - 2 * box.thickness > 0) then
raise invalid_args with "w - 2 * t > 0";
end if;
if not (box.inner_height < box.height - 2 * box.thickness) then
raise invalid_args with "b < h - 2 * t";
end if;
if not (box.queue_length <= box.length - 4 * box.thickness) then
raise invalid_args with "q <= l - 4 * t";
end if;
if not (box.queue_length <= box.width - 4 * box.thickness) then
raise invalid_args with "q <= w - 4 * t";
end if;
if not (box.queue_length <= box.height - 2 * box.thickness) then
raise invalid_args with "q <= h - 2 * t";
end if;
if not (box.queue_length <= box.inner_height - 2 * box.thickness) then
raise invalid_args with "q <= b - 2 * t";
end if;
end;
-- renvoie une chaine de texte décrivant l'état de l'objet
function to_string(box : box_info_t) return string is
tab : constant character := ada.characters.latin_1.HT;
lf : constant character := ada.characters.latin_1.LF;
begin
return "[ "
& tab & "t: " & integer'image(box.thickness) & ", " & lf
& tab & "w: " & integer'image(box.width) & ", " & lf
& tab & "l: " & integer'image(box.length) & ", " & lf
& tab & "h: " & integer'image(box.height) & ", " & lf
& tab & "q: " & integer'image(box.queue_length) & ", " & lf
& tab & "b: " & integer'image(box.inner_height) & " ]";
end;
end box_info;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- N A M E T --
-- --
-- B o d y --
-- --
-- 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. --
-- --
-- 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. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- WARNING: There is a C version of this package. Any changes to this
-- source file must be properly reflected in the C header file a-namet.h
-- which is created manually from namet.ads and namet.adb.
with Debug; use Debug;
with Opt; use Opt;
with Output; use Output;
with Tree_IO; use Tree_IO;
with Widechar; use Widechar;
package body Namet is
Name_Chars_Reserve : constant := 5000;
Name_Entries_Reserve : constant := 100;
-- The names table is locked during gigi processing, since gigi assumes
-- that the table does not move. After returning from gigi, the names
-- table is unlocked again, since writing library file information needs
-- to generate some extra names. To avoid the inefficiency of always
-- reallocating during this second unlocked phase, we reserve a bit of
-- extra space before doing the release call.
Hash_Num : constant Int := 2**12;
-- Number of headers in the hash table. Current hash algorithm is closely
-- tailored to this choice, so it can only be changed if a corresponding
-- change is made to the hash alogorithm.
Hash_Max : constant Int := Hash_Num - 1;
-- Indexes in the hash header table run from 0 to Hash_Num - 1
subtype Hash_Index_Type is Int range 0 .. Hash_Max;
-- Range of hash index values
Hash_Table : array (Hash_Index_Type) of Name_Id;
-- The hash table is used to locate existing entries in the names table.
-- The entries point to the first names table entry whose hash value
-- matches the hash code. Then subsequent names table entries with the
-- same hash code value are linked through the Hash_Link fields.
-----------------------
-- Local Subprograms --
-----------------------
function Hash return Hash_Index_Type;
pragma Inline (Hash);
-- Compute hash code for name stored in Name_Buffer (length in Name_Len)
procedure Strip_Qualification_And_Suffixes;
-- Given an encoded entity name in Name_Buffer, remove package body
-- suffix as described for Strip_Package_Body_Suffix, and also remove
-- all qualification, i.e. names followed by two underscores. The
-- contents of Name_Buffer is modified by this call, and on return
-- Name_Buffer and Name_Len reflect the stripped name.
-----------------------------
-- Add_Char_To_Name_Buffer --
-----------------------------
procedure Add_Char_To_Name_Buffer (C : Character) is
begin
if Name_Len < Name_Buffer'Last then
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := C;
end if;
end Add_Char_To_Name_Buffer;
----------------------------
-- Add_Nat_To_Name_Buffer --
----------------------------
procedure Add_Nat_To_Name_Buffer (V : Nat) is
begin
if V >= 10 then
Add_Nat_To_Name_Buffer (V / 10);
end if;
Add_Char_To_Name_Buffer (Character'Val (Character'Pos ('0') + V rem 10));
end Add_Nat_To_Name_Buffer;
----------------------------
-- Add_Str_To_Name_Buffer --
----------------------------
procedure Add_Str_To_Name_Buffer (S : String) is
begin
for J in S'Range loop
Add_Char_To_Name_Buffer (S (J));
end loop;
end Add_Str_To_Name_Buffer;
--------------
-- Finalize --
--------------
procedure Finalize is
Max_Chain_Length : constant := 50;
-- Max length of chains for which specific information is output
F : array (Int range 0 .. Max_Chain_Length) of Int;
-- N'th entry is number of chains of length N
Probes : Int := 0;
-- Used to compute average number of probes
Nsyms : Int := 0;
-- Number of symbols in table
begin
if Debug_Flag_H then
for J in F'Range loop
F (J) := 0;
end loop;
for J in Hash_Index_Type loop
if Hash_Table (J) = No_Name then
F (0) := F (0) + 1;
else
Write_Str ("Hash_Table (");
-- LLVM local
Write_Int (J);
Write_Str (") has ");
declare
C : Int := 1;
N : Name_Id;
S : Int;
begin
C := 0;
N := Hash_Table (J);
while N /= No_Name loop
N := Name_Entries.Table (N).Hash_Link;
C := C + 1;
end loop;
Write_Int (C);
Write_Str (" entries");
Write_Eol;
if C < Max_Chain_Length then
F (C) := F (C) + 1;
else
F (Max_Chain_Length) := F (Max_Chain_Length) + 1;
end if;
N := Hash_Table (J);
while N /= No_Name loop
S := Name_Entries.Table (N).Name_Chars_Index;
Write_Str (" ");
for J in 1 .. Name_Entries.Table (N).Name_Len loop
Write_Char (Name_Chars.Table (S + Int (J)));
end loop;
Write_Eol;
N := Name_Entries.Table (N).Hash_Link;
end loop;
end;
end if;
end loop;
Write_Eol;
for J in Int range 0 .. Max_Chain_Length loop
if F (J) /= 0 then
Write_Str ("Number of hash chains of length ");
if J < 10 then
Write_Char (' ');
end if;
Write_Int (J);
if J = Max_Chain_Length then
Write_Str (" or greater");
end if;
Write_Str (" = ");
Write_Int (F (J));
Write_Eol;
if J /= 0 then
Nsyms := Nsyms + F (J);
Probes := Probes + F (J) * (1 + J) * 100;
end if;
end if;
end loop;
Write_Eol;
Write_Str ("Average number of probes for lookup = ");
Probes := Probes / Nsyms;
Write_Int (Probes / 200);
Write_Char ('.');
Probes := (Probes mod 200) / 2;
Write_Char (Character'Val (48 + Probes / 10));
Write_Char (Character'Val (48 + Probes mod 10));
Write_Eol;
Write_Eol;
end if;
end Finalize;
-----------------------------
-- Get_Decoded_Name_String --
-----------------------------
procedure Get_Decoded_Name_String (Id : Name_Id) is
C : Character;
P : Natural;
begin
Get_Name_String (Id);
-- Quick loop to see if there is anything special to do
P := 1;
loop
if P = Name_Len then
return;
else
C := Name_Buffer (P);
exit when
C = 'U' or else
C = 'W' or else
C = 'Q' or else
C = 'O';
P := P + 1;
end if;
end loop;
-- Here we have at least some encoding that we must decode
Decode : declare
New_Len : Natural;
Old : Positive;
New_Buf : String (1 .. Name_Buffer'Last);
procedure Copy_One_Character;
-- Copy a character from Name_Buffer to New_Buf. Includes case
-- of copying a Uhh,Whhhh,WWhhhhhhhh sequence and decoding it.
function Hex (N : Natural) return Word;
-- Scans past N digits using Old pointer and returns hex value
procedure Insert_Character (C : Character);
-- Insert a new character into output decoded name
------------------------
-- Copy_One_Character --
------------------------
procedure Copy_One_Character is
C : Character;
begin
C := Name_Buffer (Old);
-- U (upper half insertion case)
if C = 'U'
and then Old < Name_Len
and then Name_Buffer (Old + 1) not in 'A' .. 'Z'
and then Name_Buffer (Old + 1) /= '_'
then
Old := Old + 1;
-- If we have upper half encoding, then we have to set an
-- appropriate wide character sequence for this character.
if Upper_Half_Encoding then
Widechar.Set_Wide (Char_Code (Hex (2)), New_Buf, New_Len);
-- For other encoding methods, upper half characters can
-- simply use their normal representation.
else
Insert_Character (Character'Val (Hex (2)));
end if;
-- WW (wide wide character insertion)
elsif C = 'W'
and then Old < Name_Len
and then Name_Buffer (Old + 1) = 'W'
then
Old := Old + 2;
Widechar.Set_Wide (Char_Code (Hex (8)), New_Buf, New_Len);
-- W (wide character insertion)
elsif C = 'W'
and then Old < Name_Len
and then Name_Buffer (Old + 1) not in 'A' .. 'Z'
and then Name_Buffer (Old + 1) /= '_'
then
Old := Old + 1;
Widechar.Set_Wide (Char_Code (Hex (4)), New_Buf, New_Len);
-- Any other character is copied unchanged
else
Insert_Character (C);
Old := Old + 1;
end if;
end Copy_One_Character;
---------
-- Hex --
---------
function Hex (N : Natural) return Word is
T : Word := 0;
C : Character;
begin
for J in 1 .. N loop
C := Name_Buffer (Old);
Old := Old + 1;
pragma Assert (C in '0' .. '9' or else C in 'a' .. 'f');
if C <= '9' then
T := 16 * T + Character'Pos (C) - Character'Pos ('0');
else -- C in 'a' .. 'f'
T := 16 * T + Character'Pos (C) - (Character'Pos ('a') - 10);
end if;
end loop;
return T;
end Hex;
----------------------
-- Insert_Character --
----------------------
procedure Insert_Character (C : Character) is
begin
New_Len := New_Len + 1;
New_Buf (New_Len) := C;
end Insert_Character;
-- Start of processing for Decode
begin
New_Len := 0;
Old := 1;
-- Loop through characters of name
while Old <= Name_Len loop
-- Case of character literal, put apostrophes around character
if Name_Buffer (Old) = 'Q'
and then Old < Name_Len
then
Old := Old + 1;
Insert_Character (''');
Copy_One_Character;
Insert_Character (''');
-- Case of operator name
elsif Name_Buffer (Old) = 'O'
and then Old < Name_Len
and then Name_Buffer (Old + 1) not in 'A' .. 'Z'
and then Name_Buffer (Old + 1) /= '_'
then
Old := Old + 1;
declare
-- This table maps the 2nd and 3rd characters of the name
-- into the required output. Two blanks means leave the
-- name alone
Map : constant String :=
"ab " & -- Oabs => "abs"
"ad+ " & -- Oadd => "+"
"an " & -- Oand => "and"
"co& " & -- Oconcat => "&"
"di/ " & -- Odivide => "/"
"eq= " & -- Oeq => "="
"ex**" & -- Oexpon => "**"
"gt> " & -- Ogt => ">"
"ge>=" & -- Oge => ">="
"le<=" & -- Ole => "<="
"lt< " & -- Olt => "<"
"mo " & -- Omod => "mod"
"mu* " & -- Omutliply => "*"
"ne/=" & -- One => "/="
"no " & -- Onot => "not"
"or " & -- Oor => "or"
"re " & -- Orem => "rem"
"su- " & -- Osubtract => "-"
"xo "; -- Oxor => "xor"
J : Integer;
begin
Insert_Character ('"');
-- Search the map. Note that this loop must terminate, if
-- not we have some kind of internal error, and a constraint
-- constraint error may be raised.
J := Map'First;
loop
exit when Name_Buffer (Old) = Map (J)
and then Name_Buffer (Old + 1) = Map (J + 1);
J := J + 4;
end loop;
-- Special operator name
if Map (J + 2) /= ' ' then
Insert_Character (Map (J + 2));
if Map (J + 3) /= ' ' then
Insert_Character (Map (J + 3));
end if;
Insert_Character ('"');
-- Skip past original operator name in input
while Old <= Name_Len
and then Name_Buffer (Old) in 'a' .. 'z'
loop
Old := Old + 1;
end loop;
-- For other operator names, leave them in lower case,
-- surrounded by apostrophes
else
-- Copy original operator name from input to output
while Old <= Name_Len
and then Name_Buffer (Old) in 'a' .. 'z'
loop
Copy_One_Character;
end loop;
Insert_Character ('"');
end if;
end;
-- Else copy one character and keep going
else
Copy_One_Character;
end if;
end loop;
-- Copy new buffer as result
Name_Len := New_Len;
Name_Buffer (1 .. New_Len) := New_Buf (1 .. New_Len);
end Decode;
end Get_Decoded_Name_String;
-------------------------------------------
-- Get_Decoded_Name_String_With_Brackets --
-------------------------------------------
procedure Get_Decoded_Name_String_With_Brackets (Id : Name_Id) is
P : Natural;
begin
-- Case of operator name, normal decoding is fine
if Name_Buffer (1) = 'O' then
Get_Decoded_Name_String (Id);
-- For character literals, normal decoding is fine
elsif Name_Buffer (1) = 'Q' then
Get_Decoded_Name_String (Id);
-- Only remaining issue is U/W/WW sequences
else
Get_Name_String (Id);
P := 1;
while P < Name_Len loop
if Name_Buffer (P + 1) in 'A' .. 'Z' then
P := P + 1;
-- Uhh encoding
elsif Name_Buffer (P) = 'U' then
for J in reverse P + 3 .. P + Name_Len loop
Name_Buffer (J + 3) := Name_Buffer (J);
end loop;
Name_Len := Name_Len + 3;
Name_Buffer (P + 3) := Name_Buffer (P + 2);
Name_Buffer (P + 2) := Name_Buffer (P + 1);
Name_Buffer (P) := '[';
Name_Buffer (P + 1) := '"';
Name_Buffer (P + 4) := '"';
Name_Buffer (P + 5) := ']';
P := P + 6;
-- WWhhhhhhhh encoding
elsif Name_Buffer (P) = 'W'
and then P + 9 <= Name_Len
and then Name_Buffer (P + 1) = 'W'
and then Name_Buffer (P + 2) not in 'A' .. 'Z'
and then Name_Buffer (P + 2) /= '_'
then
Name_Buffer (P + 12 .. Name_Len + 2) :=
Name_Buffer (P + 10 .. Name_Len);
Name_Buffer (P) := '[';
Name_Buffer (P + 1) := '"';
Name_Buffer (P + 10) := '"';
Name_Buffer (P + 11) := ']';
Name_Len := Name_Len + 2;
P := P + 12;
-- Whhhh encoding
elsif Name_Buffer (P) = 'W'
and then P < Name_Len
and then Name_Buffer (P + 1) not in 'A' .. 'Z'
and then Name_Buffer (P + 1) /= '_'
then
Name_Buffer (P + 8 .. P + Name_Len + 3) :=
Name_Buffer (P + 5 .. Name_Len);
Name_Buffer (P + 2 .. P + 5) := Name_Buffer (P + 1 .. P + 4);
Name_Buffer (P) := '[';
Name_Buffer (P + 1) := '"';
Name_Buffer (P + 6) := '"';
Name_Buffer (P + 7) := ']';
Name_Len := Name_Len + 3;
P := P + 8;
else
P := P + 1;
end if;
end loop;
end if;
end Get_Decoded_Name_String_With_Brackets;
------------------------
-- Get_Last_Two_Chars --
------------------------
procedure Get_Last_Two_Chars (N : Name_Id; C1, C2 : out Character) is
NE : Name_Entry renames Name_Entries.Table (N);
NEL : constant Int := Int (NE.Name_Len);
begin
if NEL >= 2 then
C1 := Name_Chars.Table (NE.Name_Chars_Index + NEL - 1);
C2 := Name_Chars.Table (NE.Name_Chars_Index + NEL - 0);
else
C1 := ASCII.NUL;
C2 := ASCII.NUL;
end if;
end Get_Last_Two_Chars;
---------------------
-- Get_Name_String --
---------------------
-- Procedure version leaving result in Name_Buffer, length in Name_Len
procedure Get_Name_String (Id : Name_Id) is
S : Int;
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
S := Name_Entries.Table (Id).Name_Chars_Index;
Name_Len := Natural (Name_Entries.Table (Id).Name_Len);
for J in 1 .. Name_Len loop
Name_Buffer (J) := Name_Chars.Table (S + Int (J));
end loop;
end Get_Name_String;
---------------------
-- Get_Name_String --
---------------------
-- Function version returning a string
function Get_Name_String (Id : Name_Id) return String is
S : Int;
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
S := Name_Entries.Table (Id).Name_Chars_Index;
declare
R : String (1 .. Natural (Name_Entries.Table (Id).Name_Len));
begin
for J in R'Range loop
R (J) := Name_Chars.Table (S + Int (J));
end loop;
return R;
end;
end Get_Name_String;
--------------------------------
-- Get_Name_String_And_Append --
--------------------------------
procedure Get_Name_String_And_Append (Id : Name_Id) is
S : Int;
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
S := Name_Entries.Table (Id).Name_Chars_Index;
for J in 1 .. Natural (Name_Entries.Table (Id).Name_Len) loop
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Name_Chars.Table (S + Int (J));
end loop;
end Get_Name_String_And_Append;
-------------------------
-- Get_Name_Table_Byte --
-------------------------
function Get_Name_Table_Byte (Id : Name_Id) return Byte is
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
return Name_Entries.Table (Id).Byte_Info;
end Get_Name_Table_Byte;
-------------------------
-- Get_Name_Table_Info --
-------------------------
function Get_Name_Table_Info (Id : Name_Id) return Int is
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
return Name_Entries.Table (Id).Int_Info;
end Get_Name_Table_Info;
-----------------------------------------
-- Get_Unqualified_Decoded_Name_String --
-----------------------------------------
procedure Get_Unqualified_Decoded_Name_String (Id : Name_Id) is
begin
Get_Decoded_Name_String (Id);
Strip_Qualification_And_Suffixes;
end Get_Unqualified_Decoded_Name_String;
---------------------------------
-- Get_Unqualified_Name_String --
---------------------------------
procedure Get_Unqualified_Name_String (Id : Name_Id) is
begin
Get_Name_String (Id);
Strip_Qualification_And_Suffixes;
end Get_Unqualified_Name_String;
----------
-- Hash --
----------
function Hash return Hash_Index_Type is
begin
-- For the cases of 1-12 characters, all characters participate in the
-- hash. The positioning is randomized, with the bias that characters
-- later on participate fully (i.e. are added towards the right side).
case Name_Len is
when 0 =>
return 0;
when 1 =>
return
Character'Pos (Name_Buffer (1));
when 2 =>
return ((
Character'Pos (Name_Buffer (1))) * 64 +
Character'Pos (Name_Buffer (2))) mod Hash_Num;
when 3 =>
return (((
Character'Pos (Name_Buffer (1))) * 16 +
Character'Pos (Name_Buffer (3))) * 16 +
Character'Pos (Name_Buffer (2))) mod Hash_Num;
when 4 =>
return ((((
Character'Pos (Name_Buffer (1))) * 8 +
Character'Pos (Name_Buffer (2))) * 8 +
Character'Pos (Name_Buffer (3))) * 8 +
Character'Pos (Name_Buffer (4))) mod Hash_Num;
when 5 =>
return (((((
Character'Pos (Name_Buffer (4))) * 8 +
Character'Pos (Name_Buffer (1))) * 4 +
Character'Pos (Name_Buffer (3))) * 4 +
Character'Pos (Name_Buffer (5))) * 8 +
Character'Pos (Name_Buffer (2))) mod Hash_Num;
when 6 =>
return ((((((
Character'Pos (Name_Buffer (5))) * 4 +
Character'Pos (Name_Buffer (1))) * 4 +
Character'Pos (Name_Buffer (4))) * 4 +
Character'Pos (Name_Buffer (2))) * 4 +
Character'Pos (Name_Buffer (6))) * 4 +
Character'Pos (Name_Buffer (3))) mod Hash_Num;
when 7 =>
return (((((((
Character'Pos (Name_Buffer (4))) * 4 +
Character'Pos (Name_Buffer (3))) * 4 +
Character'Pos (Name_Buffer (1))) * 4 +
Character'Pos (Name_Buffer (2))) * 2 +
Character'Pos (Name_Buffer (5))) * 2 +
Character'Pos (Name_Buffer (7))) * 2 +
Character'Pos (Name_Buffer (6))) mod Hash_Num;
when 8 =>
return ((((((((
Character'Pos (Name_Buffer (2))) * 4 +
Character'Pos (Name_Buffer (1))) * 4 +
Character'Pos (Name_Buffer (3))) * 2 +
Character'Pos (Name_Buffer (5))) * 2 +
Character'Pos (Name_Buffer (7))) * 2 +
Character'Pos (Name_Buffer (6))) * 2 +
Character'Pos (Name_Buffer (4))) * 2 +
Character'Pos (Name_Buffer (8))) mod Hash_Num;
when 9 =>
return (((((((((
Character'Pos (Name_Buffer (2))) * 4 +
Character'Pos (Name_Buffer (1))) * 4 +
Character'Pos (Name_Buffer (3))) * 4 +
Character'Pos (Name_Buffer (4))) * 2 +
Character'Pos (Name_Buffer (8))) * 2 +
Character'Pos (Name_Buffer (7))) * 2 +
Character'Pos (Name_Buffer (5))) * 2 +
Character'Pos (Name_Buffer (6))) * 2 +
Character'Pos (Name_Buffer (9))) mod Hash_Num;
when 10 =>
return ((((((((((
Character'Pos (Name_Buffer (01))) * 2 +
Character'Pos (Name_Buffer (02))) * 2 +
Character'Pos (Name_Buffer (08))) * 2 +
Character'Pos (Name_Buffer (03))) * 2 +
Character'Pos (Name_Buffer (04))) * 2 +
Character'Pos (Name_Buffer (09))) * 2 +
Character'Pos (Name_Buffer (06))) * 2 +
Character'Pos (Name_Buffer (05))) * 2 +
Character'Pos (Name_Buffer (07))) * 2 +
Character'Pos (Name_Buffer (10))) mod Hash_Num;
when 11 =>
return (((((((((((
Character'Pos (Name_Buffer (05))) * 2 +
Character'Pos (Name_Buffer (01))) * 2 +
Character'Pos (Name_Buffer (06))) * 2 +
Character'Pos (Name_Buffer (09))) * 2 +
Character'Pos (Name_Buffer (07))) * 2 +
Character'Pos (Name_Buffer (03))) * 2 +
Character'Pos (Name_Buffer (08))) * 2 +
Character'Pos (Name_Buffer (02))) * 2 +
Character'Pos (Name_Buffer (10))) * 2 +
Character'Pos (Name_Buffer (04))) * 2 +
Character'Pos (Name_Buffer (11))) mod Hash_Num;
when 12 =>
return ((((((((((((
Character'Pos (Name_Buffer (03))) * 2 +
Character'Pos (Name_Buffer (02))) * 2 +
Character'Pos (Name_Buffer (05))) * 2 +
Character'Pos (Name_Buffer (01))) * 2 +
Character'Pos (Name_Buffer (06))) * 2 +
Character'Pos (Name_Buffer (04))) * 2 +
Character'Pos (Name_Buffer (08))) * 2 +
Character'Pos (Name_Buffer (11))) * 2 +
Character'Pos (Name_Buffer (07))) * 2 +
Character'Pos (Name_Buffer (09))) * 2 +
Character'Pos (Name_Buffer (10))) * 2 +
Character'Pos (Name_Buffer (12))) mod Hash_Num;
-- Names longer than 12 characters are handled by taking the first
-- 6 odd numbered characters and the last 6 even numbered characters.
when others => declare
Even_Name_Len : constant Integer := (Name_Len) / 2 * 2;
begin
return ((((((((((((
Character'Pos (Name_Buffer (01))) * 2 +
Character'Pos (Name_Buffer (Even_Name_Len - 10))) * 2 +
Character'Pos (Name_Buffer (03))) * 2 +
Character'Pos (Name_Buffer (Even_Name_Len - 08))) * 2 +
Character'Pos (Name_Buffer (05))) * 2 +
Character'Pos (Name_Buffer (Even_Name_Len - 06))) * 2 +
Character'Pos (Name_Buffer (07))) * 2 +
Character'Pos (Name_Buffer (Even_Name_Len - 04))) * 2 +
Character'Pos (Name_Buffer (09))) * 2 +
Character'Pos (Name_Buffer (Even_Name_Len - 02))) * 2 +
Character'Pos (Name_Buffer (11))) * 2 +
Character'Pos (Name_Buffer (Even_Name_Len))) mod Hash_Num;
end;
end case;
end Hash;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Name_Chars.Init;
Name_Entries.Init;
-- Initialize entries for one character names
for C in Character loop
Name_Entries.Increment_Last;
Name_Entries.Table (Name_Entries.Last).Name_Chars_Index :=
Name_Chars.Last;
Name_Entries.Table (Name_Entries.Last).Name_Len := 1;
Name_Entries.Table (Name_Entries.Last).Hash_Link := No_Name;
Name_Entries.Table (Name_Entries.Last).Int_Info := 0;
Name_Entries.Table (Name_Entries.Last).Byte_Info := 0;
Name_Chars.Increment_Last;
Name_Chars.Table (Name_Chars.Last) := C;
Name_Chars.Increment_Last;
Name_Chars.Table (Name_Chars.Last) := ASCII.NUL;
end loop;
-- Clear hash table
for J in Hash_Index_Type loop
Hash_Table (J) := No_Name;
end loop;
end Initialize;
----------------------
-- Is_Internal_Name --
----------------------
-- Version taking an argument
function Is_Internal_Name (Id : Name_Id) return Boolean is
begin
Get_Name_String (Id);
return Is_Internal_Name;
end Is_Internal_Name;
----------------------
-- Is_Internal_Name --
----------------------
-- Version taking its input from Name_Buffer
function Is_Internal_Name return Boolean is
begin
if Name_Buffer (1) = '_'
or else Name_Buffer (Name_Len) = '_'
then
return True;
else
-- Test backwards, because we only want to test the last entity
-- name if the name we have is qualified with other entities.
for J in reverse 1 .. Name_Len loop
if Is_OK_Internal_Letter (Name_Buffer (J)) then
return True;
-- Quit if we come to terminating double underscore (note that
-- if the current character is an underscore, we know that
-- there is a previous character present, since we already
-- filtered out the case of Name_Buffer (1) = '_' above.
elsif Name_Buffer (J) = '_'
and then Name_Buffer (J - 1) = '_'
and then Name_Buffer (J - 2) /= '_'
then
return False;
end if;
end loop;
end if;
return False;
end Is_Internal_Name;
---------------------------
-- Is_OK_Internal_Letter --
---------------------------
function Is_OK_Internal_Letter (C : Character) return Boolean is
begin
return C in 'A' .. 'Z'
and then C /= 'O'
and then C /= 'Q'
and then C /= 'U'
and then C /= 'W'
and then C /= 'X';
end Is_OK_Internal_Letter;
----------------------
-- Is_Operator_Name --
----------------------
function Is_Operator_Name (Id : Name_Id) return Boolean is
S : Int;
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
S := Name_Entries.Table (Id).Name_Chars_Index;
return Name_Chars.Table (S + 1) = 'O';
end Is_Operator_Name;
--------------------
-- Length_Of_Name --
--------------------
function Length_Of_Name (Id : Name_Id) return Nat is
begin
return Int (Name_Entries.Table (Id).Name_Len);
end Length_Of_Name;
----------
-- Lock --
----------
procedure Lock is
begin
Name_Chars.Set_Last (Name_Chars.Last + Name_Chars_Reserve);
Name_Entries.Set_Last (Name_Entries.Last + Name_Entries_Reserve);
Name_Chars.Locked := True;
Name_Entries.Locked := True;
Name_Chars.Release;
Name_Entries.Release;
end Lock;
------------------------
-- Name_Chars_Address --
------------------------
function Name_Chars_Address return System.Address is
begin
return Name_Chars.Table (0)'Address;
end Name_Chars_Address;
----------------
-- Name_Enter --
----------------
function Name_Enter return Name_Id is
begin
Name_Entries.Increment_Last;
Name_Entries.Table (Name_Entries.Last).Name_Chars_Index :=
Name_Chars.Last;
Name_Entries.Table (Name_Entries.Last).Name_Len := Short (Name_Len);
Name_Entries.Table (Name_Entries.Last).Hash_Link := No_Name;
Name_Entries.Table (Name_Entries.Last).Int_Info := 0;
Name_Entries.Table (Name_Entries.Last).Byte_Info := 0;
-- Set corresponding string entry in the Name_Chars table
for J in 1 .. Name_Len loop
Name_Chars.Increment_Last;
Name_Chars.Table (Name_Chars.Last) := Name_Buffer (J);
end loop;
Name_Chars.Increment_Last;
Name_Chars.Table (Name_Chars.Last) := ASCII.NUL;
return Name_Entries.Last;
end Name_Enter;
--------------------------
-- Name_Entries_Address --
--------------------------
function Name_Entries_Address return System.Address is
begin
return Name_Entries.Table (First_Name_Id)'Address;
end Name_Entries_Address;
------------------------
-- Name_Entries_Count --
------------------------
function Name_Entries_Count return Nat is
begin
return Int (Name_Entries.Last - Name_Entries.First + 1);
end Name_Entries_Count;
---------------
-- Name_Find --
---------------
function Name_Find return Name_Id is
New_Id : Name_Id;
-- Id of entry in hash search, and value to be returned
S : Int;
-- Pointer into string table
Hash_Index : Hash_Index_Type;
-- Computed hash index
begin
-- Quick handling for one character names
if Name_Len = 1 then
return Name_Id (First_Name_Id + Character'Pos (Name_Buffer (1)));
-- Otherwise search hash table for existing matching entry
else
Hash_Index := Namet.Hash;
New_Id := Hash_Table (Hash_Index);
if New_Id = No_Name then
Hash_Table (Hash_Index) := Name_Entries.Last + 1;
else
Search : loop
if Name_Len /=
Integer (Name_Entries.Table (New_Id).Name_Len)
then
goto No_Match;
end if;
S := Name_Entries.Table (New_Id).Name_Chars_Index;
for J in 1 .. Name_Len loop
if Name_Chars.Table (S + Int (J)) /= Name_Buffer (J) then
goto No_Match;
end if;
end loop;
return New_Id;
-- Current entry in hash chain does not match
<<No_Match>>
if Name_Entries.Table (New_Id).Hash_Link /= No_Name then
New_Id := Name_Entries.Table (New_Id).Hash_Link;
else
Name_Entries.Table (New_Id).Hash_Link :=
Name_Entries.Last + 1;
exit Search;
end if;
end loop Search;
end if;
-- We fall through here only if a matching entry was not found in the
-- hash table. We now create a new entry in the names table. The hash
-- link pointing to the new entry (Name_Entries.Last+1) has been set.
Name_Entries.Increment_Last;
Name_Entries.Table (Name_Entries.Last).Name_Chars_Index :=
Name_Chars.Last;
Name_Entries.Table (Name_Entries.Last).Name_Len := Short (Name_Len);
Name_Entries.Table (Name_Entries.Last).Hash_Link := No_Name;
Name_Entries.Table (Name_Entries.Last).Int_Info := 0;
Name_Entries.Table (Name_Entries.Last).Byte_Info := 0;
-- Set corresponding string entry in the Name_Chars table
for J in 1 .. Name_Len loop
Name_Chars.Increment_Last;
Name_Chars.Table (Name_Chars.Last) := Name_Buffer (J);
end loop;
Name_Chars.Increment_Last;
Name_Chars.Table (Name_Chars.Last) := ASCII.NUL;
return Name_Entries.Last;
end if;
end Name_Find;
----------------------
-- Reset_Name_Table --
----------------------
procedure Reset_Name_Table is
begin
for J in First_Name_Id .. Name_Entries.Last loop
Name_Entries.Table (J).Int_Info := 0;
Name_Entries.Table (J).Byte_Info := 0;
end loop;
end Reset_Name_Table;
--------------------------------
-- Set_Character_Literal_Name --
--------------------------------
procedure Set_Character_Literal_Name (C : Char_Code) is
begin
Name_Buffer (1) := 'Q';
Name_Len := 1;
Store_Encoded_Character (C);
end Set_Character_Literal_Name;
-------------------------
-- Set_Name_Table_Byte --
-------------------------
procedure Set_Name_Table_Byte (Id : Name_Id; Val : Byte) is
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
Name_Entries.Table (Id).Byte_Info := Val;
end Set_Name_Table_Byte;
-------------------------
-- Set_Name_Table_Info --
-------------------------
procedure Set_Name_Table_Info (Id : Name_Id; Val : Int) is
begin
pragma Assert (Id in Name_Entries.First .. Name_Entries.Last);
Name_Entries.Table (Id).Int_Info := Val;
end Set_Name_Table_Info;
-----------------------------
-- Store_Encoded_Character --
-----------------------------
procedure Store_Encoded_Character (C : Char_Code) is
procedure Set_Hex_Chars (C : Char_Code);
-- Stores given value, which is in the range 0 .. 255, as two hex
-- digits (using lower case a-f) in Name_Buffer, incrementing Name_Len.
-------------------
-- Set_Hex_Chars --
-------------------
procedure Set_Hex_Chars (C : Char_Code) is
Hexd : constant String := "0123456789abcdef";
N : constant Natural := Natural (C);
begin
Name_Buffer (Name_Len + 1) := Hexd (N / 16 + 1);
Name_Buffer (Name_Len + 2) := Hexd (N mod 16 + 1);
Name_Len := Name_Len + 2;
end Set_Hex_Chars;
-- Start of processing for Store_Encoded_Character
begin
Name_Len := Name_Len + 1;
if In_Character_Range (C) then
declare
CC : constant Character := Get_Character (C);
begin
if CC in 'a' .. 'z' or else CC in '0' .. '9' then
Name_Buffer (Name_Len) := CC;
else
Name_Buffer (Name_Len) := 'U';
Set_Hex_Chars (C);
end if;
end;
elsif In_Wide_Character_Range (C) then
Name_Buffer (Name_Len) := 'W';
Set_Hex_Chars (C / 256);
Set_Hex_Chars (C mod 256);
else
Name_Buffer (Name_Len) := 'W';
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := 'W';
Set_Hex_Chars (C / 2 ** 24);
Set_Hex_Chars ((C / 2 ** 16) mod 256);
Set_Hex_Chars ((C / 256) mod 256);
Set_Hex_Chars (C mod 256);
end if;
end Store_Encoded_Character;
--------------------------------------
-- Strip_Qualification_And_Suffixes --
--------------------------------------
procedure Strip_Qualification_And_Suffixes is
J : Integer;
begin
-- Strip package body qualification string off end
for J in reverse 2 .. Name_Len loop
if Name_Buffer (J) = 'X' then
Name_Len := J - 1;
exit;
end if;
exit when Name_Buffer (J) /= 'b'
and then Name_Buffer (J) /= 'n'
and then Name_Buffer (J) /= 'p';
end loop;
-- Find rightmost __ or $ separator if one exists. First we position
-- to start the search. If we have a character constant, position
-- just before it, otherwise position to last character but one
if Name_Buffer (Name_Len) = ''' then
J := Name_Len - 2;
while J > 0 and then Name_Buffer (J) /= ''' loop
J := J - 1;
end loop;
else
J := Name_Len - 1;
end if;
-- Loop to search for rightmost __ or $ (homonym) separator
while J > 1 loop
-- If $ separator, homonym separator, so strip it and keep looking
if Name_Buffer (J) = '$' then
Name_Len := J - 1;
J := Name_Len - 1;
-- Else check for __ found
elsif Name_Buffer (J) = '_' and then Name_Buffer (J + 1) = '_' then
-- Found __ so see if digit follows, and if so, this is a
-- homonym separator, so strip it and keep looking.
if Name_Buffer (J + 2) in '0' .. '9' then
Name_Len := J - 1;
J := Name_Len - 1;
-- If not a homonym separator, then we simply strip the
-- separator and everything that precedes it, and we are done
else
Name_Buffer (1 .. Name_Len - J - 1) :=
Name_Buffer (J + 2 .. Name_Len);
Name_Len := Name_Len - J - 1;
exit;
end if;
else
J := J - 1;
end if;
end loop;
end Strip_Qualification_And_Suffixes;
---------------
-- Tree_Read --
---------------
procedure Tree_Read is
begin
Name_Chars.Tree_Read;
Name_Entries.Tree_Read;
Tree_Read_Data
(Hash_Table'Address,
Hash_Table'Length * (Hash_Table'Component_Size / Storage_Unit));
end Tree_Read;
----------------
-- Tree_Write --
----------------
procedure Tree_Write is
begin
Name_Chars.Tree_Write;
Name_Entries.Tree_Write;
Tree_Write_Data
(Hash_Table'Address,
Hash_Table'Length * (Hash_Table'Component_Size / Storage_Unit));
end Tree_Write;
------------
-- Unlock --
------------
procedure Unlock is
begin
Name_Chars.Set_Last (Name_Chars.Last - Name_Chars_Reserve);
Name_Entries.Set_Last (Name_Entries.Last - Name_Entries_Reserve);
Name_Chars.Locked := False;
Name_Entries.Locked := False;
Name_Chars.Release;
Name_Entries.Release;
end Unlock;
--------
-- wn --
--------
procedure wn (Id : Name_Id) is
begin
Write_Name (Id);
Write_Eol;
end wn;
----------------
-- Write_Name --
----------------
procedure Write_Name (Id : Name_Id) is
begin
if Id >= First_Name_Id then
Get_Name_String (Id);
Write_Str (Name_Buffer (1 .. Name_Len));
end if;
end Write_Name;
------------------------
-- Write_Name_Decoded --
------------------------
procedure Write_Name_Decoded (Id : Name_Id) is
begin
if Id >= First_Name_Id then
Get_Decoded_Name_String (Id);
Write_Str (Name_Buffer (1 .. Name_Len));
end if;
end Write_Name_Decoded;
end Namet;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . R E G I S T R Y --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2019, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Interfaces.C;
with System;
with GNAT.Directory_Operations;
package body GNAT.Registry is
use System;
------------------------------
-- Binding to the Win32 API --
------------------------------
subtype LONG is Interfaces.C.long;
subtype ULONG is Interfaces.C.unsigned_long;
subtype DWORD is ULONG;
type PULONG is access all ULONG;
subtype PDWORD is PULONG;
subtype LPDWORD is PDWORD;
subtype Error_Code is LONG;
subtype REGSAM is LONG;
type PHKEY is access all HKEY;
ERROR_SUCCESS : constant Error_Code := 0;
REG_SZ : constant := 1;
REG_EXPAND_SZ : constant := 2;
function RegCloseKey (Key : HKEY) return LONG;
pragma Import (Stdcall, RegCloseKey, "RegCloseKey");
function RegCreateKeyEx
(Key : HKEY;
lpSubKey : Address;
Reserved : DWORD;
lpClass : Address;
dwOptions : DWORD;
samDesired : REGSAM;
lpSecurityAttributes : Address;
phkResult : PHKEY;
lpdwDisposition : LPDWORD)
return LONG;
pragma Import (Stdcall, RegCreateKeyEx, "RegCreateKeyExA");
function RegDeleteKey
(Key : HKEY;
lpSubKey : Address) return LONG;
pragma Import (Stdcall, RegDeleteKey, "RegDeleteKeyA");
function RegDeleteValue
(Key : HKEY;
lpValueName : Address) return LONG;
pragma Import (Stdcall, RegDeleteValue, "RegDeleteValueA");
function RegEnumValue
(Key : HKEY;
dwIndex : DWORD;
lpValueName : Address;
lpcbValueName : LPDWORD;
lpReserved : LPDWORD;
lpType : LPDWORD;
lpData : Address;
lpcbData : LPDWORD) return LONG;
pragma Import (Stdcall, RegEnumValue, "RegEnumValueA");
function RegOpenKeyEx
(Key : HKEY;
lpSubKey : Address;
ulOptions : DWORD;
samDesired : REGSAM;
phkResult : PHKEY) return LONG;
pragma Import (Stdcall, RegOpenKeyEx, "RegOpenKeyExA");
function RegQueryValueEx
(Key : HKEY;
lpValueName : Address;
lpReserved : LPDWORD;
lpType : LPDWORD;
lpData : Address;
lpcbData : LPDWORD) return LONG;
pragma Import (Stdcall, RegQueryValueEx, "RegQueryValueExA");
function RegSetValueEx
(Key : HKEY;
lpValueName : Address;
Reserved : DWORD;
dwType : DWORD;
lpData : Address;
cbData : DWORD) return LONG;
pragma Import (Stdcall, RegSetValueEx, "RegSetValueExA");
function RegEnumKey
(Key : HKEY;
dwIndex : DWORD;
lpName : Address;
cchName : DWORD) return LONG;
pragma Import (Stdcall, RegEnumKey, "RegEnumKeyA");
---------------------
-- Local Constants --
---------------------
Max_Key_Size : constant := 1_024;
-- Maximum number of characters for a registry key
Max_Value_Size : constant := 2_048;
-- Maximum number of characters for a key's value
-----------------------
-- Local Subprograms --
-----------------------
function To_C_Mode (Mode : Key_Mode) return REGSAM;
-- Returns the Win32 mode value for the Key_Mode value
procedure Check_Result (Result : LONG; Message : String);
-- Checks value Result and raise the exception Registry_Error if it is not
-- equal to ERROR_SUCCESS. Message and the error value (Result) is added
-- to the exception message.
------------------
-- Check_Result --
------------------
procedure Check_Result (Result : LONG; Message : String) is
use type LONG;
begin
if Result /= ERROR_SUCCESS then
raise Registry_Error with
Message & " (" & LONG'Image (Result) & ')';
end if;
end Check_Result;
---------------
-- Close_Key --
---------------
procedure Close_Key (Key : HKEY) is
Result : LONG;
begin
Result := RegCloseKey (Key);
Check_Result (Result, "Close_Key");
end Close_Key;
----------------
-- Create_Key --
----------------
function Create_Key
(From_Key : HKEY;
Sub_Key : String;
Mode : Key_Mode := Read_Write) return HKEY
is
REG_OPTION_NON_VOLATILE : constant := 16#0#;
C_Sub_Key : constant String := Sub_Key & ASCII.NUL;
C_Class : constant String := "" & ASCII.NUL;
C_Mode : constant REGSAM := To_C_Mode (Mode);
New_Key : aliased HKEY;
Result : LONG;
Dispos : aliased DWORD;
begin
Result :=
RegCreateKeyEx
(From_Key,
C_Sub_Key (C_Sub_Key'First)'Address,
0,
C_Class (C_Class'First)'Address,
REG_OPTION_NON_VOLATILE,
C_Mode,
Null_Address,
New_Key'Unchecked_Access,
Dispos'Unchecked_Access);
Check_Result (Result, "Create_Key " & Sub_Key);
return New_Key;
end Create_Key;
----------------
-- Delete_Key --
----------------
procedure Delete_Key (From_Key : HKEY; Sub_Key : String) is
C_Sub_Key : constant String := Sub_Key & ASCII.NUL;
Result : LONG;
begin
Result := RegDeleteKey (From_Key, C_Sub_Key (C_Sub_Key'First)'Address);
Check_Result (Result, "Delete_Key " & Sub_Key);
end Delete_Key;
------------------
-- Delete_Value --
------------------
procedure Delete_Value (From_Key : HKEY; Sub_Key : String) is
C_Sub_Key : constant String := Sub_Key & ASCII.NUL;
Result : LONG;
begin
Result := RegDeleteValue (From_Key, C_Sub_Key (C_Sub_Key'First)'Address);
Check_Result (Result, "Delete_Value " & Sub_Key);
end Delete_Value;
-------------------
-- For_Every_Key --
-------------------
procedure For_Every_Key
(From_Key : HKEY;
Recursive : Boolean := False)
is
procedure Recursive_For_Every_Key
(From_Key : HKEY;
Recursive : Boolean := False;
Quit : in out Boolean);
-----------------------------
-- Recursive_For_Every_Key --
-----------------------------
procedure Recursive_For_Every_Key
(From_Key : HKEY;
Recursive : Boolean := False;
Quit : in out Boolean)
is
use type LONG;
use type ULONG;
Index : ULONG := 0;
Result : LONG;
Sub_Key : Interfaces.C.char_array (1 .. Max_Key_Size);
pragma Warnings (Off, Sub_Key);
Size_Sub_Key : aliased ULONG;
Sub_Hkey : HKEY;
function Current_Name return String;
------------------
-- Current_Name --
------------------
function Current_Name return String is
begin
return Interfaces.C.To_Ada (Sub_Key);
end Current_Name;
-- Start of processing for Recursive_For_Every_Key
begin
loop
Size_Sub_Key := Sub_Key'Length;
Result :=
RegEnumKey
(From_Key, Index, Sub_Key (1)'Address, Size_Sub_Key);
exit when not (Result = ERROR_SUCCESS);
Sub_Hkey := Open_Key (From_Key, Interfaces.C.To_Ada (Sub_Key));
Action (Natural (Index) + 1, Sub_Hkey, Current_Name, Quit);
if not Quit and then Recursive then
Recursive_For_Every_Key (Sub_Hkey, True, Quit);
end if;
Close_Key (Sub_Hkey);
exit when Quit;
Index := Index + 1;
end loop;
end Recursive_For_Every_Key;
-- Local Variables
Quit : Boolean := False;
-- Start of processing for For_Every_Key
begin
Recursive_For_Every_Key (From_Key, Recursive, Quit);
end For_Every_Key;
-------------------------
-- For_Every_Key_Value --
-------------------------
procedure For_Every_Key_Value
(From_Key : HKEY;
Expand : Boolean := False)
is
use GNAT.Directory_Operations;
use type LONG;
use type ULONG;
Index : ULONG := 0;
Result : LONG;
Sub_Key : String (1 .. Max_Key_Size);
pragma Warnings (Off, Sub_Key);
Value : String (1 .. Max_Value_Size);
pragma Warnings (Off, Value);
Size_Sub_Key : aliased ULONG;
Size_Value : aliased ULONG;
Type_Sub_Key : aliased DWORD;
Quit : Boolean;
begin
loop
Size_Sub_Key := Sub_Key'Length;
Size_Value := Value'Length;
Result :=
RegEnumValue
(From_Key, Index,
Sub_Key (1)'Address,
Size_Sub_Key'Unchecked_Access,
null,
Type_Sub_Key'Unchecked_Access,
Value (1)'Address,
Size_Value'Unchecked_Access);
exit when not (Result = ERROR_SUCCESS);
Quit := False;
if Type_Sub_Key = REG_EXPAND_SZ and then Expand then
Action
(Natural (Index) + 1,
Sub_Key (1 .. Integer (Size_Sub_Key)),
Directory_Operations.Expand_Path
(Value (1 .. Integer (Size_Value) - 1),
Directory_Operations.DOS),
Quit);
elsif Type_Sub_Key = REG_SZ or else Type_Sub_Key = REG_EXPAND_SZ then
Action
(Natural (Index) + 1,
Sub_Key (1 .. Integer (Size_Sub_Key)),
Value (1 .. Integer (Size_Value) - 1),
Quit);
end if;
exit when Quit;
Index := Index + 1;
end loop;
end For_Every_Key_Value;
----------------
-- Key_Exists --
----------------
function Key_Exists
(From_Key : HKEY;
Sub_Key : String) return Boolean
is
New_Key : HKEY;
begin
New_Key := Open_Key (From_Key, Sub_Key);
Close_Key (New_Key);
-- We have been able to open the key so it exists
return True;
exception
when Registry_Error =>
-- An error occurred, the key was not found
return False;
end Key_Exists;
--------------
-- Open_Key --
--------------
function Open_Key
(From_Key : HKEY;
Sub_Key : String;
Mode : Key_Mode := Read_Only) return HKEY
is
C_Sub_Key : constant String := Sub_Key & ASCII.NUL;
C_Mode : constant REGSAM := To_C_Mode (Mode);
New_Key : aliased HKEY;
Result : LONG;
begin
Result :=
RegOpenKeyEx
(From_Key,
C_Sub_Key (C_Sub_Key'First)'Address,
0,
C_Mode,
New_Key'Unchecked_Access);
Check_Result (Result, "Open_Key " & Sub_Key);
return New_Key;
end Open_Key;
-----------------
-- Query_Value --
-----------------
function Query_Value
(From_Key : HKEY;
Sub_Key : String;
Expand : Boolean := False) return String
is
use GNAT.Directory_Operations;
use type ULONG;
Value : String (1 .. Max_Value_Size);
pragma Warnings (Off, Value);
Size_Value : aliased ULONG;
Type_Value : aliased DWORD;
C_Sub_Key : constant String := Sub_Key & ASCII.NUL;
Result : LONG;
begin
Size_Value := Value'Length;
Result :=
RegQueryValueEx
(From_Key,
C_Sub_Key (C_Sub_Key'First)'Address,
null,
Type_Value'Unchecked_Access,
Value (Value'First)'Address,
Size_Value'Unchecked_Access);
Check_Result (Result, "Query_Value " & Sub_Key & " key");
if Type_Value = REG_EXPAND_SZ and then Expand then
return Directory_Operations.Expand_Path
(Value (1 .. Integer (Size_Value - 1)),
Directory_Operations.DOS);
else
return Value (1 .. Integer (Size_Value - 1));
end if;
end Query_Value;
---------------
-- Set_Value --
---------------
procedure Set_Value
(From_Key : HKEY;
Sub_Key : String;
Value : String;
Expand : Boolean := False)
is
C_Sub_Key : constant String := Sub_Key & ASCII.NUL;
C_Value : constant String := Value & ASCII.NUL;
Value_Type : DWORD;
Result : LONG;
begin
Value_Type := (if Expand then REG_EXPAND_SZ else REG_SZ);
Result :=
RegSetValueEx
(From_Key,
C_Sub_Key (C_Sub_Key'First)'Address,
0,
Value_Type,
C_Value (C_Value'First)'Address,
C_Value'Length);
Check_Result (Result, "Set_Value " & Sub_Key & " key");
end Set_Value;
---------------
-- To_C_Mode --
---------------
function To_C_Mode (Mode : Key_Mode) return REGSAM is
use type REGSAM;
KEY_READ : constant := 16#20019#;
KEY_WRITE : constant := 16#20006#;
KEY_WOW64_64KEY : constant := 16#00100#;
KEY_WOW64_32KEY : constant := 16#00200#;
begin
case Mode is
when Read_Only =>
return KEY_READ + KEY_WOW64_32KEY;
when Read_Write =>
return KEY_READ + KEY_WRITE + KEY_WOW64_32KEY;
when Read_Only_64 =>
return KEY_READ + KEY_WOW64_64KEY;
when Read_Write_64 =>
return KEY_READ + KEY_WRITE + KEY_WOW64_64KEY;
end case;
end To_C_Mode;
end GNAT.Registry;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.