content stringlengths 23 1.05M |
|---|
-- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.FICR is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Pre-programmed factory code present.
type PPFC_PPFC_Field is
(-- Present.
Present,
-- Not present.
Notpresent)
with Size => 8;
for PPFC_PPFC_Field use
(Present => 0,
Notpresent => 255);
-- Pre-programmed factory code present.
type PPFC_Register is record
-- Read-only. Pre-programmed factory code present.
PPFC : PPFC_PPFC_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PPFC_Register use record
PPFC at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Deprecated array of size of RAM block in bytes. This name is kept for backward compatinility purposes. Use SIZERAMBLOCKS instead.
-- Deprecated array of size of RAM block in bytes. This name is kept for
-- backward compatinility purposes. Use SIZERAMBLOCKS instead.
type SIZERAMBLOCK_Registers is array (0 .. 3) of HAL.UInt32;
subtype CONFIGID_HWID_Field is HAL.UInt16;
subtype CONFIGID_FWID_Field is HAL.UInt16;
-- Configuration identifier.
type CONFIGID_Register is record
-- Read-only. Hardware Identification Number.
HWID : CONFIGID_HWID_Field;
-- Read-only. Firmware Identification Number pre-loaded into the flash.
FWID : CONFIGID_FWID_Field;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CONFIGID_Register use record
HWID at 0 range 0 .. 15;
FWID at 0 range 16 .. 31;
end record;
-- Device identifier.
-- Device identifier.
type DEVICEID_Registers is array (0 .. 1) of HAL.UInt32;
-- Encryption root.
-- Encryption root.
type ER_Registers is array (0 .. 3) of HAL.UInt32;
-- Identity root.
-- Identity root.
type IR_Registers is array (0 .. 3) of HAL.UInt32;
-- Device address type.
type DEVICEADDRTYPE_DEVICEADDRTYPE_Field is
(-- Public address.
Public,
-- Random address.
Random)
with Size => 1;
for DEVICEADDRTYPE_DEVICEADDRTYPE_Field use
(Public => 0,
Random => 1);
-- Device address type.
type DEVICEADDRTYPE_Register is record
-- Read-only. Device address type.
DEVICEADDRTYPE : DEVICEADDRTYPE_DEVICEADDRTYPE_Field;
-- unspecified
Reserved_1_31 : HAL.UInt31;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DEVICEADDRTYPE_Register use record
DEVICEADDRTYPE at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Device address.
-- Device address.
type DEVICEADDR_Registers is array (0 .. 1) of HAL.UInt32;
-- Override default values for NRF_1Mbit mode.
type OVERRIDEEN_NRF_1MBIT_Field is
(-- Override the default values for NRF_1Mbit mode.
Override,
-- Do not override the default values for NRF_1Mbit mode.
Notoverride)
with Size => 1;
for OVERRIDEEN_NRF_1MBIT_Field use
(Override => 0,
Notoverride => 1);
-- Override default values for BLE_1Mbit mode.
type OVERRIDEEN_BLE_1MBIT_Field is
(-- Override the default values for BLE_1Mbit mode.
Override,
-- Do not override the default values for BLE_1Mbit mode.
Notoverride)
with Size => 1;
for OVERRIDEEN_BLE_1MBIT_Field use
(Override => 0,
Notoverride => 1);
-- Radio calibration override enable.
type OVERRIDEEN_Register is record
-- Read-only. Override default values for NRF_1Mbit mode.
NRF_1MBIT : OVERRIDEEN_NRF_1MBIT_Field;
-- unspecified
Reserved_1_2 : HAL.UInt2;
-- Read-only. Override default values for BLE_1Mbit mode.
BLE_1MBIT : OVERRIDEEN_BLE_1MBIT_Field;
-- unspecified
Reserved_4_31 : HAL.UInt28;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OVERRIDEEN_Register use record
NRF_1MBIT at 0 range 0 .. 0;
Reserved_1_2 at 0 range 1 .. 2;
BLE_1MBIT at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Override values for the OVERRIDEn registers in RADIO for NRF_1Mbit mode.
-- Override values for the OVERRIDEn registers in RADIO for NRF_1Mbit mode.
type NRF_1MBIT_Registers is array (0 .. 4) of HAL.UInt32;
-- Override values for the OVERRIDEn registers in RADIO for BLE_1Mbit mode.
-- Override values for the OVERRIDEn registers in RADIO for BLE_1Mbit mode.
type BLE_1MBIT_Registers is array (0 .. 4) of HAL.UInt32;
-----------------
-- Peripherals --
-----------------
type FICR_Disc is
(S,
Default);
-- Factory Information Configuration.
type FICR_Peripheral
(Discriminent : FICR_Disc := S)
is record
-- Code memory page size in bytes.
CODEPAGESIZE : aliased HAL.UInt32;
-- Code memory size in pages.
CODESIZE : aliased HAL.UInt32;
-- Length of code region 0 in bytes.
CLENR0 : aliased HAL.UInt32;
-- Pre-programmed factory code present.
PPFC : aliased PPFC_Register;
-- Number of individualy controllable RAM blocks.
NUMRAMBLOCK : aliased HAL.UInt32;
-- Configuration identifier.
CONFIGID : aliased CONFIGID_Register;
-- Device identifier.
DEVICEID : aliased DEVICEID_Registers;
-- Encryption root.
ER : aliased ER_Registers;
-- Identity root.
IR : aliased IR_Registers;
-- Device address type.
DEVICEADDRTYPE : aliased DEVICEADDRTYPE_Register;
-- Device address.
DEVICEADDR : aliased DEVICEADDR_Registers;
-- Radio calibration override enable.
OVERRIDEEN : aliased OVERRIDEEN_Register;
-- Override values for the OVERRIDEn registers in RADIO for NRF_1Mbit
-- mode.
NRF_1MBIT : aliased NRF_1MBIT_Registers;
-- Override values for the OVERRIDEn registers in RADIO for BLE_1Mbit
-- mode.
BLE_1MBIT : aliased BLE_1MBIT_Registers;
case Discriminent is
when S =>
-- Size of RAM blocks in bytes.
SIZERAMBLOCKS : aliased HAL.UInt32;
when Default =>
-- Deprecated array of size of RAM block in bytes. This name is
-- kept for backward compatinility purposes. Use SIZERAMBLOCKS
-- instead.
SIZERAMBLOCK : aliased SIZERAMBLOCK_Registers;
end case;
end record
with Unchecked_Union, Volatile;
for FICR_Peripheral use record
CODEPAGESIZE at 16#10# range 0 .. 31;
CODESIZE at 16#14# range 0 .. 31;
CLENR0 at 16#28# range 0 .. 31;
PPFC at 16#2C# range 0 .. 31;
NUMRAMBLOCK at 16#34# range 0 .. 31;
CONFIGID at 16#5C# range 0 .. 31;
DEVICEID at 16#60# range 0 .. 63;
ER at 16#80# range 0 .. 127;
IR at 16#90# range 0 .. 127;
DEVICEADDRTYPE at 16#A0# range 0 .. 31;
DEVICEADDR at 16#A4# range 0 .. 63;
OVERRIDEEN at 16#AC# range 0 .. 31;
NRF_1MBIT at 16#B0# range 0 .. 159;
BLE_1MBIT at 16#EC# range 0 .. 159;
SIZERAMBLOCKS at 16#38# range 0 .. 31;
SIZERAMBLOCK at 16#38# range 0 .. 127;
end record;
-- Factory Information Configuration.
FICR_Periph : aliased FICR_Peripheral
with Import, Address => FICR_Base;
end NRF_SVD.FICR;
|
with NPC_PC; use NPC_PC;
package Enemy_BST is
-------------------------------
-- Name: Jon Spohn
-- David Rogina
-- Enemy Package Specification
-------------------------------
type EnemyTree is private;
--Connect enemy node to right of parent
procedure ConnectRight (T : IN OUT EnemyTree; E : EnemyClass);
--Connect enemy node to left of parent
procedure ConnectLeft (T : IN OUT EnemyTree; E : EnemyClass);
--Make Enemy
function MakeNode (E : EnemyClass) RETURN EnemyTree;
--Initialize enemy tree
procedure Initialize (T: IN OUT EnemyTree);
--Insert enemy node into tree
procedure Insert (T : IN OUT EnemyTree; E : EnemyClass);
--Search enemy tree for specific enemy coordinates
FUNCTION Search (T: EnemyTree; X : integer; Y: integer) RETURN EnemyClass;
function GetLeft(ET: EnemyTree) Return EnemyTree;
function GetRight(ET : EnemyTree) return EnemyTree;
function GetEnemy(ET : EnemyTree) return EnemyClass;
function IsNull(ET : EnemyTree) return integer;
--Find smallest leaf of parent node
FUNCTION FindSmallest (T : EnemyTree) RETURN EnemyTree;
--Delete enemy node
PROCEDURE Delete (T : IN OUT EnemyTree; K : IN EnemyClass);
private
TYPE BinaryTreeNode;
TYPE EnemyTree IS ACCESS BinaryTreeNode;
TYPE BinaryTreeNode IS RECORD
Enemy : EnemyClass;
Left : EnemyTree := NULL;
Right : EnemyTree := NULL;
END RECORD;
end Enemy_BST;
|
with Ada.IO_Exceptions;
private with Ada.Finalization;
package Web.Lock_Files is
function Lock (
Name : String;
Force : Duration := 0.0;
Timeout : Duration := 3.0;
Retry_Interval : Duration := 1.0;
Forced : access Boolean := null)
return Boolean;
-- raise Lock_Error when failure
procedure Lock (
Name : in String;
Force : in Duration := 0.0;
Timeout : in Duration := 3.0;
Retry_Interval : in Duration := 1.0;
Forced : access Boolean := null);
-- delete lock file
procedure Unlock (Name : in String);
-- RAII-style locking
type Lock_Type (<>) is limited private;
pragma Unreferenced_Objects (Lock_Type);
function Lock (
Name : String;
Force : Duration := 0.0;
Timeout : Duration := 3.0;
Retry_Interval : Duration := 1.0)
return Lock_Type;
function Forced (Object : Lock_Type) return Boolean;
-- explicit operation
procedure Unlock (Object : in out Lock_Type);
Name_Error : exception
renames Ada.IO_Exceptions.Name_Error;
Use_Error : exception
renames Ada.IO_Exceptions.Use_Error;
Lock_Error : exception;
private
type Lock_Type (Name_Length : Natural) is
new Ada.Finalization.Limited_Controlled
with record
Locked : Boolean;
Forced : aliased Boolean;
Name : String (1 .. Name_Length);
end record;
overriding procedure Finalize (Object : in out Lock_Type);
end Web.Lock_Files;
|
------------------------------------------------------------------------------
-- --
-- Internet Protocol Suite Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.IO_Exceptions;
with INET.IP.Lookup;
with INET.Internal.UNIX_Sockets;
package body INET.TCP.TLS is
End_Error: exception renames Ada.IO_Exceptions.End_Error;
--
-- TLS_Connection
--
-------------
-- Secured --
-------------
function Secured (Connection: TLS_Connection) return Boolean is
(Connection.TLS_Go);
----------
-- Read --
----------
procedure Receive_Immediate_Wrapper
(Connection: in out TLS_Connection;
Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset;
Status : out INET.Internal.UNIX_Sockets.Operation_Status;
Errno : out Interfaces.C.int)
with Inline is
use INET.Internal.UNIX_Sockets;
begin
if not Connection.TLS_Go then
raise Program_Error with
"Attempt to Read from an unsecured TLS_Connection";
elsif Connection.Read_Down then
raise End_Error with "TLS: Read direction has been shutdown";
end if;
Connection.Context.TLS_Receive_Immediate
(Buffer => Buffer,
Last => Last);
Status := OK;
Errno := 0;
-- These are really specific to the "standard" implementation in INET.TCP
-- which we are borrowing. In the case of TLS, if something goes wrong,
-- it is usually pretty catestrophic, so we just propegate the exception
-- as it arrives. If we get here, everything appears to be normal.
end Receive_Immediate_Wrapper;
----------------------------------------------------------------------
procedure Read_Actual is new Generic_Read
(Connection_Type => TLS_Connection,
Connection_Receive_Immediate => Receive_Immediate_Wrapper);
procedure Read (Stream: in out TLS_Connection;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
renames Read_Actual;
--------------------
-- Read_Immediate --
--------------------
procedure Read_Immediate (Stream: in out TLS_Connection;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is begin
if not Stream.TLS_Go then
raise Program_Error with
"Attempt to Read from an unsecured TLS_Connection";
elsif Stream.Read_Down then
raise End_Error with "TLS: Read direction has been shutdown";
end if;
Stream.Context.TLS_Receive_Immediate (Buffer => Item,
Last => Last);
end Read_Immediate;
-----------
-- Write --
-----------
procedure Send_Immediate_Wrapper
(Connection: in out TLS_Connection;
Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Status : out INET.Internal.UNIX_Sockets.Operation_Status;
Errno : out Interfaces.C.int)
with Inline is
use INET.Internal.UNIX_Sockets;
begin
if not Connection.TLS_Go then
raise Program_Error with
"Attempt to Write to an unsecured TLS_Connection";
elsif Connection.Write_Down then
raise End_Error with "TLS: Write direction has been shutdown";
end if;
Connection.Context.TLS_Send_Immediate
(Buffer => Buffer,
Last => Last);
Status := OK;
Errno := 0;
-- These are really specific to the "standard" implementation in INET.TCP
-- which we are borrowing. In the case of TLS, if something goes wrong,
-- it is usually pretty catestrophic, so we just propegate the exception
-- as it arrives. If we get here, everything appears to be normal.
end Send_Immediate_Wrapper;
----------------------------------------------------------------------
procedure Write_Actual is new Generic_Write
(Connection_Type => TLS_Connection,
Connection_Send_Immediate => Send_Immediate_Wrapper);
procedure Write (Stream: in out TLS_Connection;
Item : in Stream_Element_Array)
renames Write_Actual;
---------------------
-- Write_Immediate --
---------------------
procedure Write_Immediate (Stream: in out TLS_Connection;
Item : in Stream_Element_Array;
Last : out Stream_Element_Offset)
is begin
if not Stream.TLS_Go then
raise Program_Error with
"Attempt to Write to an unsecured TLS_Connection";
elsif Stream.Write_Down then
raise End_Error with "TLS: Write direction has been shutdown";
end if;
Stream.Context.TLS_Send_Immediate (Buffer => Item,
Last => Last);
end Write_Immediate;
--------------
-- Shutdown --
--------------
procedure Shutdown (Connection: in out TLS_Connection) is
begin
Connection.Context.Shutdown;
TCP_Connection(Connection).Shutdown;
Connection.TLS_Go := False;
Connection.Read_Down := True;
Connection.Write_Down := True;
exception
when TLS_Error => null;
-- Sometimes the remote peer closes the connection without a close
-- notify. We do not want to propegate this out when we shutdown
end Shutdown;
-------------------
-- Shutdown_Read --
-------------------
procedure Shutdown_Read (Connection: in out TLS_Connection) is
begin
if Connection.Write_Down then
Connection.Shutdown;
else
Connection.Read_Down := True;
end if;
end Shutdown_Read;
--------------------
-- Shutdown_Write --
--------------------
procedure Shutdown_Write (Connection: in out TLS_Connection) is
begin
if Connection.Read_Down then
Connection.Shutdown;
else
Connection.Write_Down := True;
end if;
end Shutdown_Write;
--
-- TLS_Client_Connection
--
-------------
-- Connect --
-------------
procedure Connect_Actual (Connection : in out TLS_Client_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port;
Server_Name: in String)
with Inline is
begin
Connection.Shutdown;
TCP_Connection (Connection).Connect (Address, Port);
Connection.TLS_Go := False;
Connection.Read_Down := False;
Connection.Write_Down := False;
Connection.Secure (Server_Name);
exception
when others =>
Connection.Shutdown;
raise;
end Connect_Actual;
----------------------------------------------------------------------
procedure Connect (Connection: in out TLS_Client_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port)
is begin
raise Program_Error with
"TLS client connections must provide a host name for the remote peer.";
end;
----------------------------------------------------------------------
procedure Connect (Connection : in out TLS_Client_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port;
Server_Name: in String)
is begin
if Server_Name'Length = 0 then
raise Constraint_Error with
"SNI Server name must not be an empty string.";
end if;
Connect_Actual (Connection, Address, Port, Server_Name);
end;
----------------------------------------------------------------------
overriding
procedure Connect (Connection: in out TLS_Client_Connection;
Host_Name : in String;
Port : in TCP_Port)
is
use INET.IP.Lookup;
Query : IP_Lookup;
Result: IP_Lookup_Entry;
begin
Query.Lookup (Host_Name => Host_Name,
Protocol => Proto_TCP);
if not Query.Has_More_Entries then
raise TCP_Lookup_Failed with "Lookup of host """
& Host_Name & """ failed.";
end if;
Query.Pop (Result);
Connection.Connect (Address => Result.Address,
Port => Port,
Server_Name => Host_Name);
end Connect;
----------------------------------------------------------------------
overriding
procedure Connect (Connection : in out TLS_Client_Connection;
Host_Name : in String;
Port : in TCP_Port;
Version : in IP.IP_Version)
is
use INET.IP.Lookup;
Query : IP_Lookup;
Result: IP_Lookup_Entry;
begin
Query.Lookup (Host_Name => Host_Name,
Protocol => Proto_TCP,
Version => Version);
if not Query.Has_More_Entries then
raise TCP_Lookup_Failed with "Lookup of host """
& Host_Name & """ failed.";
end if;
Query.Pop (Result);
Connection.Connect (Address => Result.Address,
Port => Port,
Server_Name => Host_Name);
end Connect;
------------
-- Secure --
------------
procedure Secure
(Connection : in out TLS_Client_Connection;
Server_Name: in String)
is begin
if Server_Name'Length = 0 then
raise Constraint_Error with
"SNI Server name must not be an empty string.";
elsif Connection.Write_Down and Connection.Read_Down then
raise Program_Error with
"Secure cannot be invoked on a shutdown connection.";
elsif Connection.TLS_Go then
Connection.Context.Handshake (Socket => Connection.Socket,
Timeout => Explicit_Handshake_Timeout);
else
pragma Assert (not Connection.Context.Available);
if Server_Name'Length > 0 then
Connection.Context.Establish
(Configuration => Connection.Configuration.all,
Server_Name => Server_Name,
Socket => Connection.Socket,
Timeout => Explicit_Handshake_Timeout);
else
Connection.Context.Establish
(Configuration => Connection.Configuration.all,
Socket => Connection.Socket,
Timeout => Explicit_Handshake_Timeout);
end if;
Connection.TLS_Go := True;
Connection.Read_Down := False;
Connection.Write_Down := False;
end if;
exception
when others =>
Connection.Shutdown;
raise;
end Secure;
--
-- TLS_Server_Connection
--
-------------
-- Connect --
-------------
procedure No_Connect with Inline, No_Return is
begin
raise Program_Error with
"Connect not allowed on TLS_Server_Connection objects.";
end;
----------------------------------------------------------------------
procedure Connect (Connection: in out TLS_Server_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port)
is begin
No_Connect;
end;
----------------------------------------------------------------------
procedure Connect (Connection: in out TLS_Server_Connection;
Host_Name : in String;
Port : in TCP_Port)
is begin
No_Connect;
end;
----------------------------------------------------------------------
procedure Connect (Connection : in out TLS_Server_Connection;
Host_Name : in String;
Port : in TCP_Port;
Version : in IP.IP_Version)
is begin
No_Connect;
end;
------------
-- Secure --
------------
procedure Secure (Connection : in out TLS_Server_Connection;
Configuration: in TLS_Server_Configuration'Class)
is
-- This one is a bit unusual, since we need to make a single-use
-- TLS_Listener_Context, since libtls needs that to generate a
-- context for a server-side connection. This is part of the reason
-- why already Secured TLS_Server_Connections are not allowed.
--
-- Normally, with a TLS_Listener.Dequeue, we'd use that as the
-- listener.
--
-- This Secure is specifically here to allow for negotiated upgrades
-- to TLS, such as in SMTP with STARTTLS
Source_Context: INET.Internal.TLS.TLS_Listener_Context;
begin
if Connection.Write_Down and Connection.Read_Down then
raise Program_Error with
"Secure cannot be invoked on a shutdown connection.";
elsif Connection.TLS_Go then
raise Program_Error with
"Secure cannot be invoked on Secured TLS_Server_Connection "
& "objects. ";
end if;
Source_Context.Configure (Configuration);
Connection.Context.Establish
(Listener_Context => Source_Context,
Socket => Connection.Socket,
Timeout => Explicit_Handshake_Timeout);
Connection.TLS_Go := True;
Connection.Read_Down := False;
Connection.Write_Down := False;
exception
when others =>
Connection.Shutdown;
raise;
end Secure;
---------------
-- Re_Secure --
---------------
procedure Re_secure (Connection: in out TLS_Server_Connection) is
begin
if Connection.Write_Down and Connection.Read_Down then
raise Program_Error with
"Re_Secure cannot be invoked on a shutdown connection.";
elsif not Connection.TLS_Go then
raise Program_Error with
"Re_Secure cannot be invoked unless the TLS_Server_Connection "
& "object is already Secured";
end if;
Connection.Context.Handshake (Socket => Connection.Socket,
Timeout => Explicit_Handshake_Timeout);
exception
when others =>
Connection.Shutdown;
raise;
end Re_Secure;
--
-- TLS_Listener
--
----------
-- Bind --
----------
procedure Bind (Listener: in out TLS_Listener;
Address : in IP.IP_Address;
Port : in TCP_Port)
is begin
TCP_Listener (Listener).Bind (Address, Port);
Listener.Context.Configure (Listener.Configuration.all);
end Bind;
-------------
-- Dequeue --
-------------
procedure Dequeue (Listener : in out TLS_Listener;
Connection: in out TCP_Connection'Class)
is
begin
if Connection not in TLS_Server_Connection'Class then
raise Program_Error with
"TLS_Listener.Dequeue must be target an object of "
& "TLS_Server_Connection'Class only.";
end if;
Connection.Shutdown;
TCP_Listener (Listener).Dequeue (Connection);
declare
TLS_Connection: TLS_Server_Connection'Class
renames TLS_Server_Connection'Class (Connection);
begin
TLS_Connection.Context.Establish
(Listener_Context => Listener.Context,
Socket => TLS_Connection.Socket,
Timeout => Explicit_Handshake_Timeout);
TLS_Connection.TLS_Go := True;
TLS_Connection.Read_Down := False;
TLS_Connection.Write_Down := False;
exception
when others =>
TLS_Connection.Shutdown;
raise;
end;
end Dequeue;
----------------------------------------------------------------------
function Dequeue (Listener: in out TLS_Listener) return TCP_Connection'Class
is begin
return New_Connection: TLS_Server_Connection do
Listener.Dequeue (New_Connection);
end return;
end Dequeue;
end INET.TCP.TLS;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with League.JSON.Objects;
with League.Strings;
with League.String_Vectors;
with League.Stream_Element_Vectors;
with League.Calendars;
package ACME is
type Context is tagged limited private;
procedure Initialize
(Self : in out Context'Class;
Directory_URL : League.Strings.Universal_String;
Terms_Of_Service : out League.Strings.Universal_String);
procedure Create_Account
(Self : in out Context'Class;
Public_Key : League.JSON.Objects.JSON_Object;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
Contact : League.String_Vectors.Universal_String_Vector;
TOS_Agreed : Boolean := True;
Only_Existing : Boolean := False;
Account_URL : out League.Strings.Universal_String);
type Optional_Date_Time (Is_Set : Boolean := False) is record
case Is_Set is
when True =>
Value : League.Calendars.Date_Time;
when False =>
null;
end case;
end record;
procedure Create_Order
(Self : in out Context'Class;
Account_URL : League.Strings.Universal_String;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
DNS_Id_List : League.String_Vectors.Universal_String_Vector;
Not_Before : Optional_Date_Time := (Is_Set => False);
Not_After : Optional_Date_Time := (Is_Set => False);
Auth_List : out League.String_Vectors.Universal_String_Vector;
Finalize : out League.Strings.Universal_String;
Order_URL : out League.Strings.Universal_String);
procedure Get_Order_Status
(Self : in out Context'Class;
Account_URL : League.Strings.Universal_String;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
Order_URL : League.Strings.Universal_String;
Certificate : out League.Strings.Universal_String;
Status : out League.Strings.Universal_String);
type Challenge is record
URL : League.Strings.Universal_String;
Token : League.Strings.Universal_String;
end record;
procedure Get_Challenges
(Self : in out Context'Class;
Account_URL : League.Strings.Universal_String;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
Auth_URL : League.Strings.Universal_String;
HTTP : out Challenge;
DNS : out Challenge);
function Key_Authorization
(Token : League.Strings.Universal_String;
Public_Key : League.JSON.Objects.JSON_Object)
return League.Strings.Universal_String;
procedure Challenge_Status
(Self : in out Context'Class;
Account_URL : League.Strings.Universal_String;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
Challenge : ACME.Challenge;
Status : out League.Strings.Universal_String);
procedure Challenge_Complete
(Self : in out Context'Class;
Account_URL : League.Strings.Universal_String;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
Challenge : ACME.Challenge);
procedure Finalize_Order
(Self : in out Context'Class;
Account_URL : League.Strings.Universal_String;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
Finalize : League.Strings.Universal_String;
CSR : League.Stream_Element_Vectors.Stream_Element_Vector);
procedure Get_Certificate
(Self : in out Context'Class;
Account_URL : League.Strings.Universal_String;
Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector;
Certificate : League.Strings.Universal_String;
Text : out League.Strings.Universal_String);
private
type Context is tagged limited record
Directory : League.JSON.Objects.JSON_Object;
Nonce : League.Strings.Universal_String;
end record;
end ACME;
|
type Priority is range 1..4;
type Infix is record
Precedence : Priority;
Expression : Unbounded_String;
end record;
package Expression_Stack is new Generic_Stack (Infix);
use Expression_Stack;
function Convert (RPN : String) return String is
Arguments : Stack;
procedure Pop
( Operation : Character;
Precedence : Priority;
Association : Priority
) is
Right, Left : Infix;
Result : Infix;
begin
Pop (Right, Arguments);
Pop (Left, Arguments);
Result.Precedence := Association;
if Left.Precedence < Precedence then
Append (Result.Expression, '(');
Append (Result.Expression, Left.Expression);
Append (Result.Expression, ')');
else
Append (Result.Expression, Left.Expression);
end if;
Append (Result.Expression, ' ');
Append (Result.Expression, Operation);
Append (Result.Expression, ' ');
if Right.Precedence < Precedence then
Append (Result.Expression, '(');
Append (Result.Expression, Right.Expression);
Append (Result.Expression, ')');
else
Append (Result.Expression, Right.Expression);
end if;
Push (Result, Arguments);
end Pop;
Pointer : Integer := RPN'First;
begin
while Pointer <= RPN'Last loop
case RPN (Pointer) is
when ' ' =>
Pointer := Pointer + 1;
when '0'..'9' =>
declare
Start : constant Integer := Pointer;
begin
loop
Pointer := Pointer + 1;
exit when Pointer > RPN'Last
or else RPN (Pointer) not in '0'..'9';
end loop;
Push
( ( 4,
To_Unbounded_String (RPN (Start..Pointer - 1))
),
Arguments
);
end;
when '+' | '-' =>
Pop (RPN (Pointer), 1, 1);
Pointer := Pointer + 1;
when '*' | '/' =>
Pop (RPN (Pointer), 2, 2);
Pointer := Pointer + 1;
when '^' =>
Pop (RPN (Pointer), 4, 3);
Pointer := Pointer + 1;
when others =>
raise Constraint_Error with "Syntax";
end case;
end loop;
declare
Result : Infix;
begin
Pop (Result, Arguments);
return To_String (Result.Expression);
end;
end Convert;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 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 Orka.Rendering.Buffers;
with Orka.Resources.Locations;
with Orka.Types;
private with GL.Low_Level.Enums;
private with Orka.Rendering.Programs.Uniforms;
package Orka.Algorithms.FFT is
pragma Preelaborate;
type FFT is tagged limited private;
function Create_FFT
(Location : Resources.Locations.Location_Ptr) return FFT;
use type Types.Element_Type;
procedure Compute_FFT
(Object : in out FFT;
Buffer : Rendering.Buffers.Buffer;
Width, Height : Positive;
Transpose, Inverse : Boolean)
with Pre => Buffer.Kind = Types.Single_Type
and Width * Height * 2 = Buffer.Length
and Types.Is_Power_Of_Two (if Transpose then Height else Width);
private
package LE renames GL.Low_Level.Enums;
type FFT is tagged limited record
Program_FFT : Rendering.Programs.Program;
Local_Size : Positive;
Uniform_Size : Rendering.Programs.Uniforms.Uniform (LE.UInt_Vec2);
Uniform_Transpose : Rendering.Programs.Uniforms.Uniform (LE.Bool_Type);
Uniform_Inverse : Rendering.Programs.Uniforms.Uniform (LE.Bool_Type);
end record;
end Orka.Algorithms.FFT;
|
procedure For_Loop_Statement is
begin
for Index in Boolean loop
null;
end loop;
end For_Loop_Statement;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
procedure P is begin x := 0; end Q;
begin P(0); end;
|
-- Mojang Session API
-- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
--
-- OpenAPI spec version: 2020_06_05
--
--
-- NOTE: This package is auto generated by the swagger code generator 3.3.4.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with Swagger.Streams;
with Swagger.Servers.Operation;
package body com.github.asyncmc.mojang.sessions.ada.server.model.Skeletons is
package body Skeleton is
package API_Get_Blocked_Server_Hashes is
new Swagger.Servers.Operation (Handler => Get_Blocked_Server_Hashes,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/blockedservers");
-- A list of SHA1 hashes of banned servers
procedure Get_Blocked_Server_Hashes
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type) is
Impl : Implementation_Type;
Result : Swagger.UString;
begin
Impl.Get_Blocked_Server_Hashes (Result, Context);
if Context.Get_Status = 200 then
Stream.Start_Document;
Swagger.Streams.Serialize (Stream, "", Result);
Stream.End_Document;
end if;
end Get_Blocked_Server_Hashes;
package API_Get_Player_Profile is
new Swagger.Servers.Operation (Handler => Get_Player_Profile,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/session/minecraft/profile/{stripped_uuid}");
-- Gets the player's game profile
procedure Get_Player_Profile
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type) is
Impl : Implementation_Type;
Stripped_Uuid : Swagger.UString;
Unsigned : Swagger.Nullable_Boolean;
Result : com.github.asyncmc.mojang.sessions.ada.server.model.Models.PlayerProfile_Type;
begin
Swagger.Servers.Get_Query_Parameter (Req, "unsigned", Unsigned);
Swagger.Servers.Get_Path_Parameter (Req, 1, Stripped_Uuid);
Impl.Get_Player_Profile
(Stripped_Uuid,
Unsigned, Result, Context);
if Context.Get_Status = 200 then
Stream.Start_Document;
com.github.asyncmc.mojang.sessions.ada.server.model.Models.Serialize (Stream, "", Result);
Stream.End_Document;
end if;
end Get_Player_Profile;
procedure Register (Server : in out Swagger.Servers.Application_Type'Class) is
begin
Swagger.Servers.Register (Server, API_Get_Blocked_Server_Hashes.Definition);
Swagger.Servers.Register (Server, API_Get_Player_Profile.Definition);
end Register;
end Skeleton;
package body Shared_Instance is
-- A list of SHA1 hashes of banned servers
procedure Get_Blocked_Server_Hashes
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type) is
Result : Swagger.UString;
begin
Server.Get_Blocked_Server_Hashes (Result, Context);
if Context.Get_Status = 200 then
Stream.Start_Document;
Swagger.Streams.Serialize (Stream, "", Result);
Stream.End_Document;
end if;
end Get_Blocked_Server_Hashes;
package API_Get_Blocked_Server_Hashes is
new Swagger.Servers.Operation (Handler => Get_Blocked_Server_Hashes,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/blockedservers");
-- Gets the player's game profile
procedure Get_Player_Profile
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type) is
Stripped_Uuid : Swagger.UString;
Unsigned : Swagger.Nullable_Boolean;
Result : com.github.asyncmc.mojang.sessions.ada.server.model.Models.PlayerProfile_Type;
begin
Swagger.Servers.Get_Query_Parameter (Req, "unsigned", Unsigned);
Swagger.Servers.Get_Path_Parameter (Req, 1, Stripped_Uuid);
Server.Get_Player_Profile
(Stripped_Uuid,
Unsigned, Result, Context);
if Context.Get_Status = 200 then
Stream.Start_Document;
com.github.asyncmc.mojang.sessions.ada.server.model.Models.Serialize (Stream, "", Result);
Stream.End_Document;
end if;
end Get_Player_Profile;
package API_Get_Player_Profile is
new Swagger.Servers.Operation (Handler => Get_Player_Profile,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/session/minecraft/profile/{stripped_uuid}");
procedure Register (Server : in out Swagger.Servers.Application_Type'Class) is
begin
Swagger.Servers.Register (Server, API_Get_Blocked_Server_Hashes.Definition);
Swagger.Servers.Register (Server, API_Get_Player_Profile.Definition);
end Register;
protected body Server is
-- A list of SHA1 hashes of banned servers
procedure Get_Blocked_Server_Hashes (Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type) is
begin
Impl.Get_Blocked_Server_Hashes (Result, Context);
end Get_Blocked_Server_Hashes;
-- Gets the player's game profile
procedure Get_Player_Profile
(Stripped_Uuid : in Swagger.UString;
Unsigned : in Swagger.Nullable_Boolean;
Result : out com.github.asyncmc.mojang.sessions.ada.server.model.Models.PlayerProfile_Type;
Context : in out Swagger.Servers.Context_Type) is
begin
Impl.Get_Player_Profile
(Stripped_Uuid,
Unsigned,
Result,
Context);
end Get_Player_Profile;
end Server;
end Shared_Instance;
end com.github.asyncmc.mojang.sessions.ada.server.model.Skeletons;
|
with Ada.Text_IO, Ada.Strings.Equal_Case_Insensitive;
procedure String_Compare is
procedure Print_Comparison (A, B: String) is
use Ada.Text_IO;
Function eq(Left, Right : String) return Boolean
renames Ada.Strings.Equal_Case_Insensitive;
begin
Put_Line
( """" & A & """ and """ & B & """: " &
(if A = B then "equal, " elsif eq(A,B)
then "case-insensitive-equal, " else "not equal at all, ") &
(if A /= B then "/=, " else "") &
(if A < B then "before, " else "") &
(if A > B then "after, " else "") &
(if A <= B then "<=, " else "(not <=), ") & "and " &
(if A >= B then ">=. " else "(not >=).") );
end Print_Comparison;
begin
Print_Comparison("this", "that");
Print_Comparison("that", "this");
Print_Comparison("THAT", "That");
Print_Comparison("this", "This");
Print_Comparison("this", "this");
Print_Comparison("the", "there");
Print_Comparison("there", "the");
end String_Compare;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Img_LLD is
pragma Pure;
-- required for Fixed'Image by compiler (s-imglld.ads)
procedure Image_Long_Long_Decimal (
V : Long_Long_Integer;
S : in out String;
P : out Natural;
Scale : Integer);
end System.Img_LLD;
|
-- GIF Decoder by André van Splunter
--
-- A GIF stream is made of several "blocks".
-- The image itself is contained in an Image Descriptor block.
--
with GID.Buffering, GID.Color_tables;
with Ada.Exceptions, Ada.Text_IO;
package body GID.Decoding_GIF is
----------
-- Load --
----------
procedure Load (
image : in out Image_descriptor;
next_frame: out Ada.Calendar.Day_Duration
)
is
local: Image_descriptor;
-- With GIF, each frame is a local image with an eventual
-- palette, different dimensions, etc. ...
use GID.Buffering, Ada.Exceptions;
generic
type Number is mod <>;
procedure Read_Intel_x86_number(
from : in out Input_buffer;
n : out Number
);
pragma Inline(Read_Intel_x86_number);
procedure Read_Intel_x86_number(
from : in out Input_buffer;
n : out Number
)
is
b: U8;
m: Number:= 1;
begin
n:= 0;
for i in 1..Number'Size/8 loop
GID.Buffering.Get_Byte(from, b);
Raw_Byte (b);
n:= n + m * Number(b);
m:= m * 256;
end loop;
end Read_Intel_x86_number;
procedure Read_Intel is new Read_Intel_x86_number( U16 );
type GIFDescriptor is record
ImageLeft,
ImageTop,
ImageWidth,
ImageHeight : U16;
Depth : U8;
end record;
-- For loading from the GIF file
Descriptor : GIFDescriptor;
-- Coordinates
X, tlX, brX : Natural;
Y, tlY, brY : Natural;
-- Code information
subtype Code_size_range is Natural range 2..12;
CurrSize : Code_size_range;
subtype Color_type is U8;
Transp_color : Color_type:= 0;
-- GIF data is stored in blocks and sub-blocks.
-- We initialize block_read and block_size to force
-- reading and buffering the next sub-block
block_size : Natural:= 0;
block_read : Natural:= 0;
function Read_Byte return U8 is
pragma Inline(Read_Byte);
b: U8;
begin
if block_read >= block_size then
Get_Byte(image.buffer, b);
Raw_Byte (b);
block_size:= Natural(b);
block_read:= 0;
end if;
Get_Byte(image.buffer, b);
Raw_Byte (b);
block_read:= block_read + 1;
return b;
end Read_Byte;
-- Used while reading the codes
bits_in : U8:= 8;
bits_buf: U8;
-- Local procedure to read the next code from the file
function Read_Code return Natural is
bit_mask: Natural:= 1;
code: Natural:= 0;
begin
-- Read the code, bit by bit
for Counter in reverse 0..CurrSize - 1 loop
-- Next bit
bits_in:= bits_in + 1;
-- Maybe, a new byte needs to be loaded with a further 8 bits
if bits_in = 9 then
bits_buf:= Read_Byte;
bits_in := 1;
end if;
-- Add the current bit to the code
if (bits_buf and 1) > 0 then
code:= code + bit_mask;
end if;
bit_mask := bit_mask * 2;
bits_buf := bits_buf / 2;
end loop;
return code;
end Read_Code;
generic
-- Parameter(s) that are constant through
-- the whole image. Macro-expanded generics and
-- some optimization will trim corresponding "if's"
interlaced : Boolean;
transparency : Boolean;
pixel_mask : U32;
--
procedure GIF_Decode;
procedure GIF_Decode is
procedure Pixel_with_palette(b: U8) is
pragma Inline(Pixel_with_palette);
function Times_257(x: Primary_color_range) return Primary_color_range is
pragma Inline(Times_257);
begin
return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x
-- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8.
end Times_257;
full_opaque: constant Primary_color_range:= Primary_color_range'Last;
begin
if transparency and then b = Transp_color then
Put_Pixel(0,0,0, 0);
return;
end if;
case Primary_color_range'Modulus is
when 256 =>
Put_Pixel(
Primary_color_range(local.palette(Integer(b)).red),
Primary_color_range(local.palette(Integer(b)).green),
Primary_color_range(local.palette(Integer(b)).blue),
full_opaque
);
when 65_536 =>
Put_Pixel(
Times_257(Primary_color_range(local.palette(Integer(b)).red)),
Times_257(Primary_color_range(local.palette(Integer(b)).green)),
Times_257(Primary_color_range(local.palette(Integer(b)).blue)),
-- Times_257 makes max intensity FF go to FFFF
full_opaque
);
when others =>
raise invalid_primary_color_range;
end case;
end Pixel_with_palette;
-- Interlacing
Interlace_pass : Natural range 1..4:= 1;
Span : Natural:= 7;
-- Local procedure to draw a pixel
procedure Next_Pixel(code: Natural) is
pragma Inline(Next_Pixel);
c : constant Color_type:= Color_type(U32(code) and pixel_mask);
begin
-- Actually draw the pixel on screen buffer
if X < image.width then
if interlaced and mode = nice then
for i in reverse 0..Span loop
if Y+i < image.height then
Set_X_Y(X, image.height - (Y+i) - 1);
Pixel_with_palette(c);
end if;
end loop;
elsif Y < image.height then
Pixel_with_palette(c);
end if;
end if;
-- Move on to next pixel
X:= X + 1;
-- Or next row, if necessary
if X = brX then
X:= tlX;
if interlaced then
case Interlace_pass is
when 1 =>
Y:= Y + 8;
if Y >= brY then
Y:= 4;
Interlace_pass:= 2;
Span:= 3;
Feedback((Interlace_pass*100)/4);
end if;
when 2 =>
Y:= Y + 8;
if Y >= brY then
Y:= 2;
Interlace_pass:= 3;
Span:= 1;
Feedback((Interlace_pass*100)/4);
end if;
when 3 =>
Y:= Y + 4;
if Y >= brY then
Y:= 1;
Interlace_pass:= 4;
Span:= 0;
Feedback((Interlace_pass*100)/4);
end if;
when 4 =>
Y:= Y + 2;
end case;
if mode = fast and then Y < image.height then
Set_X_Y(X, image.height - Y - 1);
end if;
else -- not interlaced
Y:= Y + 1;
if Y < image.height then
Set_X_Y(X, image.height - Y - 1);
end if;
if Y mod 32 = 0 then
Feedback((Y*100)/image.height);
end if;
end if;
end if;
end Next_Pixel;
-- The string table
Prefix : array ( 0..4096 ) of Natural:= (others => 0);
Suffix : array ( 0..4096 ) of Natural:= (others => 0);
-- Top of Stack was 1024 until files from
-- https://www.kaggle.com/c/carvana-image-masking-challenge
-- broke it (July 2017)...
Stack : array ( 0..2048 ) of Natural;
-- Special codes (specific to GIF's flavour of LZW)
ClearCode : constant Natural:= 2 ** CurrSize; -- Reset code
EndingCode: constant Natural:= ClearCode + 1; -- End of file
FirstFree : constant Natural:= ClearCode + 2; -- Strings start here
Slot : Natural:= FirstFree; -- Last read code
InitCodeSize : constant Code_size_range:= CurrSize + 1;
TopSlot : Natural:= 2 ** InitCodeSize; -- Highest code for current size
Code : Natural;
StackPtr : Integer:= 0;
Fc : Integer:= 0;
Oc : Integer:= 0;
C : Integer;
BadCodeCount : Natural:= 0; -- the number of bad codes found
begin -- GIF_Decode
-- The decoder source and the cool comments are kindly donated by
-- André van Splunter.
--
CurrSize:= InitCodeSize;
-- This is the main loop. For each code we get we pass through the
-- linked list of prefix codes, pushing the corresponding "character"
-- for each code onto the stack. When the list reaches a single
-- "character" we push that on the stack too, and then start unstacking
-- each character for output in the correct order. Special handling is
-- included for the clear code, and the whole thing ends when we get
-- an ending code.
C := Read_Code;
while C /= EndingCode loop
-- If the code is a clear code, reinitialize all necessary items.
if C = ClearCode then
CurrSize := InitCodeSize;
Slot := FirstFree;
TopSlot := 2 ** CurrSize;
-- Continue reading codes until we get a non-clear code
-- (Another unlikely, but possible case...)
C := Read_Code;
while C = ClearCode loop
C := Read_Code;
end loop;
-- If we get an ending code immediately after a clear code
-- (Yet another unlikely case), then break out of the loop.
exit when C = EndingCode;
-- Finally, if the code is beyond the range of already set codes,
-- (This one had better NOT happen... I have no idea what will
-- result from this, but I doubt it will look good...) then set
-- it to color zero.
if C >= Slot then
C := 0;
end if;
Oc := C;
Fc := C;
-- And let us not forget to output the char...
Next_Pixel(C);
else -- C /= ClearCode
-- In this case, it's not a clear code or an ending code, so
-- it must be a code code... So we can now decode the code into
-- a stack of character codes. (Clear as mud, right?)
Code := C;
-- Here we go again with one of those off chances... If, on the
-- off chance, the code we got is beyond the range of those
-- already set up (Another thing which had better NOT happen...)
-- we trick the decoder into thinking it actually got the last
-- code read. (Hmmn... I'm not sure why this works...
-- But it does...)
if Code >= Slot then
if Code > Slot then
BadCodeCount := BadCodeCount + 1;
end if;
Code := Oc;
Stack (StackPtr) := Fc rem 256;
StackPtr := StackPtr + 1;
end if;
-- Here we scan back along the linked list of prefixes, pushing
-- helpless characters (ie. suffixes) onto the stack as we do so.
while Code >= FirstFree loop
Stack (StackPtr) := Suffix (Code);
StackPtr := StackPtr + 1;
Code := Prefix (Code);
end loop;
-- Push the last character on the stack, and set up the new
-- prefix and suffix, and if the required slot number is greater
-- than that allowed by the current bit size, increase the bit
-- size. (NOTE - If we are all full, we *don't* save the new
-- suffix and prefix... I'm not certain if this is correct...
-- it might be more proper to overwrite the last code...
Stack (StackPtr) := Code rem 256;
if Slot < TopSlot then
Suffix (Slot) := Code rem 256;
Fc := Code;
Prefix (Slot) := Oc;
Slot := Slot + 1;
Oc := C;
end if;
if Slot >= TopSlot then
if CurrSize < 12 then
TopSlot := TopSlot * 2;
CurrSize := CurrSize + 1;
end if;
end if;
-- Now that we've pushed the decoded string (in reverse order)
-- onto the stack, lets pop it off and output it...
loop
Next_Pixel(Stack (StackPtr));
exit when StackPtr = 0;
StackPtr := StackPtr - 1;
end loop;
end if;
C := Read_Code;
end loop;
if full_trace and then BadCodeCount > 0 then
Ada.Text_IO.Put_Line(
"Found" & Integer'Image(BadCodeCount) &
" bad codes"
);
end if;
end GIF_Decode;
-- Here we have several specialized instances of GIF_Decode,
-- with parameters known at compile-time -> optimizing compilers
-- will do expensive tests about interlacing and transparency at compile-time,
-- not at run-time.
--
procedure GIF_Decode_interlaced_transparent_8 is
new GIF_Decode(interlaced => True, transparency => True, pixel_mask => 255);
procedure GIF_Decode_straight_transparent_8 is
new GIF_Decode(interlaced => False, transparency => True, pixel_mask => 255);
procedure GIF_Decode_interlaced_opaque_8 is
new GIF_Decode(interlaced => True, transparency => False, pixel_mask => 255);
procedure GIF_Decode_straight_opaque_8 is
new GIF_Decode(interlaced => False, transparency => False, pixel_mask => 255);
--
procedure Skip_sub_blocks is
temp: U8;
begin
sub_blocks_sequence:
loop
Get_Byte(image.buffer, temp ); -- load sub-block length byte
Raw_Byte(temp);
exit sub_blocks_sequence when temp = 0;
-- null sub-block = end of sub-block sequence
for i in 1..temp loop
Get_Byte(image.buffer, temp ); -- load sub-block byte
Raw_Byte(temp);
end loop;
end loop sub_blocks_sequence;
end Skip_sub_blocks;
temp, temp2, label: U8;
delay_frame: U16;
c: Character;
frame_interlaced: Boolean;
frame_transparency: Boolean:= False;
local_palette : Boolean;
--
separator : Character ;
-- Colour information
new_num_of_colours : Natural;
pixel_mask : U32;
BitsPerPixel : Natural;
begin -- Load
next_frame:= 0.0;
-- Scan various GIF blocks, until finding an image
loop
Get_Byte(image.buffer, temp);
Raw_Byte(temp);
separator:= Character'Val(temp);
if full_trace then
Ada.Text_IO.Put(
"GIF separator [" & separator &
"][" & U8'Image(temp) & ']'
);
end if;
case separator is
when ',' => -- 16#2C#
exit;
-- Image descriptor will begin
-- See: 20. Image Descriptor
when ';' => -- 16#3B#
if full_trace then
Ada.Text_IO.Put(" - End of GIF");
end if;
image.next_frame:= 0.0;
next_frame:= image.next_frame;
return; -- End of GIF image
when '!' => -- 16#21# Extensions
if full_trace then
Ada.Text_IO.Put(" - Extension");
end if;
Get_Byte(image.buffer, label );
Raw_Byte (label);
case label is
when 16#F9# => -- See: 23. Graphic Control Extension
if full_trace then
Ada.Text_IO.Put_Line(" - 16#F9#: Graphic Control Extension");
end if;
Get_Byte(image.buffer, temp );
Raw_Byte(temp);
if temp /= 4 then
Raise_Exception(
error_in_image_data'Identity,
"GIF: error in Graphic Control Extension"
);
end if;
Get_Byte(image.buffer, temp );
Raw_Byte(temp);
-- Reserved 3 Bits
-- Disposal Method 3 Bits
-- User Input Flag 1 Bit
-- Transparent Color Flag 1 Bit
frame_transparency:= (temp and 1) = 1;
Read_Intel(image.buffer, delay_frame);
image.next_frame:=
image.next_frame + Ada.Calendar.Day_Duration(delay_frame) / 100.0;
next_frame:= image.next_frame;
Get_Byte(image.buffer, temp );
Raw_Byte(temp);
Transp_color:= Color_type(temp);
-- zero sub-block:
Get_Byte(image.buffer, temp );
Raw_Byte(temp);
when 16#FE# => -- See: 24. Comment Extension
if full_trace then
Ada.Text_IO.Put_Line(" - 16#FE#: Comment Extension");
sub_blocks_sequence:
loop
Get_Byte(image.buffer, temp ); -- load sub-block length byte
Raw_Byte(temp);
exit sub_blocks_sequence when temp = 0;
-- null sub-block = end of sub-block sequence
for i in 1..temp loop
Get_Byte(image.buffer, temp2);
Raw_Byte(temp2);
c:= Character'Val(temp2);
Ada.Text_IO.Put(c);
end loop;
end loop sub_blocks_sequence;
Ada.Text_IO.New_Line;
else
Skip_sub_blocks;
end if;
when 16#01# => -- See: 25. Plain Text Extension
if full_trace then
Ada.Text_IO.Put_Line(" - 16#01#: Plain Text Extension");
end if;
Skip_sub_blocks;
when 16#FF# => -- See: 26. Application Extension
if full_trace then
Ada.Text_IO.Put_Line(" - 16#FF#: Application Extension");
end if;
Skip_sub_blocks;
when others =>
if full_trace then
Ada.Text_IO.Put_Line(" - Unused extension:" & U8'Image(label));
end if;
Skip_sub_blocks;
end case;
when ASCII.NUL =>
-- Occurs in some buggy GIFs (2016).
-- Seems a 2nd zero, the 1st marking the end of sub-block list.
if full_trace then
Ada.Text_IO.Put_Line(" - Wrong separator, skip and hope for the better...");
end if;
when others =>
Raise_Exception(
error_in_image_data'Identity,
"Unknown GIF separator: [" & separator &
"] code:" & Integer'Image(Character'Pos(separator))
);
end case;
end loop;
-- Load the image descriptor
Read_Intel(image.buffer, Descriptor.ImageLeft);
Read_Intel(image.buffer, Descriptor.ImageTop);
Read_Intel(image.buffer, Descriptor.ImageWidth);
Read_Intel(image.buffer, Descriptor.ImageHeight);
Get_Byte(image.buffer, Descriptor.Depth);
Raw_Byte(Descriptor.Depth);
-- Get image corner coordinates
tlX := Natural(Descriptor.ImageLeft);
tlY := Natural(Descriptor.ImageTop);
brX := tlX + Natural(Descriptor.ImageWidth);
brY := tlY + Natural(Descriptor.ImageHeight);
-- Local Color Table Flag 1 Bit
-- Interlace Flag 1 Bit
-- Sort Flag 1 Bit
-- Reserved 2 Bits
-- Size of Local Color Table 3 Bits
--
frame_interlaced:= (Descriptor.Depth and 64) = 64;
local_palette:= (Descriptor.Depth and 128) = 128;
local.format:= GIF;
local.stream:= image.stream;
local.buffer:= image.buffer;
if local_palette then
-- Get amount of colours in image
BitsPerPixel := 1 + Natural(Descriptor.Depth and 7);
new_num_of_colours:= 2 ** BitsPerPixel;
-- 21. Local Color Table
local.palette:= new Color_table(0..new_num_of_colours-1);
Color_tables.Load_palette(local);
image.buffer:= local.buffer;
elsif image.palette = null then
Raise_Exception(
error_in_image_data'Identity,
"GIF: neither local, nor global palette"
);
else
-- Use global palette
new_num_of_colours:= 2 ** image.subformat_id;
-- usually <= 2** image.bits_per_pixel
-- Just copy main palette
local.palette:= new Color_table'(image.palette.all);
end if;
pixel_mask:= U32(new_num_of_colours - 1);
if full_trace then
Ada.Text_IO.Put_Line(
" - Image, interlaced: " & Boolean'Image(frame_interlaced) &
"; local palette: " & Boolean'Image(local_palette) &
"; transparency: " & Boolean'Image(frame_transparency) &
"; transparency index:" & Color_type'Image(Transp_color)
);
end if;
-- Get initial code size
Get_Byte(image.buffer, temp );
Raw_Byte(temp);
if Natural(temp) not in Code_size_range then
Raise_Exception(
error_in_image_data'Identity,
"GIF: wrong LZW code size (must be in 2..12), is" &
U8'Image(temp)
);
end if;
CurrSize := Natural(temp);
-- Start at top left of image
X := Natural(Descriptor.ImageLeft);
Y := Natural(Descriptor.ImageTop);
Set_X_Y(X, image.height - Y - 1);
--
if new_num_of_colours < 256 then
-- "Rare" formats -> no need of best speed
declare
-- We create an instance with dynamic parameters
procedure GIF_Decode_general is
new GIF_Decode(frame_interlaced, frame_transparency, pixel_mask);
begin
GIF_Decode_general;
end;
else
-- 8 bit, usual format: we try to make things
-- faster with specialized instanciations...
if frame_interlaced then
if frame_transparency then
GIF_Decode_interlaced_transparent_8;
else
GIF_Decode_interlaced_opaque_8;
end if;
else -- straight (non-interlaced)
if frame_transparency then
GIF_Decode_straight_transparent_8;
else
GIF_Decode_straight_opaque_8;
end if;
end if;
end if;
Feedback(100);
--
Get_Byte(image.buffer, temp ); -- zero-size sub-block
end Load;
end GID.Decoding_GIF;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Strings.Hash;
with Ada.Unchecked_Deallocation;
package body Yaml.Text_Set is
use type Ada.Containers.Hash_Type;
function Non_Zero_Hash (S : Standard.String)
return Ada.Containers.Hash_Type is
Hash : constant Ada.Containers.Hash_Type := Ada.Strings.Hash (S);
begin
if Hash = 0 then
return 1;
else
return Hash;
end if;
end Non_Zero_Hash;
function Raw_Set (Object : in out Reference;
Hash : Ada.Containers.Hash_Type;
S : Standard.String)
return not null access Holder is
Pos : Natural :=
Natural (Hash mod Ada.Containers.Hash_Type (Object.Elements'Length));
Cur : not null access Holder := Object.Elements (Pos)'Access;
begin
while Cur.Hash /= 0 and then
(Cur.Hash /= Hash or else Cur.Key.Value /= S) loop
Pos := Pos + 1;
if Pos = Object.Elements'Length then
Pos := 0;
end if;
Cur := Object.Elements (Pos)'Access;
end loop;
return Cur;
end Raw_Set;
procedure Free is new Ada.Unchecked_Deallocation
(Holder_Array, Holder_Array_Access);
function Grow_If_Needed (Object : in out Reference) return Boolean is
Old_Elements : Holder_Array_Access := Object.Elements;
begin
if Object.Count = Object.Elements'Length / 2 then
Object.Elements := new Holder_Array (0 .. Object.Count * 4 - 1);
Object.Elements.all := (others => (Hash => 0, others => <>));
for E of Old_Elements.all loop
if E.Hash /= 0 then
Raw_Set (Object, E.Hash, E.Key.Value).all := E;
end if;
end loop;
Free (Old_Elements);
return True;
else
return False;
end if;
end Grow_If_Needed;
function Get (Object : in out Reference; S : Standard.String;
Create : Boolean) return not null access Holder is
Hash : constant Ada.Containers.Hash_Type := Non_Zero_Hash (S);
begin
<<Start>>
declare
Cur : constant not null Holder_Access := Raw_Set (Object, Hash, S);
begin
if Cur.Hash = 0 then
if Grow_If_Needed (Object) then
goto Start;
end if;
if Create then
Object.Count := Object.Count + 1;
Cur.Hash := Hash;
Cur.Key := Object.Pool.From_String (S);
end if;
end if;
return Cur;
end;
end Get;
function Set (Object : in out Reference;
S : Standard.String; Value : Value_Type) return Boolean is
Hash : constant Ada.Containers.Hash_Type := Non_Zero_Hash (S);
begin
if Grow_If_Needed (Object) then null; end if;
declare
Cur : constant not null access Holder := Raw_Set (Object, Hash, S);
begin
if Cur.Hash = 0 then
Object.Count := Object.Count + 1;
Cur.Hash := Hash;
Cur.Key := Object.Pool.From_String (S);
Cur.Value := Value;
return True;
else
return False;
end if;
end;
end Set;
procedure Clear (Object : in out Reference) is
begin
Object.Elements.all := (others => (Hash => 0, others => <>));
Object.Count := 0;
end Clear;
procedure Init (Object : in out Reference; Pool : Text.Pool.Reference;
Initial_Size : Positive) is
begin
Object.Pool := Pool;
Object.Elements := new Holder_Array (0 .. Initial_Size - 1);
Clear (Object);
end Init;
procedure Finalize (Object : in out Reference) is
begin
if Object.Elements /= null then
Free (Object.Elements);
end if;
end Finalize;
end Yaml.Text_Set;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- This package provides a generic implementation for the SHAKE XOF.
-- It is the basis for each of the two SHAKE XOF algorithms
-- described in Section 6.2 of NIST FIPS-202 (August 2015).
--
-- The package provides three main procedures:
-- * Init to initialize the XOF state
-- * Update to append data to the XOF algorithm
-- * Extract to get an arbitrary amount of output bytes from the XOF.
-------------------------------------------------------------------------------
with Keccak.Generic_Sponge;
with Keccak.Types;
-- @summary
-- Generic eXtendable Output Function (XOF).
--
-- @group XOF
generic
with package XOF_Sponge is new Keccak.Generic_Sponge (<>);
Capacity : Positive;
-- Sponge capacity in bits.
--
-- This must be a multiple of 8, and must be smaller than the state size.
Suffix : Keccak.Types.Byte;
Suffix_Size : Natural;
Permutation_Initial_Value : Keccak.Types.Byte_Array := Keccak.Types.Null_Byte_Array;
-- An optional inital value for the permutation state.
--
-- If non-empty, this data block will be written to the permutation state
-- and then the permutation function will be applied. Otherwise, the
-- permutation state will be zero-initialised.
--
-- The length of this parameter cannot exceed the permutation state size.
package Keccak.Generic_XOF
is
-- Import common types from Keccak.Types to avoid users of the
-- package to be dependent on Keccak.Types.
subtype Byte is Keccak.Types.Byte;
subtype Index_Number is Keccak.Types.Index_Number;
subtype Byte_Array is Keccak.Types.Byte_Array;
subtype Rate_Bits_Number is XOF_Sponge.Rate_Bits_Number;
type States is (Updating, Ready_To_Extract, Extracting);
type Context is private;
----------------------
-- XOF procedures --
----------------------
procedure Init (Ctx : out Context)
with Global => null,
Depends => (Ctx => null),
Post => State_Of (Ctx) = Updating;
-- Initializes the XOF.
--
-- Initially, the XOF is in the Updating state; data can be input into the
-- XOF by calling the Update procedure.
--
-- @param Ctx The context to initialize.
procedure Update (Ctx : in out Context;
Message : in Byte_Array;
Bit_Length : in Natural)
with Global => null,
Depends => (Ctx =>+ (Message, Bit_Length)),
Pre => (State_Of (Ctx) = Updating
and then (Message'Length < Natural'Last / 8)
and then Bit_Length <= Message'Length * 8),
Contract_Cases => (Bit_Length mod 8 = 0 => State_Of (Ctx) = Updating,
others => State_Of (Ctx) = Ready_To_Extract);
-- Input bit-oriented data into the XOF.
--
-- This function can be called multiple times to input large amounts of
-- data.
--
-- The XOF must be in the 'Updating' state when this procedure is called.
-- Note that if Update is called where Bit_Length is not a multiple of 8
-- bits then the XOF moves to the 'Ready_To_Extract' state and no additional
-- bytes can be input into the XOF. Otherwise, if Bit_Length is a multiple of
-- 8 bits then Update can be called again to input additional data.
--
-- @param Ctx The XOF object into which the data is input.
--
-- @param Message Contains the data to input into the XOF object.
--
-- @param Bit_Length The number of bits from the 'Message' array to input
-- into the XOF. Any additional bits in 'Message' after this number of
-- bits are ignored. All calls to Update before the last call must have
-- Bit_Length as a multiple of 8 bits. The last call to Update can have
-- Bit_Length with any value.
procedure Update (Ctx : in out Context;
Message : in Byte_Array)
with Global => null,
Depends => (Ctx =>+ Message),
Pre => State_Of (Ctx) = Updating,
Post => State_Of (Ctx) = Updating;
-- Input byte-oriented data into the XOF.
--
-- This procedure can be called multiple times to process large amounts
-- of data in chunks.
--
-- @param Ctx The hash context to update.
-- @param Message The bytes to input into the XOF.
procedure Extract (Ctx : in out Context;
Digest : out Byte_Array)
with Global => null,
Depends => ((Digest, Ctx) => (Ctx, Digest)),
Post => State_Of (Ctx) = Extracting;
-- Extract bytes from the XOF.
--
-- Each call to Extract can read an arbitrary number of bytes from the XOF.
-- Additionally, Extract can be called any number of times.
--
-- @param Ctx The XOF context object
--
-- @param Digest The bytes from the XOF are output into this array. The
-- length of the array determines the number of bytes that are extracted.
function State_Of (Ctx : in Context) return States
with Global => null;
-- @return The current state of the XOF context.
function Rate return Positive
with Global => null,
Post => Rate'Result mod 8 = 0;
-- @return The rate of the XOF (in bits).
private
use type XOF_Sponge.States;
type Context is record
Sponge_Ctx : XOF_Sponge.Context;
Update_Complete : Boolean;
end record;
function Rate return Positive
is (XOF_Sponge.Block_Size_Bits - Capacity);
function Can_Absorb (Ctx : in Context) return Boolean
is (XOF_Sponge.In_Queue_Bit_Length (Ctx.Sponge_Ctx) mod 8 = 0
and (XOF_Sponge.In_Queue_Bit_Length (Ctx.Sponge_Ctx) <
XOF_Sponge.Rate_Of (Ctx.Sponge_Ctx)));
function State_Of (Ctx : in Context) return States
is (if XOF_Sponge.State_Of (Ctx.Sponge_Ctx) = XOF_Sponge.Squeezing then Extracting
elsif Ctx.Update_Complete or (not Can_Absorb (Ctx)) then Ready_To_Extract
else Updating);
end Keccak.Generic_XOF;
|
with Generic_Heapsort;
with Ada.Text_Io; use Ada.Text_Io;
procedure Test_Generic_Heapsort is
type Days is (Sun, Mon, Tue, Wed, Thu, Fri, Sat);
type Days_Col is array(Days range <>) of Natural;
procedure Sort is new Generic_Heapsort(Natural, Days, Days_Col);
Week : Days_Col := (5, 2, 7, 3, 4, 9, 1);
begin
for I in Week'range loop
Put(Days'Image(I) & ":" & Natural'Image(Week(I)) & " ");
end loop;
New_Line;
Sort(Week);
for I in Week'range loop
Put(Days'Image(I) & ":" & Natural'Image(Week(I))& " ");
end loop;
New_Line;
end Test_Generic_Heapsort;
|
with
AdaM.a_Type.enumeration_literal,
gtk.Widget;
private
with
gtk.gEntry,
gtk.Box,
gtk.Button;
limited
with
adam.a_Type.enumeration_type;
package aIDE.Editor.of_enumeration_literal
is
type Item is new Editor.item with private;
type View is access all Item'Class;
type enumeration_type_view is access all AdaM.a_Type.enumeration_type.item'Class;
package Forge
is
function to_Editor (the_Target : in AdaM.a_Type.enumeration_literal.view;
targets_Parent : in enumeration_type_view) return View;
end Forge;
overriding
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
private
use gtk.Button,
gtk.gEntry,
gtk.Box;
type Item is new Editor.item with
record
Target : AdaM.a_Type.enumeration_literal.view;
Targets_Parent : enumeration_type_view;
top_Box : gtk_Box;
name_Entry : Gtk_Entry;
rid_Button : gtk_Button;
end record;
end aIDE.Editor.of_enumeration_literal;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
private package Apsepp.Scope_Bound_Locks.Private_Handler is
----------------------------------------------------------------------------
protected Protected_Handler is
procedure Do_Lock (Lock : SB_Lock_Access;
Actually_Locked : out Boolean)
with Post => Locked (Lock.all);
procedure Do_Unlock (Lock : SB_Lock_Access)
with Post => not Locked (Lock.all);
end Protected_Handler;
----------------------------------------------------------------------------
end Apsepp.Scope_Bound_Locks.Private_Handler;
|
with Ada.Text_IO;
use Ada.Text_IO;
with Dates;
use Dates;
procedure Exemple_Dates_Erreurs is
Une_Date : T_Date;
Mois_Suivant : T_Mois;
Autre_Date : T_Date;
begin
-- Initialiser une date
Initialiser (Une_Date, 1, OCTOBRE, 2018);
-- L'afficher
Afficher (Une_Date);
New_Line;
-- Afficher un enter sur 2 positions
-- Afficher_Deux_Positions (2); -- ERREUR!
-- New_Line;
-- Afficher le mois suivant de Une_Date
Mois_Suivant := T_Mois'succ (Le_Mois (Une_Date));
Put ("Mois suivant : ");
Put (T_Mois'Image (Mois_Suivant));
New_Line;
-- OK car le type T_Mois est accessible de l'utilisateur.
-- Modifier directement la date
-- Une_Date.jour := 15; -- MARCHE PAS
-- Une_Date.Mois := Mois_Suivant; -- MARCHE PAS
Afficher (Une_Date);
New_Line;
-- Illustrer les opérations possibles sur T_Date, type privé
Autre_Date := Une_Date;
Put ("Autre date : ");
Afficher (Autre_Date);
New_Line;
if Autre_Date = Une_Date then
Put_Line ("Ce sont les mêmes dates !");
else
Put_Line ("Les dates sont différentes !");
end if;
end Exemple_Dates_Erreurs;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Elements.Definitions;
with Program.Elements.Expressions;
with Program.Lexical_Elements;
package Program.Elements.Aspect_Specifications is
pragma Pure (Program.Elements.Aspect_Specifications);
type Aspect_Specification is
limited interface and Program.Elements.Definitions.Definition;
type Aspect_Specification_Access is access all Aspect_Specification'Class
with Storage_Size => 0;
not overriding function Aspect_Mark
(Self : Aspect_Specification)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
not overriding function Aspect_Definition
(Self : Aspect_Specification)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
type Aspect_Specification_Text is limited interface;
type Aspect_Specification_Text_Access is
access all Aspect_Specification_Text'Class with Storage_Size => 0;
not overriding function To_Aspect_Specification_Text
(Self : in out Aspect_Specification)
return Aspect_Specification_Text_Access is abstract;
not overriding function Arrow_Token
(Self : Aspect_Specification_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
type Aspect_Specification_Vector is
limited interface and Program.Element_Vectors.Element_Vector;
type Aspect_Specification_Vector_Access is
access all Aspect_Specification_Vector'Class with Storage_Size => 0;
overriding function Element
(Self : Aspect_Specification_Vector;
Index : Positive)
return not null Program.Elements.Element_Access is abstract
with Post'Class => Element'Result.Is_Aspect_Specification;
function To_Aspect_Specification
(Self : Aspect_Specification_Vector'Class;
Index : Positive)
return not null Aspect_Specification_Access
is (Self.Element (Index).To_Aspect_Specification);
end Program.Elements.Aspect_Specifications;
|
with Ada.Streams;
with Ada.Text_IO;
with iconv.Strings;
procedure Test_Strings is
use type Ada.Streams.Stream_Element_Array;
L1_A : constant String := "A";
U16BE_A : constant Ada.Streams.Stream_Element_Array (1 .. 2) := (0, 16#41#);
U16BE_JAPANEASE_A : constant Ada.Streams.Stream_Element_Array (1 .. 2) :=
(16#30#, 16#42#);
begin
declare
D : iconv.Strings.Decoder := iconv.Strings.From ("UTF-16BE");
begin
pragma Assert (iconv.Strings.Decode (D, U16BE_A) = L1_A);
pragma Assert (iconv.Strings.Decode (D, U16BE_JAPANEASE_A) = "");
pragma Assert (
iconv.Strings.Decode (D, U16BE_A & U16BE_JAPANEASE_A & U16BE_A) = L1_A & L1_A);
iconv.Strings.Set_Substitute (D, (0 => Character'Pos ('?')));
pragma Assert (
iconv.Strings.Decode (D, U16BE_A & U16BE_JAPANEASE_A & U16BE_A) =
L1_A & "?" & L1_A);
end;
declare
E : iconv.Strings.Encoder := iconv.Strings.To ("UTF-16BE");
pragma Unmodified (E);
begin
pragma Assert (iconv.Strings.Encode (E, L1_A) = U16BE_A);
null;
end;
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end Test_Strings;
|
-- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Author: Emanuel Regnath (emanuel.regnath@tum.de)
with Config.Software;
with HIL.UART;
with HIL.Devices;
-- @summary Command Line Interface for user interactions
package body Console with SPARK_Mode => On is
procedure read_Command( cmd : out User_Command_Type ) is
data_rx : HIL.UART.Data_Type (1 .. 1) := (others => 0);
n_read : Natural;
begin
cmd := NONE;
if Config.Software.DEBUG_MODE_IS_ACTIVE then
HIL.UART.read (HIL.Devices.Console, data_rx, n_read);
if n_read > 0 then
case (Character'Val (data_rx (1))) is
when 's' =>
cmd := STATUS;
when 't' =>
cmd := TEST;
when 'p' =>
cmd := PROFILE;
when 'r' =>
cmd := RESTART;
when 'a' =>
cmd := ARM;
when 'd' =>
cmd := DISARM;
when '2' =>
cmd := INC_ELE;
when '1' =>
cmd := DEC_ELE;
when others =>
cmd := NONE;
end case;
end if;
end if;
end read_Command;
procedure write_Line (message : String) is
--LF : Character := Character'Val(10);
CR : constant Character := Character'Val (13); -- ASCII
begin
if message'Last < Natural'Last then
HIL.UART.write (HIL.Devices.Console, HIL.UART.toData_Type (message & CR));
else
HIL.UART.write (HIL.Devices.Console, HIL.UART.toData_Type (message));
end if;
end write_Line;
end Console;
|
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
private package Ada_Pretty.Declarations is
type Package_Body is new Node with private;
function New_Package_Body
(Name : not null Node_Access;
List : Node_Access) return Node'Class;
type Package_Spec is new Node with private;
function New_Package
(Name : not null Node_Access;
Public_Part : Node_Access;
Private_Part : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class;
type Package_Instantiation is new Node with private;
function New_Package_Instantiation
(Name : not null Node_Access;
Template : not null Node_Access;
Actual_Part : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class;
type Parameter is new Node with private;
function New_Parameter
(Name : not null Node_Access;
Type_Definition : Node_Access;
Initialization : Node_Access;
Is_In : Boolean;
Is_Out : Boolean;
Is_Aliased : Boolean;
Comment : League.Strings.Universal_String) return Node'Class;
type Subprogram_Body is new Node with private;
function New_Subprogram_Body
(Specification : not null Node_Access;
Declarations : Node_Access;
Statements : Node_Access;
Exceptions : Node_Access) return Node'Class;
type Subprogram_Declaration is new Node with private;
function New_Subprogram_Declaration
(Specification : not null Node_Access;
Aspects : Node_Access := null;
Is_Abstract : Boolean;
Is_Null : Boolean;
Expression : Node_Access;
Renamed : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class;
type Type_Declaration is new Node with private;
function New_Type
(Name : not null Node_Access;
Discriminants : Node_Access;
Definition : Node_Access;
Aspects : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class;
type Variable is new Node with private;
function New_Variable
(Name : not null Node_Access;
Type_Definition : Node_Access;
Initialization : Node_Access;
Rename : Node_Access;
Is_Constant : Boolean;
Is_Aliased : Boolean;
Aspects : Node_Access;
Comment : League.Strings.Universal_String) return Node'Class;
private
type Package_Body is new Declaration with record
Name : not null Node_Access;
List : Node_Access;
end record;
overriding function Document
(Self : Package_Body;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Package_Spec is new Declaration with record
Name : not null Node_Access;
Public_Part : Node_Access;
Private_Part : Node_Access;
Comment : League.Strings.Universal_String;
end record;
overriding function Document
(Self : Package_Spec;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Package_Instantiation is new Declaration with record
Name : not null Node_Access;
Template : not null Node_Access;
Actual_Part : Node_Access;
Comment : League.Strings.Universal_String;
end record;
overriding function Document
(Self : Package_Instantiation;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Parameter is new Node with record
Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access;
Is_In : Boolean;
Is_Out : Boolean;
Is_Aliased : Boolean;
Comment : League.Strings.Universal_String;
end record;
overriding function Document
(Self : Parameter;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
overriding function Join
(Self : Parameter;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document;
overriding function Max_Pad (Self : Parameter) return Natural is
(Self.Name.Max_Pad);
type Subprogram_Body is new Declaration with record
Specification : not null Node_Access;
Declarations : Node_Access;
Statements : Node_Access;
Exceptions : Node_Access;
end record;
overriding function Document
(Self : Subprogram_Body;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Subprogram_Declaration is new Declaration with record
Specification : not null Node_Access;
Aspects : Node_Access;
Is_Abstract : Boolean;
Is_Null : Boolean;
Expression : Node_Access;
Renamed : Node_Access;
Comment : League.Strings.Universal_String;
end record;
overriding function Document
(Self : Subprogram_Declaration;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Type_Declaration is new Declaration with record
Name : not null Node_Access;
Discriminants : Node_Access;
Definition : Node_Access;
Aspects : Node_Access;
Comment : League.Strings.Universal_String;
end record;
overriding function Document
(Self : Type_Declaration;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Variable is new Node with record
Name : not null Node_Access;
Type_Definition : Node_Access;
Initialization : Node_Access;
Rename : Node_Access;
Is_Constant : Boolean;
Is_Aliased : Boolean;
Aspects : Node_Access;
Comment : League.Strings.Universal_String;
end record;
overriding function Max_Pad (Self : Variable) return Natural is
(Self.Name.Max_Pad);
overriding function Document
(Self : Variable;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
end Ada_Pretty.Declarations;
|
------------------------------------------------------------------------
-- Copyright (C) 2004-2020 by <ada.rocks@jlfencey.com> --
-- --
-- This work is free. You can redistribute it and/or modify it under --
-- the terms of the Do What The Fuck You Want To Public License, --
-- Version 2, as published by Sam Hocevar. See the LICENSE file for --
-- more details. --
------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------
-- AMD Élan(tm) SC 520 embedded microprocessor --
-- MMCR -> Programmable Address Region Registers (PAR) --
------------------------------------------------------------------------
with Elan520.Basic_Types;
package Elan520.Programmable_Address_Region is
-- type for Target of definition in a programmable address region
type Window_Target is (Window_Disabled, -- no memory window
GP_Bus_IO, -- GP bus I/O access
GP_Bus_Memory, -- GP bus memory access
PCI_Bus, -- access to PCI bus
Boot_CS, -- Boot ROM ChipSelect
Rom_CS_1, -- Rom Area 1 Chipselect
Rom_CS_2, -- Rom Area 2 Chipselect
SD_Ram); -- SDRAM type access
-- its hardware representation
for Window_Target use (Window_Disabled => 2#000#,
GP_Bus_IO => 2#001#,
GP_Bus_Memory => 2#010#,
PCI_Bus => 2#011#,
Boot_CS => 2#100#,
Rom_CS_1 => 2#101#,
Rom_CS_2 => 2#110#,
SD_Ram => 2#111#);
for Window_Target'Size use 3;
-- the ATTR bits in the PAR register when type is memory
type Memory_Attribute is
record
Write_Protected : Basic_Types.Positive_Bit;
Cacheable : Basic_Types.Negative_Bit;
Executable : Basic_Types.Negative_Bit;
end record;
-- its hardware representation
for Memory_Attribute use
record
Write_Protected at 0 range 0 .. 0;
Cacheable at 0 range 1 .. 1;
Executable at 0 range 2 .. 2;
end record;
for Memory_Attribute'Size use 3;
-- the ATTR bits in the PAR register when type is I/O
-- just raises the GP_IO_CS signals 0 through 7
type Chip_Select_Signal is range 0 .. 7;
for Chip_Select_Signal'Size use 3;
type Page_Size is (Four_Ki_Byte, Sixty_Four_Ki_Byte);
for Page_Size use (Four_Ki_Byte => 0,
Sixty_Four_Ki_Byte => 1);
for Page_Size'Size use 1;
-- IO pages, granularity is 1 byte, size max. 512 bytes
type IO_Page_Start_Address is range 0 .. 2**16 - 1;
type IO_Page_Region_Size is range 1 .. 2**9;
type IO_Page is
record
Start_Address : IO_Page_Start_Address;
Region_Size : IO_Page_Region_Size;
end record;
-- its hardware representation
for IO_Page use
record
Start_Address at 0 range 0 .. 15;
Region_Size at 0 range 16 .. 24;
end record;
for IO_Page'Size use 25;
-- "small" memory pages (128 * 4 Ki => 512 KiBytes)
type Mem_Page_4Ki_Start_Address is range 0 .. 2**18 - 1;
type Mem_Page_4Ki_Region_Size is range 1 .. 2**7;
type Mem_Page_4Ki is
record
-- start address in 4 Ki blocks (means, the value here reflects
-- address lines A12 - A29 (18 bits))
Start_Address : Mem_Page_4Ki_Start_Address;
-- size of region in 4K blocks (7 bits => 128 max.)
Region_Size : Mem_Page_4Ki_Region_Size;
end record;
-- its hardware representation
for Mem_Page_4Ki use
record
Start_Address at 0 range 0 .. 17;
Region_Size at 0 range 18 .. 24;
end record;
for Mem_Page_4Ki'Size use 25;
-- "large" memory pages (2048 * 64 Ki => max. 128 MiBytes)
type Mem_Page_64Ki_Start_Address is range 0 .. 2**14 - 1;
type Mem_Page_64Ki_Region_Size is range 1 .. 2**11;
type Mem_Page_64Ki is
record
-- start address in 64 Ki blocks (means, the value here reflects
-- A16 - A29 (14 bits))
Start_Address : Mem_Page_64Ki_Start_Address;
Region_Size : Mem_Page_64Ki_Region_Size;
end record;
-- its hardware representation
for Mem_Page_64Ki use
record
Start_Address at 0 range 0 .. 13;
Region_Size at 0 range 14 .. 24;
end record;
for Mem_Page_64Ki'Size use 25;
-- type for a programmable address region register
type Programmable_Address_Region (
Target : Window_Target := Window_Disabled;
Pg_Sz : Page_Size := Four_Ki_Byte) is
record
case Target is
when Window_Disabled =>
null;
when GP_Bus_IO | PCI_Bus =>
IO_Attr : Chip_Select_Signal;
Sz_St_Addr_IO : IO_Page;
when GP_Bus_Memory | Boot_CS | Rom_CS_1 | Rom_CS_2 | SD_Ram =>
Mem_Attr : Memory_Attribute;
case Pg_Sz is
when Four_Ki_Byte =>
Sz_St_Addr_4Ki : Mem_Page_4Ki;
when Sixty_Four_Ki_Byte =>
Sz_St_Addr_64Ki : Mem_Page_64Ki;
end case;
end case;
end record;
-- its hardware representation
PROGRAMMABLE_ADDRESS_REGION_SIZE : constant := 32;
for Programmable_Address_Region use
record
-- discriminants
Target at 0 range 29 .. 31;
Pg_Sz at 0 range 25 .. 25;
-- variable parts depending on discriminants
-- I/O type memory regions
IO_Attr at 0 range 26 .. 28;
Sz_St_Addr_IO at 0 range 0 .. 24;
-- memory type memory regions
Mem_Attr at 0 range 26 .. 28;
Sz_St_Addr_4Ki at 0 range 0 .. 24;
Sz_St_Addr_64Ki at 0 range 0 .. 24;
end record;
for Programmable_Address_Region'Size use
PROGRAMMABLE_ADDRESS_REGION_SIZE;
pragma Atomic (Programmable_Address_Region);
PAR_ENTRIES : constant := 16;
PAR_INFO_SIZE : constant := PAR_ENTRIES *
PROGRAMMABLE_ADDRESS_REGION_SIZE;
MMCR_OFFSET_PAR_INFO : constant := 16#88#;
type PAR_Info is
array (0 .. PAR_ENTRIES - 1) of Programmable_Address_Region;
for PAR_Info'Size use PAR_INFO_SIZE;
end Elan520.Programmable_Address_Region;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Ada.Unchecked_Deallocation;
with Yaml.Destination.C_Handler;
with Yaml.Destination.C_String;
with Yaml.Source;
with Yaml.Tags;
with Lexer.Source.C_Handler;
with Text.Pool;
package body Yaml.C is
use type System.Address;
use type Interfaces.C.size_t;
use type Interfaces.C.Strings.chars_ptr;
use type Text.Reference;
Creation_Pool : Text.Pool.Reference;
Version_String : constant Interfaces.C.Strings.chars_ptr :=
Interfaces.C.Strings.New_String
(Ada.Strings.Fixed.Trim (Version_Major'Img, Ada.Strings.Left) & '.' &
Ada.Strings.Fixed.Trim (Version_Minor'Img, Ada.Strings.Left) & '.' &
Ada.Strings.Fixed.Trim (Version_Patch'Img, Ada.Strings.Left));
function Get_Version_String return Interfaces.C.Strings.chars_ptr is
(Version_String);
procedure Get_Version (Major, Minor, Patch : out Interfaces.C.int) is
begin
Major := Interfaces.C.int (Version_Major);
Minor := Interfaces.C.int (Version_Minor);
Patch := Interfaces.C.int (Version_Patch);
end Get_Version;
-- token API not implemented.
procedure Token_Delete (Token : System.Address) is null;
procedure Init (E : out Event; Kind : Event_Type) is
begin
E.Start_Mark := (Index => 1, Line => 1, Column => 1);
E.End_Mark := (Index => 1, Line => 1, Column => 1);
E.Kind := Kind;
end Init;
function Stream_Start_Event_Initialize (E : out Event;
Encoding : Encoding_Type)
return Bool is
begin
Init (E, Stream_Start);
E.Data.Encoding := Encoding;
return True;
end Stream_Start_Event_Initialize;
function Stream_End_Event_Initialize (E : out Event) return Bool is
begin
Init (E, Stream_End);
return True;
end Stream_End_Event_Initialize;
function Document_Start_Event_Initialize
(E : out Event; Version_Directive, Tag_Directive_Start, Tag_Directive_End :
System.Address; Implicit : Bool) return Bool is
begin
Init (E, Document_Start);
E.Data := (T => Document_Start, Version_Directive => Version_Directive,
Start_Dir => Tag_Directive_Start, DS_Implicit => Implicit,
End_Dir => Tag_Directive_End);
return True;
end Document_Start_Event_Initialize;
function Document_End_Event_Initialize
(E : out Event; Implicit : Bool) return Bool is
begin
Init (E, Document_End);
E.Data := (T => Document_End, DE_Implicit => Implicit);
return True;
end Document_End_Event_Initialize;
function Alias_Event_Initialize
(E : out Event; Anchor : Interfaces.C.Strings.chars_ptr) return Bool is
begin
Init (E, Alias);
E.Data := (T => Alias, Ali_Anchor => Text.Export
(Creation_Pool.From_String (
Interfaces.C.Strings.Value (Anchor))));
return True;
end Alias_Event_Initialize;
function Ada_Value_For (C_Value : Interfaces.C.Strings.chars_ptr;
Default : Text.Reference := Text.Empty)
return Text.Reference is
((if C_Value = Interfaces.C.Strings.Null_Ptr then Default else
Creation_Pool.From_String (Interfaces.C.Strings.Value (C_Value))));
function Scalar_Event_Initialize
(E : out Event; Anchor, Tag, Value : Interfaces.C.Strings.chars_ptr;
Plain_Implicit, Quoted_Implicit : Bool; Style : Scalar_Style_Type)
return Bool is
Converted_Value : constant Standard.String :=
Interfaces.C.Strings.Value (Value);
begin
Init (E, Scalar);
E.Data := (T => Scalar,
Scalar_Tag => Text.Export (Ada_Value_For (Tag, Tags.Question_Mark)),
Scalar_Anchor => Text.Export (Ada_Value_For (Anchor)),
Value => Text.Export (Creation_Pool.From_String (
Converted_Value)),
Length => Converted_Value'Length,
Plain_Implicit => Plain_Implicit,
Quoted_Implicit => Quoted_Implicit,
Scalar_Style => Style);
return True;
end Scalar_Event_Initialize;
function Sequence_Start_Event_Initialize
(E : out Event; Anchor, Tag : Interfaces.C.Strings.chars_ptr;
Implicit : Bool; Style : Collection_Style_Type) return Bool is
begin
Init (E, Sequence_Start);
E.Data := (T => Sequence_Start, Seq_Anchor => Text.Export
(Ada_Value_For (Anchor)),
Seq_Tag => Text.Export (Ada_Value_For (Tag, Tags.Question_Mark)),
Seq_Implicit => Implicit, Seq_Style => Style);
return True;
end Sequence_Start_Event_Initialize;
function Sequence_End_Event_Initialize (E : out Event) return Bool is
begin
Init (E, Sequence_End);
return True;
end Sequence_End_Event_Initialize;
function Mapping_Start_Event_Initialize
(E : out Event; Anchor, Tag : Interfaces.C.Strings.chars_ptr;
Implicit : Bool; Style : Collection_Style_Type) return Bool is
begin
Init (E, Mapping_Start);
E.Data := (T => Mapping_Start, Map_Anchor => Text.Export
(Ada_Value_For (Anchor)),
Map_Tag => Text.Export (Ada_Value_For (Tag, Tags.Question_Mark)),
Map_Implicit => Implicit, Map_Style => Style);
return True;
end Mapping_Start_Event_Initialize;
function Mapping_End_Event_Initialize (E : out Event) return Bool is
begin
Init (E, Mapping_End);
return True;
end Mapping_End_Event_Initialize;
procedure Event_Delete (E : in out Event) is
pragma Unmodified (E);
procedure Delete_If_Exists (Value : Text.Exported) is
begin
if Value /= System.Null_Address then
Text.Delete_Exported (Value);
end if;
end Delete_If_Exists;
begin
case E.Kind is
when Scalar =>
Delete_If_Exists (E.Data.Scalar_Anchor);
Delete_If_Exists (E.Data.Scalar_Tag);
Text.Delete_Exported (E.Data.Value);
when Mapping_Start =>
Delete_If_Exists (E.Data.Map_Anchor);
Delete_If_Exists (E.Data.Map_Tag);
when Sequence_Start =>
Delete_If_Exists (E.Data.Seq_Anchor);
Delete_If_Exists (E.Data.Seq_Tag);
when Alias =>
Text.Delete_Exported (E.Data.Ali_Anchor);
when others => null;
end case;
end Event_Delete;
function Document_Initialize (Document, Version_Directive,
Tag_Directives_Start, Tag_Directives_End :
System.Address; Start_Implicit, End_Implicit :
Bool) return Bool is (False);
procedure Document_Delete (Document : System.Address) is null;
function Document_Get_Node (Document : System.Address;
Index : Interfaces.C.int) return System.Address
is (System.Null_Address);
function Document_Get_Root_Node (Document : System.Address)
return System.Address is
(System.Null_Address);
function Document_Add_Scalar (Document : System.Address;
Tag, Value : Interfaces.C.Strings.chars_ptr;
Length : Interfaces.C.int;
Style : Scalar_Style_Type) return Bool is
(False);
function Document_Add_Sequence (Document : System.Address;
Tag : Interfaces.C.Strings.chars_ptr;
Style : Collection_Style_Type) return Bool is
(False);
function Document_Add_Mapping (Document : System.Address;
Tag : Interfaces.C.Strings.chars_ptr;
Style : Collection_Style_Type) return Bool is
(False);
function Document_Append_Sequence_Item (Document : System.Address;
Sequence, Item : Interfaces.C.int)
return Bool is (False);
function Document_Append_Mapping_Pair
(Document : System.Address; Mapping, Key, Value : Interfaces.C.int)
return Bool is (False);
procedure Parser_Set_Encoding (P : in out Parser_Type;
Encoding : Encoding_Type) is null;
function Parser_Initialize (P : in out Parser_Type) return Bool is
begin
P.Error := No_Error;
P.Problem := Interfaces.C.Strings.Null_Ptr;
P.Ptr := new Parser.Instance;
return True;
exception
when E : Storage_Error =>
P.Error := Memory_Error;
P.Problem := Interfaces.C.Strings.New_String (Ada.Exceptions.Exception_Message (E));
return False;
when E : others =>
P.Error := Parser_Error;
P.Problem := Interfaces.C.Strings.New_String
(Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
return False;
end Parser_Initialize;
procedure Parser_Delete (P : in out Parser_Type) is
procedure Free is new Ada.Unchecked_Deallocation
(Parser.Instance, Parser_Pointer);
begin
if P.Problem /= Interfaces.C.Strings.Null_Ptr then
Interfaces.C.Strings.Free (P.Problem);
end if;
Free (P.Ptr);
end Parser_Delete;
procedure Parser_Set_Input_String (P : in out Parser_Type;
Input : Interfaces.C.Strings.chars_ptr;
Size : Interfaces.C.size_t) is
begin
P.Ptr.Set_Input (Interfaces.C.Strings.Value (Input, Size));
end Parser_Set_Input_String;
function fread (Ptr : System.Address; Size, Count : Interfaces.C.size_t;
Stream : System.Address) return Interfaces.C.size_t with
Import, Convention => C, External_Name => "fread";
function fwrite (Ptr : System.Address; Size, Count : Interfaces.C.size_t;
Stream : System.Address) return Interfaces.C.size_t with
Import, Convention => C, External_Name => "fwrite";
function ferror (Stream : System.Address) return Interfaces.C.int with
Import, Convention => C, External_Name => "ferror";
function File_Read_Handler (Data, Buffer : System.Address;
Size : Interfaces.C.size_t;
Size_Read : out Interfaces.C.size_t) return Bool
with Convention => C;
function File_Read_Handler (Data, Buffer : System.Address;
Size : Interfaces.C.size_t;
Size_Read : out Interfaces.C.size_t) return Bool
is
use type Interfaces.C.int;
begin
Size_Read := fread (Buffer, 1, Size, Data);
return Bool (ferror (Data) = 0);
end File_Read_Handler;
procedure Parser_Set_Input_File (P : in out Parser_Type;
File : System.Address) is
begin
Parser_Set_Input (P, File_Read_Handler'Access, File);
end Parser_Set_Input_File;
procedure Parser_Set_Input (P : in out Parser_Type;
Handler : Read_Handler; Data : System.Address) is
begin
P.Ptr.Set_Input (Source.C_Handler.As_Source (Data, Handler));
end Parser_Set_Input;
function Parser_Scan (P : in out Parser_Type; Token : System.Address)
return Bool is
pragma Unreferenced (Token);
begin
P.Error := Scanner_Error;
P.Problem := Interfaces.C.Strings.New_String
("AdaYaml does not implement the low-level scanner API");
return False;
end Parser_Scan;
function To_C (M : Mark) return C_Mark is
((Index => Interfaces.C.size_t (M.Index),
Line => Interfaces.C.size_t (M.Line),
Column => Interfaces.C.size_t (M.Column)));
function To_Ada (C : C_Mark) return Mark is
((Index => Mark_Position (C.Index),
Line => Mark_Position (C.Line),
Column => Mark_Position (C.Column)));
function Parser_Parse (P : in out Parser_Type; E : out Event) return Bool is
begin
-- use internal declare block so that exception handler handles
-- all possible exceptions
declare
Raw : constant Yaml.Event := P.Ptr.Next;
function To_Type return Event_Type is
(case Raw.Kind is
when Stream_Start => Stream_Start,
when Stream_End => Stream_End,
when Document_Start => Document_Start,
when Document_End => Document_End,
when Mapping_Start => Mapping_Start,
when Mapping_End => Mapping_End,
when Sequence_Start => Sequence_Start,
when Sequence_End => Sequence_End,
when Scalar => Scalar,
when Alias => Alias,
when Annotation_Start => Annotation_Start,
when Annotation_End => Annotation_End);
generic
Null_Value : Text.Reference;
function Export_Nullable (Value : Text.Reference) return Text.Exported;
function Export_Nullable (Value : Text.Reference)
return Text.Exported is
(if Value = Null_Value then System.Null_Address else
Text.Export (Value));
function Export_Tag is new Export_Nullable (Tags.Question_Mark);
function Export_Anchor is new Export_Nullable (Text.Empty);
function To_Data return Event_Data is
(case Raw.Kind is
when Stream_Start => (T => Stream_Start, Encoding => UTF8),
when Stream_End => (T => Stream_End),
when Document_Start => (T => Document_Start,
Version_Directive => System.Null_Address,
Start_Dir => System.Null_Address,
End_Dir => System.Null_Address,
DS_Implicit => Bool (Raw.Implicit_Start)),
when Document_End => (T => Document_End,
DE_Implicit => Bool (Raw.Implicit_End)),
when Mapping_Start => (T => Mapping_Start,
Map_Anchor => Export_Anchor (Raw.Collection_Properties.Anchor),
Map_Tag => Export_Tag (Raw.Collection_Properties.Tag),
Map_Implicit => False,
Map_Style => Raw.Collection_Style),
when Mapping_End => (T => Mapping_End),
when Sequence_Start => (T => Sequence_Start,
Seq_Anchor => Export_Anchor (Raw.Collection_Properties.Anchor),
Seq_Tag => Export_Tag (Raw.Collection_Properties.Tag),
Seq_Implicit => False,
Seq_Style => Raw.Collection_Style),
when Sequence_End => (T => Sequence_End),
when Scalar => (T => Scalar,
Scalar_Anchor => Export_Anchor (Raw.Scalar_Properties.Anchor),
Scalar_Tag => Export_Tag (Raw.Scalar_Properties.Tag),
Value => Text.Export (Raw.Content),
Length => Interfaces.C.size_t (Raw.Content.Length),
Plain_Implicit => False,
Quoted_Implicit => False,
Scalar_Style => Raw.Scalar_Style),
when Alias => (T => Alias,
Ali_Anchor => Text.Export (Raw.Target)),
when Annotation_Start => (T => Annotation_Start,
Ann_Anchor => Text.Export (Raw.Annotation_Properties.Anchor),
Ann_Tag => Export_Tag (Raw.Annotation_Properties.Tag),
Ann_Name => Text.Export (Raw.Name)),
when Annotation_End => (T => Annotation_End));
begin
E := (Kind => To_Type, Data => To_Data,
Start_Mark => To_C (Raw.Start_Position),
End_Mark => To_C (Raw.End_Position));
return True;
end;
exception
when Storage_Error =>
P.Error := Memory_Error;
-- do not set problem because if we're out of memory, that would
-- likely raise another exception.
return False;
when E : Lexer_Error =>
P.Error := Scanner_Error;
P.Problem := Interfaces.C.Strings.New_String
(Ada.Exceptions.Exception_Message (E));
return False;
when E : Yaml.Parser_Error =>
P.Error := Parser_Error;
P.Problem := Interfaces.C.Strings.New_String
(Ada.Exceptions.Exception_Message (E));
return False;
when E : others =>
P.Error := Parser_Error;
P.Problem := Interfaces.C.Strings.New_String
(Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
return False;
end Parser_Parse;
function Parser_Load (P : in out Parser_Type; Document : System.Address)
return Bool is
pragma Unreferenced (Document);
begin
P.Error := Composer_Error;
P.Problem := Interfaces.C.Strings.New_String
("AdaYaml does not implement the composer API");
return False;
end Parser_Load;
function Emitter_Initialize (Emitter : in out Emitter_Type) return Bool is
begin
Emitter.Ptr := new Presenter.Instance;
return True;
end Emitter_Initialize;
procedure Emitter_Delete (Emitter : in out Emitter_Type) is
procedure Free is new Ada.Unchecked_Deallocation (Presenter.Instance,
Presenter_Pointer);
begin
if Emitter.Problem /= Interfaces.C.Strings.Null_Ptr then
Interfaces.C.Strings.Free (Emitter.Problem);
end if;
Free (Emitter.Ptr);
end Emitter_Delete;
procedure Emitter_Set_Output_String
(Emitter : in out Emitter_Type; Output : System.Address;
Size : Interfaces.C.size_t; Size_Written : access Interfaces.C.size_t) is
begin
Emitter.Ptr.Set_Output (Destination.C_String.As_Destination
(Output, Size, Size_Written));
end Emitter_Set_Output_String;
function File_Write_Handler (Data, Buffer : System.Address;
Size : Interfaces.C.size_t) return Bool with
Convention => C;
function File_Write_Handler (Data, Buffer : System.Address;
Size : Interfaces.C.size_t) return Bool is
(Bool (fwrite (Buffer, 1, Size, Data) = Size));
procedure Emitter_Set_Output_File
(Emitter : in out Emitter_Type; File : System.Address) is
begin
Emitter.Ptr.Set_Output (Destination.C_Handler.As_Destination
(File_Write_Handler'Access, File));
end Emitter_Set_Output_File;
procedure Emitter_Set_Output (Emitter : in out Emitter_Type;
Handler : Write_Handler;
Data : System.Address) is
begin
Emitter.Ptr.Set_Output (Destination.C_Handler.As_Destination
(Handler, Data));
end Emitter_Set_Output;
function Emitter_Emit (Emitter : in out Emitter_Type; E : in out Event)
return Bool is
begin
declare
function To_Properties (Tag, Anchor : Text.Exported)
return Properties is
((Anchor => (if Anchor = System.Null_Address then Text.Empty else
Text.Import (Anchor)),
Tag => (if Tag = System.Null_Address then Tags.Question_Mark else
Text.Import (Tag))));
function To_Event (E : Event) return Yaml.Event is
(case E.Kind is
when Stream_Start => (Kind => Stream_Start,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark)),
when Stream_End => (Kind => Stream_End,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark)),
when Document_Start => (Kind => Document_Start,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark),
Version => Text.Empty,
Implicit_Start => Boolean (E.Data.DS_Implicit)),
when Document_End => (Kind => Document_End,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark),
Implicit_End => Boolean (E.Data.DE_Implicit)),
when Mapping_Start =>
(Kind => Mapping_Start,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark),
Collection_Style => E.Data.Map_Style,
Collection_Properties => To_Properties (E.Data.Map_Tag, E.Data.Map_Anchor)),
when Mapping_End => (Kind => Mapping_End,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark)),
when Sequence_Start =>
(Kind => Sequence_Start,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark),
Collection_Style => E.Data.Seq_Style,
Collection_Properties => To_Properties (E.Data.Seq_Tag, E.Data.Seq_Anchor)),
when Sequence_End => (Kind => Sequence_End,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark)),
when Scalar => (Kind => Scalar,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark),
Scalar_Properties => To_Properties (E.Data.Scalar_Tag, E.Data.Scalar_Anchor),
Content => Text.Import (E.Data.Value),
Scalar_Style => E.Data.Scalar_Style),
when Alias => (Kind => Alias,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark),
Target => Text.Import (E.Data.Ali_Anchor)),
when Annotation_Start => (Kind => Annotation_Start,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark),
Annotation_Properties => To_Properties (E.Data.Ann_Tag, E.Data.Ann_Anchor),
Namespace => Standard_Annotation_Namespace,
Name => Text.Import (E.Data.Ann_Name)),
when Annotation_End => (Kind => Annotation_End,
Start_Position => To_Ada (E.Start_Mark),
End_Position => To_Ada (E.End_Mark)),
when No_Event => (others => <>));
begin
if E.Kind /= No_Event then
Emitter.Ptr.Put (To_Event (E));
end if;
Event_Delete (E);
return True;
end;
exception
when Storage_Error =>
Emitter.Error := Memory_Error;
-- do not set problem because if we're out of memory, that would
-- likely raise another exception.
return False;
when E : Constraint_Error =>
Emitter.Error := Emitter_Error;
Emitter.Problem := Interfaces.C.Strings.New_String
(Ada.Exceptions.Exception_Message (E));
return False;
when E : Yaml.Presenter_Error =>
Emitter.Error := Emitter_Error;
Emitter.Problem := Interfaces.C.Strings.New_String
(Ada.Exceptions.Exception_Message (E));
return False;
when E : others =>
Emitter.Error := Emitter_Error;
Emitter.Problem := Interfaces.C.Strings.New_String
(Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
return False;
end Emitter_Emit;
begin
Creation_Pool.Create (Text.Pool.Default_Size);
end Yaml.C;
|
pragma Task_Dispatching_Policy(FIFO_Within_Priorities);
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Real_Time.Timing_Events; use Ada.Real_Time.Timing_Events;
with Example1; use Example1;
procedure Firm is
task type Periodic_Firm is
pragma Priority(5);
end Periodic_Firm;
task body Periodic_Firm is
Next : Time;
Interval : Time_Span := Milliseconds(1);
begin
Next := Clock + Interval;
loop
select
delay until Next;
Put("-");
then abort
Sense;
end select;
delay until Next;
Next := Next + Interval;
end loop;
end Periodic_Firm;
ftask : Periodic_Firm;
begin
Put_Line("Firm_Task!");
end Firm;
|
with Ada.Strings.Bounded;
with Ada.Strings.Fixed;
with Ada.Containers.Vectors;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Regexp_Readers.Generic_Readers;
--
-- This package hierarchy provides resources to operate with the description
-- of research projects (mostly EU-style, but it can be used in other
-- contexts).
--
-- The model for a project is the following
--
-- * A project has
-- * A name
-- * A short name
-- * A sequence of partners
-- * A sequence of WPs
-- * A risk lists
--
-- * Every PARTNER has
-- * Name, short name, ID, index
-- * A description
-- * A set of roles, every role hase
-- * name, ID
-- * descripiton
-- * cost
--
-- * Every WP has
-- * Name, short name, ID, index, description
-- * WP type (research, admin, ...)
-- * A sequence of tasks
-- * Computed attributes:
-- - begin/end dates
-- - partner effort
-- - deliverables
-- - milestones
--
-- * Every task has
-- * Name, short name, ID, index, description
-- * A parent WP
-- * A dependence list (task depends on...)
-- * A sequence of activity periods. Every period has
-- - begin/end date
-- - intensity
-- - partner effort, every effort has
-- + partner ID
-- + role
-- + number of PM
-- * A set of milestones
-- * A set of deliverables
--
-- * Every milestone has
-- * Name, short name, description, ID, index
-- * A parent task
-- * A due date
--
-- * Every deliverable has
-- * Name, short name, description, ID, index
-- * A parent task
-- * A due date
--
-- A few comments about the data involved
--
-- * Name and short name: they are used to be included in the
-- research proposal by using a special syntax (#{...} ruby-like or
-- \R{...} LaTeX-like?) that uses as parameter entity attributes
-- optionally decorated
--
-- * The dates can be in two format: symbolic and absolute. The idea
-- is that we want to allow for dates like "design.start + 3" to denote
-- three months after the end of the design WP. However, when
-- we need to create, say, a GANNT we need actual months that can be
-- obtained by computing all the symbolic dates.
--
-- * For every element we have at least two indexes: a "local" and
-- a "full" one. For example, task T4.3 has "3" as a local index
-- and "4.3" is the global one and "T4.3" is the "decorated" one.
-- While local and full are not necessarily unique (4.3 can also
-- be a deliverable or a milestone of WP4), the decorated is unique.
--
-- IDs are "labels" for entities and have a hierarchical structure, like
--
-- wp1.task2 -- A task of WP1
-- wp1.blue_print -- A deliverable of WP1
--
-- In the context of WP1 only task2 or blue_print are necessary. We will
-- call the parts separated by "." basic IDs.
--
-- Basic IDs are case insensitive and have the usual "Ada identifier syntax"
-- (letters, numbers and underscores, begin with a letter, no double or
-- final underscore allowed). We cannot use '-' (as it is allowed in XML)
-- since we could want to use the IDs in expression and ambiguity
-- could arise with subtraction.
--
-- An attribute is an ID with a final ".attribute", for example
--
-- wp1.task2.begin -- The begin date of task2
-- wp1.duration -- The overall duration of WP1
--
-- Date attributes can be used in expressions. Attributes can also be included
-- in descriptions using a syntax like
--
-- #command{wp1.task2.begin?option1=a, option2=b}
--
-- where "command" is a specific command and it can be empty
-- (that is, something like "#{wp1.name}" is allowed). The part after "?"
-- is optional and it is used for fine control the attribute format;
-- for example,
--
-- #{dissemination.name?short}
--
-- could be used to insert the "short name" of WP dissemination.
-- We could consider the possibility of default attributes and options
-- so that something like
--
-- #{dissemination}
--
-- is possible. The idea for the default is the following
--
-- * Every "class" of entity (WP, task, deliverable, ...) has a default
-- attribute.
-- * Every attribute associated with an entity (e.g., name of a WP)
-- has a default option list
-- * The maps
--
-- class -> attribute
-- (class, attribute) -> option
--
-- are part of the project attributes.
-- --------------------------------------------------------------------
-- ** Parsers, writers, processors
--
-- In order to read/write textual representations of the projects we will
-- need parsers and writers. Most probably initially we will support only
-- the YAML format since it is fairly easy to parse and to write by hand.
-- In order to allow for new formats we will use a "plugin-like structure"
--
-- A different matter is the production of external files with information
-- taken from the project. For example, LaTeX sources with the WP description
-- or a GANTT chart of the activities in SVG, PDF or TeX format.
--
-- The part of code that takes care of such productions is called a
-- _processor_. Initially most probably we will support two kinds of
-- processors
--
-- 1. Template-based, much in the spirit of AWS templates. If possible,
-- we will try to use them out-of-the-box
-- 2. Server-based: an external processor is launched with some parameters
-- that include a local port that can be queried to get informations
-- about the project. The queries have the format of an attribute
-- query (options included) with the difference that an some special
-- attributes are added, namely:
-- - tasks
-- - delivs
-- - milestones
-- - wps
-- - and maybe others
--
-- The new attributes can be used to query "all the ... of ...". For
-- example, in order to get all the tasks of WP dissemination the
-- processor can ask for
--
-- dissemination.tasks
--
-- The answer will include a space-separated list of the ids of the
-- tasks.
--
-- ----------------------------------------------------------------
-- ** Editing projects
--
-- In editing projects we can add/remove
-- - WP
-- - tasks of a WP
-- - deliverables
-- - milestones
-- - partners
-- - roles in partners
--
-- We can also change
-- - descriptions
-- - names
-- - dates
--
--
package EU_Projects is
-- Is a bound of 10 billions enough?
type Currency is delta 0.01 digits 12 range 0.0 .. 9_999_999_999.99;
Max_ID_Length : constant Positive := 256;
--
-- Function to check if X satisfies the syntax of IDs. Informally, an
-- ID has a syntax similar to an Ada identifier with the following additions
--
-- (1) "." can be used inside the identifier so that "foo.bar" is OK
-- (2) An identifier cannot begin nor end with "_" or "."
-- (3) "_" must always be followed by an alphanumeric char
-- (4) "." must always be followed by a letter
-- (5) At most one "." can be present
--
function Is_Valid_ID (X : String) return Boolean
is (
(X'Length = 0)
or else ((X'Length <= Max_ID_Length)
and then (Is_Letter (X (X'First)) and Is_Alphanumeric (X (X'Last)))
and then (for all I in X'Range =>
(Is_Alphanumeric (X (I))
or else (X (I) = '_' and then Is_Alphanumeric (X (I + 1)))
or else (X (I) = '.' and then Is_Letter (X (I + 1)))))
and then (for all I in X'Range =>
(for all J in I + 1 .. X'Last =>
(if X (I) = '.' then X (J) /= '.'))))
-- Note : in the condition above I+1 is always well defined since
-- if X(X'Last) is alphanumeric, the last two tests are cutted
-- away by the "or else" after Is_Alphanumeric (X (I)), otherwise
-- if X(X'Last) is not alphanumeric, the "for all" will not checked
-- at all because of the preceding "and then"
);
package Bounded_Identifiers is
new Ada.Strings.Bounded.Generic_Bounded_Length (Max_ID_Length);
use Bounded_Identifiers;
type Dotted_Identifier is new Bounded_Identifiers.Bounded_String
with Dynamic_Predicate =>
Is_Valid_ID (To_String (Bounded_String (Dotted_Identifier)));
-- A simple identifier is similar to a Dotted_Identifier, but it
-- cannot have a dot
subtype Simple_Identifier is Dotted_Identifier
with Dynamic_Predicate =>
(for all Ch of To_String (Simple_Identifier) => Ch /= '.');
function Image (X : Dotted_Identifier) return String
is (To_String (X));
function To_ID (X : String)return Dotted_Identifier
is (To_Bounded_String (X))
with Pre => Is_Valid_ID (X);
function Verbose_To_ID (X : String) return Dotted_Identifier;
-- Like To_ID, but it prints some debug info. Useful for debugging.
function Join (X, Y : Simple_Identifier) return Dotted_Identifier
is (To_ID (To_String (X) & "." & To_String (Y)));
function Join (X : Simple_Identifier; Y : String) return Dotted_Identifier
is (Join (X, To_ID (Y)));
package ID_Readers is
new Regexp_Readers.Generic_Readers
(Result_Type => Dotted_Identifier,
Regexp => Regexp_Readers.Dotted_Identifier,
Convert => To_ID);
package ID_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Dotted_Identifier);
subtype ID_List is ID_Vectors.Vector;
function To_ID_List (Input : String;
Separators : String := " ,")
return ID_List;
Bad_Identifier : exception;
Bad_Input : exception;
-- The result of function 'Image associated to discrete types has
-- a space at the beginning. That space is quite annoying and needs
-- to be trimmed. This function is here so that everyone can use it
function Chop (X : String) return String
is (Ada.Strings.Fixed.Trim (X, Ada.Strings.Both));
function Image (X : Integer) return String
is (Chop (Integer'Image (X)));
end EU_Projects;
|
-- { dg-do compile }
-- { dg-options "-O3" }
with Opt3_Pkg; use Opt3_Pkg;
procedure Opt3 is
type Buffer_Type is array (Integer range <> ) of Short_Integer;
B : Buffer_Type (1 .. 256) := (others => 0);
begin
F (B(1));
end;
|
-- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Utils.Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
-- begin read only
-- end read only
package body Utils.Test_Data.Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
function Wrap_Test_Get_Random_254206_4c55ca
(Min, Max: Integer) return Integer is
begin
begin
pragma Assert(Min <= Max);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(utils.ads:0):Test_GetRandom test requirement violated");
end;
declare
Test_Get_Random_254206_4c55ca_Result: constant Integer :=
GNATtest_Generated.GNATtest_Standard.Utils.Get_Random(Min, Max);
begin
begin
pragma Assert(Test_Get_Random_254206_4c55ca_Result in Min .. Max);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(utils.ads:0:):Test_GetRandom test commitment violated");
end;
return Test_Get_Random_254206_4c55ca_Result;
end;
end Wrap_Test_Get_Random_254206_4c55ca;
-- end read only
-- begin read only
procedure Test_Get_Random_test_getrandom(Gnattest_T: in out Test);
procedure Test_Get_Random_254206_4c55ca(Gnattest_T: in out Test) renames
Test_Get_Random_test_getrandom;
-- id:2.2/2542065c792cecb1/Get_Random/1/0/test_getrandom/
procedure Test_Get_Random_test_getrandom(Gnattest_T: in out Test) is
function Get_Random(Min, Max: Integer) return Integer renames
Wrap_Test_Get_Random_254206_4c55ca;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
for I in 1 .. 5 loop
Assert(Get_Random(1, 5) in 1 .. 5, "Wrong random number returned.");
end loop;
Assert(Get_Random(5, 5) = 5, "Wrong random number from 5 returned.");
-- begin read only
end Test_Get_Random_test_getrandom;
-- end read only
-- begin read only
function Wrap_Test_Days_Difference_3eb9cd_fd50f2
(Date_To_Compare: Date_Record) return Integer is
begin
declare
Test_Days_Difference_3eb9cd_fd50f2_Result: constant Integer :=
GNATtest_Generated.GNATtest_Standard.Utils.Days_Difference
(Date_To_Compare);
begin
return Test_Days_Difference_3eb9cd_fd50f2_Result;
end;
end Wrap_Test_Days_Difference_3eb9cd_fd50f2;
-- end read only
-- begin read only
procedure Test_Days_Difference_test_daysdifference(Gnattest_T: in out Test);
procedure Test_Days_Difference_3eb9cd_fd50f2
(Gnattest_T: in out Test) renames
Test_Days_Difference_test_daysdifference;
-- id:2.2/3eb9cd623ef6a20f/Days_Difference/1/0/test_daysdifference/
procedure Test_Days_Difference_test_daysdifference
(Gnattest_T: in out Test) is
function Days_Difference
(Date_To_Compare: Date_Record) return Integer renames
Wrap_Test_Days_Difference_3eb9cd_fd50f2;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Game_Date := (1_600, 1, 2, 0, 0);
Assert
(Days_Difference((1_600, 1, 1, 0, 0)) = 1,
"Invalid count of days difference between game dates.");
-- begin read only
end Test_Days_Difference_test_daysdifference;
-- end read only
-- begin read only
function Wrap_Test_Generate_Robotic_Name_eb65d6_cad966
return Unbounded_String is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(utils.ads:0):Test_GenerateRoboticName test requirement violated");
end;
declare
Test_Generate_Robotic_Name_eb65d6_cad966_Result: constant Unbounded_String :=
GNATtest_Generated.GNATtest_Standard.Utils.Generate_Robotic_Name;
begin
begin
pragma Assert
(Length
(Source => Test_Generate_Robotic_Name_eb65d6_cad966_Result) >
0);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(utils.ads:0:):Test_GenerateRoboticName test commitment violated");
end;
return Test_Generate_Robotic_Name_eb65d6_cad966_Result;
end;
end Wrap_Test_Generate_Robotic_Name_eb65d6_cad966;
-- end read only
-- begin read only
procedure Test_Generate_Robotic_Name_test_generateroboticname
(Gnattest_T: in out Test);
procedure Test_Generate_Robotic_Name_eb65d6_cad966
(Gnattest_T: in out Test) renames
Test_Generate_Robotic_Name_test_generateroboticname;
-- id:2.2/eb65d6968733e831/Generate_Robotic_Name/1/0/test_generateroboticname/
procedure Test_Generate_Robotic_Name_test_generateroboticname
(Gnattest_T: in out Test) is
function Generate_Robotic_Name return Unbounded_String renames
Wrap_Test_Generate_Robotic_Name_eb65d6_cad966;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Assert
(Length(Generate_Robotic_Name) > 0,
"Failed to generate robotic name.");
-- begin read only
end Test_Generate_Robotic_Name_test_generateroboticname;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Utils.Test_Data.Tests;
|
-- This file is generated by SWIG. Do *not* modify by hand.
--
with Interfaces.C.Strings;
package LLVM_link_time_Optimizer.Binding is
LTO_H : constant := 1;
LTO_API_VERSION : constant := 3;
function lto_get_version return Interfaces.C.Strings.chars_ptr;
function lto_get_error_message return Interfaces.C.Strings.chars_ptr;
function lto_module_is_object_file
(path : in Interfaces.C.Strings.chars_ptr)
return Interfaces.C.Extensions.bool;
function lto_module_is_object_file_for_target
(path : in Interfaces.C.Strings.chars_ptr;
target_triple_prefix : in Interfaces.C.Strings.chars_ptr)
return Interfaces.C.Extensions.bool;
function lto_module_is_object_file_in_memory
(mem : access Interfaces.C.Extensions.void;
length : in Interfaces.C.size_t)
return Interfaces.C.Extensions.bool;
function lto_module_is_object_file_in_memory_for_target
(mem : access Interfaces.C.Extensions.void;
length : in Interfaces.C.size_t;
target_triple_prefix : in Interfaces.C.Strings.chars_ptr)
return Interfaces.C.Extensions.bool;
function lto_module_create
(path : in Interfaces.C.Strings.chars_ptr)
return LLVM_link_time_Optimizer.lto_module_t;
function lto_module_create_from_memory
(mem : access Interfaces.C.Extensions.void;
length : in Interfaces.C.size_t)
return LLVM_link_time_Optimizer.lto_module_t;
procedure lto_module_dispose
(the_mod : in LLVM_link_time_Optimizer.lto_module_t);
function lto_module_get_target_triple
(the_mod : in LLVM_link_time_Optimizer.lto_module_t)
return Interfaces.C.Strings.chars_ptr;
function lto_module_get_num_symbols
(the_mod : in LLVM_link_time_Optimizer.lto_module_t)
return Interfaces.C.unsigned;
function lto_module_get_symbol_name
(the_mod : in LLVM_link_time_Optimizer.lto_module_t;
index : in Interfaces.C.unsigned)
return Interfaces.C.Strings.chars_ptr;
function lto_module_get_symbol_attribute
(the_mod : in LLVM_link_time_Optimizer.lto_module_t;
index : in Interfaces.C.unsigned)
return LLVM_link_time_Optimizer.lto_symbol_attributes;
function lto_codegen_create return LLVM_link_time_Optimizer.lto_code_gen_t;
procedure lto_codegen_dispose
(arg_1 : in LLVM_link_time_Optimizer.lto_code_gen_t);
function lto_codegen_add_module
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
the_mod : in LLVM_link_time_Optimizer.lto_module_t)
return Interfaces.C.Extensions.bool;
function lto_codegen_set_debug_model
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
arg_1 : in LLVM_link_time_Optimizer.lto_debug_model)
return Interfaces.C.Extensions.bool;
function lto_codegen_set_pic_model
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
arg_1 : in LLVM_link_time_Optimizer.lto_codegen_model)
return Interfaces.C.Extensions.bool;
procedure lto_codegen_set_gcc_path
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
path : in Interfaces.C.Strings.chars_ptr);
procedure lto_codegen_set_assembler_path
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
path : in Interfaces.C.Strings.chars_ptr);
procedure lto_codegen_add_must_preserve_symbol
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
symbol : in Interfaces.C.Strings.chars_ptr);
function lto_codegen_write_merged_modules
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
path : in Interfaces.C.Strings.chars_ptr)
return Interfaces.C.Extensions.bool;
function lto_codegen_compile
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
length : access Interfaces.C.size_t)
return access Interfaces.C.Extensions.void;
procedure lto_codegen_debug_options
(cg : in LLVM_link_time_Optimizer.lto_code_gen_t;
arg_1 : in Interfaces.C.Strings.chars_ptr);
function llvm_create_optimizer return
LLVM_link_time_Optimizer.llvm_lto_t;
procedure llvm_destroy_optimizer
(lto : in LLVM_link_time_Optimizer.llvm_lto_t);
function llvm_read_object_file
(lto : in LLVM_link_time_Optimizer.llvm_lto_t;
input_filename : in Interfaces.C.Strings.chars_ptr)
return LLVM_link_time_Optimizer.llvm_lto_status_t;
function llvm_optimize_modules
(lto : in LLVM_link_time_Optimizer.llvm_lto_t;
output_filename : in Interfaces.C.Strings.chars_ptr)
return LLVM_link_time_Optimizer.llvm_lto_status_t;
private
pragma Import (C, lto_get_version, "Ada_lto_get_version");
pragma Import (C, lto_get_error_message, "Ada_lto_get_error_message");
pragma Import
(C,
lto_module_is_object_file,
"Ada_lto_module_is_object_file");
pragma Import
(C,
lto_module_is_object_file_for_target,
"Ada_lto_module_is_object_file_for_target");
pragma Import
(C,
lto_module_is_object_file_in_memory,
"Ada_lto_module_is_object_file_in_memory");
pragma Import
(C,
lto_module_is_object_file_in_memory_for_target,
"Ada_lto_module_is_object_file_in_memory_for_target");
pragma Import (C, lto_module_create, "Ada_lto_module_create");
pragma Import
(C,
lto_module_create_from_memory,
"Ada_lto_module_create_from_memory");
pragma Import (C, lto_module_dispose, "Ada_lto_module_dispose");
pragma Import
(C,
lto_module_get_target_triple,
"Ada_lto_module_get_target_triple");
pragma Import
(C,
lto_module_get_num_symbols,
"Ada_lto_module_get_num_symbols");
pragma Import
(C,
lto_module_get_symbol_name,
"Ada_lto_module_get_symbol_name");
pragma Import
(C,
lto_module_get_symbol_attribute,
"Ada_lto_module_get_symbol_attribute");
pragma Import (C, lto_codegen_create, "Ada_lto_codegen_create");
pragma Import (C, lto_codegen_dispose, "Ada_lto_codegen_dispose");
pragma Import (C, lto_codegen_add_module, "Ada_lto_codegen_add_module");
pragma Import
(C,
lto_codegen_set_debug_model,
"Ada_lto_codegen_set_debug_model");
pragma Import
(C,
lto_codegen_set_pic_model,
"Ada_lto_codegen_set_pic_model");
pragma Import
(C,
lto_codegen_set_gcc_path,
"Ada_lto_codegen_set_gcc_path");
pragma Import
(C,
lto_codegen_set_assembler_path,
"Ada_lto_codegen_set_assembler_path");
pragma Import
(C,
lto_codegen_add_must_preserve_symbol,
"Ada_lto_codegen_add_must_preserve_symbol");
pragma Import
(C,
lto_codegen_write_merged_modules,
"Ada_lto_codegen_write_merged_modules");
pragma Import (C, lto_codegen_compile, "Ada_lto_codegen_compile");
pragma Import
(C,
lto_codegen_debug_options,
"Ada_lto_codegen_debug_options");
pragma Import (C, llvm_create_optimizer, "Ada_llvm_create_optimizer");
pragma Import (C, llvm_destroy_optimizer, "Ada_llvm_destroy_optimizer");
pragma Import (C, llvm_read_object_file, "Ada_llvm_read_object_file");
pragma Import (C, llvm_optimize_modules, "Ada_llvm_optimize_modules");
end LLVM_link_time_Optimizer.Binding;
|
package impact.d2.orbs.Joint.pulley
--
--
--
is
--
-- #ifndef B2_PULLEY_JOINT_H
-- #define B2_PULLEY_JOINT_H
--
-- #include <Box2D/Dynamics/Joints/b2Joint.h>
--
-- const float32 b2_minPulleyLength = 2.0f;
--
-- /// Pulley joint definition. This requires two ground anchors,
-- /// two dynamic body anchor points, max lengths for each side,
-- /// and a pulley ratio.
-- struct b2PulleyJointDef : public b2JointDef
-- {
-- b2PulleyJointDef()
-- {
-- type = e_pulleyJoint;
-- groundAnchorA.Set(-1.0f, 1.0f);
-- groundAnchorB.Set(1.0f, 1.0f);
-- localAnchorA.Set(-1.0f, 0.0f);
-- localAnchorB.Set(1.0f, 0.0f);
-- lengthA = 0.0f;
-- maxLengthA = 0.0f;
-- lengthB = 0.0f;
-- maxLengthB = 0.0f;
-- ratio = 1.0f;
-- collideConnected = true;
-- }
--
-- /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
-- void Initialize(b2Body* bodyA, b2Body* bodyB,
-- const b2Vec2& groundAnchorA, const b2Vec2& groundAnchorB,
-- const b2Vec2& anchorA, const b2Vec2& anchorB,
-- float32 ratio);
--
-- /// The first ground anchor in world coordinates. This point never moves.
-- b2Vec2 groundAnchorA;
--
-- /// The second ground anchor in world coordinates. This point never moves.
-- b2Vec2 groundAnchorB;
--
-- /// The local anchor point relative to bodyA's origin.
-- b2Vec2 localAnchorA;
--
-- /// The local anchor point relative to bodyB's origin.
-- b2Vec2 localAnchorB;
--
-- /// The a reference length for the segment attached to bodyA.
-- float32 lengthA;
--
-- /// The maximum length of the segment attached to bodyA.
-- float32 maxLengthA;
--
-- /// The a reference length for the segment attached to bodyB.
-- float32 lengthB;
--
-- /// The maximum length of the segment attached to bodyB.
-- float32 maxLengthB;
--
-- /// The pulley ratio, used to simulate a block-and-tackle.
-- float32 ratio;
-- };
--
-- /// The pulley joint is connected to two bodies and two fixed ground points.
-- /// The pulley supports a ratio such that:
-- /// length1 + ratio * length2 <= constant
-- /// Yes, the force transmitted is scaled by the ratio.
-- /// The pulley also enforces a maximum length limit on both sides. This is
-- /// useful to prevent one side of the pulley hitting the top.
-- class b2PulleyJoint : public b2Joint
-- {
-- public:
-- b2Vec2 GetAnchorA() const;
-- b2Vec2 GetAnchorB() const;
--
-- b2Vec2 GetReactionForce(float32 inv_dt) const;
-- float32 GetReactionTorque(float32 inv_dt) const;
--
-- /// Get the first ground anchor.
-- b2Vec2 GetGroundAnchorA() const;
--
-- /// Get the second ground anchor.
-- b2Vec2 GetGroundAnchorB() const;
--
-- /// Get the current length of the segment attached to body1.
-- float32 GetLength1() const;
--
-- /// Get the current length of the segment attached to body2.
-- float32 GetLength2() const;
--
-- /// Get the pulley ratio.
-- float32 GetRatio() const;
--
-- protected:
--
-- friend class b2Joint;
-- b2PulleyJoint(const b2PulleyJointDef* data);
--
-- void InitVelocityConstraints(const b2TimeStep& step);
-- void SolveVelocityConstraints(const b2TimeStep& step);
-- bool SolvePositionConstraints(float32 baumgarte);
--
-- b2Vec2 m_groundAnchor1;
-- b2Vec2 m_groundAnchor2;
-- b2Vec2 m_localAnchor1;
-- b2Vec2 m_localAnchor2;
--
-- b2Vec2 m_u1;
-- b2Vec2 m_u2;
--
-- float32 m_constant;
-- float32 m_ratio;
--
-- float32 m_maxLength1;
-- float32 m_maxLength2;
--
-- // Effective masses
-- float32 m_pulleyMass;
-- float32 m_limitMass1;
-- float32 m_limitMass2;
--
-- // Impulses for accumulation/warm starting.
-- float32 m_impulse;
-- float32 m_limitImpulse1;
-- float32 m_limitImpulse2;
--
-- b2LimitState m_state;
-- b2LimitState m_limitState1;
-- b2LimitState m_limitState2;
-- };
--
-- #endif
procedure dummy;
end impact.d2.orbs.Joint.pulley;
|
with
lace.make_Subject,
lace.make_Observer,
lace.Any,
lace.Subject,
lace.Observer;
private
with
ada.Strings.unbounded;
package lace.Subject_and_instant_Observer
--
-- Provides a concrete type for a combined event Subject and an instant Observer.
--
is
type Item is limited new lace.Any.limited_item
and lace.Subject .item
and lace.Observer .item with private;
type View is access all Item'Class;
package Forge
is
function to_Subject_and_Observer (Name : in String) return Item;
end Forge;
overriding
function Name (Self : in Item) return String;
private
use ada.Strings.unbounded;
package Subject is new make_Subject (Any.limited_item);
package Observer is new make_Observer (Subject .item);
type Item is limited new Observer.item with
record
Name : unbounded_String;
end record;
end lace.Subject_and_instant_Observer;
|
-- This file is generated by SWIG. Please do *not* modify by hand.
--
with gmp_c.Pointers;
with gmp_c.a_a_gmp_randstate_struct;
with gmp_c.gmp_randstate_t;
with gmp_c.mp_ptr;
with gmp_c.mp_srcptr;
with gmp_c.mpf_ptr;
with gmp_c.mpf_srcptr;
with gmp_c.mpf_t;
with gmp_c.mpq_ptr;
with gmp_c.mpq_srcptr;
with gmp_c.mpz_ptr;
with gmp_c.mpz_srcptr;
with Interfaces.C;
with Interfaces.C.Strings;
with Swig;
with Swig.Pointers;
with Interfaces.C;
package gmp_c.Binding is
procedure randinit
(arg_3_1 : in gmp_c.gmp_randstate_t.Item;
arg_3_2 : in gmp_c.gmp_randalg_t);
procedure randinit_default (arg_1 : in gmp_c.gmp_randstate_t.Item);
procedure randinit_lc_2exp
(arg_4_1 : in gmp_c.gmp_randstate_t.Item;
arg_4_2 : in gmp_c.mpz_srcptr.Item;
arg_4_3 : in Interfaces.C.unsigned_long;
arg_4_4 : in gmp_c.mp_bitcnt_t);
function randinit_lc_2exp_size
(arg_2_1 : in gmp_c.gmp_randstate_t.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) return Interfaces.C.int;
procedure randinit_mt (arg_1 : in gmp_c.gmp_randstate_t.Item);
procedure randinit_set
(arg_2_1 : in gmp_c.gmp_randstate_t.Item;
arg_2_2 : in gmp_c.a_a_gmp_randstate_struct.Pointer);
procedure randseed
(arg_2_1 : in gmp_c.gmp_randstate_t.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure randseed_ui
(arg_2_1 : in gmp_c.gmp_randstate_t.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure randclear (arg_1 : in gmp_c.gmp_randstate_t.Item);
function urandomb_ui
(arg_2_1 : in gmp_c.gmp_randstate_t.Item;
arg_2_2 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
function urandomm_ui
(arg_2_1 : in gmp_c.gmp_randstate_t.Item;
arg_2_2 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
function asprintf
(arg_3_1 : in Swig.Pointers.chars_ptr_Pointer;
arg_3_2 : in Interfaces.C.Strings.chars_ptr) return Interfaces.C.int;
function printf
(arg_2 : in Interfaces.C.Strings.chars_ptr) return Interfaces.C.int;
function snprintf
(arg_4_1 : in Interfaces.C.Strings.chars_ptr;
arg_4_2 : in Interfaces.C.size_t;
arg_4_3 : in Interfaces.C.Strings.chars_ptr) return Interfaces.C.int;
function sprintf
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.Strings.chars_ptr) return Interfaces.C.int;
function scanf
(arg_2 : in Interfaces.C.Strings.chars_ptr) return Interfaces.C.int;
function sscanf
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.Strings.chars_ptr) return Interfaces.C.int;
function realloc
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t) return Swig.void_ptr;
procedure add
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure add_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure addmul
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure addmul_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure z_and
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure array_init
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mp_size_t;
arg_3_3 : in gmp_c.mp_size_t);
procedure bin_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure bin_uiui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure cdiv_q
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure cdiv_q_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function cdiv_q_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure cdiv_qr
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_ptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in gmp_c.mpz_srcptr.Item);
function cdiv_qr_ui
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_ptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure cdiv_r
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure cdiv_r_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function cdiv_r_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
function cdiv_ui
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure clear (arg_1 : in gmp_c.mpz_ptr.Item);
procedure a_a_gmpz_clears (arg_2 : in gmp_c.mpz_ptr.Item);
procedure clrbit
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
function cmp
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function cmp_d
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.double) return Interfaces.C.int;
function a_a_gmpz_cmp_si
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.long) return Interfaces.C.int;
function a_a_gmpz_cmp_ui
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
function cmpabs
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function cmpabs_d
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.double) return Interfaces.C.int;
function cmpabs_ui
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
procedure com
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure combit
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
function congruent_p
(arg_3_1 : in gmp_c.mpz_srcptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function congruent_2exp_p
(arg_3_1 : in gmp_c.mpz_srcptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) return Interfaces.C.int;
function congruent_ui_p
(arg_3_1 : in gmp_c.mpz_srcptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
procedure divexact
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure divexact_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
function divisible_p
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function divisible_ui_p
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
function divisible_2exp_p
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) return Interfaces.C.int;
procedure dump (arg_1 : in gmp_c.mpz_srcptr.Item);
function z_export
(arg_7_1 : in Swig.void_ptr;
arg_7_2 : in Swig.Pointers.size_t_Pointer;
arg_7_3 : in Interfaces.C.int;
arg_7_4 : in Interfaces.C.size_t;
arg_7_5 : in Interfaces.C.int;
arg_7_6 : in Interfaces.C.size_t;
arg_7_7 : in gmp_c.mpz_srcptr.Item) return Swig.void_ptr;
procedure fac_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure a_a_gmpz_2fac_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure a_a_gmpz_mfac_uiui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure a_a_gmpz_primorial_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure fdiv_q
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure fdiv_q_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function fdiv_q_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure fdiv_qr
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_ptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in gmp_c.mpz_srcptr.Item);
function fdiv_qr_ui
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_ptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure fdiv_r
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure fdiv_r_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function fdiv_r_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
function fdiv_ui
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure fib_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure fib2_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_ptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
function fits_sint_p
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_slong_p
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_sshort_p
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
procedure gcd
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
function gcd_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure gcdext
(arg_5_1 : in gmp_c.mpz_ptr.Item;
arg_5_2 : in gmp_c.mpz_ptr.Item;
arg_5_3 : in gmp_c.mpz_ptr.Item;
arg_5_4 : in gmp_c.mpz_srcptr.Item;
arg_5_5 : in gmp_c.mpz_srcptr.Item);
function get_d
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.double;
function get_d_2exp
(arg_2_1 : in Swig.Pointers.long_Pointer;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.double;
function get_si (arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.long;
function get_str
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.int;
arg_3_3 : in gmp_c.mpz_srcptr.Item)
return Interfaces.C.Strings.chars_ptr;
function hamdist
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return gmp_c.mp_bitcnt_t;
procedure import
(arg_7_1 : in gmp_c.mpz_ptr.Item;
arg_7_2 : in Interfaces.C.size_t;
arg_7_3 : in Interfaces.C.int;
arg_7_4 : in Interfaces.C.size_t;
arg_7_5 : in Interfaces.C.int;
arg_7_6 : in Interfaces.C.size_t;
arg_7_7 : in Swig.void_ptr);
procedure init (arg_1 : in gmp_c.mpz_ptr.Item);
procedure init2
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
procedure a_a_gmpz_inits (arg_2 : in gmp_c.mpz_ptr.Item);
procedure init_set
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure init_set_d
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure init_set_si
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.long);
function init_set_str
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
procedure init_set_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
function invert
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
procedure ior
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
function jacobi
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function kronecker_si
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.long) return Interfaces.C.int;
function kronecker_ui
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
function si_kronecker
(arg_2_1 : in Interfaces.C.long;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function ui_kronecker
(arg_2_1 : in Interfaces.C.unsigned_long;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
procedure lcm
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure lcm_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure lucnum_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure lucnum2_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_ptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
function millerrabin
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.int) return Interfaces.C.int;
procedure the_mod
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure mul
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure mul_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure mul_si
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.long);
procedure mul_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure nextprime
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
function perfect_power_p
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
procedure pow_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure powm
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_srcptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in gmp_c.mpz_srcptr.Item);
procedure a_a_gmpz_powm_sec
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_srcptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in gmp_c.mpz_srcptr.Item);
procedure powm_ui
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_srcptr.Item;
arg_4_3 : in Interfaces.C.unsigned_long;
arg_4_4 : in gmp_c.mpz_srcptr.Item);
function probab_prime_p
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.int) return Interfaces.C.int;
procedure random
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t);
procedure random2
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t);
procedure realloc2
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
function remove
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item) return gmp_c.mp_bitcnt_t;
function root
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
procedure rootrem
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_ptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in Interfaces.C.unsigned_long);
procedure rrandomb
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function scan0
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) return gmp_c.mp_bitcnt_t;
function scan1
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) return gmp_c.mp_bitcnt_t;
procedure set
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure set_d
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure set_f
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure set_si
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.long);
function set_str
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
procedure set_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure setbit
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
function sizeinbase
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.int) return Interfaces.C.size_t;
procedure sqrt
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure sqrtrem
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_ptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure sub
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure sub_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure ui_sub
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure submul
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure submul_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure swap
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_ptr.Item);
function tdiv_ui
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure tdiv_q
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure tdiv_q_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function tdiv_q_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure tdiv_qr
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_ptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in gmp_c.mpz_srcptr.Item);
function tdiv_qr_ui
(arg_4_1 : in gmp_c.mpz_ptr.Item;
arg_4_2 : in gmp_c.mpz_ptr.Item;
arg_4_3 : in gmp_c.mpz_srcptr.Item;
arg_4_4 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
procedure tdiv_r
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure tdiv_r_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function tdiv_r_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long)
return Interfaces.C.unsigned_long;
function tstbit
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) return Interfaces.C.int;
procedure ui_pow_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure urandomb
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure urandomm
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure z_xor
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure add
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure canonicalize (arg_1 : in gmp_c.mpq_ptr.Item);
procedure clear (arg_1 : in gmp_c.mpq_ptr.Item);
procedure a_a_gmpq_clears (arg_2 : in gmp_c.mpq_ptr.Item);
function cmp
(arg_2_1 : in gmp_c.mpq_srcptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item) return Interfaces.C.int;
function a_a_gmpq_cmp_si
(arg_3_1 : in gmp_c.mpq_srcptr.Item;
arg_3_2 : in Interfaces.C.long;
arg_3_3 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
function a_a_gmpq_cmp_ui
(arg_3_1 : in gmp_c.mpq_srcptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
function a_a_gmpq_cmp_z
(arg_2_1 : in gmp_c.mpq_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
procedure div
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure div_2exp
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function equal
(arg_2_1 : in gmp_c.mpq_srcptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item) return Interfaces.C.int;
procedure get_num
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item);
procedure get_den
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item);
function get_d
(arg_1 : in gmp_c.mpq_srcptr.Item) return Interfaces.C.double;
function get_str
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.int;
arg_3_3 : in gmp_c.mpq_srcptr.Item)
return Interfaces.C.Strings.chars_ptr;
procedure init (arg_1 : in gmp_c.mpq_ptr.Item);
procedure a_a_gmpq_inits (arg_2 : in gmp_c.mpq_ptr.Item);
procedure inv
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item);
procedure mul
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure mul_2exp
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure set
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item);
procedure set_d
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure set_den
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure set_f
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure set_num
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure set_si
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.long;
arg_3_3 : in Interfaces.C.unsigned_long);
function set_str
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
procedure set_ui
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure set_z
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure sub
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure swap
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpq_ptr.Item);
procedure the_abs
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure add
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure add_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure ceil
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure clear (arg_1 : in gmp_c.mpf_ptr.Item);
procedure a_a_gmpf_clears (arg_2 : in gmp_c.mpf_ptr.Item);
function cmp
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function a_a_gmpf_cmp_z
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function cmp_d
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in Interfaces.C.double) return Interfaces.C.int;
function cmp_si
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in Interfaces.C.long) return Interfaces.C.int;
function cmp_ui
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) return Interfaces.C.int;
procedure div
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure div_2exp
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure div_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure dump (arg_1 : in gmp_c.mpf_srcptr.Item);
function eq
(arg_3_1 : in gmp_c.mpf_srcptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) return Interfaces.C.int;
function fits_sint_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_slong_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_sshort_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_uint_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_ulong_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_ushort_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
procedure floor
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
function get_d
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.double;
function get_d_2exp
(arg_2_1 : in Swig.Pointers.long_Pointer;
arg_2_2 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.double;
function get_default_prec return gmp_c.mp_bitcnt_t;
function get_prec
(arg_1 : in gmp_c.mpf_srcptr.Item) return gmp_c.mp_bitcnt_t;
function get_si (arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.long;
function get_str
(arg_5_1 : in Interfaces.C.Strings.chars_ptr;
arg_5_2 : in gmp_c.Pointers.mp_exp_t_Pointer;
arg_5_3 : in Interfaces.C.int;
arg_5_4 : in Interfaces.C.size_t;
arg_5_5 : in gmp_c.mpf_srcptr.Item)
return Interfaces.C.Strings.chars_ptr;
function get_ui
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.unsigned_long;
procedure init (arg_1 : in gmp_c.mpf_ptr.Item);
procedure init2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
procedure a_a_gmpf_inits (arg_2 : in gmp_c.mpf_ptr.Item);
procedure init_set
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure init_set_d
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure init_set_si
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.long);
function init_set_str
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
procedure init_set_ui
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
function integer_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
procedure mul
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure mul_2exp
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure mul_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure neg
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure pow_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure random2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mp_size_t;
arg_3_3 : in gmp_c.mp_exp_t);
procedure reldiff
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure set
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure set_d
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure set_default_prec (arg_1 : in gmp_c.mp_bitcnt_t);
procedure set_prec
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
procedure set_prec_raw
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
procedure set_q
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item);
procedure set_si
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.long);
function set_str
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
procedure set_ui
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure set_z
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
function size (arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.size_t;
procedure sqrt
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure sqrt_ui
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure sub
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure sub_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure swap
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_ptr.Item);
procedure trunc
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure ui_div
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure ui_sub
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure urandomb
(arg_3_1 : in gmp_c.mpf_t.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
function a_a_gmpn_add_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
function a_a_gmpn_addmul_1
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_size_t;
arg_4_4 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
procedure a_a_gmpn_divexact_1
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_size_t;
arg_4_4 : in gmp_c.mp_limb_t);
function a_a_gmpn_divexact_by3c
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_size_t;
arg_4_4 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
function a_a_gmpn_divrem
(arg_6_1 : in gmp_c.mp_ptr.Item;
arg_6_2 : in gmp_c.mp_size_t;
arg_6_3 : in gmp_c.mp_ptr.Item;
arg_6_4 : in gmp_c.mp_size_t;
arg_6_5 : in gmp_c.mp_srcptr.Item;
arg_6_6 : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
function a_a_gmpn_divrem_1
(arg_5_1 : in gmp_c.mp_ptr.Item;
arg_5_2 : in gmp_c.mp_size_t;
arg_5_3 : in gmp_c.mp_srcptr.Item;
arg_5_4 : in gmp_c.mp_size_t;
arg_5_5 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
function a_a_gmpn_divrem_2
(arg_5_1 : in gmp_c.mp_ptr.Item;
arg_5_2 : in gmp_c.mp_size_t;
arg_5_3 : in gmp_c.mp_ptr.Item;
arg_5_4 : in gmp_c.mp_size_t;
arg_5_5 : in gmp_c.mp_srcptr.Item) return gmp_c.mp_limb_t;
function a_a_gmpn_div_qr_2
(arg_5_1 : in gmp_c.mp_ptr.Item;
arg_5_2 : in gmp_c.mp_ptr.Item;
arg_5_3 : in gmp_c.mp_srcptr.Item;
arg_5_4 : in gmp_c.mp_size_t;
arg_5_5 : in gmp_c.mp_srcptr.Item) return gmp_c.mp_limb_t;
function a_a_gmpn_gcd
(arg_5_1 : in gmp_c.mp_ptr.Item;
arg_5_2 : in gmp_c.mp_ptr.Item;
arg_5_3 : in gmp_c.mp_size_t;
arg_5_4 : in gmp_c.mp_ptr.Item;
arg_5_5 : in gmp_c.mp_size_t) return gmp_c.mp_size_t;
function a_a_gmpn_gcd_1
(arg_3_1 : in gmp_c.mp_srcptr.Item;
arg_3_2 : in gmp_c.mp_size_t;
arg_3_3 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
function a_a_gmpn_gcdext_1
(arg_4_1 : in gmp_c.Pointers.mp_limb_signed_t_Pointer;
arg_4_2 : in gmp_c.Pointers.mp_limb_signed_t_Pointer;
arg_4_3 : in gmp_c.mp_limb_t;
arg_4_4 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
function a_a_gmpn_gcdext
(arg_7_1 : in gmp_c.mp_ptr.Item;
arg_7_2 : in gmp_c.mp_ptr.Item;
arg_7_3 : in gmp_c.Pointers.mp_size_t_Pointer;
arg_7_4 : in gmp_c.mp_ptr.Item;
arg_7_5 : in gmp_c.mp_size_t;
arg_7_6 : in gmp_c.mp_ptr.Item;
arg_7_7 : in gmp_c.mp_size_t) return gmp_c.mp_size_t;
function a_a_gmpn_get_str
(arg_4_1 : in Swig.Pointers.unsigned_char_Pointer;
arg_4_2 : in Interfaces.C.int;
arg_4_3 : in gmp_c.mp_ptr.Item;
arg_4_4 : in gmp_c.mp_size_t) return Interfaces.C.size_t;
function a_a_gmpn_hamdist
(arg_3_1 : in gmp_c.mp_srcptr.Item;
arg_3_2 : in gmp_c.mp_srcptr.Item;
arg_3_3 : in gmp_c.mp_size_t) return gmp_c.mp_bitcnt_t;
function a_a_gmpn_lshift
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_size_t;
arg_4_4 : in Interfaces.C.unsigned) return gmp_c.mp_limb_t;
function a_a_gmpn_mod_1
(arg_3_1 : in gmp_c.mp_srcptr.Item;
arg_3_2 : in gmp_c.mp_size_t;
arg_3_3 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
function a_a_gmpn_mul
(arg_5_1 : in gmp_c.mp_ptr.Item;
arg_5_2 : in gmp_c.mp_srcptr.Item;
arg_5_3 : in gmp_c.mp_size_t;
arg_5_4 : in gmp_c.mp_srcptr.Item;
arg_5_5 : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
function a_a_gmpn_mul_1
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_size_t;
arg_4_4 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
procedure a_a_gmpn_mul_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_sqr
(arg_3_1 : in gmp_c.mp_ptr.Item;
arg_3_2 : in gmp_c.mp_srcptr.Item;
arg_3_3 : in gmp_c.mp_size_t);
procedure a_a_gmpn_com
(arg_3_1 : in gmp_c.mp_ptr.Item;
arg_3_2 : in gmp_c.mp_srcptr.Item;
arg_3_3 : in gmp_c.mp_size_t);
function a_a_gmpn_perfect_square_p
(arg_2_1 : in gmp_c.mp_srcptr.Item;
arg_2_2 : in gmp_c.mp_size_t) return Interfaces.C.int;
function a_a_gmpn_perfect_power_p
(arg_2_1 : in gmp_c.mp_srcptr.Item;
arg_2_2 : in gmp_c.mp_size_t) return Interfaces.C.int;
function a_a_gmpn_popcount
(arg_2_1 : in gmp_c.mp_srcptr.Item;
arg_2_2 : in gmp_c.mp_size_t) return gmp_c.mp_bitcnt_t;
function a_a_gmpn_pow_1
(arg_5_1 : in gmp_c.mp_ptr.Item;
arg_5_2 : in gmp_c.mp_srcptr.Item;
arg_5_3 : in gmp_c.mp_size_t;
arg_5_4 : in gmp_c.mp_limb_t;
arg_5_5 : in gmp_c.mp_ptr.Item) return gmp_c.mp_size_t;
function a_a_gmpn_preinv_mod_1
(arg_4_1 : in gmp_c.mp_srcptr.Item;
arg_4_2 : in gmp_c.mp_size_t;
arg_4_3 : in gmp_c.mp_limb_t;
arg_4_4 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
procedure a_a_gmpn_random
(arg_2_1 : in gmp_c.mp_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t);
procedure a_a_gmpn_random2
(arg_2_1 : in gmp_c.mp_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t);
function a_a_gmpn_rshift
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_size_t;
arg_4_4 : in Interfaces.C.unsigned) return gmp_c.mp_limb_t;
function a_a_gmpn_scan0
(arg_2_1 : in gmp_c.mp_srcptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) return gmp_c.mp_bitcnt_t;
function a_a_gmpn_scan1
(arg_2_1 : in gmp_c.mp_srcptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) return gmp_c.mp_bitcnt_t;
function a_a_gmpn_set_str
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in Swig.Pointers.unsigned_char_Pointer;
arg_4_3 : in Interfaces.C.size_t;
arg_4_4 : in Interfaces.C.int) return gmp_c.mp_size_t;
function a_a_gmpn_sqrtrem
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_ptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t) return gmp_c.mp_size_t;
function a_a_gmpn_sub_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
function a_a_gmpn_submul_1
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_size_t;
arg_4_4 : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
procedure a_a_gmpn_tdiv_qr
(arg_7_1 : in gmp_c.mp_ptr.Item;
arg_7_2 : in gmp_c.mp_ptr.Item;
arg_7_3 : in gmp_c.mp_size_t;
arg_7_4 : in gmp_c.mp_srcptr.Item;
arg_7_5 : in gmp_c.mp_size_t;
arg_7_6 : in gmp_c.mp_srcptr.Item;
arg_7_7 : in gmp_c.mp_size_t);
procedure a_a_gmpn_and_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_andn_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_nand_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_ior_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_iorn_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_nior_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_xor_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_xnor_n
(arg_4_1 : in gmp_c.mp_ptr.Item;
arg_4_2 : in gmp_c.mp_srcptr.Item;
arg_4_3 : in gmp_c.mp_srcptr.Item;
arg_4_4 : in gmp_c.mp_size_t);
procedure a_a_gmpn_copyi
(arg_3_1 : in gmp_c.mp_ptr.Item;
arg_3_2 : in gmp_c.mp_srcptr.Item;
arg_3_3 : in gmp_c.mp_size_t);
procedure a_a_gmpn_copyd
(arg_3_1 : in gmp_c.mp_ptr.Item;
arg_3_2 : in gmp_c.mp_srcptr.Item;
arg_3_3 : in gmp_c.mp_size_t);
procedure a_a_gmpn_zero
(arg_2_1 : in gmp_c.mp_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t);
procedure a_a_gmpn_cnd_swap
(arg_4_1 : in gmp_c.mp_limb_t;
arg_4_2 : in gmp_c.Pointers.mp_limb_t_Pointer;
arg_4_3 : in gmp_c.Pointers.mp_limb_t_Pointer;
arg_4_4 : in gmp_c.mp_size_t);
procedure the_abs
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpz_srcptr.Item);
function fits_uint_p
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_ulong_p
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_ushort_p
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function get_ui
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.unsigned_long;
function getlimbn
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item;
a_a_gmp_n : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
procedure neg
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpz_srcptr.Item);
function perfect_square_p
(a_a_gmp_a : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function popcount
(a_a_gmp_u : in gmp_c.mpz_srcptr.Item) return gmp_c.mp_bitcnt_t;
procedure set_q
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item);
function size
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.size_t;
procedure the_abs
(a_a_gmp_w : in gmp_c.mpq_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item);
procedure neg
(a_a_gmp_w : in gmp_c.mpq_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item);
function a_a_gmpn_add
(a_a_gmp_wp : in gmp_c.mp_ptr.Item;
a_a_gmp_xp : in gmp_c.mp_srcptr.Item;
a_a_gmp_xsize : in gmp_c.mp_size_t;
a_a_gmp_yp : in gmp_c.mp_srcptr.Item;
a_a_gmp_ysize : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
function a_a_gmpn_add_1
(a_a_gmp_dst : in gmp_c.mp_ptr.Item;
a_a_gmp_src : in gmp_c.mp_srcptr.Item;
a_a_gmp_size : in gmp_c.mp_size_t;
a_a_gmp_n : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
function a_a_gmpn_cmp
(a_a_gmp_xp : in gmp_c.mp_srcptr.Item;
a_a_gmp_yp : in gmp_c.mp_srcptr.Item;
a_a_gmp_size : in gmp_c.mp_size_t) return Interfaces.C.int;
function a_a_gmpn_zero_p
(a_a_gmp_p : in gmp_c.mp_srcptr.Item;
a_a_gmp_n : in gmp_c.mp_size_t) return Interfaces.C.int;
function a_a_gmpn_sub
(a_a_gmp_wp : in gmp_c.mp_ptr.Item;
a_a_gmp_xp : in gmp_c.mp_srcptr.Item;
a_a_gmp_xsize : in gmp_c.mp_size_t;
a_a_gmp_yp : in gmp_c.mp_srcptr.Item;
a_a_gmp_ysize : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
function a_a_gmpn_sub_1
(a_a_gmp_dst : in gmp_c.mp_ptr.Item;
a_a_gmp_src : in gmp_c.mp_srcptr.Item;
a_a_gmp_size : in gmp_c.mp_size_t;
a_a_gmp_n : in gmp_c.mp_limb_t) return gmp_c.mp_limb_t;
function a_a_gmpn_neg
(a_a_gmp_rp : in gmp_c.mp_ptr.Item;
a_a_gmp_up : in gmp_c.mp_srcptr.Item;
a_a_gmp_n : in gmp_c.mp_size_t) return gmp_c.mp_limb_t;
private
pragma Import (C, randinit, "Ada_randinit");
pragma Import (C, randinit_default, "Ada_randinit_default");
pragma Import (C, randinit_lc_2exp, "Ada_randinit_lc_2exp");
pragma Import (C, randinit_lc_2exp_size, "Ada_randinit_lc_2exp_size");
pragma Import (C, randinit_mt, "Ada_randinit_mt");
pragma Import (C, randinit_set, "Ada_randinit_set");
pragma Import (C, randseed, "Ada_randseed");
pragma Import (C, randseed_ui, "Ada_randseed_ui");
pragma Import (C, randclear, "Ada_randclear");
pragma Import (C, urandomb_ui, "Ada_urandomb_ui");
pragma Import (C, urandomm_ui, "Ada_urandomm_ui");
pragma Import (C, asprintf, "Ada_asprintf");
pragma Import (C, printf, "Ada_printf");
pragma Import (C, snprintf, "Ada_snprintf");
pragma Import (C, sprintf, "Ada_sprintf");
pragma Import (C, scanf, "Ada_scanf");
pragma Import (C, sscanf, "Ada_sscanf");
pragma Import (C, realloc, "Ada_realloc");
procedure add_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure add
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item) renames
add_v1;
pragma Import (C, add_v1, "Ada_add__SWIG_0");
procedure add_ui_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure add_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
add_ui_v1;
pragma Import (C, add_ui_v1, "Ada_add_ui__SWIG_0");
pragma Import (C, addmul, "Ada_addmul");
pragma Import (C, addmul_ui, "Ada_addmul_ui");
pragma Import (C, z_and, "Ada_z_and");
pragma Import (C, array_init, "Ada_array_init");
pragma Import (C, bin_ui, "Ada_bin_ui");
pragma Import (C, bin_uiui, "Ada_bin_uiui");
pragma Import (C, cdiv_q, "Ada_cdiv_q");
pragma Import (C, cdiv_q_2exp, "Ada_cdiv_q_2exp");
pragma Import (C, cdiv_q_ui, "Ada_cdiv_q_ui");
pragma Import (C, cdiv_qr, "Ada_cdiv_qr");
pragma Import (C, cdiv_qr_ui, "Ada_cdiv_qr_ui");
pragma Import (C, cdiv_r, "Ada_cdiv_r");
pragma Import (C, cdiv_r_2exp, "Ada_cdiv_r_2exp");
pragma Import (C, cdiv_r_ui, "Ada_cdiv_r_ui");
pragma Import (C, cdiv_ui, "Ada_cdiv_ui");
procedure clear_v1 (arg_1 : in gmp_c.mpz_ptr.Item);
procedure clear (arg_1 : in gmp_c.mpz_ptr.Item) renames clear_v1;
pragma Import (C, clear_v1, "Ada_clear__SWIG_0");
pragma Import (C, a_a_gmpz_clears, "Ada___gmpz_clears");
pragma Import (C, clrbit, "Ada_clrbit");
function cmp_v1
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function cmp
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int renames
cmp_v1;
pragma Import (C, cmp_v1, "Ada_cmp__SWIG_0");
function cmp_d_v1
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.double) return Interfaces.C.int;
function cmp_d
(arg_2_1 : in gmp_c.mpz_srcptr.Item;
arg_2_2 : in Interfaces.C.double) return Interfaces.C.int renames
cmp_d_v1;
pragma Import (C, cmp_d_v1, "Ada_cmp_d__SWIG_0");
pragma Import (C, a_a_gmpz_cmp_si, "Ada___gmpz_cmp_si");
pragma Import (C, a_a_gmpz_cmp_ui, "Ada___gmpz_cmp_ui");
pragma Import (C, cmpabs, "Ada_cmpabs");
pragma Import (C, cmpabs_d, "Ada_cmpabs_d");
pragma Import (C, cmpabs_ui, "Ada_cmpabs_ui");
pragma Import (C, com, "Ada_com");
pragma Import (C, combit, "Ada_combit");
pragma Import (C, congruent_p, "Ada_congruent_p");
pragma Import (C, congruent_2exp_p, "Ada_congruent_2exp_p");
pragma Import (C, congruent_ui_p, "Ada_congruent_ui_p");
pragma Import (C, divexact, "Ada_divexact");
pragma Import (C, divexact_ui, "Ada_divexact_ui");
pragma Import (C, divisible_p, "Ada_divisible_p");
pragma Import (C, divisible_ui_p, "Ada_divisible_ui_p");
pragma Import (C, divisible_2exp_p, "Ada_divisible_2exp_p");
procedure dump_v1 (arg_1 : in gmp_c.mpz_srcptr.Item);
procedure dump (arg_1 : in gmp_c.mpz_srcptr.Item) renames dump_v1;
pragma Import (C, dump_v1, "Ada_dump__SWIG_0");
pragma Import (C, z_export, "Ada_z_export");
pragma Import (C, fac_ui, "Ada_fac_ui");
pragma Import (C, a_a_gmpz_2fac_ui, "Ada___gmpz_2fac_ui");
pragma Import (C, a_a_gmpz_mfac_uiui, "Ada___gmpz_mfac_uiui");
pragma Import (C, a_a_gmpz_primorial_ui, "Ada___gmpz_primorial_ui");
pragma Import (C, fdiv_q, "Ada_fdiv_q");
pragma Import (C, fdiv_q_2exp, "Ada_fdiv_q_2exp");
pragma Import (C, fdiv_q_ui, "Ada_fdiv_q_ui");
pragma Import (C, fdiv_qr, "Ada_fdiv_qr");
pragma Import (C, fdiv_qr_ui, "Ada_fdiv_qr_ui");
pragma Import (C, fdiv_r, "Ada_fdiv_r");
pragma Import (C, fdiv_r_2exp, "Ada_fdiv_r_2exp");
pragma Import (C, fdiv_r_ui, "Ada_fdiv_r_ui");
pragma Import (C, fdiv_ui, "Ada_fdiv_ui");
pragma Import (C, fib_ui, "Ada_fib_ui");
pragma Import (C, fib2_ui, "Ada_fib2_ui");
function fits_sint_p_v1
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_sint_p
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int renames
fits_sint_p_v1;
pragma Import (C, fits_sint_p_v1, "Ada_fits_sint_p__SWIG_0");
function fits_slong_p_v1
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_slong_p
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int renames
fits_slong_p_v1;
pragma Import (C, fits_slong_p_v1, "Ada_fits_slong_p__SWIG_0");
function fits_sshort_p_v1
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_sshort_p
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int renames
fits_sshort_p_v1;
pragma Import (C, fits_sshort_p_v1, "Ada_fits_sshort_p__SWIG_0");
pragma Import (C, gcd, "Ada_gcd");
pragma Import (C, gcd_ui, "Ada_gcd_ui");
pragma Import (C, gcdext, "Ada_gcdext");
function get_d_v1
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.double;
function get_d
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.double renames
get_d_v1;
pragma Import (C, get_d_v1, "Ada_get_d__SWIG_0");
function get_d_2exp_v1
(arg_2_1 : in Swig.Pointers.long_Pointer;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.double;
function get_d_2exp
(arg_2_1 : in Swig.Pointers.long_Pointer;
arg_2_2 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.double renames
get_d_2exp_v1;
pragma Import (C, get_d_2exp_v1, "Ada_get_d_2exp__SWIG_0");
function get_si_v1
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.long;
function get_si
(arg_1 : in gmp_c.mpz_srcptr.Item) return Interfaces.C.long renames
get_si_v1;
pragma Import (C, get_si_v1, "Ada_get_si__SWIG_0");
function get_str_v1
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.int;
arg_3_3 : in gmp_c.mpz_srcptr.Item)
return Interfaces.C.Strings.chars_ptr;
function get_str
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.int;
arg_3_3 : in gmp_c.mpz_srcptr.Item)
return Interfaces.C.Strings.chars_ptr renames
get_str_v1;
pragma Import (C, get_str_v1, "Ada_get_str__SWIG_0");
pragma Import (C, hamdist, "Ada_hamdist");
pragma Import (C, import, "Ada_import");
procedure init_v1 (arg_1 : in gmp_c.mpz_ptr.Item);
procedure init (arg_1 : in gmp_c.mpz_ptr.Item) renames init_v1;
pragma Import (C, init_v1, "Ada_init__SWIG_0");
procedure init2_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
procedure init2
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) renames
init2_v1;
pragma Import (C, init2_v1, "Ada_init2__SWIG_0");
pragma Import (C, a_a_gmpz_inits, "Ada___gmpz_inits");
procedure init_set_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure init_set
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) renames
init_set_v1;
pragma Import (C, init_set_v1, "Ada_init_set__SWIG_0");
procedure init_set_d_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure init_set_d
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.double) renames
init_set_d_v1;
pragma Import (C, init_set_d_v1, "Ada_init_set_d__SWIG_0");
procedure init_set_si_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.long);
procedure init_set_si
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.long) renames
init_set_si_v1;
pragma Import (C, init_set_si_v1, "Ada_init_set_si__SWIG_0");
function init_set_str_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
function init_set_str
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int renames
init_set_str_v1;
pragma Import (C, init_set_str_v1, "Ada_init_set_str__SWIG_0");
procedure init_set_ui_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure init_set_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) renames
init_set_ui_v1;
pragma Import (C, init_set_ui_v1, "Ada_init_set_ui__SWIG_0");
pragma Import (C, invert, "Ada_invert");
pragma Import (C, ior, "Ada_ior");
pragma Import (C, jacobi, "Ada_jacobi");
pragma Import (C, kronecker_si, "Ada_kronecker_si");
pragma Import (C, kronecker_ui, "Ada_kronecker_ui");
pragma Import (C, si_kronecker, "Ada_si_kronecker");
pragma Import (C, ui_kronecker, "Ada_ui_kronecker");
pragma Import (C, lcm, "Ada_lcm");
pragma Import (C, lcm_ui, "Ada_lcm_ui");
pragma Import (C, lucnum_ui, "Ada_lucnum_ui");
pragma Import (C, lucnum2_ui, "Ada_lucnum2_ui");
pragma Import (C, millerrabin, "Ada_millerrabin");
pragma Import (C, the_mod, "Ada_mod");
procedure mul_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure mul
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item) renames
mul_v1;
pragma Import (C, mul_v1, "Ada_mul__SWIG_0");
procedure mul_2exp_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure mul_2exp
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) renames
mul_2exp_v1;
pragma Import (C, mul_2exp_v1, "Ada_mul_2exp__SWIG_0");
pragma Import (C, mul_si, "Ada_mul_si");
procedure mul_ui_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure mul_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
mul_ui_v1;
pragma Import (C, mul_ui_v1, "Ada_mul_ui__SWIG_0");
pragma Import (C, nextprime, "Ada_nextprime");
pragma Import (C, perfect_power_p, "Ada_perfect_power_p");
procedure pow_ui_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure pow_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
pow_ui_v1;
pragma Import (C, pow_ui_v1, "Ada_pow_ui__SWIG_0");
pragma Import (C, powm, "Ada_powm");
pragma Import (C, a_a_gmpz_powm_sec, "Ada___gmpz_powm_sec");
pragma Import (C, powm_ui, "Ada_powm_ui");
pragma Import (C, probab_prime_p, "Ada_probab_prime_p");
pragma Import (C, random, "Ada_random");
procedure random2_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t);
procedure random2
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mp_size_t) renames
random2_v1;
pragma Import (C, random2_v1, "Ada_random2__SWIG_0");
pragma Import (C, realloc2, "Ada_realloc2");
pragma Import (C, remove, "Ada_remove");
pragma Import (C, root, "Ada_root");
pragma Import (C, rootrem, "Ada_rootrem");
pragma Import (C, rrandomb, "Ada_rrandomb");
pragma Import (C, scan0, "Ada_scan0");
pragma Import (C, scan1, "Ada_scan1");
procedure set_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure set
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) renames
set_v1;
pragma Import (C, set_v1, "Ada_set__SWIG_0");
procedure set_d_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure set_d
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.double) renames
set_d_v1;
pragma Import (C, set_d_v1, "Ada_set_d__SWIG_0");
procedure set_f_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure set_f
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) renames
set_f_v1;
pragma Import (C, set_f_v1, "Ada_set_f__SWIG_0");
procedure set_si_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.long);
procedure set_si
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.long) renames
set_si_v1;
pragma Import (C, set_si_v1, "Ada_set_si__SWIG_0");
function set_str_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
function set_str
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int renames
set_str_v1;
pragma Import (C, set_str_v1, "Ada_set_str__SWIG_0");
procedure set_ui_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure set_ui
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) renames
set_ui_v1;
pragma Import (C, set_ui_v1, "Ada_set_ui__SWIG_0");
pragma Import (C, setbit, "Ada_setbit");
pragma Import (C, sizeinbase, "Ada_sizeinbase");
procedure sqrt_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure sqrt
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) renames
sqrt_v1;
pragma Import (C, sqrt_v1, "Ada_sqrt__SWIG_0");
pragma Import (C, sqrtrem, "Ada_sqrtrem");
procedure sub_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure sub
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in gmp_c.mpz_srcptr.Item) renames
sub_v1;
pragma Import (C, sub_v1, "Ada_sub__SWIG_0");
procedure sub_ui_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure sub_ui
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.mpz_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
sub_ui_v1;
pragma Import (C, sub_ui_v1, "Ada_sub_ui__SWIG_0");
procedure ui_sub_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in gmp_c.mpz_srcptr.Item);
procedure ui_sub
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in gmp_c.mpz_srcptr.Item) renames
ui_sub_v1;
pragma Import (C, ui_sub_v1, "Ada_ui_sub__SWIG_0");
pragma Import (C, submul, "Ada_submul");
pragma Import (C, submul_ui, "Ada_submul_ui");
procedure swap_v1
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_ptr.Item);
procedure swap
(arg_2_1 : in gmp_c.mpz_ptr.Item;
arg_2_2 : in gmp_c.mpz_ptr.Item) renames
swap_v1;
pragma Import (C, swap_v1, "Ada_swap__SWIG_0");
pragma Import (C, tdiv_ui, "Ada_tdiv_ui");
pragma Import (C, tdiv_q, "Ada_tdiv_q");
pragma Import (C, tdiv_q_2exp, "Ada_tdiv_q_2exp");
pragma Import (C, tdiv_q_ui, "Ada_tdiv_q_ui");
pragma Import (C, tdiv_qr, "Ada_tdiv_qr");
pragma Import (C, tdiv_qr_ui, "Ada_tdiv_qr_ui");
pragma Import (C, tdiv_r, "Ada_tdiv_r");
pragma Import (C, tdiv_r_2exp, "Ada_tdiv_r_2exp");
pragma Import (C, tdiv_r_ui, "Ada_tdiv_r_ui");
pragma Import (C, tstbit, "Ada_tstbit");
pragma Import (C, ui_pow_ui, "Ada_ui_pow_ui");
procedure urandomb_v1
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure urandomb
(arg_3_1 : in gmp_c.mpz_ptr.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) renames
urandomb_v1;
pragma Import (C, urandomb_v1, "Ada_urandomb__SWIG_0");
pragma Import (C, urandomm, "Ada_urandomm");
pragma Import (C, z_xor, "Ada_z_xor");
procedure add_v2
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure add
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item) renames
add_v2;
pragma Import (C, add_v2, "Ada_add__SWIG_1");
pragma Import (C, canonicalize, "Ada_canonicalize");
procedure clear_v2 (arg_1 : in gmp_c.mpq_ptr.Item);
procedure clear (arg_1 : in gmp_c.mpq_ptr.Item) renames clear_v2;
pragma Import (C, clear_v2, "Ada_clear__SWIG_1");
pragma Import (C, a_a_gmpq_clears, "Ada___gmpq_clears");
function cmp_v2
(arg_2_1 : in gmp_c.mpq_srcptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item) return Interfaces.C.int;
function cmp
(arg_2_1 : in gmp_c.mpq_srcptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item) return Interfaces.C.int renames
cmp_v2;
pragma Import (C, cmp_v2, "Ada_cmp__SWIG_1");
pragma Import (C, a_a_gmpq_cmp_si, "Ada___gmpq_cmp_si");
pragma Import (C, a_a_gmpq_cmp_ui, "Ada___gmpq_cmp_ui");
pragma Import (C, a_a_gmpq_cmp_z, "Ada___gmpq_cmp_z");
procedure div_v1
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure div
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item) renames
div_v1;
pragma Import (C, div_v1, "Ada_div__SWIG_0");
procedure div_2exp_v1
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure div_2exp
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) renames
div_2exp_v1;
pragma Import (C, div_2exp_v1, "Ada_div_2exp__SWIG_0");
pragma Import (C, equal, "Ada_equal");
pragma Import (C, get_num, "Ada_get_num");
pragma Import (C, get_den, "Ada_get_den");
function get_d_v2
(arg_1 : in gmp_c.mpq_srcptr.Item) return Interfaces.C.double;
function get_d
(arg_1 : in gmp_c.mpq_srcptr.Item) return Interfaces.C.double renames
get_d_v2;
pragma Import (C, get_d_v2, "Ada_get_d__SWIG_1");
function get_str_v2
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.int;
arg_3_3 : in gmp_c.mpq_srcptr.Item)
return Interfaces.C.Strings.chars_ptr;
function get_str
(arg_3_1 : in Interfaces.C.Strings.chars_ptr;
arg_3_2 : in Interfaces.C.int;
arg_3_3 : in gmp_c.mpq_srcptr.Item)
return Interfaces.C.Strings.chars_ptr renames
get_str_v2;
pragma Import (C, get_str_v2, "Ada_get_str__SWIG_1");
procedure init_v2 (arg_1 : in gmp_c.mpq_ptr.Item);
procedure init (arg_1 : in gmp_c.mpq_ptr.Item) renames init_v2;
pragma Import (C, init_v2, "Ada_init__SWIG_1");
pragma Import (C, a_a_gmpq_inits, "Ada___gmpq_inits");
pragma Import (C, inv, "Ada_inv");
procedure mul_v2
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure mul
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item) renames
mul_v2;
pragma Import (C, mul_v2, "Ada_mul__SWIG_1");
procedure mul_2exp_v2
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure mul_2exp
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) renames
mul_2exp_v2;
pragma Import (C, mul_2exp_v2, "Ada_mul_2exp__SWIG_1");
procedure set_v2
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item);
procedure set
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item) renames
set_v2;
pragma Import (C, set_v2, "Ada_set__SWIG_1");
procedure set_d_v2
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure set_d
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in Interfaces.C.double) renames
set_d_v2;
pragma Import (C, set_d_v2, "Ada_set_d__SWIG_1");
pragma Import (C, set_den, "Ada_set_den");
procedure set_f_v2
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure set_f
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) renames
set_f_v2;
pragma Import (C, set_f_v2, "Ada_set_f__SWIG_1");
pragma Import (C, set_num, "Ada_set_num");
procedure set_si_v2
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.long;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure set_si
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.long;
arg_3_3 : in Interfaces.C.unsigned_long) renames
set_si_v2;
pragma Import (C, set_si_v2, "Ada_set_si__SWIG_1");
function set_str_v2
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
function set_str
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int renames
set_str_v2;
pragma Import (C, set_str_v2, "Ada_set_str__SWIG_1");
procedure set_ui_v2
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure set_ui
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in Interfaces.C.unsigned_long) renames
set_ui_v2;
pragma Import (C, set_ui_v2, "Ada_set_ui__SWIG_1");
procedure set_z_v1
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure set_z
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) renames
set_z_v1;
pragma Import (C, set_z_v1, "Ada_set_z__SWIG_0");
procedure sub_v2
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item);
procedure sub
(arg_3_1 : in gmp_c.mpq_ptr.Item;
arg_3_2 : in gmp_c.mpq_srcptr.Item;
arg_3_3 : in gmp_c.mpq_srcptr.Item) renames
sub_v2;
pragma Import (C, sub_v2, "Ada_sub__SWIG_1");
procedure swap_v2
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpq_ptr.Item);
procedure swap
(arg_2_1 : in gmp_c.mpq_ptr.Item;
arg_2_2 : in gmp_c.mpq_ptr.Item) renames
swap_v2;
pragma Import (C, swap_v2, "Ada_swap__SWIG_1");
procedure the_abs_v1
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure the_abs
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) renames
the_abs_v1;
pragma Import (C, the_abs_v1, "Ada_abs__SWIG_0");
procedure add_v3
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure add
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item) renames
add_v3;
pragma Import (C, add_v3, "Ada_add__SWIG_2");
procedure add_ui_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure add_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
add_ui_v2;
pragma Import (C, add_ui_v2, "Ada_add_ui__SWIG_1");
pragma Import (C, ceil, "Ada_ceil");
procedure clear_v3 (arg_1 : in gmp_c.mpf_ptr.Item);
procedure clear (arg_1 : in gmp_c.mpf_ptr.Item) renames clear_v3;
pragma Import (C, clear_v3, "Ada_clear__SWIG_2");
pragma Import (C, a_a_gmpf_clears, "Ada___gmpf_clears");
function cmp_v3
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function cmp
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int renames
cmp_v3;
pragma Import (C, cmp_v3, "Ada_cmp__SWIG_2");
pragma Import (C, a_a_gmpf_cmp_z, "Ada___gmpf_cmp_z");
function cmp_d_v2
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in Interfaces.C.double) return Interfaces.C.int;
function cmp_d
(arg_2_1 : in gmp_c.mpf_srcptr.Item;
arg_2_2 : in Interfaces.C.double) return Interfaces.C.int renames
cmp_d_v2;
pragma Import (C, cmp_d_v2, "Ada_cmp_d__SWIG_1");
pragma Import (C, cmp_si, "Ada_cmp_si");
pragma Import (C, cmp_ui, "Ada_cmp_ui");
procedure div_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure div
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item) renames
div_v2;
pragma Import (C, div_v2, "Ada_div__SWIG_1");
procedure div_2exp_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure div_2exp
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) renames
div_2exp_v2;
pragma Import (C, div_2exp_v2, "Ada_div_2exp__SWIG_1");
pragma Import (C, div_ui, "Ada_div_ui");
procedure dump_v2 (arg_1 : in gmp_c.mpf_srcptr.Item);
procedure dump (arg_1 : in gmp_c.mpf_srcptr.Item) renames dump_v2;
pragma Import (C, dump_v2, "Ada_dump__SWIG_1");
pragma Import (C, eq, "Ada_eq");
function fits_sint_p_v2
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_sint_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int renames
fits_sint_p_v2;
pragma Import (C, fits_sint_p_v2, "Ada_fits_sint_p__SWIG_1");
function fits_slong_p_v2
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_slong_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int renames
fits_slong_p_v2;
pragma Import (C, fits_slong_p_v2, "Ada_fits_slong_p__SWIG_1");
function fits_sshort_p_v2
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_sshort_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int renames
fits_sshort_p_v2;
pragma Import (C, fits_sshort_p_v2, "Ada_fits_sshort_p__SWIG_1");
function fits_uint_p_v1
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_uint_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int renames
fits_uint_p_v1;
pragma Import (C, fits_uint_p_v1, "Ada_fits_uint_p__SWIG_0");
function fits_ulong_p_v1
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_ulong_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int renames
fits_ulong_p_v1;
pragma Import (C, fits_ulong_p_v1, "Ada_fits_ulong_p__SWIG_0");
function fits_ushort_p_v1
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int;
function fits_ushort_p
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.int renames
fits_ushort_p_v1;
pragma Import (C, fits_ushort_p_v1, "Ada_fits_ushort_p__SWIG_0");
pragma Import (C, floor, "Ada_floor");
function get_d_v3
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.double;
function get_d
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.double renames
get_d_v3;
pragma Import (C, get_d_v3, "Ada_get_d__SWIG_2");
function get_d_2exp_v2
(arg_2_1 : in Swig.Pointers.long_Pointer;
arg_2_2 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.double;
function get_d_2exp
(arg_2_1 : in Swig.Pointers.long_Pointer;
arg_2_2 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.double renames
get_d_2exp_v2;
pragma Import (C, get_d_2exp_v2, "Ada_get_d_2exp__SWIG_1");
pragma Import (C, get_default_prec, "Ada_get_default_prec");
pragma Import (C, get_prec, "Ada_get_prec");
function get_si_v2
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.long;
function get_si
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.long renames
get_si_v2;
pragma Import (C, get_si_v2, "Ada_get_si__SWIG_1");
function get_str_v3
(arg_5_1 : in Interfaces.C.Strings.chars_ptr;
arg_5_2 : in gmp_c.Pointers.mp_exp_t_Pointer;
arg_5_3 : in Interfaces.C.int;
arg_5_4 : in Interfaces.C.size_t;
arg_5_5 : in gmp_c.mpf_srcptr.Item)
return Interfaces.C.Strings.chars_ptr;
function get_str
(arg_5_1 : in Interfaces.C.Strings.chars_ptr;
arg_5_2 : in gmp_c.Pointers.mp_exp_t_Pointer;
arg_5_3 : in Interfaces.C.int;
arg_5_4 : in Interfaces.C.size_t;
arg_5_5 : in gmp_c.mpf_srcptr.Item)
return Interfaces.C.Strings.chars_ptr renames
get_str_v3;
pragma Import (C, get_str_v3, "Ada_get_str__SWIG_2");
function get_ui_v1
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.unsigned_long;
function get_ui
(arg_1 : in gmp_c.mpf_srcptr.Item)
return Interfaces.C.unsigned_long renames
get_ui_v1;
pragma Import (C, get_ui_v1, "Ada_get_ui__SWIG_0");
procedure init_v3 (arg_1 : in gmp_c.mpf_ptr.Item);
procedure init (arg_1 : in gmp_c.mpf_ptr.Item) renames init_v3;
pragma Import (C, init_v3, "Ada_init__SWIG_2");
procedure init2_v2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t);
procedure init2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mp_bitcnt_t) renames
init2_v2;
pragma Import (C, init2_v2, "Ada_init2__SWIG_1");
pragma Import (C, a_a_gmpf_inits, "Ada___gmpf_inits");
procedure init_set_v2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure init_set
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) renames
init_set_v2;
pragma Import (C, init_set_v2, "Ada_init_set__SWIG_1");
procedure init_set_d_v2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure init_set_d
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.double) renames
init_set_d_v2;
pragma Import (C, init_set_d_v2, "Ada_init_set_d__SWIG_1");
procedure init_set_si_v2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.long);
procedure init_set_si
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.long) renames
init_set_si_v2;
pragma Import (C, init_set_si_v2, "Ada_init_set_si__SWIG_1");
function init_set_str_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
function init_set_str
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int renames
init_set_str_v2;
pragma Import (C, init_set_str_v2, "Ada_init_set_str__SWIG_1");
procedure init_set_ui_v2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure init_set_ui
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) renames
init_set_ui_v2;
pragma Import (C, init_set_ui_v2, "Ada_init_set_ui__SWIG_1");
pragma Import (C, integer_p, "Ada_integer_p");
procedure mul_v3
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure mul
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item) renames
mul_v3;
pragma Import (C, mul_v3, "Ada_mul__SWIG_2");
procedure mul_2exp_v3
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure mul_2exp
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) renames
mul_2exp_v3;
pragma Import (C, mul_2exp_v3, "Ada_mul_2exp__SWIG_2");
procedure mul_ui_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure mul_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
mul_ui_v2;
pragma Import (C, mul_ui_v2, "Ada_mul_ui__SWIG_1");
procedure neg_v1
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure neg
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) renames
neg_v1;
pragma Import (C, neg_v1, "Ada_neg__SWIG_0");
procedure pow_ui_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure pow_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
pow_ui_v2;
pragma Import (C, pow_ui_v2, "Ada_pow_ui__SWIG_1");
procedure random2_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mp_size_t;
arg_3_3 : in gmp_c.mp_exp_t);
procedure random2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mp_size_t;
arg_3_3 : in gmp_c.mp_exp_t) renames
random2_v2;
pragma Import (C, random2_v2, "Ada_random2__SWIG_1");
pragma Import (C, reldiff, "Ada_reldiff");
procedure set_v3
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure set
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) renames
set_v3;
pragma Import (C, set_v3, "Ada_set__SWIG_2");
procedure set_d_v3
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.double);
procedure set_d
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.double) renames
set_d_v3;
pragma Import (C, set_d_v3, "Ada_set_d__SWIG_2");
pragma Import (C, set_default_prec, "Ada_set_default_prec");
pragma Import (C, set_prec, "Ada_set_prec");
pragma Import (C, set_prec_raw, "Ada_set_prec_raw");
procedure set_q_v1
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item);
procedure set_q
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpq_srcptr.Item) renames
set_q_v1;
pragma Import (C, set_q_v1, "Ada_set_q__SWIG_0");
procedure set_si_v3
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.long);
procedure set_si
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.long) renames
set_si_v3;
pragma Import (C, set_si_v3, "Ada_set_si__SWIG_2");
function set_str_v3
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int;
function set_str
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.Strings.chars_ptr;
arg_3_3 : in Interfaces.C.int) return Interfaces.C.int renames
set_str_v3;
pragma Import (C, set_str_v3, "Ada_set_str__SWIG_2");
procedure set_ui_v3
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long);
procedure set_ui
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in Interfaces.C.unsigned_long) renames
set_ui_v3;
pragma Import (C, set_ui_v3, "Ada_set_ui__SWIG_2");
procedure set_z_v2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item);
procedure set_z
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpz_srcptr.Item) renames
set_z_v2;
pragma Import (C, set_z_v2, "Ada_set_z__SWIG_1");
function size_v1
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.size_t;
function size
(arg_1 : in gmp_c.mpf_srcptr.Item) return Interfaces.C.size_t renames
size_v1;
pragma Import (C, size_v1, "Ada_size__SWIG_0");
procedure sqrt_v2
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item);
procedure sqrt
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_srcptr.Item) renames
sqrt_v2;
pragma Import (C, sqrt_v2, "Ada_sqrt__SWIG_1");
pragma Import (C, sqrt_ui, "Ada_sqrt_ui");
procedure sub_v3
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure sub
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in gmp_c.mpf_srcptr.Item) renames
sub_v3;
pragma Import (C, sub_v3, "Ada_sub__SWIG_2");
procedure sub_ui_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long);
procedure sub_ui
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in gmp_c.mpf_srcptr.Item;
arg_3_3 : in Interfaces.C.unsigned_long) renames
sub_ui_v2;
pragma Import (C, sub_ui_v2, "Ada_sub_ui__SWIG_1");
procedure swap_v3
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_ptr.Item);
procedure swap
(arg_2_1 : in gmp_c.mpf_ptr.Item;
arg_2_2 : in gmp_c.mpf_ptr.Item) renames
swap_v3;
pragma Import (C, swap_v3, "Ada_swap__SWIG_2");
pragma Import (C, trunc, "Ada_trunc");
pragma Import (C, ui_div, "Ada_ui_div");
procedure ui_sub_v2
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in gmp_c.mpf_srcptr.Item);
procedure ui_sub
(arg_3_1 : in gmp_c.mpf_ptr.Item;
arg_3_2 : in Interfaces.C.unsigned_long;
arg_3_3 : in gmp_c.mpf_srcptr.Item) renames
ui_sub_v2;
pragma Import (C, ui_sub_v2, "Ada_ui_sub__SWIG_1");
procedure urandomb_v2
(arg_3_1 : in gmp_c.mpf_t.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t);
procedure urandomb
(arg_3_1 : in gmp_c.mpf_t.Item;
arg_3_2 : in gmp_c.gmp_randstate_t.Item;
arg_3_3 : in gmp_c.mp_bitcnt_t) renames
urandomb_v2;
pragma Import (C, urandomb_v2, "Ada_urandomb__SWIG_1");
pragma Import (C, a_a_gmpn_add_n, "Ada___gmpn_add_n");
pragma Import (C, a_a_gmpn_addmul_1, "Ada___gmpn_addmul_1");
pragma Import (C, a_a_gmpn_divexact_1, "Ada___gmpn_divexact_1");
pragma Import (C, a_a_gmpn_divexact_by3c, "Ada___gmpn_divexact_by3c");
pragma Import (C, a_a_gmpn_divrem, "Ada___gmpn_divrem");
pragma Import (C, a_a_gmpn_divrem_1, "Ada___gmpn_divrem_1");
pragma Import (C, a_a_gmpn_divrem_2, "Ada___gmpn_divrem_2");
pragma Import (C, a_a_gmpn_div_qr_2, "Ada___gmpn_div_qr_2");
pragma Import (C, a_a_gmpn_gcd, "Ada___gmpn_gcd");
pragma Import (C, a_a_gmpn_gcd_1, "Ada___gmpn_gcd_1");
pragma Import (C, a_a_gmpn_gcdext_1, "Ada___gmpn_gcdext_1");
pragma Import (C, a_a_gmpn_gcdext, "Ada___gmpn_gcdext");
pragma Import (C, a_a_gmpn_get_str, "Ada___gmpn_get_str");
pragma Import (C, a_a_gmpn_hamdist, "Ada___gmpn_hamdist");
pragma Import (C, a_a_gmpn_lshift, "Ada___gmpn_lshift");
pragma Import (C, a_a_gmpn_mod_1, "Ada___gmpn_mod_1");
pragma Import (C, a_a_gmpn_mul, "Ada___gmpn_mul");
pragma Import (C, a_a_gmpn_mul_1, "Ada___gmpn_mul_1");
pragma Import (C, a_a_gmpn_mul_n, "Ada___gmpn_mul_n");
pragma Import (C, a_a_gmpn_sqr, "Ada___gmpn_sqr");
pragma Import (C, a_a_gmpn_com, "Ada___gmpn_com");
pragma Import (C, a_a_gmpn_perfect_square_p, "Ada___gmpn_perfect_square_p");
pragma Import (C, a_a_gmpn_perfect_power_p, "Ada___gmpn_perfect_power_p");
pragma Import (C, a_a_gmpn_popcount, "Ada___gmpn_popcount");
pragma Import (C, a_a_gmpn_pow_1, "Ada___gmpn_pow_1");
pragma Import (C, a_a_gmpn_preinv_mod_1, "Ada___gmpn_preinv_mod_1");
pragma Import (C, a_a_gmpn_random, "Ada___gmpn_random");
pragma Import (C, a_a_gmpn_random2, "Ada___gmpn_random2");
pragma Import (C, a_a_gmpn_rshift, "Ada___gmpn_rshift");
pragma Import (C, a_a_gmpn_scan0, "Ada___gmpn_scan0");
pragma Import (C, a_a_gmpn_scan1, "Ada___gmpn_scan1");
pragma Import (C, a_a_gmpn_set_str, "Ada___gmpn_set_str");
pragma Import (C, a_a_gmpn_sqrtrem, "Ada___gmpn_sqrtrem");
pragma Import (C, a_a_gmpn_sub_n, "Ada___gmpn_sub_n");
pragma Import (C, a_a_gmpn_submul_1, "Ada___gmpn_submul_1");
pragma Import (C, a_a_gmpn_tdiv_qr, "Ada___gmpn_tdiv_qr");
pragma Import (C, a_a_gmpn_and_n, "Ada___gmpn_and_n");
pragma Import (C, a_a_gmpn_andn_n, "Ada___gmpn_andn_n");
pragma Import (C, a_a_gmpn_nand_n, "Ada___gmpn_nand_n");
pragma Import (C, a_a_gmpn_ior_n, "Ada___gmpn_ior_n");
pragma Import (C, a_a_gmpn_iorn_n, "Ada___gmpn_iorn_n");
pragma Import (C, a_a_gmpn_nior_n, "Ada___gmpn_nior_n");
pragma Import (C, a_a_gmpn_xor_n, "Ada___gmpn_xor_n");
pragma Import (C, a_a_gmpn_xnor_n, "Ada___gmpn_xnor_n");
pragma Import (C, a_a_gmpn_copyi, "Ada___gmpn_copyi");
pragma Import (C, a_a_gmpn_copyd, "Ada___gmpn_copyd");
pragma Import (C, a_a_gmpn_zero, "Ada___gmpn_zero");
pragma Import (C, a_a_gmpn_cnd_swap, "Ada___gmpn_cnd_swap");
procedure the_abs_v2
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpz_srcptr.Item);
procedure the_abs
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpz_srcptr.Item) renames
the_abs_v2;
pragma Import (C, the_abs_v2, "Ada_abs__SWIG_1");
function fits_uint_p_v2
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_uint_p
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int renames
fits_uint_p_v2;
pragma Import (C, fits_uint_p_v2, "Ada_fits_uint_p__SWIG_1");
function fits_ulong_p_v2
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_ulong_p
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int renames
fits_ulong_p_v2;
pragma Import (C, fits_ulong_p_v2, "Ada_fits_ulong_p__SWIG_1");
function fits_ushort_p_v2
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int;
function fits_ushort_p
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.int renames
fits_ushort_p_v2;
pragma Import (C, fits_ushort_p_v2, "Ada_fits_ushort_p__SWIG_1");
function get_ui_v2
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.unsigned_long;
function get_ui
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item)
return Interfaces.C.unsigned_long renames
get_ui_v2;
pragma Import (C, get_ui_v2, "Ada_get_ui__SWIG_1");
pragma Import (C, getlimbn, "Ada_getlimbn");
procedure neg_v2
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpz_srcptr.Item);
procedure neg
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpz_srcptr.Item) renames
neg_v2;
pragma Import (C, neg_v2, "Ada_neg__SWIG_1");
pragma Import (C, perfect_square_p, "Ada_perfect_square_p");
pragma Import (C, popcount, "Ada_popcount");
procedure set_q_v2
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item);
procedure set_q
(a_a_gmp_w : in gmp_c.mpz_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item) renames
set_q_v2;
pragma Import (C, set_q_v2, "Ada_set_q__SWIG_1");
function size_v2
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.size_t;
function size
(a_a_gmp_z : in gmp_c.mpz_srcptr.Item) return Interfaces.C.size_t renames
size_v2;
pragma Import (C, size_v2, "Ada_size__SWIG_1");
procedure the_abs_v3
(a_a_gmp_w : in gmp_c.mpq_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item);
procedure the_abs
(a_a_gmp_w : in gmp_c.mpq_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item) renames
the_abs_v3;
pragma Import (C, the_abs_v3, "Ada_abs__SWIG_2");
procedure neg_v3
(a_a_gmp_w : in gmp_c.mpq_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item);
procedure neg
(a_a_gmp_w : in gmp_c.mpq_ptr.Item;
a_a_gmp_u : in gmp_c.mpq_srcptr.Item) renames
neg_v3;
pragma Import (C, neg_v3, "Ada_neg__SWIG_2");
pragma Import (C, a_a_gmpn_add, "Ada___gmpn_add");
pragma Import (C, a_a_gmpn_add_1, "Ada___gmpn_add_1");
pragma Import (C, a_a_gmpn_cmp, "Ada___gmpn_cmp");
pragma Import (C, a_a_gmpn_zero_p, "Ada___gmpn_zero_p");
pragma Import (C, a_a_gmpn_sub, "Ada___gmpn_sub");
pragma Import (C, a_a_gmpn_sub_1, "Ada___gmpn_sub_1");
pragma Import (C, a_a_gmpn_neg, "Ada___gmpn_neg");
end gmp_c.Binding;
|
------------------------------------------------------------------------------
-- --
-- GNAT SYSTEM UTILITIES --
-- --
-- C S I N F O --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Program to check consistency of sinfo.ads and sinfo.adb. Checks that
-- field name usage is consistent and that assertion cross-reference lists
-- are correct, as well as making sure that all the comments on field name
-- usage are consistent.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Spitbol; use GNAT.Spitbol;
with GNAT.Spitbol.Patterns; use GNAT.Spitbol.Patterns;
with GNAT.Spitbol.Table_Boolean;
with GNAT.Spitbol.Table_VString;
procedure CSinfo is
package TB renames GNAT.Spitbol.Table_Boolean;
package TV renames GNAT.Spitbol.Table_VString;
use TB, TV;
Infil : File_Type;
Lineno : Natural := 0;
Err : exception;
-- Raised on fatal error
Done : exception;
-- Raised after error is found to terminate run
WSP : Pattern := Span (' ' & ASCII.HT);
Fields : TV.Table (300);
Fields1 : TV.Table (300);
Refs : TV.Table (300);
Refscopy : TV.Table (300);
Special : TB.Table (50);
Inlines : TV.Table (100);
-- The following define the standard fields used for binary operator,
-- unary operator, and other expression nodes. Numbers in the range 1-5
-- refer to the Fieldn fields. Letters D-R refer to flags:
-- D = Flag4
-- E = Flag5
-- F = Flag6
-- G = Flag7
-- H = Flag8
-- I = Flag9
-- J = Flag10
-- K = Flag11
-- L = Flag12
-- M = Flag13
-- N = Flag14
-- O = Flag15
-- P = Flag16
-- Q = Flag17
-- R = Flag18
Flags : TV.Table (20);
-- Maps flag numbers to letters
N_Fields : Pattern := BreakX ("JL");
E_Fields : Pattern := BreakX ("5EFGHIJLOP");
U_Fields : Pattern := BreakX ("1345EFGHIJKLOPQ");
B_Fields : Pattern := BreakX ("12345EFGHIJKLOPQ");
Line : VString;
Bad : Boolean;
Field : VString := Nul;
Fields_Used : VString := Nul;
Name : VString := Nul;
Next : VString := Nul;
Node : VString := Nul;
Ref : VString := Nul;
Synonym : VString := Nul;
Nxtref : VString := Nul;
Which_Field : aliased VString := Nul;
Node_Search : Pattern := WSP & "-- N_" & Rest * Node;
Break_Punc : Pattern := Break (" .,");
Plus_Binary : Pattern := WSP & "-- plus fields for binary operator";
Plus_Unary : Pattern := WSP & "-- plus fields for unary operator";
Plus_Expr : Pattern := WSP & "-- plus fields for expression";
Break_Syn : Pattern := WSP & "-- " & Break (' ') * Synonym &
" (" & Break (')') * Field;
Break_Field : Pattern := BreakX ('-') * Field;
Get_Field : Pattern := BreakX (Decimal_Digit_Set) &
Span (Decimal_Digit_Set) * Which_Field;
Break_WFld : Pattern := Break (Which_Field'Access);
Get_Funcsyn : Pattern := WSP & "function " & Rest * Synonym;
Extr_Field : Pattern := BreakX ('-') & "-- " & Rest * Field;
Get_Procsyn : Pattern := WSP & "procedure Set_" & Rest * Synonym;
Get_Inline : Pattern := WSP & "pragma Inline (" & Break (')') * Name;
Set_Name : Pattern := "Set_" & Rest * Name;
Func_Rest : Pattern := " function " & Rest * Synonym;
Get_Nxtref : Pattern := Break (',') * Nxtref & ',';
Test_Syn : Pattern := Break ('=') & "= N_" &
(Break (" ,)") or Rest) * Next;
Chop_Comma : Pattern := BreakX (',') * Next;
Return_Fld : Pattern := WSP & "return " & Break (' ') * Field;
Set_Syn : Pattern := " procedure Set_" & Rest * Synonym;
Set_Fld : Pattern := WSP & "Set_" & Break (' ') * Field & " (N, Val)";
Break_With : Pattern := Break ('_') ** Field & "_With_Parent";
type VStringA is array (Natural range <>) of VString;
procedure Next_Line;
-- Read next line trimmed from Infil into Line and bump Lineno
procedure Sort (A : in out VStringA);
-- Sort a (small) array of VString's
procedure Next_Line is
begin
Line := Get_Line (Infil);
Trim (Line);
Lineno := Lineno + 1;
end Next_Line;
procedure Sort (A : in out VStringA) is
Temp : VString;
begin
<<Sort>>
for J in 1 .. A'Length - 1 loop
if A (J) > A (J + 1) then
Temp := A (J);
A (J) := A (J + 1);
A (J + 1) := Temp;
goto Sort;
end if;
end loop;
end Sort;
-- Start of processing for CSinfo
begin
Anchored_Mode := True;
New_Line;
Open (Infil, In_File, "sinfo.ads");
Put_Line ("Check for field name consistency");
-- Setup table for mapping flag numbers to letters
Set (Flags, "4", V ("D"));
Set (Flags, "5", V ("E"));
Set (Flags, "6", V ("F"));
Set (Flags, "7", V ("G"));
Set (Flags, "8", V ("H"));
Set (Flags, "9", V ("I"));
Set (Flags, "10", V ("J"));
Set (Flags, "11", V ("K"));
Set (Flags, "12", V ("L"));
Set (Flags, "13", V ("M"));
Set (Flags, "14", V ("N"));
Set (Flags, "15", V ("O"));
Set (Flags, "16", V ("P"));
Set (Flags, "17", V ("Q"));
Set (Flags, "18", V ("R"));
-- Special fields table. The following fields are not recorded or checked
-- by Csinfo, since they are specially handled. This means that he both
-- the field definitions, and the corresponding subprograms are ignored.
Set (Special, "Analyzed", True);
Set (Special, "Assignment_OK", True);
Set (Special, "Associated_Node", True);
Set (Special, "Cannot_Be_Constant", True);
Set (Special, "Chars", True);
Set (Special, "Comes_From_Source", True);
Set (Special, "Do_Overflow_Check", True);
Set (Special, "Do_Range_Check", True);
Set (Special, "Entity", True);
Set (Special, "Error_Posted", True);
Set (Special, "Etype", True);
Set (Special, "Evaluate_Once", True);
Set (Special, "First_Itype", True);
Set (Special, "Has_Dynamic_Itype", True);
Set (Special, "Has_Dynamic_Range_Check", True);
Set (Special, "Has_Dynamic_Length_Check", True);
Set (Special, "Has_Private_View", True);
Set (Special, "Is_Controlling_Actual", True);
Set (Special, "Is_Overloaded", True);
Set (Special, "Is_Static_Expression", True);
Set (Special, "Left_Opnd", True);
Set (Special, "Must_Not_Freeze", True);
Set (Special, "Parens", True);
Set (Special, "Raises_Constraint_Error", True);
Set (Special, "Right_Opnd", True);
-- Loop to acquire information from node definitions in sinfo.ads,
-- checking for consistency in Op/Flag assignments to each synonym
loop
Bad := False;
Next_Line;
exit when Match (Line, " -- Node Access Functions");
if Match (Line, Node_Search)
and then not Match (Node, Break_Punc)
then
Fields_Used := Nul;
elsif Node = "" then
null;
elsif Line = "" then
Node := Nul;
elsif Match (Line, Plus_Binary) then
Bad := Match (Fields_Used, B_Fields);
elsif Match (Line, Plus_Unary) then
Bad := Match (Fields_Used, U_Fields);
elsif Match (Line, Plus_Expr) then
Bad := Match (Fields_Used, E_Fields);
elsif not Match (Line, Break_Syn) then
null;
elsif Match (Synonym, "plus") then
null;
else
Match (Field, Break_Field);
if not Present (Special, Synonym) then
if Present (Fields, Synonym) then
if Field /= Get (Fields, Synonym) then
Put_Line
("Inconsistent field reference at line" &
Lineno'Img & " for " & Synonym);
raise Done;
end if;
else
Set (Fields, Synonym, Field);
end if;
Set (Refs, Synonym, Node & ',' & Get (Refs, Synonym));
Match (Field, Get_Field);
if Match (Field, "Flag") then
Which_Field := Get (Flags, Which_Field);
end if;
if Match (Fields_Used, Break_WFld) then
Put_Line
("Overlapping field at line " & Lineno'Img &
" for " & Synonym);
raise Done;
end if;
Append (Fields_Used, Which_Field);
Bad := Bad or Match (Fields_Used, N_Fields);
end if;
end if;
if Bad then
Put_Line ("fields conflict with standard fields for node " & Node);
end if;
end loop;
Put_Line (" OK");
New_Line;
Put_Line ("Check for function consistency");
-- Loop through field function definitions to make sure they are OK
Fields1 := Fields;
loop
Next_Line;
exit when Match (Line, " -- Node Update");
if Match (Line, Get_Funcsyn)
and then not Present (Special, Synonym)
then
if not Present (Fields1, Synonym) then
Put_Line
("function on line " & Lineno &
" is for unused synonym");
raise Done;
end if;
Next_Line;
if not Match (Line, Extr_Field) then
raise Err;
end if;
if Field /= Get (Fields1, Synonym) then
Put_Line ("Wrong field in function " & Synonym);
raise Done;
else
Delete (Fields1, Synonym);
end if;
end if;
end loop;
Put_Line (" OK");
New_Line;
Put_Line ("Check for missing functions");
declare
List : TV.Table_Array := Convert_To_Array (Fields1);
begin
if List'Length > 0 then
Put_Line ("No function for field synonym " & List (1).Name);
raise Done;
end if;
end;
-- Check field set procedures
Put_Line (" OK");
New_Line;
Put_Line ("Check for set procedure consistency");
Fields1 := Fields;
loop
Next_Line;
exit when Match (Line, " -- Inline Pragmas");
exit when Match (Line, " -- Iterator Procedures");
if Match (Line, Get_Procsyn)
and then not Present (Special, Synonym)
then
if not Present (Fields1, Synonym) then
Put_Line
("procedure on line " & Lineno & " is for unused synonym");
raise Done;
end if;
Next_Line;
if not Match (Line, Extr_Field) then
raise Err;
end if;
if Field /= Get (Fields1, Synonym) then
Put_Line ("Wrong field in procedure Set_" & Synonym);
raise Done;
else
Delete (Fields1, Synonym);
end if;
end if;
end loop;
Put_Line (" OK");
New_Line;
Put_Line ("Check for missing set procedures");
declare
List : TV.Table_Array := Convert_To_Array (Fields1);
begin
if List'Length > 0 then
Put_Line ("No procedure for field synonym Set_" & List (1).Name);
raise Done;
end if;
end;
Put_Line (" OK");
New_Line;
Put_Line ("Check pragma Inlines are all for existing subprograms");
Clear (Fields1);
while not End_Of_File (Infil) loop
Next_Line;
if Match (Line, Get_Inline)
and then not Present (Special, Name)
then
exit when Match (Name, Set_Name);
if not Present (Fields, Name) then
Put_Line
("Pragma Inline on line " & Lineno &
" does not correspond to synonym");
raise Done;
else
Set (Inlines, Name, Get (Inlines, Name) & 'r');
end if;
end if;
end loop;
Put_Line (" OK");
New_Line;
Put_Line ("Check no pragma Inlines were omitted");
declare
List : TV.Table_Array := Convert_To_Array (Fields);
Nxt : VString := Nul;
begin
for M in List'Range loop
Nxt := List (M).Name;
if Get (Inlines, Nxt) /= "r" then
Put_Line ("Incorrect pragma Inlines for " & Nxt);
raise Done;
end if;
end loop;
end;
Put_Line (" OK");
New_Line;
Clear (Inlines);
Close (Infil);
Open (Infil, In_File, "sinfo.adb");
Lineno := 0;
Put_Line ("Check references in functions in body");
Refscopy := Refs;
loop
Next_Line;
exit when Match (Line, " -- Field Access Functions --");
end loop;
loop
Next_Line;
exit when Match (Line, " -- Field Set Procedures --");
if Match (Line, Func_Rest)
and then not Present (Special, Synonym)
then
Ref := Get (Refs, Synonym);
Delete (Refs, Synonym);
if Ref = "" then
Put_Line
("Function on line " & Lineno & " is for unknown synonym");
raise Err;
end if;
-- Alpha sort of references for this entry
declare
Refa : VStringA (1 .. 100);
N : Natural := 0;
begin
loop
exit when not Match (Ref, Get_Nxtref, Nul);
N := N + 1;
Refa (N) := Nxtref;
end loop;
Sort (Refa (1 .. N));
Next_Line;
Next_Line;
Next_Line;
-- Checking references for one entry
for M in 1 .. N loop
Next_Line;
if not Match (Line, Test_Syn) then
Put_Line ("Expecting N_" & Refa (M) & " at line " & Lineno);
raise Done;
end if;
Match (Next, Chop_Comma);
if Next /= Refa (M) then
Put_Line ("Expecting N_" & Refa (M) & " at line " & Lineno);
raise Done;
end if;
end loop;
Next_Line;
Match (Line, Return_Fld);
if Field /= Get (Fields, Synonym) then
Put_Line
("Wrong field for function " & Synonym & " at line " &
Lineno & " should be " & Get (Fields, Synonym));
raise Done;
end if;
end;
end if;
end loop;
Put_Line (" OK");
New_Line;
Put_Line ("Check for missing functions in body");
declare
List : TV.Table_Array := Convert_To_Array (Refs);
begin
if List'Length /= 0 then
Put_Line ("Missing function " & List (1).Name & " in body");
raise Done;
end if;
end;
Put_Line (" OK");
New_Line;
Put_Line ("Check Set procedures in body");
Refs := Refscopy;
loop
Next_Line;
exit when Match (Line, "end");
exit when Match (Line, " -- Iterator Procedures");
if Match (Line, Set_Syn)
and then not Present (Special, Synonym)
then
Ref := Get (Refs, Synonym);
Delete (Refs, Synonym);
if Ref = "" then
Put_Line
("Function on line " & Lineno & " is for unknown synonym");
raise Err;
end if;
-- Alpha sort of references for this entry
declare
Refa : VStringA (1 .. 100);
N : Natural;
begin
N := 0;
loop
exit when not Match (Ref, Get_Nxtref, Nul);
N := N + 1;
Refa (N) := Nxtref;
end loop;
Sort (Refa (1 .. N));
Next_Line;
Next_Line;
Next_Line;
-- Checking references for one entry
for M in 1 .. N loop
Next_Line;
if not Match (Line, Test_Syn)
or else Next /= Refa (M)
then
Put_Line ("Expecting N_" & Refa (M) & " at line " & Lineno);
raise Err;
end if;
end loop;
loop
Next_Line;
exit when Match (Line, Set_Fld);
end loop;
Match (Field, Break_With);
if Field /= Get (Fields, Synonym) then
Put_Line
("Wrong field for procedure Set_" & Synonym &
" at line " & Lineno & " should be " &
Get (Fields, Synonym));
raise Done;
end if;
Delete (Fields1, Synonym);
end;
end if;
end loop;
Put_Line (" OK");
New_Line;
Put_Line ("Check for missing set procedures in body");
declare
List : TV.Table_Array := Convert_To_Array (Fields1);
begin
if List'Length /= 0 then
Put_Line ("Missing procedure Set_" & List (1).Name & " in body");
raise Done;
end if;
end;
Put_Line (" OK");
New_Line;
Put_Line ("All tests completed successfully, no errors detected");
exception
when Done =>
null;
end CSinfo;
|
-- Taken from #2382 submitted by @JulienPivard
-- @summary
-- Implémentation par une tâche.
-- @description
-- Implémentation par une tache de la classe synchronisé.
-- @group Version tâche
--
-- package Carte_P.Tasche_P
package Input
with
Pure => False,
Preelaborate => False,
Elaborate_Body => True,
Spark_Mode => Off
is
---------------------------------------------------------------------------
task type Tasche_T is new Carte_T with
-- Implémentation par une tâche de l'interface Carte_T.
-----------------------------------
overriding
entry Coucou;
-- Implémentation par un accept.
-----------------------------------
-- overriding
-- entry Inutile;
-- Implémentation par un accept.
-- @param This
-- La carte.
end Tasche_T;
---------------------------------------------------------------------------
overriding
procedure Inutile
(This : in out Tasche_T);
-- Implémentation par une procédure.
-- @param This
-- La carte.
end Carte_P.Tasche_P;
|
with LATIN_FILE_NAMES; use LATIN_FILE_NAMES;
with STRINGS_PACKAGE; use STRINGS_PACKAGE;
with CONFIG;
with PREFACE;
package body WORD_SUPPORT_PACKAGE is
function LEN(S : STRING) return INTEGER is
begin
return TRIM(S)'LENGTH;
end LEN;
function EFF_PART(PART : PART_OF_SPEECH_TYPE) return PART_OF_SPEECH_TYPE is
begin
if PART = VPAR then
return V;
elsif PART = SUPINE then
return V;
else
return PART;
end if;
end EFF_PART;
function ADJ_COMP_FROM_KEY(KEY : STEM_KEY_TYPE) return COMPARISON_TYPE is
begin
case KEY is
when 0 | 1 | 2 => return POS;
when 3 => return COMP;
when 4 => return SUPER;
when others => return X;
end case;
end ADJ_COMP_FROM_KEY;
function ADV_COMP_FROM_KEY(KEY : STEM_KEY_TYPE) return COMPARISON_TYPE is
begin
case KEY is
when 1 => return POS;
when 2 => return COMP;
when 3 => return SUPER;
when others => return X;
end case;
end ADV_COMP_FROM_KEY;
function NUM_SORT_FROM_KEY(KEY : STEM_KEY_TYPE) return NUMERAL_SORT_TYPE is
begin
case KEY is
when 1 => return CARD;
when 2 => return ORD;
when 3 => return DIST;
when 4 => return ADVERB;
when others => return X;
end case;
end NUM_SORT_FROM_KEY;
function FIRST_INDEX(INPUT_WORD : STRING;
D_K : DICTIONARY_FILE_KIND := DEFAULT_DICTIONARY_FILE_KIND)
return STEM_IO.COUNT is
WD : constant STRING := TRIM(INPUT_WORD); -- string may not start at 1
begin
if D_K = LOCAL then
return DDLF(WD(WD'FIRST), 'a', D_K);
elsif WD'LENGTH < 2 then
return 0; -- BDLF(WD(WD'FIRST), ' ', D_K);
else
return DDLF(WD(WD'FIRST), WD(WD'FIRST+1), D_K);
end if;
end FIRST_INDEX;
function LAST_INDEX(INPUT_WORD : STRING;
D_K : DICTIONARY_FILE_KIND := DEFAULT_DICTIONARY_FILE_KIND)
return STEM_IO.COUNT is
WD : constant STRING := TRIM(INPUT_WORD);
begin -- remember the string may not start at 1
if D_K = LOCAL then
return DDLL(WD(WD'FIRST), 'a', D_K);
elsif WD'LENGTH < 2 then
return 0; -- BDLL(WD(WD'FIRST), ' ', D_K);
else
return DDLL(WD(WD'FIRST), WD(WD'FIRST+1), D_K);
end if;
end LAST_INDEX;
--procedure PUT_INDICES(CH : STRING;
-- D_K : DICTIONARY_KIND) is
-- WD : STRING(1..2) := CH(1..2);
-- begin
-- if CH = " " then
-- if BBLL(CH(1), CH(2), D_K) >= BBLF(CH(1), CH(2), D_K) then
-- PUT("CH = ("); PUT(CH); PUT(") index is of range ");
-- PUT(BBLF(CH(1), CH(2), D_K)); PUT(".."); PUT(BBLL(CH(1), CH(2), D_K));
-- PUT(" number ");
-- PUT(BBLL(CH(1), CH(2), D_K) - BBLF(CH(1), CH(2), D_K) + 1);
-- end if;
-- elsif CH(2) = ' ' then
-- if BDLL(CH(1), CH(2), D_K) >= BDLF(CH(1), CH(2), D_K) then
-- PUT("CH = ("); PUT(CH); PUT(") index is of range ");
-- PUT(BDLF(CH(1), CH(2), D_K)); PUT(".."); PUT(BDLL(CH(1), CH(2), D_K));
-- PUT(" number ");
-- PUT(BDLL(CH(1), CH(2), D_K) - BDLF(CH(1), CH(2), D_K) + 1);
-- end if;
-- else
-- if LAST_INDEX(WD, D_K) >= FIRST_INDEX(WD, D_K) then
-- PUT("CH = ("); PUT(WD); PUT(") index is of range ");
-- PUT(FIRST_INDEX(WD, D_K)); PUT(".."); PUT(LAST_INDEX(WD, D_K));
-- PUT(" number ");
-- PUT(LAST_INDEX(WD, D_K) - FIRST_INDEX(WD, D_K) + 1);
-- end if;
-- end if;
-- NEW_LINE;
-- end PUT_INDICES;
procedure LOAD_BDL_FROM_DISK is
use STEM_IO;
DS : DICTIONARY_STEM;
INDEX_FIRST,
INDEX_LAST : STEM_IO.COUNT := 0;
K : INTEGER := 0;
begin
--PUT_LINE("LOADING BDL FROM DISK");
if DICTIONARY_AVAILABLE(GENERAL) then
-- The blanks are on the GENERAL dictionary
LOADING_BDL_FROM_DISK:
declare
D_K : DICTIONARY_KIND := GENERAL;
begin
if not IS_OPEN(STEM_FILE(D_K)) then
--TEXT_IO.PUT_LINE("LOADING_BDL is going to OPEN " &
--ADD_FILE_NAME_EXTENSION(STEM_FILE_NAME,
--DICTIONARY_KIND'IMAGE(D_K)));
OPEN(STEM_FILE(D_K), STEM_IO.IN_FILE,
ADD_FILE_NAME_EXTENSION(STEM_FILE_NAME,
DICTIONARY_KIND'IMAGE(D_K)));
--TEXT_IO.PUT_LINE("OPENing was successful");
end if;
--TEXT_IO.PUT_LINE("BDL OPEN");
INDEX_FIRST := BBLF(' ', ' ', DICTIONARY_KIND(D_K));
INDEX_LAST := BBLL(' ', ' ', DICTIONARY_KIND(D_K));
SET_INDEX(STEM_FILE(D_K), STEM_IO.POSITIVE_COUNT(INDEX_FIRST));
for J in INDEX_FIRST..INDEX_LAST loop
READ(STEM_FILE(D_K), DS);
K := K + 1;
BDL(K) := DS;
end loop;
CLOSE(STEM_FILE(D_K));
--TEXT_IO.PUT_LINE("BDL LOADED FROM DISK K = " & INTEGER'IMAGE(K));
exception
when NAME_ERROR =>
TEXT_IO.PUT_LINE("LOADING BDL FROM DISK had NAME_ERROR on " &
ADD_FILE_NAME_EXTENSION(STEM_FILE_NAME,
DICTIONARY_KIND'IMAGE(D_K)));
TEXT_IO.PUT_LINE("The will be no blank stems loaded");
when USE_ERROR =>
TEXT_IO.PUT_LINE("LOADING BDL FROM DISK had USE_ERROR on " &
ADD_FILE_NAME_EXTENSION(STEM_FILE_NAME,
DICTIONARY_KIND'IMAGE(D_K)));
TEXT_IO.PUT_LINE("There will be no blank stems loaded");
end LOADING_BDL_FROM_DISK;
end if;
-- Now load the stems of just one letter
for D_K in GENERAL..DICTIONARY_KIND'LAST loop
if DICTIONARY_AVAILABLE(D_K) then
exit when D_K = LOCAL;
--TEXT_IO.PUT_LINE("OPENING BDL STEMFILE " & EXT(D_K));
if not IS_OPEN(STEM_FILE(D_K)) then
--PUT_LINE("LOADING_BDL is going to OPEN " &
--ADD_FILE_NAME_EXTENSION(STEM_FILE_NAME,
--DICTIONARY_KIND'IMAGE(D_K)));
OPEN(STEM_FILE(D_K), STEM_IO.IN_FILE,
ADD_FILE_NAME_EXTENSION(STEM_FILE_NAME,
DICTIONARY_KIND'IMAGE(D_K)));
--STEMFILE." & EXT(D_K));
--PUT_LINE("OPENing was successful");
end if;
for I in CHARACTER range 'a'..'z' loop
INDEX_FIRST := BDLF(I, ' ', D_K);
INDEX_LAST := BDLL(I, ' ', D_K);
if INDEX_FIRST > 0 then
SET_INDEX(STEM_FILE(D_K), STEM_IO.POSITIVE_COUNT(INDEX_FIRST));
for J in INDEX_FIRST..INDEX_LAST loop
READ(STEM_FILE(D_K), DS);
K := K + 1;
BDL(K) := DS;
end loop;
end if;
end loop;
--TEXT_IO.PUT_LINE("Single letters LOADED FROM DISK K = " & INTEGER'IMAGE(K));
CLOSE(STEM_FILE(D_K));
end if;
end loop;
BDL_LAST := K;
--TEXT_IO.PUT("FINISHED LOADING BDL FROM DISK BDL_LAST = ");
--TEXT_IO.PUT(INTEGER'IMAGE(BDL_LAST));
--TEXT_IO.NEW_LINE;
end LOAD_BDL_FROM_DISK;
procedure LOAD_INDICES_FROM_INDX_FILE(INDXFILE_NAME : STRING;
D_K : DICTIONARY_KIND) is
use TEXT_IO;
use INFLECTIONS_PACKAGE.INTEGER_IO;
use STEM_IO;
use COUNT_IO;
CH : STRING(1..2);
M, N : STEM_IO.COUNT;
NUMBER_OF_BLANK_STEMS,
NUMBER_OF_NON_BLANK_STEMS : STEM_IO.COUNT := 0;
S : STRING(1..100) := (others => ' ');
LAST, L : INTEGER := 0;
function MAX(A, B : STEM_IO.COUNT) return STEM_IO.COUNT is
begin
if A >= B then return A; end if; return B;
end MAX;
begin
OPEN(INDX_FILE(D_K), TEXT_IO.IN_FILE,
ADD_FILE_NAME_EXTENSION(INDX_FILE_NAME,
DICTIONARY_KIND'IMAGE(D_K)));
--"INDXFILE." & EXT(D_K)); -- $$$$$$$$$$$$
PREFACE.PUT(DICTIONARY_KIND'IMAGE(D_K));
PREFACE.PUT(" Dictionary loading");
if D_K = GENERAL then
GET_LINE(INDX_FILE(D_K), S, LAST);
CH := S(1..2);
GET(S(4..LAST), M, L);
BBLF(CH(1), CH(2), D_K) := M;
GET(S(L+1..LAST), N, L);
BBLL(CH(1), CH(2), D_K) := N;
NUMBER_OF_BLANK_STEMS := MAX(NUMBER_OF_BLANK_STEMS, N);
end if;
while not END_OF_FILE(INDX_FILE(D_K)) loop
GET_LINE(INDX_FILE(D_K), S, LAST);
exit when LAST = 0;
CH := S(1..2);
GET(S(4..LAST), M, L);
if CH(2) = ' ' then
BDLF(CH(1), CH(2), D_K) := M;
else
DDLF(CH(1), CH(2), D_K) := M;
end if;
GET(S(L+1..LAST), N, L);
if CH(2) = ' ' then
BDLL(CH(1), CH(2), D_K) := N;
NUMBER_OF_BLANK_STEMS := MAX(NUMBER_OF_BLANK_STEMS, N);
else
DDLL(CH(1), CH(2), D_K) := N;
NUMBER_OF_NON_BLANK_STEMS := MAX(NUMBER_OF_NON_BLANK_STEMS, N);
end if;
end loop;
CLOSE(INDX_FILE(D_K));
PREFACE.SET_COL(33); PREFACE.PUT("-- ");
if not CONFIG.SUPPRESS_PREFACE then
PUT(STEM_IO.COUNT((NUMBER_OF_NON_BLANK_STEMS)), 6);
end if; -- Kludge for when TEXT_IO.COUNT too small
PREFACE.PUT(" stems");
PREFACE.SET_COL(55); PREFACE.PUT_LINE("-- Loaded correctly");
end LOAD_INDICES_FROM_INDX_FILE;
end WORD_SUPPORT_PACKAGE;
|
-- { dg-do compile }
package body Pak is
pragma Suppress (Discriminant_Check);
-- Suppress discriminant check to prevent the assignment from using
-- the predefined primitive _assign.
procedure Initialize (X : in out T) is begin null; end Initialize;
procedure Finalize (X : in out T) is begin null; end Finalize;
procedure Assign (X : out T'Class) is
Y : T;
begin
T (X) := Y;
end Assign;
end Pak;
|
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
procedure Main is
Target: constant Integer := 2020;
Puzzle_Input: constant array (1 .. 200) of Integer := (
2000, 50, 1984, 1600, 1736, 1572, 2010, 1559, 1999, 1764,
1808, 1745, 1343, 1495, 1860, 1977, 1981, 1640, 1966, 1961,
1978, 1719, 1930, 535, 1804, 1535, 1507, 1284, 1618, 1991,
1589, 1593, 1960, 1953, 1963, 1697, 1741, 1823, 1932, 1789,
1822, 1972, 1570, 1651, 1800, 1514, 726, 1567, 72, 1987,
1791, 1842, 1020, 1541, 1383, 1505, 2009, 1925, 13, 1973,
1599, 1632, 1905, 1626, 1554, 1913, 1890, 1583, 1513, 1828,
187, 1616, 1508, 1524, 1613, 1648, 32, 1612, 1992, 1671,
1955, 1943, 1936, 1870, 1629, 1493, 1770, 1699, 1990, 1658,
1592, 1596, 1888, 1540, 239, 1677, 1602, 1877, 1481, 2004,
1985, 1829, 1980, 2008, 1964, 897, 1843, 1750, 1969, 1790,
1989, 1606, 1484, 1983, 1986, 1501, 1511, 1543, 1869, 1051,
1810, 1716, 1633, 1850, 1500, 1120, 1849, 1941, 1403, 1515,
1915, 1862, 2002, 1952, 1893, 1494, 1610, 1797, 1908, 1534,
1979, 2006, 1971, 1993, 1432, 1547, 1488, 1642, 1982, 1666,
1856, 1889, 1691, 1976, 1962, 2005, 1611, 1665, 1816, 1880,
1896, 1552, 1809, 1844, 1553, 1841, 1785, 1968, 1491, 1498,
1995, 1748, 1533, 1988, 2001, 1917, 1788, 1537, 1659, 1574,
1724, 1997, 923, 1476, 1763, 1817, 1998, 1848, 1974, 1830,
1672, 1861, 1652, 1551, 1363, 1645, 1996, 1965, 1967, 1778);
begin
for A of Puzzle_Input loop
for B of Puzzle_Input loop
if A + B = Target then
Put("Product ot two numbers: ");
Put(A*B);
New_Line;
end if;
for C of Puzzle_Input loop
if A + B + C = Target then
Put("Product ot three numbers: ");
Put(A*B*C);
New_Line;
end if;
end loop;
end loop;
end loop;
end Main;
|
with
lace.Event.Logger.text,
ada.unchecked_Deallocation,
system.RPC;
package body lace.Event.utility
is
--------------
-- Event Kinds
--
function to_Kind (From : in ada.Tags.Tag) return lace.Event.Kind
is
begin
return event.Kind (ada.Tags.external_Tag (From));
end to_Kind;
function Name_of (Kind : in Event.Kind) return String
is
begin
return String (Kind);
end Name_of;
---------
-- Events
--
function Kind_of (the_Event : in Event.item'Class) return Event.Kind
is
begin
return to_Kind (the_Event'Tag);
end Kind_of;
function Name_of (the_Event : in Event.item'Class) return String
is
begin
return Name_of (Kind_of (the_Event));
end Name_of;
--------------
-- Connections
--
procedure connect (the_Observer : in Observer.view;
to_Subject : in Subject .view;
with_Response : in Response.view;
to_Event_Kind : in Event.Kind)
is
begin
the_Observer.add (with_Response,
to_Event_Kind,
to_Subject.Name);
to_Subject.register (the_Observer,
to_Event_Kind);
end connect;
procedure disconnect (the_Observer : in Observer.view;
from_Subject : in Subject .view;
for_Response : in Response.view;
to_Event_Kind : in Event.Kind;
Subject_Name : in String)
is
begin
begin
the_Observer.rid (for_Response,
to_Event_Kind,
Subject_Name);
exception
when storage_Error =>
null; -- The observer is dead.
end;
begin
from_Subject.deregister (the_Observer,
to_Event_Kind);
exception
when system.RPC.communication_Error
| storage_Error =>
null; -- The subject is dead.
end;
end disconnect;
----------
-- Logging
--
the_Logger : Event.Logger.text.view;
procedure use_text_Logger (log_Filename : in String)
is
begin
the_Logger := new Event.Logger.text.item' (Event.Logger.text.to_Logger (log_Filename));
lace.Subject .Logger_is (the_Logger.all'Access);
lace.Observer.Logger_is (the_Logger.all'Access);
end use_text_Logger;
function Logger return lace.event.Logger.view
is
begin
return the_Logger.all'Access;
end Logger;
--------------
-- Termination
--
procedure close
is
use type Event.Logger.text.view;
begin
if the_Logger /= null
then
declare
procedure deallocate is new ada.unchecked_Deallocation (Event.Logger.text.item'Class,
Event.Logger.text.view);
begin
the_Logger.destruct;
deallocate (the_Logger);
end;
end if;
end close;
end lace.Event.utility;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- A demonstration for the Window Watchdog on the STM32F4 series MCUs.
-- Note that, for proper execution, you will need to reset the board manually
-- after downloading, even if it starts running automatically, due to the
-- behavior of the watchdog device.
-- The program activates the watchdog and then loops indefinitely, toggling
-- the board's green LED. (A board with two LEDs is required but the colors
-- are immaterial). Within the loop there is a delay statement representing
-- some application work being done. After that delay the program refreshes
-- the watchdog counter to avoid the reset. The delay value itself, therefore,
-- can be used to demonstrate the fact that the watchdog must only be
-- refreshed within the configured window of time: doing so too soon or too
-- late (or not at all) indicates some fault in the software and thus triggers
-- the reset. When the program first runs it checks for a previous system
-- reset (something an application might want to do), and in that case it
-- turns on the red LED. That is the only indication that the window was
-- missed because once the board resets it will begin toggling the green
-- LED again. The red LED will remain turned on, however, so you can see
-- the evidence.
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
with HAL; use HAL;
with STM32.Device; use STM32.Device;
with STM32.Board; use STM32.Board;
with STM32.WWDG; use STM32.WWDG;
with Ada.Real_Time; use Ada.Real_Time;
procedure Demo_WWDG is
----------------------------------------------------------------------------
-- For the following, see Figure 215 in RM0090, illustrating the watchdog
-- behavior and significant events. Note that time is increasing to the
-- right in the figure.
-- www.st.com/resource/en/reference_manual/DM00031020.pdf
----------------------------------------------------------------------------
Initial_Count : constant Downcounter := 127;
-- This is the initial counter value of the countdown timer. In the figure,
-- this is the counter value at the start of the "refresh not allowed"
-- interval. It is an arbitrary, user-defined value.
Window_Start_Count : constant Downcounter := 80;
-- This is the value of the countdown counter when the refresh window is to
-- open. In the figure, this is the counter value at the start of the
-- "refresh allowed" interval. It is an arbitrary, user-defined value.
--
-- The last counter value prior to reset is always 64 (16#40#). At 16#3F#
-- the high-order counter bit T6 (see the figure) clears, causing the
-- watchdog to trigger the system reset (when activated). That is also
-- the closing of the refresh window.
Clock_Prescaler : constant Prescalers := Divider_8;
-- The above are all that is required to drive the watchdog (by passing
-- them to the API routines). The rest of the constants that follow are
-- used to calculate a demonstration-specific delay value used purely to
-- show how the watchdog behaves. We calculate these values so that the
-- source code will be independent of a given board. They are also useful
-- for understanding the watchdog refresh window opening and closing
-- times. The goal is to calculate the Time_Span value for the window,
-- ie the "refresh allowed" interval in the figure, so that you can
-- experiment with values relative to that window.
PCLK1_Frequency : constant UInt32 := System_Clock_Frequencies.PCLK1;
-- The PCLK1 frequency on the STM32F429I Discovery boards is 45MHz, for
-- example, and that is what we use in the comments below.
Divider : constant UInt32 := (case Clock_Prescaler is
when Divider_1 => 1,
when Divider_2 => 2,
when Divider_4 => 4,
when Divider_8 => 8);
WWDG_Counter_Freq : constant UInt32 := PCLK1_Frequency / 4096 / Divider;
-- 45MHz / 4096 / 8 = 1373 Hz
WWDG_Counter_Period : constant Duration := 1.0 / Duration (WWDG_Counter_Freq);
-- 1 / 1373 = ~0.000728
WWDG_Timeout : constant Duration := WWDG_Counter_Period * 64;
-- ~0.000728 * 64 = ~0.046
--
-- The time at which the timeout occurs, ie the window closes. The
-- watchdog always triggers at count 63 (16#3F# in the diagram).
Refresh_Window_Closing : constant Time_Span := To_Time_Span (WWDG_Timeout);
-- ~46 ms
--
-- The time at which the window closes, just before the reset will be
-- triggered.
Refresh_Not_Allowed : constant Integer := Integer (Initial_Count - Window_Start_Count);
-- (127 - 80) = 47
--
-- This is the interval, in terms of counts, before the refresh window
-- opens, ie before when the downcounter matches the Window_Start_Count
-- value. In the figure, this is the width of the "refresh now allowed"
-- interval.
WWDG_Window_Starts : constant Duration := WWDG_Counter_Period * Refresh_Not_Allowed;
-- ~0.000728 * 47 = ~0.034
--
-- The time at which the window opens, immediately after the "refresh not
-- allowed" interval ends.
Refresh_Window_Opening : constant Time_Span := To_Time_Span (WWDG_Window_Starts);
-- ~34ms
-- So now we know, given the assumed PCLK1 value and the user-defined
-- configuration selections, that the "refresh allowed" window opens
-- approximately 34ms after the watchdog is activated/refreshed, and closes
-- approximately 46ms after being activated/refreshed. The window is thus
-- approximately 12ms wide.
Window_Midpoint : constant Time_Span :=
Refresh_Window_Opening + ((Refresh_Window_Closing - Refresh_Window_Opening) / 2);
-- The midpoint of the window, given the above calculations, is
-- approximately 40ms after activation/refresh.
Application_Work_Interval : constant Time_Span := Window_Midpoint;
-- The amount to pause before refreshing the watchdog counter, representing
-- some work being done by the application. The midpoint of the refresh
-- window is chosen arbitrarily. Experiment with different values within
-- and outside the window to see that refreshing outside the window will
-- trigger the reset.
begin
Initialize_LEDs;
if WWDG_Reset_Indicated then
-- We missed the refresh window in a previous execution of the program
-- and were reset, so signal that fact.
Turn_On (Red_LED);
Clear_WWDG_Reset_Flag;
else
Turn_Off (Red_LED);
end if;
Enable_Watchdog_Clock;
Reset_Watchdog;
Set_Watchdog_Prescaler (Clock_Prescaler);
Set_Watchdog_Window (Window_Start_Count);
Activate_Watchdog (Initial_Count);
loop
-- show we are running...
Green_LED.Toggle;
-- Do some application-specific work here, requiring an interval
-- represented by the delay value (not counting the time to toggle the
-- LED or do anything else), after which we reset the watchdog. But of
-- course it cannot be too soon or too late, otherwise the system is
-- reset by the watchdog.
delay until Clock + Application_Work_Interval;
Refresh_Watchdog_Counter (Initial_Count);
end loop;
end Demo_WWDG;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure DePermute is
type U64 is mod 2**64;
type Num is range 0 .. 20;
type NumList is array (Natural range <>) of Num;
type PtNumList is access all NumList;
package IO is new Ada.Text_IO.Integer_IO (Num);
package UIO is new Ada.Text_IO.Modular_IO (U64);
function deranged (depth : Natural; list : PtNumList;
show : Boolean) return U64 is
tmp : Num; count : U64 := 0;
begin
if depth = list'Length then
if show then
for i in list'Range loop IO.Put (list (i), 2); end loop;
New_Line;
end if; return 1;
end if;
for i in reverse depth .. list'Last loop
if Num (i + 1) /= list (depth) then
tmp := list (i); list (i) := list (depth); list (depth) := tmp;
count := count + deranged (depth + 1, list, show);
tmp := list (i); list (i) := list (depth); list (depth) := tmp;
end if;
end loop;
return count;
end deranged;
function gen_n (len : Natural; show : Boolean) return U64 is
list : PtNumList;
begin
list := new NumList (0 .. len - 1);
for i in list'Range loop list (i) := Num (i + 1); end loop;
return deranged (0, list, show);
end gen_n;
function sub_fact (n : Natural) return U64 is begin
if n < 2 then return U64 (1 - n);
else return (sub_fact (n - 1) + sub_fact (n - 2)) * U64 (n - 1);
end if;
end sub_fact;
count : U64;
begin
Put_Line ("Deranged 4:");
count := gen_n (4, True);
Put_Line ("List vs. calc:");
for i in Natural range 0 .. 9 loop
IO.Put (Num (i), 1); UIO.Put (gen_n (i, False), 7);
UIO.Put (sub_fact (i), 7); New_Line;
end loop;
Put_Line ("!20 = " & U64'Image (sub_fact (20)));
end DePermute;
|
------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2004-2016, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Characters.Wide_Wide_Latin_1;
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
use Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
with Ada.Strings.Wide_Wide_Unbounded; use Ada.Strings.Wide_Wide_Unbounded;
with Ada.Wide_Wide_Characters.Handling; use Ada.Wide_Wide_Characters.Handling;
package body Case_Handling is
procedure Add_Exception
(HTable : Exceptions_Table;
Str : String;
Read_Only : Boolean);
-- Add Str exception in HTable
procedure Remove_Exception (HTable : Exceptions_Table; Str : String);
-- Remove str exception from the HTable
function Mixed_Case
(Image : Wide_Wide_String;
Smart : Boolean := False) return Wide_Wide_String;
-- The same as one in package specification, but on Wide_Wide_String.
----------------
-- Mixed_Case --
----------------
function Mixed_Case
(Image : Wide_Wide_String;
Smart : Boolean := False) return Wide_Wide_String
is
package Latin_1 renames Ada.Characters.Wide_Wide_Latin_1;
Do_Upper : Boolean;
C : Wide_Wide_Character;
Result : Unbounded_Wide_Wide_String;
begin
if Image'Length = 0 then
return Image;
end if;
Do_Upper := True;
for Index in Image'Range loop
C := Image (Index);
if C = '.'
or else C = '_'
or else C = ' '
or else C = '('
or else C = ')'
or else C = '+'
or else C = '-'
or else C = '*'
or else C = '/'
or else C = ','
or else C = ';'
or else C = '''
or else C = Latin_1.HT
or else C = Latin_1.LF
or else C = Latin_1.CR
then
Do_Upper := True;
Append (Result, C);
else
if Do_Upper then
Append (Result, Ada.Wide_Wide_Characters.Handling.To_Upper (C));
elsif not Smart then
Append (Result, To_Lower (C));
else
Append (Result, C);
end if;
Do_Upper := False;
end if;
end loop;
return To_Wide_Wide_String (Result);
end Mixed_Case;
----------------
-- Mixed_Case --
----------------
function Mixed_Case
(S : UTF8_String; Smart : Boolean := False) return UTF8_String
is
Image : constant Wide_Wide_String := Decode (S);
begin
return Encode (Mixed_Case (Image, Smart));
end Mixed_Case;
---------------
-- Set_Case --
---------------
function Set_Case
(C : Casing_Exceptions;
Word : UTF8_String;
Casing : Casing_Type) return UTF8_String
is
function Set_Substring_Exception
(Word : Wide_Wide_String) return UTF8_String;
-- Apply substring exception to word if possible.
-----------------------------
-- Set_Substring_Exception --
-----------------------------
function Set_Substring_Exception
(Word : Wide_Wide_String) return UTF8_String
is
procedure Apply (Substring : Wide_Wide_String);
-- Check if a substring exception exists for this substring and
-- apply it.
Result : Unbounded_Wide_Wide_String;
-----------
-- Apply --
-----------
procedure Apply (Substring : Wide_Wide_String) is
-- Set L_Str with the key for Str in the exception hash table
L_Word : constant Wide_Wide_String := To_Lower (Substring);
Pos : Cursor;
begin
Pos := C.S.Find (L_Word);
if Has_Element (Pos) then
Append (Result, Element (Pos).Word);
else
Append (Result, Substring);
end if;
end Apply;
First : Natural := Word'First - 1;
begin
if C.S = null then
return Encode (Word);
end if;
-- Look for all substring in this word
for K in Word'Range loop
if Word (K) = '_' then
Apply (Word (First + 1 .. K - 1));
First := K;
Append (Result, '_');
end if;
end loop;
-- Apply to the last one
Apply (Word (First + 1 .. Word'Last));
return Encode (To_Wide_Wide_String (Result));
end Set_Substring_Exception;
Image : constant Wide_Wide_String := Decode (Word);
L_Str : constant Wide_Wide_String := To_Lower (Image);
N : Cursor;
begin
if Casing = Unchanged then
-- Nothing to do in this case
return Word;
end if;
-- Now we check for the case exception for this word. If found we
-- just return the record casing, if not set we set the word casing
-- according to the rule set in Casing.
if C.E /= null then
N := C.E.Find (L_Str);
end if;
if not Has_Element (N) then
-- No case exception for this word, apply standard rules
case Casing is
when Unchanged =>
return Set_Substring_Exception (Image);
when Upper =>
return Set_Substring_Exception (To_Upper (Image));
when Lower =>
return Set_Substring_Exception (L_Str);
when Mixed =>
return Set_Substring_Exception (Mixed_Case (Image));
when Smart_Mixed =>
return Set_Substring_Exception
(Mixed_Case (Image, Smart => True));
end case;
else
-- We have found a case exception
return Encode (Element (N).Word);
end if;
end Set_Case;
-------------------
-- Add_Exception --
-------------------
procedure Add_Exception
(HTable : Exceptions_Table;
Str : String;
Read_Only : Boolean)
is
Image : constant Wide_Wide_String := Decode (Str);
begin
HTable.Include (To_Lower (Image), (Image'Length, Read_Only, Image));
end Add_Exception;
procedure Add_Exception
(C : in out Casing_Exceptions;
Word : String;
Read_Only : Boolean) is
begin
Add_Exception (C.E, Word, Read_Only);
end Add_Exception;
-----------------------------
-- Add_Substring_Exception --
-----------------------------
procedure Add_Substring_Exception
(C : in out Casing_Exceptions;
Substring : String;
Read_Only : Boolean) is
begin
Add_Exception (C.S, Substring, Read_Only);
end Add_Substring_Exception;
----------------------
-- Remove_Exception --
----------------------
procedure Remove_Exception
(HTable : Exceptions_Table;
Str : String)
is
Image : constant Wide_Wide_String := Decode (Str);
L_Str : constant Wide_Wide_String := To_Lower (Image);
Pos : Cursor := HTable.Find (L_Str);
begin
if Has_Element (Pos) and then not Element (Pos).Read_Only then
HTable.Delete (Pos);
end if;
end Remove_Exception;
procedure Remove_Exception (C : in out Casing_Exceptions; Word : String) is
begin
Remove_Exception (C.E, Word);
end Remove_Exception;
--------------------------------
-- Remove_Substring_Exception --
--------------------------------
procedure Remove_Substring_Exception
(C : in out Casing_Exceptions;
Substring : String) is
begin
Remove_Exception (C.S, Substring);
end Remove_Substring_Exception;
-------------
-- Destroy --
-------------
procedure Destroy (C : in out Casing_Exceptions) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Map, Exceptions_Table);
begin
-- Word exceptions
if C.E /= null then
C.E.Clear;
Unchecked_Free (C.E);
end if;
-- Substring exceptions
if C.S /= null then
C.S.Clear;
Unchecked_Free (C.S);
end if;
end Destroy;
end Case_Handling;
|
-- Abstract:
--
-- see spec
--
-- Copyright (C) 1998, 2003, 2009, 2015, 2017 - 2019 Free Software Foundation, Inc.
--
-- SAL 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. SAL is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- See the GNU General Public License for more details. You should
-- have received a copy of the GNU General Public License distributed
-- with SAL; see file COPYING. If not, write to the Free Software
-- Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-- USA.
--
-- As a special exception, if other files instantiate generics from
-- SAL, or you link SAL object files with other files to produce an
-- executable, that 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.
pragma License (Modified_GPL);
package body SAL.Gen_Bounded_Definite_Stacks
with Spark_Mode
is
pragma Suppress (All_Checks);
procedure Clear (Stack : in out Sgbds.Stack)
is begin
Stack.Top := 0;
end Clear;
function Depth (Stack : in Sgbds.Stack) return Size_Type
is (Stack.Top);
function Is_Empty (Stack : in Sgbds.Stack) return Boolean
is begin
return Stack.Top = 0;
end Is_Empty;
function Is_Full (Stack : in Sgbds.Stack) return Boolean
is begin
return Stack.Top = Stack.Size;
end Is_Full;
function Peek
(Stack : in Sgbds.Stack;
Index : in Peek_Type := 1)
return Element_Type
is (Stack.Data (Stack.Top - Index + 1));
procedure Pop (Stack : in out Sgbds.Stack; Count : in Base_Peek_Type := 1)
is begin
Stack.Top := Stack.Top - Count;
end Pop;
procedure Pop (Stack : in out Sgbds.Stack; Item : out Element_Type)
is begin
Item := Stack.Peek (1);
Stack.Top := Stack.Top - 1;
end Pop;
function Pop (Stack : in out Sgbds.Stack) return Element_Type with
Spark_Mode => Off
is begin
return Result : Element_Type do
Pop (Stack, Result);
end return;
end Pop;
procedure Push (Stack : in out Sgbds.Stack; Item : in Element_Type)
is begin
Stack.Top := Stack.Top + 1;
Stack.Data (Stack.Top) := Item;
end Push;
end SAL.Gen_Bounded_Definite_Stacks;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Drone is
-- Create program that handles drone.
Choice: Character;
Altitude: Integer;
Start: Integer;
begin
-- Initialize variables.
Altitude := 0;
Start := 0;
-- Print menu for the first time.
Put_Line("Current Altitude :" &Integer'Image(Altitude));
Put_Line("Menu");
Put_Line("s -- Start");
Put_Line("u -- Up");
Put_Line("d-- Down");
Put_Line("q -- Quit");
-- Get the action to do.
Put("What to do : ");
get(Choice);
-- Handle drone.
while true loop
case Choice is
when 's' | 'S' => -- Start engine.
Start := 1;
when 'u' | 'U' => -- Go up.
if Altitude = 4 then -- Drone out of reach.
Altitude := 5;
Put_line("drone out of reach");
exit; -- Exit the program.
end if;
if Start = 0 then -- Engine shutting down.
Put_line("Engine shutting down");
else
Altitude := Altitude + 1; -- Increment altitude.
end if;
when 'd' | 'D' => -- Go down.
if Start = 0 then -- Engine shutting down.
Put_line("Engine shutting down");
end if;
if Altitude = 0 then -- Impossible to go down when Altitude = 0.
Put_line("Impossible move");
else
Altitude := Altitude - 1; -- Decrement altitude.
end if;
when 'q' | 'Q' => -- Quit program.
Put_Line("GOODBYE");
exit; -- Exit the program.
when others => null;
end case;
-- Print menu for the seconde time.
Put_Line("Current Altitude :" &Integer'Image(Altitude));
Put_Line("Menu");
Put_Line("s -- Start");
Put_Line("u -- Up");
Put_Line("d-- Down");
Put_Line("q -- Quit");
-- Get choice for the second time.
Put("What to do : ");
get(Choice);
end loop;
end Drone;
|
-- C85011A.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.
--*
-- OBJECTIVE:
-- CHECK THAT A PACKAGE CAN BE RENAMED AND THE NEW NAME CAN APPEAR
-- IN A RENAMING DECLARATION, AND THAT A 'USE' CLAUSE CAN REFER TO
-- THE PACKAGE BY EITHER NAME, INCLUDING RENAMINGS OF GENERIC AND
-- NONGENERIC PACKAGES INSIDE THEMSELVES.
-- HISTORY:
-- JET 04/28/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C85011A IS
PACKAGE PACK1 IS
I : NATURAL := 0;
PACKAGE PACKA RENAMES PACK1;
END PACK1;
GENERIC
TYPE T IS RANGE <>;
PACKAGE GPACK IS
J : T := T'FIRST;
PACKAGE PACKB RENAMES GPACK;
END GPACK;
PACKAGE PACK2 IS NEW GPACK(NATURAL);
PACKAGE PACK3 RENAMES PACK1;
PACKAGE PACK4 RENAMES PACK2;
PACKAGE PACK5 RENAMES PACK3;
PACKAGE PACK6 RENAMES PACK4;
BEGIN
TEST ("C85011A", "CHECK THAT A PACKAGE CAN BE RENAMED AND THE " &
"NEW NAME CAN APPEAR IN A RENAMING " &
"DECLARATION, AND THAT A 'USE' CLAUSE CAN " &
"REFER TO THE PACKAGE BY EITHER NAME, " &
"INCLUDING RENAMINGS OF GENERIC AND NONGENERIC " &
"PACKAGES INSIDE THEMSELVES");
IF PACK1.I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK1.I");
END IF;
IF PACK2.J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK2.J");
END IF;
IF PACK3.I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK3.I");
END IF;
IF PACK4.J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK4.J");
END IF;
IF PACK5.I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK5.I");
END IF;
IF PACK6.J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK6.J");
END IF;
IF PACK1.PACKA.I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK1.PACKA.I");
END IF;
IF PACK2.PACKB.J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF PACK2.PACKB.J");
END IF;
DECLARE
USE PACK1, PACK2;
BEGIN
IF I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF I (1)");
END IF;
IF J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF J (1)");
END IF;
END;
DECLARE
USE PACK3, PACK4;
BEGIN
IF I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF I (2)");
END IF;
IF J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF J (2)");
END IF;
END;
DECLARE
USE PACK5, PACK6;
BEGIN
IF I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF I (3)");
END IF;
IF J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF J (3)");
END IF;
END;
DECLARE
USE PACK1.PACKA, PACK2.PACKB;
BEGIN
IF I /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF I (4)");
END IF;
IF J /= IDENT_INT(0) THEN
FAILED ("INCORRECT VALUE OF J (4)");
END IF;
END;
RESULT;
END C85011A;
|
-- 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
---------------------------------------------------------------------------
package Ada.Finalization is
pragma Preelaborate (Finalization);
pragma Remote_Types (Finalization);
type Controlled is abstract tagged private;
pragma Preelaborable_Initialization (Controlled);
procedure Initialize (Object : in out Controlled) is null;
procedure Adjust (Object : in out Controlled) is null;
procedure Finalize (Object : in out Controlled) is null;
type Limited_Controlled is abstract tagged limited private;
pragma Preelaborable_Initialization (Limited_Controlled);
procedure Initialize (Object : in out Limited_Controlled) is null;
procedure Finalize (Object : in out Limited_Controlled) is null;
private
pragma Import (Ada, Controlled);
pragma Import (Ada, Limited_Controlled);
end Ada.Finalization;
|
with
any_Math.any_Random;
package float_Math.Random is new float_Math.any_Random;
|
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with GNAT.Command_Line;
with Options;
package body Command_Line is
Long_Switch_Show_Help : constant String := "--help";
Long_Switch_Show_Version : constant String := "--version";
Long_Switch_Web_Dir_Base : constant String := "--web-base=";
Long_Switch_TCP_IP_Port : constant String := "--port=";
Long_Switch_Host_List : constant String := "--host-list=";
Long_Switch_Be_Quiet : constant String := "--quiet";
Config : GNAT.Command_Line.Command_Line_Configuration;
procedure Parse (Success : out Boolean)
is
use GNAT.Command_Line;
use Options;
begin
Define_Switch (Config, Show_Help'Access,
Help => "Show this help text.",
Long_Switch => Long_Switch_Show_Help);
Define_Switch (Config, Show_Version'Access,
Help => "Show program name and version.",
Long_Switch => Long_Switch_Show_Version);
Define_Switch (Config, Web_Dir_Base'Access, "-w=", Argument => "DIR",
Help => "Base of web directory strcture.",
Long_Switch => Long_Switch_Web_Dir_Base);
Define_Switch (Config, TCP_IP_Port'Access, "-p=", Argument => "PORT",
Help => "Web server listen port.",
Long_Switch => Long_Switch_TCP_IP_Port);
Define_Switch (Config, Host_List_File'Access, "-h=", Argument => "FILE",
Help => "List of hosts to serve.",
Long_Switch => Long_Switch_Host_List);
Define_Switch (Config, Be_Quiet'Access, "-q",
Help => "Be quiet (No banner, blessing etc).",
Long_Switch => Long_Switch_Be_Quiet);
-- Do the whole parsing business.
Getopt (Config);
Success := True;
exception
when
Invalid_Switch |
Invalid_Parameter |
Exit_From_Command_Line =>
Success := False;
raise;
end Parse;
end Command_Line;
|
pragma Ada_2012;
package body DDS.Request_Reply.Tests.Simple.Server is
------------------------
-- Compute_And_Replie --
------------------------
task body Ref2 is
Octets_Data : DDS.Octets;
String_Data : DDS.String;
L_Replier : DDS.Request_Reply.Replier.Ref_Access;
L_Id : DDS.SampleIdentity_T;
begin
select
accept Compute_And_Reply (Replier : Octets_Replier.Ref_Access;
Data : DDS.Octets;
Id : DDS.SampleIdentity_T)
do
Dds.Copy (Octets_Data, Data);
L_Id := Id;
L_Replier := Request_Reply.Replier.Ref_Access (Replier);
end Compute_And_Reply;
declare
L : constant Standard.String := "Ret Octets";
Result : constant Dds.Octets := Dds.Octets'(Length => L'Length,
Value => L'Address);
begin
Octets_Replier.Ref_Access (L_Replier).Send_Reply (Result, Id => L_Id);
end;
or
accept Compute_And_Reply (Replier : String_Replier.Ref_Access;
Data : DDS.String;
Id : DDS.SampleIdentity_T)
do
Dds.Copy (String_Data, Data);
L_Id := Id;
L_Replier := Request_Reply.Replier.Ref_Access (Replier);
end Compute_And_Reply;
declare
Ret : DDS.String;
begin
Copy (Ret, "In reply to: """);
Append (Ret, String_Data);
Append (Ret, """");
String_Replier.Ref_Access (L_Replier).Send_Reply (Ret, Id => L_Id);
Finalize (Ret);
end;
or
terminate;
end select;
end Ref2;
procedure Compute_And_Reply (Self : not null access Ref;
Replier : Octets_Replier.Ref_Access;
Data : DDS.Octets;
Id : DDS.SampleIdentity_T)
is
L : constant Standard.String := "Ret Octets";
Result : constant Dds.Octets := Dds.Octets'(Length => L'Length,
Value => L'Address);
begin
Replier.Send_Reply (Result, Id => Id);
end Compute_And_Reply;
------------------------
-- Compute_And_Replie --
------------------------
procedure Compute_And_Reply
(Self : not null access Ref;
Replier : String_Replier.Ref_Access;
Data : DDS.String;
Id : DDS.SampleIdentity_T)
is
Ret : String;
begin
Copy (Ret, "In reply to: """);
Append (Ret, Data);
Append (Ret, """");
Replier.Send_Reply (Ret, Id => Id);
end Compute_And_Reply;
end DDS.Request_Reply.Tests.Simple.Server;
|
with Ada.Unchecked_Deallocation;
with Interfaces;
with kv.avm.Transactions;
package kv.avm.Clients is
type Client_Interface is interface;
type Client_Access is access all Client_Interface'CLASS;
type Status_Type is (Uninitialized, Closed, Running, Transacting, Failed);
subtype Open_Status_Type is Status_Type range Running .. Transacting;
procedure Bind_Address
(Self : in out Client_Interface;
Address : in String) is abstract;
procedure Bind_Port
(Self : in out Client_Interface;
Port : in Positive) is abstract;
procedure Open
(Self : in out Client_Interface) is abstract;
procedure Close
(Self : in out Client_Interface) is abstract;
function Get_Status(Self : Client_Interface) return Status_Type is abstract;
function Is_Open(Self : Client_Interface) return Boolean is abstract;
procedure Send_Transaction
(Self : in out Client_Interface;
Transaction : in kv.avm.Transactions.Transactions_Interface'CLASS) is abstract;
procedure Conclude_Transaction
(Self : in out Client_Interface) is abstract;
function Is_Transaction_Pending(Self : Client_Interface) return Boolean is abstract;
function Get_Transaction(Self : Client_Interface) return kv.avm.Transactions.Transactions_Access is abstract;
function Get_Domain(Self : Client_Interface) return Interfaces.Unsigned_32 is abstract;
procedure Free is new Ada.Unchecked_Deallocation(Client_Interface'CLASS, Client_Access);
type Client_Factory is interface;
type Factory_Access is access all Client_Factory'CLASS;
procedure New_Client
(Self : in out Client_Factory;
Client : out Client_Access) is abstract;
end kv.avm.Clients;
|
package body Base with SPARK_Mode is
subtype Base58Digit is Integer range 0 .. 57;
type Alpha_Type is array (Base58Digit) of Character;
Alphabet : constant Alpha_Type :=
"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
------------
-- Encode --
------------
function Encode (S : String) return Number is
-- biggest possible carry
subtype Carry_Type is Integer range 0 .. 255 + 256 * 57;
Carry : Carry_Type;
J : Integer;
begin
declare
-- compute the required size of the Buf buffer
Size : constant Integer := S'Length * 138 / 100 + 1;
-- the Buf buffer is a Base58 number with a digit per cell,
-- but represented using numbers 0 to 57 instead of the actual
-- characters.
type Base58Number is array (1 .. Size) of Base58Digit;
Buf : Base58Number := (others => 0);
High : Integer := Size;
begin
-- Buf contains the current encoded number. We now process each input
-- character one by one. Basically, what we do for each digit is to
-- compute
-- Buf * 256 + S (I)
-- that is, we take into account the new input digit by shifting the
-- others to the left (by multiplying with 256) and adding the new
-- number. Of course we do these operations on the Base58 number held
-- by Buf, so this computation is done backwards from the end of Buf
-- with a Carry that initially contains S (I).
for I in S'Range loop
J := Size;
Carry := Character'Pos(S (I));
while J in Buf'Range and then (Carry /= 0 or else J > High) loop
pragma Loop_Invariant (Carry in 0 .. 255);
Carry := Carry + 256 * Buf (J);
Buf (J) := Carry rem 58;
Carry := Carry / 58;
J := J - 1;
end loop;
High := J;
end loop;
declare
Result : Number (1 .. Size);
begin
for I in Result'Range loop
Result (I) := Alphabet (Buf (I));
end loop;
return Result;
end;
end;
end Encode;
------------
-- Decode --
------------
function Decode (N : Number) return String is
begin
return String (N);
end Decode;
end Base;
|
-----------------------------------------------------------------------
-- awa-counters-modules -- Module counters
-- Copyright (C) 2015 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.Unchecked_Deallocation;
with ADO.Queries;
with ADO.Statements;
with ADO.Parameters;
with ADO.Sessions.Entities;
with ADO.SQL;
with Util.Dates;
with Util.Log.Loggers;
with AWA.Modules.Beans;
with AWA.Applications;
with AWA.Counters.Models;
with AWA.Modules.Get;
with AWA.Counters.Beans;
with AWA.Counters.Components;
package body AWA.Counters.Modules is
use type ADO.Schemas.Class_Mapping_Access;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Awa.Counters.Module");
package Register is new AWA.Modules.Beans (Module => Counter_Module,
Module_Access => Counter_Module_Access);
procedure Load_Definition (DB : in out ADO.Sessions.Master_Session;
Def : in Counter_Def;
Result : out Natural);
procedure Flush (DB : in out ADO.Sessions.Master_Session;
Counter : in Counter_Def;
Def_Id : in Natural;
Counters : in Counter_Maps.Map;
Date : in Ada.Calendar.Time);
-- ------------------------------
-- Initialize the counters module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Counter_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the counters module");
Register.Register (Plugin => Plugin,
Name => "AWA.Counters.Beans.Stat_List_Bean",
Handler => AWA.Counters.Beans.Create_Counter_Stat_Bean'Access);
App.Add_Components (AWA.Counters.Components.Definition);
AWA.Modules.Module (Plugin).Initialize (App, Props);
-- Add here the creation of manager instances.
end Initialize;
-- ------------------------------
-- Configures the module after its initialization and after having read its XML configuration.
-- ------------------------------
overriding
procedure Configure (Plugin : in out Counter_Module;
Props : in ASF.Applications.Config) is
pragma Unreferenced (Props);
begin
Plugin.Counter_Limit := Plugin.Get_Config (PARAM_COUNTER_LIMIT, DEFAULT_COUNTER_LIMIT);
Plugin.Age_Limit := Duration (Plugin.Get_Config (PARAM_AGE_LIMIT, 300));
Log.Info ("Counter flush module limit is{0} counters with max age{1} seconds",
Natural'Image (Plugin.Counter_Limit), Duration'Image (Plugin.Age_Limit));
end Configure;
-- ------------------------------
-- Get the counters module.
-- ------------------------------
function Get_Counter_Module return Counter_Module_Access is
function Get is new AWA.Modules.Get (Counter_Module, Counter_Module_Access, NAME);
begin
return Get;
end Get_Counter_Module;
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt> and associated with the
-- database object <tt>Object</tt>.
-- ------------------------------
procedure Increment (Plugin : in out Counter_Module;
Counter : in Counter_Index_Type;
Object : in ADO.Objects.Object_Ref'Class) is
Key : constant ADO.Objects.Object_Key := Object.Get_Key;
begin
if Plugin.Counters.Need_Flush (Plugin.Counter_Limit, Plugin.Age_Limit) then
Plugin.Flush;
end if;
Plugin.Counters.Increment (Counter, Key);
end Increment;
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt> and associated with the
-- database object key <tt>Key</tt>.
-- ------------------------------
procedure Increment (Plugin : in out Counter_Module;
Counter : in Counter_Index_Type;
Key : in ADO.Objects.Object_Key) is
begin
if Plugin.Counters.Need_Flush (Plugin.Counter_Limit, Plugin.Age_Limit) then
Plugin.Flush;
end if;
Plugin.Counters.Increment (Counter, Key);
end Increment;
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt>.
-- ------------------------------
procedure Increment (Plugin : in out Counter_Module;
Counter : in Counter_Index_Type) is
Key : ADO.Objects.Object_Key (ADO.Objects.KEY_INTEGER, null);
begin
if Plugin.Counters.Need_Flush (Plugin.Counter_Limit, Plugin.Age_Limit) then
Plugin.Flush;
end if;
Plugin.Counters.Increment (Counter, Key);
end Increment;
-- ------------------------------
-- Get the current counter value.
-- ------------------------------
procedure Get_Counter (Plugin : in out Counter_Module;
Counter : in AWA.Counters.Counter_Index_Type;
Object : in ADO.Objects.Object_Ref'Class;
Result : out Natural) is
Id : constant ADO.Identifier := ADO.Objects.Get_Value (Object.Get_Key);
DB : ADO.Sessions.Master_Session := Plugin.Get_Master_Session;
Stmt : ADO.Statements.Query_Statement
:= DB.Create_Statement ("SELECT SUM(counter) FROM awa_counter WHERE "
& "object_id = :id AND definition_id = :definition_id");
Def_Id : Natural;
begin
Plugin.Counters.Get_Definition (DB, Counter, Def_Id);
Stmt.Bind_Param ("id", Id);
Stmt.Bind_Param ("definition_id", Def_Id);
Stmt.Execute;
Result := Stmt.Get_Result_Integer;
end Get_Counter;
protected body Counter_Table is
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt> and associated with the
-- database object <tt>Key</tt>.
-- ------------------------------
procedure Increment (Counter : in Counter_Index_Type;
Key : in ADO.Objects.Object_Key) is
procedure Increment (Key : in ADO.Objects.Object_Key;
Element : in out Positive);
procedure Increment (Key : in ADO.Objects.Object_Key;
Element : in out Positive) is
pragma Unreferenced (Key);
begin
Element := Element + 1;
end Increment;
Pos : Counter_Maps.Cursor;
begin
if Counters = null then
Counters := new Counter_Map_Array (1 .. Counter_Arrays.Get_Last);
Day := Ada.Calendar.Clock;
Day_End := Util.Dates.Get_Day_End (Day);
end if;
Pos := Counters (Counter).Find (Key);
if Counter_Maps.Has_Element (Pos) then
Counters (Counter).Update_Element (Pos, Increment'Access);
else
Counters (Counter).Insert (Key, 1);
Nb_Counters := Nb_Counters + 1;
end if;
end Increment;
-- ------------------------------
-- Get the counters that have been collected with the date and prepare to collect
-- new counters.
-- ------------------------------
procedure Steal_Counters (Result : out Counter_Map_Array_Access;
Date : out Ada.Calendar.Time) is
begin
Result := Counters;
Date := Day;
Counters := null;
Nb_Counters := 0;
end Steal_Counters;
-- ------------------------------
-- Check if we must flush the counters.
-- ------------------------------
function Need_Flush (Limit : in Natural;
Seconds : in Duration) return Boolean is
use type Ada.Calendar.Time;
begin
if Counters = null then
return False;
elsif Nb_Counters > Limit then
return True;
else
declare
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
begin
return Now > Day_End or Now - Day >= Seconds;
end;
end if;
end Need_Flush;
-- ------------------------------
-- Get the definition ID associated with the counter.
-- ------------------------------
procedure Get_Definition (Session : in out ADO.Sessions.Master_Session;
Counter : in Counter_Index_Type;
Result : out Natural) is
begin
if Definitions = null then
Definitions := new Definition_Array_Type (1 .. Counter_Arrays.Get_Last);
Definitions.all := (others => 0);
end if;
if Definitions (Counter) = 0 then
Load_Definition (Session, Counter_Arrays.Get_Element (Counter).all,
Definitions (Counter));
end if;
Result := Definitions (Counter);
end Get_Definition;
end Counter_Table;
procedure Load_Definition (DB : in out ADO.Sessions.Master_Session;
Def : in Counter_Def;
Result : out Natural) is
Def_Db : AWA.Counters.Models.Counter_Definition_Ref;
Query : ADO.SQL.Query;
Found : Boolean;
Entity : ADO.Nullable_Entity_Type;
begin
if Def.Table = null then
Query.Set_Filter ("name = :name AND entity_type IS NULL");
else
Query.Set_Filter ("name = :name AND entity_type = :entity_type");
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "entity_type",
Table => Def.Table,
Session => DB);
end if;
Query.Bind_Param ("name", Def.Field.all);
Def_Db.Find (DB, Query, Found);
if not Found then
if Def.Table /= null then
Entity.Value := ADO.Sessions.Entities.Find_Entity_Type (DB, Def.Table);
Entity.Is_Null := False;
Def_Db.Set_Entity_Type (Entity);
end if;
Def_Db.Set_Name (Def.Field.all);
Def_Db.Save (DB);
end if;
Result := Natural (Def_Db.Get_Id);
end Load_Definition;
procedure Flush (DB : in out ADO.Sessions.Master_Session;
Counter : in Counter_Def;
Def_Id : in Natural;
Counters : in Counter_Maps.Map;
Date : in Ada.Calendar.Time) is
Query : ADO.Queries.Context;
Stmt : ADO.Statements.Query_Statement;
Update : ADO.Statements.Query_Statement;
Iter : Counter_Maps.Cursor := Counters.First;
Id : ADO.Identifier;
begin
Query.Set_Query (AWA.Counters.Models.Query_Counter_Update);
Stmt := DB.Create_Statement (Query);
if Counter.Table /= null and Counter.Field'Length > 0 then
Query.Set_Query (AWA.Counters.Models.Query_Counter_Update_Field);
Update := DB.Create_Statement (Query);
end if;
while Counter_Maps.Has_Element (Iter) loop
Id := ADO.Objects.Get_Value (Counter_Maps.Key (Iter));
Stmt.Bind_Param ("date", Date);
Stmt.Bind_Param ("id", Id);
Stmt.Bind_Param ("counter", Counter_Maps.Element (Iter));
Stmt.Bind_Param ("definition", Integer (Def_Id));
Stmt.Execute;
if Counter.Table /= null and Counter.Field'Length > 0 then
Update.Bind_Param ("id", Id);
Update.Bind_Param ("counter", Counter_Maps.Element (Iter));
Update.Bind_Param ("table", ADO.Parameters.Token (Counter.Table.Table.all));
Update.Bind_Param ("field", ADO.Parameters.Token (Counter.Field.all));
Update.Execute;
end if;
Counter_Maps.Next (Iter);
end loop;
end Flush;
-- ------------------------------
-- Flush the existing counters and update all the database records refered to them.
-- ------------------------------
procedure Flush (Plugin : in out Counter_Module) is
procedure Free is new
Ada.Unchecked_Deallocation (Object => Counter_Map_Array,
Name => Counter_Map_Array_Access);
Day : Ada.Calendar.Time;
Counters : Counter_Map_Array_Access;
begin
Plugin.Counters.Steal_Counters (Counters, Day);
if Counters = null then
return;
end if;
declare
DB : ADO.Sessions.Master_Session := Plugin.Get_Master_Session;
Date : constant Ada.Calendar.Time := Util.Dates.Get_Day_Start (Day);
Def_Id : Natural;
begin
DB.Begin_Transaction;
for I in Counters'Range loop
if not Counters (I).Is_Empty then
declare
Counter : constant Counter_Def := Counter_Arrays.Get_Element (I).all;
begin
Plugin.Counters.Get_Definition (DB, I, Def_Id);
Flush (DB, Counter, Def_Id, Counters (I), Date);
end;
end if;
end loop;
DB.Commit;
end;
Free (Counters);
end Flush;
end AWA.Counters.Modules;
|
-- Simple_Example
-- A simple example of using the Ada 2012 interface to Lua
-- Copyright (c) 2015, James Humphry - see LICENSE for terms
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Lua; use Lua;
with Lua.Util; use Lua.Util;
procedure Simple_Example is
L : Lua_State;
begin
Put_Line("A simple example of using Lua from within Ada");
Put("Lua version: ");
Put(Item => L.Version, Aft => 0, Exp => 0);
New_Line;
Put_Line("Lua state status: " & Thread_Status'Image(L.Status));
New_Line;
Put_Line("Basic stack manipulation.");
Put("Initial stack size: "); Put(L.GetTop); New_Line;
Put_Line("Pushing 3.0, 7.5, 2.3, 'Hello, World!', True, 5");
L.PushNumber(3.0);
L.PushNumber(7.5);
L.PushNumber(2.3);
L.PushString("Hello, World!");
L.PushBoolean(True);
L.PushInteger(5);
Put("Stack size now: "); Put(L.GetTop); New_Line;
Print_Stack(L);
Put("Get top element as string: "); Put(L.ToString(-1)); New_Line;
Print_Stack(L);
Put_Line("Pop top three elements");
L.Pop(3);
Print_Stack(L);
Put_Line("Is Stack(-2) <= Stack(-1)? " &
(if L.Compare(index1 => -2, index2 => -1, op => OPLE)
then "Yes"
else "No"));
Put_Line("Duplicating element at index 2. ");
L.PushValue(2);
Print_Stack(L);
Put_Line("Adding top two elements.");
L.Arith(OPADD);
Print_Stack(L);
Put_Line("Is Stack(-2) <= Stack(-1)? " &
(if L.Compare(index1 => -2, index2 => -1, op => OPLE)
then "Yes"
else "No"));
New_Line;
Put_Line("Setting global foobar to 5");
L.PushNumber(5.0);
L.SetGlobal("foobar");
L.GetGlobal("foobar");
Put("Global foobar = "); Put(L.ToNumber(-1), Aft => 0, Exp => 0); New_Line;
New_Line;
Put_Line("Manually triggering garbage collection...");
L.GC(what => GCCOLLECT);
New_Line;
Put("Checking type of main thread: ");
L.Geti(index => RegistryIndex, i => RIDX_MainThread);
Put(L.TypeName(-1));
New_Line;
end Simple_Example;
|
-- Copyright 2010-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
package body Mixed is
-- We are importing symbols from foo.o, so make sure this object file
-- gets linked in.
Pragma Linker_Options ("foo.o");
type Color is (Red, Green, Blue);
procedure C_Function;
pragma Import (C, C_Function, "c_function");
procedure Callme;
pragma Export (C, Callme, "callme");
procedure Break_Me (Light : Color) is
begin
Put_Line ("Light: " & Color'Image (Light)); -- STOP
end Break_Me;
procedure Callme is
begin
Break_Me (Red);
Break_Me (Green);
Break_Me (Blue);
end Callme;
procedure Start_Test is
begin
-- Call C_Function, which will call Callme.
C_Function;
end Start_Test;
end Mixed;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
package body Apsepp.Test_Event_Class.Generic_Timestamp_Mixin is
----------------------------------------------------------------------------
overriding
procedure Set (Obj : in out Child_W_Timestamp; Data : Test_Event_Data) is
begin
Parent (Obj).Set (Data); -- Inherited procedure call.
Obj.Date := Data.Date;
end Set;
----------------------------------------------------------------------------
overriding
function Timestamp (Obj : Child_W_Timestamp) return Time
is (Obj.Date);
----------------------------------------------------------------------------
overriding
procedure Set_Timestamp (Obj : in out Child_W_Timestamp;
Date : Time := Clock) is
begin
Obj.Date := Date;
end Set_Timestamp;
----------------------------------------------------------------------------
end Apsepp.Test_Event_Class.Generic_Timestamp_Mixin;
|
[VERSION] 2.0
[COSIMULATION] False
[INTERPOLATION] True
[SOLVERTYPE] Transient
[DESCRIPTION]
[NUMBEROFPORTS] 0
[PARAMETERS] 0
|
-----------------------------------------------------------------------
-- ado-configs -- Database connection configuration
-- Copyright (C) 2010, 2011, 2012, 2016, 2017, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with Util.Properties;
package ADO.Configs is
-- Configuration property to control the search paths to load XML queries.
QUERY_PATHS_CONFIG : constant String := "ado.queries.paths";
-- Configuration property to control whether all the program XML queries must be
-- loaded when the database configuration is setup.
QUERY_LOAD_CONFIG : constant String := "ado.queries.load";
-- Configuration property to enable or disable the dynamic load of database driver.
DYNAMIC_DRIVER_LOAD : constant String := "ado.drivers.load";
-- Configuration property to skip reading the database table entities.
NO_ENTITY_LOAD : constant String := "ado.entities.ignore";
-- Maximum number of columns allowed for a table (SQLite limit is 2000).
MAX_COLUMNS : constant := 2000;
-- Maximum number of database drivers (MySQL, PostgreSQL, SQLite, X).
MAX_DRIVERS : constant := 4;
-- Raised when the connection URI is invalid.
Connection_Error : exception;
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
procedure Initialize (Config : in String);
-- Initialize the drivers and the library and configure the runtime with the given properties.
procedure Initialize (Config : in Util.Properties.Manager'Class);
-- Get the global configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
function Get_Config (Name : in String;
Default : in String := "") return String;
-- Returns true if the global configuration property is set to true/on.
function Is_On (Name : in String) return Boolean;
-- ------------------------------
-- The database configuration properties
-- ------------------------------
type Configuration is new Ada.Finalization.Controlled with private;
type Configuration_Access is access all Configuration'Class;
-- Set the connection URL to connect to the database.
-- The driver connection is a string of the form:
--
-- driver://[host][:port]/[database][?property1][=value1]...
--
-- If the string is invalid or if the driver cannot be found,
-- the Connection_Error exception is raised.
procedure Set_Connection (Config : in out Configuration;
URI : in String);
-- Get the connection URI that describes the database connection string.
-- The returned string may contain connection authentication information.
function Get_URI (Config : in Configuration) return String;
-- Get the connection URI that describes the database connection string
-- but the connection authentication is replaced by XXXX.
function Get_Log_URI (Config : in Configuration) return String;
-- Set a property on the datasource for the driver.
-- The driver can retrieve the property to configure and open
-- the database connection.
procedure Set_Property (Config : in out Configuration;
Name : in String;
Value : in String);
-- Get a property from the data source configuration.
-- If the property does not exist, an empty string is returned.
function Get_Property (Config : in Configuration;
Name : in String) return String;
-- Returns true if the configuration property is set to true/on.
function Is_On (Config : in Configuration;
Name : in String) return Boolean;
-- Set the server hostname.
procedure Set_Server (Config : in out Configuration;
Server : in String);
-- Get the server hostname.
function Get_Server (Config : in Configuration) return String;
-- Set the server port.
procedure Set_Port (Config : in out Configuration;
Port : in Natural);
-- Get the server port.
function Get_Port (Config : in Configuration) return Natural;
-- Set the database name.
procedure Set_Database (Config : in out Configuration;
Database : in String);
-- Get the database name.
function Get_Database (Config : in Configuration) return String;
-- Get the database driver name.
function Get_Driver (Config : in Configuration) return String;
-- Iterate over the configuration properties and execute the given procedure passing the
-- property name and its value.
procedure Iterate (Config : in Configuration;
Process : access procedure (Name : in String;
Item : in Util.Properties.Value));
type Driver_Index is new Natural range 0 .. MAX_DRIVERS;
private
use Ada.Strings.Unbounded;
type Configuration is new Ada.Finalization.Controlled with record
URI : Unbounded_String;
Log_URI : Unbounded_String;
Driver : Unbounded_String;
Server : Unbounded_String;
Port : Natural := 0;
Database : Unbounded_String;
Properties : Util.Properties.Manager;
end record;
end ADO.Configs;
|
-- This file is generated by SWIG. Do *not* modify by hand.
--
with llvm;
with Interfaces.C.Strings;
package LLVM_bit_Writer.Binding is
function LLVMWriteBitcodeToFileHandle
(M : in llvm.LLVMModuleRef;
Handle : in Interfaces.C.int)
return Interfaces.C.int;
function LLVMWriteBitcodeToFile
(M : in llvm.LLVMModuleRef;
Path : in Interfaces.C.Strings.chars_ptr)
return Interfaces.C.int;
private
pragma Import
(C,
LLVMWriteBitcodeToFileHandle,
"Ada_LLVMWriteBitcodeToFileHandle");
pragma Import (C, LLVMWriteBitcodeToFile, "Ada_LLVMWriteBitcodeToFile");
end LLVM_bit_Writer.Binding;
|
-- CC1104C.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.
--*
-- OBJECTIVE;
-- CHECK THAT A GENERIC FORMAL IN OUT PARAMETER CAN HAVE A
-- LIMITED TYPE.
-- HISTORY:
-- BCB 08/03/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE CC1104C IS
TASK TYPE TSK IS
ENTRY E;
END TSK;
VAR : INTEGER := IDENT_INT(0);
NEW_VAL : INTEGER := IDENT_INT(5);
TSK_VAR : TSK;
PACKAGE PP IS
TYPE LP IS LIMITED PRIVATE;
PROCEDURE INIT (ONE : OUT LP; TWO : INTEGER);
FUNCTION EQUAL (ONE : LP; TWO : INTEGER) RETURN BOOLEAN;
PRIVATE
TYPE LP IS RANGE 1 .. 100;
END PP;
USE PP;
TYPE REC IS RECORD
COMP : LP;
END RECORD;
C : LP;
REC_VAR : REC;
GENERIC
TYPE T IS LIMITED PRIVATE;
IN_OUT_VAR : IN OUT T;
IN_OUT_TSK : IN OUT TSK;
VAL : IN OUT T;
WITH PROCEDURE INIT (L : IN OUT T; R : T);
PROCEDURE P;
GENERIC
VAL : IN OUT LP;
PROCEDURE Q;
GENERIC
VAL : IN OUT REC;
PROCEDURE R;
PACKAGE BODY PP IS
PROCEDURE INIT(ONE : OUT LP; TWO : INTEGER) IS
BEGIN
ONE := LP(TWO);
END INIT;
FUNCTION EQUAL(ONE : LP; TWO : INTEGER) RETURN BOOLEAN IS
BEGIN
RETURN ONE = LP(TWO);
END EQUAL;
END PP;
TASK BODY TSK IS
BEGIN
ACCEPT E;
END TSK;
PROCEDURE P IS
BEGIN
INIT(IN_OUT_VAR,VAL);
IN_OUT_TSK.E;
INIT(C,50);
END P;
PROCEDURE Q IS
BEGIN
INIT(VAL,75);
INIT(REC_VAR.COMP,50);
END Q;
PROCEDURE R IS
BEGIN
INIT(VAL.COMP,75);
END R;
PROCEDURE I (ONE : IN OUT INTEGER; TWO : INTEGER) IS
BEGIN
ONE := TWO;
END I;
PROCEDURE NEW_P IS NEW P(INTEGER,VAR,TSK_VAR,NEW_VAL,I);
PROCEDURE NEW_Q IS NEW Q(C);
PROCEDURE NEW_R IS NEW R(REC_VAR);
BEGIN
TEST ("CC1104C", "CHECK THAT A GENERIC FORMAL IN OUT PARAMETER " &
"CAN HAVE A LIMITED TYPE");
NEW_P;
IF NOT EQUAL(VAR,5) THEN
FAILED ("WRONG VALUE ASSIGNED TO IN OUT PARAMETER IN " &
"GENERIC PACKAGE - 1");
END IF;
NEW_Q;
IF NOT EQUAL(C,75) THEN
FAILED ("WRONG VALUE ASSIGNED TO IN OUT PARAMETER IN " &
"GENERIC PACKAGE - 2");
END IF;
NEW_R;
IF NOT EQUAL(REC_VAR.COMP,75) THEN
FAILED ("WRONG VALUE ASSIGNED TO IN OUT PARAMETER IN " &
"GENERIC PACKAGE - 3");
END IF;
RESULT;
END CC1104C;
|
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with LSC.Internal.Types, LSC.Internal.IO;
with Ada.Unchecked_Conversion;
use type LSC.Internal.Types.Word64;
use type LSC.Internal.Types.Word32;
use type LSC.Internal.Types.Byte;
package body LSC.Internal.IO
with SPARK_Mode => Off
is
subtype Nibble is Natural range 0 .. 15;
----------------------------------------------------------------------------
procedure Put (T : String)
is
procedure Gnat_IO_Put (T : String)
with Import, External_Name => "gnat__io__put__6";
begin
Gnat_IO_Put (T);
end Put;
procedure Put (I : Integer);
procedure Put (I : Integer)
is
procedure Gnat_IO_Put (I : Integer)
with Import, External_Name => "gnat__io__put__2";
begin
Gnat_IO_Put (I);
end Put;
procedure Get (T : out Character);
procedure Get (T : out Character)
is
procedure Gnat_IO_Get (T : out Character)
with Import, External_Name => "gnat__io__get__2";
begin
Gnat_IO_Get (T);
end Get;
procedure Put_Line (T : String)
is
procedure Gnat_IO_Put_Line (T : String)
with Import, External_Name => "gnat__io__put_line__2";
begin
Gnat_IO_Put_Line (T);
end Put_Line;
procedure New_Line
is
procedure Gnat_IO_New_Line (Spacing : Positive := 1)
with Import, External_Name => "gnat__io__new_line__2";
begin
Gnat_IO_New_Line;
end New_Line;
----------------------------------------------------------------------------
function Read_Byte return Types.Byte
is
Result : Character;
function To_Byte is new Ada.Unchecked_Conversion (Character, Types.Byte);
begin
IO.Get (Result);
return To_Byte (Result);
end Read_Byte;
----------------------------------------------------------------------------
function End_Of_Stream return Boolean
is
begin
return False;
end End_Of_Stream;
----------------------------------------------------------------------------
function Num_To_Char (N : Nibble) return Character;
function Num_To_Char (N : Nibble) return Character
is
Digit : Character;
begin
case N is
when 16#0# =>
Digit := '0';
when 16#1# =>
Digit := '1';
when 16#2# =>
Digit := '2';
when 16#3# =>
Digit := '3';
when 16#4# =>
Digit := '4';
when 16#5# =>
Digit := '5';
when 16#6# =>
Digit := '6';
when 16#7# =>
Digit := '7';
when 16#8# =>
Digit := '8';
when 16#9# =>
Digit := '9';
when 16#A# =>
Digit := 'a';
when 16#B# =>
Digit := 'b';
when 16#C# =>
Digit := 'c';
when 16#D# =>
Digit := 'd';
when 16#E# =>
Digit := 'e';
when 16#F# =>
Digit := 'f';
end case;
return Digit;
end Num_To_Char;
----------------------------------------------------------------------------
procedure Print_Byte (Item : in Types.Byte)
is
begin
IO.Put (Num_To_Char (Nibble (Item / 16)) & Num_To_Char (Nibble (Item rem 16)));
end Print_Byte;
----------------------------------------------------------------------------
procedure Print_Word32 (Item : in Types.Word32)
is
subtype HD_Index is Positive range 1 .. 8;
subtype HD_Type is String (HD_Index);
Result : HD_Type;
Number : Types.Word32;
begin
Number := Item;
Result := HD_Type'(others => 'X');
for Index in HD_Index
loop
Result ((HD_Index'Last - Index) + 1) := Num_To_Char (Nibble (Number mod 16));
Number := Number / 16;
end loop;
IO.Put (Result);
end Print_Word32;
----------------------------------------------------------------------------
procedure Print_Word64 (Item : in Types.Word64)
is
subtype HD_Index is Positive range 1 .. 16;
subtype HD_Type is String (HD_Index);
Result : HD_Type;
Number : Types.Word64;
begin
Number := Item;
Result := HD_Type'(others => 'X');
for Index in HD_Index
loop
Result ((HD_Index'Last - Index) + 1) := Num_To_Char (Nibble (Number mod 16));
Number := Number / 16;
end loop;
IO.Put (Result);
end Print_Word64;
----------------------------------------------------------------------------
procedure Print_Index (I : in Types.Index)
is
begin
IO.Put (Integer (I));
end Print_Index;
----------------------------------------------------------------------------
procedure Print_Natural (I : Natural)
is
begin
IO.Put (Integer (I));
end Print_Natural;
----------------------------------------------------------------------------
procedure Print_Word32_Array (Block : in Types.Word32_Array_Type;
Space : in Natural;
Break : in Types.Index;
Newln : in Boolean)
is
begin
for I in Types.Index range Block'First .. Block'Last
loop
Print_Word32 (Block (I));
-- space separate values
for S in 1 .. Space
loop
IO.Put (" ");
end loop;
-- intermediate new line
if I mod Break = Break - 1 then
IO.New_Line;
end if;
end loop;
-- final new line
if Newln then
IO.New_Line;
end if;
end Print_Word32_Array;
----------------------------------------------------------------------------
procedure Print_Word64_Array (Block : in Types.Word64_Array_Type;
Space : in Natural;
Break : in Types.Index;
Newln : in Boolean)
is
begin
for I in Types.Index range Block'First .. Block'Last
loop
Print_Word64 (Block (I));
-- space separate values
for S in 1 .. Space
loop
IO.Put (" ");
end loop;
-- intermediate new line
if I mod Break = Break - 1 then
IO.New_Line;
end if;
end loop;
-- final new line
if Newln then
IO.New_Line;
end if;
end Print_Word64_Array;
end LSC.Internal.IO;
|
-- { dg-do compile }
-- { dg-options "-gnat12 -gnatct" }
with Ada.Containers.Vectors;
with Limited_With4_Pkg;
package Limited_With4 is
type Object is tagged private;
type Object_Ref is access all Object;
type Class_Ref is access all Object'Class;
package Vec is new Ada.Containers.Vectors
(Positive, Limited_With4_Pkg.Object_Ref,Limited_With4_Pkg ."=");
subtype Vector is Vec.Vector;
private
type Object is tagged record
V : Vector;
end record;
end Limited_With4;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Greet is
begin
-- Print "Hello, World!" to the screen
Put_line ("Hello, World!");
Ada.Text_IO.Put_line ("Hello, world (two)!");
end Greet; |
function Median (Picture : Image; Radius : Positive) return Image is
type Extended_Luminance is range 0..10_000_000;
type VRGB is record
Color : Pixel;
Value : Luminance;
end record;
Width : constant Positive := 2*Radius*(Radius+1);
type Window is array (-Width..Width) of VRGB;
Sorted : Window;
Next : Integer;
procedure Put (Color : Pixel) is -- Sort using binary search
pragma Inline (Put);
This : constant Luminance :=
Luminance
( ( 2_126 * Extended_Luminance (Color.R)
+ 7_152 * Extended_Luminance (Color.G)
+ 722 * Extended_Luminance (Color.B)
)
/ 10_000
);
That : Luminance;
Low : Integer := Window'First;
High : Integer := Next - 1;
Middle : Integer := (Low + High) / 2;
begin
while Low <= High loop
That := Sorted (Middle).Value;
if That > This then
High := Middle - 1;
elsif That < This then
Low := Middle + 1;
else
exit;
end if;
Middle := (Low + High) / 2;
end loop;
Sorted (Middle + 1..Next) := Sorted (Middle..Next - 1);
Sorted (Middle) := (Color, This);
Next := Next + 1;
end Put;
Result : Image (Picture'Range (1), Picture'Range (2));
begin
for I in Picture'Range (1) loop
for J in Picture'Range (2) loop
Next := Window'First;
for X in I - Radius .. I + Radius loop
for Y in J - Radius .. J + Radius loop
Put
( Picture
( Integer'Min (Picture'Last (1), Integer'Max (Picture'First (1), X)),
Integer'Min (Picture'Last (2), Integer'Max (Picture'First (2), Y))
) );
end loop;
end loop;
Result (I, J) := Sorted (0).Color;
end loop;
end loop;
return Result;
end Median;
|
-- As prototyped in the Generic_Real_Arrays specification:
-- function Unit_Matrix (Order : Positive; First_1, First_2 : Integer := 1) return Real_Matrix;
-- For the task:
mat : Real_Matrix := Unit_Matrix(5);
|
-- @TODO: do we need to create a seperate spec file which imports these as stated here:
-- https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gnat_ugn_unw/Creating-a-Spec-for-Ada-DLLs.html#Creating-a-Spec-for-Ada-DLLs
package my_lib is
procedure Do_Stuff;
-- procedure Initialize_API;
-- procedure Finalize_API;
-- This should be unncessary for Ada-Ada dynamic loading
-- Eff it, do it anyways
private
pragma Export(C, Do_Stuff);
-- pragma Export(C, Initialize_API);
-- pragma Export(C, Finalize_API);
end my_lib; |
with Rejuvenation.Node_Locations; use Rejuvenation.Node_Locations;
package Rejuvenation.Utils is
-- Raw signature --------
function Raw_Signature
(Node : Ada_Node'Class;
Before : Node_Location := No_Trivia;
After : Node_Location := No_Trivia)
return String;
-- Return the original text for the node, using the charset of the
-- corresponding analysis unit.
function Raw_Signature
(Token : Token_Reference; Charset : String) return String;
-- Return the original text for the token, using the given charset.
function Raw_Signature
(First_Node, Last_Node : Ada_Node'Class;
Before, After : Node_Location := No_Trivia)
return String;
-- Return the original text for the first node until the last node,
-- using the charset of the corresponding analysis unit.
function Are_Equal_As_Raw_Signature
(Node1, Node2 : Ada_Node'Class) return Boolean;
-- Return whether two AST nodes have the same original text.
function Are_Equal_Case_Insensitive_As_Raw_Signature
(Node1, Node2 : Ada_Node'Class) return Boolean;
-- Return whether two AST nodes have the same original text
-- when ignoring casing.
-- Package (Distributed over files) functionality
function In_Same_Package (Unit1, Unit2 : Analysis_Unit) return Boolean;
-- Two analysis units are in the same package X
-- when their files names (excluding the extension) are the same.
-- For example, the analysis units with file names 'X.adb' and 'X.ads'
-- are in the same package 'X'.
-- Image --------
function Image (Node_List_Vector : Node_List.Vector) return String;
-- Return the Image of each node.
-- Get tokens --------
function Get_Trivia_Before
(Node : Ada_Node'Class) return Token_List.Vector;
-- Return the trivia (whitespace, comments) tokens
-- in front of the AST node.
function Get_Trivia_Before
(Token : Token_Reference) return Token_List.Vector;
-- Return the trivia (whitespace, comments) tokens
-- in front of the token.
function Get_Trivia_After
(Node : Ada_Node'Class) return Token_List.Vector;
-- Return the trivia (whitespace, comments) tokens
-- after the AST node.
function Get_Trivia_After
(Token : Token_Reference) return Token_List.Vector;
-- Return the trivia (whitespace, comments) tokens
-- after the token.
function Get_Tokens (Node : Ada_Node'Class) return Token_List.Vector;
-- Return the tokens that form the AST node.
end Rejuvenation.Utils;
|
------------------------------------------------------------------------------
-- Copyright (c) 2013-2019, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.S_Expressions.Generic_Caches provides a simple memory container --
-- for S-expressions. The container is append-only, and provides cursors to --
-- replay it from start. --
-- This is a generic package that allow client-selected storage pools. An --
-- instance with default storage pools is provided in --
-- Natools.S_Expressions.Caches. --
-- The intended usage is efficient caching of S-expressions in memory. For --
-- more flexible in-memory S-expression objects, --
-- see Natools.S_Expressions.Holders. --
------------------------------------------------------------------------------
with System.Storage_Pools;
with Natools.S_Expressions.Lockable;
with Natools.S_Expressions.Printers;
with Natools.S_Expressions.Replayable;
private with Ada.Finalization;
private with Ada.Unchecked_Deallocation;
private with Natools.References;
generic
Atom_Pool : in out System.Storage_Pools.Root_Storage_Pool'Class;
Counter_Pool : in out System.Storage_Pools.Root_Storage_Pool'Class;
Structure_Pool : in out System.Storage_Pools.Root_Storage_Pool'Class;
package Natools.S_Expressions.Generic_Caches is
pragma Preelaborate (Generic_Caches);
type Reference is new Printers.Printer with private;
pragma Preelaborable_Initialization (Reference);
overriding procedure Open_List (Output : in out Reference);
overriding procedure Append_Atom
(Output : in out Reference; Data : in Atom);
overriding procedure Close_List (Output : in out Reference);
function Duplicate (Cache : Reference) return Reference;
-- Create a new copy of the S-expression held in Cache and return it
function Move (Source : in out S_Expressions.Descriptor'Class)
return Reference;
-- Build a new cache by (destructively) reading Original
type Cursor is new Lockable.Descriptor and Replayable.Descriptor
with private;
pragma Preelaborable_Initialization (Cursor);
overriding function Current_Event (Object : in Cursor) return Events.Event;
overriding function Current_Atom (Object : in Cursor) return Atom;
overriding function Current_Level (Object : in Cursor) return Natural;
overriding procedure Query_Atom
(Object : in Cursor;
Process : not null access procedure (Data : in Atom));
overriding procedure Read_Atom
(Object : in Cursor;
Data : out Atom;
Length : out Count);
overriding procedure Next
(Object : in out Cursor;
Event : out Events.Event);
overriding procedure Lock
(Object : in out Cursor;
State : out Lockable.Lock_State);
overriding procedure Unlock
(Object : in out Cursor;
State : in out Lockable.Lock_State;
Finish : in Boolean := True);
overriding function Duplicate (Object : Cursor) return Cursor;
function First (Cache : Reference'Class) return Cursor;
-- Create a new Cursor pointing at the beginning of Cache
function Move (Source : in out S_Expressions.Descriptor'Class) return Cursor
is (Move (Source).First);
-- Return a cursor holding a copy of Original (which is
-- destructively read)
function Conditional_Move
(Source : in out S_Expressions.Descriptor'Class)
return Cursor
is (if Source in Cursor then Cursor (Source) else Move (Source).First);
-- Return a copy of Source, with cheap copy if possible,
-- otherwise with destructive Move
private
type Atom_Access is access Atom;
for Atom_Access'Storage_Pool use Atom_Pool;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Atom, Atom_Access);
type Node;
type Node_Access is access Node;
for Node_Access'Storage_Pool use Structure_Pool;
type Node_Kind is (Atom_Node, List_Node);
type Node (Kind : Node_Kind) is record
Parent : Node_Access;
Next : Node_Access;
case Kind is
when Atom_Node => Data : Atom_Access;
when List_Node => Child : Node_Access;
end case;
end record;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Node, Node_Access);
type Tree is new Ada.Finalization.Limited_Controlled with record
Root : Node_Access := null;
Last : Node_Access := null;
Opening : Boolean := False;
end record;
procedure Append
(Exp : in out Tree;
Kind : in Node_Kind;
Data : in Atom_Access := null);
-- Append a new node of the given Kind to Exp
procedure Close_List (Exp : in out Tree);
-- Close innermost list
function Create_Tree return Tree;
-- Create a new empty Tree
function Duplicate (Source : Tree) return Tree;
-- Deep copy of a Tree object
overriding procedure Finalize (Object : in out Tree);
-- Release all nodes contained in Object
package Trees is new References (Tree, Structure_Pool, Counter_Pool);
type Reference is new Printers.Printer with record
Exp : Trees.Reference;
end record;
type Cursor is new Lockable.Descriptor and Replayable.Descriptor with record
Exp : Trees.Reference;
Position : Node_Access := null;
Opening : Boolean := False;
Stack : Lockable.Lock_Stack;
Locked : Boolean := False;
end record;
function Absolute_Level (Object : Cursor) return Natural;
end Natools.S_Expressions.Generic_Caches;
|
with logger;
use logger;
package body text_file is
procedure write_string_to_file(file_path, content : string) is
file : file_type;
begin
begin
debug("Ouverture du fichier " & file_path);
-- Ouverture du fichier
open(file, out_file, file_path);
exception
-- si le fichier n'existe pas
when name_error =>
debug("Fichier inexistant ou erreur. Création");
-- creation du fichier
create(file, out_file, file_path);
debug("Fichier crée");
end;
-- écriture de la chaîne dans le fichier
put(file, content);
-- fermeture du fichier
close(file);
debug("Fichier écrit et fermé");
end;
procedure read_file_to_string(file_path : string; content : out unbounded_string) is
file : file_type;
begin
content := to_unbounded_string("");
debug("Ouverture du fichier " & file_path);
-- Ouverture du fichier
open(file, in_file, file_path);
while not end_of_file(file) loop
declare
line : constant string := get_line(file);
begin
append(content, line);
end;
end loop;
-- fermeture du fichier
close(file);
debug("Fichier écrit et fermé");
end;
procedure read_file_to_string(file_handle : in out file_type; content : out unbounded_string) is
begin
reset(file_handle, in_file);
content := to_unbounded_string("");
while not end_of_file(file_handle) loop
declare
line : constant string := get_line(file_handle);
begin
append(content, line);
end;
end loop;
end;
end text_file;
|
------------------------------------------------------------------------------
-- --
-- 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.Standard_Profile_L2_Metamodel;
with AMF.Internals.Tables.UML_Constructors;
package body AMF.Internals.Factories.Standard_Profile_L2_Factories is
-----------------
-- Constructor --
-----------------
function Constructor
(Extent : AMF.Internals.AMF_Extent)
return not null AMF.Factories.Factory_Access is
begin
return new Standard_Profile_L2_Factory'(Extent => Extent);
end Constructor;
-----------------------
-- Convert_To_String --
-----------------------
overriding function Convert_To_String
(Self : not null access Standard_Profile_L2_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Value : League.Holders.Holder) return League.Strings.Universal_String is
begin
raise Program_Error;
return League.Strings.Empty_Universal_String;
end Convert_To_String;
------------
-- Create --
------------
overriding function Create
(Self : not null access Standard_Profile_L2_Factory;
Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class)
return not null AMF.Elements.Element_Access
is
MC : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Meta_Class.all).Element;
Element : AMF.Internals.AMF_Element;
begin
if MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Auxiliary then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Auxiliary;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Call then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Call;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Create then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Create;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Derive then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Derive;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Destroy then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Destroy;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Document then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Document;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Entity then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Entity;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Executable then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Executable;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Focus then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Focus;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Framework then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Framework;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Implement then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Implement;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Implementation_Class then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Implementation_Class;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Instantiate then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Instantiate;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Library then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Library;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Metaclass then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Metaclass;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Model_Library then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Model_Library;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Process then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Process;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Realization then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Realization;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Refine then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Refine;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Responsibility then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Responsibility;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Script then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Script;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Send then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Send;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Service then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Service;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Source then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Source;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Specification then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Specification;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Subsystem then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Subsystem;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Trace then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Trace;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Type then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Type;
elsif MC = AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Utility then
Element := AMF.Internals.Tables.UML_Constructors.Create_Standard_Profile_L2_Utility;
else
raise Program_Error;
end if;
AMF.Internals.Extents.Internal_Append (Self.Extent, Element);
AMF.Internals.Listener_Registry.Notify_Instance_Create
(AMF.Internals.Helpers.To_Element (Element));
return AMF.Internals.Helpers.To_Element (Element);
end Create;
------------------------
-- Create_From_String --
------------------------
overriding function Create_From_String
(Self : not null access Standard_Profile_L2_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Image : League.Strings.Universal_String) return League.Holders.Holder is
begin
raise Program_Error;
return League.Holders.Empty_Holder;
end Create_From_String;
-----------------
-- Create_Link --
-----------------
overriding function Create_Link
(Self : not null access Standard_Profile_L2_Factory;
Association :
not null access AMF.CMOF.Associations.CMOF_Association'Class;
First_Element : not null AMF.Elements.Element_Access;
Second_Element : not null AMF.Elements.Element_Access)
return not null AMF.Links.Link_Access
is
pragma Unreferenced (Self);
begin
return
AMF.Internals.Links.Proxy
(AMF.Internals.Links.Create_Link
(AMF.Internals.Elements.Element_Base'Class
(Association.all).Element,
AMF.Internals.Helpers.To_Element (First_Element),
AMF.Internals.Helpers.To_Element (Second_Element)));
end Create_Link;
-----------------
-- Get_Package --
-----------------
overriding function Get_Package
(Self : not null access constant Standard_Profile_L2_Factory)
return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package
is
pragma Unreferenced (Self);
begin
return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do
Result.Add (Get_Package);
end return;
end Get_Package;
-----------------
-- Get_Package --
-----------------
function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is
begin
return
AMF.CMOF.Packages.CMOF_Package_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MM_Standard_Profile_L2_Standard_Profile_L2));
end Get_Package;
----------------------
-- Create_Auxiliary --
----------------------
overriding function Create_Auxiliary
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Auxiliaries.Standard_Profile_L2_Auxiliary_Access is
begin
return
AMF.Standard_Profile_L2.Auxiliaries.Standard_Profile_L2_Auxiliary_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Auxiliary))));
end Create_Auxiliary;
-----------------
-- Create_Call --
-----------------
overriding function Create_Call
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Calls.Standard_Profile_L2_Call_Access is
begin
return
AMF.Standard_Profile_L2.Calls.Standard_Profile_L2_Call_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Call))));
end Create_Call;
-------------------
-- Create_Create --
-------------------
overriding function Create_Create
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Creates.Standard_Profile_L2_Create_Access is
begin
return
AMF.Standard_Profile_L2.Creates.Standard_Profile_L2_Create_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Create))));
end Create_Create;
-------------------
-- Create_Derive --
-------------------
overriding function Create_Derive
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Derives.Standard_Profile_L2_Derive_Access is
begin
return
AMF.Standard_Profile_L2.Derives.Standard_Profile_L2_Derive_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Derive))));
end Create_Derive;
--------------------
-- Create_Destroy --
--------------------
overriding function Create_Destroy
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Destroies.Standard_Profile_L2_Destroy_Access is
begin
return
AMF.Standard_Profile_L2.Destroies.Standard_Profile_L2_Destroy_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Destroy))));
end Create_Destroy;
---------------------
-- Create_Document --
---------------------
overriding function Create_Document
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Documents.Standard_Profile_L2_Document_Access is
begin
return
AMF.Standard_Profile_L2.Documents.Standard_Profile_L2_Document_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Document))));
end Create_Document;
-------------------
-- Create_Entity --
-------------------
overriding function Create_Entity
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Entities.Standard_Profile_L2_Entity_Access is
begin
return
AMF.Standard_Profile_L2.Entities.Standard_Profile_L2_Entity_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Entity))));
end Create_Entity;
-----------------------
-- Create_Executable --
-----------------------
overriding function Create_Executable
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Executables.Standard_Profile_L2_Executable_Access is
begin
return
AMF.Standard_Profile_L2.Executables.Standard_Profile_L2_Executable_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Executable))));
end Create_Executable;
------------------
-- Create_Focus --
------------------
overriding function Create_Focus
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Focuses.Standard_Profile_L2_Focus_Access is
begin
return
AMF.Standard_Profile_L2.Focuses.Standard_Profile_L2_Focus_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Focus))));
end Create_Focus;
----------------------
-- Create_Framework --
----------------------
overriding function Create_Framework
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Frameworks.Standard_Profile_L2_Framework_Access is
begin
return
AMF.Standard_Profile_L2.Frameworks.Standard_Profile_L2_Framework_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Framework))));
end Create_Framework;
----------------------
-- Create_Implement --
----------------------
overriding function Create_Implement
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Implements.Standard_Profile_L2_Implement_Access is
begin
return
AMF.Standard_Profile_L2.Implements.Standard_Profile_L2_Implement_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Implement))));
end Create_Implement;
---------------------------------
-- Create_Implementation_Class --
---------------------------------
overriding function Create_Implementation_Class
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Implementation_Classes.Standard_Profile_L2_Implementation_Class_Access is
begin
return
AMF.Standard_Profile_L2.Implementation_Classes.Standard_Profile_L2_Implementation_Class_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Implementation_Class))));
end Create_Implementation_Class;
------------------------
-- Create_Instantiate --
------------------------
overriding function Create_Instantiate
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Instantiates.Standard_Profile_L2_Instantiate_Access is
begin
return
AMF.Standard_Profile_L2.Instantiates.Standard_Profile_L2_Instantiate_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Instantiate))));
end Create_Instantiate;
--------------------
-- Create_Library --
--------------------
overriding function Create_Library
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Libraries.Standard_Profile_L2_Library_Access is
begin
return
AMF.Standard_Profile_L2.Libraries.Standard_Profile_L2_Library_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Library))));
end Create_Library;
----------------------
-- Create_Metaclass --
----------------------
overriding function Create_Metaclass
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Metaclasses.Standard_Profile_L2_Metaclass_Access is
begin
return
AMF.Standard_Profile_L2.Metaclasses.Standard_Profile_L2_Metaclass_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Metaclass))));
end Create_Metaclass;
--------------------------
-- Create_Model_Library --
--------------------------
overriding function Create_Model_Library
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Model_Libraries.Standard_Profile_L2_Model_Library_Access is
begin
return
AMF.Standard_Profile_L2.Model_Libraries.Standard_Profile_L2_Model_Library_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Model_Library))));
end Create_Model_Library;
--------------------
-- Create_Process --
--------------------
overriding function Create_Process
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Processes.Standard_Profile_L2_Process_Access is
begin
return
AMF.Standard_Profile_L2.Processes.Standard_Profile_L2_Process_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Process))));
end Create_Process;
------------------------
-- Create_Realization --
------------------------
overriding function Create_Realization
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Realizations.Standard_Profile_L2_Realization_Access is
begin
return
AMF.Standard_Profile_L2.Realizations.Standard_Profile_L2_Realization_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Realization))));
end Create_Realization;
-------------------
-- Create_Refine --
-------------------
overriding function Create_Refine
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Refines.Standard_Profile_L2_Refine_Access is
begin
return
AMF.Standard_Profile_L2.Refines.Standard_Profile_L2_Refine_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Refine))));
end Create_Refine;
---------------------------
-- Create_Responsibility --
---------------------------
overriding function Create_Responsibility
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Responsibilities.Standard_Profile_L2_Responsibility_Access is
begin
return
AMF.Standard_Profile_L2.Responsibilities.Standard_Profile_L2_Responsibility_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Responsibility))));
end Create_Responsibility;
-------------------
-- Create_Script --
-------------------
overriding function Create_Script
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Scripts.Standard_Profile_L2_Script_Access is
begin
return
AMF.Standard_Profile_L2.Scripts.Standard_Profile_L2_Script_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Script))));
end Create_Script;
-----------------
-- Create_Send --
-----------------
overriding function Create_Send
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Sends.Standard_Profile_L2_Send_Access is
begin
return
AMF.Standard_Profile_L2.Sends.Standard_Profile_L2_Send_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Send))));
end Create_Send;
--------------------
-- Create_Service --
--------------------
overriding function Create_Service
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Services.Standard_Profile_L2_Service_Access is
begin
return
AMF.Standard_Profile_L2.Services.Standard_Profile_L2_Service_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Service))));
end Create_Service;
-------------------
-- Create_Source --
-------------------
overriding function Create_Source
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Sources.Standard_Profile_L2_Source_Access is
begin
return
AMF.Standard_Profile_L2.Sources.Standard_Profile_L2_Source_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Source))));
end Create_Source;
--------------------------
-- Create_Specification --
--------------------------
overriding function Create_Specification
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Specifications.Standard_Profile_L2_Specification_Access is
begin
return
AMF.Standard_Profile_L2.Specifications.Standard_Profile_L2_Specification_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Specification))));
end Create_Specification;
----------------------
-- Create_Subsystem --
----------------------
overriding function Create_Subsystem
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Subsystems.Standard_Profile_L2_Subsystem_Access is
begin
return
AMF.Standard_Profile_L2.Subsystems.Standard_Profile_L2_Subsystem_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Subsystem))));
end Create_Subsystem;
------------------
-- Create_Trace --
------------------
overriding function Create_Trace
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Traces.Standard_Profile_L2_Trace_Access is
begin
return
AMF.Standard_Profile_L2.Traces.Standard_Profile_L2_Trace_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Trace))));
end Create_Trace;
-----------------
-- Create_Type --
-----------------
overriding function Create_Type
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Types.Standard_Profile_L2_Type_Access is
begin
return
AMF.Standard_Profile_L2.Types.Standard_Profile_L2_Type_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Type))));
end Create_Type;
--------------------
-- Create_Utility --
--------------------
overriding function Create_Utility
(Self : not null access Standard_Profile_L2_Factory)
return AMF.Standard_Profile_L2.Utilities.Standard_Profile_L2_Utility_Access is
begin
return
AMF.Standard_Profile_L2.Utilities.Standard_Profile_L2_Utility_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.Standard_Profile_L2_Metamodel.MC_Standard_Profile_L2_Utility))));
end Create_Utility;
end AMF.Internals.Factories.Standard_Profile_L2_Factories;
|
-- { dg-do run }
with Pack18_Pkg; use Pack18_Pkg;
procedure Pack18 is
use Pack18_Pkg.Attributes_Tables;
Table : Instance;
begin
Init (Table);
Set_Last (Table, 1);
Table.Table (Last (Table)).N := 0;
end;
|
with Big_Integers; use Big_Integers;
package Types with
SPARK_Mode
is
-- Index types used in implementations
type Extended_Index_Type is range - 1 .. 18;
subtype Product_Index_Type is Extended_Index_Type range 0 .. 18;
subtype Index_Type is Extended_Index_Type range 0 .. 9;
-- Array types used in implementations
type Integer_Curve25519 is array (Product_Index_Type range <>) of Long_Long_Integer
with Dynamic_Predicate => Integer_Curve25519'First = 0;
subtype Product_Integer is Integer_Curve25519 (Product_Index_Type);
-- Integer_255 are arrays of 32 bits integers
subtype Integer_255 is Integer_Curve25519 (Index_Type) with
Dynamic_Predicate => (for all J of Integer_255 => J in -2**31 .. 2**31 - 1);
type Conversion_Array_Type is array (Product_Index_Type) of Big_Integer with Ghost;
-- Constants and predicates used in implementations
Min_Add : constant Long_Long_Integer := -2**30 + 1 with Ghost;
Max_Add : constant Long_Long_Integer := 2**30 - 1 with Ghost;
Min_Multiply : constant Long_Long_Integer := - (2**27 - 1) with Ghost;
Max_Multiply : constant Long_Long_Integer := 2**27 - 1 with Ghost;
function All_In_Range
(X, Y : Integer_255;
Min, Max : Long_Long_Integer)
return Boolean
is
(for all J in X'Range =>
X (J) in Min .. Max
and then Y (J) in Min .. Max)
with
Ghost;
end Types;
|
------------------------------------------------------------------------------
-- Copyright (c) 2013-2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Exceptions;
with Natools.S_Expressions.Test_Tools;
package body Natools.S_Expressions.Encodings.Tests is
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Hexadecimal_Test (Report);
Base64_Test (Report);
User_Base64_Test (Report);
end All_Tests;
procedure Hexadecimal_Test (Report : in out NT.Reporter'Class) is
All_Octets : Atom (1 .. 256);
begin
for I in All_Octets'Range loop
All_Octets (I) := Octet (I - All_Octets'First);
end loop;
declare
Name : constant String := "Decoding upper-case hexadecimal encoded";
begin
Test_Tools.Test_Atom
(Report, Name,
All_Octets,
Decode_Hex (Encode_Hex (All_Octets, Upper)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Decoding lower-case hexadecimal encoded";
begin
Test_Tools.Test_Atom
(Report, Name,
All_Octets,
Decode_Hex (Encode_Hex (All_Octets, Lower)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Decoding garbage-laced text";
begin
Test_Tools.Test_Atom
(Report, Name,
(16#01#, 16#23#, 16#45#, 16#67#, 16#89#,
16#AB#, 16#CD#, 16#EF#, 16#AB#, 16#CD#, 16#EF#),
Decode_Hex (All_Octets));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Decoding an odd number of nibbles";
begin
Test_Tools.Test_Atom
(Report, Name,
(16#45#, 16#56#, 16#70#),
Decode_Hex (To_Atom ("45 56 7")));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Decode_Hex with non-hex-digit";
Result : Octet;
begin
Result := Decode_Hex (180);
Report.Item (Name, NT.Fail);
Report.Info ("No exception raised. Result: " & Octet'Image (Result));
exception
when Constraint_Error =>
Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected exception "
& Ada.Exceptions.Exception_Name (Error)
& " has been raised");
end;
declare
Name : constant String := "Overflow in Encode_Hex";
Result : Octet;
begin
Result := Encode_Hex (16, Lower);
Report.Item (Name, NT.Fail);
Report.Info ("No exception raised. Result: " & Octet'Image (Result));
exception
when Constraint_Error =>
Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected exception "
& Ada.Exceptions.Exception_Name (Error)
& " has been raised");
end;
end Hexadecimal_Test;
procedure Base64_Test (Report : in out NT.Reporter'Class) is
begin
declare
Name : constant String := "Decoding encoding of all octet triplets";
Success : Boolean := True;
Expected : Atom (1 .. 3);
begin
for A in Octet loop
Expected (1) := A;
for B in Octet loop
Expected (2) := B;
for C in Octet loop
Expected (3) := C;
declare
Found : constant Atom
:= Decode_Base64 (Encode_Base64 (Expected));
begin
if Expected /= Found then
if Success then
Success := False;
Report.Item (Name, NT.Fail);
end if;
Test_Tools.Dump_Atom (Report, Found, "Found");
Test_Tools.Dump_Atom (Report, Expected, "Expected");
end if;
end;
end loop;
end loop;
end loop;
if Success then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Decoding encoding of all octet duets";
Success : Boolean := True;
Expected : Atom (1 .. 2);
begin
for A in Octet loop
Expected (1) := A;
for B in Octet loop
Expected (2) := B;
declare
Found : constant Atom
:= Decode_Base64 (Encode_Base64 (Expected));
begin
if Expected /= Found then
if Success then
Success := False;
Report.Item (Name, NT.Fail);
end if;
Test_Tools.Dump_Atom (Report, Found, "Found");
Test_Tools.Dump_Atom (Report, Expected, "Expected");
end if;
end;
end loop;
end loop;
if Success then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Decoding encoding of all single octets";
Success : Boolean := True;
Expected : Atom (1 .. 1);
begin
for A in Octet loop
Expected (1) := A;
declare
Found : constant Atom
:= Decode_Base64 (Encode_Base64 (Expected));
begin
if Expected /= Found then
if Success then
Success := False;
Report.Item (Name, NT.Fail);
end if;
Test_Tools.Dump_Atom (Report, Found, "Found");
Test_Tools.Dump_Atom (Report, Expected, "Expected");
end if;
end;
end loop;
if Success then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Decode_Base64 with non-base64-digit";
Result : Octet;
begin
Result := Decode_Base64 (127);
Report.Item (Name, NT.Fail);
Report.Info ("No exception raised. Result: " & Octet'Image (Result));
exception
when Constraint_Error =>
Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected exception "
& Ada.Exceptions.Exception_Name (Error)
& " has been raised");
end;
declare
Name : constant String := "Overflow in Encode_Base64";
Result : Octet;
begin
Result := Encode_Base64 (64);
Report.Item (Name, NT.Fail);
Report.Info ("No exception raised. Result: " & Octet'Image (Result));
exception
when Constraint_Error =>
Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected exception "
& Ada.Exceptions.Exception_Name (Error)
& " has been raised");
end;
end Base64_Test;
procedure User_Base64_Test (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Base-64 with user-defined charset");
begin
declare
Digit_62 : constant Octet := Character'Pos ('-');
Digit_63 : constant Octet := Character'Pos ('_');
-- Charset for Base-64 URI (RFC 4648)
Padding : constant Octet := Character'Pos ('|');
Source : constant Atom
:= (4#0000#, 4#0100#, 4#2003#, 4#0100#, 4#1101#, 4#2013#,
4#0200#, 4#2102#, 4#2023#, 4#0300#, 4#3103#, 4#2033#,
4#1001#, 4#0110#, 4#2103#, 4#1101#, 4#1111#, 4#2113#,
4#1201#, 4#2112#, 4#2123#, 4#1301#, 4#3113#, 4#2133#,
4#2002#, 4#0120#, 4#2203#, 4#2102#, 4#1121#, 4#2213#,
4#2202#, 4#2122#, 4#2223#, 4#2302#, 4#3123#, 4#2233#,
4#3003#, 4#0130#, 4#2303#, 4#3103#, 4#1131#, 4#2313#,
4#3203#, 4#2132#, 4#2323#, 4#3303#, 4#3133#, 4#2333#,
16#42#);
Expected : constant Atom
:= (65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, Digit_62, Digit_63,
81, 103, Padding, Padding);
Encoded_Short : constant Atom
:= Encode_Base64 (Source, Digit_62, Digit_63);
Encoded_Long : constant Atom
:= Encode_Base64 (Source, Digit_62, Digit_63, Padding);
begin
Test_Tools.Test_Atom (Test, Expected, Encoded_Long);
Test_Tools.Test_Atom
(Test,
Expected (Expected'First .. Expected'Last - 2),
Encoded_Short);
Test_Tools.Test_Atom
(Test,
Source,
Decode_Base64 (Encoded_Long, Digit_62, Digit_63));
Test_Tools.Test_Atom
(Test,
Source,
Decode_Base64 (Encoded_Short, Digit_62, Digit_63));
end;
exception
when Error : others => Test.Report_Exception (Error);
end User_Base64_Test;
end Natools.S_Expressions.Encodings.Tests;
|
pragma Style_Checks (Off);
with CSS.Analysis.Parser.Lexer_dfa; use CSS.Analysis.Parser.Lexer_dfa;
package body CSS.Analysis.Parser.Lexer_dfa is
-- Warning: This file is automatically generated by AFLEX.
-- It is useless to modify it. Change the ".Y" & ".L" files instead.
-- Nov 2002. Fixed insufficient buffer size bug causing
-- damage to comments at about the 1000-th character
function YYText return String is
J : Integer := yytext_ptr;
begin
while J <= yy_ch_buf'Last and then yy_ch_buf (J) /= ASCII.NUL loop
J := J + 1;
end loop;
declare
subtype Sliding_Type is String (1 .. J - yytext_ptr);
begin
return Sliding_Type (yy_ch_buf (yytext_ptr .. J - 1));
end;
end YYText;
-- Returns the length of the matched text
function YYLength return Integer is
begin
return yy_cp - yy_bp;
end YYLength;
-- Done after the current pattern has been matched and before the
-- corresponding action - sets up yytext
procedure YY_DO_BEFORE_ACTION is
begin
yytext_ptr := yy_bp;
yy_hold_char := yy_ch_buf (yy_cp);
yy_ch_buf (yy_cp) := ASCII.NUL;
yy_c_buf_p := yy_cp;
end YY_DO_BEFORE_ACTION;
end CSS.Analysis.Parser.Lexer_dfa;
|
pragma Check_Policy (Trace => Disable);
-- with Ada;
with System.Shared_Locking;
-- with System.Storage_Elements.Formatting;
package body System.Pool_Size is
type Unaligned_Storage_Offset is new Storage_Elements.Storage_Offset;
for Unaligned_Storage_Offset'Alignment use 1;
subtype Positive_Storage_Count is
Storage_Elements.Storage_Offset range
1 ..
Storage_Elements.Storage_Offset'Last;
type Freed_Chunk is record
Size : Storage_Elements.Storage_Count;
Next : Storage_Elements.Storage_Offset; -- -1 means last
end record;
pragma Suppress_Initialization (Freed_Chunk);
-- implementation of mixed
procedure Allocate (
Allocator : aliased in out Bounded_Allocator;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count)
is
Actual_Alignment : constant Positive_Storage_Count :=
Storage_Elements.Storage_Offset'Max (
Allocator.Alignment,
Freed_Chunk'Size / Standard'Storage_Unit);
Error : Boolean := False;
begin
if Allocator.Alignment rem Positive_Storage_Count'(Alignment) /= 0 then
raise Constraint_Error;
end if;
Shared_Locking.Enter;
declare
Actual_Size : constant Storage_Elements.Storage_Count :=
Size_In_Storage_Elements
+ (-Size_In_Storage_Elements) mod Actual_Alignment;
begin
Storage_Address := Null_Address;
if Allocator.First_Free >= 0 then
-- search freed list by best matching
declare
Matched_Size : Storage_Elements.Storage_Count :=
Storage_Elements.Storage_Count'Last;
Matched_Index : Storage_Elements.Storage_Offset := -1;
Previous_Matched_Index : Storage_Elements.Storage_Offset := -1;
begin
declare
Index : Storage_Elements.Storage_Count :=
Allocator.First_Free;
Previous_Index : Storage_Elements.Storage_Offset := -1;
begin
loop
declare
Chunk : Freed_Chunk;
for Chunk'Address use
Allocator.Storage'Address + Index;
begin
if Chunk.Size >= Actual_Size
and then Chunk.Size < Matched_Size
then
Previous_Matched_Index := Previous_Index;
Matched_Size := Chunk.Size;
Matched_Index := Index;
end if;
Previous_Index := Index;
exit when Chunk.Next < 0;
pragma Assert (Chunk.Next > Index);
Index := Chunk.Next;
end;
end loop;
end;
if Matched_Index >= 0 then
-- found
Storage_Address := Allocator.Storage'Address + Matched_Index;
declare
Chunk : Freed_Chunk;
for Chunk'Address use Storage_Address;
Rest_Size : constant Storage_Elements.Storage_Count :=
Chunk.Size - Actual_Size;
begin
if Rest_Size >= Actual_Alignment then
-- split
declare
New_Index : constant
Storage_Elements.Storage_Count :=
Matched_Index + Actual_Size;
New_Chunk : Freed_Chunk;
for New_Chunk'Address use
Allocator.Storage'Address + New_Index;
begin
New_Chunk.Size := Rest_Size;
New_Chunk.Next := Chunk.Next;
Chunk.Size := Actual_Size;
Chunk.Next := New_Index;
end;
pragma Check (Trace, Ada.Debug.Put ("split"));
end if;
if Previous_Matched_Index >= 0 then
declare
Previous_Chunk : Freed_Chunk;
for Previous_Chunk'Address use
Allocator.Storage'Address
+ Previous_Matched_Index;
begin
Previous_Chunk.Next := Chunk.Next;
end;
else
Allocator.First_Free := Chunk.Next;
end if;
end;
pragma Check (Trace, Ada.Debug.Put ("from freed list"));
end if;
end;
end if;
if Storage_Address = Null_Address then
-- allocate from empty area
declare
Next_Empty : Storage_Elements.Storage_Count;
begin
Next_Empty := Allocator.First_Empty + Actual_Size;
if Next_Empty <= Allocator.Size then
Storage_Address :=
Allocator.Storage'Address + Allocator.First_Empty;
Allocator.First_Empty := Next_Empty;
pragma Check (Trace, Ada.Debug.Put ("from empty area"));
else
Error := True;
end if;
end;
end if;
end;
Shared_Locking.Leave;
if Error then
raise Storage_Error;
end if;
pragma Check (Trace,
Check =>
Ada.Debug.Put (
Storage_Elements.Formatting.Image (Storage_Address)));
end Allocate;
procedure Deallocate (
Allocator : aliased in out Bounded_Allocator;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count)
is
Actual_Alignment : constant Positive_Storage_Count :=
Storage_Elements.Storage_Offset'Max (
Allocator.Alignment,
Freed_Chunk'Size / Standard'Storage_Unit);
begin
pragma Check (Trace,
Check =>
Ada.Debug.Put (
Storage_Elements.Formatting.Image (Storage_Address)));
if Allocator.Alignment rem Positive_Storage_Count'(Alignment) /= 0 then
raise Constraint_Error;
end if;
Shared_Locking.Enter;
declare
Actual_Index : Storage_Elements.Storage_Count :=
Storage_Address - Allocator.Storage'Address;
Actual_Size : Storage_Elements.Storage_Count :=
Size_In_Storage_Elements
+ (-Size_In_Storage_Elements) mod Actual_Alignment;
Previous_Index : Storage_Elements.Storage_Offset := -1;
begin
if Allocator.First_Free >= 0 then
declare
Previous_Previous_Index : Storage_Elements.Storage_Offset := -1;
begin
-- search freed list for previous chunk
declare
Index : Storage_Elements.Storage_Count :=
Allocator.First_Free;
begin
while Index < Actual_Index loop
Previous_Previous_Index := Previous_Index;
Previous_Index := Index;
declare
Chunk : Freed_Chunk;
for Chunk'Address use
Allocator.Storage'Address + Index;
begin
exit when Chunk.Next < 0;
pragma Assert (Chunk.Next > Index);
Index := Chunk.Next;
end;
end loop;
end;
-- try to merge
if Previous_Index >= 0 then
declare
Previous_Chunk : Freed_Chunk;
for Previous_Chunk'Address use
Allocator.Storage'Address + Previous_Index;
begin
if Actual_Index + Actual_Size = Previous_Chunk.Next then
-- merge next chunk
declare
Next_Chunk : Freed_Chunk;
for Next_Chunk'Address use
Allocator.Storage'Address + Previous_Chunk.Next;
begin
Actual_Size := Actual_Size + Next_Chunk.Size;
Previous_Chunk.Next := Next_Chunk.Next;
end;
pragma Check (Trace, Ada.Debug.Put ("merge next"));
end if;
if Previous_Index + Previous_Chunk.Size =
Actual_Index
then
-- merge previous chunk
if Previous_Previous_Index >= 0 then
declare
Previous_Previous_Chunk : Freed_Chunk;
for Previous_Previous_Chunk'Address use
Allocator.Storage'Address
+ Previous_Previous_Index;
begin
Previous_Previous_Chunk.Next :=
Previous_Chunk.Next;
end;
else
Allocator.First_Free := Previous_Chunk.Next;
end if;
Actual_Index := Previous_Index;
Actual_Size := Actual_Size + Previous_Chunk.Size;
Previous_Index := Previous_Previous_Index;
pragma Check (Trace, Ada.Debug.Put ("merge previous"));
end if;
end;
else
if Actual_Index + Actual_Size = Allocator.First_Free then
-- merge next chunk
declare
Next_Chunk : Freed_Chunk;
for Next_Chunk'Address use
Allocator.Storage'Address + Allocator.First_Free;
begin
Actual_Size := Actual_Size + Next_Chunk.Size;
Allocator.First_Free := Next_Chunk.Next;
end;
pragma Check (Trace, Ada.Debug.Put ("merge next"));
end if;
end if;
end;
end if;
if Actual_Index + Actual_Size < Allocator.First_Empty then
-- add new freed chunk
declare
New_Chunk : Freed_Chunk;
for New_Chunk'Address use
Allocator.Storage'Address + Actual_Index;
begin
New_Chunk.Size := Actual_Size;
if Previous_Index >= 0 then
pragma Assert (Previous_Index < Actual_Index);
declare
Previous_Chunk : Freed_Chunk;
for Previous_Chunk'Address use
Allocator.Storage'Address + Previous_Index;
begin
New_Chunk.Next := Previous_Chunk.Next;
Previous_Chunk.Next := Actual_Index;
end;
else
New_Chunk.Next := Allocator.First_Free;
Allocator.First_Free := Actual_Index;
end if;
end;
pragma Check (Trace, Ada.Debug.Put ("to freed list"));
else
-- compaction
if Previous_Index >= 0 then
declare
Previous_Chunk : Freed_Chunk;
for Previous_Chunk'Address use
Allocator.Storage'Address + Previous_Index;
begin
Previous_Chunk.Next := -1;
end;
else
Allocator.First_Free := -1;
end if;
Allocator.First_Empty := Actual_Index;
pragma Check (Trace, Ada.Debug.Put ("to empty area"));
end if;
end;
Shared_Locking.Leave;
end Deallocate;
function Storage_Size (Allocator : Bounded_Allocator)
return Storage_Elements.Storage_Count is
begin
return Allocator.Size;
end Storage_Size;
-- implementation of fixed
procedure Allocate (
Allocator : aliased in out Bounded_Fixed_Allocator;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count)
is
Aligned_Component_Size : constant Storage_Elements.Storage_Count :=
Storage_Elements.Storage_Offset'Max (
-- minimum chunk size
Storage_Elements.Storage_Offset'Size / Standard'Storage_Unit,
-- component size
Allocator.Component_Size
+ (-Allocator.Component_Size)
mod Positive_Storage_Count'(Allocator.Alignment));
Error : Boolean := False;
begin
if Allocator.Alignment rem Positive_Storage_Count'(Alignment) /= 0
or else Size_In_Storage_Elements /= Allocator.Component_Size
then
raise Constraint_Error;
end if;
Shared_Locking.Enter;
if Allocator.First_Free >= 0 then
Storage_Address := Allocator.Storage'Address + Allocator.First_Free;
declare
Next : Unaligned_Storage_Offset;
for Next'Address use Storage_Address;
begin
Allocator.First_Free := Storage_Elements.Storage_Offset (Next);
end;
elsif Allocator.First_Empty <=
Allocator.Size - Aligned_Component_Size + 1
then
Storage_Address := Allocator.Storage'Address + Allocator.First_Empty;
Allocator.First_Empty :=
Allocator.First_Empty + Aligned_Component_Size;
else
Error := True;
end if;
Shared_Locking.Leave;
if Error then
raise Storage_Error;
end if;
end Allocate;
procedure Deallocate (
Allocator : aliased in out Bounded_Fixed_Allocator;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is
begin
if Size_In_Storage_Elements /= Allocator.Component_Size
or else Alignment /= Allocator.Alignment
then
raise Constraint_Error;
end if;
Shared_Locking.Enter;
declare
Next : Unaligned_Storage_Offset;
for Next'Address use Storage_Address;
begin
Next := Unaligned_Storage_Offset (Allocator.First_Free);
end;
Allocator.First_Free := Storage_Address - Allocator.Storage'Address;
Shared_Locking.Leave;
end Deallocate;
function Storage_Size (Allocator : Bounded_Fixed_Allocator)
return Storage_Elements.Storage_Count is
begin
return Allocator.Size;
end Storage_Size;
-- implementation of required by compiler
overriding procedure Allocate (
Pool : in out Stack_Bounded_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is
begin
case Pool.Elmt_Size is
when 0 =>
Allocate (
Pool.Mixed,
Storage_Address,
Size_In_Storage_Elements,
Alignment);
when others =>
Allocate (
Pool.Fixed,
Storage_Address,
Size_In_Storage_Elements,
Alignment);
end case;
end Allocate;
overriding procedure Deallocate (
Pool : in out Stack_Bounded_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is
begin
case Pool.Elmt_Size is
when 0 =>
Deallocate (
Pool.Mixed,
Storage_Address,
Size_In_Storage_Elements,
Alignment);
when others =>
Deallocate (
Pool.Fixed,
Storage_Address,
Size_In_Storage_Elements,
Alignment);
end case;
end Deallocate;
overriding function Storage_Size (Pool : Stack_Bounded_Pool)
return Storage_Elements.Storage_Count is
begin
case Pool.Elmt_Size is
when 0 =>
return Storage_Size (Pool.Mixed);
when others =>
return Storage_Size (Pool.Fixed);
end case;
end Storage_Size;
end System.Pool_Size;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Containers;
with Ada.Strings.Unbounded;
with Natools.Constant_Indefinite_Ordered_Maps;
package body Natools.Constant_Indefinite_Ordered_Map_Tests is
package Test_Maps is new
Constant_Indefinite_Ordered_Maps
(Key_Type => String,
Element_Type => Integer);
function Image (Map : Test_Maps.Unsafe_Maps.Map) return String;
function Image (Map : Test_Maps.Updatable_Map) return String;
function Sample_Map return Test_Maps.Unsafe_Maps.Map;
function Sample_Map return Test_Maps.Updatable_Map
is (Test_Maps.Create (Sample_Map));
------------------------------
-- Local Helper Subprograms --
------------------------------
function Image (Map : Test_Maps.Unsafe_Maps.Map) return String is
use Ada.Strings.Unbounded;
Result : Unbounded_String;
First : Boolean := True;
procedure Process (Cursor : Test_Maps.Unsafe_Maps.Cursor);
procedure Process (Cursor : Test_Maps.Unsafe_Maps.Cursor) is
begin
if First then
First := False;
else
Append (Result, ", ");
end if;
Append (Result, Test_Maps.Unsafe_Maps.Key (Cursor));
Append (Result, " ->");
Append
(Result, Integer'Image (Test_Maps.Unsafe_Maps.Element (Cursor)));
end Process;
begin
Append (Result, "(");
Map.Iterate (Process'Access);
Append (Result, ")");
return To_String (Result);
end Image;
function Image (Map : Test_Maps.Updatable_Map) return String is
begin
return Image (Map.To_Unsafe_Map);
end Image;
function Sample_Map return Test_Maps.Unsafe_Maps.Map is
Result : Test_Maps.Unsafe_Maps.Map;
begin
for I in 0 .. 9 loop
Result.Insert
((1 => '1',
2 => Character'Val (Character'Pos ('0') + I)),
I + 10);
Result.Insert
((1 => '2',
2 => Character'Val (Character'Pos ('0') + I)),
I + 20);
end loop;
return Result;
end Sample_Map;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Consistency (Report);
Cursor_Operations (Report);
Direct_Access (Report);
Empty_Map (Report);
Iterations (Report);
Map_Updates (Report);
Unsafe_Map_Roundtrip (Report);
Ada_2012_Indexing (Report);
Ada_2012_Iteration (Report);
Ada_2012_Errors (Report);
Range_Iterators (Report);
Update_Constructors (Report);
Update_Constructor_Exceptions (Report);
Rank (Report);
end All_Tests;
----------------------
-- Individual Tests --
----------------------
procedure Ada_2012_Errors (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Errors in Ada 2012 extensions");
begin
declare
Map : Test_Maps.Updatable_Map := Sample_Map;
Fixed_Map : constant Test_Maps.Updatable_Map := Sample_Map;
Empty_Map : constant Test_Maps.Updatable_Map
:= Test_Maps.Create (Test_Maps.Unsafe_Maps.Empty_Map);
I : Integer;
begin
for Position in Empty_Map.Iterate loop
Test.Fail ("Found element in empty map:");
Test.Info (" (" & Test_Maps.Key (Position)
& " ->" & Integer'Image (Test_Maps.Element (Position)) & ')');
end loop;
for Position in reverse Empty_Map.Iterate loop
Test.Fail ("Found element in reverse empty map:");
Test.Info (" (" & Test_Maps.Key (Position)
& " ->" & Integer'Image (Test_Maps.Element (Position)) & ')');
end loop;
begin
I := Fixed_Map ("#1");
Test.Fail ("Found value " & Integer'Image (I) & " for key ""#1""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception for value ""#1""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
I := Fixed_Map (Fixed_Map.Find ("#2"));
Test.Fail ("Found value " & Integer'Image (I) & " for key ""#2""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with value for ""#2""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
I := Fixed_Map (Map.Find ("20"));
Test.Fail ("Found value " & Integer'Image (I)
& " for key ""20"" in foreign map");
exception
when Program_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with for foreign cursor");
Test.Report_Exception (Error, NT.Fail);
end;
begin
Map ("#3") := 93;
Test.Fail ("Found node for key ""#3""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception for value ""#3""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
Map (Map.Find ("#4")) := 94;
Test.Fail ("Found node for key ""#4""");
exception
when Constraint_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with node for ""#4""");
Test.Report_Exception (Error, NT.Fail);
end;
begin
Map (Fixed_Map.Find ("20")) := 95;
Test.Fail ("Found node for key ""20"" in foreign map");
exception
when Program_Error => null;
when Error : others =>
Test.Fail ("Unexpected exception with node for foreign cursor");
Test.Report_Exception (Error, NT.Fail);
end;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Ada_2012_Errors;
procedure Ada_2012_Indexing (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Ada 2012 user-defined indexing");
procedure Test_Constant (Map : in Test_Maps.Updatable_Map);
procedure Test_Constant (Map : in Test_Maps.Updatable_Map) is
I : Integer;
begin
I := Map ("25");
if I /= 25 then
Test.Fail ("Unexpacted value" & Integer'Image (I)
& " for Map (""25"")");
end if;
I := Map (Map.Find ("12"));
if I /= 12 then
Test.Fail ("Unexpacted value" & Integer'Image (I)
& " for Map (""12"")");
end if;
end Test_Constant;
begin
declare
Map : Test_Maps.Updatable_Map := Sample_Map;
I : Integer;
begin
I := Map ("15");
if I /= 15 then
Test.Fail ("Unexpacted value" & Integer'Image (I)
& " for Map (""15"")");
end if;
Map ("23") := 2;
I := Map.Element ("23");
if I /= 2 then
Test.Fail ("Unexpected value" & Integer'Image (I)
& " for updated Map (""23"")");
Test.Info ("Full map: " & Image (Map));
end if;
Test_Constant (Map);
end;
exception
when Error : others => Test.Report_Exception (Error);
end Ada_2012_Indexing;
procedure Ada_2012_Iteration (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Ada 2012 user-defined iteration");
begin
declare
Map : Test_Maps.Updatable_Map := Sample_Map;
Expected, Direction : Integer;
Abort_Loop : Boolean := False;
procedure Test_Element (Element : in Integer);
procedure Test_Element (Element : in Integer) is
begin
if Expected /= Element then
Test.Fail ("Got element" & Integer'Image (Element)
& ", expected" & Integer'Image (Expected));
Test.Info ("Current map: " & Image (Map));
Abort_Loop := True;
end if;
Expected := Expected + Direction;
end Test_Element;
begin
Direction := 1;
Expected := 10;
Abort_Loop := False;
for Element of Map loop
Test_Element (Element);
exit when Abort_Loop;
end loop;
Direction := -1;
Expected := 29;
Abort_Loop := False;
for Element of reverse Map loop
Test_Element (Element);
exit when Abort_Loop;
end loop;
Expected := 59;
Direction := -1;
for Element of Map loop
Element := Expected;
Expected := Expected + Direction;
end loop;
Direction := 1;
Expected := 40;
Abort_Loop := False;
for Element of reverse Map loop
Test_Element (Element);
exit when Abort_Loop;
end loop;
Direction := 1;
Expected := 50;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("19")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Direction := -1;
Expected := 50;
Abort_Loop := False;
for Position in Map.Iterate (Map.Find ("19")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Ada_2012_Iteration;
procedure Consistency (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Consistency checks");
begin
if Test_Maps.Has_Element (Test_Maps.No_Element) then
Test.Fail ("No_Element has an element");
end if;
declare
use type Ada.Containers.Count_Type;
use type Test_Maps.Cursor;
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Cursor : Test_Maps.Cursor;
begin
if Map.Length /= 20 then
Test.Fail ("Unexpected map length:"
& Ada.Containers.Count_Type'Image (Map.Length));
end if;
Cursor := Map.First;
if Test_Maps.Key (Cursor) /= Map.First_Key then
Test.Fail ("Key (First) /= First_Key");
end if;
if Test_Maps.Element (Cursor) /= Map.First_Element then
Test.Fail ("Element (First) /= First_Element");
end if;
if Test_Maps.Previous (Cursor) /= Test_Maps.No_Element then
Test.Fail ("Previous (First) has element");
end if;
Test_Maps.Next (Cursor);
if Cursor < Map.First then
Test.Fail ("Second < First");
end if;
if Cursor < Map.First_Key then
Test.Fail ("Second < First_Key");
end if;
if not (Map.First_Key < Cursor) then
Test.Fail ("Second <= First_Key");
end if;
Cursor := Map.Last;
if Test_Maps.Key (Cursor) /= Map.Last_Key then
Test.Fail ("Key (Last) /= Last_Key");
end if;
if Test_Maps.Element (Cursor) /= Map.Last_Element then
Test.Fail ("Element (Last) /= Last_Element");
end if;
if Test_Maps.Next (Cursor) /= Test_Maps.No_Element then
Test.Fail ("Next (Last) has element");
end if;
Test_Maps.Previous (Cursor);
if Cursor > Map.Last then
Test.Fail ("Before_Last > Last");
end if;
if Cursor > Map.Last_Key then
Test.Fail ("Before_Last > Last_Key");
end if;
if not (Map.Last_Key > Cursor) then
Test.Fail ("Before_Last >= Last_Key");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Consistency;
procedure Cursor_Operations (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Cursor operations");
begin
declare
procedure Check (Cursor : in Test_Maps.Cursor);
procedure Check (Key : in String; Element : in Integer);
Expected : String := "??";
procedure Check (Cursor : in Test_Maps.Cursor) is
begin
Test_Maps.Query_Element (Cursor, Check'Access);
end Check;
procedure Check (Key : in String; Element : in Integer) is
begin
if Key /= Expected or Element /= Integer'Value (Expected) then
Test.Fail ("Expected """ & Expected
& """, got (""" & Key
& " ->" & Integer'Image (Element) & ')');
end if;
end Check;
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Cursor, Alternate : Test_Maps.Cursor;
begin
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Default cursor is not empty");
return;
end if;
Expected := "17";
Cursor := Map.Find (Expected);
if not Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Find (""17"") has no element");
return;
end if;
Check (Cursor);
Alternate := Test_Maps.Previous (Cursor);
Expected := "16";
Check (Alternate);
Alternate := Test_Maps.Next (Cursor);
Expected := "18";
Check (Alternate);
Test_Maps.Clear (Alternate);
if Test_Maps.Has_Element (Alternate) then
Test.Fail ("Clear cursor has element");
return;
end if;
Test_Maps.Next (Alternate);
if Test_Maps.Has_Element (Alternate) then
Test.Fail ("Next (Empty_Cursor) has element");
return;
end if;
Test_Maps.Previous (Alternate);
if Test_Maps.Has_Element (Alternate) then
Test.Fail ("Previous (Empty_Cursor) has element");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Cursor_Operations;
procedure Direct_Access (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Direct node access");
begin
declare
use type Test_Maps.Cursor;
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Img : String := "??";
Cursor : Test_Maps.Cursor;
begin
for I in 10 .. 29 loop
Img (1) := Character'Val (Character'Pos ('0') + I / 10);
Img (2) := Character'Val (Character'Pos ('0') + I mod 10);
if not Map.Contains (Img) then
Test.Fail ("Sample_Map should contain key """ & Img & '"');
elsif Map.Floor (Img) /= Map.Ceiling (Img) then
Test.Fail ("Floor /= Ceiling for existing key """ & Img & '"');
elsif Map.Element (Img) /= I then
Test.Fail ("Unexpected element"
& Integer'Image (Map.Element (Img))
& " for key """ & Img & '"');
end if;
Cursor := Map.Floor ("1");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Floor (""1"") is not empty ("""
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Find ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Find (""2"") is not empty ("""
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Ceiling ("3");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Ceiling (""3"") is not empty ("""
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Floor ("2");
if not Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Floor (""2"") is empty");
elsif Test_Maps.Key (Cursor) /= "19" then
Test.Fail ("Map.Floor (""2"") returns unexpected node """
& Test_Maps.Key (Cursor) & '"');
end if;
Cursor := Map.Ceiling ("2");
if not Test_Maps.Has_Element (Cursor) then
Test.Fail ("Map.Ceiling (""2"") is empty");
elsif Test_Maps.Key (Cursor) /= "20" then
Test.Fail ("Map.Ceiling (""2"") returns unexpected node """
& Test_Maps.Key (Cursor) & '"');
end if;
end loop;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Direct_Access;
procedure Empty_Map (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Operations on empty map");
begin
declare
use type Ada.Containers.Count_Type;
use type Test_Maps.Updatable_Map;
procedure Fail_Test (Cursor : in Test_Maps.Cursor);
procedure Fail_Test (Cursor : in Test_Maps.Cursor) is
pragma Unreferenced (Cursor);
begin
Test.Fail ("Unexpected callback use");
end Fail_Test;
Cursor : Test_Maps.Cursor;
Map : Test_Maps.Updatable_Map;
pragma Unmodified (Map);
begin
Map.Iterate (Fail_Test'Access);
Map.Reverse_Iterate (Fail_Test'Access);
if Test_Maps.Has_Element (Map.First) then
Test.Fail ("Empty_Map.First has an element");
end if;
if Test_Maps.Has_Element (Map.Last) then
Test.Fail ("Empty_Map.Last has an element");
end if;
if not Map.To_Unsafe_Map.Is_Empty then
Test.Fail ("Empty_Map.To_Unsafe_Map is not empty");
end if;
if Map.Length /= 0 then
Test.Fail ("Empty_Map.Length is not zero");
end if;
if Map.Contains ("foo") then
Test.Fail ("Empty_Map.Contains (""foo"")");
end if;
Cursor := Map.Find ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Empty_Map.Find (""2"") has element ("""
& Test_Maps.Key (Cursor) & """ ->"
& Integer'Image (Test_Maps.Element (Cursor)) & ')');
end if;
Cursor := Map.Floor ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Empty_Map.Floor (""2"") has element ("""
& Test_Maps.Key (Cursor) & """ ->"
& Integer'Image (Test_Maps.Element (Cursor)) & ')');
end if;
Cursor := Map.Ceiling ("2");
if Test_Maps.Has_Element (Cursor) then
Test.Fail ("Empty_Map.Ceiling (""2"") has element ("""
& Test_Maps.Key (Cursor) & """ ->"
& Integer'Image (Test_Maps.Element (Cursor)) & ')');
end if;
if Map /= Test_Maps.Create (Test_Maps.Unsafe_Maps.Empty_Map) then
Test.Fail ("Empty_Map /= Create (Unsafe_Empty_Map)");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Empty_Map;
procedure Iterations (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Iterative visit of the whole container");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
procedure Check (Key : in String; Element : in Integer);
procedure Check_Cursor (Cursor : in Test_Maps.Cursor);
procedure Init_Backward (Id_Char : in Character);
procedure Init_Forward (Id_Char : in Character);
Id : String := "??";
Index : Integer := 0;
Direction : Integer := 1;
procedure Check (Key : in String; Element : in Integer) is
Space_Image : constant String := Integer'Image (Index);
Image : constant String
:= Space_Image (Space_Image'First + 1 .. Space_Image'Last);
begin
if Key /= Image then
Test.Fail (Id & '.' & Image
& ". unexpected key """ & Key & '"');
end if;
if Element /= Index then
Test.Fail (Id & '.' & Image
& ". unexpected element" & Integer'Image (Element));
end if;
Index := Index + Direction;
end Check;
procedure Check_Cursor (Cursor : in Test_Maps.Cursor) is
begin
Check (Test_Maps.Key (Cursor), Test_Maps.Element (Cursor));
end Check_Cursor;
procedure Init_Backward (Id_Char : in Character) is
begin
Id := Id_Char & 'b';
Index := 29;
Direction := -1;
end Init_Backward;
procedure Init_Forward (Id_Char : in Character) is
begin
Id := Id_Char & 'f';
Index := 10;
Direction := 1;
end Init_Forward;
begin
begin
Init_Forward ('1');
Map.Iterate (Check_Cursor'Access);
end;
begin
Init_Backward ('1');
Map.Reverse_Iterate (Check_Cursor'Access);
end;
declare
Cursor : Test_Maps.Cursor := Map.First;
begin
Init_Forward ('2');
while Test_Maps.Has_Element (Cursor) loop
Check_Cursor (Cursor);
Test_Maps.Next (Cursor);
end loop;
end;
declare
Cursor : Test_Maps.Cursor := Map.Last;
begin
Init_Backward ('2');
while Test_Maps.Has_Element (Cursor) loop
Check_Cursor (Cursor);
Test_Maps.Previous (Cursor);
end loop;
end;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Iterations;
procedure Map_Updates (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Map updates");
begin
declare
use type Test_Maps.Updatable_Map;
procedure Update (Key : in String; Element : in out Integer);
procedure Update (Key : in String; Element : in out Integer) is
pragma Unreferenced (Key);
begin
Element := 7;
end Update;
Map_A : Test_Maps.Updatable_Map := Sample_Map;
Map_B : Test_Maps.Updatable_Map := Sample_Map;
Cursor : Test_Maps.Cursor;
begin
if Map_A = Map_B then
Test.Fail ("Unrelated maps are equal");
return;
end if;
Cursor := Map_A.Find ("17");
pragma Assert (Test_Maps.Has_Element (Cursor));
if Test_Maps.Is_Related (Map_B, Cursor) then
Test.Fail ("Map_B and Cursor should be unrelated");
return;
end if;
Map_A.Update_Element (Cursor, Update'Access);
if Test_Maps.Element (Cursor) /= 7 then
Test.Fail ("Update failure, element is"
& Integer'Image (Test_Maps.Element (Cursor))
& ", should be 7");
end if;
Test_Maps.Move (Map_B, Map_A);
if not Map_A.Is_Empty then
Test.Fail ("Move source is not empty");
end if;
if not Test_Maps.Is_Related (Map_B, Cursor) then
Test.Fail ("Move target is not related to old source");
else
Map_B.Update_Element (Cursor, Update'Access);
end if;
Map_A.Replace (Map_B.To_Unsafe_Map);
if Map_A.Is_Empty then
Test.Fail ("Replaced map is empty");
end if;
if Map_A.Element ("17") /= 7 then
Test.Fail ("Unexpected value"
& Integer'Image (Map_A.Element ("17"))
& "for Map_A.Element (""17"")");
end if;
Map_B.Clear;
if not Map_B.Is_Empty then
Test.Fail ("Cleared map is not empty");
end if;
if Test_Maps.Is_Related (Map_B, Cursor) then
Test.Fail ("Clear map is still related to cursor");
end if;
if (not Test_Maps.Has_Element (Cursor))
or else Test_Maps.Element (Cursor) /= 7
then
Test.Fail ("Orphaned cursor has lost its value");
end if;
Test_Maps.Next (Cursor);
if (not Test_Maps.Has_Element (Cursor))
or else Test_Maps.Element (Cursor) /= 18
then
Test.Fail ("Moved orphaned cursor has lost its value");
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Map_Updates;
procedure Range_Iterators (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Map updates");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Expected, Direction : Integer;
Abort_Loop : Boolean := False;
procedure Test_Element (Element : in Integer);
procedure Test_Element (Element : in Integer) is
begin
if Expected /= Element then
Test.Fail ("Got element" & Integer'Image (Element)
& ", expected" & Integer'Image (Expected));
Test.Info ("Current map: " & Image (Map));
Abort_Loop := True;
end if;
Expected := Expected + Direction;
end Test_Element;
begin
Direction := 1;
Expected := 10;
Abort_Loop := False;
for Position in Map.Iterate loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Direction := 1;
Expected := 15;
Abort_Loop := False;
for Position in Map.Iterate (Map.Find ("15"), Map.Find ("25")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (26);
Direction := -1;
Expected := 23;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("13"), Map.Find ("23"))
loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (12);
Direction := 1;
Expected := 99;
Abort_Loop := False;
for Position in Map.Iterate (Map.Find ("17"), Map.Find ("16")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (99);
Direction := 1;
Expected := 99;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("27"), Map.Find ("26"))
loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (99);
Direction := 1;
Expected := 10;
Abort_Loop := False;
for Position in Map.Iterate (Map.First, Map.Find ("20")) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (21);
Direction := -1;
Expected := 29;
Abort_Loop := False;
for Position in reverse Map.Iterate (Map.Find ("25"), Map.Last) loop
Test_Element (Test_Maps.Element (Position));
exit when Abort_Loop;
end loop;
Test_Element (24);
end;
exception
when Error : others => Test.Report_Exception (Error);
end Range_Iterators;
procedure Rank (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Rank function");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
procedure Test_Rank
(Cursor : in Test_Maps.Cursor;
Expected : in Ada.Containers.Count_Type;
Name : in String);
procedure Test_Rank
(Cursor : in Test_Maps.Cursor;
Expected : in Ada.Containers.Count_Type;
Name : in String)
is
use type Ada.Containers.Count_Type;
Actual : constant Ada.Containers.Count_Type
:= Test_Maps.Rank (Cursor);
begin
if Actual /= Expected then
Test.Fail ("Expected rank"
& Ada.Containers.Count_Type'Image (Expected)
& " for " & Name & ", found"
& Ada.Containers.Count_Type'Image (Actual));
end if;
end Test_Rank;
begin
Test_Rank (Test_Maps.No_Element, 0, "No_Element");
Test_Rank (Map.First, 1, "Map.First");
Test_Rank (Map.Last, 20, "Map.Last");
Test_Rank (Test_Maps.Next (Map.First), 2, "Next (Map.First)");
Test_Rank (Test_Maps.Next (Map.Last), 0, "Next (Map.Last)");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Rank;
procedure Unsafe_Map_Roundtrip (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Constant_Map <-> Unsafe_Map roundtrip");
begin
declare
use type Test_Maps.Unsafe_Maps.Map;
Unsafe : constant Test_Maps.Unsafe_Maps.Map := Sample_Map;
Safe : constant Test_Maps.Updatable_Map := Test_Maps.Create (Unsafe);
Roundtrip : constant Test_Maps.Unsafe_Maps.Map := Safe.To_Unsafe_Map;
begin
if Unsafe /= Roundtrip then
Test.Fail;
Test.Info ("Original: " & Image (Unsafe));
Test.Info ("Roundtrip: " & Image (Roundtrip));
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Unsafe_Map_Roundtrip;
procedure Update_Constructors (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("""Update"" constructors");
procedure Check_Map
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Dump : out Boolean);
-- Base map consistency check
procedure Check_Map_Not_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String);
-- Check consistency and that Key does not exist
procedure Check_Map_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String;
Value : in Integer);
-- Check consistency and that Key exists and is associated with Value
procedure Check_Map
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Dump : out Boolean)
is
use type Ada.Containers.Count_Type;
I : Integer;
Current : Test_Maps.Cursor := Map.First;
Previous : Test_Maps.Cursor;
begin
Dump := False;
if Map.Length /= Expected_Length then
Test.Fail (Context & ": found length"
& Ada.Containers.Count_Type'Image (Map.Length)
& ", expected:"
& Ada.Containers.Count_Type'Image (Expected_Length));
Dump := True;
end if;
if not Test_Maps.Has_Element (Current) then
return;
end if;
loop
begin
I := Integer'Value (Test_Maps.Key (Current));
exception
when Constraint_Error =>
Test.Fail (Context & ": Invalid key """
& Test_Maps.Key (Current) & '"');
Dump := True;
exit;
end;
if I /= abs Test_Maps.Element (Current) then
Test.Fail (Context & ": Inconsistent key """
& Test_Maps.Key (Current) & """ and value "
& Integer'Image (Test_Maps.Element (Current)));
Dump := True;
end if;
Previous := Current;
Test_Maps.Next (Current);
exit when not Test_Maps.Has_Element (Current);
if Test_Maps.Key (Previous) >= Test_Maps.Key (Current) then
Test.Fail (Context & ": Inconsistent ordering of keys """
& Test_Maps.Key (Previous) & """ and """
& Test_Maps.Key (Current));
Dump := True;
end if;
end loop;
end Check_Map;
procedure Check_Map_Not_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String)
is
Dump : Boolean;
Position : constant Test_Maps.Cursor := Map.Find (Key);
begin
Check_Map (Map, Context, Expected_Length, Dump);
if Test_Maps.Has_Element (Position) then
Test.Fail (Context & ": unexpected key """
& Test_Maps.Key (Position) & """ found with value "
& Integer'Image (Test_Maps.Element (Position)));
Dump := True;
end if;
if Dump then
Test.Info (Context & ": Map dump " & Image (Map));
end if;
end Check_Map_Not_Value;
procedure Check_Map_Value
(Map : in Test_Maps.Updatable_Map;
Context : in String;
Expected_Length : in Ada.Containers.Count_Type;
Key : in String;
Value : in Integer)
is
Dump : Boolean;
Position : constant Test_Maps.Cursor := Map.Find (Key);
begin
Check_Map (Map, Context, Expected_Length, Dump);
if not Test_Maps.Has_Element (Position) then
Test.Fail (Context & ": key """ & Key & """ not found");
Dump := True;
elsif Test_Maps.Element (Position) /= Value then
Test.Fail (Context & ": key """ & Key & """ found with value "
& Integer'Image (Test_Maps.Element (Position))
& " instead of "
& Integer'Image (Value));
Dump := True;
end if;
if Dump then
Test.Info (Context & ": Map dump " & Image (Map));
end if;
end Check_Map_Value;
begin
declare
Base : constant Test_Maps.Updatable_Map := Sample_Map;
Position : Test_Maps.Cursor;
begin
Check_Map_Not_Value (Base, "Base", 20, "152");
Check_Map_Value
(Test_Maps.Insert (Test_Maps.Empty_Updatable_Map, "1", -1),
"Insert on empty map", 1,
"1", -1);
Check_Map_Value
(Test_Maps.Insert (Base, "152", 152),
"Insert", 21,
"152", 152);
Check_Map_Value
(Base.Include ("21 ", 21),
"Inserting Include", 21,
"21 ", 21);
Check_Map_Value
(Base.Include ("21", -21),
"Replacing Include", 20,
"21", -21);
Check_Map_Value
(Base.Replace ("28", -28),
"Replace", 20,
"28", -28);
Check_Map_Not_Value
(Test_Maps.Delete (Base, "11"),
"Delete", 19, "11");
Check_Map_Not_Value
(Test_Maps.Exclude (Base, "27"),
"Exclude", 19, "27");
Check_Map_Not_Value
(Test_Maps.Exclude (Test_Maps.Empty_Updatable_Map, "23"),
"Empty Exclude", 0, "23");
Check_Map_Value
(Test_Maps.Replace_Element (Base, Base.Find ("12"), -12, Position),
"Replace_Element", 20,
"12", -12);
if Test_Maps.Key (Position) /= "12" then
Test.Fail ("Output Position key is """
& Test_Maps.Key (Position) & """, expected ""12""");
end if;
if Test_Maps.Element (Position) /= -12 then
Test.Fail ("Output Position element is "
& Integer'Image (Test_Maps.Element (Position))
& ", expected -12");
end if;
declare
use type Test_Maps.Updatable_Map;
Derived : constant Test_Maps.Updatable_Map := Base.Exclude ("foo");
begin
if Derived /= Base then
Test.Fail ("No-op Exclude return differing maps");
Test.Info ("Base: " & Image (Base));
Test.Info ("Excluded: " & Image (Derived));
end if;
end;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Update_Constructors;
procedure Update_Constructor_Exceptions
(Report : in out NT.Reporter'Class)
is
Test : NT.Test := Report.Item
("Exceptions raised in ""Update"" constructors");
begin
declare
Map : constant Test_Maps.Updatable_Map := Sample_Map;
Unrelated_Map : constant Test_Maps.Updatable_Map := Sample_Map;
Unrelated_Position : constant Test_Maps.Cursor
:= Unrelated_Map.Find ("19");
Output : Test_Maps.Updatable_Map;
begin
Insert :
declare
Name : constant String := "Insert with used key";
begin
Output := Test_Maps.Insert (Map, "14", -14);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Insert;
Empty_Replace :
declare
Name : constant String := "Replace on empty map";
begin
Output := Test_Maps.Empty_Updatable_Map.Replace ("14", -14);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Empty_Replace;
Replace :
declare
Name : constant String := "Replace with non-existent key";
begin
Output := Map.Replace ("-14", -14);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Replace;
Replace_Element :
declare
Name : constant String := "Replace_Element with empty cursor";
Position : constant Test_Maps.Cursor := Map.Find ("-18");
begin
Output := Test_Maps.Replace_Element (Map, Position, -18);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Replace_Element;
Unrelated_Replace_Element :
declare
Name : constant String := "Replace_Element with unrelated cursor";
begin
Output := Test_Maps.Replace_Element (Map, Unrelated_Position, -1);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Program_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Unrelated_Replace_Element;
Empty_Delete_Key :
declare
Name : constant String := "Delete on empty map";
begin
Output := Test_Maps.Delete (Test_Maps.Empty_Updatable_Map, "24");
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Empty_Delete_Key;
Delete_Key :
declare
Name : constant String := "Delete with non-existent key";
begin
Output := Test_Maps.Delete (Map, "-24");
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Delete_Key;
Delete_Empty_Cursor :
declare
Name : constant String := "Delete with empty cursor";
begin
Output := Test_Maps.Delete (Map, Test_Maps.No_Element);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Constraint_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Delete_Empty_Cursor;
Delete_Unrelated_Cursor :
declare
Name : constant String := "Delete with unrelated cursor";
begin
Output := Test_Maps.Delete (Map, Unrelated_Position);
Test.Fail ("Expected exception in " & Name);
Test.Info ("Result: " & Image (Output));
exception
when Program_Error => null;
when others =>
Test.Fail ("Unexpected exception in " & Name);
end Delete_Unrelated_Cursor;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Update_Constructor_Exceptions;
end Natools.Constant_Indefinite_Ordered_Map_Tests;
|
M:main
F:G$main$0_0$0({2}DF,SV:S),C,0,0,0,0,0
S:G$test$0_0$0({1}SC:U),E,0,0
S:G$main$0_0$0({2}DF,SV:S),C,0,0
|
-- Institution: Technische Universitaet Muenchen
-- Department: Real-Time Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)
-- Martin Becker (becker@rcs.ei.tum.de)
--
-- @summary Servo Actuator frontend
with Units; use Units;
with Config; use Config;
package Servo with SPARK_Mode is
type Servo_Type is (LEFT_ELEVON, RIGHT_ELEVON);
subtype Servo_Angle_Type is Angle_Type range CFG_SERVO_ANGLE_LIMIT_MIN .. CFG_SERVO_ANGLE_LIMIT_MAX;
procedure initialize;
procedure activate;
procedure deactivate;
procedure Set_Critical_Angle (which: Servo_Type; angle : Servo_Angle_Type);
-- call this if the angle is vital at this very moment. It will be restored
-- immediately after a potential in-air reset. this procedure is a bit slower
procedure Set_Angle (which: Servo_Type; angle : Servo_Angle_Type);
-- call this for all other angles, which is faster.
procedure sync;
end Servo;
|
-----------------------------------------------------------------------
-- wiki-plugins-variables -- Variables plugin
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
-- === Variables Plugins ===
-- The `Wiki.Plugins.Variables` package defines a the variables plugin that allows
-- to set or update a variable that will be replaced by the `Wiki.Filters.Variables` filter.
package Wiki.Plugins.Variables is
type Variable_Plugin is new Wiki_Plugin with null record;
-- Set or update a variable in the `Wiki.Filters.Variable` filter.
overriding
procedure Expand (Plugin : in out Variable_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in out Plugin_Context);
type List_Variable_Plugin is new Wiki_Plugin with null record;
-- List the variables from the `Wiki.Filters.Variable` filter.
overriding
procedure Expand (Plugin : in out List_Variable_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in out Plugin_Context);
end Wiki.Plugins.Variables;
|
with Ada.Text_IO; use Ada.Text_IO;
with OLED_SH1106; use OLED_SH1106;
with Interfaces.C; use Interfaces.C;
with Bitmap_Graphics; use Bitmap_Graphics;
procedure AdaOLED is
Center : Point := (64, 32);
P : Point := (10, 10);
Q : Point := (100, 40);
begin
Put_Line ("OLED Display Driver Test");
if Start_Driver then
Init_Display; -- Display initialisation
Clear;
Put(P, "This is a test", 20);
Show;
delay 1.0;
Clear;
Put(P, "This is a TEST", 20, Black, White);
Show;
delay 2.0;
for Size in 1..6 loop
Clear;
Dot(Center, Size*2);
Show;
delay 0.1;
end loop;
delay 1.0;
for X in 0..20 loop
Clear;
Q.X := 20+4*X;
Q.Y := 10+X;
Line(P, Q);
Show;
delay 0.1;
end loop;
delay 1.0;
for X in 0..20 loop
for Y in 0..5 loop
delay 0.05;
Clear;
Q.X := 20+4*X;
Q.Y := 10+X;
Rectangle(P, Q, 2);
Show;
end loop;
end loop;
for X in 0..40 loop
delay 0.1;
Clear;
Q.X := P.X + 2* X;
Q.Y := 60;
Rectangle(P, (P.X+80, Q.Y) );
Fill_Rectangle(P, Q);
Show;
end loop;
delay 2.0;
for R in 0..20 loop
delay 0.4;
Clear;
Circle(Center, R, 3);
Show;
end loop;
for R in 0..20 loop
delay 0.4;
Clear;
Fill_Circle(Center, R);
Show;
end loop;
delay 1.0;
Clear;
Put(Center, 'E', 8);
Show;
delay 1.0;
Clear;
Put(Center, 'F', 12);
Show;
delay 1.0;
Clear;
Put(Center, 'G', 16);
Show;
delay 1.0;
Clear;
Put(Center, 'H', 20, Black, White);
Show;
delay 1.0;
Clear;
Put(Center, 'K', 24, Black, White);
Show;
delay 1.0;
Clear;
Put(Center, 127, 16, Black, White);
Show;
delay 1.0;
Clear;
Put(Center, 1234, 20);
Show;
delay 0.8;
Clear;
Bitmap(Center, Signal);
Show;
delay 0.8;
Clear;
Bitmap(Center, Message);
Show;
delay 10.0;
else
Put_Line ("Driver initialisation failed!");
end if;
Stop_Driver;
end AdaOLED;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . S T R T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Err_Vars; use Err_Vars;
with Prj.Attr; use Prj.Attr;
with Prj.Err; use Prj.Err;
with Snames;
with Table;
with Uintp; use Uintp;
package body Prj.Strt is
Buffer : String_Access;
Buffer_Last : Natural := 0;
type Choice_String is record
The_String : Name_Id;
Already_Used : Boolean := False;
end record;
-- The string of a case label, and an indication that it has already
-- been used (to avoid duplicate case labels).
Choices_Initial : constant := 10;
Choices_Increment : constant := 100;
-- These should be in alloc.ads
Choice_Node_Low_Bound : constant := 0;
Choice_Node_High_Bound : constant := 099_999_999;
-- In practice, infinite
type Choice_Node_Id is
range Choice_Node_Low_Bound .. Choice_Node_High_Bound;
First_Choice_Node_Id : constant Choice_Node_Id :=
Choice_Node_Low_Bound;
package Choices is
new Table.Table
(Table_Component_Type => Choice_String,
Table_Index_Type => Choice_Node_Id'Base,
Table_Low_Bound => First_Choice_Node_Id,
Table_Initial => Choices_Initial,
Table_Increment => Choices_Increment,
Table_Name => "Prj.Strt.Choices");
-- Used to store the case labels and check that there is no duplicate
package Choice_Lasts is
new Table.Table
(Table_Component_Type => Choice_Node_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Prj.Strt.Choice_Lasts");
-- Used to store the indexes of the choices in table Choices, to
-- distinguish nested case constructions.
Choice_First : Choice_Node_Id := 0;
-- Index in table Choices of the first case label of the current
-- case construction. Zero means no current case construction.
type Name_Location is record
Name : Name_Id := No_Name;
Location : Source_Ptr := No_Location;
end record;
-- Store the identifier and the location of a simple name
package Names is
new Table.Table
(Table_Component_Type => Name_Location,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Prj.Strt.Names");
-- Used to accumulate the single names of a name
procedure Add (This_String : Name_Id);
-- Add a string to the case label list, indicating that it has not
-- yet been used.
procedure Add_To_Names (NL : Name_Location);
-- Add one single names to table Names
procedure External_Reference
(In_Tree : Project_Node_Tree_Ref;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
External_Value : out Project_Node_Id;
Expr_Kind : in out Variable_Kind;
Flags : Processing_Flags);
-- Parse an external reference. Current token is "external"
procedure Attribute_Reference
(In_Tree : Project_Node_Tree_Ref;
Reference : out Project_Node_Id;
First_Attribute : Attribute_Node_Id;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
Flags : Processing_Flags);
-- Parse an attribute reference. Current token is an apostrophe
procedure Terms
(In_Tree : Project_Node_Tree_Ref;
Term : out Project_Node_Id;
Expr_Kind : in out Variable_Kind;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
Optional_Index : Boolean;
Flags : Processing_Flags);
-- Recursive procedure to parse one term or several terms concatenated
-- using "&".
---------
-- Add --
---------
procedure Add (This_String : Name_Id) is
begin
Choices.Increment_Last;
Choices.Table (Choices.Last) :=
(The_String => This_String,
Already_Used => False);
end Add;
------------------
-- Add_To_Names --
------------------
procedure Add_To_Names (NL : Name_Location) is
begin
Names.Increment_Last;
Names.Table (Names.Last) := NL;
end Add_To_Names;
-------------------------
-- Attribute_Reference --
-------------------------
procedure Attribute_Reference
(In_Tree : Project_Node_Tree_Ref;
Reference : out Project_Node_Id;
First_Attribute : Attribute_Node_Id;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
Flags : Processing_Flags)
is
Current_Attribute : Attribute_Node_Id := First_Attribute;
begin
-- Declare the node of the attribute reference
Reference :=
Default_Project_Node
(Of_Kind => N_Attribute_Reference, In_Tree => In_Tree);
Set_Location_Of (Reference, In_Tree, To => Token_Ptr);
Scan (In_Tree); -- past apostrophe
-- Body may be an attribute name
if Token = Tok_Body then
Token := Tok_Identifier;
Token_Name := Snames.Name_Body;
end if;
Expect (Tok_Identifier, "identifier");
if Token = Tok_Identifier then
Set_Name_Of (Reference, In_Tree, To => Token_Name);
-- Check if the identifier is one of the attribute identifiers in the
-- context (package or project level attributes).
Current_Attribute :=
Attribute_Node_Id_Of (Token_Name, Starting_At => First_Attribute);
-- If the identifier is not allowed, report an error
if Current_Attribute = Empty_Attribute then
Error_Msg_Name_1 := Token_Name;
Error_Msg (Flags, "unknown attribute %%", Token_Ptr);
Reference := Empty_Node;
-- Scan past the attribute name
Scan (In_Tree);
-- Skip a possible index for an associative array
if Token = Tok_Left_Paren then
Scan (In_Tree);
if Token = Tok_String_Literal then
Scan (In_Tree);
if Token = Tok_Right_Paren then
Scan (In_Tree);
end if;
end if;
end if;
else
-- Give its characteristics to this attribute reference
Set_Project_Node_Of (Reference, In_Tree, To => Current_Project);
Set_Package_Node_Of (Reference, In_Tree, To => Current_Package);
Set_Expression_Kind_Of
(Reference, In_Tree, To => Variable_Kind_Of (Current_Attribute));
Set_Case_Insensitive
(Reference, In_Tree,
To => Attribute_Kind_Of (Current_Attribute) in
All_Case_Insensitive_Associative_Array);
Set_Default_Of
(Reference, In_Tree,
To => Attribute_Default_Of (Current_Attribute));
-- Scan past the attribute name
Scan (In_Tree);
-- If the attribute is an associative array, get the index
if Attribute_Kind_Of (Current_Attribute) /= Single then
Expect (Tok_Left_Paren, "`(`");
if Token = Tok_Left_Paren then
Scan (In_Tree);
if Others_Allowed_For (Current_Attribute)
and then Token = Tok_Others
then
Set_Associative_Array_Index_Of
(Reference, In_Tree, To => All_Other_Names);
Scan (In_Tree);
else
if Others_Allowed_For (Current_Attribute) then
Expect
(Tok_String_Literal, "literal string or others");
else
Expect (Tok_String_Literal, "literal string");
end if;
if Token = Tok_String_Literal then
Set_Associative_Array_Index_Of
(Reference, In_Tree, To => Token_Name);
Scan (In_Tree);
end if;
end if;
end if;
Expect (Tok_Right_Paren, "`)`");
if Token = Tok_Right_Paren then
Scan (In_Tree);
end if;
end if;
end if;
-- Change name of obsolete attributes
if Present (Reference) then
case Name_Of (Reference, In_Tree) is
when Snames.Name_Specification =>
Set_Name_Of (Reference, In_Tree, To => Snames.Name_Spec);
when Snames.Name_Specification_Suffix =>
Set_Name_Of
(Reference, In_Tree, To => Snames.Name_Spec_Suffix);
when Snames.Name_Implementation =>
Set_Name_Of (Reference, In_Tree, To => Snames.Name_Body);
when Snames.Name_Implementation_Suffix =>
Set_Name_Of
(Reference, In_Tree, To => Snames.Name_Body_Suffix);
when others =>
null;
end case;
end if;
end if;
end Attribute_Reference;
---------------------------
-- End_Case_Construction --
---------------------------
procedure End_Case_Construction
(Check_All_Labels : Boolean;
Case_Location : Source_Ptr;
Flags : Processing_Flags;
String_Type : Boolean)
is
Non_Used : Natural := 0;
First_Non_Used : Choice_Node_Id := First_Choice_Node_Id;
begin
-- First, if Check_All_Labels is True, check if all values of the string
-- type have been used.
if Check_All_Labels then
if String_Type then
for Choice in Choice_First .. Choices.Last loop
if not Choices.Table (Choice).Already_Used then
Non_Used := Non_Used + 1;
if Non_Used = 1 then
First_Non_Used := Choice;
end if;
end if;
end loop;
-- If only one is not used, report a single warning for this value
if Non_Used = 1 then
Error_Msg_Name_1 := Choices.Table (First_Non_Used).The_String;
Error_Msg
(Flags, "?value %% is not used as label", Case_Location);
-- If several are not used, report a warning for each one of them
elsif Non_Used > 1 then
Error_Msg
(Flags, "?the following values are not used as labels:",
Case_Location);
for Choice in First_Non_Used .. Choices.Last loop
if not Choices.Table (Choice).Already_Used then
Error_Msg_Name_1 := Choices.Table (Choice).The_String;
Error_Msg (Flags, "\?%%", Case_Location);
end if;
end loop;
end if;
else
Error_Msg
(Flags,
"?no when others for this case construction",
Case_Location);
end if;
end if;
-- If this is the only case construction, empty the tables
if Choice_Lasts.Last = 1 then
Choice_Lasts.Set_Last (0);
Choices.Set_Last (First_Choice_Node_Id);
Choice_First := 0;
-- Second case construction, set the tables to the first
elsif Choice_Lasts.Last = 2 then
Choice_Lasts.Set_Last (1);
Choices.Set_Last (Choice_Lasts.Table (1));
Choice_First := 1;
-- Third or more case construction, set the tables to the previous one
else
Choice_Lasts.Decrement_Last;
Choices.Set_Last (Choice_Lasts.Table (Choice_Lasts.Last));
Choice_First := Choice_Lasts.Table (Choice_Lasts.Last - 1) + 1;
end if;
end End_Case_Construction;
------------------------
-- External_Reference --
------------------------
procedure External_Reference
(In_Tree : Project_Node_Tree_Ref;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
External_Value : out Project_Node_Id;
Expr_Kind : in out Variable_Kind;
Flags : Processing_Flags)
is
Field_Id : Project_Node_Id := Empty_Node;
Ext_List : Boolean := False;
begin
External_Value :=
Default_Project_Node
(Of_Kind => N_External_Value,
In_Tree => In_Tree);
Set_Location_Of (External_Value, In_Tree, To => Token_Ptr);
-- The current token is either external or external_as_list
Ext_List := Token = Tok_External_As_List;
Scan (In_Tree);
if Ext_List then
Set_Expression_Kind_Of (External_Value, In_Tree, To => List);
else
Set_Expression_Kind_Of (External_Value, In_Tree, To => Single);
end if;
if Expr_Kind = Undefined then
if Ext_List then
Expr_Kind := List;
else
Expr_Kind := Single;
end if;
end if;
Expect (Tok_Left_Paren, "`(`");
-- Scan past the left parenthesis
if Token = Tok_Left_Paren then
Scan (In_Tree);
end if;
-- Get the name of the external reference
Expect (Tok_String_Literal, "literal string");
if Token = Tok_String_Literal then
Field_Id :=
Default_Project_Node
(Of_Kind => N_Literal_String,
In_Tree => In_Tree,
And_Expr_Kind => Single);
Set_String_Value_Of (Field_Id, In_Tree, To => Token_Name);
Set_External_Reference_Of (External_Value, In_Tree, To => Field_Id);
-- Scan past the first argument
Scan (In_Tree);
case Token is
when Tok_Right_Paren =>
if Ext_List then
Error_Msg (Flags, "`,` expected", Token_Ptr);
end if;
Scan (In_Tree); -- scan past right paren
when Tok_Comma =>
Scan (In_Tree); -- scan past comma
-- Get the string expression for the default
declare
Loc : constant Source_Ptr := Token_Ptr;
begin
Parse_Expression
(In_Tree => In_Tree,
Expression => Field_Id,
Flags => Flags,
Current_Project => Current_Project,
Current_Package => Current_Package,
Optional_Index => False);
if Expression_Kind_Of (Field_Id, In_Tree) = List then
Error_Msg
(Flags, "expression must be a single string", Loc);
else
Set_External_Default_Of
(External_Value, In_Tree, To => Field_Id);
end if;
end;
Expect (Tok_Right_Paren, "`)`");
if Token = Tok_Right_Paren then
Scan (In_Tree); -- scan past right paren
end if;
when others =>
if Ext_List then
Error_Msg (Flags, "`,` expected", Token_Ptr);
else
Error_Msg (Flags, "`,` or `)` expected", Token_Ptr);
end if;
end case;
end if;
end External_Reference;
-----------------------
-- Parse_Choice_List --
-----------------------
procedure Parse_Choice_List
(In_Tree : Project_Node_Tree_Ref;
First_Choice : out Project_Node_Id;
Flags : Processing_Flags;
String_Type : Boolean := True)
is
Current_Choice : Project_Node_Id := Empty_Node;
Next_Choice : Project_Node_Id := Empty_Node;
Choice_String : Name_Id := No_Name;
Found : Boolean := False;
begin
-- Declare the node of the first choice
First_Choice :=
Default_Project_Node
(Of_Kind => N_Literal_String,
In_Tree => In_Tree,
And_Expr_Kind => Single);
-- Initially Current_Choice is the same as First_Choice
Current_Choice := First_Choice;
loop
Expect (Tok_String_Literal, "literal string");
exit when Token /= Tok_String_Literal;
Set_Location_Of (Current_Choice, In_Tree, To => Token_Ptr);
Choice_String := Token_Name;
-- Give the string value to the current choice
Set_String_Value_Of (Current_Choice, In_Tree, To => Choice_String);
if String_Type then
-- Check if the label is part of the string type and if it has not
-- been already used.
Found := False;
for Choice in Choice_First .. Choices.Last loop
if Choices.Table (Choice).The_String = Choice_String then
-- This label is part of the string type
Found := True;
if Choices.Table (Choice).Already_Used then
-- But it has already appeared in a choice list for this
-- case construction so report an error.
Error_Msg_Name_1 := Choice_String;
Error_Msg (Flags, "duplicate case label %%", Token_Ptr);
else
Choices.Table (Choice).Already_Used := True;
end if;
exit;
end if;
end loop;
-- If the label is not part of the string list, report an error
if not Found then
Error_Msg_Name_1 := Choice_String;
Error_Msg (Flags, "illegal case label %%", Token_Ptr);
end if;
end if;
-- Scan past the label
Scan (In_Tree);
-- If there is no '|', we are done
if Token = Tok_Vertical_Bar then
-- Otherwise, declare the node of the next choice, link it to
-- Current_Choice and set Current_Choice to this new node.
Next_Choice :=
Default_Project_Node
(Of_Kind => N_Literal_String,
In_Tree => In_Tree,
And_Expr_Kind => Single);
Set_Next_Literal_String
(Current_Choice, In_Tree, To => Next_Choice);
Current_Choice := Next_Choice;
Scan (In_Tree);
else
exit;
end if;
end loop;
end Parse_Choice_List;
----------------------
-- Parse_Expression --
----------------------
procedure Parse_Expression
(In_Tree : Project_Node_Tree_Ref;
Expression : out Project_Node_Id;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
Optional_Index : Boolean;
Flags : Processing_Flags)
is
First_Term : Project_Node_Id := Empty_Node;
Expression_Kind : Variable_Kind := Undefined;
begin
-- Declare the node of the expression
Expression :=
Default_Project_Node (Of_Kind => N_Expression, In_Tree => In_Tree);
Set_Location_Of (Expression, In_Tree, To => Token_Ptr);
-- Parse the term or terms of the expression
Terms (In_Tree => In_Tree,
Term => First_Term,
Expr_Kind => Expression_Kind,
Flags => Flags,
Current_Project => Current_Project,
Current_Package => Current_Package,
Optional_Index => Optional_Index);
-- Set the first term and the expression kind
Set_First_Term (Expression, In_Tree, To => First_Term);
Set_Expression_Kind_Of (Expression, In_Tree, To => Expression_Kind);
end Parse_Expression;
----------------------------
-- Parse_String_Type_List --
----------------------------
procedure Parse_String_Type_List
(In_Tree : Project_Node_Tree_Ref;
First_String : out Project_Node_Id;
Flags : Processing_Flags)
is
Last_String : Project_Node_Id := Empty_Node;
Next_String : Project_Node_Id := Empty_Node;
String_Value : Name_Id := No_Name;
begin
-- Declare the node of the first string
First_String :=
Default_Project_Node
(Of_Kind => N_Literal_String,
In_Tree => In_Tree,
And_Expr_Kind => Single);
-- Initially, Last_String is the same as First_String
Last_String := First_String;
loop
Expect (Tok_String_Literal, "literal string");
exit when Token /= Tok_String_Literal;
String_Value := Token_Name;
-- Give its string value to Last_String
Set_String_Value_Of (Last_String, In_Tree, To => String_Value);
Set_Location_Of (Last_String, In_Tree, To => Token_Ptr);
-- Now, check if the string is already part of the string type
declare
Current : Project_Node_Id := First_String;
begin
while Current /= Last_String loop
if String_Value_Of (Current, In_Tree) = String_Value then
-- This is a repetition, report an error
Error_Msg_Name_1 := String_Value;
Error_Msg (Flags, "duplicate value %% in type", Token_Ptr);
exit;
end if;
Current := Next_Literal_String (Current, In_Tree);
end loop;
end;
-- Scan past the literal string
Scan (In_Tree);
-- If there is no comma following the literal string, we are done
if Token /= Tok_Comma then
exit;
else
-- Declare the next string, link it to Last_String and set
-- Last_String to its node.
Next_String :=
Default_Project_Node
(Of_Kind => N_Literal_String,
In_Tree => In_Tree,
And_Expr_Kind => Single);
Set_Next_Literal_String (Last_String, In_Tree, To => Next_String);
Last_String := Next_String;
Scan (In_Tree);
end if;
end loop;
end Parse_String_Type_List;
------------------------------
-- Parse_Variable_Reference --
------------------------------
procedure Parse_Variable_Reference
(In_Tree : Project_Node_Tree_Ref;
Variable : out Project_Node_Id;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
Flags : Processing_Flags)
is
Current_Variable : Project_Node_Id := Empty_Node;
The_Package : Project_Node_Id := Current_Package;
The_Project : Project_Node_Id := Current_Project;
Specified_Project : Project_Node_Id := Empty_Node;
Specified_Package : Project_Node_Id := Empty_Node;
Look_For_Variable : Boolean := True;
First_Attribute : Attribute_Node_Id := Empty_Attribute;
Variable_Name : Name_Id;
begin
Names.Init;
loop
Expect (Tok_Identifier, "identifier");
if Token /= Tok_Identifier then
Look_For_Variable := False;
exit;
end if;
Add_To_Names (NL => (Name => Token_Name, Location => Token_Ptr));
Scan (In_Tree);
exit when Token /= Tok_Dot;
Scan (In_Tree);
end loop;
if Look_For_Variable then
if Token = Tok_Apostrophe then
-- Attribute reference
case Names.Last is
when 0 =>
-- Cannot happen
null;
when 1 =>
-- This may be a project name or a package name.
-- Project name have precedence.
-- First, look if it can be a package name
First_Attribute :=
First_Attribute_Of
(Package_Node_Id_Of (Names.Table (1).Name));
-- Now, look if it can be a project name
if Names.Table (1).Name =
Name_Of (Current_Project, In_Tree)
then
The_Project := Current_Project;
else
The_Project :=
Imported_Or_Extended_Project_Of
(Current_Project, In_Tree, Names.Table (1).Name);
end if;
if No (The_Project) then
-- If it is neither a project name nor a package name,
-- report an error.
if First_Attribute = Empty_Attribute then
Error_Msg_Name_1 := Names.Table (1).Name;
Error_Msg (Flags, "unknown project %",
Names.Table (1).Location);
First_Attribute := Attribute_First;
else
-- If it is a package name, check if the package has
-- already been declared in the current project.
The_Package :=
First_Package_Of (Current_Project, In_Tree);
while Present (The_Package)
and then Name_Of (The_Package, In_Tree) /=
Names.Table (1).Name
loop
The_Package :=
Next_Package_In_Project (The_Package, In_Tree);
end loop;
-- If it has not been already declared, report an
-- error.
if No (The_Package) then
Error_Msg_Name_1 := Names.Table (1).Name;
Error_Msg (Flags, "package % not yet defined",
Names.Table (1).Location);
end if;
end if;
else
-- It is a project name
First_Attribute := Attribute_First;
The_Package := Empty_Node;
end if;
when others =>
-- We have either a project name made of several simple
-- names (long project), or a project name (short project)
-- followed by a package name. The long project name has
-- precedence.
declare
Short_Project : Name_Id;
Long_Project : Name_Id;
begin
-- Clear the Buffer
Buffer_Last := 0;
-- Get the name of the short project
for Index in 1 .. Names.Last - 1 loop
Add_To_Buffer
(Get_Name_String (Names.Table (Index).Name),
Buffer, Buffer_Last);
if Index /= Names.Last - 1 then
Add_To_Buffer (".", Buffer, Buffer_Last);
end if;
end loop;
Name_Len := Buffer_Last;
Name_Buffer (1 .. Buffer_Last) :=
Buffer (1 .. Buffer_Last);
Short_Project := Name_Find;
-- Now, add the last simple name to get the name of the
-- long project.
Add_To_Buffer (".", Buffer, Buffer_Last);
Add_To_Buffer
(Get_Name_String (Names.Table (Names.Last).Name),
Buffer, Buffer_Last);
Name_Len := Buffer_Last;
Name_Buffer (1 .. Buffer_Last) :=
Buffer (1 .. Buffer_Last);
Long_Project := Name_Find;
-- Check if the long project is imported or extended
if Long_Project = Name_Of (Current_Project, In_Tree) then
The_Project := Current_Project;
else
The_Project :=
Imported_Or_Extended_Project_Of
(Current_Project,
In_Tree,
Long_Project);
end if;
-- If the long project exists, then this is the prefix
-- of the attribute.
if Present (The_Project) then
First_Attribute := Attribute_First;
The_Package := Empty_Node;
else
-- Otherwise, check if the short project is imported
-- or extended.
if Short_Project =
Name_Of (Current_Project, In_Tree)
then
The_Project := Current_Project;
else
The_Project := Imported_Or_Extended_Project_Of
(Current_Project, In_Tree,
Short_Project);
end if;
-- If short project does not exist, report an error
if No (The_Project) then
Error_Msg_Name_1 := Long_Project;
Error_Msg_Name_2 := Short_Project;
Error_Msg (Flags, "unknown projects % or %",
Names.Table (1).Location);
The_Package := Empty_Node;
First_Attribute := Attribute_First;
else
-- Now, we check if the package has been declared
-- in this project.
The_Package :=
First_Package_Of (The_Project, In_Tree);
while Present (The_Package)
and then Name_Of (The_Package, In_Tree) /=
Names.Table (Names.Last).Name
loop
The_Package :=
Next_Package_In_Project (The_Package, In_Tree);
end loop;
-- If it has not, then we report an error
if No (The_Package) then
Error_Msg_Name_1 :=
Names.Table (Names.Last).Name;
Error_Msg_Name_2 := Short_Project;
Error_Msg (Flags,
"package % not declared in project %",
Names.Table (Names.Last).Location);
First_Attribute := Attribute_First;
else
-- Otherwise, we have the correct project and
-- package.
First_Attribute :=
First_Attribute_Of
(Package_Id_Of (The_Package, In_Tree));
end if;
end if;
end if;
end;
end case;
Attribute_Reference
(In_Tree,
Variable,
Flags => Flags,
Current_Project => The_Project,
Current_Package => The_Package,
First_Attribute => First_Attribute);
return;
end if;
end if;
Variable :=
Default_Project_Node
(Of_Kind => N_Variable_Reference, In_Tree => In_Tree);
if Look_For_Variable then
case Names.Last is
when 0 =>
-- Cannot happen (so why null instead of raise PE???)
null;
when 1 =>
-- Simple variable name
Set_Name_Of (Variable, In_Tree, To => Names.Table (1).Name);
when 2 =>
-- Variable name with a simple name prefix that can be
-- a project name or a package name. Project names have
-- priority over package names.
Set_Name_Of (Variable, In_Tree, To => Names.Table (2).Name);
-- Check if it can be a package name
The_Package := First_Package_Of (Current_Project, In_Tree);
while Present (The_Package)
and then Name_Of (The_Package, In_Tree) /=
Names.Table (1).Name
loop
The_Package :=
Next_Package_In_Project (The_Package, In_Tree);
end loop;
-- Now look for a possible project name
The_Project := Imported_Or_Extended_Project_Of
(Current_Project, In_Tree, Names.Table (1).Name);
if Present (The_Project) then
Specified_Project := The_Project;
elsif No (The_Package) then
Error_Msg_Name_1 := Names.Table (1).Name;
Error_Msg (Flags, "unknown package or project %",
Names.Table (1).Location);
Look_For_Variable := False;
else
Specified_Package := The_Package;
end if;
when others =>
-- Variable name with a prefix that is either a project name
-- made of several simple names, or a project name followed
-- by a package name.
Set_Name_Of
(Variable, In_Tree, To => Names.Table (Names.Last).Name);
declare
Short_Project : Name_Id;
Long_Project : Name_Id;
begin
-- First, we get the two possible project names
-- Clear the buffer
Buffer_Last := 0;
-- Add all the simple names, except the last two
for Index in 1 .. Names.Last - 2 loop
Add_To_Buffer
(Get_Name_String (Names.Table (Index).Name),
Buffer, Buffer_Last);
if Index /= Names.Last - 2 then
Add_To_Buffer (".", Buffer, Buffer_Last);
end if;
end loop;
Name_Len := Buffer_Last;
Name_Buffer (1 .. Name_Len) := Buffer (1 .. Buffer_Last);
Short_Project := Name_Find;
-- Add the simple name before the name of the variable
Add_To_Buffer (".", Buffer, Buffer_Last);
Add_To_Buffer
(Get_Name_String (Names.Table (Names.Last - 1).Name),
Buffer, Buffer_Last);
Name_Len := Buffer_Last;
Name_Buffer (1 .. Name_Len) := Buffer (1 .. Buffer_Last);
Long_Project := Name_Find;
-- Check if the prefix is the name of an imported or
-- extended project.
The_Project := Imported_Or_Extended_Project_Of
(Current_Project, In_Tree, Long_Project);
if Present (The_Project) then
Specified_Project := The_Project;
else
-- Now check if the prefix may be a project name followed
-- by a package name.
-- First check for a possible project name
The_Project :=
Imported_Or_Extended_Project_Of
(Current_Project, In_Tree, Short_Project);
if No (The_Project) then
-- Unknown prefix, report an error
Error_Msg_Name_1 := Long_Project;
Error_Msg_Name_2 := Short_Project;
Error_Msg
(Flags, "unknown projects % or %",
Names.Table (1).Location);
Look_For_Variable := False;
else
Specified_Project := The_Project;
-- Now look for the package in this project
The_Package := First_Package_Of (The_Project, In_Tree);
while Present (The_Package)
and then Name_Of (The_Package, In_Tree) /=
Names.Table (Names.Last - 1).Name
loop
The_Package :=
Next_Package_In_Project (The_Package, In_Tree);
end loop;
if No (The_Package) then
-- The package does not exist, report an error
Error_Msg_Name_1 := Names.Table (2).Name;
Error_Msg (Flags, "unknown package %",
Names.Table (Names.Last - 1).Location);
Look_For_Variable := False;
else
Specified_Package := The_Package;
end if;
end if;
end if;
end;
end case;
end if;
if Look_For_Variable then
Variable_Name := Name_Of (Variable, In_Tree);
Set_Project_Node_Of (Variable, In_Tree, To => Specified_Project);
Set_Package_Node_Of (Variable, In_Tree, To => Specified_Package);
if Present (Specified_Project) then
The_Project := Specified_Project;
else
The_Project := Current_Project;
end if;
Current_Variable := Empty_Node;
-- Look for this variable
-- If a package was specified, check if the variable has been
-- declared in this package.
if Present (Specified_Package) then
Current_Variable :=
First_Variable_Of (Specified_Package, In_Tree);
while Present (Current_Variable)
and then
Name_Of (Current_Variable, In_Tree) /= Variable_Name
loop
Current_Variable := Next_Variable (Current_Variable, In_Tree);
end loop;
else
-- Otherwise, if no project has been specified and we are in
-- a package, first check if the variable has been declared in
-- the package.
if No (Specified_Project)
and then Present (Current_Package)
then
Current_Variable :=
First_Variable_Of (Current_Package, In_Tree);
while Present (Current_Variable)
and then Name_Of (Current_Variable, In_Tree) /= Variable_Name
loop
Current_Variable :=
Next_Variable (Current_Variable, In_Tree);
end loop;
end if;
-- If we have not found the variable in the package, check if the
-- variable has been declared in the project, or in any of its
-- ancestors, or in any of the project it extends.
if No (Current_Variable) then
declare
Proj : Project_Node_Id := The_Project;
begin
loop
Current_Variable := First_Variable_Of (Proj, In_Tree);
while
Present (Current_Variable)
and then
Name_Of (Current_Variable, In_Tree) /= Variable_Name
loop
Current_Variable :=
Next_Variable (Current_Variable, In_Tree);
end loop;
exit when Present (Current_Variable);
-- If the current project is a child project, check if
-- the variable is declared in its parent. Otherwise, if
-- the current project extends another project, check if
-- the variable is declared in one of the projects the
-- current project extends.
if No (Parent_Project_Of (Proj, In_Tree)) then
Proj :=
Extended_Project_Of
(Project_Declaration_Of (Proj, In_Tree), In_Tree);
else
Proj := Parent_Project_Of (Proj, In_Tree);
end if;
Set_Project_Node_Of (Variable, In_Tree, To => Proj);
exit when No (Proj);
end loop;
end;
end if;
end if;
-- If the variable was not found, report an error
if No (Current_Variable) then
Error_Msg_Name_1 := Variable_Name;
Error_Msg
(Flags, "unknown variable %", Names.Table (Names.Last).Location);
end if;
end if;
if Present (Current_Variable) then
Set_Expression_Kind_Of
(Variable, In_Tree,
To => Expression_Kind_Of (Current_Variable, In_Tree));
if Kind_Of (Current_Variable, In_Tree) =
N_Typed_Variable_Declaration
then
Set_String_Type_Of
(Variable, In_Tree,
To => String_Type_Of (Current_Variable, In_Tree));
end if;
end if;
-- If the variable is followed by a left parenthesis, report an error
-- but attempt to scan the index.
if Token = Tok_Left_Paren then
Error_Msg
(Flags, "\variables cannot be associative arrays", Token_Ptr);
Scan (In_Tree);
Expect (Tok_String_Literal, "literal string");
if Token = Tok_String_Literal then
Scan (In_Tree);
Expect (Tok_Right_Paren, "`)`");
if Token = Tok_Right_Paren then
Scan (In_Tree);
end if;
end if;
end if;
end Parse_Variable_Reference;
---------------------------------
-- Start_New_Case_Construction --
---------------------------------
procedure Start_New_Case_Construction
(In_Tree : Project_Node_Tree_Ref;
String_Type : Project_Node_Id)
is
Current_String : Project_Node_Id;
begin
-- Set Choice_First, depending on whether this is the first case
-- construction or not.
if Choice_First = 0 then
Choice_First := 1;
Choices.Set_Last (First_Choice_Node_Id);
else
Choice_First := Choices.Last + 1;
end if;
-- Add the literal of the string type to the Choices table
if Present (String_Type) then
Current_String := First_Literal_String (String_Type, In_Tree);
while Present (Current_String) loop
Add (This_String => String_Value_Of (Current_String, In_Tree));
Current_String := Next_Literal_String (Current_String, In_Tree);
end loop;
end if;
-- Set the value of the last choice in table Choice_Lasts
Choice_Lasts.Increment_Last;
Choice_Lasts.Table (Choice_Lasts.Last) := Choices.Last;
end Start_New_Case_Construction;
-----------
-- Terms --
-----------
procedure Terms
(In_Tree : Project_Node_Tree_Ref;
Term : out Project_Node_Id;
Expr_Kind : in out Variable_Kind;
Current_Project : Project_Node_Id;
Current_Package : Project_Node_Id;
Optional_Index : Boolean;
Flags : Processing_Flags)
is
Next_Term : Project_Node_Id := Empty_Node;
Term_Id : Project_Node_Id := Empty_Node;
Current_Expression : Project_Node_Id := Empty_Node;
Next_Expression : Project_Node_Id := Empty_Node;
Current_Location : Source_Ptr := No_Location;
Reference : Project_Node_Id := Empty_Node;
begin
-- Declare a new node for the term
Term := Default_Project_Node (Of_Kind => N_Term, In_Tree => In_Tree);
Set_Location_Of (Term, In_Tree, To => Token_Ptr);
case Token is
when Tok_Left_Paren =>
-- If we have a left parenthesis and we don't know the expression
-- kind, then this is a string list.
case Expr_Kind is
when Undefined =>
Expr_Kind := List;
when List =>
null;
when Single =>
-- If we already know that this is a single string, report
-- an error, but set the expression kind to string list to
-- avoid several errors.
Expr_Kind := List;
Error_Msg
(Flags, "literal string list cannot appear in a string",
Token_Ptr);
end case;
-- Declare a new node for this literal string list
Term_Id := Default_Project_Node
(Of_Kind => N_Literal_String_List,
In_Tree => In_Tree,
And_Expr_Kind => List);
Set_Current_Term (Term, In_Tree, To => Term_Id);
Set_Location_Of (Term, In_Tree, To => Token_Ptr);
-- Scan past the left parenthesis
Scan (In_Tree);
-- If the left parenthesis is immediately followed by a right
-- parenthesis, the literal string list is empty.
if Token = Tok_Right_Paren then
Scan (In_Tree);
else
-- Otherwise parse the expression(s) in the literal string list
loop
Current_Location := Token_Ptr;
Parse_Expression
(In_Tree => In_Tree,
Expression => Next_Expression,
Flags => Flags,
Current_Project => Current_Project,
Current_Package => Current_Package,
Optional_Index => Optional_Index);
-- The expression kind is String list, report an error
if Expression_Kind_Of (Next_Expression, In_Tree) = List then
Error_Msg (Flags, "single expression expected",
Current_Location);
end if;
-- If Current_Expression is empty, it means that the
-- expression is the first in the string list.
if No (Current_Expression) then
Set_First_Expression_In_List
(Term_Id, In_Tree, To => Next_Expression);
else
Set_Next_Expression_In_List
(Current_Expression, In_Tree, To => Next_Expression);
end if;
Current_Expression := Next_Expression;
-- If there is a comma, continue with the next expression
exit when Token /= Tok_Comma;
Scan (In_Tree); -- past the comma
end loop;
-- We expect a closing right parenthesis
Expect (Tok_Right_Paren, "`)`");
if Token = Tok_Right_Paren then
Scan (In_Tree);
end if;
end if;
when Tok_String_Literal =>
-- If we don't know the expression kind (first term), then it is
-- a simple string.
if Expr_Kind = Undefined then
Expr_Kind := Single;
end if;
-- Declare a new node for the string literal
Term_Id :=
Default_Project_Node
(Of_Kind => N_Literal_String, In_Tree => In_Tree);
Set_Current_Term (Term, In_Tree, To => Term_Id);
Set_String_Value_Of (Term_Id, In_Tree, To => Token_Name);
-- Scan past the string literal
Scan (In_Tree);
-- Check for possible index expression
if Token = Tok_At then
if not Optional_Index then
Error_Msg (Flags, "index not allowed here", Token_Ptr);
Scan (In_Tree);
if Token = Tok_Integer_Literal then
Scan (In_Tree);
end if;
-- Set the index value
else
Scan (In_Tree);
Expect (Tok_Integer_Literal, "integer literal");
if Token = Tok_Integer_Literal then
declare
Index : constant Int := UI_To_Int (Int_Literal_Value);
begin
if Index = 0 then
Error_Msg
(Flags, "index cannot be zero", Token_Ptr);
else
Set_Source_Index_Of
(Term_Id, In_Tree, To => Index);
end if;
end;
Scan (In_Tree);
end if;
end if;
end if;
when Tok_Identifier =>
Current_Location := Token_Ptr;
-- Get the variable or attribute reference
Parse_Variable_Reference
(In_Tree => In_Tree,
Variable => Reference,
Flags => Flags,
Current_Project => Current_Project,
Current_Package => Current_Package);
Set_Current_Term (Term, In_Tree, To => Reference);
if Present (Reference) then
-- If we don't know the expression kind (first term), then it
-- has the kind of the variable or attribute reference.
if Expr_Kind = Undefined then
Expr_Kind := Expression_Kind_Of (Reference, In_Tree);
elsif Expr_Kind = Single
and then Expression_Kind_Of (Reference, In_Tree) = List
then
-- If the expression is a single list, and the reference is
-- a string list, report an error, and set the expression
-- kind to string list to avoid multiple errors.
Expr_Kind := List;
Error_Msg
(Flags,
"list variable cannot appear in single string expression",
Current_Location);
end if;
end if;
when Tok_Project =>
-- Project can appear in an expression as the prefix of an
-- attribute reference of the current project.
Current_Location := Token_Ptr;
Scan (In_Tree);
Expect (Tok_Apostrophe, "`'`");
if Token = Tok_Apostrophe then
Attribute_Reference
(In_Tree => In_Tree,
Reference => Reference,
Flags => Flags,
First_Attribute => Prj.Attr.Attribute_First,
Current_Project => Current_Project,
Current_Package => Empty_Node);
Set_Current_Term (Term, In_Tree, To => Reference);
end if;
-- Same checks as above for the expression kind
if Present (Reference) then
if Expr_Kind = Undefined then
Expr_Kind := Expression_Kind_Of (Reference, In_Tree);
elsif Expr_Kind = Single
and then Expression_Kind_Of (Reference, In_Tree) = List
then
Error_Msg
(Flags, "lists cannot appear in single string expression",
Current_Location);
end if;
end if;
when Tok_External
| Tok_External_As_List
=>
External_Reference
(In_Tree => In_Tree,
Flags => Flags,
Current_Project => Current_Project,
Current_Package => Current_Package,
Expr_Kind => Expr_Kind,
External_Value => Reference);
Set_Current_Term (Term, In_Tree, To => Reference);
when others =>
Error_Msg (Flags, "cannot be part of an expression", Token_Ptr);
Term := Empty_Node;
return;
end case;
-- If there is an '&', call Terms recursively
if Token = Tok_Ampersand then
Scan (In_Tree); -- scan past ampersand
Terms
(In_Tree => In_Tree,
Term => Next_Term,
Expr_Kind => Expr_Kind,
Flags => Flags,
Current_Project => Current_Project,
Current_Package => Current_Package,
Optional_Index => Optional_Index);
-- And link the next term to this term
Set_Next_Term (Term, In_Tree, To => Next_Term);
end if;
end Terms;
end Prj.Strt;
|
package Opt46 is
type Session_Type is limited private;
procedure Close (Session : Session_Type);
private
type Session_Data;
type Session_Data_Access is access Session_Data;
type Session_Type is record
Data : Session_Data_Access;
end record;
end Opt46;
|
package Problem_68 is
-- Consider the following "magic" 3-gon ring, filled with the numbers 1 to 6, and each line adding to nine.
-- 4
-- 3
-- 1 2 6
-- 5
--
-- Working clockwise, and starting from the group of three with the numerically lowest external
-- node (4,3,2 in this example), each solution can be described uniquely. For example, the above
-- solution can be described by the set: 4,3,2; 6,2,1; 5,1,3.
--
-- It is possible to complete the ring with four different totals: 9, 10, 11, and 12. There are
-- eight solutions in total.
-- By concatenating each group it is possible to form 9-digit strings; the maximum string for a
-- 3-gon ring is 432621513.
--
-- Using the numbers 1 to 10, and depending on arrangements, it is possible to form 16- and
-- 17-digit strings. What is the maximum 16-digit string for a "magic" 5-gon ring?
procedure Solve;
end Problem_68;
|
-- REST API Validation
-- API to validate
-- ------------ EDIT NOTE ------------
-- This file was generated with swagger-codegen. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .swagger-codegen-ignore file:
--
-- src/testapi-servers.ads
--
-- Then, you can drop this edit note comment.
-- ------------ EDIT NOTE ------------
with Swagger.Servers;
with TestAPI.Models;
with TestAPI.Skeletons;
package TestAPI.Servers is
use TestAPI.Models;
type Server_Type is limited new TestAPI.Skeletons.Server_Type with record
Todos : TestAPI.Models.Ticket_Type_Vectors.Vector;
Last_Id : Swagger.Long := 0;
end record;
-- Create a ticket
overriding
procedure Do_Create_Ticket
(Server : in out Server_Type;
Title : in Swagger.UString;
Owner : in Swagger.Nullable_UString;
Status : in Swagger.Nullable_UString;
Description : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
-- Delete a ticket
overriding
procedure Do_Delete_Ticket
(Server : in out Server_Type;
Tid : in Swagger.Long;
Context : in out Swagger.Servers.Context_Type);
-- Patch a ticket
overriding
procedure Do_Patch_Ticket
(Server : in out Server_Type;
Tid : in Swagger.Long;
Owner : in Swagger.Nullable_UString;
Status : in Swagger.Nullable_UString;
Title : in Swagger.Nullable_UString;
Description : in Swagger.Nullable_UString;
Result : out TestAPI.Models.Ticket_Type;
Context : in out Swagger.Servers.Context_Type);
-- Update a ticket
overriding
procedure Do_Update_Ticket
(Server : in out Server_Type;
Tid : in Swagger.Long;
Owner : in Swagger.Nullable_UString;
Status : in Swagger.Nullable_UString;
Title : in Swagger.Nullable_UString;
Description : in Swagger.Nullable_UString;
Result : out TestAPI.Models.Ticket_Type;
Context : in out Swagger.Servers.Context_Type);
-- Get a ticket
-- Get a ticket
overriding
procedure Do_Get_Ticket
(Server : in out Server_Type;
Tid : in Swagger.Long;
Result : out TestAPI.Models.Ticket_Type;
Context : in out Swagger.Servers.Context_Type);
-- Options the tickets
-- List the tickets created for the project.
overriding
procedure Do_Options_Ticket
(Server : in out Server_Type;
Tid : in Swagger.Long;
Result : out TestAPI.Models.Ticket_Type;
Context : in out Swagger.Servers.Context_Type);
-- List the tickets
overriding
procedure Do_Head_Ticket
(Server : in out Server_Type;
Context : in out Swagger.Servers.Context_Type);
-- List the tickets
-- List the tickets created for the project.
overriding
procedure Do_List_Tickets
(Server : in out Server_Type;
Status : in Swagger.Nullable_UString;
Owner : in Swagger.Nullable_UString;
Result : out TestAPI.Models.Ticket_Type_Vectors.Vector;
Context : in out Swagger.Servers.Context_Type);
--
-- Query an orchestrated service instance
overriding
procedure Orch_Store
(Server : in out Server_Type;
Body2_Type : in InlineObject3_Type;
Context : in out Swagger.Servers.Context_Type);
package Server_Impl is
new TestAPI.Skeletons.Shared_Instance (Server_Type);
end TestAPI.Servers;
|
-- { dg-do run }
-- { dg-options "-gnat12" }
procedure In_Out_Parameter3 is
type Arr is array (1..16) of Integer;
type Rec1 is record
A : Arr;
B : Boolean;
end record;
type Rec2 is record
R : Rec1;
end record;
pragma Pack (Rec2);
function F (I : In Out Rec1) return Boolean is
A : Integer := I.A (1);
begin
I.A (1) := I.A (1) + 1;
return (A > 0);
end;
I : Rec2 := (R => (A => (others => 0), B => True));
B : Boolean;
begin
B := F (I.R);
if B then
raise Program_Error;
end if;
if I.R.A (1) /= 1 then
raise Program_Error;
end if;
if F (I.R) = False then
raise Program_Error;
end if;
if I.R.A (1) /= 2 then
raise Program_Error;
end if;
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . T A B L E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-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. --
-- --
------------------------------------------------------------------------------
-- This package provides a singleton version of GNAT.Dynamic_Tables
-- (g-dyntab.ads). See that package for documentation. This package just
-- declares a single instance of GNAT.Dynamic_Tables.Instance, and provides
-- wrappers for all the subprograms, passing that single instance.
-- Note that these three interfaces should remain synchronized to keep as much
-- coherency as possible among these related units:
--
-- GNAT.Dynamic_Tables
-- GNAT.Table
-- Table (the compiler unit)
with GNAT.Dynamic_Tables;
generic
type Table_Component_Type is private;
type Table_Index_Type is range <>;
Table_Low_Bound : Table_Index_Type := Table_Index_Type'First;
Table_Initial : Positive := 8;
Table_Increment : Natural := 100;
Table_Name : String := ""; -- for debugging printouts
pragma Unreferenced (Table_Name);
Release_Threshold : Natural := 0;
package GNAT.Table is
pragma Elaborate_Body;
package Tab is new GNAT.Dynamic_Tables
(Table_Component_Type,
Table_Index_Type,
Table_Low_Bound,
Table_Initial,
Table_Increment,
Release_Threshold);
subtype Valid_Table_Index_Type is Tab.Valid_Table_Index_Type;
subtype Table_Last_Type is Tab.Table_Last_Type;
subtype Table_Type is Tab.Table_Type;
function "=" (X, Y : Table_Type) return Boolean renames Tab."=";
subtype Table_Ptr is Tab.Table_Ptr;
The_Instance : Tab.Instance;
Table : Table_Ptr renames The_Instance.Table;
Locked : Boolean renames The_Instance.Locked;
function Is_Empty return Boolean;
procedure Init;
pragma Inline (Init);
procedure Free;
pragma Inline (Free);
function First return Table_Index_Type;
pragma Inline (First);
function Last return Table_Last_Type;
pragma Inline (Last);
procedure Release;
pragma Inline (Release);
procedure Set_Last (New_Val : Table_Last_Type);
pragma Inline (Set_Last);
procedure Increment_Last;
pragma Inline (Increment_Last);
procedure Decrement_Last;
pragma Inline (Decrement_Last);
procedure Append (New_Val : Table_Component_Type);
pragma Inline (Append);
procedure Append_All (New_Vals : Table_Type);
pragma Inline (Append_All);
procedure Set_Item
(Index : Valid_Table_Index_Type;
Item : Table_Component_Type);
pragma Inline (Set_Item);
subtype Saved_Table is Tab.Instance;
-- Type used for Save/Restore subprograms
function Save return Saved_Table;
pragma Inline (Save);
-- Resets table to empty, but saves old contents of table in returned
-- value, for possible later restoration by a call to Restore.
procedure Restore (T : in out Saved_Table);
pragma Inline (Restore);
-- Given a Saved_Table value returned by a prior call to Save, restores
-- the table to the state it was in at the time of the Save call.
procedure Allocate (Num : Integer := 1);
function Allocate (Num : Integer := 1) return Valid_Table_Index_Type;
pragma Inline (Allocate);
-- Adds Num to Last. The function version also returns the old value of
-- Last + 1. Note that this function has the possible side effect of
-- reallocating the table. This means that a reference X.Table (X.Allocate)
-- is incorrect, since the call to X.Allocate may modify the results of
-- calling X.Table.
generic
with procedure Action
(Index : Valid_Table_Index_Type;
Item : Table_Component_Type;
Quit : in out Boolean) is <>;
procedure For_Each;
pragma Inline (For_Each);
generic
with function Lt (Comp1, Comp2 : Table_Component_Type) return Boolean;
procedure Sort_Table;
pragma Inline (Sort_Table);
end GNAT.Table;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014-2019, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Directories;
with Natools.S_Expressions.Atom_Ref_Constructors;
with Natools.S_Expressions.File_Readers;
with Natools.S_Expressions.Interpreter_Loop;
with Natools.S_Expressions.Printers.Pretty.Config;
with Natools.Static_Maps.Web.Sites;
with Natools.Web.Error_Pages;
with Natools.Web.Sites.Updaters;
package body Natools.Web.Sites is
procedure Add_Backend
(Builder : in out Site_Builder;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class);
procedure Add_Page
(Builder : in out Site_Builder;
Constructor : in Page_Constructor;
File_Root : in S_Expressions.Atom;
Path_Root : in S_Expressions.Atom);
procedure Add_Page
(Builder : in out Site_Builder;
Constructor : in Page_Constructor;
File_Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class);
procedure Add_Page_Simple
(Builder : in out Site_Builder;
Constructor : in Page_Constructor;
Common_Name : in S_Expressions.Atom);
procedure Get_Page
(Container : in Page_Maps.Updatable_Map;
Path : in S_Expressions.Atom;
Result : out Page_Maps.Cursor;
Extra_Path_First : out S_Expressions.Offset);
procedure Execute
(Builder : in out Site_Builder;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class);
procedure Set_If_Possible
(Reference : in out S_Expressions.Atom_Refs.Immutable_Reference;
Expression : in S_Expressions.Lockable.Descriptor'Class);
procedure Add_Backends is new S_Expressions.Interpreter_Loop
(Site_Builder, Meaningless_Type, Add_Backend);
procedure Add_Pages is new S_Expressions.Interpreter_Loop
(Site_Builder, Page_Constructor, Add_Page, Add_Page_Simple);
procedure Interpreter is new S_Expressions.Interpreter_Loop
(Site_Builder, Meaningless_Type, Execute);
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Get_Page
(Container : in Page_Maps.Updatable_Map;
Path : in S_Expressions.Atom;
Result : out Page_Maps.Cursor;
Extra_Path_First : out S_Expressions.Offset)
is
use type S_Expressions.Atom;
use type S_Expressions.Octet;
use type S_Expressions.Offset;
begin
Result := Container.Floor (Path);
if not Page_Maps.Has_Element (Result) then
Extra_Path_First := 0;
return;
end if;
declare
Found_Path : constant S_Expressions.Atom := Page_Maps.Key (Result);
begin
if Found_Path'Length > Path'Length
or else Path (Path'First .. Path'First + Found_Path'Length - 1)
/= Found_Path
then
Page_Maps.Clear (Result);
return;
end if;
Extra_Path_First := Path'First + Found_Path'Length;
end;
if Extra_Path_First in Path'Range
and then Path (Extra_Path_First) /= Character'Pos ('/')
then
Page_Maps.Clear (Result);
return;
end if;
end Get_Page;
procedure Set_If_Possible
(Reference : in out S_Expressions.Atom_Refs.Immutable_Reference;
Expression : in S_Expressions.Lockable.Descriptor'Class)
is
use type S_Expressions.Events.Event;
begin
if Expression.Current_Event = S_Expressions.Events.Add_Atom then
Reference := S_Expressions.Atom_Ref_Constructors.Create
(Expression.Current_Atom);
end if;
end Set_If_Possible;
----------------------
-- Site Interpreter --
----------------------
procedure Add_Backend
(Builder : in out Site_Builder;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class)
is
pragma Unreferenced (Context);
use type S_Expressions.Events.Event;
begin
if Arguments.Current_Event /= S_Expressions.Events.Add_Atom then
Log (Severities.Error, "Invalid syntax for backend """
& S_Expressions.To_String (Name) & '"');
return;
end if;
declare
Backend_Type : constant S_Expressions.Atom := Arguments.Current_Atom;
Constructor : constant Backend_Constructors.Cursor
:= Builder.Constructors.Backend.Find (Backend_Type);
begin
if not Backend_Constructors.Has_Element (Constructor) then
Log (Severities.Error, "Unknown backend type """
& S_Expressions.To_String (Backend_Type)
& """ for backend """
& S_Expressions.To_String (Name) & '"');
return;
end if;
Arguments.Next;
declare
Backend : constant Backends.Backend'Class
:= Backend_Constructors.Element (Constructor).all (Arguments);
Cursor : Backend_Maps.Unsafe_Maps.Cursor;
Inserted : Boolean;
begin
Builder.Backends.Insert (Name, Backend, Cursor, Inserted);
if not Inserted then
Log (Severities.Error, "Duplicate backend name """
& S_Expressions.To_String (Name) & '"');
end if;
end;
end;
end Add_Backend;
procedure Add_Page
(Builder : in out Site_Builder;
Constructor : in Page_Constructor;
File_Root : in S_Expressions.Atom;
Path_Root : in S_Expressions.Atom)
is
use type S_Expressions.Atom;
function Get_Loader (File : S_Expressions.Atom) return Page_Loader'Class;
function Get_Loader
(File : S_Expressions.Atom) return Page_Loader'Class
is
Cursor : constant Page_Loaders.Cursor
:= Builder.Old_Loaders.Find (File);
begin
if Page_Loaders.Has_Element (Cursor) then
return Page_Loaders.Element (Cursor);
else
return Constructor (File);
end if;
end Get_Loader;
File : constant S_Expressions.Atom
:= Builder.File_Prefix.Query.Data.all
& File_Root
& Builder.File_Suffix.Query.Data.all;
Path : constant S_Expressions.Atom
:= Builder.Path_Prefix.Query.Data.all
& Path_Root
& Builder.Path_Suffix.Query.Data.all;
Loader : Page_Loader'Class := Get_Loader (File);
begin
Load (Loader, Builder, Path);
if Loader not in Transient_Page_Loader'Class
or else Can_Be_Stored (Transient_Page_Loader'Class (Loader))
then
Builder.New_Loaders.Insert (File, Loader);
end if;
end Add_Page;
procedure Add_Page
(Builder : in out Site_Builder;
Constructor : in Page_Constructor;
File_Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class)
is
use type S_Expressions.Events.Event;
begin
if Arguments.Current_Event = S_Expressions.Events.Add_Atom then
Add_Page (Builder, Constructor, File_Name, Arguments.Current_Atom);
end if;
end Add_Page;
procedure Add_Page_Simple
(Builder : in out Site_Builder;
Constructor : in Page_Constructor;
Common_Name : in S_Expressions.Atom) is
begin
Add_Page (Builder, Constructor, Common_Name, Common_Name);
end Add_Page_Simple;
procedure Execute
(Builder : in out Site_Builder;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class)
is
pragma Unreferenced (Context);
package Commands renames Natools.Static_Maps.Web.Sites;
use type S_Expressions.Events.Event;
use type S_Expressions.Atom;
use type S_Expressions.Octet;
use type S_Expressions.Offset;
begin
case Commands.To_Command (S_Expressions.To_String (Name)) is
when Commands.Error =>
declare
Cursor : Page_Constructors.Cursor
:= Builder.Constructors.Page.Find (Name);
begin
if not Page_Constructors.Has_Element (Cursor)
and then Name'Length > 1
and then Name (Name'Last) = Character'Pos ('s')
then
Cursor := Builder.Constructors.Page.Find
(Name (Name'First .. Name'Last - 1));
end if;
if Page_Constructors.Has_Element (Cursor) then
Add_Pages
(Arguments,
Builder,
Page_Constructors.Element (Cursor));
else
Log (Severities.Error, "Unknown site command """
& S_Expressions.To_String (Name) & '"');
end if;
end;
when Commands.Set_ACL =>
if Arguments.Current_Event = S_Expressions.Events.Add_Atom then
declare
Cursor : constant ACL_Constructors.Cursor
:= Builder.Constructors.ACL.Find (Arguments.Current_Atom);
begin
if ACL_Constructors.Has_Element (Cursor) then
declare
function Create return ACL.Backend'Class;
function Create return ACL.Backend'Class is
Constructor : constant ACL_Constructor
:= ACL_Constructors.Element (Cursor);
begin
return Constructor.all (Arguments);
end Create;
begin
Arguments.Next;
Builder.ACL := ACL.Backend_Refs.Create (Create'Access);
end;
else
Log (Severities.Error, "Unknown ACL type """
& S_Expressions.To_String (Arguments.Current_Atom));
end if;
end;
end if;
when Commands.Set_Backends =>
Add_Backends (Arguments, Builder, Meaningless_Value);
when Commands.Set_Default_Template =>
Set_If_Possible (Builder.Default_Template, Arguments);
when Commands.Set_File_Prefix =>
Set_If_Possible (Builder.File_Prefix, Arguments);
when Commands.Set_File_Suffix =>
Set_If_Possible (Builder.File_Suffix, Arguments);
when Commands.Set_Filters =>
Builder.Filters.Populate (Arguments);
when Commands.Set_Named_Element_File =>
if Arguments.Current_Event = S_Expressions.Events.Add_Atom then
declare
Reader : S_Expressions.File_Readers.S_Reader
:= S_Expressions.File_Readers.Reader
(S_Expressions.To_String (Arguments.Current_Atom));
begin
Containers.Set_Expression_Maps
(Builder.Named_Elements, Reader);
end;
end if;
when Commands.Set_Named_Elements =>
Containers.Set_Expression_Maps (Builder.Named_Elements, Arguments);
when Commands.Set_Path_Prefix =>
Set_If_Possible (Builder.Path_Prefix, Arguments);
when Commands.Set_Path_Suffix =>
Set_If_Possible (Builder.Path_Suffix, Arguments);
when Commands.Set_Printer =>
S_Expressions.Printers.Pretty.Config.Update
(Builder.Printer_Parameters, Arguments);
when Commands.Set_Static_Paths =>
Containers.Append_Atoms (Builder.Static, Arguments);
when Commands.Set_Template_File =>
if Arguments.Current_Event = S_Expressions.Events.Add_Atom then
declare
Reader : S_Expressions.File_Readers.S_Reader
:= S_Expressions.File_Readers.Reader
(S_Expressions.To_String (Arguments.Current_Atom));
begin
Containers.Set_Expressions (Builder.Templates, Reader);
end;
end if;
when Commands.Set_Templates =>
Containers.Set_Expressions (Builder.Templates, Arguments);
end case;
end Execute;
procedure Expire_At
(Builder : in out Site_Builder;
Time : in Ada.Calendar.Time)
is
use type Ada.Calendar.Time;
begin
if not Builder.Expire.Present or else Time < Builder.Expire.Time then
Builder.Expire := (Present => True, Time => Time);
end if;
end Expire_At;
function Get_Backend (From : Site_Builder; Name : S_Expressions.Atom)
return Backends.Backend'Class is
begin
return From.Backends.Element (Name);
end Get_Backend;
function Get_Filter (From : Site_Builder; Name : S_Expressions.Atom)
return Filters.Filter'Class is
begin
return From.Filters.Get_Filter (Name);
end Get_Filter;
procedure Insert
(Builder : in out Site_Builder;
Path : in S_Expressions.Atom;
New_Page : in Page'Class) is
begin
Builder.Pages.Insert (Path, New_Page);
end Insert;
procedure Insert
(Builder : in out Site_Builder;
Tags : in Web.Tags.Tag_List;
Visible : in Web.Tags.Visible'Class) is
begin
Web.Tags.Register (Builder.Tags, Tags, Visible);
end Insert;
procedure Update
(Builder : in out Site_Builder;
Expression : in out S_Expressions.Lockable.Descriptor'Class) is
begin
Interpreter (Expression, Builder, Meaningless_Value);
end Update;
-------------------------------
-- Exchange Public Interface --
-------------------------------
function Comment_Info (Ex : in out Exchange)
return Comment_Cookies.Comment_Info is
begin
if not Ex.Comment_Info_Initialized then
Ex.Comment_Info := Comment_Cookies.Decode
(Ex.Site.Constructors.Codec_DB,
Ex.Cookie (Comment_Cookies.Cookie_Name));
Ex.Comment_Info_Initialized := True;
end if;
return Ex.Comment_Info;
end Comment_Info;
function Identity (Ex : Exchange) return Containers.Identity is
begin
if not Exchanges.Has_Identity (Ex.Backend.all) then
if Ex.Site.ACL.Is_Empty then
Exchanges.Set_Identity (Ex.Backend.all, Containers.Null_Identity);
else
Ex.Site.ACL.Update.Authenticate (Ex.Backend.all);
end if;
pragma Assert (Exchanges.Has_Identity (Ex.Backend.all));
end if;
return Exchanges.Identity (Ex.Backend.all);
end Identity;
procedure Set_Comment_Cookie
(Ex : in out Exchange;
Info : in Comment_Cookies.Comment_Info) is
begin
Ex.Set_Cookie
(Comment_Cookies.Cookie_Name,
Comment_Cookies.Encode (Ex.Site.Constructors.Codec_DB, Info));
end Set_Comment_Cookie;
---------------------------
-- Site Public Interface --
---------------------------
procedure Queue_Update
(Object : in Site;
Update : in Updates.Site_Update'Class) is
begin
if Object.Updater /= null then
Object.Updater.Queue (Update);
end if;
end Queue_Update;
procedure Insert
(Object : in out Site;
Path : in S_Expressions.Atom;
New_Page : in Page'Class) is
begin
Object.Pages := Page_Maps.Insert (Object.Pages, Path, New_Page);
end Insert;
procedure Insert
(Object : in out Site;
Tags : in Web.Tags.Tag_List;
Visible : in Web.Tags.Visible'Class) is
begin
Web.Tags.Live_Register (Object.Tags, Tags, Visible);
end Insert;
procedure Register
(Object : in out Site;
Name : in String;
Constructor : in Filters.Stores.Constructor) is
begin
Object.Filters.Register (S_Expressions.To_Atom (Name), Constructor);
end Register;
procedure Register
(Self : in out Site;
Name : in String;
Constructor : in Page_Constructor) is
begin
Self.Constructors.Page.Insert
(S_Expressions.To_Atom (Name), Constructor);
end Register;
procedure Register
(Self : in out Site;
Name : in String;
Constructor : in Backend_Constructor) is
begin
Self.Constructors.Backend.Insert
(S_Expressions.To_Atom (Name), Constructor);
end Register;
procedure Register
(Self : in out Site;
Name : in String;
Constructor : in ACL_Constructor) is
begin
Self.Constructors.ACL.Insert (S_Expressions.To_Atom (Name), Constructor);
end Register;
procedure Register
(Object : in out Site;
Key : in Character;
Filter : in not null Comment_Cookies.Decoder) is
begin
Comment_Cookies.Register (Object.Constructors.Codec_DB, Key, Filter);
end Register;
procedure Reload (Object : in out Site) is
Reader : S_Expressions.File_Readers.S_Reader
:= S_Expressions.File_Readers.Reader
(S_Expressions.To_String (Object.File_Name.Query.Data.all));
Empty_Atom : constant S_Expressions.Atom_Refs.Immutable_Reference
:= S_Expressions.Atom_Ref_Constructors.Create
(S_Expressions.Null_Atom);
Builder : Site_Builder
:= (Constructors => Object.Constructors'Access,
Default_Template
=> S_Expressions.Atom_Refs.Null_Immutable_Reference,
Expire => (Present => False),
File_Prefix => Empty_Atom,
File_Suffix => Empty_Atom,
Filters => Object.Filters.Duplicate,
New_Loaders => <>,
Old_Loaders => Object.Loaders,
Path_Prefix => Empty_Atom,
Path_Suffix => Empty_Atom,
ACL | Backends | Named_Elements | Pages | Static | Tags | Templates
| Printer_Parameters
=> <>);
begin
Update (Builder, Reader);
Object.ACL := Builder.ACL;
Object.Backends := Backend_Maps.Create (Builder.Backends);
Object.Default_Template := Builder.Default_Template;
Object.Expire := Builder.Expire;
Object.Filters := Builder.Filters;
Object.Loaders := Page_Loaders.Create (Builder.New_Loaders);
Object.Named_Elements := Builder.Named_Elements;
Object.Pages := Page_Maps.Create (Builder.Pages);
Object.Printer_Parameters := Builder.Printer_Parameters;
Object.Static := Containers.Create (Builder.Static);
Object.Tags := Tags.Create (Builder.Tags);
Object.Templates := Builder.Templates;
if Object.Default_Template.Is_Empty then
Object.Default_Template := S_Expressions.Atom_Ref_Constructors.Create
(S_Expressions.To_Atom ("html"));
end if;
Object.Load_Date := Ada.Calendar.Clock;
end Reload;
procedure Remove
(Object : in out Site;
Tags : in Web.Tags.Tag_List;
Visible : in Web.Tags.Visible'Class) is
begin
Web.Tags.Live_Unregister (Object.Tags, Tags, Visible);
end Remove;
procedure Reset (Object : in out Site; File_Name : in String) is
begin
Object.File_Name := S_Expressions.Atom_Ref_Constructors.Create
(S_Expressions.To_Atom (File_Name));
Reload (Object);
end Reset;
procedure Respond
(Object : in out Site;
Exchange : aliased in out Exchanges.Exchange)
is
use type S_Expressions.Octet;
use type S_Expressions.Offset;
Extended_Exchange : Sites.Exchange (Exchange'Access, Object'Access);
procedure Call_Page
(Key : in S_Expressions.Atom;
Page_Object : in out Page'Class);
procedure Send_File_If_Exists (In_Directory : in S_Expressions.Atom);
Path : constant S_Expressions.Atom
:= S_Expressions.To_Atom (Exchanges.Path (Exchange));
procedure Call_Page
(Key : in S_Expressions.Atom;
Page_Object : in out Page'Class)
is
use type S_Expressions.Atom;
begin
pragma Assert (Key'Length <= Path'Length
and then Key = Path (Path'First .. Path'First + Key'Length - 1));
Respond
(Page_Object,
Extended_Exchange,
Path (Path'First + Key'Length .. Path'Last));
end Call_Page;
procedure Send_File_If_Exists (In_Directory : in S_Expressions.Atom) is
use type Ada.Directories.File_Kind;
use type S_Expressions.Atom;
File_Name : constant S_Expressions.Atom := In_Directory & Path;
Candidate_Name : constant String
:= S_Expressions.To_String (File_Name);
begin
if Ada.Directories.Exists (Candidate_Name)
and then Ada.Directories.Kind (Candidate_Name)
/= Ada.Directories.Directory
then
Exchanges.Send_File (Exchange, File_Name);
end if;
end Send_File_If_Exists;
Cursor : Page_Maps.Cursor;
Extra_Path_First : S_Expressions.Offset;
begin
if not Object.Static.Is_Empty then
for Path_Ref of Object.Static.Query.Data.all loop
Send_File_If_Exists (Path_Ref.Query.Data.all);
if Exchanges.Has_Response (Exchange) then
return;
end if;
end loop;
end if;
Get_Page (Object.Pages, Path, Cursor, Extra_Path_First);
if not Page_Maps.Has_Element (Cursor) then
Error_Pages.Not_Found (Extended_Exchange);
return;
end if;
Response_Loop :
loop
Object.Pages.Update_Element (Cursor, Call_Page'Access);
exit Response_Loop when Exchanges.Has_Response (Exchange);
Find_Parent :
loop
Remove_Path_Component :
loop
Extra_Path_First := Extra_Path_First - 1;
exit Response_Loop
when Extra_Path_First not in Path'Range;
exit Remove_Path_Component
when Path (Extra_Path_First) = Character'Pos ('/');
end loop Remove_Path_Component;
Cursor := Object.Pages.Find
(Path (Path'First .. Extra_Path_First - 1));
exit Find_Parent when Page_Maps.Has_Element (Cursor);
end loop Find_Parent;
end loop Response_Loop;
if not Exchanges.Has_Response (Exchange) then
Error_Pages.Not_Found (Extended_Exchange);
end if;
end Respond;
procedure Set_Cookie_Encoder
(Object : in out Site;
Filter : in not null Comment_Cookies.Encoder;
Serialization : in Comment_Cookies.Serialization_Kind) is
begin
Comment_Cookies.Set_Encoder
(Object.Constructors.Codec_DB,
Filter,
Serialization);
end Set_Cookie_Encoder;
procedure Set_Updater
(Object : in out Site;
Updater : in Updaters.Updater_Access) is
begin
Object.Updater := Updater;
end Set_Updater;
-------------------------
-- Site Data Accessors --
-------------------------
function Get_Backend (From : Site; Name : S_Expressions.Atom)
return Backends.Backend'Class is
begin
return From.Backends.Element (Name);
end Get_Backend;
function Get_Filter (From : Site; Name : S_Expressions.Atom)
return Filters.Filter'Class is
begin
return From.Filters.Get_Filter (Name);
end Get_Filter;
function Get_Tags (Object : Site) return Tags.Tag_DB is
begin
return Object.Tags;
end Get_Tags;
function Get_Template
(Object : in Site;
Name : in S_Expressions.Atom)
return Containers.Optional_Expression
is
Cursor : constant Containers.Expression_Maps.Cursor
:= Object.Templates.Find (Name);
Found : constant Boolean
:= Containers.Expression_Maps.Has_Element (Cursor);
begin
if Found then
return (Is_Empty => False,
Value => Containers.Expression_Maps.Element (Cursor));
else
return (Is_Empty => True);
end if;
end Get_Template;
function Get_Template
(Object : in Site;
Elements : in Containers.Expression_Maps.Constant_Map;
Expression : in out S_Expressions.Lockable.Descriptor'Class;
Name : in S_Expressions.Atom := S_Expressions.Null_Atom;
Lookup_Template : in Boolean := True;
Lookup_Element : in Boolean := True;
Lookup_Name : in Boolean := False)
return S_Expressions.Caches.Cursor
is
Cursor : Containers.Expression_Maps.Cursor;
use type S_Expressions.Events.Event;
begin
-- Check whether Name should be extracted from Expression
if Name'Length = 0
and then (not Lookup_Name)
and then (Lookup_Template or Lookup_Element)
and then Expression.Current_Event = S_Expressions.Events.Add_Atom
then
declare
Actual_Name : constant S_Expressions.Atom
:= Expression.Current_Atom;
begin
Expression.Next;
return Get_Template
(Object, Elements, Expression,
Actual_Name,
Lookup_Template, Lookup_Element, True);
end;
end if;
-- Try Name among elements
Cursor := Elements.Find (Name);
if Containers.Expression_Maps.Has_Element (Cursor) then
return Containers.Expression_Maps.Element (Cursor);
end if;
-- Try Name among templates
Cursor := Object.Templates.Find (Name);
if Containers.Expression_Maps.Has_Element (Cursor) then
return Containers.Expression_Maps.Element (Cursor);
end if;
-- Fallback on Expression, converting it destructively if needed
if Expression in S_Expressions.Caches.Cursor then
return S_Expressions.Caches.Cursor (Expression);
else
return S_Expressions.Caches.Move (Expression);
end if;
end Get_Template;
function Load_Date (Object : in Site) return Ada.Calendar.Time is
begin
return Object.Load_Date;
end Load_Date;
function Named_Element_Map
(Object : in Site;
Name : in S_Expressions.Atom)
return Containers.Expression_Maps.Constant_Map
is
Cursor : constant Containers.Expression_Map_Maps.Cursor
:= Object.Named_Elements.Find (Name);
begin
if Containers.Expression_Map_Maps.Has_Element (Cursor) then
return Containers.Expression_Map_Maps.Element (Cursor);
else
return Containers.Expression_Maps.Empty_Constant_Map;
end if;
end Named_Element_Map;
function Default_Template (Object : Site) return S_Expressions.Atom is
begin
return Object.Default_Template.Query.Data.all;
end Default_Template;
procedure Set_Parameters
(Object : in Site;
Printer : in out S_Expressions.Printers.Pretty.Printer'Class) is
begin
Printer.Set_Parameters (Object.Printer_Parameters);
end Set_Parameters;
end Natools.Web.Sites;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package Slim.Menu_Commands is
type Menu_Command is limited interface;
type Menu_Command_Access is access all Menu_Command'Class;
not overriding procedure Run (Self : Menu_Command) is abstract;
end Slim.Menu_Commands;
|
--------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2020, Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Video.Pixel_Formats
--
-- Description of various pixel formats.
--------------------------------------------------------------------------------------------------------------------
with Ada.Characters.Latin_1;
with Ada.Unchecked_Conversion;
with Interfaces;
with Interfaces.C;
with SDL.Video.Palettes;
package SDL.Video.Pixel_Formats is
pragma Preelaborate;
package C renames Interfaces.C;
type Pixel_Types is
(Unknown,
Index_1,
Index_4,
Index_8,
Packed_8,
Packed_16,
Packed_32,
Array_U8,
Array_U16,
Array_U32,
Array_F16,
Array_F32) with
Convention => C;
-- Bitmap pixel order, high bit -> low bit.
type Bitmap_Pixel_Order is (None, Little_Endian, Big_Endian) with
Convention => C;
-- Packed component order, high bit -> low bit.
type Packed_Component_Order is
(None,
XRGB,
RGBX,
ARGB,
RGBA,
XBGR,
BGRX,
ABGR,
BGRA) with
Convention => C;
-- Array component order, low byte -> high byte.
type Array_Component_Order is (None, RGB, RGBA, ARGB, BGR, BGRA, ABGR);
-- Describe how the components are laid out in bit form.
type Packed_Component_Layout is
(None,
Bits_332,
Bits_4444,
Bits_1555,
Bits_5551,
Bits_565,
Bits_8888,
Bits_2101010,
Bits_1010102) with
Convention => C;
type Bits_Per_Pixels is range 0 .. 32 with
Static_Predicate => Bits_Per_Pixels in 0 | 1 | 4 | 8 | 12 | 15 | 16 | 24 | 32,
Convention => C;
Bits_Per_Pixel_Error : constant Bits_Per_Pixels := 0;
type Bytes_Per_Pixels is range 0 .. 4 with
Convention => C;
Bytes_Per_Pixel_Error : constant Bytes_Per_Pixels := Bytes_Per_Pixels'First;
-- 29 28 24 20 16 8 0
-- 000 1 ptpt popo llll bibibibi bybybyby
--
-- or
--
-- 24 16 8 0
-- DDDDDDDD CCCCCCCC BBBBBBBB AAAAAAAA
type Index_Order_Padding is range 0 .. 1 with
Convention => C;
type Pixel_Orders (Pixel_Type : Pixel_Types := Unknown) is
record
case Pixel_Type is
when Index_1 | Index_4 | Index_8 =>
Indexed_Order : Bitmap_Pixel_Order;
Indexed_Pad : Index_Order_Padding;
when Packed_8 | Packed_16 | Packed_32 =>
Packed_Order : Packed_Component_Order;
when Array_U8 | Array_U16 | Array_U32 | Array_F16 | Array_F32 =>
Array_Order : Array_Component_Order;
when others =>
null;
end case;
end record with
Unchecked_Union => True,
Convention => C,
Size => 4;
pragma Warnings (Off, "no component clause given"); -- Stop warning about Pixel_Type having no rep clause.
for Pixel_Orders use
record
Indexed_Order at 0 range 0 .. 2; -- This was 2 as that is the max size required but it causes a bit set bug!
Indexed_Pad at 0 range 3 .. 3;
Packed_Order at 0 range 0 .. 3;
Array_Order at 0 range 0 .. 3;
end record;
pragma Warnings (On, "no component clause given");
type Planar_Pixels is
record
A : Character;
B : Character;
C : Character;
D : Character;
end record with
Size => 32,
Convention => C;
for Planar_Pixels use
record
A at 0 range 0 .. 7;
B at 0 range 8 .. 15;
C at 0 range 16 .. 23;
D at 0 range 24 .. 31;
end record;
type Non_Planar_Pixel_Padding is range 0 .. 7 with
Convention => C;
type Non_Planar_Pixels is
record
Bytes_Per_Pixel : Bytes_Per_Pixels;
Bits_Per_Pixel : Bits_Per_Pixels;
Layout : Packed_Component_Layout;
Pixel_Order : Pixel_Orders;
Pixel_Type : Pixel_Types;
Flag : Boolean;
Padding : Non_Planar_Pixel_Padding;
end record with
Size => 32,
Convention => C;
for Non_Planar_Pixels use
record
Bytes_Per_Pixel at 0 range 0 .. 7;
Bits_Per_Pixel at 0 range 8 .. 15;
Layout at 0 range 16 .. 19;
Pixel_Order at 0 range 20 .. 23;
Pixel_Type at 0 range 24 .. 27;
Flag at 0 range 28 .. 28;
Padding at 0 range 29 .. 31;
end record;
type Pixel_Format_Names (Planar : Boolean := False) is
record
case Planar is
when True =>
Planar_Format : Planar_Pixels;
when False =>
Non_Planar_Format : Non_Planar_Pixels;
end case;
end record with
Unchecked_Union => True,
Size => 32,
Convention => C;
Pixel_Format_Unknown : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => True,
Planar_Format => Planar_Pixels'
(others => Ada.Characters.Latin_1.NUL));
Pixel_Format_Index_1_LSB : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Index_1,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Index_1,
Indexed_Order => Little_Endian,
Indexed_Pad => Index_Order_Padding'First),
Layout => None,
Bits_Per_Pixel => 1,
Bytes_Per_Pixel => 0));
Pixel_Format_Index_1_MSB : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Index_1,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Index_1,
Indexed_Order => Big_Endian,
Indexed_Pad => Index_Order_Padding'First),
Layout => None,
Bits_Per_Pixel => 1,
Bytes_Per_Pixel => 0));
Pixel_Format_Index_4_LSB : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Index_4,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Index_4,
Indexed_Order => Little_Endian,
Indexed_Pad => Index_Order_Padding'First),
Layout => None,
Bits_Per_Pixel => 4,
Bytes_Per_Pixel => 0));
Pixel_Format_Index_4_MSB : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Index_4,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Index_4,
Indexed_Order => Big_Endian,
Indexed_Pad => Index_Order_Padding'First),
Layout => None,
Bits_Per_Pixel => 4,
Bytes_Per_Pixel => 0));
Pixel_Format_Index_8 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Index_8,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Index_8,
Indexed_Order => None,
Indexed_Pad => Index_Order_Padding'First),
Layout => None,
Bits_Per_Pixel => 8,
Bytes_Per_Pixel => 1));
Pixel_Format_RGB_332 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_8,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_8,
Packed_Order => XRGB),
Layout => Bits_332,
Bits_Per_Pixel => 8,
Bytes_Per_Pixel => 1));
Pixel_Format_RGB_444 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => XRGB),
Layout => Bits_4444,
Bits_Per_Pixel => 12,
Bytes_Per_Pixel => 2));
Pixel_Format_RGB_555 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => XRGB),
Layout => Bits_1555,
Bits_Per_Pixel => 15,
Bytes_Per_Pixel => 2));
Pixel_Format_BGR_555 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => XBGR),
Layout => Bits_1555,
Bits_Per_Pixel => 15,
Bytes_Per_Pixel => 2));
Pixel_Format_ARGB_4444 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => ARGB),
Layout => Bits_4444,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_RGBA_4444 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => RGBA),
Layout => Bits_4444,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_ABGR_4444 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => ABGR),
Layout => Bits_4444,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_BGRA_4444 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => BGRA),
Layout => Bits_4444,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_ARGB_1555 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => ARGB),
Layout => Bits_1555,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_RGBA_5551 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => RGBA),
Layout => Bits_5551,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_ABGR_1555 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => ABGR),
Layout => Bits_1555,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_BGRA_5551 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => BGRA),
Layout => Bits_5551,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_RGB_565 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => XRGB),
Layout => Bits_565,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_BGR_565 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_16,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_16,
Packed_Order => XBGR),
Layout => Bits_565,
Bits_Per_Pixel => 16,
Bytes_Per_Pixel => 2));
Pixel_Format_RGB_24 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Array_U8,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Array_U8,
Array_Order => RGB),
Layout => None,
Bits_Per_Pixel => 24,
Bytes_Per_Pixel => 3));
Pixel_Format_BGR_24 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Array_U8,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Array_U8,
Array_Order => BGR),
Layout => None,
Bits_Per_Pixel => 24,
Bytes_Per_Pixel => 3));
Pixel_Format_RGB_888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => XRGB),
Layout => Bits_8888,
Bits_Per_Pixel => 24,
Bytes_Per_Pixel => 4));
Pixel_Format_RGBX_8888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => RGBX),
Layout => Bits_8888,
Bits_Per_Pixel => 24,
Bytes_Per_Pixel => 4));
Pixel_Format_BGR_888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => XBGR),
Layout => Bits_8888,
Bits_Per_Pixel => 24,
Bytes_Per_Pixel => 4));
Pixel_Format_BGRX_8888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => BGRX),
Layout => Bits_8888,
Bits_Per_Pixel => 24,
Bytes_Per_Pixel => 4));
Pixel_Format_ARGB_8888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => ARGB),
Layout => Bits_8888,
Bits_Per_Pixel => 32,
Bytes_Per_Pixel => 4));
Pixel_Format_RGBA_8888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => RGBA),
Layout => Bits_8888,
Bits_Per_Pixel => 32,
Bytes_Per_Pixel => 4));
Pixel_Format_ABGR_8888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => ABGR),
Layout => Bits_8888,
Bits_Per_Pixel => 32,
Bytes_Per_Pixel => 4));
Pixel_Format_BGRA_8888 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => BGRA),
Layout => Bits_8888,
Bits_Per_Pixel => 32,
Bytes_Per_Pixel => 4));
Pixel_Format_ARGB_2101010 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => False,
Non_Planar_Format => Non_Planar_Pixels'
(Padding => Non_Planar_Pixel_Padding'First,
Flag => True,
Pixel_Type => Packed_32,
Pixel_Order => Pixel_Orders'
(Pixel_Type => Packed_32,
Packed_Order => ARGB),
Layout => Bits_2101010,
Bits_Per_Pixel => 32,
Bytes_Per_Pixel => 4));
Pixel_Format_YV_12 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => True,
Planar_Format => Planar_Pixels'
(A => 'Y',
B => 'V',
C => '1',
D => '2'));
Pixel_Format_IYUV : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => True,
Planar_Format => Planar_Pixels'
(A => 'I',
B => 'Y',
C => 'U',
D => 'V'));
Pixel_Format_YUY_2 : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => True,
Planar_Format => Planar_Pixels'
(A => 'Y',
B => 'U',
C => 'Y',
D => '2'));
Pixel_Format_UYVY : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => True,
Planar_Format => Planar_Pixels'
(A => 'U',
B => 'Y',
C => 'V',
D => 'Y'));
Pixel_Format_YVYU : constant Pixel_Format_Names :=
Pixel_Format_Names'(Planar => True,
Planar_Format => Planar_Pixels'
(A => 'Y',
B => 'V',
C => 'Y',
D => 'U'));
type Colour_Mask is mod 2 ** 32 with
Convention => C;
type Private_Pixel_Format is private;
type Pixel_Format is
record
Format : Pixel_Format_Names;
Palette : Palettes.Palette_Access;
Bits : Bits_Per_Pixels;
Bytes : Bytes_Per_Pixels;
Padding : Interfaces.Unsigned_16;
Red_Mask : Colour_Mask;
Green_Mask : Colour_Mask;
Blue_Mask : Colour_Mask;
Alpha_Mask : Colour_Mask;
-- This is mainly padding to make sure the record size matches what is expected from C.
Private_Part : Private_Pixel_Format;
end record with
Convention => C;
-- TODO: Possibly change this to a controlled type.
type Pixel_Format_Access is access all Pixel_Format with
Convention => C;
function Create (Format : in Pixel_Format_Names) return Pixel_Format_Access with
Import => True,
Convention => C,
External_Name => "SDL_AllocFormat";
procedure Free (Format : in Pixel_Format_Access) with
Import => True,
Convention => C,
External_Name => "SDL_FreeFormat";
function Image (Format : in Pixel_Format_Names) return String;
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_GetPixelFormatName";
procedure To_Components
(Pixel : in Interfaces.Unsigned_32;
Format : in Pixel_Format_Access;
Red : out Palettes.Colour_Component;
Green : out Palettes.Colour_Component;
Blue : out Palettes.Colour_Component) with
Import => True,
Convention => C,
External_Name => "SDL_GetRGB";
procedure To_Components
(Pixel : in Interfaces.Unsigned_32;
Format : in Pixel_Format_Access;
Red : out Palettes.Colour_Component;
Green : out Palettes.Colour_Component;
Blue : out Palettes.Colour_Component;
Alpha : out Palettes.Colour_Component) with
Import => True,
Convention => C,
External_Name => "SDL_GetRGBA";
function To_Pixel
(Format : in Pixel_Format_Access;
Red : in Palettes.Colour_Component;
Green : in Palettes.Colour_Component;
Blue : in Palettes.Colour_Component) return Interfaces.Unsigned_32 with
Import => True,
Convention => C,
External_Name => "SDL_MapRGB";
function To_Pixel
(Format : in Pixel_Format_Access;
Red : in Palettes.Colour_Component;
Green : in Palettes.Colour_Component;
Blue : in Palettes.Colour_Component;
Alpha : in Palettes.Colour_Component) return Interfaces.Unsigned_32 with
Import => True,
Convention => C,
External_Name => "SDL_MapRGBA";
function To_Colour (Pixel : in Interfaces.Unsigned_32; Format : in Pixel_Format_Access) return Palettes.Colour with
Inline => True;
function To_Pixel (Colour : in Palettes.Colour; Format : in Pixel_Format_Access) return Interfaces.Unsigned_32 with
Inline => True;
function To_Name
(Bits : in Bits_Per_Pixels;
Red_Mask : in Colour_Mask;
Green_Mask : in Colour_Mask;
Blue_Mask : in Colour_Mask;
Alpha_Mask : in Colour_Mask) return Pixel_Format_Names with
Import => True,
Convention => C,
External_Name => "SDL_MasksToPixelFormatEnum";
function To_Masks
(Format : in Pixel_Format_Names;
Bits : out Bits_Per_Pixels;
Red_Mask : out Colour_Mask;
Green_Mask : out Colour_Mask;
Blue_Mask : out Colour_Mask;
Alpha_Mask : out Colour_Mask) return Boolean with
Inline => True;
-- Gamma
type Gamma_Value is mod 2 ** 16 with
Convention => C;
type Gamma_Ramp is array (Integer range 1 .. 256) of Gamma_Value with
Convention => C;
procedure Calculate (Gamma : in Float; Ramp : out Gamma_Ramp) with
Import => True,
Convention => C,
External_Name => "SDL_CalculateGammaRamp";
private
-- The following fields are defined as "internal use" in the SDL docs.
type Private_Pixel_Format is
record
Rred_Loss : Interfaces.Unsigned_8;
Green_Loss : Interfaces.Unsigned_8;
Blue_Loss : Interfaces.Unsigned_8;
Alpha_Loss : Interfaces.Unsigned_8;
Red_Shift : Interfaces.Unsigned_8;
Green_Shift : Interfaces.Unsigned_8;
Blue_Shift : Interfaces.Unsigned_8;
Alpha_Shift : Interfaces.Unsigned_8;
Ref_Count : C.int;
Next : Pixel_Format_Access;
end record with
Convention => C;
end SDL.Video.Pixel_Formats;
|
--------------------------------------------------------------------------
-- ASnip Source Code Decorator
-- Copyright (C) 2006, Georg Bauhaus
--
-- 1. Permission is hereby granted to use, copy, modify and/or distribute
-- this package, provided that:
-- * copyright notices are retained unchanged,
-- * any distribution of this package, whether modified or not,
-- includes this license text.
-- 2. Permission is hereby also granted to distribute binary programs which
-- depend on this package. If the binary program depends on a modified
-- version of this package, you are encouraged to publicly release the
-- modified version of this package.
--
-- THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT WARRANTY. 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 AUTHORS BE LIABLE TO ANY PARTY FOR
-- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS PACKAGE.
--------------------------------------------------------------------------
-- eMail: bauhaus@arcor.de
with ASnip.Testing;
with Ada.Text_IO;
procedure driver is
use Ada, ASnip;
begin
Text_IO.put_line("=== RUNNING TESTS ===");
Text_IO.put("reserved_word_search:");
Testing.reserved_word_search;
Text_IO.put_line(" passed");
-- Text_IO.put("buffering:");
-- Testing.buffering;
-- Text_IO.put_line(" passed");
Text_IO.put("reading:");
Testing.reading;
Text_IO.put_line(" passed if files are the same");
Text_IO.put("simple tokenizing:");
Testing.simple_tokenizing;
Text_IO.put_line(" passed if files are the same");
end driver;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics 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. --
-- --
------------------------------------------------------------------------------
-- A simple example that blinks all the LEDs simultaneously, w/o tasking. It
-- does not use the "board" packages and so works directly with the platform
-- package STM32F40xx and the GPIO driver to control the LEDs.
-- Note that this is set up for an STM32F4_Discovery board because it uses
-- four LEDs, but it would be trivial to change it to another board. The
-- F4_Disco board is based on an STM32F405 MCU so we use the STM32F40xxx
-- package to get the GPIO port GPIO_D for the LEDs.
--
-- Note that using the STM32.Board package would make this even easier
-- but that is not what this program demonstrates.
with STM32.User_Button;
with STM32.Device; use STM32.Device;
with STM32.GPIO; use STM32.GPIO;
with Ada.Real_Time; use Ada.Real_Time;
procedure Demo_GPIO is
Green_LED : GPIO_Point renames PD12;
Orange_LED : GPIO_Point renames PD13;
Red_LED : GPIO_Point renames PD14;
Blue_LED : GPIO_Point renames PD15;
Pattern : GPIO_Points := (Orange_LED, Red_LED, Blue_LED, Green_LED);
-- The LEDs on the F4 Disco are not physically laid out "consecutively"
-- in such a way that we can simply go in enumeral order to get circular
-- rotation. Thus we define this mapping, using a consecutive index to get
-- the physical LED blinking order desired.
Next_LED : Positive range Pattern'Range := Pattern'First;
Clockwise : Boolean := True;
Period : constant Time_Span := Milliseconds (75); -- arbitrary
Next_Release : Time := Clock;
procedure Initialize_LEDs;
-- Enable the clock for the four LEDs and configure them as outputs. Note
-- there is a procedure defined in STM32.Board to do this. We do it here
-- to demonstrate the use of the GPIO interface.
procedure Initialize_LEDs is
Configuration : GPIO_Port_Configuration;
begin
Enable_Clock (GPIO_D);
Configuration.Mode := Mode_Out;
Configuration.Output_Type := Push_Pull;
Configuration.Speed := Speed_100MHz;
Configuration.Resistors := Floating;
Configure_IO (Pattern, Config => Configuration);
end Initialize_LEDs;
begin
Initialize_LEDs;
STM32.User_Button.Initialize;
loop
Pattern (Next_LED).Clear;
if STM32.User_Button.Has_Been_Pressed then
Clockwise := not Clockwise;
end if;
if Clockwise then
Next_LED := (if Next_LED = Pattern'Last then Pattern'First else Next_LED + 1);
else
Next_LED := (if Next_LED = Pattern'First then Pattern'Last else Next_LED - 1);
end if;
Pattern (Next_LED).Set;
Next_Release := Next_Release + Period;
delay until Next_Release;
end loop;
end Demo_GPIO;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
procedure Apsepp.Test_Node_Class.Generic_Assert (Cond : Boolean;
Message : String := "") is
begin
Assert (Test_Node_Tag, Cond, Message);
end;
|
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Discrim1 is
type SQUARE is array(INTEGER range <>,
INTEGER range <>) of INTEGER;
type LINEAR_TYPE is array(INTEGER range <>) of POSITIVE;
type STUFF(List_Size : POSITIVE) is
record
Matrix : SQUARE(1..List_Size, 1..List_Size);
Elements : INTEGER := List_Size * List_Size;
Linear : LINEAR_TYPE(1..List_Size);
Number : INTEGER := List_Size;
end record;
type ANOTHER_STUFF is new STUFF;
subtype STUFF_5 is STUFF(5);
Data_Store : STUFF(5);
Big_Store : STUFF(12);
Extra_Store : ANOTHER_STUFF(5);
More_Store : STUFF(5);
Five_Store : STUFF_5;
Name_Store : STUFF(List_Size => 5);
begin
for Index1 in Data_Store.Matrix'RANGE(1) loop
Data_Store.Linear(Index1) := Index1;
for Index2 in Data_Store.Matrix'RANGE(2) loop
Data_Store.Matrix(Index1, Index2) := Index1 * Index2;
end loop;
end loop;
Five_Store := Data_Store;
More_Store := Five_Store;
Put("The number of elements in More_Store.Matrix is");
Put(More_Store.Elements, 5);
New_Line;
end Discrim1;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.DMAC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- DMAC_CTRL_LVLEN array
type DMAC_CTRL_LVLEN_Field_Array is array (0 .. 3) of Boolean
with Component_Size => 1, Size => 4;
-- Type definition for DMAC_CTRL_LVLEN
type DMAC_CTRL_LVLEN_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LVLEN as a value
Val : HAL.UInt4;
when True =>
-- LVLEN as an array
Arr : DMAC_CTRL_LVLEN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for DMAC_CTRL_LVLEN_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- Control
type DMAC_CTRL_Register is record
-- Software Reset
SWRST : Boolean := False;
-- DMA Enable
DMAENABLE : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
-- Priority Level 0 Enable
LVLEN : DMAC_CTRL_LVLEN_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for DMAC_CTRL_Register use record
SWRST at 0 range 0 .. 0;
DMAENABLE at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
LVLEN at 0 range 8 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
end record;
-- CRC Beat Size
type CRCCTRL_CRCBEATSIZESelect is
(-- 8-bit bus transfer
BYTE,
-- 16-bit bus transfer
HWORD,
-- 32-bit bus transfer
WORD)
with Size => 2;
for CRCCTRL_CRCBEATSIZESelect use
(BYTE => 0,
HWORD => 1,
WORD => 2);
-- CRC Polynomial Type
type CRCCTRL_CRCPOLYSelect is
(-- CRC-16 (CRC-CCITT)
CRC16,
-- CRC32 (IEEE 802.3)
CRC32)
with Size => 2;
for CRCCTRL_CRCPOLYSelect use
(CRC16 => 0,
CRC32 => 1);
-- CRC Input Source
type CRCCTRL_CRCSRCSelect is
(-- CRC Disabled
DISABLE,
-- I/O interface
IO)
with Size => 6;
for CRCCTRL_CRCSRCSelect use
(DISABLE => 0,
IO => 1);
-- CRC Operating Mode
type CRCCTRL_CRCMODESelect is
(-- Default operating mode
DEFAULT,
-- Memory CRC monitor operating mode
CRCMON,
-- Memory CRC generation operating mode
CRCGEN)
with Size => 2;
for CRCCTRL_CRCMODESelect use
(DEFAULT => 0,
CRCMON => 2,
CRCGEN => 3);
-- CRC Control
type DMAC_CRCCTRL_Register is record
-- CRC Beat Size
CRCBEATSIZE : CRCCTRL_CRCBEATSIZESelect := SAM_SVD.DMAC.BYTE;
-- CRC Polynomial Type
CRCPOLY : CRCCTRL_CRCPOLYSelect := SAM_SVD.DMAC.CRC16;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- CRC Input Source
CRCSRC : CRCCTRL_CRCSRCSelect := SAM_SVD.DMAC.DISABLE;
-- CRC Operating Mode
CRCMODE : CRCCTRL_CRCMODESelect := SAM_SVD.DMAC.DEFAULT;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for DMAC_CRCCTRL_Register use record
CRCBEATSIZE at 0 range 0 .. 1;
CRCPOLY at 0 range 2 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
CRCSRC at 0 range 8 .. 13;
CRCMODE at 0 range 14 .. 15;
end record;
-- CRC Status
type DMAC_CRCSTATUS_Register is record
-- CRC Module Busy
CRCBUSY : Boolean := False;
-- CRC Zero
CRCZERO : Boolean := False;
-- CRC Error
CRCERR : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CRCSTATUS_Register use record
CRCBUSY at 0 range 0 .. 0;
CRCZERO at 0 range 1 .. 1;
CRCERR at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
-- Debug Control
type DMAC_DBGCTRL_Register is record
-- Debug Run
DBGRUN : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_DBGCTRL_Register use record
DBGRUN at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- DMAC_SWTRIGCTRL_SWTRIG array
type DMAC_SWTRIGCTRL_SWTRIG_Field_Array is array (0 .. 31) of Boolean
with Component_Size => 1, Size => 32;
-- Software Trigger Control
type DMAC_SWTRIGCTRL_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWTRIG as a value
Val : HAL.UInt32;
when True =>
-- SWTRIG as an array
Arr : DMAC_SWTRIGCTRL_SWTRIG_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAC_SWTRIGCTRL_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype DMAC_PRICTRL0_LVLPRI0_Field is HAL.UInt5;
-- Level 0 Quality of Service
type PRICTRL0_QOS0Select is
(-- Regular delivery
REGULAR,
-- Bandwidth shortage
SHORTAGE,
-- Latency sensitive
SENSITIVE,
-- Latency critical
CRITICAL)
with Size => 2;
for PRICTRL0_QOS0Select use
(REGULAR => 0,
SHORTAGE => 1,
SENSITIVE => 2,
CRITICAL => 3);
subtype DMAC_PRICTRL0_LVLPRI1_Field is HAL.UInt5;
-- Level 1 Quality of Service
type PRICTRL0_QOS1Select is
(-- Regular delivery
REGULAR,
-- Bandwidth shortage
SHORTAGE,
-- Latency sensitive
SENSITIVE,
-- Latency critical
CRITICAL)
with Size => 2;
for PRICTRL0_QOS1Select use
(REGULAR => 0,
SHORTAGE => 1,
SENSITIVE => 2,
CRITICAL => 3);
subtype DMAC_PRICTRL0_LVLPRI2_Field is HAL.UInt5;
-- Level 2 Quality of Service
type PRICTRL0_QOS2Select is
(-- Regular delivery
REGULAR,
-- Bandwidth shortage
SHORTAGE,
-- Latency sensitive
SENSITIVE,
-- Latency critical
CRITICAL)
with Size => 2;
for PRICTRL0_QOS2Select use
(REGULAR => 0,
SHORTAGE => 1,
SENSITIVE => 2,
CRITICAL => 3);
subtype DMAC_PRICTRL0_LVLPRI3_Field is HAL.UInt5;
-- Level 3 Quality of Service
type PRICTRL0_QOS3Select is
(-- Regular delivery
REGULAR,
-- Bandwidth shortage
SHORTAGE,
-- Latency sensitive
SENSITIVE,
-- Latency critical
CRITICAL)
with Size => 2;
for PRICTRL0_QOS3Select use
(REGULAR => 0,
SHORTAGE => 1,
SENSITIVE => 2,
CRITICAL => 3);
-- Priority Control 0
type DMAC_PRICTRL0_Register is record
-- Level 0 Channel Priority Number
LVLPRI0 : DMAC_PRICTRL0_LVLPRI0_Field := 16#0#;
-- Level 0 Quality of Service
QOS0 : PRICTRL0_QOS0Select := SAM_SVD.DMAC.SENSITIVE;
-- Level 0 Round-Robin Scheduling Enable
RRLVLEN0 : Boolean := False;
-- Level 1 Channel Priority Number
LVLPRI1 : DMAC_PRICTRL0_LVLPRI1_Field := 16#0#;
-- Level 1 Quality of Service
QOS1 : PRICTRL0_QOS1Select := SAM_SVD.DMAC.SENSITIVE;
-- Level 1 Round-Robin Scheduling Enable
RRLVLEN1 : Boolean := False;
-- Level 2 Channel Priority Number
LVLPRI2 : DMAC_PRICTRL0_LVLPRI2_Field := 16#0#;
-- Level 2 Quality of Service
QOS2 : PRICTRL0_QOS2Select := SAM_SVD.DMAC.SENSITIVE;
-- Level 2 Round-Robin Scheduling Enable
RRLVLEN2 : Boolean := False;
-- Level 3 Channel Priority Number
LVLPRI3 : DMAC_PRICTRL0_LVLPRI3_Field := 16#0#;
-- Level 3 Quality of Service
QOS3 : PRICTRL0_QOS3Select := SAM_SVD.DMAC.SENSITIVE;
-- Level 3 Round-Robin Scheduling Enable
RRLVLEN3 : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAC_PRICTRL0_Register use record
LVLPRI0 at 0 range 0 .. 4;
QOS0 at 0 range 5 .. 6;
RRLVLEN0 at 0 range 7 .. 7;
LVLPRI1 at 0 range 8 .. 12;
QOS1 at 0 range 13 .. 14;
RRLVLEN1 at 0 range 15 .. 15;
LVLPRI2 at 0 range 16 .. 20;
QOS2 at 0 range 21 .. 22;
RRLVLEN2 at 0 range 23 .. 23;
LVLPRI3 at 0 range 24 .. 28;
QOS3 at 0 range 29 .. 30;
RRLVLEN3 at 0 range 31 .. 31;
end record;
subtype DMAC_INTPEND_ID_Field is HAL.UInt5;
-- Interrupt Pending
type DMAC_INTPEND_Register is record
-- Channel ID
ID : DMAC_INTPEND_ID_Field := 16#0#;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Transfer Error
TERR : Boolean := False;
-- Transfer Complete
TCMPL : Boolean := False;
-- Channel Suspend
SUSP : Boolean := False;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- CRC Error
CRCERR : Boolean := False;
-- Fetch Error
FERR : Boolean := False;
-- Busy
BUSY : Boolean := False;
-- Pending
PEND : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for DMAC_INTPEND_Register use record
ID at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
TERR at 0 range 8 .. 8;
TCMPL at 0 range 9 .. 9;
SUSP at 0 range 10 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
CRCERR at 0 range 12 .. 12;
FERR at 0 range 13 .. 13;
BUSY at 0 range 14 .. 14;
PEND at 0 range 15 .. 15;
end record;
-- DMAC_INTSTATUS_CHINT array
type DMAC_INTSTATUS_CHINT_Field_Array is array (0 .. 31) of Boolean
with Component_Size => 1, Size => 32;
-- Interrupt Status
type DMAC_INTSTATUS_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHINT as a value
Val : HAL.UInt32;
when True =>
-- CHINT as an array
Arr : DMAC_INTSTATUS_CHINT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAC_INTSTATUS_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- DMAC_BUSYCH_BUSYCH array
type DMAC_BUSYCH_BUSYCH_Field_Array is array (0 .. 31) of Boolean
with Component_Size => 1, Size => 32;
-- Busy Channels
type DMAC_BUSYCH_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- BUSYCH as a value
Val : HAL.UInt32;
when True =>
-- BUSYCH as an array
Arr : DMAC_BUSYCH_BUSYCH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAC_BUSYCH_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- DMAC_PENDCH_PENDCH array
type DMAC_PENDCH_PENDCH_Field_Array is array (0 .. 31) of Boolean
with Component_Size => 1, Size => 32;
-- Pending Channels
type DMAC_PENDCH_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PENDCH as a value
Val : HAL.UInt32;
when True =>
-- PENDCH as an array
Arr : DMAC_PENDCH_PENDCH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAC_PENDCH_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- DMAC_ACTIVE_LVLEX array
type DMAC_ACTIVE_LVLEX_Field_Array is array (0 .. 3) of Boolean
with Component_Size => 1, Size => 4;
-- Type definition for DMAC_ACTIVE_LVLEX
type DMAC_ACTIVE_LVLEX_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LVLEX as a value
Val : HAL.UInt4;
when True =>
-- LVLEX as an array
Arr : DMAC_ACTIVE_LVLEX_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for DMAC_ACTIVE_LVLEX_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
subtype DMAC_ACTIVE_ID_Field is HAL.UInt5;
subtype DMAC_ACTIVE_BTCNT_Field is HAL.UInt16;
-- Active Channel and Levels
type DMAC_ACTIVE_Register is record
-- Read-only. Level 0 Channel Trigger Request Executing
LVLEX : DMAC_ACTIVE_LVLEX_Field;
-- unspecified
Reserved_4_7 : HAL.UInt4;
-- Read-only. Active Channel ID
ID : DMAC_ACTIVE_ID_Field;
-- unspecified
Reserved_13_14 : HAL.UInt2;
-- Read-only. Active Channel Busy
ABUSY : Boolean;
-- Read-only. Active Channel Block Transfer Count
BTCNT : DMAC_ACTIVE_BTCNT_Field;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAC_ACTIVE_Register use record
LVLEX at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
ID at 0 range 8 .. 12;
Reserved_13_14 at 0 range 13 .. 14;
ABUSY at 0 range 15 .. 15;
BTCNT at 0 range 16 .. 31;
end record;
--------------------------------------
-- DMAC_CHANNEL cluster's Registers --
--------------------------------------
-- Trigger Source
type CHCTRLA_TRIGSRCSelect is
(-- Only software/event triggers
DISABLE)
with Size => 7;
for CHCTRLA_TRIGSRCSelect use
(DISABLE => 0);
-- Trigger Action
type CHCTRLA_TRIGACTSelect is
(-- One trigger required for each block transfer
BLOCK,
-- One trigger required for each burst transfer
BURST,
-- One trigger required for each transaction
TRANSACTION)
with Size => 2;
for CHCTRLA_TRIGACTSelect use
(BLOCK => 0,
BURST => 2,
TRANSACTION => 3);
-- Burst Length
type CHCTRLA_BURSTLENSelect is
(-- Single-beat burst length
SINGLE,
-- 2-beats burst length
Val_2BEAT,
-- 3-beats burst length
Val_3BEAT,
-- 4-beats burst length
Val_4BEAT,
-- 5-beats burst length
Val_5BEAT,
-- 6-beats burst length
Val_6BEAT,
-- 7-beats burst length
Val_7BEAT,
-- 8-beats burst length
Val_8BEAT,
-- 9-beats burst length
Val_9BEAT,
-- 10-beats burst length
Val_10BEAT,
-- 11-beats burst length
Val_11BEAT,
-- 12-beats burst length
Val_12BEAT,
-- 13-beats burst length
Val_13BEAT,
-- 14-beats burst length
Val_14BEAT,
-- 15-beats burst length
Val_15BEAT,
-- 16-beats burst length
Val_16BEAT)
with Size => 4;
for CHCTRLA_BURSTLENSelect use
(SINGLE => 0,
Val_2BEAT => 1,
Val_3BEAT => 2,
Val_4BEAT => 3,
Val_5BEAT => 4,
Val_6BEAT => 5,
Val_7BEAT => 6,
Val_8BEAT => 7,
Val_9BEAT => 8,
Val_10BEAT => 9,
Val_11BEAT => 10,
Val_12BEAT => 11,
Val_13BEAT => 12,
Val_14BEAT => 13,
Val_15BEAT => 14,
Val_16BEAT => 15);
-- FIFO Threshold
type CHCTRLA_THRESHOLDSelect is
(-- Destination write starts after each beat source address read
Val_1BEAT,
-- Destination write starts after 2-beats source address read
Val_2BEATS,
-- Destination write starts after 4-beats source address read
Val_4BEATS,
-- Destination write starts after 8-beats source address read
Val_8BEATS)
with Size => 2;
for CHCTRLA_THRESHOLDSelect use
(Val_1BEAT => 0,
Val_2BEATS => 1,
Val_4BEATS => 2,
Val_8BEATS => 3);
-- Channel n Control A
type DMAC_CHCTRLA_DMAC_CHANNEL_Register is record
-- Channel Software Reset
SWRST : Boolean := False;
-- Channel Enable
ENABLE : Boolean := False;
-- unspecified
Reserved_2_5 : HAL.UInt4 := 16#0#;
-- Channel Run in Standby
RUNSTDBY : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Trigger Source
TRIGSRC : CHCTRLA_TRIGSRCSelect := SAM_SVD.DMAC.DISABLE;
-- unspecified
Reserved_15_19 : HAL.UInt5 := 16#0#;
-- Trigger Action
TRIGACT : CHCTRLA_TRIGACTSelect := SAM_SVD.DMAC.BLOCK;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Burst Length
BURSTLEN : CHCTRLA_BURSTLENSelect := SAM_SVD.DMAC.SINGLE;
-- FIFO Threshold
THRESHOLD : CHCTRLA_THRESHOLDSelect := SAM_SVD.DMAC.Val_1BEAT;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAC_CHCTRLA_DMAC_CHANNEL_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_5 at 0 range 2 .. 5;
RUNSTDBY at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
TRIGSRC at 0 range 8 .. 14;
Reserved_15_19 at 0 range 15 .. 19;
TRIGACT at 0 range 20 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
BURSTLEN at 0 range 24 .. 27;
THRESHOLD at 0 range 28 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- Software Command
type CHCTRLB_CMDSelect is
(-- No action
NOACT,
-- Channel suspend operation
SUSPEND,
-- Channel resume operation
RESUME)
with Size => 2;
for CHCTRLB_CMDSelect use
(NOACT => 0,
SUSPEND => 1,
RESUME => 2);
-- Channel n Control B
type DMAC_CHCTRLB_DMAC_CHANNEL_Register is record
-- Software Command
CMD : CHCTRLB_CMDSelect := SAM_SVD.DMAC.NOACT;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CHCTRLB_DMAC_CHANNEL_Register use record
CMD at 0 range 0 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- Channel Priority Level
type CHPRILVL_PRILVLSelect is
(-- Channel Priority Level 0 (Lowest Level)
LVL0,
-- Channel Priority Level 1
LVL1,
-- Channel Priority Level 2
LVL2,
-- Channel Priority Level 3 (Highest Level)
LVL3)
with Size => 2;
for CHPRILVL_PRILVLSelect use
(LVL0 => 0,
LVL1 => 1,
LVL2 => 2,
LVL3 => 3);
-- Channel n Priority Level
type DMAC_CHPRILVL_DMAC_CHANNEL_Register is record
-- Channel Priority Level
PRILVL : CHPRILVL_PRILVLSelect := SAM_SVD.DMAC.LVL0;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CHPRILVL_DMAC_CHANNEL_Register use record
PRILVL at 0 range 0 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- Channel Event Input Action
type CHEVCTRL_EVACTSelect is
(-- No action
NOACT,
-- Transfer and periodic transfer trigger
TRIG,
-- Conditional transfer trigger
CTRIG,
-- Conditional block transfer
CBLOCK,
-- Channel suspend operation
SUSPEND,
-- Channel resume operation
RESUME,
-- Skip next block suspend action
SSKIP,
-- Increase priority
INCPRI)
with Size => 3;
for CHEVCTRL_EVACTSelect use
(NOACT => 0,
TRIG => 1,
CTRIG => 2,
CBLOCK => 3,
SUSPEND => 4,
RESUME => 5,
SSKIP => 6,
INCPRI => 7);
-- Channel Event Output Mode
type CHEVCTRL_EVOMODESelect is
(-- Block event output selection. Refer to BTCTRL.EVOSEL for available
-- selections.
DEFAULT,
-- Ongoing trigger action
TRIGACT)
with Size => 2;
for CHEVCTRL_EVOMODESelect use
(DEFAULT => 0,
TRIGACT => 1);
-- Channel n Event Control
type DMAC_CHEVCTRL_DMAC_CHANNEL_Register is record
-- Channel Event Input Action
EVACT : CHEVCTRL_EVACTSelect := SAM_SVD.DMAC.NOACT;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Channel Event Output Mode
EVOMODE : CHEVCTRL_EVOMODESelect := SAM_SVD.DMAC.DEFAULT;
-- Channel Event Input Enable
EVIE : Boolean := False;
-- Channel Event Output Enable
EVOE : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CHEVCTRL_DMAC_CHANNEL_Register use record
EVACT at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
EVOMODE at 0 range 4 .. 5;
EVIE at 0 range 6 .. 6;
EVOE at 0 range 7 .. 7;
end record;
-- Channel n Interrupt Enable Clear
type DMAC_CHINTENCLR_DMAC_CHANNEL_Register is record
-- Channel Transfer Error Interrupt Enable
TERR : Boolean := False;
-- Channel Transfer Complete Interrupt Enable
TCMPL : Boolean := False;
-- Channel Suspend Interrupt Enable
SUSP : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CHINTENCLR_DMAC_CHANNEL_Register use record
TERR at 0 range 0 .. 0;
TCMPL at 0 range 1 .. 1;
SUSP at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
-- Channel n Interrupt Enable Set
type DMAC_CHINTENSET_DMAC_CHANNEL_Register is record
-- Channel Transfer Error Interrupt Enable
TERR : Boolean := False;
-- Channel Transfer Complete Interrupt Enable
TCMPL : Boolean := False;
-- Channel Suspend Interrupt Enable
SUSP : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CHINTENSET_DMAC_CHANNEL_Register use record
TERR at 0 range 0 .. 0;
TCMPL at 0 range 1 .. 1;
SUSP at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
-- Channel n Interrupt Flag Status and Clear
type DMAC_CHINTFLAG_DMAC_CHANNEL_Register is record
-- Channel Transfer Error
TERR : Boolean := False;
-- Channel Transfer Complete
TCMPL : Boolean := False;
-- Channel Suspend
SUSP : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CHINTFLAG_DMAC_CHANNEL_Register use record
TERR at 0 range 0 .. 0;
TCMPL at 0 range 1 .. 1;
SUSP at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
-- Channel n Status
type DMAC_CHSTATUS_DMAC_CHANNEL_Register is record
-- Channel Pending
PEND : Boolean := False;
-- Channel Busy
BUSY : Boolean := False;
-- Channel Fetch Error
FERR : Boolean := False;
-- Channel CRC Error
CRCERR : Boolean := False;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for DMAC_CHSTATUS_DMAC_CHANNEL_Register use record
PEND at 0 range 0 .. 0;
BUSY at 0 range 1 .. 1;
FERR at 0 range 2 .. 2;
CRCERR at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
type DMAC_CHANNEL_Cluster is record
-- Channel n Control A
CHCTRLA : aliased DMAC_CHCTRLA_DMAC_CHANNEL_Register;
-- Channel n Control B
CHCTRLB : aliased DMAC_CHCTRLB_DMAC_CHANNEL_Register;
-- Channel n Priority Level
CHPRILVL : aliased DMAC_CHPRILVL_DMAC_CHANNEL_Register;
-- Channel n Event Control
CHEVCTRL : aliased DMAC_CHEVCTRL_DMAC_CHANNEL_Register;
-- Channel n Interrupt Enable Clear
CHINTENCLR : aliased DMAC_CHINTENCLR_DMAC_CHANNEL_Register;
-- Channel n Interrupt Enable Set
CHINTENSET : aliased DMAC_CHINTENSET_DMAC_CHANNEL_Register;
-- Channel n Interrupt Flag Status and Clear
CHINTFLAG : aliased DMAC_CHINTFLAG_DMAC_CHANNEL_Register;
-- Channel n Status
CHSTATUS : aliased DMAC_CHSTATUS_DMAC_CHANNEL_Register;
end record
with Size => 128;
for DMAC_CHANNEL_Cluster use record
CHCTRLA at 16#0# range 0 .. 31;
CHCTRLB at 16#4# range 0 .. 7;
CHPRILVL at 16#5# range 0 .. 7;
CHEVCTRL at 16#6# range 0 .. 7;
CHINTENCLR at 16#C# range 0 .. 7;
CHINTENSET at 16#D# range 0 .. 7;
CHINTFLAG at 16#E# range 0 .. 7;
CHSTATUS at 16#F# range 0 .. 7;
end record;
type DMAC_CHANNEL_Clusters is array (0 .. 31) of DMAC_CHANNEL_Cluster;
-----------------
-- Peripherals --
-----------------
-- Direct Memory Access Controller
type DMAC_Peripheral is record
-- Control
CTRL : aliased DMAC_CTRL_Register;
-- CRC Control
CRCCTRL : aliased DMAC_CRCCTRL_Register;
-- CRC Data Input
CRCDATAIN : aliased HAL.UInt32;
-- CRC Checksum
CRCCHKSUM : aliased HAL.UInt32;
-- CRC Status
CRCSTATUS : aliased DMAC_CRCSTATUS_Register;
-- Debug Control
DBGCTRL : aliased DMAC_DBGCTRL_Register;
-- Software Trigger Control
SWTRIGCTRL : aliased DMAC_SWTRIGCTRL_Register;
-- Priority Control 0
PRICTRL0 : aliased DMAC_PRICTRL0_Register;
-- Interrupt Pending
INTPEND : aliased DMAC_INTPEND_Register;
-- Interrupt Status
INTSTATUS : aliased DMAC_INTSTATUS_Register;
-- Busy Channels
BUSYCH : aliased DMAC_BUSYCH_Register;
-- Pending Channels
PENDCH : aliased DMAC_PENDCH_Register;
-- Active Channel and Levels
ACTIVE : aliased DMAC_ACTIVE_Register;
-- Descriptor Memory Section Base Address
BASEADDR : aliased HAL.UInt32;
-- Write-Back Memory Section Base Address
WRBADDR : aliased HAL.UInt32;
DMAC_CHANNEL : aliased DMAC_CHANNEL_Clusters;
end record
with Volatile;
for DMAC_Peripheral use record
CTRL at 16#0# range 0 .. 15;
CRCCTRL at 16#2# range 0 .. 15;
CRCDATAIN at 16#4# range 0 .. 31;
CRCCHKSUM at 16#8# range 0 .. 31;
CRCSTATUS at 16#C# range 0 .. 7;
DBGCTRL at 16#D# range 0 .. 7;
SWTRIGCTRL at 16#10# range 0 .. 31;
PRICTRL0 at 16#14# range 0 .. 31;
INTPEND at 16#20# range 0 .. 15;
INTSTATUS at 16#24# range 0 .. 31;
BUSYCH at 16#28# range 0 .. 31;
PENDCH at 16#2C# range 0 .. 31;
ACTIVE at 16#30# range 0 .. 31;
BASEADDR at 16#34# range 0 .. 31;
WRBADDR at 16#38# range 0 .. 31;
DMAC_CHANNEL at 16#40# range 0 .. 4095;
end record;
-- Direct Memory Access Controller
DMAC_Periph : aliased DMAC_Peripheral
with Import, Address => DMAC_Base;
end SAM_SVD.DMAC;
|
--
-- It is not always easy to mix standard input/output and traditional files
-- This package provides a type that can work transparently with both.
-- The interface is very similar to the interface of Text_IO.
--
with Ada.Text_IO;
use Ada;
package Utilities.Hybrid_Files is
use type Text_IO.File_Mode;
type Hybrid_File is limited private;
function Mode (Item : Hybrid_File) return Text_IO.File_Mode;
function Get_Line (From : Hybrid_File) return String
with Pre => Mode (From) = Text_IO.In_File;
function End_Of_File (From : Hybrid_File) return Boolean
with Pre => Mode (From) = Text_IO.In_File;
procedure Put_Line (To : Hybrid_File; Item : String)
with Pre => Mode (To) = Text_IO.Out_File;
procedure New_Line (To : Hybrid_File)
with Pre => Mode (To) = Text_IO.Out_File;
procedure Open (File : in out Hybrid_File;
Name : String;
M : Text_IO.File_Mode)
with Post => Mode (File) = M;
procedure Create
(File : in out Hybrid_File;
Name : String;
M : Text_IO.File_Mode)
with Post => Mode (File) = M;
procedure Open (File : in out Hybrid_File;
M : Text_IO.File_Mode)
with Post => Mode (File) = M;
procedure Close (File : in out Hybrid_File);
private
type Hybrid_File is limited
record
File : Text_IO.File_Type;
Opened : Boolean := False;
Standard_IO : Boolean;
Mode : Text_IO.File_Mode;
end record;
function Get_Line (From : Hybrid_File) return String
is (if From.Standard_IO then
Text_IO.Get_Line
else
Text_IO.Get_Line (From.File));
function End_Of_File (From : Hybrid_File) return Boolean
is (if From.Standard_IO then
Text_IO.End_Of_File (Text_IO.Standard_Input)
else
Text_IO.End_Of_File (From.File));
function Mode (Item : Hybrid_File) return Text_IO.File_Mode
is (Item.Mode);
end Utilities.Hybrid_Files;
|
------------------------------------------------------------------------------
-- Copyright (c) 2016, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Characters.Latin_1;
with Natools.Smaz.Original_Hash;
package Natools.Smaz.Original is
pragma Pure (Natools.Smaz.Original);
LF : constant Character := Ada.Characters.Latin_1.LF;
CR : constant Character := Ada.Characters.Latin_1.CR;
Dictionary : constant Natools.Smaz.Dictionary
:= (Dict_Last => 253,
String_Size => 593,
Variable_Length_Verbatim => True,
Max_Word_Length => 7,
Offsets => (1, 2, 5, 6, 7, 8, 10, 11, 14, 15, 16, 17, 19, 20, 23, 25,
27, 29, 31, 32, 35, 37, 39, 40, 42, 43, 45, 47, 49, 50, 52, 54, 56,
59, 61, 64, 66, 68, 70, 71, 73, 76, 78, 80, 85, 86, 87, 89, 91, 95,
96, 99, 101, 103, 105, 107, 110, 112, 113, 115, 116, 117, 119, 121,
124, 127, 128, 130, 137, 140, 142, 145, 147, 150, 152, 154, 156,
159, 161, 164, 166, 168, 169, 172, 173, 175, 177, 181, 183, 185,
188, 189, 191, 193, 197, 199, 201, 203, 206, 208, 211, 216, 217,
219, 223, 225, 228, 230, 233, 235, 236, 237, 239, 242, 245, 247,
249, 252, 254, 257, 260, 262, 264, 267, 269, 272, 274, 277, 279,
283, 285, 287, 289, 292, 295, 298, 301, 303, 305, 307, 309, 312,
315, 318, 321, 323, 325, 328, 330, 333, 336, 338, 340, 342, 344,
347, 351, 354, 356, 359, 362, 365, 368, 371, 373, 375, 377, 379,
382, 385, 387, 390, 392, 395, 397, 400, 403, 406, 409, 411, 413,
415, 418, 420, 422, 425, 428, 430, 432, 435, 437, 440, 443, 445,
448, 450, 452, 454, 455, 459, 462, 464, 467, 470, 473, 474, 476,
479, 482, 484, 487, 492, 495, 497, 500, 502, 504, 507, 510, 513,
514, 516, 518, 519, 521, 523, 524, 526, 529, 531, 534, 536, 539,
541, 544, 546, 548, 550, 552, 555, 557, 559, 561, 563, 566, 569,
572, 575, 578, 581, 583, 584, 587, 590),
Values => " theetaofoandinse r th tinhethhhe to" & CR & LF & "ls d a"
& "anerc od on ofreof t , isuat n orwhichfmasitthat" & LF & "wa"
& "sen wes an i" & CR & "f gpnd snd ed wedhttp://forteingy The "
& "ctir hisst inarnt, toyng hwithlealto boubewere bseo enthang th"
& "eir""hifrom fin deionmev.veallre rirois cof tareea. her mer p"
& "es bytheydiraicnots, d tat celah neas tioon n tiowe a om, as o"
& "urlillchhadthise tg e" & CR & LF & " where coe oa us dss" & LF
& CR & LF & CR & LF & CR & "="" be es amaonet tor butelsol e ss,n"
& "oter waivhoe a rhats tnsch whtrut/havely ta ha ontha- latien p"
& "e rethereasssi fowaecourwhoitszfors>otun<imth ncate><verad wel"
& "yee nid clacil</rt widive, itwhi magexe cmen.com",
Hash => Natools.Smaz.Original_Hash.Hash'Access);
-- Dictionary built by filtering the S-expression below in the `smaz` tool
-- The S-expression itslef comes for the original `smaz.c`, after removing
-- the commas.
-- ((
-- )" " "the" "e" "t" "a" "of" "o" "and" "i" "n" "s" "e " "r" " th" (
-- )" t" "in" "he" "th" "h" "he " "to" "\r\n" "l" "s " "d" " a" "an" (
-- )"er" "c" " o" "d " "on" " of" "re" "of " "t " ", " "is" "u" "at" (
-- )" " "n " "or" "which" "f" "m" "as" "it" "that" "\n" "was" "en" (
-- )" " " w" "es" " an" " i" "\r" "f " "g" "p" "nd" " s" "nd " "ed " (
-- )"w" "ed" "http://" "for" "te" "ing" "y " "The" " c" "ti" "r " "his" (
-- )"st" " in" "ar" "nt" "," " to" "y" "ng" " h" "with" "le" "al" "to " (
-- )"b" "ou" "be" "were" " b" "se" "o " "ent" "ha" "ng " "their" "\"" (
-- )"hi" "from" " f" "in " "de" "ion" "me" "v" "." "ve" "all" "re " (
-- )"ri" "ro" "is " "co" "f t" "are" "ea" ". " "her" " m" "er " " p" (
-- )"es " "by" "they" "di" "ra" "ic" "not" "s, " "d t" "at " "ce" "la" (
-- )"h " "ne" "as " "tio" "on " "n t" "io" "we" " a " "om" ", a" "s o" (
-- )"ur" "li" "ll" "ch" "had" "this" "e t" "g " "e\r\n" " wh" "ere" (
-- )" co" "e o" "a " "us" " d" "ss" "\n\r\n" "\r\n\r" "=\"" " be" " e" (
-- )"s a" "ma" "one" "t t" "or " "but" "el" "so" "l " "e s" "s," "no" (
-- )"ter" " wa" "iv" "ho" "e a" " r" "hat" "s t" "ns" "ch " "wh" "tr" (
-- )"ut" "/" "have" "ly " "ta" " ha" " on" "tha" "-" " l" "ati" "en " (
-- )"pe" " re" "there" "ass" "si" " fo" "wa" "ec" "our" "who" "its" "z" (
-- )"fo" "rs" ">" "ot" "un" "<" "im" "th " "nc" "ate" "><" "ver" "ad" (
-- )" we" "ly" "ee" " n" "id" " cl" "ac" "il" "</" "rt" " wi" "div" (
-- )"e, " " it" "whi" " ma" "ge" "x" "e c" "men" ".com")
end Natools.Smaz.Original;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . B I T F I E L D _ U T I L S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2019-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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Bitfield_Utils;
package System.Bitfields is
-- Instances of the generic package in System.Bitfield_Utils. So far
-- we have just one, which defaults to the natural endianness of the
-- machine. We might someday want to support Scalar_Storage_Order.
-- Note: we use Long_Long_Integer'Size / 2 instead of 32 to support
-- specifying a target configuration file where the largest integer is
-- 32 bits instead of 64.
Val_Bits : constant := Long_Long_Integer'Size / 2;
Val_Bytes : constant := Val_Bits / System.Storage_Unit;
type Val_2 is mod 2**(Val_Bits * 2) with Alignment => Val_Bytes;
pragma Provide_Shift_Operators (Val_2);
type Val is mod 2**Val_Bits with Alignment => Val_Bytes;
package Utils is new System.Bitfield_Utils.G (Val, Val_2);
procedure Copy_Bitfield
(Src_Address : Address;
Src_Offset : Utils.Bit_Offset_In_Byte;
Dest_Address : Address;
Dest_Offset : Utils.Bit_Offset_In_Byte;
Size : Utils.Bit_Size)
renames Utils.Copy_Bitfield;
end System.Bitfields;
|
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.RNG; use STM32_SVD.RNG;
package body STM32.RNG is
----------------------
-- Enable_RNG_Clock --
----------------------
procedure Enable_RNG_Clock is
begin
RCC_Periph.AHB2ENR.RNGEN := True;
end Enable_RNG_Clock;
----------------
-- Enable_RNG --
----------------
procedure Enable_RNG is
begin
RNG_Periph.CR.RNGEN := True;
end Enable_RNG;
-----------------
-- Disable_RNG --
-----------------
procedure Disable_RNG is
begin
RNG_Periph.CR.RNGEN := False;
end Disable_RNG;
---------------
-- Reset_RNG --
---------------
procedure Reset_RNG
is
begin
RCC_Periph.AHB2RSTR.RNGRST := True;
RCC_Periph.AHB2RSTR.RNGRST := False;
end Reset_RNG;
-----------------
-- RNG_Enabled --
-----------------
function RNG_Enabled return Boolean is
(RNG_Periph.CR.RNGEN);
--------------------------
-- Enable_RNG_Interrupt --
--------------------------
procedure Enable_RNG_Interrupt is
begin
RNG_Periph.CR.IE := True;
end Enable_RNG_Interrupt;
---------------------------
-- Disable_RNG_Interrupt --
---------------------------
procedure Disable_RNG_Interrupt is
begin
RNG_Periph.CR.IE := False;
end Disable_RNG_Interrupt;
---------------------------
-- RNG_Interrupt_Enabled --
---------------------------
function RNG_Interrupt_Enabled return Boolean is
(RNG_Periph.CR.IE);
--------------
-- RNG_Data --
--------------
function RNG_Data return UInt32
is (RNG_Periph.DR);
--------------------
-- RNG_Data_Ready --
--------------------
function RNG_Data_Ready return Boolean
is (RNG_Periph.SR.DRDY);
---------------------------
-- RNG_Seed_Error_Status --
---------------------------
function RNG_Seed_Error_Status return Boolean is
(RNG_Periph.SR.SECS);
----------------------------
-- RNG_Clock_Error_Status --
----------------------------
function RNG_Clock_Error_Status return Boolean is
(RNG_Periph.SR.CECS);
---------------------------------
-- Clear_RNG_Seed_Error_Status --
---------------------------------
procedure Clear_RNG_Seed_Error_Status
is
begin
RNG_Periph.SR.SECS := False;
end Clear_RNG_Seed_Error_Status;
----------------------------------
-- Clear_RNG_Clock_Error_Status --
----------------------------------
procedure Clear_RNG_Clock_Error_Status
is
begin
RNG_Periph.SR.CECS := False;
end Clear_RNG_Clock_Error_Status;
end STM32.RNG;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014-2019, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Web.Simple_Pages provides a simple implementation of Sites.Page --
-- and Tags.Visible, representing a single page in a usual blog-style --
-- static site. --
------------------------------------------------------------------------------
with Ada.Calendar;
with Natools.S_Expressions.Atom_Refs;
with Natools.S_Expressions.Lockable;
with Natools.Web.Sites;
with Natools.Web.Tags;
private with Natools.References;
private with Natools.S_Expressions.Caches;
private with Natools.Storage_Pools;
private with Natools.Web.Containers;
private with Natools.Web.Comments;
private with Natools.Web.String_Tables;
package Natools.Web.Simple_Pages is
type Page_Template is private;
procedure Set_Comments
(Object : in out Page_Template;
Expression : in out S_Expressions.Lockable.Descriptor'Class);
procedure Set_Comment_Path_Prefix
(Object : in out Page_Template;
Prefix : in S_Expressions.Atom);
procedure Set_Comment_Path_Suffix
(Object : in out Page_Template;
Suffix : in S_Expressions.Atom);
procedure Set_Elements
(Object : in out Page_Template;
Expression : in out S_Expressions.Lockable.Descriptor'Class);
procedure Set_Component
(Object : in out Page_Template;
Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class;
Known_Component : out Boolean);
procedure Update
(Object : in out Page_Template;
Expression : in out S_Expressions.Lockable.Descriptor'Class);
Default_Template : constant Page_Template;
type Page_Ref is new Tags.Visible and Sites.Page with private;
function Create
(File_Path, Web_Path : in S_Expressions.Atom_Refs.Immutable_Reference;
Template : in Page_Template := Default_Template;
Name : in S_Expressions.Atom := S_Expressions.Null_Atom)
return Page_Ref;
function Create
(Expression : in out S_Expressions.Lockable.Descriptor'Class;
Template : in Page_Template := Default_Template;
Name : in S_Expressions.Atom := S_Expressions.Null_Atom)
return Page_Ref;
procedure Get_Lifetime
(Page : in Page_Ref;
Publication : out Ada.Calendar.Time;
Has_Publication : out Boolean;
Expiration : out Ada.Calendar.Time;
Has_Expiration : out Boolean);
function Get_Tags (Page : Page_Ref) return Tags.Tag_List;
procedure Register
(Page : in Page_Ref;
Builder : in out Sites.Site_Builder;
Path : in S_Expressions.Atom);
overriding procedure Render
(Exchange : in out Sites.Exchange;
Object : in Page_Ref;
Expression : in out S_Expressions.Lockable.Descriptor'Class);
overriding procedure Respond
(Object : in out Page_Ref;
Exchange : in out Sites.Exchange;
Extra_Path : in S_Expressions.Atom);
type Loader is new Sites.Page_Loader with private;
overriding procedure Load
(Object : in out Loader;
Builder : in out Sites.Site_Builder;
Path : in S_Expressions.Atom);
function Create (File : in S_Expressions.Atom)
return Sites.Page_Loader'Class;
procedure Register_Loader (Site : in out Sites.Site);
private
type Page_Template is record
Comments : Containers.Optional_Expression;
Comment_Path_Prefix : S_Expressions.Atom_Refs.Immutable_Reference;
Comment_Path_Suffix : S_Expressions.Atom_Refs.Immutable_Reference;
Elements : Containers.Expression_Maps.Constant_Map;
Name : S_Expressions.Atom_Refs.Immutable_Reference;
end record;
Default_Template : constant Page_Template := (others => <>);
type Page_Data is new Tags.Visible with record
Self : Tags.Visible_Access;
File_Path : S_Expressions.Atom_Refs.Immutable_Reference;
Web_Path : S_Expressions.Atom_Refs.Immutable_Reference;
Elements : Containers.Expression_Maps.Constant_Map;
Tags : Web.Tags.Tag_List;
Dates : Containers.Date_Maps.Constant_Map;
Comment_List : Comments.Comment_List;
Maps : String_Tables.String_Table_Map;
end record;
not overriding procedure Get_Element
(Data : in Page_Data;
Name : in S_Expressions.Atom;
Element : out S_Expressions.Caches.Cursor;
Found : out Boolean);
overriding procedure Render
(Exchange : in out Sites.Exchange;
Object : in Page_Data;
Expression : in out S_Expressions.Lockable.Descriptor'Class);
package Data_Refs is new References
(Page_Data,
Storage_Pools.Access_In_Default_Pool'Storage_Pool,
Storage_Pools.Access_In_Default_Pool'Storage_Pool);
type Page_Ref is new Tags.Visible and Sites.Page with record
Ref : Data_Refs.Reference;
end record;
function Get_Tags (Page : Page_Ref) return Tags.Tag_List
is (Page.Ref.Query.Data.Tags);
type Loader is new Sites.Page_Loader with record
File_Path : S_Expressions.Atom_Refs.Immutable_Reference;
end record;
end Natools.Web.Simple_Pages;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T K R --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Gnatvsn;
with Krunch;
with Switch; use Switch;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Command_Line; use Ada.Command_Line;
with System.IO; use System.IO;
procedure Gnatkr is
pragma Ident (Gnatvsn.Gnat_Static_Version_String);
Count : Natural;
Maxlen : Integer;
Exit_Program : exception;
function Get_Maximum_File_Name_Length return Integer;
pragma Import (C, Get_Maximum_File_Name_Length,
"__gnat_get_maximum_file_name_length");
procedure Usage;
-- Output usage information
-----------
-- Usage --
-----------
procedure Usage is
begin
Put_Line ("Usage: gnatkr filename[.extension] [krunch-count]");
end Usage;
procedure Check_Version_And_Help is new Check_Version_And_Help_G (Usage);
begin
Check_Version_And_Help ("GNATKR", "1992");
Count := Argument_Count;
if Count < 1 or else Count > 2 then
Usage;
raise Exit_Program;
else
-- If the length (krunch-count) argument is omitted use the system
-- default if there is one, otherwise use 8.
if Count = 1 then
Maxlen := Get_Maximum_File_Name_Length;
if Maxlen = -1 then
Maxlen := 8;
end if;
else
Maxlen := 0;
for J in Argument (2)'Range loop
if Argument (2) (J) /= ' ' then
if Argument (2) (J) not in '0' .. '9' then
Put_Line ("Illegal argument for krunch-count");
raise Exit_Program;
else
Maxlen := Maxlen * 10 +
Character'Pos (Argument (2) (J)) - Character'Pos ('0');
end if;
end if;
end loop;
-- Zero means crunch only system files
if Maxlen = 0 then
Maxlen := Natural'Last;
end if;
end if;
declare
Fname : String := Argument (1);
Klen : Natural := Fname'Length;
Extp : Boolean := False;
-- True if extension is present
Ext : Natural := 0;
-- If extension is present, points to it (init to prevent warning)
begin
-- Remove extension if present (an extension is defined as the
-- section of the file name after the last dot in the name. If
-- there is no dot in the name, then
-- name is all lower case and contains no other instances of dots)
for J in reverse 1 .. Klen loop
if Fname (J) = '.' then
Extp := True;
Ext := J;
Klen := J - 1;
exit;
end if;
end loop;
-- Fold to lower case and replace dots by dashes
for J in 1 .. Klen loop
Fname (J) := To_Lower (Fname (J));
if Fname (J) = '.' then
Fname (J) := '-';
end if;
end loop;
Krunch (Fname, Klen, Maxlen, False);
Put (Fname (1 .. Klen));
if Extp then
Put (Fname (Ext .. Fname'Length));
end if;
New_Line;
end;
end if;
Set_Exit_Status (Success);
exception
when Exit_Program =>
Set_Exit_Status (Failure);
end Gnatkr;
|
with Screen_Interface; use Screen_Interface;
with Giza.GUI; use Giza.GUI;
with Giza.Context;
with Clock_Window;
pragma Warnings (Off, "*not referenced");
with Utils;
pragma Warnings (On, "*not referenced");
procedure GUI_Test is
begin
Screen_Interface.Initialize;
Giza.GUI.Set_Context (new Giza.Context.Instance);
Giza.GUI.Set_Backend (new Screen_Interface.GTKada_Backend);
Push (new Clock_Window.Instance);
Event_Loop;
end GUI_Test;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.