repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 4,616 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Line_Style_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Line_Style_Attribute_Node is
begin
return Self : Style_Line_Style_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Line_Style_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Line_Style_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Line_Style_Attribute,
Style_Line_Style_Attribute_Node'Tag);
end Matreshka.ODF_Style.Line_Style_Attributes;
|
annexi-strayline/AURA | Ada | 4,085 | ads | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package implements a Hashed_Map set which maps a single Subsystem to
-- Subsystem Set. One such map is maintained by the registry for all AURA
-- Subsystems that have been identified as requring Auto Configuration
with Ada.Containers.Hashed_Maps;
with Unit_Names;
with Unit_Names.Hash;
with Unit_Names.Sets;
package Registrar.Dependency_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Unit_Names.Unit_Name,
Element_Type => Unit_Names.Sets.Set,
Hash => Unit_Names.Hash,
Equivalent_Keys => Unit_Names."=",
"=" => Unit_Names.Sets."=");
|
Fabien-Chouteau/AGATE | Ada | 3,249 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017-2018, Fabien Chouteau --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
private package AGATE.SysCalls is
type Syscall_ID is (Yield, Clock, Delay_Until, Sem_Signal, Sem_Wait,
Shutdown, Mutex_Wait_Lock, Mutex_Try_Lock,
Mutex_Release, Print);
function Call (ID : Syscall_ID;
Arg1, Arg2, Arg3 : Word := 0)
return UInt64;
procedure Call (ID : Syscall_ID;
Arg1, Arg2, Arg3 : Word := 0);
type Syscall_Handler is access
function (Arg1, Arg2, Arg3 : Word) return UInt64;
function Registred (ID : Syscall_ID) return Boolean;
-- Return True if a handler is registered for the given syscall
procedure Register (ID : Syscall_ID;
Handler : not null Syscall_Handler)
with Pre => not Registred (ID);
-- Register a handler for the given syscall
end AGATE.SysCalls;
|
OneWingedShark/Byron | Ada | 552 | adb | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
with
Ada.Containers.Vectors;
Procedure Lexington.Aux.P19(Data : in out Token_Vector_Pkg.Vector) is
-- Filters out all tokens of the given ID.
Procedure Filter( ID : Token_ID ) is
begin
for Index in reverse Data.First_Index..Data.Last_Index loop
if Token_Pkg.ID(Data(Index)) = ID then
Data.Delete( Index );
end if;
end loop;
End Filter;
Begin
Filter( Comment );
Filter( Whitespace );
Filter( End_of_Line );
End Lexington.Aux.P19;
|
AdaCore/Ada_Drivers_Library | Ada | 4,468 | adb | ------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
package body Logging_With_Categories is
Is_Enabled : array (Categories) of Boolean :=
(others => Categories_Enabled_By_Default);
Cat_Priorities : array (Categories) of Priorities :=
(others => Default_Priority);
Prefix_Enabled : array (Categories) of Boolean :=
(others => Prefix_Enabled_By_Default);
--------------
-- Log_Line --
--------------
procedure Log_Line (Cat : Categories; Str : String) is
begin
if Is_Enabled (Cat) then
if Prefix_Enabled (Cat) then
Log_Line_Backend (Cat'Img & ": " & Str, Cat_Priorities (Cat));
else
Log_Line_Backend (Str, Cat_Priorities (Cat));
end if;
end if;
end Log_Line;
--------------
-- Log_Line --
--------------
procedure Log_Line (Str : String) is
begin
Log_Line (Default_Category, Str);
end Log_Line;
-------------
-- Enabled --
-------------
function Enabled (Cat : Categories) return Boolean
is (Is_Enabled (Cat));
------------
-- Enable --
------------
procedure Enable
(Cat : Categories)
is
begin
Is_Enabled (Cat) := True;
end Enable;
-------------
-- Disable --
-------------
procedure Disable
(Cat : Categories)
is
begin
Is_Enabled (Cat) := False;
end Disable;
-------------------
-- Enable_Prefix --
-------------------
procedure Enable_Prefix (Cat : Categories) is
begin
Prefix_Enabled (Cat) := True;
end Enable_Prefix;
--------------------
-- Disable_Prefix --
--------------------
procedure Disable_Prefix (Cat : Categories) is
begin
Prefix_Enabled (Cat) := False;
end Disable_Prefix;
--------------
-- Priority --
--------------
function Priority (Cat : Categories) return Priorities
is (Cat_Priorities (Cat));
------------------
-- Set_Priority --
------------------
procedure Set_Priority
(Cat : Categories;
Prio : Priorities)
is
begin
Cat_Priorities (Cat) := Prio;
end Set_Priority;
end Logging_With_Categories;
|
charlie5/lace | Ada | 1,269 | adb | with
chat.Client.local,
lace.Event.utility,
ada.Characters.latin_1,
ada.command_Line,
ada.Text_IO,
ada.Exceptions;
procedure launch_simple_chat_Client
--
-- Starts a chat client.
--
is
use ada.Text_IO;
begin
-- Usage
--
if ada.command_Line.argument_Count /= 1
then
put_Line ("Usage: $ ./launch_simple_chat_Client <nickname>");
return;
end if;
declare
use chat.Client.local;
client_Name : constant String := ada.command_Line.Argument (1);
the_Client : chat.Client.local.item := to_Client (client_Name);
begin
the_Client.start;
end;
exception
when E : others =>
lace.Event.utility.close;
new_Line;
put_Line ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
put_Line ("Unhandled exception, aborting. Please report the following to developer.");
put_Line ("________________________________________________________________________");
put_Line (ada.Exceptions.exception_Information (E));
put (ada.Characters.latin_1.ESC & "[1A"); -- Move cursor up.
put_Line ("________________________________________________________________________");
new_Line;
end launch_simple_chat_Client;
|
Rodeo-McCabe/orka | Ada | 982 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ahven.Framework;
package Test_SIMD_SSE_Swizzle is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
private
procedure Test_Shuffle;
procedure Test_Transpose_Function;
procedure Test_Transpose_Procedure;
end Test_SIMD_SSE_Swizzle;
|
reznikmm/matreshka | Ada | 6,649 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
with AMF.CMOF.Associations;
with AMF.CMOF.Packages;
with AMF.CMOF.Properties;
with AMF.CMOF.Types;
package Generator.Names is
function To_Ada_Identifier
(Name : Wide_Wide_String) return Wide_Wide_String;
function To_Ada_Identifier
(Name : League.Strings.Universal_String) return Wide_Wide_String;
function Plural (Name : Wide_Wide_String) return Wide_Wide_String;
function Owning_Metamodel_Name
(Element : not null access AMF.CMOF.Elements.CMOF_Element'Class)
return League.Strings.Universal_String;
-- Returns name of the owning metamodel. It is computed as name of first
-- enclosing package of the specified element.
function Owning_Metamodel_Ada_Name
(Element : not null access AMF.CMOF.Elements.CMOF_Element'Class)
return League.Strings.Universal_String;
-- Returns Ada name of the owning metamodel. It is computed as name of
-- first enclosing package of the specified element.
---------------------------------
-- Metamodel package constants --
---------------------------------
function Association_Constant_Name
(Association : not null AMF.CMOF.Associations.CMOF_Association_Access)
return League.Strings.Universal_String;
function Association_Constant_Package_Name
(Association : not null AMF.CMOF.Associations.CMOF_Association_Access)
return League.Strings.Universal_String;
function Association_Constant_Qualified_Name
(Association : not null AMF.CMOF.Associations.CMOF_Association_Access)
return League.Strings.Universal_String;
function Type_Constant_Name
(Element : not null access constant AMF.CMOF.Types.CMOF_Type'Class)
return League.Strings.Universal_String;
function Type_Constant_Package_Name
(Element : not null access constant AMF.CMOF.Types.CMOF_Type'Class)
return League.Strings.Universal_String;
function Type_Constant_Qualified_Name
(Element : not null access constant AMF.CMOF.Types.CMOF_Type'Class)
return League.Strings.Universal_String;
function Package_Constant_Name
(Element : not null AMF.CMOF.Packages.CMOF_Package_Access)
return League.Strings.Universal_String;
function Package_Constant_Package_Name
(Element : not null AMF.CMOF.Packages.CMOF_Package_Access)
return League.Strings.Universal_String;
function Package_Constant_Qualified_Name
(Element : not null AMF.CMOF.Packages.CMOF_Package_Access)
return League.Strings.Universal_String;
function Property_Constant_Name
(Property : not null AMF.CMOF.Properties.CMOF_Property_Access)
return League.Strings.Universal_String;
function Property_Constant_Package_Name
(Property : not null AMF.CMOF.Properties.CMOF_Property_Access)
return League.Strings.Universal_String;
function Property_Constant_Qualified_Name
(Property : not null AMF.CMOF.Properties.CMOF_Property_Access)
return League.Strings.Universal_String;
function Element_Constant_Package_Name
(Element : not null AMF.CMOF.Elements.CMOF_Element_Access)
return League.Strings.Universal_String;
function Element_Constant_Qualified_Name
(Element : not null AMF.CMOF.Elements.CMOF_Element_Access)
return League.Strings.Universal_String;
end Generator.Names;
|
zhmu/ananas | Ada | 9,072 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 1 0 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_110 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_110;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
-- The following declarations are for the case where the address
-- passed to GetU_110 or SetU_110 is not guaranteed to be aligned.
-- These routines are used when the packed array is itself a
-- component of a packed record, and therefore may not be aligned.
type ClusterU is new Cluster;
for ClusterU'Alignment use 1;
type ClusterU_Ref is access ClusterU;
type Rev_ClusterU is new ClusterU
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_ClusterU_Ref is access Rev_ClusterU;
------------
-- Get_110 --
------------
function Get_110
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_110
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_110;
-------------
-- GetU_110 --
-------------
function GetU_110
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_110
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end GetU_110;
------------
-- Set_110 --
------------
procedure Set_110
(Arr : System.Address;
N : Natural;
E : Bits_110;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_110;
-------------
-- SetU_110 --
-------------
procedure SetU_110
(Arr : System.Address;
N : Natural;
E : Bits_110;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end SetU_110;
end System.Pack_110;
|
stcarrez/ada-asf | Ada | 28,556 | adb | -----------------------------------------------------------------------
-- asf-views-nodes-jsf -- JSF Core Tag Library
-- Copyright (C) 2010 - 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with GNAT.Regpat;
with Ada.Exceptions;
with Util.Beans.Objects;
with ASF.Converters;
with ASF.Converters.Dates;
with ASF.Validators.Texts;
with ASF.Validators.Numbers;
with ASF.Components.Holders;
with ASF.Components.Core.Views;
package body ASF.Views.Nodes.Jsf is
-- Get the date conversion global format.
function Get_Format (Node : in Convert_Date_Time_Tag_Node;
Context : in Contexts.Facelets.Facelet_Context'Class)
return ASF.Converters.Dates.Format_Type;
-- Get a dateStyle or a timeStyle attribute value.
function Get_Date_Style (Node : in Convert_Date_Time_Tag_Node;
Name : in String;
Attr : in Tag_Attribute_Access;
Context : in Contexts.Facelets.Facelet_Context'Class)
return ASF.Converters.Dates.Style_Type;
-- ------------------------------
-- Converter Tag
-- ------------------------------
-- ------------------------------
-- Create the Converter Tag
-- ------------------------------
function Create_Converter_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Views.Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Converter_Tag_Node_Access := new Converter_Tag_Node;
Conv : constant Tag_Attribute_Access := Find_Attribute (Attributes,
"converterId");
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
if Conv = null then
Node.Error ("Missing 'converterId' attribute");
else
Node.Converter := EL.Objects.To_Object (Conv.Value);
end if;
return Node.all'Access;
end Create_Converter_Tag_Node;
-- ------------------------------
-- Build the component tree from the tag node and attach it as
-- the last child of the given parent. Calls recursively the
-- method to create children. Get the specified converter and
-- add it to the parent component. This operation does not create any
-- new UIComponent.
-- ------------------------------
overriding
procedure Build_Components (Node : access Converter_Tag_Node;
Parent : in UIComponent_Access;
Context : in out Contexts.Facelets.Facelet_Context'Class) is
use ASF.Components.Holders;
use type ASF.Converters.Converter_Access;
Cvt : constant Converters.Converter_Access := Context.Get_Converter (Node.Converter);
begin
if not (Parent.all in Value_Holder'Class) then
Node.Error ("Parent component is not an instance of Value_Holder");
return;
end if;
if Cvt = null then
Node.Error ("Converter '{0}' was not found",
Util.Beans.Objects.To_String (Node.Converter));
return;
end if;
declare
VH : constant access Value_Holder'Class := Value_Holder'Class (Parent.all)'Access;
begin
VH.Set_Converter (Converter => Cvt);
end;
end Build_Components;
-- ------------------------------
-- Convert Date Time Tag
-- ------------------------------
-- ------------------------------
-- Create the Converter Tag
-- ------------------------------
function Create_Convert_Date_Time_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Convert_Date_Time_Tag_Node_Access := new Convert_Date_Time_Tag_Node;
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
Node.Date_Style := Find_Attribute (Attributes, "dateStyle");
Node.Time_Style := Find_Attribute (Attributes, "timeStyle");
Node.Locale := Find_Attribute (Attributes, "locale");
Node.Pattern := Find_Attribute (Attributes, "pattern");
Node.Format := Find_Attribute (Attributes, "type");
return Node.all'Access;
end Create_Convert_Date_Time_Tag_Node;
-- ------------------------------
-- Get a dateStyle or a timeStyle attribute value.
-- ------------------------------
function Get_Date_Style (Node : in Convert_Date_Time_Tag_Node;
Name : in String;
Attr : in Tag_Attribute_Access;
Context : in Contexts.Facelets.Facelet_Context'Class)
return ASF.Converters.Dates.Style_Type is
Style : constant String := Get_Value (Attr, Context, "");
begin
if Style = "default" or else Style = "" then
return ASF.Converters.Dates.DEFAULT;
elsif Style = "short" then
return ASF.Converters.Dates.SHORT;
elsif Style = "medium" then
return ASF.Converters.Dates.MEDIUM;
elsif Style = "long" then
return ASF.Converters.Dates.LONG;
elsif Style = "full" then
return ASF.Converters.Dates.FULL;
else
Node.Error ("Invalid attribute {0}: {1}", Name, Style);
return ASF.Converters.Dates.DEFAULT;
end if;
end Get_Date_Style;
-- ------------------------------
-- Get the date conversion global format.
-- ------------------------------
function Get_Format (Node : in Convert_Date_Time_Tag_Node;
Context : in Contexts.Facelets.Facelet_Context'Class)
return ASF.Converters.Dates.Format_Type is
Format : constant String := Get_Value (Node.Format, Context, "");
begin
if Format = "both" then
return ASF.Converters.Dates.BOTH;
elsif Format = "time" then
return ASF.Converters.Dates.TIME;
elsif Format = "date" then
return ASF.Converters.Dates.DATE;
else
Node.Error ("Invalid attribute type: {0}", Format);
return ASF.Converters.Dates.BOTH;
end if;
end Get_Format;
-- ------------------------------
-- Build the component tree from the tag node and attach it as
-- the last child of the given parent. Calls recursively the
-- method to create children. Get the specified converter and
-- add it to the parent component. This operation does not create any
-- new UIComponent.
-- ------------------------------
overriding
procedure Build_Components (Node : access Convert_Date_Time_Tag_Node;
Parent : in UIComponent_Access;
Context : in out Contexts.Facelets.Facelet_Context'Class) is
use ASF.Components.Holders;
use ASF.Converters;
C : ASF.Converters.Dates.Date_Converter_Access;
Locale : constant String := Get_Value (Node.Locale, Context, "");
begin
if not (Parent.all in Value_Holder'Class) then
Node.Error ("Parent component is not an instance of Value_Holder");
return;
end if;
if Node.Pattern /= null then
C := Dates.Create_Date_Converter (Date => Converters.Dates.DEFAULT,
Time => Converters.Dates.DEFAULT,
Format => Converters.Dates.CONVERTER_PATTERN,
Locale => Locale,
Pattern => Get_Value (Node.Pattern, Context, ""));
elsif Node.Format /= null then
C := Dates.Create_Date_Converter (Date => Get_Date_Style (Node.all, "dateStyle",
Node.Date_Style, Context),
Time => Get_Date_Style (Node.all, "timeStyle",
Node.Time_Style, Context),
Format => Get_Format (Node.all, Context),
Locale => Locale,
Pattern => "");
elsif Node.Date_Style /= null then
C := Dates.Create_Date_Converter (Date => Get_Date_Style (Node.all, "dateStyle",
Node.Date_Style, Context),
Time => Converters.Dates.DEFAULT,
Format => Converters.Dates.DATE,
Locale => Locale,
Pattern => "");
elsif Node.Time_Style /= null then
C := Dates.Create_Date_Converter (Date => Converters.Dates.DEFAULT,
Time => Get_Date_Style (Node.all, "timeStyle",
Node.Time_Style, Context),
Format => ASF.Converters.Dates.TIME,
Locale => Locale,
Pattern => "");
else
C := Dates.Create_Date_Converter (Date => Converters.Dates.DEFAULT,
Time => Converters.Dates.DEFAULT,
Format => ASF.Converters.Dates.BOTH,
Locale => Locale,
Pattern => "");
end if;
declare
VH : constant access Value_Holder'Class
:= Value_Holder'Class (Parent.all)'Access;
begin
VH.Set_Converter (Converter => C.all'Access,
Release => True);
end;
end Build_Components;
-- ------------------------------
-- Validator Tag
-- ------------------------------
-- ------------------------------
-- Create the Validator Tag
-- ------------------------------
function Create_Validator_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Views.Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Validator_Tag_Node_Access := new Validator_Tag_Node;
Vid : constant Tag_Attribute_Access := Find_Attribute (Attributes,
"validatorId");
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
if Vid = null then
Node.Error ("Missing 'validatorId' attribute");
else
Node.Validator := EL.Objects.To_Object (Vid.Value);
end if;
return Node.all'Access;
end Create_Validator_Tag_Node;
-- ------------------------------
-- Get the specified validator and add it to the parent component.
-- This operation does not create any new UIComponent.
-- ------------------------------
overriding
procedure Build_Components (Node : access Validator_Tag_Node;
Parent : in UIComponent_Access;
Context : in out Contexts.Facelets.Facelet_Context'Class) is
use ASF.Components.Holders;
use type ASF.Validators.Validator_Access;
V : Validators.Validator_Access;
Shared : Boolean;
begin
if not (Parent.all in Editable_Value_Holder'Class) then
Node.Error ("Parent component is not an instance of Editable_Value_Holder");
return;
end if;
Validator_Tag_Node'Class (Node.all).Get_Validator (Context, V, Shared);
if V = null then
Node.Error ("Validator was not found");
return;
end if;
declare
VH : constant access Editable_Value_Holder'Class
:= Editable_Value_Holder'Class (Parent.all)'Access;
begin
VH.Add_Validator (Validator => V, Shared => Shared);
end;
end Build_Components;
-- ------------------------------
-- Get the validator instance that corresponds to the validator tag.
-- Returns in <b>Validator</b> the instance if it exists and indicate
-- in <b>Shared</b> whether it must be freed or not when the component is deleted.
-- ------------------------------
procedure Get_Validator (Node : in Validator_Tag_Node;
Context : in out Contexts.Facelets.Facelet_Context'Class;
Validator : out Validators.Validator_Access;
Shared : out Boolean) is
begin
Validator := Context.Get_Validator (Node.Validator);
Shared := True;
end Get_Validator;
-- ------------------------------
-- Range Validator Tag
-- ------------------------------
-- ------------------------------
-- Create the Range_Validator Tag
-- ------------------------------
function Create_Range_Validator_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Range_Validator_Tag_Node_Access := new Range_Validator_Tag_Node;
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
Node.Minimum := Find_Attribute (Attributes, "minimum");
Node.Maximum := Find_Attribute (Attributes, "maximum");
if Node.Minimum = null and then Node.Maximum = null then
Node.Error ("Missing 'minimum' or 'maximum' attribute");
end if;
return Node.all'Access;
end Create_Range_Validator_Tag_Node;
-- ------------------------------
-- Get the validator instance that corresponds to the range validator.
-- Returns in <b>Validator</b> the validator instance if it exists and indicate
-- in <b>Shared</b> whether it must be freed or not when the component is deleted.
-- ------------------------------
overriding
procedure Get_Validator (Node : in Range_Validator_Tag_Node;
Context : in out Contexts.Facelets.Facelet_Context'Class;
Validator : out Validators.Validator_Access;
Shared : out Boolean) is
Min : Long_Long_Integer := Long_Long_Integer'First;
Max : Long_Long_Integer := Long_Long_Integer'Last;
begin
-- Get the minimum and maximum attributes.
begin
if Node.Minimum /= null then
Min := EL.Objects.To_Long_Long_Integer (Get_Value (Node.Minimum.all, Context));
end if;
if Node.Maximum /= null then
Max := EL.Objects.To_Long_Long_Integer (Get_Value (Node.Maximum.all, Context));
end if;
exception
when Constraint_Error =>
Node.Error ("Invalid minimum or maximum value");
end;
Shared := False;
if Max < Min then
Node.Error ("Minimum ({0}) should be less than maximum ({1})",
Long_Long_Integer'Image (Min), Long_Long_Integer'Image (Max));
return;
end if;
Validator := Validators.Numbers.Create_Range_Validator (Minimum => Min,
Maximum => Max);
end Get_Validator;
-- ------------------------------
-- Length Validator Tag
-- ------------------------------
-- ------------------------------
-- Create the Length_Validator Tag. Verifies that the XML node defines
-- the <b>minimum</b> or the <b>maximum</b> or both attributes.
-- ------------------------------
function Create_Length_Validator_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Length_Validator_Tag_Node_Access := new Length_Validator_Tag_Node;
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
Node.Minimum := Find_Attribute (Attributes, "minimum");
Node.Maximum := Find_Attribute (Attributes, "maximum");
if Node.Minimum = null and then Node.Maximum = null then
Node.Error ("Missing 'minimum' or 'maximum' attribute");
end if;
return Node.all'Access;
end Create_Length_Validator_Tag_Node;
-- ------------------------------
-- Get the validator instance that corresponds to the validator tag.
-- Returns in <b>Validator</b> the instance if it exists and indicate
-- in <b>Shared</b> whether it must be freed or not when the component is deleted.
-- ------------------------------
overriding
procedure Get_Validator (Node : in Length_Validator_Tag_Node;
Context : in out Contexts.Facelets.Facelet_Context'Class;
Validator : out Validators.Validator_Access;
Shared : out Boolean) is
Min : Natural := 0;
Max : Natural := Natural'Last;
begin
-- Get the minimum and maximum attributes.
begin
if Node.Minimum /= null then
Min := Natural (EL.Objects.To_Integer (Get_Value (Node.Minimum.all, Context)));
end if;
if Node.Maximum /= null then
Max := Natural (EL.Objects.To_Integer (Get_Value (Node.Maximum.all, Context)));
end if;
exception
when Constraint_Error =>
Node.Error ("Invalid minimum or maximum value");
end;
Shared := False;
if Max < Min then
Node.Error ("Minimum ({0}) should be less than maximum ({1})",
Natural'Image (Min), Natural'Image (Max));
return;
end if;
Validator := Validators.Texts.Create_Length_Validator (Minimum => Min,
Maximum => Max);
end Get_Validator;
-- ------------------------------
-- Regex Validator Tag
-- ------------------------------
-- ------------------------------
-- Create the Regex_Validator Tag. Verifies that the XML node defines
-- the <b>pattern</b> and that it is a valid regular expression.
-- ------------------------------
function Create_Regex_Validator_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Regex_Validator_Tag_Node_Access := new Regex_Validator_Tag_Node;
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
Node.Pattern := Find_Attribute (Attributes, "pattern");
if Node.Pattern = null then
Node.Error ("Missing 'pattern' attribute");
end if;
return Node.all'Access;
end Create_Regex_Validator_Tag_Node;
-- ------------------------------
-- Get the validator instance that corresponds to the validator tag.
-- Returns in <b>Validator</b> the instance if it exists and indicate
-- in <b>Shared</b> whether it must be freed or not when the component is deleted.
-- ------------------------------
overriding
procedure Get_Validator (Node : in Regex_Validator_Tag_Node;
Context : in out Contexts.Facelets.Facelet_Context'Class;
Validator : out Validators.Validator_Access;
Shared : out Boolean) is
begin
Shared := False;
if Node.Pattern /= null then
declare
Value : constant EL.Objects.Object := Get_Value (Node.Pattern.all, Context);
Regexp : constant String := EL.Objects.To_String (Value);
Pattern : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile (Regexp);
begin
Validator := Validators.Texts.Create_Regex_Validator (Pattern => Pattern);
return;
end;
end if;
Validator := Validators.Texts.Create_Regex_Validator
(Pattern => GNAT.Regpat.Compile ("[^.]*"));
exception
when E : GNAT.Regpat.Expression_Error =>
Node.Error ("Invalid pattern: " & Ada.Exceptions.Exception_Message (E));
Validator := Validators.Texts.Create_Regex_Validator
(Pattern => GNAT.Regpat.Compile ("[^.]*"));
end Get_Validator;
-- ------------------------------
-- Attribute Tag
-- ------------------------------
-- ------------------------------
-- Create the Attribute Tag
-- ------------------------------
function Create_Attribute_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Views.Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Attr : constant Tag_Attribute_Access := Find_Attribute (Attributes, "name");
Node : Attribute_Tag_Node_Access;
begin
Node := new Attribute_Tag_Node;
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
Node.Attr_Name := Attr;
Node.Value := Find_Attribute (Attributes, "value");
if Node.Attr_Name = null then
Node.Error ("Missing 'name' attribute");
else
Node.Attr.Name := Attr.Value;
end if;
if Node.Value = null then
Node.Error ("Missing 'value' attribute");
end if;
return Node.all'Access;
end Create_Attribute_Tag_Node;
-- ------------------------------
-- Build the component tree from the tag node and attach it as
-- the last child of the given parent. Calls recursively the
-- method to create children.
-- Adds the attribute to the component node.
-- This operation does not create any new UIComponent.
-- ------------------------------
overriding
procedure Build_Components (Node : access Attribute_Tag_Node;
Parent : in UIComponent_Access;
Context : in out Contexts.Facelets.Facelet_Context'Class) is
use EL.Expressions;
begin
if Node.Attr_Name /= null and then Node.Value /= null then
if Node.Value.Binding /= null then
declare
Expr : constant EL.Expressions.Expression
:= ASF.Views.Nodes.Reduce_Expression (Node.Value.all, Context);
begin
Parent.Set_Attribute (Def => Node.Attr'Access, Value => Expr);
end;
else
Parent.Set_Attribute (Def => Node.Attr'Access,
Value => Get_Value (Node.Value.all, Context));
end if;
end if;
end Build_Components;
-- ------------------------------
-- Facet Tag
-- ------------------------------
-- ------------------------------
-- Create the Facet Tag
-- ------------------------------
function Create_Facet_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Views.Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Facet_Tag_Node_Access := new Facet_Tag_Node;
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
Node.Facet_Name := Find_Attribute (Attributes, "name");
if Node.Facet_Name = null then
Node.Error ("Missing 'name' attribute");
end if;
return Node.all'Access;
end Create_Facet_Tag_Node;
-- ------------------------------
-- Build the component tree from the tag node and attach it as
-- the facet component of the given parent. Calls recursively the
-- method to create children.
-- ------------------------------
overriding
procedure Build_Components (Node : access Facet_Tag_Node;
Parent : in UIComponent_Access;
Context : in out Contexts.Facelets.Facelet_Context'Class) is
begin
if Node.Facet_Name /= null then
declare
Facet : constant UIComponent_Access := new UIComponent;
Name : constant Util.Beans.Objects.Object := Get_Value (Node.Facet_Name.all, Context);
begin
Node.Build_Children (Facet, Context);
Parent.Add_Facet (Util.Beans.Objects.To_String (Name), Facet.all'Access, Node);
end;
end if;
end Build_Components;
-- ------------------------------
-- Metadata Tag
-- ------------------------------
-- ------------------------------
-- Create the Metadata Tag
-- ------------------------------
function Create_Metadata_Tag_Node (Binding : in Binding_Type;
Line : in Views.Line_Info;
Parent : in Views.Nodes.Tag_Node_Access;
Attributes : in Views.Nodes.Tag_Attribute_Array_Access)
return Views.Nodes.Tag_Node_Access is
Node : constant Metadata_Tag_Node_Access := new Metadata_Tag_Node;
begin
Initialize (Node.all'Access, Binding, Line, Parent, Attributes);
return Node.all'Access;
end Create_Metadata_Tag_Node;
-- ------------------------------
-- Build the component tree from the tag node and attach it as a metadata information
-- facet for the UIView parent component.
-- ------------------------------
overriding
procedure Build_Components (Node : access Metadata_Tag_Node;
Parent : in UIComponent_Access;
Context : in out Contexts.Facelets.Facelet_Context'Class) is
use ASF.Components.Core.Views;
begin
if not (Parent.all in UIView'Class) then
Node.Error ("Parent component of <f:metadata> must be a <f:view>");
return;
end if;
declare
UI : constant UIViewMetaData_Access := new UIViewMetaData;
begin
UIView'Class (Parent.all).Set_Metadata (UI, Node);
Build_Attributes (UI.all, Node.all, Context);
UI.Initialize (UI.Get_Context.all);
Node.Build_Children (UI.all'Access, Context);
end;
end Build_Components;
end ASF.Views.Nodes.Jsf;
|
reznikmm/matreshka | Ada | 4,001 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Text_Table_Type_Attributes;
package Matreshka.ODF_Text.Table_Type_Attributes is
type Text_Table_Type_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Table_Type_Attributes.ODF_Text_Table_Type_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Table_Type_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Table_Type_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Table_Type_Attributes;
|
onox/orka | Ada | 1,912 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with EGL.Objects.Configs;
with EGL.Objects.Displays;
package EGL.Objects.Surfaces is
pragma Preelaborate;
type Swap_Behavior is (Buffer_Preserved, Buffer_Destroyed);
type Surface (Platform : Displays.Platform_Kind) is new EGL_Object with private;
function Create_Surface
(Display : Displays.Display;
Config : Configs.Config;
Window : Native_Window_Ptr;
sRGB : Boolean) return Surface
with Pre => Display.Is_Initialized and Config.Is_Initialized;
function Width (Object : Surface) return Natural
with Pre => Object.Is_Initialized;
function Height (Object : Surface) return Natural
with Pre => Object.Is_Initialized;
function Behavior (Object : Surface) return Swap_Behavior
with Pre => Object.Is_Initialized;
procedure Swap_Buffers (Object : Surface)
with Pre => Object.Is_Initialized;
private
for Swap_Behavior use
(Buffer_Preserved => 16#3094#,
Buffer_Destroyed => 16#3095#);
for Swap_Behavior'Size use Int'Size;
type Surface (Platform : Displays.Platform_Kind) is new EGL_Object with record
Display : Displays.Display (Platform);
end record;
overriding procedure Pre_Finalize (Object : in out Surface);
end EGL.Objects.Surfaces;
|
zhmu/ananas | Ada | 482 | adb | -- { dg-do compile }
with Text_IO; use Text_IO;
with Expect2_Pkg; use Expect2_Pkg;
procedure Expect2 is
begin
if Unlikely (I = 0) then
Put_Line ("Zero was passed");
return;
end if;
if Likely (I > 0) then
Put_Line ("A positive number was passed");
else
Put_Line ("A negative number was passed");
end if;
if Expect ((I rem 2) = 0, False) then
Put_Line ("An even number was passed");
else
Put_Line ("An odd number was passed");
end if;
end;
|
meowthsli/veriflight_boards | Ada | 457 | adb | with Interfaces.C;
package body usb_handler is
-- External IRQ handler
function usb_handler return Interfaces.C.int
with
Import => True,
Convention => C,
External_Name => "OTG_FS_IRQHandler";
-- Main usb device
protected body Device_Interface is
procedure Handler is
unused : Interfaces.C.int;
begin
unused := usb_handler;
end Handler;
end Device_Interface;
end usb_handler;
|
flyx/OpenGLAda | Ada | 638 | ads | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
-- Autogenerated by Generate, do not edit
package GL.API.UInts is
pragma Preelaborate;
Uniform1 : T51;
Uniform1v : T52;
Uniform2 : T53;
Uniform2v : T54;
Uniform3 : T55;
Uniform3v : T56;
Uniform4 : T57;
Uniform4v : T58;
Uniform_Matrix2 : T59;
Uniform_Matrix3 : T60;
Uniform_Matrix4 : T61;
Vertex_Attrib1 : T62;
Vertex_Attrib2 : T63;
Vertex_Attrib2v : T64;
Vertex_Attrib3 : T65;
Vertex_Attrib3v : T66;
Vertex_Attrib4 : T67;
Vertex_Attrib4v : T68;
end GL.API.UInts;
|
reznikmm/matreshka | Ada | 7,060 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Sender_Phone_Private_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Sender_Phone_Private_Element_Node is
begin
return Self : Text_Sender_Phone_Private_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Sender_Phone_Private_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Sender_Phone_Private
(ODF.DOM.Text_Sender_Phone_Private_Elements.ODF_Text_Sender_Phone_Private_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Sender_Phone_Private_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Sender_Phone_Private_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Sender_Phone_Private_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Sender_Phone_Private
(ODF.DOM.Text_Sender_Phone_Private_Elements.ODF_Text_Sender_Phone_Private_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Sender_Phone_Private_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Sender_Phone_Private
(Visitor,
ODF.DOM.Text_Sender_Phone_Private_Elements.ODF_Text_Sender_Phone_Private_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Sender_Phone_Private_Element,
Text_Sender_Phone_Private_Element_Node'Tag);
end Matreshka.ODF_Text.Sender_Phone_Private_Elements;
|
stcarrez/dynamo | Ada | 93,639 | adb | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . S T A T E M E N T S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
with Asis.Declarations; use Asis.Declarations;
with Asis.Elements; use Asis.Elements;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Expressions; use Asis.Expressions;
with Asis.Extensions; use Asis.Extensions;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Sem; use A4G.A_Sem;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.Contt.UT; use A4G.Contt.UT;
with A4G.Mapping; use A4G.Mapping;
with A4G.Norm; use A4G.Norm;
with A4G.Vcheck; use A4G.Vcheck;
with A4G.Span_End; use A4G.Span_End;
with Atree; use Atree;
with Nlists; use Nlists;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
package body Asis.Statements is
Package_Name : constant String := "Asis.Statements.";
---------------------------
-- ASIS 2005 Draft stuff --
---------------------------
------------------------
-- Associated_Message --
------------------------
function Associated_Message
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
begin
Check_Validity (Statement, Package_Name & "Associated_Message");
if not (Arg_Kind = A_Raise_Statement) then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Associated_Message",
Wrong_Kind => Arg_Kind);
end if;
return Node_To_Element_New
(Node => Sinfo.Expression (Node (Statement)),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Associated_Message");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Associated_Message",
Ex => Ex,
Arg_Element => Statement);
end Associated_Message;
----------------------------------------
-- Extended_Return_Exception_Handlers --
----------------------------------------
function Extended_Return_Exception_Handlers
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Exception_Handler_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Resilt_List : List_Id := No_List;
begin
Check_Validity
(Statement, Package_Name & "Extended_Return_Exception_Handlers");
if not (Arg_Kind = An_Extended_Return_Statement) then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Extended_Return_Exception_Handlers",
Wrong_Kind => Arg_Kind);
end if;
if Present (Handled_Statement_Sequence (Node (Statement))) then
Resilt_List :=
Exception_Handlers (Handled_Statement_Sequence (Node (Statement)));
end if;
return N_To_E_List_New
(List => Resilt_List,
Include_Pragmas => Include_Pragmas,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name &
"Extended_Return_Exception_Handlers");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Extended_Return_Exception_Handlers",
Ex => Ex,
Arg_Element => Statement);
end Extended_Return_Exception_Handlers;
--------------------------------
-- Extended_Return_Statements --
--------------------------------
function Extended_Return_Statements
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Statement_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Result_List : List_Id := No_List;
begin
Check_Validity (Statement, Package_Name & "Extended_Return_Statements");
if not (Arg_Kind = An_Extended_Return_Statement) then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Extended_Return_Statements",
Wrong_Kind => Arg_Kind);
end if;
if Present (Handled_Statement_Sequence (Node (Statement))) then
Result_List :=
Sinfo.Statements (Handled_Statement_Sequence (Node (Statement)));
end if;
return N_To_E_List_New (List => Result_List,
Include_Pragmas => Include_Pragmas,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Extended_Return_Statements");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Extended_Return_Statements",
Ex => Ex,
Arg_Element => Statement);
end Extended_Return_Statements;
-------------------------------
-- Return_Object_Declaration --
-------------------------------
function Return_Object_Declaration
(Statement : Asis.Statement)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Result_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Return_Object_Declaration");
if not (Arg_Kind = An_Extended_Return_Statement) then
Raise_ASIS_Inappropriate_Element
(Diagnosis => Package_Name & "Return_Object_Declaration",
Wrong_Kind => Arg_Kind);
end if;
Result_Node := First (Return_Object_Declarations (Node (Statement)));
while Nkind (Result_Node) /= N_Object_Declaration loop
-- It may be some internal subtypes here
Result_Node := Next (Result_Node);
end loop;
return Node_To_Element_New (Node => Result_Node,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Return_Object_Declaration");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Return_Object_Declaration",
Ex => Ex,
Arg_Element => Statement);
end Return_Object_Declaration;
------------------------------------------------------------------------------
-------------------
-- Aborted_Tasks --
-------------------
function Aborted_Tasks
(Statement : Asis.Statement)
return Asis.Expression_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Aborted_Tasks");
if not (Arg_Kind = An_Abort_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Aborted_Tasks",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return N_To_E_List_New
(List => Names (Arg_Node),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Aborted_Tasks");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Aborted_Tasks",
Ex => Ex,
Arg_Element => Statement);
end Aborted_Tasks;
------------------------------------
-- Accept_Body_Exception_Handlers --
------------------------------------
function Accept_Body_Exception_Handlers
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Exception_Handler_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Resilt_List : List_Id := No_List;
begin
Check_Validity (Statement,
Package_Name & "Accept_Body_Exception_Handlers");
if not (Arg_Kind = An_Accept_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Accept_Body_Exception_Handlers",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
if Present (Handled_Statement_Sequence (Arg_Node)) then
Resilt_List :=
Exception_Handlers (Handled_Statement_Sequence (Arg_Node));
end if;
return N_To_E_List_New (List => Resilt_List,
Include_Pragmas => Include_Pragmas,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Accept_Body_Exception_Handlers");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Accept_Body_Exception_Handlers",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Include_Pragmas);
end Accept_Body_Exception_Handlers;
----------------------------
-- Accept_Body_Statements --
----------------------------
function Accept_Body_Statements
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Statement_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Resilt_List : List_Id := No_List;
begin
Check_Validity (Statement, Package_Name & "Accept_Body_Statements");
if not (Arg_Kind = An_Accept_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Accept_Body_Statements",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
if Present (Handled_Statement_Sequence (Arg_Node)) then
Resilt_List :=
Sinfo.Statements (Handled_Statement_Sequence (Arg_Node));
end if;
return N_To_E_List_New
(List => Resilt_List,
Include_Pragmas => Include_Pragmas,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Accept_Body_Statements");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Accept_Body_Statements",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Include_Pragmas);
end Accept_Body_Statements;
------------------------------
-- Accept_Entry_Direct_Name --
------------------------------
function Accept_Entry_Direct_Name
(Statement : Asis.Statement)
return Asis.Name
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Accept_Entry_Direct_Name");
if not (Arg_Kind = An_Accept_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Accept_Entry_Direct_Name",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New (
Node => Entry_Direct_Name (Arg_Node),
Internal_Kind => An_Identifier,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Accept_Entry_Direct_Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Accept_Entry_Direct_Name",
Ex => Ex,
Arg_Element => Statement);
end Accept_Entry_Direct_Name;
------------------------
-- Accept_Entry_Index --
------------------------
function Accept_Entry_Index
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Result_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Accept_Entry_Index");
if not (Arg_Kind = An_Accept_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Accept_Entry_Index",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Result_Node := Entry_Index (Arg_Node);
if No (Result_Node) then
return Nil_Element;
else
return Node_To_Element_New (Node => Result_Node,
Starting_Element => Statement);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Accept_Entry_Index");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Accept_Entry_Index",
Ex => Ex,
Arg_Element => Statement);
end Accept_Entry_Index;
-----------------------
-- Accept_Parameters --
-----------------------
function Accept_Parameters
(Statement : Asis.Statement)
return Asis.Parameter_Specification_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Accept_Parameters");
if not (Arg_Kind = An_Accept_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Accept_Parameters",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return N_To_E_List_New
(List => Parameter_Specifications (Arg_Node),
Starting_Element => Statement,
Internal_Kind => A_Parameter_Specification);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Accept_Parameters");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Accept_Parameters",
Ex => Ex,
Arg_Element => Statement);
end Accept_Parameters;
---------------------------
-- Assignment_Expression --
---------------------------
function Assignment_Expression
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Assignment_Expression");
if not (Arg_Kind = An_Assignment_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Assignment_Expression",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New (
Node => Sinfo.Expression (Arg_Node),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Assignment_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Assignment_Expression",
Ex => Ex,
Arg_Element => Statement);
end Assignment_Expression;
------------------------------
-- Assignment_Variable_Name --
------------------------------
function Assignment_Variable_Name
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Assignment_Variable_Name");
if not (Arg_Kind = An_Assignment_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Assignment_Variable_Name",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New (
Node => Sinfo.Name (Arg_Node),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Assignment_Variable_Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Assignment_Variable_Name",
Ex => Ex,
Arg_Element => Statement);
end Assignment_Variable_Name;
-----------------------------
-- Block_Declarative_Items --
-----------------------------
function Block_Declarative_Items
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Declarative_Item_List
is
Arg_El : Asis.Element;
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Block_Declarative_Items");
if not (Arg_Kind = A_Block_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Block_Declarative_Items",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Arg_El := Statement;
if Special_Case (Arg_El) = A_Dummy_Block_Statement then
Set_Special_Case (Arg_El, Not_A_Special_Case);
end if;
return N_To_E_List_New
(List => Sinfo.Declarations (Arg_Node),
Include_Pragmas => Include_Pragmas,
Starting_Element => Arg_El);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Block_Declarative_Items");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Block_Declarative_Items",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Include_Pragmas);
end Block_Declarative_Items;
------------------------------
-- Block_Exception_Handlers --
------------------------------
function Block_Exception_Handlers
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Exception_Handler_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Arg_El : Asis.Element;
begin
Check_Validity (Statement, Package_Name & "Block_Exception_Handlers");
if not (Arg_Kind = A_Block_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Block_Exception_Handlers",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
if Special_Case (Statement) = A_Dummy_Block_Statement and then
No (Handled_Statement_Sequence (Arg_Node))
then
-- for the dummy block originated from the package_body_declaration
-- having no handled_sequence_of_statements on its own.
return Nil_Element_List;
end if;
Arg_El := Statement;
if Special_Case (Arg_El) = A_Dummy_Block_Statement then
Set_Special_Case (Arg_El, Not_A_Special_Case);
end if;
return N_To_E_List_New
(List =>
Exception_Handlers (Handled_Statement_Sequence (Arg_Node)),
Include_Pragmas => Include_Pragmas,
Starting_Element => Arg_El);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Block_Exception_Handlers");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Block_Exception_Handlers",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Include_Pragmas);
end Block_Exception_Handlers;
----------------------
-- Block_Statements --
----------------------
function Block_Statements
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Statement_List
is
Arg_El : Asis.Element;
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Block_Statements");
if not (Arg_Kind = A_Block_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Block_Statements",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Arg_El := Statement;
if Special_Case (Arg_El) = A_Dummy_Block_Statement then
Set_Special_Case (Arg_El, Not_A_Special_Case);
end if;
return N_To_E_List_New
(List =>
Sinfo.Statements (Handled_Statement_Sequence (Arg_Node)),
Include_Pragmas => Include_Pragmas,
Starting_Element => Arg_El);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Block_Statements");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Block_Statements",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Include_Pragmas);
end Block_Statements;
-------------------------------
-- Call_Statement_Parameters --
-------------------------------
function Call_Statement_Parameters
(Statement : Asis.Statement;
Normalized : Boolean := False)
return Asis.Association_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Res_Norm_Case : Normalization_Cases := Is_Not_Normalized;
Res_Node_List : List_Id;
begin
Check_Validity (Statement, Package_Name & "Call_Statement_Parameters");
Arg_Node := Node (Statement);
if (not (Arg_Kind = An_Entry_Call_Statement or else
Arg_Kind = A_Procedure_Call_Statement))
or else
(Normalized and then Nkind (Arg_Node) = N_Attribute_Reference)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Call_Statement_Parameters",
Wrong_Kind => Arg_Kind);
end if;
if Is_Prefix_Notation (Statement) then
Arg_Node := R_Node (Statement);
end if;
if Normalized then
Res_Norm_Case := Is_Normalized;
end if;
if Normalized and then
Nkind (Arg_Node) /= N_Attribute_Reference
then
if No (Parameter_Associations (Arg_Node))
or else
Is_Nil (Corresponding_Called_Entity (Statement))
then
return Nil_Element_List;
else
return Normalized_Param_Associations (Call_Elem => Statement);
end if;
else
if Nkind (Arg_Node) = N_Attribute_Reference then
-- call to 'Output, 'Read or 'Write
Res_Node_List := Sinfo.Expressions (Arg_Node);
else
Res_Node_List := Parameter_Associations (Arg_Node);
end if;
return N_To_E_List_New (List => Res_Node_List,
Internal_Kind => A_Parameter_Association,
Norm_Case => Res_Norm_Case,
Starting_Element => Statement);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Normalized,
Outer_Call => Package_Name & "Call_Statement_Parameters");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Call_Statement_Parameters",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Normalized);
end Call_Statement_Parameters;
-----------------
-- Called_Name --
-----------------
function Called_Name
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
-- local variables needed for processing calls to 'Output, 'Read
-- and 'Write:
Result_Kind : Internal_Element_Kinds := Not_An_Element;
Result_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Called_Name");
if not (Arg_Kind = An_Entry_Call_Statement or else
Arg_Kind = A_Procedure_Call_Statement)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Called_Name",
Wrong_Kind => Arg_Kind);
end if;
if Is_Prefix_Notation (Statement) then
Arg_Node := R_Node (Statement);
else
Arg_Node := Node (Statement);
end if;
if Nkind (Arg_Node) = N_Attribute_Reference then
-- calls like T'Output (...); T'Read (...) and T'Write (...)
-- should be processed separately, and the result should
-- be built on the same node as argument
Result_Kind := Subprogram_Attribute_Kind (Arg_Node);
Result_Node := Arg_Node;
else
Result_Node := Sinfo.Name (Arg_Node);
end if;
if Is_Rewrite_Substitution (Result_Node)
and then
Nkind (Result_Node) = N_Explicit_Dereference
and then
Nkind (Prefix (Result_Node)) = N_Function_Call
then
-- Needed to process cases like F (1), where F - parameterless
-- function that returns access-to-subprogram result.
Result_Node := Prefix (Result_Node);
end if;
return Node_To_Element_New (
Starting_Element => Statement,
Node => Result_Node,
Internal_Kind => Result_Kind);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Called_Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Called_Name",
Ex => Ex,
Arg_Element => Statement);
end Called_Name;
---------------------
-- Case_Expression --
---------------------
function Case_Expression
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Case_Expression");
if not (Arg_Kind = A_Case_Statement or else
Arg_Kind = A_Case_Expression)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Case_Expression",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New
(Node => Sinfo.Expression (Arg_Node),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Case_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Case_Expression",
Ex => Ex,
Arg_Element => Statement);
end Case_Expression;
----------------------------------------
-- Case_Statement_Alternative_Choices --
----------------------------------------
function Case_Statement_Alternative_Choices
(Path : Asis.Path)
return Asis.Element_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Path);
Arg_Node : Node_Id;
begin
Check_Validity
(Path, Package_Name & "Case_Statement_Alternative_Choices");
if not (Arg_Kind = A_Case_Path) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Case_Statement_Alternative_Choices",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Path);
return Discrete_Choice_Node_To_Element_List (
Choice_List => Discrete_Choices (Arg_Node),
Starting_Element => Path);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Path,
Outer_Call => Package_Name &
"Case_Statement_Alternative_Choices");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Case_Statement_Alternative_Choices",
Ex => Ex,
Arg_Element => Path);
end Case_Statement_Alternative_Choices;
-----------------------------------
-- Choice_Parameter_Specification --
-------------------------------------
function Choice_Parameter_Specification
(Handler : Asis.Exception_Handler)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Handler);
Arg_Node : Node_Id;
Result_Node : Node_Id;
begin
Check_Validity
(Handler, Package_Name & "Choice_Parameter_Specification");
if not (Arg_Kind = An_Exception_Handler) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Choice_Parameter_Specification",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Handler);
Result_Node := Choice_Parameter (Arg_Node);
if No (Result_Node) then
return Nil_Element;
else
return Node_To_Element_New (
Node => Result_Node,
Internal_Kind => A_Choice_Parameter_Specification,
Starting_Element => Handler);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Handler,
Outer_Call => Package_Name & "Choice_Parameter_Specification");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Choice_Parameter_Specification",
Ex => Ex,
Arg_Element => Handler);
end Choice_Parameter_Specification;
--------------------------
-- Condition_Expression --
--------------------------
function Condition_Expression (Path : Asis.Path) return Asis.Expression is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Path);
Res_Node : Node_Id := Empty;
Arg_Node : Node_Id;
begin
Check_Validity (Path, Package_Name & "Condition_Expression");
if not (Arg_Kind = An_If_Path or else
Arg_Kind = An_Elsif_Path or else
Arg_Kind = An_If_Expression_Path or else
Arg_Kind = An_Elsif_Expression_Path)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Condition_Expression",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := R_Node (Path);
case Arg_Kind is
when An_If_Path |
An_Elsif_Path =>
Res_Node := Condition (Arg_Node);
when An_If_Expression_Path |
An_Elsif_Expression_Path =>
Res_Node := Prev (Arg_Node);
when others =>
null;
end case;
return Node_To_Element_New (Node => Res_Node,
Starting_Element => Path);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Path,
Outer_Call => Package_Name & "Condition_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Condition_Expression",
Ex => Ex,
Arg_Element => Path);
end Condition_Expression;
---------------------------------
-- Corresponding_Called_Entity --
---------------------------------
function Corresponding_Called_Entity
(Statement : Asis.Statement)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
begin
Check_Validity (Statement, Package_Name & "Corresponding_Called_Entity");
if not (Arg_Kind = An_Entry_Call_Statement or else
Arg_Kind = A_Procedure_Call_Statement)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Called_Entity",
Wrong_Kind => Arg_Kind);
end if;
return Get_Corr_Called_Entity (Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Corresponding_Called_Entity");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Corresponding_Called_Entity",
Ex => Ex,
Arg_Element => Statement);
end Corresponding_Called_Entity;
-----------------------------------------
-- Corresponding_Destination_Statement --
-----------------------------------------
function Corresponding_Destination_Statement
(Statement : Asis.Statement)
return Asis.Statement
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Res_Label : Node_Id;
Res_Stmt : Node_Id;
begin
Check_Validity
(Statement, Package_Name & "Corresponding_Destination_Statement");
if not (Arg_Kind = A_Goto_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Destination_Statement",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := R_Node (Statement);
if Is_Rewrite_Substitution (Arg_Node)
and then
Nkind (Arg_Node) = N_Loop_Statement
and then
Nkind (Original_Node (Arg_Node)) = N_Goto_Statement
then
-- goto statement is rewritten into infinite loop
if not Is_Empty_List (Sinfo.Statements (Arg_Node)) then
Res_Stmt := First (Sinfo.Statements (Arg_Node));
else
-- Pathological case:
--
-- <<Junk>> goto Junk;
Res_Stmt := Arg_Node;
end if;
else
Arg_Node := Node (Statement);
Res_Label := Parent (Entity (Sinfo.Name (Arg_Node)));
-- this is N_Implicit_Label_Declaration node representing the
-- implicit declaration of the destination label
Res_Stmt := Label_Construct (Res_Label);
while not Is_Statement (Res_Stmt) loop
Res_Stmt := Next (Res_Stmt);
end loop;
-- if we are in the tree corresponding to a successful compiler
-- run, we shall for sure find a statement after any label!
end if;
return Node_To_Element_New (Node => Res_Stmt,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name &
"Corresponding_Destination_Statement");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name &
"Corresponding_Destination_Statement",
Ex => Ex,
Arg_Element => Statement);
end Corresponding_Destination_Statement;
-------------------------
-- Corresponding_Entry --
-------------------------
function Corresponding_Entry
(Statement : Asis.Statement)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Res_Entry_Dcl : Node_Id;
Result_Unit : Compilation_Unit;
begin
Check_Validity (Statement, Package_Name & "Corresponding_Entry");
if not (Arg_Kind = An_Accept_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Entry",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Res_Entry_Dcl := Parent (Entity (Entry_Direct_Name (Arg_Node)));
Result_Unit := Enclosing_Unit
(Encl_Cont_Id (Statement), Res_Entry_Dcl);
return Node_To_Element_New (Node => Res_Entry_Dcl,
In_Unit => Result_Unit);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Corresponding_Entry");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Corresponding_Entry",
Ex => Ex,
Arg_Element => Statement);
end Corresponding_Entry;
-------------------------------
-- Corresponding_Loop_Exited --
-------------------------------
function Corresponding_Loop_Exited
(Statement : Asis.Statement)
return Asis.Statement
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Res_Loop : Node_Id;
Loop_Name : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Corresponding_Loop_Exited");
if not (Arg_Kind = An_Exit_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Corresponding_Loop_Exited",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Loop_Name := Sinfo.Name (Arg_Node);
if Present (Loop_Name) then
-- we simply jump to the result loop:
Loop_Name := Parent (Entity (Loop_Name));
-- here we are in the implicit declaration of the loop name
Res_Loop := Label_Construct (Loop_Name);
else
-- here we have to traverse the tree up to the first enclosing
-- loop statement
Res_Loop := Parent (Arg_Node);
while Nkind (Res_Loop) /= N_Loop_Statement loop
Res_Loop := Parent (Res_Loop);
end loop;
end if;
return Node_To_Element_New (Node => Res_Loop,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Corresponding_Loop_Exited");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Corresponding_Loop_Exited",
Ex => Ex,
Arg_Element => Statement);
end Corresponding_Loop_Exited;
----------------------
-- Delay_Expression --
----------------------
function Delay_Expression
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Delay_Expression");
if not (Arg_Kind = A_Delay_Until_Statement
or else
Arg_Kind = A_Delay_Relative_Statement)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Delay_Expression",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New
(Node => Sinfo.Expression (Arg_Node),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Delay_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Delay_Expression",
Ex => Ex,
Arg_Element => Statement);
end Delay_Expression;
-----------------------
-- Exception_Choices --
-----------------------
function Exception_Choices
(Handler : Asis.Exception_Handler)
return Asis.Element_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Handler);
Arg_Node : Node_Id;
begin
Check_Validity (Handler, Package_Name & "Exception_Choices");
if not (Arg_Kind = An_Exception_Handler) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Exception_Choices",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Handler);
return N_To_E_List_New
(List => Exception_Choices (Arg_Node),
Starting_Element => Handler);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Handler,
Outer_Call => Package_Name & "Exception_Choices");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Exception_Choices",
Ex => Ex,
Arg_Element => Handler);
end Exception_Choices;
--------------------
-- Exit_Condition --
--------------------
function Exit_Condition
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Result_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Exit_Condition");
if not (Arg_Kind = An_Exit_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Exit_Loop_Name",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Result_Node := Condition (Arg_Node);
if No (Result_Node) then
return Nil_Element;
else
return Node_To_Element_New (Node => Result_Node,
Starting_Element => Statement);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Exit_Condition");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Exit_Condition",
Ex => Ex,
Arg_Element => Statement);
end Exit_Condition;
--------------------
-- Exit_Loop_Name --
--------------------
function Exit_Loop_Name
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Result_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Exit_Loop_Name");
if not (Arg_Kind = An_Exit_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Exit_Loop_Name",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Result_Node := Sinfo.Name (Arg_Node);
if No (Result_Node) then
return Nil_Element;
else
return Node_To_Element_New (Node => Result_Node,
Starting_Element => Statement);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Exit_Loop_Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Exit_Loop_Name",
Ex => Ex,
Arg_Element => Statement);
end Exit_Loop_Name;
--------------------------------------
-- For_Loop_Parameter_Specification --
--------------------------------------
function For_Loop_Parameter_Specification
(Statement : Asis.Statement)
return Asis.Declaration
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Res_Node : Node_Id;
Res_Kind : Internal_Element_Kinds := Not_An_Element;
begin
Check_Validity
(Statement, Package_Name & "For_Loop_Parameter_Specification");
if not (Arg_Kind = A_For_Loop_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "For_Loop_Parameter_Specification",
Wrong_Kind => Arg_Kind);
end if;
Res_Node := Iteration_Scheme (Node (Statement));
if Present (Iterator_Specification (Res_Node)) then
Res_Node := Iterator_Specification (Res_Node);
if Of_Present (Res_Node) then
Res_Kind := An_Element_Iterator_Specification;
else
Res_Kind := A_Generalized_Iterator_Specification;
end if;
elsif Present (Loop_Parameter_Specification (Res_Node)) then
Res_Node := Loop_Parameter_Specification (Res_Node);
Res_Kind := A_Loop_Parameter_Specification;
else
null;
pragma Assert (False);
end if;
return Node_To_Element_New (
Node => Res_Node,
Internal_Kind => Res_Kind,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name &
"For_Loop_Parameter_Specification");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "For_Loop_Parameter_Specification",
Ex => Ex,
Arg_Element => Statement);
end For_Loop_Parameter_Specification;
----------------
-- Goto_Label --
----------------
function Goto_Label
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Goto_Label");
if not (Arg_Kind = A_Goto_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Goto_Label",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New (Node => Sinfo.Name (Arg_Node),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Goto_Label");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Goto_Label",
Ex => Ex,
Arg_Element => Statement);
end Goto_Label;
-----------
-- Guard --
-----------
function Guard (Path : Asis.Path) return Asis.Expression is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Path);
Arg_Node : Node_Id;
Result_Node : Node_Id;
begin
Check_Validity (Path, Package_Name & "Guard");
if not (Arg_Kind = A_Select_Path or else
Arg_Kind = An_Or_Path)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Guard",
Wrong_Kind => Arg_Kind);
end if;
if not (Nkind (Parent (R_Node (Path))) = N_Selective_Accept) then
return Nil_Element;
end if;
Arg_Node := Node (Path);
Result_Node := Condition (Arg_Node);
if No (Result_Node) then
return Nil_Element;
else
return Node_To_Element_New (Node => Result_Node,
Starting_Element => Path);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Path,
Outer_Call => Package_Name & "Guard");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Guard",
Ex => Ex,
Arg_Element => Path);
end Guard;
------------------------
-- Handler_Statements --
------------------------
function Handler_Statements
(Handler : Asis.Exception_Handler;
Include_Pragmas : Boolean := False)
return Asis.Statement_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Handler);
Arg_Node : Node_Id;
begin
Check_Validity (Handler, Package_Name & "Handler_Statements");
if not (Arg_Kind = An_Exception_Handler) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Handler_Statements",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Handler);
return N_To_E_List_New
(List => Sinfo.Statements (Arg_Node),
Include_Pragmas => Include_Pragmas,
Starting_Element => Handler);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Handler,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Handler_Statements");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Handler_Statements",
Ex => Ex,
Arg_Element => Handler,
Bool_Par_ON => Include_Pragmas);
end Handler_Statements;
--------------------------------------
-- Is_Call_On_Dispatching_Operation --
--------------------------------------
function Is_Call_On_Dispatching_Operation
(Call : Asis.Element)
return Boolean
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Call);
Called_Entity : Asis.Element;
begin
-- Just the first version, should be tested more carefully!
-- Is currently implemented as a secondary query based on
-- some queries from Asis.Extensions.
-- ??? !!!
-- Still depends on partially implemented queries from
-- Asis.Extensions
Check_Validity (Call, Package_Name & "Is_Call_On_Dispatching_Operation");
if not (Arg_Kind = A_Function_Call or else
Arg_Kind = A_Procedure_Call_Statement)
then
return False;
end if;
if Arg_Kind = A_Function_Call then
Called_Entity := Corresponding_Called_Function (Call);
else
Called_Entity := Corresponding_Called_Entity (Call);
end if;
if Is_Nil (Called_Entity) or else
(not Is_Dispatching_Operation (Called_Entity))
then
return False;
else
return True;
end if;
-- Owning_Type := Primary_Owner (Called_Entity);
-- Owning_Type := Type_Declaration_View (Owning_Type);
-- Owning_Type_Kind := Int_Kind (Owning_Type);
-- return
-- (Owning_Type_Kind = A_Tagged_Private_Type_Definition or else
-- Owning_Type_Kind = A_Private_Extension_Definition or else
-- Owning_Type_Kind = A_Derived_Record_Extension_Definition or else
-- Owning_Type_Kind = A_Tagged_Record_Type_Definition);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Call,
Outer_Call => Package_Name &
"Is_Call_On_Dispatching_Operation");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Call_On_Dispatching_Operation",
Ex => Ex,
Arg_Element => Call);
end Is_Call_On_Dispatching_Operation;
----------------------
-- Is_Declare_Block --
----------------------
function Is_Declare_Block
(Statement : Asis.Statement)
return Boolean
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
First_Letter : Character;
-- the first character of the statement, should be either
-- B[egin] or D[eclare]
begin
-- If the argument represents the dummy block statement created by
-- the Asis_Declarations.Body_Block_Statement (obsolescent!)
-- function, the result will be True if and only if the
-- corresponding body has any declarative item on its own.
Check_Validity (Statement, Package_Name & "Is_Declare_Block");
if not (Arg_Kind = A_Block_Statement) then
return False;
end if;
Arg_Node := Node (Statement);
if Special_Case (Statement) = A_Dummy_Block_Statement then
if Present (Sinfo.Declarations (Arg_Node)) then
return True;
else
return False;
end if;
else
-- a "normal" block statement: here we should be more accurate, and
-- we cannot rely on "Present (Declarations (Arg_Node))" approach
-- because of the implicit label declarations
First_Letter := Source_Text (Get_Source_File_Index (
Sloc (Arg_Node))) -- the unit's text buffer
(Sloc (Arg_Node));
case First_Letter is
when 'b' | 'B' =>
return False;
when 'd' | 'D' =>
return True;
when others =>
-- Unexpected beginning of the block statement
raise Internal_Implementation_Error;
end case;
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Is_Declare_Block");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Declare_Block",
Ex => Ex,
Arg_Element => Statement);
end Is_Declare_Block;
-------------------------
-- Is_Dispatching_Call --
-------------------------
function Is_Dispatching_Call (Call : Asis.Element) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Call);
Arg_Node : Node_Id := R_Node (Call);
begin
Check_Validity (Call, Package_Name & "Is_Dispatching_Call");
if not (Arg_Kind = A_Function_Call or else
Arg_Kind = A_Procedure_Call_Statement)
then
return False;
end if;
if Is_Prefix_Notation (Call)
and then
Nkind (Arg_Node) = N_Explicit_Dereference
and then
Is_Rewrite_Substitution (Arg_Node)
and then
Nkind (Original_Node (Arg_Node)) = N_Function_Call
then
Arg_Node := Prefix (Arg_Node);
end if;
if not (Nkind (Arg_Node) = N_Function_Call or else
Nkind (Arg_Node) = N_Procedure_Call_Statement)
then
-- this may be possible as a result of tree rewriting, but if we
-- have rewriting, we do not have a dispatching call, so:
return False;
else
return Present (Controlling_Argument (Arg_Node));
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Call,
Outer_Call => Package_Name & "Is_Dispatching_Call");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Dispatching_Call",
Ex => Ex,
Arg_Element => Call);
end Is_Dispatching_Call;
----------------------
-- Is_Name_Repeated --
----------------------
function Is_Name_Repeated (Statement : Asis.Statement) return Boolean is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Last_Comp : Asis.Element;
S : Source_Ptr;
Result : Boolean;
begin
Check_Validity (Statement, Package_Name & "Is_Name_Repeated");
if not (Arg_Kind = A_Loop_Statement or else
Arg_Kind = A_While_Loop_Statement or else
Arg_Kind = A_For_Loop_Statement or else
Arg_Kind = A_Block_Statement or else
Arg_Kind = An_Accept_Statement)
then
Result := False;
end if;
if Arg_Kind = A_Loop_Statement or else
Arg_Kind = A_While_Loop_Statement or else
Arg_Kind = A_For_Loop_Statement or else
Arg_Kind = A_Block_Statement
then
Result := not Asis.Elements.Is_Nil (Statement_Identifier (Statement));
elsif Arg_Kind = An_Accept_Statement then
if Is_Nil (Accept_Body_Statements (Statement, True)) then
-- no statements - no "do .. end;" part - no "end"
-- to repeat the name after
Result := False;
else
Last_Comp := Get_Last_Component (Statement);
S := Set_Image_End (Last_Comp);
-- now S points to the last character (it for sure is ';')
-- of the last component (a statement, an exception
-- handler or pragma) in the accept statement.
-- First, we reset S to point onto the first character
-- after the final end of the accept statement:
-- the final "end" lexically is an identifier, so:
S := Next_Identifier (S);
S := S + 3;
-- the first character after "end"
S := Rightmost_Non_Blank (S);
-- and the final check - what follows the final "end"
if Get_Character (S) = ';' then
Result := False;
else
Result := True;
end if;
end if;
end if;
return Result;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Is_Name_Repeated");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Name_Repeated",
Ex => Ex,
Arg_Element => Statement);
end Is_Name_Repeated;
-----------------
-- Label_Names --
-----------------
function Label_Names
(Statement : Asis.Statement)
return Asis.Defining_Name_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Parent_Node : Node_Id;
Labels_Number : Nat := 0; -- how many labels the statement has
Label_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Label_Names");
if not (Arg_Kind in Internal_Statement_Kinds) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Label_Names",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
-- First, process a special case when an infinite loop is programmed as
--
-- <<Target>> Stmt;
-- ...
-- goto Target;
--
-- If Stmt has exactly one label attached to it, the front-end rewrites
-- this construct as a subtree headed by N_Loop_Statement node
Parent_Node := Parent (R_Node (Statement));
if Nkind (Parent_Node) = N_Loop_Statement
and then
Is_Rewrite_Substitution (Parent_Node)
and then
Nkind (Original_Node (Parent_Node)) = N_Goto_Statement
and then
Arg_Node = First (Sinfo.Statements (Parent_Node))
then
return
(1 => Node_To_Element_New
(Node => Sinfo.Identifier (Parent_Node),
Internal_Kind => A_Defining_Identifier,
Starting_Element => Statement));
elsif Nkind (Arg_Node) = N_Goto_Statement
and then
Nkind (R_Node (Statement)) = N_Loop_Statement
and then
Is_Empty_List (Sinfo.Statements (R_Node (Statement)))
then
-- This is a pathological case of
--
-- <<Target>> goto Target;
return
(1 => Node_To_Element_New
(Node => Sinfo.Identifier (R_Node (Statement)),
Internal_Kind => A_Defining_Identifier,
Starting_Element => Statement));
end if;
if not Is_List_Member (Arg_Node) then
-- the accept statement in accept alternative, it cannot
-- have labels at all
return Nil_Element_List;
end if;
Label_Node := Prev (Arg_Node);
while Nkind (Label_Node) in N_Raise_xxx_Error loop
-- See B920-A06
Label_Node := Prev (Label_Node);
end loop;
while Nkind (Label_Node) = N_Label loop
Labels_Number := Labels_Number + 1;
Label_Node := Prev (Label_Node);
end loop;
-- Label_Node is not the Node of N_Label kind now
if Labels_Number = 0 then
return Nil_Element_List;
else
declare
Result_List : Asis.Element_List
(1 .. ASIS_Integer (Labels_Number));
begin
if Label_Node = Empty then
-- special case: the first statement in the statement
-- sequence is labeled
Label_Node := First (List_Containing (Arg_Node));
else
Label_Node := Next (Label_Node);
end if;
-- the first label attached to the statement and the number of
-- attached labels are obtained
for I in 1 .. ASIS_Integer (Labels_Number) loop
-- the order of labels is important !
Result_List (I) := Node_To_Element_New (
Node => Label_Node,
Internal_Kind => A_Defining_Identifier,
Starting_Element => Statement);
Label_Node := Next (Label_Node);
end loop;
return Result_List;
end;
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Label_Names");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Label_Names",
Ex => Ex,
Arg_Element => Statement);
end Label_Names;
---------------------
-- Loop_Statements --
---------------------
function Loop_Statements
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Statement_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Loop_Statements");
if not (Arg_Kind = A_Loop_Statement or else
Arg_Kind = A_While_Loop_Statement or else
Arg_Kind = A_For_Loop_Statement)
then
Raise_ASIS_Inappropriate_Element
("Asis_Statement.Loop_Statements",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return N_To_E_List_New
(List => Sinfo.Statements (Arg_Node),
Include_Pragmas => Include_Pragmas,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Loop_Statements");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Loop_Statements",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Include_Pragmas);
end Loop_Statements;
--------------------------
-- Qualified_Expression --
--------------------------
function Qualified_Expression
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Qualified_Expression");
if not (Arg_Kind = A_Code_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Qualified_Expression",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New (
Node => Sinfo.Expression (Arg_Node),
Internal_Kind => A_Qualified_Expression,
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Qualified_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Qualified_Expression",
Ex => Ex,
Arg_Element => Statement);
end Qualified_Expression;
----------------------
-- Raised_Exception --
----------------------
function Raised_Exception
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Result_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Raised_Exception");
if not (Arg_Kind = A_Raise_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Raised_Exception",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Result_Node := Sinfo.Name (Arg_Node);
if No (Result_Node) then
return Nil_Element;
else
return Node_To_Element_New (
Node => Result_Node,
Starting_Element => Statement);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Raised_Exception");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Raised_Exception",
Ex => Ex,
Arg_Element => Statement);
end Raised_Exception;
------------------------
-- Requeue_Entry_Name --
------------------------
function Requeue_Entry_Name
(Statement : Asis.Statement)
return Asis.Name
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Requeue_Entry_Name");
if not (Arg_Kind = A_Requeue_Statement
or else
Arg_Kind = A_Requeue_Statement_With_Abort)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Requeue_Entry_Name",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New (Node => Sinfo.Name (Arg_Node),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Requeue_Entry_Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Requeue_Entry_Name",
Ex => Ex,
Arg_Element => Statement);
end Requeue_Entry_Name;
-----------------------
-- Return_Expression --
-----------------------
function Return_Expression
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Result_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Return_Expression");
if not (Arg_Kind = A_Return_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Return_Expression",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
Result_Node := Sinfo.Expression (Arg_Node);
if No (Result_Node) then
return Nil_Element;
else
return Node_To_Element_New (Node => Result_Node,
Starting_Element => Statement);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Return_Expression");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Return_Expression",
Ex => Ex,
Arg_Element => Statement);
end Return_Expression;
----------------------------
-- Sequence_Of_Statements --
----------------------------
function Sequence_Of_Statements
(Path : Asis.Path;
Include_Pragmas : Boolean := False)
return Asis.Statement_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Path);
Arg_Node : Node_Id;
Result_List : List_Id;
-- for processing An_If_Path, An_Elsif_Path, An_Else_Path, A_Case_Path
-- and A_Then_Abort_Path arguments; the node of such argument has
-- regular structure
-- local variables for processing A_Select_Path and An_Or_Path
-- arguments; the node of such arguments has irregular structure
Statement_List : List_Id;
First_Element : Asis.Element := Nil_Element;
Alternative_Node_Kind : Node_Kind;
begin
Check_Validity (Path, Package_Name & "Sequence_Of_Statements");
if not (Arg_Kind in Internal_Statement_Path_Kinds) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Sequence_Of_Statements",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Path);
case Arg_Kind is
when An_If_Path | An_Elsif_Path =>
Result_List := Then_Statements (Arg_Node);
when An_Else_Path =>
Result_List := Else_Statements (Arg_Node);
when A_Case_Path =>
Result_List := Sinfo.Statements (Arg_Node);
when A_Then_Abort_Path =>
Result_List := Sinfo.Statements (Arg_Node);
when A_Select_Path | An_Or_Path =>
Alternative_Node_Kind := Nkind (Arg_Node);
if Alternative_Node_Kind = N_Terminate_Alternative then
-- special case: result list contains only one dummy terminate
-- statement; no tree traversing needed: the result is based
-- on the same node as the argument
return Asis.Statement_List'(
1 => Node_To_Element_New (
Node => Arg_Node,
Internal_Kind => A_Terminate_Alternative_Statement,
Starting_Element => Path));
else
-- this alternative corresponds to the situation of
-- N_Accept_Alternative, N_Delay_Alternative,
-- N_Entry_Call_Alternative or N_Triggering_Alternative
-- forming the first element of the element list to be
-- returned:
if Alternative_Node_Kind = N_Accept_Alternative then
First_Element :=
Node_To_Element_New (
Node => Accept_Statement (Arg_Node),
Internal_Kind => An_Accept_Statement,
Starting_Element => Path);
elsif Alternative_Node_Kind = N_Delay_Alternative then
First_Element :=
Node_To_Element_New (
Node => Delay_Statement (Arg_Node),
Starting_Element => Path);
elsif Alternative_Node_Kind = N_Entry_Call_Alternative then
First_Element :=
Node_To_Element_New (
Node => Entry_Call_Statement (Arg_Node),
Starting_Element => Path);
elsif Alternative_Node_Kind = N_Triggering_Alternative then
First_Element :=
Node_To_Element_New (
Node => Triggering_Statement (Arg_Node),
Starting_Element => Path);
end if;
-- the rest of the returned list:
Statement_List := Sinfo.Statements (Arg_Node);
return Asis.Statement_List'(1 => First_Element) &
N_To_E_List_New
(List => Statement_List,
Include_Pragmas => Include_Pragmas,
Starting_Element => Path);
end if;
when others =>
null;
end case;
return N_To_E_List_New (List => Result_List,
Include_Pragmas => Include_Pragmas,
Starting_Element => Path);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Path,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Sequence_Of_Statements");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Sequence_Of_Statements",
Ex => Ex,
Arg_Element => Path,
Bool_Par_ON => Include_Pragmas);
end Sequence_Of_Statements;
--------------------------
-- Statement_Identifier --
--------------------------
function Statement_Identifier
(Statement : Asis.Statement)
return Asis.Defining_Name
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "Statement_Identifier");
if not (Arg_Kind = A_Loop_Statement or else
Arg_Kind = A_While_Loop_Statement or else
Arg_Kind = A_For_Loop_Statement or else
Arg_Kind = A_Block_Statement)
then
Raise_ASIS_Inappropriate_Element
("Asis_Statement.Statement_Identifier",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
if Special_Case (Statement) = A_Dummy_Block_Statement or else
Has_Created_Identifier (Arg_Node)
then
return Nil_Element;
else
return Node_To_Element_New (
Node => Sinfo.Identifier (Arg_Node),
Internal_Kind => A_Defining_Identifier,
Starting_Element => Statement);
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "Statement_Identifier");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Statement_Identifier",
Ex => Ex,
Arg_Element => Statement);
end Statement_Identifier;
---------------------
-- Statement_Paths --
---------------------
function Statement_Paths
(Statement : Asis.Statement;
Include_Pragmas : Boolean := False)
return Asis.Path_List
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
Path_List_Length : ASIS_Integer; -- Length of returned list
Elsif_Or_Length : ASIS_Integer; -- Number of Elsif or Or paths
Else_Present : Boolean;
begin
Check_Validity (Statement, Package_Name & "Statement_Paths");
if not (Arg_Kind = An_If_Statement or else
Arg_Kind = A_Case_Statement or else
Arg_Kind = A_Selective_Accept_Statement or else
Arg_Kind = A_Timed_Entry_Call_Statement or else
Arg_Kind = A_Conditional_Entry_Call_Statement or else
Arg_Kind = An_Asynchronous_Select_Statement)
then
Raise_ASIS_Inappropriate_Element
(Package_Name & "Statement_Paths",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
case Arg_Kind is
when An_If_Statement =>
Path_List_Length := 1; -- An_If_Path
Else_Present := Present (Else_Statements (Arg_Node));
if Else_Present then
Path_List_Length := Path_List_Length + 1;
end if;
if Present (Elsif_Parts (Arg_Node)) then
Elsif_Or_Length := ASIS_Integer
(List_Length (Elsif_Parts (Arg_Node)));
else
Elsif_Or_Length := 0;
end if;
Path_List_Length := Path_List_Length + Elsif_Or_Length;
declare
Path_List : Asis.Element_List (1 .. Path_List_Length);
-- Element List to be returned by the function
begin
Path_List (1) := Node_To_Element_New
(Node => Arg_Node,
Internal_Kind => An_If_Path,
Starting_Element => Statement);
Path_List (2 .. Elsif_Or_Length + 1) :=
N_To_E_List_New
(List => Elsif_Parts (Arg_Node),
Internal_Kind => An_Elsif_Path,
Starting_Element => Statement);
if Else_Present then
Path_List (Path_List_Length) := Node_To_Element_New
(Node => Arg_Node,
Internal_Kind => An_Else_Path,
Starting_Element => Statement);
end if;
return Path_List;
end;
when A_Case_Statement =>
-- only here the value of Include_Pragmas is important
return N_To_E_List_New
(List => Alternatives (Arg_Node),
Include_Pragmas => Include_Pragmas,
Starting_Element => Statement);
when A_Selective_Accept_Statement =>
Elsif_Or_Length := ASIS_Integer
(List_Length (Select_Alternatives (Arg_Node)));
Path_List_Length := Elsif_Or_Length;
Else_Present := Present (Else_Statements (Arg_Node));
if Else_Present then
Path_List_Length := Path_List_Length + 1;
end if;
declare
Path_List : Asis.Element_List (1 .. Path_List_Length);
-- Element List to be returned by the function
begin
Path_List (1 .. Elsif_Or_Length) :=
N_To_E_List_New
(List => Select_Alternatives (Arg_Node),
Starting_Element => Statement);
if Else_Present then
Path_List (Path_List_Length) := Node_To_Element_New
(Node => Arg_Node,
Internal_Kind => An_Else_Path,
Starting_Element => Statement);
end if;
return Path_List;
end;
when A_Timed_Entry_Call_Statement =>
return Asis.Path_List'(
1 => Node_To_Element_New (
Node => Entry_Call_Alternative (Arg_Node),
Internal_Kind => A_Select_Path,
Starting_Element => Statement),
2 => Node_To_Element_New (
Node => Delay_Alternative (Arg_Node),
Internal_Kind => An_Or_Path,
Starting_Element => Statement));
when A_Conditional_Entry_Call_Statement =>
return Asis.Path_List'(
1 => Node_To_Element_New (
Node => Entry_Call_Alternative (Arg_Node),
Internal_Kind => A_Select_Path,
Starting_Element => Statement),
2 => Node_To_Element_New (
Node => Arg_Node,
Internal_Kind => An_Else_Path,
Starting_Element => Statement));
when An_Asynchronous_Select_Statement =>
return Asis.Path_List'(
1 => Node_To_Element_New (
Node => Triggering_Alternative (Arg_Node),
Internal_Kind => A_Select_Path,
Starting_Element => Statement),
2 => Node_To_Element_New (
Node => Abortable_Part (Arg_Node),
Internal_Kind => A_Then_Abort_Path,
Starting_Element => Statement));
when others =>
raise Internal_Implementation_Error;
-- this choice can never be reached, see the condition
-- for defining the appropriate element
end case;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Bool_Par => Include_Pragmas,
Outer_Call => Package_Name & "Statement_Paths");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Statement_Paths",
Ex => Ex,
Arg_Element => Statement,
Bool_Par_ON => Include_Pragmas);
end Statement_Paths;
---------------------
-- While_Condition --
---------------------
function While_Condition
(Statement : Asis.Statement)
return Asis.Expression
is
Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Statement);
Arg_Node : Node_Id;
begin
Check_Validity (Statement, Package_Name & "While_Condition");
if not (Arg_Kind = A_While_Loop_Statement) then
Raise_ASIS_Inappropriate_Element
(Package_Name & "While_Condition",
Wrong_Kind => Arg_Kind);
end if;
Arg_Node := Node (Statement);
return Node_To_Element_New (
Node => Condition (Iteration_Scheme (Arg_Node)),
Starting_Element => Statement);
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Argument => Statement,
Outer_Call => Package_Name & "While_Condition");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "While_Condition",
Ex => Ex,
Arg_Element => Statement);
end While_Condition;
end Asis.Statements;
|
AaronC98/PlaneSystem | Ada | 9,499 | adb | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2008-2017, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Unchecked_Conversion;
with GNAT.MD5;
with AWS.Digest;
with AWS.Utils;
package body AWS.Jabber.Digest_Md5 is
use Ada;
function Response
(Username, Realm, Password, Host, Nonce, Cnonce : String)
return Utils.Hex_String;
-- Generate the response directive
subtype MD5_16_Hash is String (1 .. 16);
function Make_URP_Hash
(Username, Realm, Password : String) return MD5_16_Hash;
-- Compute the 16 octect md5 hash of username:realm:password
----------------------
-- Decode_Challenge --
----------------------
function Decode_Challenge
(Encoded_Challenge : Translator.Base64_String) return Challenge
is
Decoded_Challenge : Challenge;
procedure Parse_Key_Value (S : String);
-- Parse a key=value string and fill challenge
---------------------
-- Parse_Key_Value --
---------------------
procedure Parse_Key_Value (S : String) is
begin
for K in S'Range loop
if S (K) = '=' then
if S (S'First .. K - 1) = "nonce" then
if S (K + 1) = '"' then
Decoded_Challenge.Nonce :=
To_Unbounded_String (S (K + 2 .. S'Last - 1));
else
Decoded_Challenge.Nonce :=
To_Unbounded_String (S (K + 1 .. S'Last));
end if;
elsif S (S'First .. K - 1) = "realm" then
if S (K + 1) = '"' then
Decoded_Challenge.Realm :=
To_Unbounded_String (S (K + 2 .. S'Last - 1));
else
Decoded_Challenge.Realm :=
To_Unbounded_String (S (K + 1 .. S'Last));
end if;
end if;
end if;
end loop;
end Parse_Key_Value;
Message : constant String :=
Translator.To_String
(Translator.Base64_Decode (Encoded_Challenge));
Index : Natural := Message'First;
begin
-- Get a key=value message separated with ','
for K in Message'Range loop
if Message (K) = ',' then
Parse_Key_Value (Message (Index .. K - 1));
Index := K + 1;
end if;
end loop;
return Decoded_Challenge;
end Decode_Challenge;
-------------------
-- Make_URP_Hash --
-------------------
function Make_URP_Hash
(Username, Realm, Password : String) return MD5_16_Hash
is
type Byte is mod 2 ** 8;
type Byte_Array is array (Long_Integer range <>) of Byte with Pack;
subtype Fingerprint is Byte_Array (1 .. 16); -- 128 bits
subtype Digest_String is Utils.Hex_String (1 .. 32);
function To_String is new Unchecked_Conversion
(Source => Fingerprint,
Target => MD5_16_Hash);
function Digest_From_Text (S : Digest_String) return Fingerprint;
----------------------
-- Digest_From_Text --
----------------------
function Digest_From_Text (S : Digest_String) return Fingerprint is
type Word is mod 2 ** 32;
function Shift_Left (Value : Word; Amount : Natural) return Word
with Import, Convention => Intrinsic;
Digest : Fingerprint;
Val : Word;
Ch : Character;
begin
for I in Digest'Range loop
Ch := S (2 * Integer (I - 1) + 1);
case Ch is
when '0' .. '9' => Val
:= Character'Pos (Ch) - Character'Pos ('0');
when 'a' .. 'f' => Val
:= Character'Pos (Ch) - Character'Pos ('a') + 10;
when 'A' .. 'F' => Val
:= Character'Pos (Ch) - Character'Pos ('A') + 10;
when others => raise Program_Error;
end case;
Val := Shift_Left (Val, 4);
Ch := S (2 * Integer (I));
case Ch is
when '0' .. '9' => Val
:= Val + (Character'Pos (Ch) - Character'Pos ('0'));
when 'a' .. 'f' => Val
:= Val + (Character'Pos (Ch) - Character'Pos ('a') + 10);
when 'A' .. 'F' => Val
:= Val + (Character'Pos (Ch) - Character'Pos ('A') + 10);
when others => raise Program_Error;
end case;
Digest (I) := Byte (Val);
end loop;
return Digest;
end Digest_From_Text;
URP : constant String := Username & ':' & Realm & ':' & Password;
URP_Digest : constant Digest_String := GNAT.MD5.Digest (URP);
begin
return To_String (Digest_From_Text (URP_Digest));
end Make_URP_Hash;
---------------------
-- Reply_Challenge --
---------------------
function Reply_Challenge
(Username, Realm, Password, Host, Nonce : String)
return Translator.Base64_String
is
-- Return a base64 encoded form of
-- username="Username",realm="Realm",nonce="Nonce",
-- cnone="A_Client_Generated_Nonce",nc=0000001,qop=auth,
-- digest-uri="xmpp/Hostname",response=A_Computed_challenge_response,
-- charset=utf-8
-- Note that authzid is not used
CNonce : constant String := AWS.Digest.Create_Nonce;
Clear_Response : constant String :=
"realm=" & '"' & Realm & '"' & ','
& "username=" & '"' & Username & '"' & ','
& "cnonce=" & '"' & CNonce & '"' & ','
& "nonce=" & '"' & Nonce & '"' & ','
& "nc=" & "00000001" & ','
& "qop=" & "auth" & ','
& "digest-uri=" & '"' & "xmpp/" & Host & '"' & ','
& "response=" & Digest_Md5.Response
(Username, Realm, Password, Host, Nonce, CNonce);
begin
return AWS.Translator.Base64_Encode (Clear_Response);
end Reply_Challenge;
--------------
-- Response --
--------------
function Response
(Username, Realm, Password, Host, Nonce, Cnonce : String)
return Utils.Hex_String
is
-- The value of the response directive is computed as follows:
-- * Create a 16 octet md5 hash of a string
-- of the form "username:realm:password".
-- Call it string URP
-- * create a string of the form "URP:nonce:cnonce:authzid".
-- Call this string A1.
-- * Create a string of the form "AUTHENTICATE:digest-uri".
-- Call this string A2.
-- * Compute the 32 hex digit MD5 hash of A1. Call the result HA1.
-- * Compute the 32 hex digit MD5 hash of A2. Call the result HA2.
-- * Then compute the 32 hex digit MD5 hash
-- of "HA1:nonce:nc:cnonce:qop:HA2"
URP : constant String :=
Digest_Md5.Make_URP_Hash
(Username, Realm, Password);
A1 : constant String := URP & ":" & Nonce & ':' & Cnonce;
A2 : constant String := "AUTHENTICATE:xmpp/" & Host;
HA1 : constant GNAT.MD5.Message_Digest := GNAT.MD5.Digest (A1);
HA2 : constant GNAT.MD5.Message_Digest := GNAT.MD5.Digest (A2);
begin
-- Compute the 32 hex digit MD5 hash of KD
return GNAT.MD5.Digest
(HA1 & ":" & Nonce & ":00000001:" & Cnonce & ":auth:" & HA2);
end Response;
end AWS.Jabber.Digest_Md5;
|
reznikmm/matreshka | Ada | 4,081 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Presentation_Style_Name_Attributes;
package Matreshka.ODF_Presentation.Style_Name_Attributes is
type Presentation_Style_Name_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Style_Name_Attributes.ODF_Presentation_Style_Name_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Style_Name_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Style_Name_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Style_Name_Attributes;
|
AaronC98/PlaneSystem | Ada | 7,113 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
-- This is the socket memory stream. It can be used to route all data to an
-- in-memory buffer before actually sending the data to a real socket for
-- example.
--
-- The server side is done by the AWS runtime, that is there is no needed to
-- Bind, Listen or Accept_Socket. To use such socket both side has to call
-- Connect on a specific port with the hostname set to ":memory:".
with Memory_Streams;
package AWS.Net.Memory is
type Socket_Type is new Net.Socket_Type with private;
----------------
-- Initialize --
----------------
overriding procedure Bind
(Socket : in out Socket_Type;
Port : Natural;
Host : String := "";
Reuse_Address : Boolean := False;
IPv6_Only : Boolean := False;
Family : Family_Type := Family_Unspec) is null;
-- Bind a socket on a given port
overriding procedure Listen
(Socket : Socket_Type;
Queue_Size : Positive := 5) is null;
-- Set the queue size of the socket
overriding procedure Accept_Socket
(Socket : Net.Socket_Type'Class;
New_Socket : in out Socket_Type) is null;
-- Accept a connection on a socket
overriding procedure Connect
(Socket : in out Socket_Type;
Host : String;
Port : Positive;
Wait : Boolean := True;
Family : Family_Type := Family_Unspec)
with Pre => Host = ":memory:";
-- Connect to any known memory socket or create a new one. The memory
-- socket identifier is given by the Port number.
overriding procedure Shutdown
(Socket : Socket_Type; How : Shutmode_Type := Shut_Read_Write);
-- Shutdown the read, write or both side of the socket.
-- If How is Both, close it. Does not raise Socket_Error if the socket is
-- not connected or already shutdown.
--------
-- IO --
--------
overriding procedure Send
(Socket : Socket_Type;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset);
overriding procedure Receive
(Socket : Socket_Type;
Data : out Stream_Element_Array;
Last : out Stream_Element_Offset)
with Inline;
overriding function Pending
(Socket : Socket_Type) return Stream_Element_Count;
-- Returns the number of bytes which are available inside socket
-- for immediate read.
------------
-- Others --
------------
overriding function Get_FD (Socket : Socket_Type) return Integer;
-- Returns the file descriptor associated with the socket
overriding function Peer_Addr (Socket : Socket_Type) return String;
-- Returns the peer name/address
overriding function Peer_Port (Socket : Socket_Type) return Positive;
-- Returns the port of the peer socket
overriding function Get_Addr (Socket : Socket_Type) return String;
-- Returns the name/address of the socket
overriding function Get_Port (Socket : Socket_Type) return Positive;
-- Returns the port of the socket
overriding function Is_Any_Address (Socket : Socket_Type) return Boolean;
-- Return true if the socket accepts connections on any of the hosts's
-- network addresses.
overriding procedure Set_Send_Buffer_Size
(Socket : Socket_Type;
Size : Natural) is null;
-- Set the internal socket send buffer size.
-- Do not confuse with buffers for the AWS.Net.Buffered operations.
overriding procedure Set_Receive_Buffer_Size
(Socket : Socket_Type;
Size : Natural) is null;
-- Set the internal socket receive buffer size.
-- Do not confuse with buffers for the AWS.Net.Buffered operations.
overriding function Get_Send_Buffer_Size
(Socket : Socket_Type) return Natural;
-- Returns the internal socket send buffer size.
-- Do not confuse with buffers for the AWS.Net.Buffered operations.
overriding function Get_Receive_Buffer_Size
(Socket : Socket_Type) return Natural;
-- Returns the internal socket receive buffer size.
-- Do not confuse with buffers for the AWS.Net.Buffered operations.
overriding function Errno (Socket : Socket_Type) return Integer;
-- Returns and clears error state in socket
private
type Element_Access is access Stream_Element_Array;
type Constant_Element_Access is access constant Stream_Element_Array;
package Stream_Memory is new Memory_Streams
(Stream_Element, Stream_Element_Offset, Stream_Element_Array,
Element_Access, Constant_Element_Access);
type Stream_Access is access Stream_Memory.Stream_Type;
type Socket_Type is new Net.Socket_Type with record
Port : Positive;
S : Stream_Access;
end record;
overriding procedure Free (Socket : in out Socket_Type);
-- Release memory associated with the socket object
overriding procedure Initialize (Socket : in out Socket_Type);
end AWS.Net.Memory;
|
AdaCore/training_material | Ada | 254 | ads | package Point_Of_Sale is
procedure Catalog (With_Count : Boolean := False);
procedure Sell_Item
(Item : String;
Count : Positive := 1);
procedure Return_Item
(Item : String;
Count : Positive := 1);
end Point_Of_Sale;
|
reznikmm/spawn | Ada | 1,443 | adb | --
-- Copyright (C) 2018-2019, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Ada.Strings.UTF_Encoding.Wide_Strings;
with Interfaces.C;
with Spawn.Windows_API;
separate (Spawn.Environments)
function Search_In_Path
(File : UTF_8_String;
Path : UTF_8_String) return UTF_8_String
is
use type Spawn.Windows_API.DWORD;
Raw_Path : Interfaces.C.wchar_array :=
Interfaces.C.To_C
(Ada.Strings.UTF_Encoding.Wide_Strings.Decode (Path));
Raw_File : Interfaces.C.wchar_array :=
Interfaces.C.To_C
(Ada.Strings.UTF_Encoding.Wide_Strings.Decode (File));
Raw_Exe : Interfaces.C.wchar_array := Interfaces.C.To_C (".exe");
Buffer : Interfaces.C.wchar_array (1 .. Spawn.Windows_API.MAX_PATH);
Length : constant Spawn.Windows_API.DWORD :=
Spawn.Windows_API.SearchPath
(lpPath => Raw_Path (Raw_Path'First)'Unchecked_Access,
lpFileName => Raw_File (Raw_File'First)'Unchecked_Access,
lpExtension => Raw_Exe (Raw_Exe'First)'Unchecked_Access,
nBufferLength => Buffer'Length,
lpBuffer => Buffer (Buffer'First)'Unchecked_Access,
lpFilePart => null);
begin
return
(if Length = 0 or else Length > Buffer'Length then ""
else Ada.Strings.UTF_Encoding.Wide_Strings.Encode
(Interfaces.C.To_Ada
(Buffer (1 .. Interfaces.C.size_t (Length)), Trim_Nul => False)));
end Search_In_Path;
|
stcarrez/ada-enet | Ada | 998 | ads | -----------------------------------------------------------------------
-- receiver -- Ethernet Packet Receiver
-- Copyright (C) 2016, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Net.DNS;
package Dns_List is
type Query_Array is array (1 .. 30) of aliased Net.DNS.Query;
Queries : Query_Array;
end Dns_List;
|
zhmu/ananas | Ada | 4,161 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . M O S T _ R E C E N T _ E X C E P T I O N --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2022, 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 routines for accessing the most recently raised
-- exception. This may be useful for certain logging activities. It may
-- also be useful for mimicking implementation dependent capabilities in
-- Ada 83 compilers, but see also GNAT.Current_Exceptions for this usage.
with Ada.Exceptions;
package GNAT.Most_Recent_Exception is
-----------------
-- Subprograms --
-----------------
function Occurrence
return Ada.Exceptions.Exception_Occurrence;
-- Returns the Exception_Occurrence for the most recently raised exception
-- in the current task. If no exception has been raised in the current task
-- prior to the call, returns Null_Occurrence.
function Occurrence_Access
return Ada.Exceptions.Exception_Occurrence_Access;
-- Similar to the above, but returns an access to the occurrence value.
-- This value is in a task specific location, and may be validly accessed
-- as long as no further exception is raised in the calling task.
-- Note: unlike the routines in GNAT.Current_Exception, these functions
-- access the most recently raised exception, regardless of where they
-- are called. Consider the following example:
-- exception
-- when Constraint_Error =>
-- begin
-- ...
-- exception
-- when Tasking_Error => ...
-- end;
--
-- -- Assuming a Tasking_Error was raised in the inner block,
-- -- a call to GNAT.Most_Recent_Exception.Occurrence will
-- -- return information about this Tasking_Error exception,
-- -- not about the Constraint_Error exception being handled
-- -- by the current handler code.
end GNAT.Most_Recent_Exception;
|
zhangkaizhao/completely-unscientific-benchmarks | Ada | 966 | ads | with Ada.Numerics.Discrete_Random;
package Tree_Naive_Pointers is
type Node is private;
type NodePtr is access Node;
type Tree is private;
procedure initialize;
function hasValue(t: in out Tree; x: Integer) return Boolean;
procedure insert(t: in out Tree; x: Integer);
procedure erase(t: in out Tree; x: Integer);
private
function merge(lower, greater: NodePtr) return NodePtr;
function merge(lower, equal, greater: NodePtr) return NodePtr;
procedure split(orig: NodePtr; lower, greaterOrEqual: in out NodePtr; val: Integer);
procedure split(orig: NodePtr; lower, equal, greater: in out NodePtr; val: Integer);
procedure make_node(n: out NodePtr; x: Integer);
type Tree is record
root: NodePtr := null;
end record;
package Integer_Random is new Ada.Numerics.Discrete_Random(Integer);
use Integer_Random;
g: Generator;
type Node is record
left, right: NodePtr;
x: Integer := 0;
y: Integer := Random(g);
end record;
end Tree_Naive_Pointers;
|
sungyeon/drake | Ada | 4,511 | adb | with Ada.Containers.Array_Sorting;
with System.Long_Long_Integer_Types;
procedure Ada.Containers.Generic_Array_Sort (Container : in out Array_Type) is
subtype Word_Integer is System.Long_Long_Integer_Types.Word_Integer;
begin
if Index_Type'Pos (Index_Type'First) in
Long_Long_Integer (Word_Integer'First) ..
Long_Long_Integer (Word_Integer'Last)
and then Index_Type'Pos (Index_Type'Last) in
Long_Long_Integer (Word_Integer'First) ..
Long_Long_Integer (Word_Integer'Last)
then
declare
type Context_Type is limited record
Container : not null access Array_Type;
end record;
pragma Suppress_Initialization (Context_Type);
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean;
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type := Index_Type'Val (Left);
Right_Index : constant Index_Type := Index_Type'Val (Right);
begin
return Context.Container (Left_Index) <
Context.Container (Right_Index);
end LT;
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address);
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address)
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type := Index_Type'Val (Left);
Right_Index : constant Index_Type := Index_Type'Val (Right);
Temp : constant Element_Type := Context.Container (Left_Index);
begin
Context.Container (Left_Index) := Context.Container (Right_Index);
Context.Container (Right_Index) := Temp;
end Swap;
Context : aliased Context_Type :=
(Container => Container'Unrestricted_Access);
begin
Array_Sorting.In_Place_Merge_Sort (
Index_Type'Pos (Container'First),
Index_Type'Pos (Container'Last),
Context'Address,
LT => LT'Access,
Swap => Swap'Access);
end;
else
declare
type Context_Type is limited record
Container : not null access Array_Type;
Offset : Long_Long_Integer;
end record;
pragma Suppress_Initialization (Context_Type);
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean;
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Left) + Context.Offset);
Right_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Right) + Context.Offset);
begin
return Context.Container (Left_Index) <
Context.Container (Right_Index);
end LT;
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address);
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address)
is
Context : Context_Type;
for Context'Address use Params;
Left_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Left) + Context.Offset);
Right_Index : constant Index_Type :=
Index_Type'Val (Long_Long_Integer (Right) + Context.Offset);
Temp : constant Element_Type := Context.Container (Left_Index);
begin
Context.Container (Left_Index) := Context.Container (Right_Index);
Context.Container (Right_Index) := Temp;
end Swap;
Offset : constant Long_Long_Integer :=
Index_Type'Pos (Container'First);
Context : aliased Context_Type :=
(Container'Unrestricted_Access, Offset);
begin
Array_Sorting.In_Place_Merge_Sort (
0,
Word_Integer (Index_Type'Pos (Container'Last) - Offset),
Context'Address,
LT => LT'Access,
Swap => Swap'Access);
end;
end if;
end Ada.Containers.Generic_Array_Sort;
|
reznikmm/matreshka | Ada | 4,785 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Table_Tracked_Changes_Elements;
package Matreshka.ODF_Table.Tracked_Changes_Elements is
type Table_Tracked_Changes_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_Tracked_Changes_Elements.ODF_Table_Tracked_Changes
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Tracked_Changes_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Tracked_Changes_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_Tracked_Changes_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Table_Tracked_Changes_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Table_Tracked_Changes_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Table.Tracked_Changes_Elements;
|
jrmarino/AdaBase | Ada | 40,279 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
with AdaBase.Results.Converters;
package body AdaBase.Results.Field is
package ARC renames AdaBase.Results.Converters;
-- [1] For several conversions, the string equivalents in both ASCII
-- and UTF-8 must be identical. For this, just skip the conversion
-- from UTF-8 to ASCII as the extract step makes no differnce
-- [2] For types with textual components (e.g. enum types), convert
-- UTF-8 data to ASCII first
-----------------
-- as_nbyte0 --
-----------------
function as_nbyte0 (field : Std_Field) return NByte0
is
begin
case field.native.datatype is
when ft_nbyte0 => return field.native.v00;
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_chain =>
declare
cadena : constant Chain := ARC.convert (field.native.v17);
begin
return ARC.convert (cadena);
end;
when ft_bits =>
declare
cadena : constant Bits := ARC.convert (field.native.v20);
begin
return ARC.convert (cadena);
end;
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_nbyte0;
-----------------
-- as_nbyte1 --
-----------------
function as_nbyte1 (field : Std_Field) return NByte1
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return field.native.v01;
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_chain =>
declare
cadena : constant Chain := ARC.convert (field.native.v17);
begin
return ARC.convert (cadena);
end;
when ft_bits =>
declare
cadena : constant Bits := ARC.convert (field.native.v20);
begin
return ARC.convert (cadena);
end;
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_nbyte1;
-----------------
-- as_nbyte2 --
-----------------
function as_nbyte2 (field : Std_Field) return NByte2
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return field.native.v02;
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_chain =>
declare
cadena : constant Chain := ARC.convert (field.native.v17);
begin
return ARC.convert (cadena);
end;
when ft_bits =>
declare
cadena : constant Bits := ARC.convert (field.native.v20);
begin
return ARC.convert (cadena);
end;
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_nbyte2;
-----------------
-- as_nbyte3 --
-----------------
function as_nbyte3 (field : Std_Field) return NByte3
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return field.native.v03;
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_chain =>
declare
cadena : constant Chain := ARC.convert (field.native.v17);
begin
return ARC.convert (cadena);
end;
when ft_bits =>
declare
cadena : constant Bits := ARC.convert (field.native.v20);
begin
return ARC.convert (cadena);
end;
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_nbyte3;
-----------------
-- as_nbyte4 --
-----------------
function as_nbyte4 (field : Std_Field) return NByte4
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return field.native.v04;
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_chain =>
declare
cadena : constant Chain := ARC.convert (field.native.v17);
begin
return ARC.convert (cadena);
end;
when ft_bits =>
declare
cadena : constant Bits := ARC.convert (field.native.v20);
begin
return ARC.convert (cadena);
end;
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_nbyte4;
-----------------
-- as_nbyte8 --
-----------------
function as_nbyte8 (field : Std_Field) return NByte8
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return field.native.v05;
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_chain =>
declare
cadena : constant Chain := ARC.convert (field.native.v17);
begin
return ARC.convert (cadena);
end;
when ft_bits =>
declare
cadena : constant Bits := ARC.convert (field.native.v20);
begin
return ARC.convert (cadena);
end;
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_nbyte8;
----------------
-- as_byte1 --
----------------
function as_byte1 (field : Std_Field) return Byte1
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return field.native.v06;
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_chain |
ft_bits |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_byte1;
----------------
-- as_byte2 --
----------------
function as_byte2 (field : Std_Field) return Byte2
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return field.native.v07;
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_chain |
ft_bits |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_byte2;
----------------
-- as_byte3 --
----------------
function as_byte3 (field : Std_Field) return Byte3
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return field.native.v08;
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_chain |
ft_bits |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_byte3;
----------------
-- as_byte4 --
----------------
function as_byte4 (field : Std_Field) return Byte4
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return field.native.v09;
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_chain |
ft_bits |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_byte4;
----------------
-- as_byte8 --
----------------
function as_byte8 (field : Std_Field) return Byte8
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return field.native.v10;
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_real9 |
ft_real18 |
ft_geometry |
ft_timestamp |
ft_chain |
ft_bits |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_byte8;
----------------
-- as_real9 --
----------------
function as_real9 (field : Std_Field) return Real9
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_real9 => return field.native.v11;
when ft_real18 => return ARC.convert (field.native.v12);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_timestamp |
ft_chain |
ft_bits |
ft_geometry |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_real9;
-----------------
-- as_real18 --
-----------------
function as_real18 (field : Std_Field) return Real18
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_real9 => return ARC.convert (field.native.v11);
when ft_real18 => return field.native.v12;
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21); -- [1]
when ft_timestamp |
ft_chain |
ft_bits |
ft_geometry |
ft_enumtype |
ft_settype => raise UNSUPPORTED_CONVERSION;
end case;
end as_real18;
-----------------
-- as_string --
-----------------
function as_string (field : Std_Field) return String
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_real9 => return ARC.convert (field.native.v11);
when ft_real18 => return ARC.convert (field.native.v12);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_timestamp => return ARC.convert (field.native.v16);
when ft_chain => return ARC.convert (field.native.v17);
when ft_enumtype => return ARC.convert (field.native.v18);
when ft_settype => return ARC.convert (field.native.v19);
when ft_bits => return ARC.convert (field.native.v20);
when ft_utf8 => return ARC.cvu2str (CT.USS (field.native.v21));
when ft_geometry => return WKB.produce_WKT (field.native.v22);
end case;
end as_string;
------------------
-- as_wstring --
------------------
function as_wstring (field : Std_Field) return Wide_String
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_real9 => return ARC.convert (field.native.v11);
when ft_real18 => return ARC.convert (field.native.v12);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_timestamp => return ARC.convert (field.native.v16);
when ft_chain => return ARC.convert (field.native.v17);
when ft_enumtype => return ARC.convert (field.native.v18);
when ft_settype => return ARC.convert (field.native.v19);
when ft_bits => return ARC.convert (field.native.v20);
when ft_utf8 => return ARC.cvu2str (CT.USS (field.native.v21));
when ft_geometry =>
return ARC.convert (WKB.produce_WKT (field.native.v22));
end case;
end as_wstring;
-------------------
-- as_wwstring --
-------------------
function as_wwstring (field : Std_Field) return Wide_Wide_String
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_byte1 => return ARC.convert (field.native.v06);
when ft_byte2 => return ARC.convert (field.native.v07);
when ft_byte3 => return ARC.convert (field.native.v08);
when ft_byte4 => return ARC.convert (field.native.v09);
when ft_byte8 => return ARC.convert (field.native.v10);
when ft_real9 => return ARC.convert (field.native.v11);
when ft_real18 => return ARC.convert (field.native.v12);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_timestamp => return ARC.convert (field.native.v16);
when ft_chain => return ARC.convert (field.native.v17);
when ft_enumtype => return ARC.convert (field.native.v18);
when ft_settype => return ARC.convert (field.native.v19);
when ft_bits => return ARC.convert (field.native.v20);
when ft_utf8 => return ARC.cvu2str (CT.USS (field.native.v21));
when ft_geometry =>
return ARC.convert (WKB.produce_WKT (field.native.v22));
end case;
end as_wwstring;
-----------------
-- as_time --
-----------------
function as_time (field : Std_Field) return AC.Time is
begin
case field.native.datatype is
when ft_timestamp => return field.native.v16;
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 => return ARC.convert (field.native.v21);
when others => raise UNSUPPORTED_CONVERSION;
end case;
end as_time;
------------------
-- as_geometry --
------------------
function as_geometry (field : Std_Field) return GEO.Geometry is
begin
case field.native.datatype is
when ft_geometry =>
return WKB.Translate_WKB (CT.USS (field.native.v22));
when ft_chain =>
return WKB.Translate_WKB (ARC.convert (field.native.v22));
when others => raise UNSUPPORTED_CONVERSION;
end case;
end as_geometry;
----------------
-- as_chain --
----------------
function as_chain (field : Std_Field) return Chain
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_chain => return ARC.convert (field.native.v17);
when ft_geometry => return ARC.convert (field.native.v22);
when ft_bits =>
declare
target_bits : constant Bits := ARC.convert (field.native.v20);
begin
return ARC.convert (target_bits);
end;
when ft_byte1 |
ft_byte2 |
ft_byte3 |
ft_byte4 |
ft_byte8 |
ft_real9 |
ft_real18 |
ft_utf8 |
ft_enumtype |
ft_settype |
ft_timestamp => raise UNSUPPORTED_CONVERSION;
end case;
end as_chain;
-------------------
-- as_enumtype --
-------------------
function as_enumtype (field : Std_Field) return Enumtype
is
begin
case field.native.datatype is
when ft_enumtype => return field.native.v18;
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_utf8 =>
declare
txt : constant Textual := ARC.cvu2str (field.native.v21); -- [2]
begin
return ARC.convert (txt);
end;
when others => raise UNSUPPORTED_CONVERSION;
end case;
end as_enumtype;
-----------------
-- as_settype --
-----------------
function as_settype (field : Std_Field) return Settype
is
begin
case field.native.datatype is
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_settype => return ARC.convert (field.native.v19);
when ft_utf8 => return ARC.convert (field.native.v21);
when others => raise UNSUPPORTED_CONVERSION;
end case;
end as_settype;
---------------
-- as_bits --
---------------
function as_bits (field : Std_Field) return Bits
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.convert (field.native.v00);
when ft_nbyte1 => return ARC.convert (field.native.v01);
when ft_nbyte2 => return ARC.convert (field.native.v02);
when ft_nbyte3 => return ARC.convert (field.native.v03);
when ft_nbyte4 => return ARC.convert (field.native.v04);
when ft_nbyte8 => return ARC.convert (field.native.v05);
when ft_textual => return ARC.convert (field.native.v13);
when ft_widetext => return ARC.convert (field.native.v14);
when ft_supertext => return ARC.convert (field.native.v15);
when ft_chain => return ARC.convert (field.native.v17);
when ft_bits => return ARC.convert (field.native.v20);
when ft_byte1 |
ft_byte2 |
ft_byte3 |
ft_byte4 |
ft_byte8 |
ft_real9 |
ft_real18 |
ft_utf8 |
ft_geometry |
ft_enumtype |
ft_settype |
ft_timestamp => raise UNSUPPORTED_CONVERSION;
end case;
end as_bits;
---------------
-- as_utf8 --
---------------
function as_utf8 (field : Std_Field) return Text_UTF8
is
begin
case field.native.datatype is
when ft_nbyte0 => return ARC.cv2utf8 (field.native.v00);
when ft_nbyte1 => return ARC.cv2utf8 (field.native.v01);
when ft_nbyte2 => return ARC.cv2utf8 (field.native.v02);
when ft_nbyte3 => return ARC.cv2utf8 (field.native.v03);
when ft_nbyte4 => return ARC.cv2utf8 (field.native.v04);
when ft_nbyte8 => return ARC.cv2utf8 (field.native.v05);
when ft_byte1 => return ARC.cv2utf8 (field.native.v06);
when ft_byte2 => return ARC.cv2utf8 (field.native.v07);
when ft_byte3 => return ARC.cv2utf8 (field.native.v08);
when ft_byte4 => return ARC.cv2utf8 (field.native.v09);
when ft_byte8 => return ARC.cv2utf8 (field.native.v10);
when ft_real9 => return ARC.cv2utf8 (field.native.v11);
when ft_real18 => return ARC.cv2utf8 (field.native.v12);
when ft_textual => return ARC.cv2utf8 (field.native.v13);
when ft_widetext => return ARC.cv2utf8 (field.native.v14);
when ft_supertext => return ARC.cv2utf8 (field.native.v15);
when ft_timestamp => return ARC.cv2utf8 (field.native.v16);
when ft_enumtype => return ARC.cv2utf8 (field.native.v18);
when ft_settype => return ARC.cv2utf8 (field.native.v19);
when ft_utf8 => return Text_UTF8 (CT.USS (field.native.v21));
when ft_geometry =>
return ARC.cv2utf8 (WKB.produce_WKT (field.native.v22));
when ft_chain |
ft_bits => raise UNSUPPORTED_CONVERSION;
end case;
end as_utf8;
---------------
-- is_null --
---------------
function is_null (field : Std_Field) return Boolean is
begin
return field.explicit_null;
end is_null;
-------------------
-- native_type --
-------------------
function native_type (field : Std_Field) return field_types is
begin
return field.native.datatype;
end native_type;
----------------------
-- spawn_field #1 --
----------------------
function spawn_field (data : Variant; null_data : Boolean := False)
return Std_Field
is
result : Std_Field;
begin
result.set (data => data, exnull => null_data);
return result;
end spawn_field;
----------------------
-- spawn_field #2 --
----------------------
function spawn_field (binob : Chain) return Std_Field
is
result : Std_Field;
chainstr : constant String := ARC.convert (binob);
begin
result.set (data => (ft_chain, CT.SUS (chainstr)), exnull => False);
return result;
end spawn_field;
----------------------
-- spawn_field #3 --
----------------------
function spawn_field (enumset : String) return Std_Field
is
result : Std_Field;
begin
result.set (data => (ft_settype, CT.SUS (enumset)), exnull => False);
return result;
end spawn_field;
------------------------
-- spawn_bits_field --
------------------------
function spawn_bits_field (bitstring : String) return Std_Field
is
result : Std_Field;
begin
result.set (data => (ft_bits, CT.SUS (bitstring)), exnull => False);
return result;
end spawn_bits_field;
------------------------
-- spawn_null_field --
------------------------
function spawn_null_field (data_type : field_types) return Std_Field
is
result : Std_Field;
begin
case data_type is
when ft_nbyte0 => result.set ((ft_nbyte0, PARAM_IS_BOOLEAN), True);
when ft_nbyte1 => result.set ((ft_nbyte1, PARAM_IS_NBYTE_1), True);
when ft_nbyte2 => result.set ((ft_nbyte2, PARAM_IS_NBYTE_2), True);
when ft_nbyte3 => result.set ((ft_nbyte3, PARAM_IS_NBYTE_3), True);
when ft_nbyte4 => result.set ((ft_nbyte4, PARAM_IS_NBYTE_4), True);
when ft_nbyte8 => result.set ((ft_nbyte8, PARAM_IS_NBYTE_8), True);
when ft_byte1 => result.set ((ft_byte1, PARAM_IS_BYTE_1), True);
when ft_byte2 => result.set ((ft_byte2, PARAM_IS_BYTE_2), True);
when ft_byte3 => result.set ((ft_byte3, PARAM_IS_BYTE_3), True);
when ft_byte4 => result.set ((ft_byte4, PARAM_IS_BYTE_4), True);
when ft_byte8 => result.set ((ft_byte8, PARAM_IS_BYTE_8), True);
when ft_real9 => result.set ((ft_real9, PARAM_IS_REAL_9), True);
when ft_real18 => result.set ((ft_real18, PARAM_IS_REAL_18), True);
when ft_textual => result.set ((ft_textual, PARAM_IS_TEXTUAL), True);
when ft_widetext => result.set ((ft_widetext, PARAM_IS_TEXTWIDE), True);
when ft_supertext => result.set ((ft_supertext, PARAM_IS_TEXTSUPER), True);
when ft_timestamp => result.set ((ft_timestamp, PARAM_IS_TIMESTAMP), True);
when ft_chain => result.set ((ft_chain, PARAM_IS_TEXTUAL), True);
when ft_enumtype => result.set ((ft_enumtype, PARAM_IS_ENUM), True);
when ft_settype => result.set ((ft_settype, PARAM_IS_TEXTUAL), True);
when ft_bits => result.set ((ft_bits, PARAM_IS_TEXTUAL), True);
when ft_utf8 => result.set ((ft_utf8, PARAM_IS_TEXTUAL), True);
when ft_geometry => result.set ((ft_geometry, PARAM_IS_TEXTUAL), True);
end case;
return result;
end spawn_null_field;
-----------
-- set --
-----------
procedure set (field : out Std_Field; data : Variant; exnull : Boolean) is
begin
case data.datatype is
when ft_nbyte0 => field.native := (ft_nbyte0, data.v00);
when ft_nbyte1 => field.native := (ft_nbyte1, data.v01);
when ft_nbyte2 => field.native := (ft_nbyte2, data.v02);
when ft_nbyte3 => field.native := (ft_nbyte3, data.v03);
when ft_nbyte4 => field.native := (ft_nbyte4, data.v04);
when ft_nbyte8 => field.native := (ft_nbyte8, data.v05);
when ft_byte1 => field.native := (ft_byte1, data.v06);
when ft_byte2 => field.native := (ft_byte2, data.v07);
when ft_byte3 => field.native := (ft_byte3, data.v08);
when ft_byte4 => field.native := (ft_byte4, data.v09);
when ft_byte8 => field.native := (ft_byte8, data.v10);
when ft_real9 => field.native := (ft_real9, data.v11);
when ft_real18 => field.native := (ft_real18, data.v12);
when ft_textual => field.native := (ft_textual, data.v13);
when ft_widetext => field.native := (ft_widetext, data.v14);
when ft_supertext => field.native := (ft_supertext, data.v15);
when ft_timestamp => field.native := (ft_timestamp, data.v16);
when ft_chain => field.native := (ft_chain, data.v17);
when ft_enumtype => field.native := (ft_enumtype, data.v18);
when ft_settype => field.native := (ft_settype, data.v19);
when ft_bits => field.native := (ft_bits, data.v20);
when ft_utf8 => field.native := (ft_utf8, data.v21);
when ft_geometry => field.native := (ft_geometry, data.v22);
end case;
field.explicit_null := exnull;
end set;
end AdaBase.Results.Field;
|
tum-ei-rcs/StratoX | Ada | 2,966 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . R E A L _ T I M E . D E L A Y S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- Implements Real_Time.Time absolute delays
-- Note: the compiler generates direct calls to this interface, in the
-- processing of time types.
package Ada.Real_Time.Delays
with SPARK_Mode => On is
function To_Duration (T : Real_Time.Time) return Duration;
-- Convert Time to Duration
procedure Delay_Until (T : Time);
-- Delay until Clock has reached (at least) time T,
-- or the task is aborted to at least the current ATC nesting level.
-- The body of this procedure must perform all the processing
-- required for an abort point.
end Ada.Real_Time.Delays;
|
sungyeon/drake | Ada | 35,790 | adb | with Ada.Containers.Array_Sorting;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Address_To_Named_Access_Conversions;
with System.Growth;
with System.Long_Long_Integer_Types;
package body Ada.Containers.Indefinite_Vectors is
pragma Check_Policy (Validate => Ignore);
use type Copy_On_Write.Data_Access;
use type System.Address;
use type System.Long_Long_Integer_Types.Word_Integer;
subtype Word_Integer is System.Long_Long_Integer_Types.Word_Integer;
package DA_Conv is
new System.Address_To_Named_Access_Conversions (Data, Data_Access);
function Upcast is
new Unchecked_Conversion (Data_Access, Copy_On_Write.Data_Access);
function Downcast is
new Unchecked_Conversion (Copy_On_Write.Data_Access, Data_Access);
procedure Free is new Unchecked_Deallocation (Element_Type, Element_Access);
procedure Free is new Unchecked_Deallocation (Data, Data_Access);
-- diff (Assign_Element)
--
--
--
--
--
--
--
--
procedure Swap_Element (I, J : Word_Integer; Params : System.Address);
procedure Swap_Element (I, J : Word_Integer; Params : System.Address) is
Data : constant Data_Access := DA_Conv.To_Pointer (Params);
Temp : constant Element_Access := Data.Items (Index_Type'Val (I));
begin
Data.Items (Index_Type'Val (I)) := Data.Items (Index_Type'Val (J));
-- diff
-- diff
Data.Items (Index_Type'Val (J)) := Temp;
end Swap_Element;
function Equivalent_Element (Left : Element_Access; Right : Element_Type)
return Boolean;
function Equivalent_Element (Left : Element_Access; Right : Element_Type)
return Boolean is
begin
return Left /= null and then Left.all = Right;
end Equivalent_Element;
procedure Allocate_Element (
Item : out Element_Access;
New_Item : Element_Type);
procedure Allocate_Element (
Item : out Element_Access;
New_Item : Element_Type) is
begin
Item := new Element_Type'(New_Item);
end Allocate_Element;
procedure Free_Data (Data : in out Copy_On_Write.Data_Access);
procedure Free_Data (Data : in out Copy_On_Write.Data_Access) is
X : Data_Access := Downcast (Data);
begin
for I in X.Items'Range loop
Free (X.Items (I));
end loop;
Free (X);
Data := null;
end Free_Data;
procedure Allocate_Data (
Target : out not null Copy_On_Write.Data_Access;
New_Length : Count_Type;
Capacity : Count_Type);
procedure Allocate_Data (
Target : out not null Copy_On_Write.Data_Access;
New_Length : Count_Type;
Capacity : Count_Type)
is
New_Data : constant Data_Access :=
new Data'(
Capacity_Last => Index_Type'First - 1 + Index_Type'Base (Capacity),
Super => <>,
Max_Length => New_Length,
Items => <>);
begin
Target := Upcast (New_Data);
end Allocate_Data;
procedure Move_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type);
procedure Move_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type) is
begin
Allocate_Data (Target, New_Length, Capacity);
declare
subtype R is
Extended_Index range
Index_Type'First ..
Index_Type'First - 1 + Index_Type'Base (Length);
begin
for I in R loop
Downcast (Target).Items (I) := Downcast (Source).Items (I);
Downcast (Source).Items (I) := null;
end loop;
end;
end Move_Data;
procedure Copy_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type);
procedure Copy_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type) is
begin
Allocate_Data (Target, New_Length, Capacity);
declare
subtype R is
Extended_Index range
Index_Type'First ..
Index_Type'First - 1 + Index_Type'Base (Length);
begin
for I in R loop
if Downcast (Source).Items (I) /= null then
Allocate_Element (
Downcast (Target).Items (I),
Downcast (Source).Items (I).all);
end if;
end loop;
end;
end Copy_Data;
function Max_Length (Data : not null Copy_On_Write.Data_Access)
return not null access Count_Type;
function Max_Length (Data : not null Copy_On_Write.Data_Access)
return not null access Count_Type is
begin
return Downcast (Data).Max_Length'Access;
end Max_Length;
procedure Reallocate (
Container : in out Vector;
Length : Count_Type;
Capacity : Count_Type;
To_Update : Boolean);
procedure Reallocate (
Container : in out Vector;
Length : Count_Type;
Capacity : Count_Type;
To_Update : Boolean) is
begin
Copy_On_Write.Unique (
Target => Container.Super'Access,
Target_Length => Container.Length,
Target_Capacity => Indefinite_Vectors.Capacity (Container),
New_Length => Length,
New_Capacity => Capacity,
To_Update => To_Update,
Allocate => Allocate_Data'Access,
Move => Move_Data'Access,
Copy => Copy_Data'Access,
Free => Free_Data'Access,
Max_Length => Max_Length'Access);
end Reallocate;
procedure Unique (Container : in out Vector; To_Update : Boolean);
procedure Unique (Container : in out Vector; To_Update : Boolean) is
begin
if Copy_On_Write.Shared (Container.Super.Data) then
Reallocate (
Container,
Container.Length,
Capacity (Container), -- not shrinking
To_Update);
end if;
end Unique;
-- implementation
function Empty_Vector return Vector is
begin
return (Finalization.Controlled with Super => <>, Length => 0);
end Empty_Vector;
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= No_Element;
end Has_Element;
overriding function "=" (Left, Right : Vector) return Boolean is
begin
if Left.Length /= Right.Length then
return False;
elsif Left.Length = 0 or else Left.Super.Data = Right.Super.Data then
return True;
else
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
for I in Index_Type'First .. Last (Left) loop
if Downcast (Left.Super.Data).Items (I) = null then
if Downcast (Right.Super.Data).Items (I) /= null then
return False;
end if;
elsif not Equivalent_Element (
Downcast (Right.Super.Data).Items (I),
Downcast (Left.Super.Data).Items (I).all)
then
return False;
end if;
end loop;
return True;
end if;
end "=";
function To_Vector (Length : Count_Type) return Vector is
begin
return Result : Vector do
Insert_Space (Result, Index_Type'First, Length);
end return;
end To_Vector;
function To_Vector (New_Item : Element_Type; Length : Count_Type)
return Vector is
begin
return Result : Vector do
Append (Result, New_Item, Length);
end return;
end To_Vector;
-- diff (Generic_Array_To_Vector)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
function "&" (Left, Right : Vector) return Vector is
begin
return Result : Vector := Left do
Append (Result, Right);
end return;
end "&";
function "&" (Left : Vector; Right : Element_Type) return Vector is
begin
return Result : Vector := Left do
Append (Result, Right);
end return;
end "&";
function "&" (Left : Element_Type; Right : Vector) return Vector is
begin
return Result : Vector do
Reallocate (Result, 0, 1 + Right.Length, True);
Append (Result, Left);
Append (Result, Right);
end return;
end "&";
function "&" (Left, Right : Element_Type) return Vector is
begin
return Result : Vector do
Reallocate (Result, 0, 2, True);
Append (Result, Left);
Append (Result, Right);
end return;
end "&";
function Capacity (Container : Vector) return Count_Type is
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
if Data = null then
return 0;
else
return Count_Type'Base (Data.Capacity_Last - Index_Type'First + 1);
end if;
end Capacity;
procedure Reserve_Capacity (
Container : in out Vector;
Capacity : Count_Type)
is
New_Capacity : constant Count_Type :=
Count_Type'Max (Capacity, Container.Length);
begin
Reallocate (Container, Container.Length, New_Capacity, True);
end Reserve_Capacity;
function Length (Container : Vector) return Count_Type is
begin
return Container.Length;
end Length;
procedure Set_Length (Container : in out Vector; Length : Count_Type) is
Old_Capacity : constant Count_Type := Capacity (Container);
Failure : Boolean;
begin
Copy_On_Write.In_Place_Set_Length (
Target => Container.Super'Access,
Target_Length => Container.Length,
Target_Capacity => Old_Capacity,
New_Length => Length,
Failure => Failure,
Max_Length => Max_Length'Access);
if Failure then
declare
function Grow is
new System.Growth.Good_Grow (
Count_Type,
Component_Size => Element_Array'Component_Size);
New_Capacity : Count_Type;
begin
if Old_Capacity >= Length then
New_Capacity := Old_Capacity; -- not shrinking
else
New_Capacity := Count_Type'Max (Grow (Old_Capacity), Length);
end if;
Reallocate (Container, Length, New_Capacity, False);
end;
end if;
Container.Length := Length;
end Set_Length;
function Is_Empty (Container : Vector) return Boolean is
begin
return Container.Length = 0;
end Is_Empty;
procedure Clear (Container : in out Vector) is
begin
Copy_On_Write.Clear (Container.Super'Access, Free => Free_Data'Access);
Container.Length := 0;
end Clear;
function To_Cursor (
Container : Vector'Class;
Index : Extended_Index)
return Cursor
is
pragma Check (Pre,
Check =>
Index <= Last_Index (Container) + 1
or else raise Constraint_Error);
begin
if Index = Index_Type'First + Index_Type'Base (Container.Length) then
return No_Element; -- Last_Index (Container) + 1
else
return Index;
end if;
end To_Cursor;
function Element (
Container : Vector'Class;
Index : Index_Type)
return Element_Type is
begin
return Constant_Reference (
Vector (Container),
Index) -- checking Constraint_Error
.Element.all;
end Element;
procedure Replace_Element (
Container : in out Vector;
Position : Cursor;
New_Item : Element_Type)
is
pragma Check (Pre,
Check =>
Position in Index_Type'First .. Last (Container)
or else raise Constraint_Error);
begin
Unique (Container, True);
declare
E : Element_Access
renames Downcast (Container.Super.Data).Items (Position);
begin
Free (E);
Allocate_Element (E, New_Item);
end;
end Replace_Element;
procedure Query_Element (
Container : Vector'Class;
Index : Index_Type;
Process : not null access procedure (Element : Element_Type)) is
begin
Process (
Constant_Reference (
Vector (Container),
Index) -- checking Constraint_Error
.Element.all);
end Query_Element;
procedure Update_Element (
Container : in out Vector'Class;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type)) is
begin
Process (
Reference (Vector (Container), Position) -- checking Constraint_Error
.Element.all);
end Update_Element;
function Constant_Reference (Container : aliased Vector; Position : Cursor)
return Constant_Reference_Type
is
pragma Check (Pre,
Check =>
Position in Index_Type'First .. Last (Container)
or else raise Constraint_Error);
begin
Unique (Container'Unrestricted_Access.all, False);
declare
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
return (Element => Data.Items (Position).all'Access);
end;
end Constant_Reference;
function Reference (Container : aliased in out Vector; Position : Cursor)
return Reference_Type
is
pragma Check (Pre,
Check =>
Position in Index_Type'First .. Last (Container)
or else raise Constraint_Error);
begin
Unique (Container, True);
declare
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
return (Element => Data.Items (Position).all'Access);
end;
end Reference;
procedure Assign (Target : in out Vector; Source : Vector) is
begin
Copy_On_Write.Assign (
Target.Super'Access,
Source.Super'Access,
Free => Free_Data'Access);
Target.Length := Source.Length;
end Assign;
function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector is
begin
return Result : Vector := Source do
Reserve_Capacity (Result, Capacity);
end return;
end Copy;
procedure Move (Target : in out Vector; Source : in out Vector) is
begin
Copy_On_Write.Move (
Target.Super'Access,
Source.Super'Access,
Free => Free_Data'Access);
Target.Length := Source.Length;
Source.Length := 0;
end Move;
procedure Insert (
Container : in out Vector;
Before : Cursor;
New_Item : Vector)
is
Position : Cursor;
begin
Insert (
Container,
Before, -- checking Constraint_Error
New_Item, -- checking Program_Error if same nonempty container
Position);
end Insert;
procedure Insert (
Container : in out Vector;
Before : Cursor;
New_Item : Vector;
Position : out Cursor)
is
pragma Check (Pre,
Check =>
Before <= Last (Container) + 1 or else raise Constraint_Error);
pragma Check (Pre,
Check =>
Container'Address /= New_Item'Address
or else Is_Empty (Container)
or else raise Program_Error);
-- same nonempty container (should this case be supported?)
New_Item_Length : constant Count_Type := New_Item.Length;
begin
if Container.Length = 0
and then Capacity (Container) < New_Item_Length -- New_Item_Length > 0
then
Position := Index_Type'First;
Assign (Container, New_Item);
else
Insert_Space (Container, Before, Position, New_Item_Length);
if New_Item_Length > 0 then
Unique (New_Item'Unrestricted_Access.all, False); -- private
declare
D : constant Index_Type'Base := Position - Index_Type'First;
begin
for I in
Position .. Position + Index_Type'Base (New_Item_Length) - 1
loop
declare
E : Element_Access
renames Downcast (Container.Super.Data).Items (I);
S : Element_Access
renames Downcast (New_Item.Super.Data).Items (I - D);
begin
pragma Check (Validate, E = null);
Allocate_Element (E, S.all);
end;
end loop;
end;
end if;
end if;
end Insert;
procedure Insert (
Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1)
is
Position : Cursor;
begin
Insert (
Container,
Before, -- checking Constraint_Error
New_Item,
Position,
Count);
end Insert;
procedure Insert (
Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Position : out Cursor;
Count : Count_Type := 1) is
begin
Insert_Space (
Container,
Before, -- checking Constraint_Error
Position,
Count);
for I in Position .. Position + Index_Type'Base (Count) - 1 loop
declare
E : Element_Access
renames Downcast (Container.Super.Data).Items (I);
begin
pragma Check (Validate, E = null);
Allocate_Element (E, New_Item);
end;
end loop;
end Insert;
procedure Prepend (Container : in out Vector; New_Item : Vector) is
begin
Insert (
Container,
Index_Type'First,
New_Item); -- checking Program_Error if same nonempty container
end Prepend;
procedure Prepend (
Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type := 1) is
begin
Insert (Container, Index_Type'First, New_Item, Count);
end Prepend;
procedure Append (Container : in out Vector; New_Item : Vector) is
New_Item_Length : constant Count_Type := New_Item.Length;
Old_Length : constant Count_Type := Container.Length;
begin
if Old_Length = 0 and then Capacity (Container) < New_Item_Length then
Assign (Container, New_Item);
elsif New_Item_Length > 0 then
Set_Length (Container, Old_Length + New_Item_Length);
Unique (New_Item'Unrestricted_Access.all, False); -- private
declare
D : constant Index_Type'Base := Index_Type'Base (Old_Length);
begin
for I in Index_Type'First + D .. Last (Container) loop
declare
E : Element_Access
renames Downcast (Container.Super.Data).Items (I);
S : Element_Access
renames Downcast (New_Item.Super.Data).Items (I - D);
begin
pragma Check (Validate, E = null);
if S /= null then
Allocate_Element (E, S.all);
end if;
end;
end loop;
end;
end if;
end Append;
procedure Append (
Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type := 1)
is
Old_Length : constant Count_Type := Container.Length;
begin
Set_Length (Container, Old_Length + Count);
for I in
Index_Type'First + Index_Type'Base (Old_Length) ..
Last (Container)
loop
declare
E : Element_Access
renames Downcast (Container.Super.Data).Items (I);
begin
pragma Check (Validate, E = null);
Allocate_Element (E, New_Item);
end;
end loop;
end Append;
procedure Insert_Space (
Container : in out Vector'Class;
Before : Extended_Index;
Count : Count_Type := 1)
is
Position : Cursor;
begin
Insert_Space (
Vector (Container),
Before, -- checking Constraint_Error
Position,
Count);
end Insert_Space;
procedure Insert_Space (
Container : in out Vector;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1)
is
pragma Check (Pre,
Check =>
Before <= Last (Container) + 1 or else raise Constraint_Error);
Old_Length : constant Count_Type := Container.Length;
After_Last : constant Index_Type'Base :=
Index_Type'First + Index_Type'Base (Old_Length);
begin
Position := Before;
if Position = No_Element then
Position := After_Last;
end if;
if Count > 0 then
Set_Length (Container, Old_Length + Count);
if Position < After_Last then -- Last_Index (Container) + 1
Unique (Container, True);
declare
Data : constant Data_Access := Downcast (Container.Super.Data);
subtype R1 is
Extended_Index range
Position + Index_Type'Base (Count) ..
After_Last - 1 + Index_Type'Base (Count);
subtype R2 is Extended_Index range Position .. After_Last - 1;
begin
for I in R2'Last + 1 .. R1'Last loop
Free (Data.Items (I));
end loop;
Data.Items (R1) := Data.Items (R2);
for I in R2'First .. R1'First - 1 loop
Data.Items (I) := null;
end loop;
end;
end if;
end if;
end Insert_Space;
procedure Delete (
Container : in out Vector;
Position : in out Cursor;
Count : Count_Type := 1)
is
pragma Check (Pre,
Check =>
Position in
Index_Type'First ..
Last (Container) - Index_Type'Base (Count) + 1
or else raise Constraint_Error);
begin
if Count > 0 then
declare
Old_Length : constant Count_Type := Container.Length;
After_Last : constant Index_Type'Base :=
Index_Type'First + Index_Type'Base (Old_Length);
begin
if Position + Index_Type'Base (Count) < After_Last then
Unique (Container, True);
declare
Data : constant Data_Access :=
Downcast (Container.Super.Data);
subtype R1 is
Extended_Index range
Position .. After_Last - 1 - Index_Type'Base (Count);
subtype R2 is
Extended_Index range
Position + Index_Type'Base (Count) .. After_Last - 1;
begin
for I in R1'First .. R2'First - 1 loop
Free (Data.Items (I));
end loop;
Data.Items (R1) := Data.Items (R2);
for I in R1'Last + 1 .. R2'Last loop
Data.Items (I) := null;
end loop;
end;
end if;
Set_Length (Container, Old_Length - Count);
Position := No_Element;
end;
end if;
end Delete;
procedure Delete_First (
Container : in out Vector'Class;
Count : Count_Type := 1)
is
Position : Cursor := Index_Type'First;
begin
Delete (Vector (Container), Position, Count => Count);
end Delete_First;
procedure Delete_Last (
Container : in out Vector'Class;
Count : Count_Type := 1) is
begin
Set_Length (Vector (Container), Container.Length - Count);
end Delete_Last;
procedure Reverse_Elements (Container : in out Vector) is
begin
if Container.Length > 1 then
Unique (Container, True);
Array_Sorting.In_Place_Reverse (
Index_Type'Pos (Index_Type'First),
Index_Type'Pos (Last (Container)),
DA_Conv.To_Address (Downcast (Container.Super.Data)),
Swap => Swap_Element'Access);
end if;
end Reverse_Elements;
procedure Swap (Container : in out Vector; I, J : Cursor) is
pragma Check (Pre,
Check =>
(I in Index_Type'First .. Last (Container)
and then J in Index_Type'First .. Last (Container))
or else raise Constraint_Error);
begin
Unique (Container, True);
Swap_Element (
Index_Type'Pos (I),
Index_Type'Pos (J),
DA_Conv.To_Address (Downcast (Container.Super.Data)));
end Swap;
function First_Index (Container : Vector'Class)
return Index_Type
is
pragma Unreferenced (Container);
begin
return Index_Type'First;
end First_Index;
function First (Container : Vector) return Cursor is
begin
if Container.Length = 0 then
return No_Element;
else
return Index_Type'First;
end if;
end First;
function First_Element (Container : Vector'Class)
return Element_Type is
begin
return Element (Container, Index_Type'First);
end First_Element;
function Last_Index (Container : Vector'Class)
return Extended_Index is
begin
return Last (Vector (Container));
end Last_Index;
function Last (Container : Vector) return Cursor is
begin
return Index_Type'First - 1 + Index_Type'Base (Container.Length);
end Last;
function Last_Element (Container : Vector'Class)
return Element_Type is
begin
return Element (Container, Last_Index (Container));
end Last_Element;
function Find_Index (
Container : Vector'Class;
Item : Element_Type;
Index : Index_Type := Index_Type'First)
return Extended_Index is
begin
if Index = Index_Type'First and then Container.Length = 0 then
return No_Index;
else
return Find (
Vector (Container),
Item,
Index); -- checking Constraint_Error
end if;
end Find_Index;
function Find (
Container : Vector;
Item : Element_Type)
return Cursor is
begin
return Find (Container, Item, First (Container));
end Find;
function Find (
Container : Vector;
Item : Element_Type;
Position : Cursor)
return Cursor
is
pragma Check (Pre,
Check =>
Position in Index_Type'First .. Last (Container)
or else (Is_Empty (Container) and then Position = No_Element)
or else raise Constraint_Error);
Last : constant Cursor := Indefinite_Vectors.Last (Container);
begin
if Position in Index_Type'First .. Last then
Unique (Container'Unrestricted_Access.all, False); -- private
for I in Position .. Last loop
if Equivalent_Element (
Downcast (Container.Super.Data).Items (I),
Item)
then
return I;
end if;
end loop;
end if;
return No_Element;
end Find;
function Reverse_Find_Index (
Container : Vector'Class;
Item : Element_Type;
Index : Index_Type := Index_Type'Last)
return Extended_Index
is
Start : constant Extended_Index :=
Extended_Index'Min (Index, Last_Index (Container));
begin
return Reverse_Find (
Vector (Container),
Item,
Start); -- checking Constraint_Error
end Reverse_Find_Index;
function Reverse_Find (
Container : Vector;
Item : Element_Type)
return Cursor is
begin
return Reverse_Find (Container, Item, Last (Container));
end Reverse_Find;
function Reverse_Find (
Container : Vector;
Item : Element_Type;
Position : Cursor)
return Cursor
is
pragma Check (Pre,
Check =>
(Position in Index_Type'First .. Last (Container))
or else (Is_Empty (Container) and then Position = No_Element)
or else raise Constraint_Error);
begin
if Position >= Index_Type'First then
Unique (Container'Unrestricted_Access.all, False); -- private
for I in reverse Index_Type'First .. Position loop
if Equivalent_Element (
Downcast (Container.Super.Data).Items (I),
Item)
then
return I;
end if;
end loop;
end if;
return No_Element;
end Reverse_Find;
function Contains (Container : Vector; Item : Element_Type)
return Boolean is
begin
return Find (Container, Item) /= No_Element;
end Contains;
procedure Iterate (
Container : Vector'Class;
Process : not null access procedure (Position : Cursor)) is
begin
for I in Index_Type'First .. Last (Vector (Container)) loop
Process (I);
end loop;
end Iterate;
procedure Reverse_Iterate (
Container : Vector'Class;
Process : not null access procedure (Position : Cursor)) is
begin
for I in reverse Index_Type'First .. Last (Vector (Container)) loop
Process (I);
end loop;
end Reverse_Iterate;
function Iterate (Container : Vector'Class)
return Vector_Iterator_Interfaces.Reversible_Iterator'Class is
begin
return Vector_Iterator'(
First => First (Vector (Container)),
Last => Last (Vector (Container)));
end Iterate;
function Iterate (Container : Vector'Class; First, Last : Cursor)
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
is
pragma Check (Pre,
Check =>
(First <= Indefinite_Vectors.Last (Vector (Container)) + 1
and then Last <= Indefinite_Vectors.Last (Vector (Container)))
or else raise Constraint_Error);
Actual_First : Cursor := First;
Actual_Last : Cursor := Last;
begin
if Actual_First = No_Element
or else Actual_Last < Actual_First -- implies Last = No_Element
then
Actual_First := No_Element;
Actual_Last := No_Element;
end if;
return Vector_Iterator'(First => Actual_First, Last => Actual_Last);
end Iterate;
-- diff (Constant_Reference)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-- diff (Reference)
--
--
--
--
--
--
--
--
--
--
--
--
--
--
overriding procedure Adjust (Object : in out Vector) is
begin
Copy_On_Write.Adjust (Object.Super'Access);
end Adjust;
overriding function First (Object : Vector_Iterator) return Cursor is
begin
return Object.First;
end First;
overriding function Next (Object : Vector_Iterator; Position : Cursor)
return Cursor is
begin
if Position >= Object.Last then
return No_Element;
else
return Position + 1;
end if;
end Next;
overriding function Last (Object : Vector_Iterator) return Cursor is
begin
return Object.Last;
end Last;
overriding function Previous (Object : Vector_Iterator; Position : Cursor)
return Cursor is
begin
if Position <= Object.First then
return No_Element;
else
return Position - 1;
end if;
end Previous;
-- diff (Constant_Indexing)
--
--
--
--
--
--
-- diff (Indexing)
--
--
--
--
--
--
package body Generic_Sorting is
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean;
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean
is
Data : constant Data_Access := DA_Conv.To_Pointer (Params);
begin
return Data.Items (Index_Type'Val (Left)).all <
Data.Items (Index_Type'Val (Right)).all;
end LT;
function Is_Sorted (Container : Vector) return Boolean is
begin
if Container.Length <= 1 then
return True;
else
Unique (Container'Unrestricted_Access.all, False); -- private
return Array_Sorting.Is_Sorted (
Index_Type'Pos (Index_Type'First),
Index_Type'Pos (Last (Container)),
DA_Conv.To_Address (Downcast (Container.Super.Data)),
LT => LT'Access);
end if;
end Is_Sorted;
procedure Sort (Container : in out Vector) is
begin
if Container.Length > 1 then
Unique (Container, True);
Array_Sorting.In_Place_Merge_Sort (
Index_Type'Pos (Index_Type'First),
Index_Type'Pos (Last (Container)),
DA_Conv.To_Address (Downcast (Container.Super.Data)),
LT => LT'Access,
Swap => Swap_Element'Access);
end if;
end Sort;
procedure Merge (Target : in out Vector; Source : in out Vector) is
pragma Check (Pre,
Check =>
Target'Address /= Source'Address
or else Is_Empty (Target)
or else raise Program_Error);
-- RM A.18.2(237/3), same nonempty container
begin
if Source.Length > 0 then
declare
Old_Length : constant Count_Type := Target.Length;
begin
if Old_Length = 0 then
Move (Target, Source);
else
Set_Length (Target, Old_Length + Source.Length);
Unique (Target, True);
Unique (Source, True); -- splicing
for I in Index_Type'First .. Last (Source) loop
Downcast (Target.Super.Data).Items (
I + Index_Type'Base (Old_Length)) :=
Downcast (Source.Super.Data).Items (I);
Downcast (Source.Super.Data).Items (I) := null;
end loop;
Set_Length (Source, 0);
Array_Sorting.In_Place_Merge (
Index_Type'Pos (Index_Type'First),
Word_Integer (Index_Type'First)
+ Word_Integer (Old_Length),
Index_Type'Pos (Last (Target)),
DA_Conv.To_Address (Downcast (Target.Super.Data)),
LT => LT'Access,
Swap => Swap_Element'Access);
end if;
end;
end if;
end Merge;
end Generic_Sorting;
package body Streaming is
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Vector)
is
Length : Count_Type'Base;
begin
Count_Type'Base'Read (Stream, Length);
Clear (Item);
if Length > 0 then
Set_Length (Item, Length);
for I in Index_Type'First .. Last (Item) loop
declare
E : Element_Access
renames Downcast (Item.Super.Data).Items (I);
begin
pragma Check (Validate, E = null);
Allocate_Element (E, Element_Type'Input (Stream));
end;
end loop;
end if;
end Read;
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Vector)
is
Length : constant Count_Type := Indefinite_Vectors.Length (Item);
begin
Count_Type'Write (Stream, Length);
if Length > 0 then
Unique (Item'Unrestricted_Access.all, False); -- private
for I in Index_Type'First .. Last (Item) loop
Element_Type'Output (
Stream,
Downcast (Item.Super.Data).Items (I).all);
end loop;
end if;
end Write;
end Streaming;
end Ada.Containers.Indefinite_Vectors;
|
ficorax/PortAudioAda | Ada | 789 | ads | with Ada.Numerics;
with PortAudioAda; use PortAudioAda;
package Ctestc_Types is
Pi : constant := Ada.Numerics.Pi;
Two_Pi : constant := Pi * 2.0;
Default_Buffer_Size : constant := 32;
type Float_Array
is array (Natural range <>) of aliased Float;
pragma Convention (C, Float_Array);
type paTestData is
record
left_phase : aliased Float;
right_phase : aliased Float;
end record;
pragma Convention (C, paTestData);
type paTestData_Ptr is access all paTestData;
pragma Convention (C, paTestData_Ptr);
pragma No_Strict_Aliasing (paTestData_Ptr);
outputParameters : aliased PA_Stream_Parameters;
data : aliased paTestData;
pragma Convention (C, data);
end Ctestc_Types;
|
persan/A-gst | Ada | 16,968 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with glib;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_garray_h;
with Interfaces.C.Strings;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h;
with System;
-- with GStreamer.GST_Low_Level.libxml2_libxml_tree_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h is
-- unsupported macro: GST_TYPE_CAPS (gst_caps_get_type())
-- arg-macro: function GST_CAPS (object)
-- return (GstCaps*)object;
-- arg-macro: function GST_IS_CAPS (object)
-- return (object) and then (GST_CAPS(object).type = GST_TYPE_CAPS);
-- unsupported macro: GST_TYPE_STATIC_CAPS (gst_static_caps_get_type())
-- unsupported macro: GST_CAPS_ANY gst_caps_new_any()
-- unsupported macro: GST_CAPS_NONE gst_caps_new_empty()
-- unsupported macro: GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY")
-- unsupported macro: GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE")
-- arg-macro: function GST_CAPS_IS_SIMPLE (caps)
-- return gst_caps_get_size(caps) = 1;
-- arg-macro: procedure GST_DEBUG_CAPS (string, caps)
-- GST_DEBUG ( string "%s: " GST_PTR_FORMAT, caps)
-- arg-macro: procedure GST_STATIC_CAPS (string)
-- { { 0, 0, (GstCapsFlags) 0, NULL, GST_PADDING_INIT }, string, GST_PADDING_INIT }
-- arg-macro: function GST_CAPS_REFCOUNT (caps)
-- return (GST_CAPS(caps)).refcount;
-- arg-macro: function GST_CAPS_REFCOUNT_VALUE (caps)
-- return g_atomic_int_get (and(GST_CAPS(caps)).refcount);
-- GStreamer
-- * Copyright (C) 2003 David A. Schleef <[email protected]>
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
--*
-- * GstCapsFlags:
-- * @GST_CAPS_FLAGS_NONE: no extra flags (Since 0.10.36)
-- * @GST_CAPS_FLAGS_ANY: Caps has no specific content, but can contain
-- * anything.
-- *
-- * Extra flags for a caps.
--
type GstCapsFlags is
(GST_CAPS_FLAGS_NONE,
GST_CAPS_FLAGS_ANY);
pragma Convention (C, GstCapsFlags); -- gst/gstcaps.h:46
--*
-- * GstCapsIntersectMode:
-- * @GST_CAPS_INTERSECT_ZIG_ZAG : Zig-zags over both caps.
-- * @GST_CAPS_INTERSECT_FIRST : Keeps the first caps order.
-- *
-- * Modes of caps intersection
-- *
-- * @GST_CAPS_INTERSECT_ZIG_ZAG tries to preserve overall order of both caps
-- * by iterating on the caps' structures as the following matrix shows:
-- * |[
-- * caps1
-- * +-------------
-- * | 1 2 4 7
-- * caps2 | 3 5 8 10
-- * | 6 9 11 12
-- * ]|
-- * Used when there is no explicit precedence of one caps over the other. e.g.
-- * tee's sink pad getcaps function, it will probe its src pad peers' for their
-- * caps and intersect them with this mode.
-- *
-- * @GST_CAPS_INTERSECT_FIRST is useful when an element wants to preserve
-- * another element's caps priority order when intersecting with its own caps.
-- * Example: If caps1 is [A, B, C] and caps2 is [E, B, D, A], the result
-- * would be [A, B], maintaining the first caps priority on the intersection.
-- *
-- * Since: 0.10.33
--
type GstCapsIntersectMode is
(GST_CAPS_INTERSECT_ZIG_ZAG,
GST_CAPS_INTERSECT_FIRST);
pragma Convention (C, GstCapsIntersectMode); -- gst/gstcaps.h:78
--*
-- * GST_CAPS_ANY:
-- *
-- * Means that the element/pad can output 'anything'. Useful for elements
-- * that output unknown media, such as filesrc.
--
--*
-- * GST_CAPS_NONE:
-- *
-- * The opposite of %GST_CAPS_ANY: it means that the pad/element outputs an
-- * undefined media type that can not be detected.
--
--*
-- * GST_STATIC_CAPS_ANY:
-- *
-- * Creates a new #GstCaps static caps that matches anything.
-- * This can be used in pad templates.
--
--*
-- * GST_STATIC_CAPS_NONE:
-- *
-- * Creates a new #GstCaps static caps that matches nothing.
-- * This can be used in pad templates.
--
--*
-- * GST_CAPS_IS_SIMPLE:
-- * @caps: the #GstCaps instance to check
-- *
-- * Convenience macro that checks if the number of structures in the given caps
-- * is exactly one.
--
--*
-- * GST_DEBUG_CAPS:
-- * @string: a string that should be prepended to the caps data.
-- * @caps: the #GstCaps instance to print
-- *
-- * Convenience macro for printing out the contents of caps with GST_DEBUG().
-- *
-- * Deprecated: do not use anymore
--
--*
-- * GST_STATIC_CAPS:
-- * @string: the string describing the caps
-- *
-- * Creates a new #GstCaps static caps from an input string.
-- * This can be used in pad templates.
--
type GstCaps;
type u_GstCaps_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstCaps is u_GstCaps; -- gst/gstcaps.h:148
type GstStaticCaps;
type u_GstStaticCaps_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstStaticCaps is u_GstStaticCaps; -- gst/gstcaps.h:149
-- refcount
--*
-- * GST_CAPS_REFCOUNT:
-- * @caps: a #GstCaps
-- *
-- * Get access to the reference count field of the caps
--
--*
-- * GST_CAPS_REFCOUNT_VALUE:
-- * @caps: a #GstCaps
-- *
-- * Get the reference count value of the caps.
--
--*
-- * GstCaps:
-- * @type: GType of the caps
-- * @refcount: the atomic refcount value
-- * @flags: extra flags for the caps, read only.
-- *
-- * Object describing media types.
--
type GstCaps is record
c_type : aliased GLIB.GType; -- gst/gstcaps.h:176
refcount : aliased GLIB.gint; -- gst/gstcaps.h:180
flags : aliased GstCapsFlags; -- gst/gstcaps.h:183
structs : access GStreamer.GST_Low_Level.glib_2_0_glib_garray_h.GPtrArray; -- gst/gstcaps.h:186
u_gst_reserved : u_GstCaps_u_gst_reserved_array; -- gst/gstcaps.h:189
end record;
pragma Convention (C_Pass_By_Copy, GstCaps); -- gst/gstcaps.h:175
--< public >
-- with COW
-- refcounting
--< public >
-- read only
--< private >
--< private >
--*
-- * GstStaticCaps:
-- * @caps: the cached #GstCaps
-- * @string: a string describing a caps
-- *
-- * Datastructure to initialize #GstCaps from a string description usually
-- * used in conjunction with GST_STATIC_CAPS() and gst_static_caps_get() to
-- * instantiate a #GstCaps.
--
--< public >
type GstStaticCaps is record
caps : aliased GstCaps; -- gst/gstcaps.h:203
string : Interfaces.C.Strings.chars_ptr; -- gst/gstcaps.h:204
u_gst_reserved : u_GstStaticCaps_u_gst_reserved_array; -- gst/gstcaps.h:207
end record;
pragma Convention (C_Pass_By_Copy, GstStaticCaps); -- gst/gstcaps.h:201
--< private >
function gst_caps_get_type return GLIB.GType; -- gst/gstcaps.h:210
pragma Import (C, gst_caps_get_type, "gst_caps_get_type");
function gst_caps_new_empty return access GstCaps; -- gst/gstcaps.h:211
pragma Import (C, gst_caps_new_empty, "gst_caps_new_empty");
function gst_caps_new_any return access GstCaps; -- gst/gstcaps.h:212
pragma Import (C, gst_caps_new_any, "gst_caps_new_any");
function gst_caps_new_simple (media_type : Interfaces.C.Strings.chars_ptr; fieldname : Interfaces.C.Strings.chars_ptr -- , ...
) return access GstCaps; -- gst/gstcaps.h:213
pragma Import (C, gst_caps_new_simple, "gst_caps_new_simple");
function gst_caps_new_full (struct1 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h.GstStructure -- , ...
) return access GstCaps; -- gst/gstcaps.h:216
pragma Import (C, gst_caps_new_full, "gst_caps_new_full");
function gst_caps_new_full_valist (structure : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h.GstStructure; var_args : access System.Address) return access GstCaps; -- gst/gstcaps.h:217
pragma Import (C, gst_caps_new_full_valist, "gst_caps_new_full_valist");
-- reference counting
function gst_caps_ref (caps : access GstCaps) return access GstCaps; -- gst/gstcaps.h:221
pragma Import (C, gst_caps_ref, "gst_caps_ref");
function gst_caps_copy (caps : access constant GstCaps) return access GstCaps; -- gst/gstcaps.h:222
pragma Import (C, gst_caps_copy, "gst_caps_copy");
function gst_caps_make_writable (caps : access GstCaps) return access GstCaps; -- gst/gstcaps.h:223
pragma Import (C, gst_caps_make_writable, "gst_caps_make_writable");
procedure gst_caps_unref (caps : access GstCaps); -- gst/gstcaps.h:224
pragma Import (C, gst_caps_unref, "gst_caps_unref");
function gst_static_caps_get_type return GLIB.GType; -- gst/gstcaps.h:226
pragma Import (C, gst_static_caps_get_type, "gst_static_caps_get_type");
function gst_static_caps_get (static_caps : access GstStaticCaps) return access GstCaps; -- gst/gstcaps.h:227
pragma Import (C, gst_static_caps_get, "gst_static_caps_get");
-- manipulation
procedure gst_caps_append (caps1 : access GstCaps; caps2 : access GstCaps); -- gst/gstcaps.h:230
pragma Import (C, gst_caps_append, "gst_caps_append");
procedure gst_caps_merge (caps1 : access GstCaps; caps2 : access GstCaps); -- gst/gstcaps.h:232
pragma Import (C, gst_caps_merge, "gst_caps_merge");
procedure gst_caps_append_structure (caps : access GstCaps; structure : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h.GstStructure); -- gst/gstcaps.h:234
pragma Import (C, gst_caps_append_structure, "gst_caps_append_structure");
procedure gst_caps_remove_structure (caps : access GstCaps; idx : GLIB.guint); -- gst/gstcaps.h:236
pragma Import (C, gst_caps_remove_structure, "gst_caps_remove_structure");
procedure gst_caps_merge_structure (caps : access GstCaps; structure : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h.GstStructure); -- gst/gstcaps.h:237
pragma Import (C, gst_caps_merge_structure, "gst_caps_merge_structure");
function gst_caps_get_size (caps : access constant GstCaps) return GLIB.guint; -- gst/gstcaps.h:239
pragma Import (C, gst_caps_get_size, "gst_caps_get_size");
function gst_caps_get_structure (caps : access constant GstCaps; index : GLIB.guint) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h.GstStructure; -- gst/gstcaps.h:240
pragma Import (C, gst_caps_get_structure, "gst_caps_get_structure");
function gst_caps_steal_structure (caps : access GstCaps; index : GLIB.guint) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h.GstStructure; -- gst/gstcaps.h:242
pragma Import (C, gst_caps_steal_structure, "gst_caps_steal_structure");
function gst_caps_copy_nth (caps : access constant GstCaps; nth : GLIB.guint) return access GstCaps; -- gst/gstcaps.h:244
pragma Import (C, gst_caps_copy_nth, "gst_caps_copy_nth");
procedure gst_caps_truncate (caps : access GstCaps); -- gst/gstcaps.h:245
pragma Import (C, gst_caps_truncate, "gst_caps_truncate");
procedure gst_caps_set_value
(caps : access GstCaps;
field : Interfaces.C.Strings.chars_ptr;
value : access constant Glib.Values.GValue); -- gst/gstcaps.h:246
pragma Import (C, gst_caps_set_value, "gst_caps_set_value");
procedure gst_caps_set_simple (caps : access GstCaps; field : Interfaces.C.Strings.chars_ptr -- , ...
); -- gst/gstcaps.h:249
pragma Import (C, gst_caps_set_simple, "gst_caps_set_simple");
procedure gst_caps_set_simple_valist
(caps : access GstCaps;
field : Interfaces.C.Strings.chars_ptr;
varargs : access System.Address); -- gst/gstcaps.h:251
pragma Import (C, gst_caps_set_simple_valist, "gst_caps_set_simple_valist");
-- tests
function gst_caps_is_any (caps : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:256
pragma Import (C, gst_caps_is_any, "gst_caps_is_any");
function gst_caps_is_empty (caps : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:257
pragma Import (C, gst_caps_is_empty, "gst_caps_is_empty");
function gst_caps_is_fixed (caps : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:258
pragma Import (C, gst_caps_is_fixed, "gst_caps_is_fixed");
function gst_caps_is_always_compatible (caps1 : access constant GstCaps; caps2 : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:259
pragma Import (C, gst_caps_is_always_compatible, "gst_caps_is_always_compatible");
function gst_caps_is_subset (subset : access constant GstCaps; superset : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:261
pragma Import (C, gst_caps_is_subset, "gst_caps_is_subset");
function gst_caps_is_subset_structure (caps : access constant GstCaps; structure : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gststructure_h.GstStructure) return GLIB.gboolean; -- gst/gstcaps.h:263
pragma Import (C, gst_caps_is_subset_structure, "gst_caps_is_subset_structure");
function gst_caps_is_equal (caps1 : access constant GstCaps; caps2 : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:265
pragma Import (C, gst_caps_is_equal, "gst_caps_is_equal");
function gst_caps_is_equal_fixed (caps1 : access constant GstCaps; caps2 : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:267
pragma Import (C, gst_caps_is_equal_fixed, "gst_caps_is_equal_fixed");
function gst_caps_can_intersect (caps1 : access constant GstCaps; caps2 : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:269
pragma Import (C, gst_caps_can_intersect, "gst_caps_can_intersect");
function gst_caps_is_strictly_equal (caps1 : access constant GstCaps; caps2 : access constant GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:271
pragma Import (C, gst_caps_is_strictly_equal, "gst_caps_is_strictly_equal");
-- operations
function gst_caps_intersect (caps1 : access constant GstCaps; caps2 : access constant GstCaps) return access GstCaps; -- gst/gstcaps.h:276
pragma Import (C, gst_caps_intersect, "gst_caps_intersect");
function gst_caps_intersect_full
(caps1 : access constant GstCaps;
caps2 : access constant GstCaps;
mode : GstCapsIntersectMode) return access GstCaps; -- gst/gstcaps.h:278
pragma Import (C, gst_caps_intersect_full, "gst_caps_intersect_full");
function gst_caps_subtract (minuend : access constant GstCaps; subtrahend : access constant GstCaps) return access GstCaps; -- gst/gstcaps.h:281
pragma Import (C, gst_caps_subtract, "gst_caps_subtract");
function gst_caps_union (caps1 : access constant GstCaps; caps2 : access constant GstCaps) return access GstCaps; -- gst/gstcaps.h:283
pragma Import (C, gst_caps_union, "gst_caps_union");
function gst_caps_normalize (caps : access constant GstCaps) return access GstCaps; -- gst/gstcaps.h:285
pragma Import (C, gst_caps_normalize, "gst_caps_normalize");
function gst_caps_do_simplify (caps : access GstCaps) return GLIB.gboolean; -- gst/gstcaps.h:286
pragma Import (C, gst_caps_do_simplify, "gst_caps_do_simplify");
function gst_caps_save_thyself (caps : access constant GstCaps; parent : GStreamer.GST_Low_Level.libxml2_libxml_tree_h.xmlNodePtr) return GStreamer.GST_Low_Level.libxml2_libxml_tree_h.xmlNodePtr; -- gst/gstcaps.h:289
pragma Import (C, gst_caps_save_thyself, "gst_caps_save_thyself");
function gst_caps_load_thyself (parent : GStreamer.GST_Low_Level.libxml2_libxml_tree_h.xmlNodePtr) return access GstCaps; -- gst/gstcaps.h:291
pragma Import (C, gst_caps_load_thyself, "gst_caps_load_thyself");
-- utility
procedure gst_caps_replace (caps : System.Address; newcaps : access GstCaps); -- gst/gstcaps.h:295
pragma Import (C, gst_caps_replace, "gst_caps_replace");
function gst_caps_to_string (caps : access constant GstCaps) return access GLIB.gchar; -- gst/gstcaps.h:297
pragma Import (C, gst_caps_to_string, "gst_caps_to_string");
function gst_caps_from_string (string : access GLIB.gchar) return access GstCaps; -- gst/gstcaps.h:298
pragma Import (C, gst_caps_from_string, "gst_caps_from_string");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
|
jscparker/math_packages | Ada | 22,337 | ads |
-------------------------------------------------------------------------------
-- package Disorderly.Random.Deviates, Floating point random deviates.
-- Copyright (C) 1995-2018 Jonathan S. Parker
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------------------
-- PACKAGE Disorderly.Random.Deviates
--
-- Generates floating point streams of Random deviates (variates) from
-- the following distributions:
--
-- Uniform, Normal (Gaussian), Exponential, Lorentzian (Cauchy),
-- Poissonian, Binomial, Negative Binomial, Weibull, Rayleigh,
-- Student_t, Beta, Gamma, Chi_Squared, Log_Normal, Multivariate_Normal
--
-- The more complicated deviates are accompanied by routines that
-- calculate their respective probability densities. The test routine,
-- (deviates_demo_1), verifies that the random variables are
-- drawn from these probability distributions, as advertized.
--
-- So deviates_demo_1.adb is a useful demonstration of the
-- random variable generators in this package, as well as the exact
-- distributions they are drawn from.
--
-- The package is pure.
--
-- Most routines would grind to a halt if they had to recalculate
-- certain quantities each call. So these quantities are calculated
-- on the first call, and then placed into a record that's passed
-- as in/out parameter to keep the package pure.
--
-- Uses 53 bits of the 61-bit generator Disorderly.Random.
--
-- For most of the routines, the time_per_call is not constant. Most
-- routines call the random number generator an unpredictable number
-- of times each time the routine is called.
--
-- Wikipedia gives extended descriptions of each distribution. The
-- probability density functions generated by the functions declared
-- below are taken directly from the Wikipedia articles on the same,
-- to ensure that the Wikipedia discussions are exactly relevant.
--
-- Uses the integer valued Disorderly.Random in the parent package to
-- create a floating point generator (Uniform).
-- Is generic in the floating point type (as long as its 15 digits!).
--
-- Like the other routines in this collection, Deviates is designed
-- to exploit the newer 64-bit CPU's. All of the routines use
-- 15 digit floats, which means 53 bit mantissas in practice.
-- Poisson should be thought of as single precision though.
--
-- References:
--
-- Chandrasekaran and Sheppard,
-- Journal of Pascal, Ada, and Modula2, Vol 5, Num 4, (1986).
--
-- Kemp, C.D. (1986). 'A modal method for generating binomial
-- variables', Commun. Statist. - Theor. Meth. 15(3), 805-813.
--
-- see also Fortran 77 code from the book:
-- Dagpunar, J. 'Principles of random variate generation'
-- Clarendon Press, Oxford, 1988. ISBN 0-19-852202-9
--
-- Many thanks are due to Allan Miller - most routines are based on
-- his Fortran 90 versions of the Dagpunar code.
--
-- Notes on the Distributions:
--
-- The functions approximate in a statistical manner certain continuous
-- probability distributions or densities (except Poisson and the Binomials,
-- which are integer valued here, not continuous). More precisely, if
-- you ran the program a long time, added up the number of points output
-- in each interval (X,X+dX), and plotted the resulting histogram,
-- you would get a function f(X), where f(X) is given as follows.
-- The functions are given in Normalized form.
--
-- The easy ones:
--
-- Random_Real (X, State_Val) samples from a uniform distribution:
-- = 1 for 0.0 <= X < 1.0
-- = 0 otherwise.
--
-- Exponential (Mean) = Exp (-X / Mean) / Mean for X > 0; 0 otherwise.
--
-- Normal (Mean, Sigma) =
-- = Exp (-(X - Mean)**2 / (2*Sigma**2)) / (Sigma*Sqrt(2*Pi))
--
-- Sometimes Normal is called Gaussian if Mean /=0 and Std Dev /= 1.
-- Sometimes Normal is called Std Normal if Mean =0 and Std Dev = 1.
--
-- Poisson (Mean) = Mean**k * Exp (-Mean) / k!
--
-- Output of Poisson is integer valued; Output includes 0.
--
-- The Cauchy probability density has a Lorentzian shape: (a/pi) / (a^2 + X^2).
--
-- The more complicated distribution are described well in their
-- respective Wikipedia articles.
generic
type Real is digits <>;
-- 15 digits required. This is checked.
package Disorderly.Random.Deviates is
pragma Pure (Deviates);
procedure Get_Random_Real
(Random_Real : out Real;
Stream : in out State);
--
-- Uniform on [0.0, 1.0).
-- (X starts out on 0..2**53-1; then squeezed onto [0,1) by
-- multiplying X by 2.0**(-53).)
type Normal_Initializer is private;
procedure Get_Normal
(Mean : in Real;
Sigma : in Real;
N_Init : in out Normal_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Normal_Initializer and pass it in.
-- The procedure Get_Normal does everything else for you.
--
-- The Gaussian distribution probability density:
--
-- f(X) = A * Exp (-(X-Mean)**2 / (2*Sigma**2))
--
-- Sigma = Standard_Deviation
-- A = 1.0 / (Sigma*Sqrt(2*Pi)) (normalization constant)
--
-- If Sigma=1, and Mean=0 then its usually called the
-- Standard Normal distribution.
function Normal_Probability
(Mean : in Real; -- Mean of random variable X
Sigma : in Real; -- Std Dev of random variable X
X : in Real)
return Real;
subtype Log_Normal_Initializer is Normal_Initializer;
procedure Get_Log_Normal -- outputs random variable X
(Mean_Z : in Real; -- Mean of random variable Z = Log (X)
Sigma_Z : in Real; -- Std Dev of random variable Z = Log (X)
LN_Init : in out Log_Normal_Initializer;
Stream : in out State;
Result : out Real); -- X
--
-- 1. Must declare variable of type Log_Normal_Initializer and pass it in.
-- The procedure Get_Log_Normal does everything else for you.
--
-- The Log_Normal distribution probability density for X:
--
-- f(X) = A * Exp (-(Log(X) - Mean_Z)**2 / (2*Sigma_Z**2)) / X
--
-- f(X) = 0 (for X <= 0)
--
-- Sigma_Z = Standard_Deviation of Z = Log (X)
-- A = 1.0 / (Sigma_Z * Sqrt (2*Pi))
--
-- If Z is a normally distributed Random Variable with (Mean_Z, Sigma_Z)
-- then X = Exp (Z) is Log_Normal distributed with the distribution given
-- above. In terms of Z's Average and Std Deviation, (Mean_Z, Sigma_Z):
-- Mean_X = Exp (Mean_Z + Sigma_Z**2 / 2)
-- Sigma_X**2 = Mean_X**2 * (Exp (Sigma_Z**2) - 1))
--
-- Suppose you have (Mean_X, Sigma_X) and you want (Mean_Z, Sigma_Z) of
-- Z = Log(X), (the latter is the pair you plug into Get_Log_Normal above).
-- The formula is
-- Sigma_Z**2 = Log (1 + Sigma_X**2 / Mean_X**2))
-- Mean_Z = Log (Mean_X) - 0.5 * Sigma_Z**2
--
function Log_Normal_Probability
(Mean_Z : in Real; -- Mean of random variable Z = Log (X)
Sigma_Z : in Real; -- Std Dev of random variable Z = Log (X)
X : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- The Log_Normal probability density:
--
-- f(X) = A * Exp (-(Log(X) - Mean_Z)**2 / (2*Sigma_Z**2)) / X
--
-- f(X) = 0 (for X <= 0)
--
-- Sigma_Z = Standard_Deviation of Z, (where Z = Log (X)).
-- A = 1.0 / (Sigma_Z * Sqrt (2*Pi))
procedure Get_Cauchy
(A : in Real;
Stream : in out State;
Result : out Real);
--
-- The Cauchy (Lorentzian) distribution probability density:
--
-- f(X) = A / [(A*A + X*X) * Pi] -- normalized and scaled
--
-- Generates random deviates X in range (-inf, inf).
procedure Get_Exponential
(Mean : in Real;
Stream : in out State;
Result : out Real);
--
-- 1. Must have Mean > 0.0.
-- Raises contraint_Error if Mean is <= 0.0.
--
-- The Exponential distribution probability density:
--
-- f(X) = Exp (-X / Mean) / Mean for X > 0; 0 otherwise.
--
-- Generates a random deviate X in [0,inf).
procedure Get_Weibull
(a : in Real;
Stream : in out State;
Result : out Real);
--
-- The Weibull distribution probability density function:
--
-- f(X) = a * X**(a-1) * Exp (-X**a) if X > 0; f(X) = 0 otherwise.
--
-- If a=1 its Get_Exponential with Mean=1. Use Get_Exponential; much faster.
-- If a=2 its Rayleigh distribution. Use Get_Rayleigh; its faster.
-- If a=0, raises contraint_Error.
-- If a is too near 0, (or far from 1 in general) get Nan's or nonsense.
procedure Get_Rayleigh
(Stream : in out State;
Result : out Real);
--
-- The Rayleigh distribution probability density:
--
-- f(X) = 2 * X * Exp (-X**2) if X > 0; f(X) = 0 otherwise.
--
type Binomial_Initializer is private;
procedure Get_Binomial
(n : in Positive;
p : in Real;
B_Init : in out Binomial_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Binomial_Initializer and pass it in.
-- The procedure Get_Binomial does everything else for you.
--
-- 2. Must have: 0 < p < 1. (p = Bernoulli success probability.)
--
-- The Binomial distribution probability density:
--
-- f(X) = (n!/([X]!(n-[X])!)) * p^[X] * (1-p)^(n-[X])
-- if 0 <= X <= n; f(X) = 0 otherwise.
--
-- Result is output as a float, but is always Integer valued.
function Binomial_Probability
(n : in Positive;
k : in Integer;
p : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- Uses Log_Gamma to get:
--
-- [n!/(k!(n-k)!)] * p^k * (1-p)^(n-k)
-- if 0 <= k <= n;
-- returns 0 otherwise.
--
-- k < 0 returns 0
-- k > n returns 0
--
-- p <= 0.0 raises Constraint_Error
-- p >= 1.0 raises Constraint_Error
type Neg_Binomial_Initializer is private;
procedure Get_Neg_Binomial
(r : in Real;
p : in Real;
NB_Init : in out Neg_Binomial_Initializer;
Stream : in out State;
Result : out Real);
--
-- Result is a random deviate from distribution f_r(k) where f_r(k) is
-- the probability of r successes and k failures in n = k+r Bernoulli trials.
-- Assumes that the final trial is a success, and p = success probability.
-- (r is not retricted to integer values; output Result is. Result is k-like.)
--
-- Slow for large r, (r >> 10).
-- Slow for small p, (p < 0.1).
--
-- Must have: r > 0.0
-- r = the number of successes when r integer.
-- The random deviate output (Result) is sampled
-- from a distribution f_r(k) where f_r(k) is the
-- probability that k failures and r successes
-- are observed in a series of uncorrelated Bernoulli trials
-- (with the final trial being a success).
-- Must have: 0 < p < 1
-- p = Bernoulli success probability
--
-- Result is output as a float, but is always Integer valued.
function Neg_Binomial_Probability
(r : in Real;
k : in Integer;
p : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- Uses Log_Gamma to get:
--
-- [Gamma(r + k)/[(Gamma(r)*k!] * p^r * (1-p)^k
--
-- Must have: r > 0.0
-- Must have: 0 < p < 1
-- p = Bernoulli success probability
--
-- Probability of r successes and k failures in n = k+r Bernoulli trials.
-- Assumes that the final trial is a success, and p = success probability.
--
-- If r = 1, the distribution is the probability of success on the (k+1)th
-- trial with k previous failures: geometric distribution, p*(1-p)^k.
-- As r -> inf, keeping the Mean = r*(1-p)/p constant, you get the
-- Poissonian distribution. So its a large p limit, opposite of Binomial.
subtype Poisson_Initializer is Binomial_Initializer;
p_Shift : constant := -20;
-- binomial is used to get Poisson, by setting p~2**(-20) and p*Mean = n.
-- p is the binomial (Bernoulli) success probability: p = 2.0**p_Shift.
-- p = -20 is stnd. If p=-20, then Max allowed Mean is < 2048, and you can
-- sample for 2 days at least without detecting difference between Poisson
-- and binomial. If you set p=-23, then you can sample for 2 wks without
-- problem, but then the maximum allowed Mean is < 256.
procedure Get_Poisson
(Mean : in Real;
P_Init : in out Poisson_Initializer;
Stream : in out State;
Result : out Real);
--
-- The Poisson distribution probability mass function:
--
-- f(k) = Mean^k * Exp (-Mean) / k!
--
-- Output of Poisson is integer valued, but floating point type.
-- Output includes 0.
--
-- Must have Mean > 0
-- Must have Mean < 2047.0 (if p_Shift = -20; ie p = 2**(-20))
-- Must have Mean < 256.0 (if p_Shift = -23; ie p = 2**(-23))
--
-- If mean > 8 then routine uses Binomial with p = 2**(-20) (with large
-- n so that Mean=n*p). The binomial distribution agrees with Poisson
-- with err ~ 5.0e-7 here. This discrepency is hard to
-- measure, but the routine should be thought of as single-precision.
-- This discrepency can be reduced by a factor of 8 by reducing p
-- by a factor of 8, (but max allowed Mean falls by a factor of 8).
function Poisson_Probability
(Mean : in Real;
k : in Integer)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- The Poisson distribution (probability mass function):
--
-- f(k) = Mean^k * Exp (-Mean) / k!
--
-- Negative k input is allowed (for convenience).
-- Output is 0 for k < 0.
type Student_t_Initializer is private;
procedure Get_Student_t
(m : in Positive;
Student_t_Init : in out Student_t_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Student_t_Initializer and pass it in.
-- The procedure Get_Student_t does everything else for you.
--
-- 2. Must have m >= 1. (m = degrees of freedom of distribution.)
--
-- The Student_t distribution probability density:
--
-- f(X) = (1 + X*X/m)^(-(m+1)/2) *
-- Gamma((m+1)/2) / [Sqrt (m*Pi) * Gamma(m/2)]
--
-- generates a random deviate from a t distribution
-- using Kinderman and Monahan's ratio method.
function Student_t_Probability
(m : in Positive;
x : in Real)
return Real;
--
-- A Probability density function.
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- Uses Log_Gamma to get:
--
-- f(X) = Gamma((m+1)/2) * (1 + X*X/m)^(-(m+1)/2) / [Sqrt (m*Pi) * Gamma(m/2)]
type Beta_Initializer is private;
procedure Get_Beta
(aa : in Real;
bb : in Real;
Beta_Init : in out Beta_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Beta_Initializer and pass it in.
-- The procedure Get_Beta does everything else for you.
--
-- 2. Must have aa > 0, bb > 0.
--
-- Get_Beta generates a random deviate in [0,1] from a beta distribution.
-- Uses Cheng's log logistic method.
--
-- The Beta distribution probability density:
--
-- f(X) = X**(aa-1) * (1-X)**(bb-1) *
-- Gamma (aa + bb) / (Gamma (bb)*Gamma (aa))
--
function Beta_Probability
(aa, bb : in Real;
x : in Real)
return Real;
--
-- NOT a random deviate. (Used for testing mostly.)
--
-- f(x) = x**(aa-1) * (1-x)**(bb-1) *
-- Gamma (aa + bb) / (Gamma (bb)*Gamma (aa))
--
-- x must be in range (0, 1)
type Gamma_Initializer is private;
procedure Get_Gamma
(s : in Real;
Gamma_Init : in out Gamma_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Gamma_Initializer and pass it in.
-- The procedure Get_Gamma does everything else for you.
--
-- 2. Must have s > 0.
-- s = Shape parameter of Gamma distribution.
--
-- Generates a random deviate in [0,infinity) from a gamma distribution.
function Gamma_Probability
(s : in Real;
x : in Real)
return Real;
--
-- f(x) = x**(s-1) * Exp (-x) / Gamma (s)
-- = 0 if x < 0.
--
-- (where s = Gamma shape parameter).
-- Must have s > 0.
-- NOT a random deviate. (Used for testing mostly.)
subtype Chi_Initializer is Gamma_Initializer;
procedure Get_Chi_Squared
(Degrees_of_Freedom : in Real;
Chi_Init : in out Chi_Initializer;
Stream : in out State;
Result : out Real);
--
-- 1. Must declare variable of type Chi_Initializer and pass it in.
-- The procedure Get_Chi_Squared does everything else for you.
--
-- 2. Must have Degrees_of_Freedom > 0.
--
-- Generates a random deviate in [0,infinity) from a Chi-Sq distribution.
function Chi_Squared_Probability
(Degrees_of_Freedom : in Real;
x : in Real)
return Real;
--
-- f(x) = (1 / 2) * (x / 2)**(s-1) * Exp (-x / 2) / Gamma (s)
-- = 0 if x < 0.
--
-- (where s = 0.5 * Degrees_of_Freedom).
-- NOT a random deviate. (Used for testing mostly.)
-- USING Get_Multivariate_Normal:
--
-- procedure Get_Multivariate_Normal is harder to use than the 1-dimensional
-- routines. You have to remember the following:
-- 1. You need a positive definite Covariance matrix.
-- 2. Declare it type Matrix (a..b, a..b) where a and b are type Positive.
-- 3. Declare Means : Vector(a..b), same range as Matrix, and initialize Means.
-- 4. Use procedure Choleski_Decompose to get the LU decomp. of Covariance.
subtype MV_Normal_Initializer is Normal_Initializer;
type Vector is array (Positive range <>) of Real;
type Matrix is array (Positive range <>, Positive range <>) of Real;
procedure Choleski_Decompose
(Covariance : in Matrix;
LU_of_Covariance : out Matrix); -- Choleski Decomp of Covariance matrix.
procedure Get_Multivariate_Normal
(Mean : in Vector;
LU_of_Covariance : in Matrix;
MV_Init : in out MV_Normal_Initializer;
Stream : in out State;
Result : out Vector);
--
-- To use Get_Multivariate_Normal:
-- put a Positive Definite Covariance matrix into
-- Choleski_Decompose to get Sqrt_Covariance.
--
-- Must have
-- Mean'First = Covariance'First(1) = Covariance'First(2)
-- Mean'Last = Covariance'Last(1) = Covariance'Last(2)
-- Mean'Length > 1
-- So use:
-- Mean : Vector (1..n);
-- Covariance : Matrix (1..n, 1..n);
--
-- Must initialize: Mean.
function Multivariate_Normal_Probability
(Mean : in Vector; -- Mean of random variables X
LU_of_Covariance : in Matrix; -- L of LU decomp of Covariance matrix
X : in Vector)
return Real;
procedure Test_Choleski;
private
Half : constant Real := +0.5;
Zero : constant Real := +0.0;
One : constant Real := +1.0;
Two : constant Real := +2.0;
Three : constant Real := +3.0;
Four : constant Real := +4.0;
Five : constant Real := +5.0;
Eight : constant Real := +8.0;
Sixteen : constant Real := +16.0;
Quarter : constant Real := +0.25;
Two_to_the_Ninth : constant Real := +512.0;
type Binomial_Initializer is
record
n : Positive := Positive'First;
r0 : Integer := 0;
p : Real := Half;
p_r : Real := Zero;
odds_ratio : Real := Zero;
Uninitialized : Boolean := True;
end record;
type Student_t_Initializer is
record
m : Positive := Positive'First;
a, f, g : Real := Zero;
Uninitialized : Boolean := True;
end record;
type Beta_Initializer is
record
Alpha, Beta : Real := Zero;
d, f, h, t, c : Real := Zero;
Swap : Boolean := False;
Uninitialized : Boolean := True;
end record;
type Gamma_Initializer is
record
s, p, c, uf, vr, d : Real := Zero;
Uninitialized : Boolean := True;
end record;
type Neg_Binomial_Initializer is
record
Reciprocal_Log_p1 : Real := Zero;
Reciprocal_Log_q1 : Real := Zero;
p : Real := Half;
Uninitialized : Boolean := True;
end record;
type Normal_Initializer is
record
Mean : Real := Zero;
Sigma : Real := Zero;
X2 : Real := Zero;
Uninitialized : Boolean := True;
end record;
Max_Allowed_Real : constant Real := Two**(Real'Machine_Emax-32);
Min_Allowed_Real : constant Real := Two**(Real'Machine_Emin+32);
end Disorderly.Random.Deviates;
|
persan/midnightsun-ctf-LoveLacedLetter | Ada | 326 | ads | package Hide.File_Coder is
procedure Encode (Source_File_Name : Posix.C_String;
Output_File_Name : Posix.C_String;
Offset : Natural;
Text : String);
function Decode (File_Name : Posix.C_String) return String;
end Hide.File_Coder;
|
RREE/ada-util | Ada | 2,538 | ads | -----------------------------------------------------------------------
-- util-log-appenders-files -- File log appenders
-- Copyright (C) 2001 - 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Util.Properties;
-- Write log events to a file.
package Util.Log.Appenders.Files is
-- ------------------------------
-- File appender
-- ------------------------------
type File_Appender (Length : Positive) is new Appender with private;
type File_Appender_Access is access all File_Appender'Class;
overriding
procedure Append (Self : in out File_Appender;
Message : in Util.Strings.Builders.Builder;
Date : in Ada.Calendar.Time;
Level : in Level_Type;
Logger : in String);
-- Set the file where the appender will write the logs.
-- When <tt>Append</tt> is true, the log message are appended to the existing file.
-- When set to false, the file is cleared before writing new messages.
procedure Set_File (Self : in out File_Appender;
Path : in String;
Append : in Boolean := True);
-- Flush the log events.
overriding
procedure Flush (Self : in out File_Appender);
-- Flush and close the file.
overriding
procedure Finalize (Self : in out File_Appender);
-- Create a file appender and configure it according to the properties
function Create (Name : in String;
Properties : in Util.Properties.Manager;
Default : in Level_Type)
return Appender_Access;
private
type File_Appender (Length : Positive) is new Appender (Length) with record
Output : Ada.Text_IO.File_Type;
Immediate_Flush : Boolean := False;
end record;
end Util.Log.Appenders.Files;
|
damaki/libkeccak | Ada | 2,042 | ads | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
pragma SPARK_Mode (On);
with Gimli.Sponge;
with Keccak.Generic_Hash;
-- @summary
-- Instantiation of a Hash function based on the Gimli permutation.
package Gimli.Hash is new Keccak.Generic_Hash
(Hash_Sponge => Gimli.Sponge,
Digest_Size => 256,
Capacity => 256,
Suffix => 2#1111#,
Suffix_Size => 4);
|
reznikmm/matreshka | Ada | 4,965 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Final_Nodes.Collections is
pragma Preelaborate;
package UML_Final_Node_Collections is
new AMF.Generic_Collections
(UML_Final_Node,
UML_Final_Node_Access);
type Set_Of_UML_Final_Node is
new UML_Final_Node_Collections.Set with null record;
Empty_Set_Of_UML_Final_Node : constant Set_Of_UML_Final_Node;
type Ordered_Set_Of_UML_Final_Node is
new UML_Final_Node_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Final_Node : constant Ordered_Set_Of_UML_Final_Node;
type Bag_Of_UML_Final_Node is
new UML_Final_Node_Collections.Bag with null record;
Empty_Bag_Of_UML_Final_Node : constant Bag_Of_UML_Final_Node;
type Sequence_Of_UML_Final_Node is
new UML_Final_Node_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Final_Node : constant Sequence_Of_UML_Final_Node;
private
Empty_Set_Of_UML_Final_Node : constant Set_Of_UML_Final_Node
:= (UML_Final_Node_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Final_Node : constant Ordered_Set_Of_UML_Final_Node
:= (UML_Final_Node_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Final_Node : constant Bag_Of_UML_Final_Node
:= (UML_Final_Node_Collections.Bag with null record);
Empty_Sequence_Of_UML_Final_Node : constant Sequence_Of_UML_Final_Node
:= (UML_Final_Node_Collections.Sequence with null record);
end AMF.UML.Final_Nodes.Collections;
|
reznikmm/matreshka | Ada | 3,648 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Clear_Association_Actions.Hash is
new AMF.Elements.Generic_Hash (UML_Clear_Association_Action, UML_Clear_Association_Action_Access);
|
reznikmm/matreshka | Ada | 43,016 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0003 is
pragma Preelaborate;
Group_0003 : aliased constant Core_Second_Stage
:= (16#40# .. 16#41# => -- 0340 .. 0341
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#43# .. 16#44# => -- 0343 .. 0344
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#45# => -- 0345
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Other_Alphabetic
| Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Extend
| ID_Continue
| Lowercase
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4F# => -- 034F
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Glue,
(Other_Default_Ignorable_Code_Point
| Case_Ignorable
| Default_Ignorable_Code_Point
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#58# .. 16#5B# => -- 0358 .. 035B
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#5C# => -- 035C
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Glue,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#5D# .. 16#62# => -- 035D .. 0362
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Glue,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#63# .. 16#6F# => -- 0363 .. 036F
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#70# => -- 0370
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#71# => -- 0371
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#72# => -- 0372
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#73# => -- 0373
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#74# => -- 0374
(Modifier_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Diacritic
| Alphabetic
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#75# => -- 0375
(Modifier_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Diacritic
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#76# => -- 0376
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#77# => -- 0377
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#78# .. 16#79# => -- 0378 .. 0379
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#7A# => -- 037A
(Modifier_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Diacritic
| Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7B# .. 16#7D# => -- 037B .. 037D
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#7E# => -- 037E
(Other_Punctuation, Neutral,
Other, Mid_Num, Other, Infix_Numeric,
(Terminal_Punctuation
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7F# => -- 037F
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#80# .. 16#83# => -- 0380 .. 0383
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#84# .. 16#85# => -- 0384 .. 0385
(Modifier_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Diacritic
| Case_Ignorable
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#86# => -- 0386
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#87# => -- 0387
(Other_Punctuation, Neutral,
Other, Mid_Letter, Other, Alphabetic,
(Other_ID_Continue
| Terminal_Punctuation
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#88# .. 16#8A# => -- 0388 .. 038A
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8B# => -- 038B
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#8C# => -- 038C
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8D# => -- 038D
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#8E# .. 16#8F# => -- 038E .. 038F
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#90# => -- 0390
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#91# .. 16#A1# => -- 0391 .. 03A1
(Uppercase_Letter, Ambiguous,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#A2# => -- 03A2
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#A3# .. 16#A9# => -- 03A3 .. 03A9
(Uppercase_Letter, Ambiguous,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#AA# .. 16#AB# => -- 03AA .. 03AB
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#AC# .. 16#B0# => -- 03AC .. 03B0
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#B1# .. 16#C1# => -- 03B1 .. 03C1
(Lowercase_Letter, Ambiguous,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#C2# => -- 03C2
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#C3# .. 16#C9# => -- 03C3 .. 03C9
(Lowercase_Letter, Ambiguous,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#CA# .. 16#CE# => -- 03CA .. 03CE
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#CF# => -- 03CF
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#D0# .. 16#D1# => -- 03D0 .. 03D1
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#D2# => -- 03D2
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Math
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#D3# .. 16#D4# => -- 03D3 .. 03D4
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#D5# => -- 03D5
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#D6# => -- 03D6
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#D7# => -- 03D7
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#D8# => -- 03D8
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#D9# => -- 03D9
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#DA# => -- 03DA
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#DB# => -- 03DB
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#DC# => -- 03DC
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#DD# => -- 03DD
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#DE# => -- 03DE
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#DF# => -- 03DF
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#E0# => -- 03E0
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#E1# => -- 03E1
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#E2# => -- 03E2
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#E3# => -- 03E3
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#E4# => -- 03E4
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#E5# => -- 03E5
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#E6# => -- 03E6
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#E7# => -- 03E7
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#E8# => -- 03E8
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#E9# => -- 03E9
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#EA# => -- 03EA
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#EB# => -- 03EB
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#EC# => -- 03EC
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#ED# => -- 03ED
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#EE# => -- 03EE
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#EF# => -- 03EF
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#F0# .. 16#F1# => -- 03F0 .. 03F1
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#F2# => -- 03F2
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#F3# => -- 03F3
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Soft_Dotted
| Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#F4# => -- 03F4
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Math
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#F5# => -- 03F5
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#F6# => -- 03F6
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math => True,
others => False)),
16#F7# => -- 03F7
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#F8# => -- 03F8
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#F9# .. 16#FA# => -- 03F9 .. 03FA
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#FB# => -- 03FB
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#FC# => -- 03FC
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#FD# .. 16#FF# => -- 03FD .. 03FF
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
others =>
(Nonspacing_Mark, Ambiguous,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0003;
|
charlie5/lace | Ada | 229 | ads | generic
type Item is private;
type View is access all Item;
pool_Size : Positive := 5_000;
package lace.fast_Pool
is
function new_Item return View;
procedure free (Self : in out View);
end lace.fast_Pool;
|
Lyanf/pok | Ada | 2,704 | ads | -- ---------------------------------------------------------------------------
-- --
-- BLACKBOARD constant and type definitions and management services --
-- --
-- ---------------------------------------------------------------------------
with APEX.Processes;
package APEX.Blackboards is
Max_Number_Of_Blackboards : constant := System_Limit_Number_Of_Blackboards;
subtype Blackboard_Name_Type is Name_Type;
type Blackboard_Id_Type is private;
Null_Blackboard_Id : constant Blackboard_Id_Type;
type Empty_Indicator_Type is (Empty, Occupied);
type Blackboard_Status_Type is record
Empty_Indicator : Empty_Indicator_Type;
Max_Message_Size : Message_Size_Type;
Waiting_Processes : APEX.Processes.Waiting_Range_Type;
end record;
procedure Create_Blackboard
(Blackboard_Name : in Blackboard_Name_Type;
Max_Message_Size : in Message_Size_Type;
Blackboard_Id : out Blackboard_Id_Type;
Return_Code : out Return_Code_Type);
procedure Display_Blackboard
(Blackboard_Id : in Blackboard_Id_Type;
Message_Addr : in Message_Addr_Type;
Length : in Message_Size_Type;
Return_Code : out Return_Code_Type);
procedure Read_Blackboard
(Blackboard_Id : in Blackboard_Id_Type;
Time_Out : in System_Time_Type;
Message_Addr : in Message_Addr_Type;
-- The message address is passed IN, although the respective message is
-- passed OUT
Length : out Message_Size_Type;
Return_Code : out Return_Code_Type);
procedure Clear_Blackboard
(Blackboard_Id : in Blackboard_Id_Type;
Return_Code : out Return_Code_Type);
procedure Get_Blackboard_Id
(Blackboard_Name : in Blackboard_Name_Type;
Blackboard_Id : out Blackboard_Id_Type;
Return_Code : out Return_Code_Type);
procedure Get_Blackboard_Status
(Blackboard_Id : in Blackboard_Id_Type;
Blackboard_Status : out Blackboard_Status_Type;
Return_Code : out Return_Code_Type);
private
type Blackboard_Id_Type is new APEX_Integer;
Null_Blackboard_Id : constant Blackboard_Id_Type := 0;
pragma Convention (C, Empty_Indicator_Type);
pragma Convention (C, Blackboard_Status_Type);
-- POK BINDINGS
pragma Import (C, Create_Blackboard, "CREATE_BLACKBOARD");
pragma Import (C, Display_Blackboard, "DISPLAY_BLACKBOARD");
pragma Import (C, Read_Blackboard, "READ_BLACKBOARD");
pragma Import (C, Clear_Blackboard, "CLEAR_BLACKBOARD");
pragma Import (C, Get_Blackboard_Id, "GET_BLACKBOARD_ID");
pragma Import (C, Get_Blackboard_Status, "GET_BLACKBOARD_STATUS");
-- END OF POK BINDINGS
end APEX.Blackboards;
|
BrickBot/Bound-T-H8-300 | Ada | 3,769 | ads | -- Flow.Unresolvable (decl)
--
-- Unresolvable dynamic flow and call edges, for use when the target
-- program contains a dynamic jump or call that we do not even try
-- to resolve.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.2 $
-- $Date: 2015/10/24 19:36:49 $
--
-- $Log: flow-unresolvable.ads,v $
-- Revision 1.2 2015/10/24 19:36:49 niklas
-- Moved to free licence.
--
-- Revision 1.1 2006-03-25 20:08:08 niklas
-- First version.
--
package Flow.Unresolvable is
--
-- Unresolvable jumps
--
type Edge_T is new Boundable_Edge_T with null record;
--
-- An unresolvable dynamic jump.
type Edge_Ref is access all Edge_T'Class;
--
-- A reference to a heap-allocated unresolvable edge object.
function Basis (Item : Edge_T) return Storage.Cell_List_T;
--
-- The basis of an unresolvable Edge_T is a null set.
--
-- Overrides (implements) Storage.Bounds.Basis.
function Image (Item : Edge_T) return String;
--
-- Displays "Unresolvable".
--
-- Overrides Storage.Bounds.Image.
procedure Apply (
Bounds : in Storage.Bounds.Bounds_T'Class;
Upon : in out Edge_T;
Graph : in Graph_T);
--
-- Applies the Bounds Upon the boundable edge as explained for the
-- abstract declaration Flow.Apply (Upon : Boundable_Edge_T).
--
-- The (default) implementation does nothing (leaving the edge
-- Unresolved).
--
-- Overrides (implements) Flow.Apply (Upon : Boundable_Edge_T).
function Edge return Dynamic_Edge_T;
--
-- A new unresovable edge.
--
-- Unresolvable calls
--
type Call_T is new Edge_T with null record;
--
-- An unresolvable dynamic call.
--
-- Inherits all operations from the unresolvable Edge_T.
type Call_Ref is access all Call_T'Class;
--
-- A reference to a heap-allocated unresolvable call object.
function Call return Dynamic_Edge_T;
--
-- A new unresovable call.
end Flow.Unresolvable;
|
strenkml/EE368 | Ada | 1,695 | ads |
with Memory.Container; use Memory.Container;
package Memory.SPM is
type SPM_Type is new Container_Type with private;
type SPM_Pointer is access all SPM_Type'Class;
function Create_SPM(mem : access Memory_Type'Class;
size : Natural;
latency : Time_Type := 1) return SPM_Pointer;
function Random_SPM(next : access Memory_Type'Class;
generator : Distribution_Type;
max_cost : Cost_Type)
return Memory_Pointer;
overriding
function Clone(mem : SPM_Type) return Memory_Pointer;
overriding
procedure Permute(mem : in out SPM_Type;
generator : in Distribution_Type;
max_cost : in Cost_Type);
overriding
procedure Read(mem : in out SPM_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Write(mem : in out SPM_Type;
address : in Address_Type;
size : in Positive);
overriding
function Get_Path_Length(mem : SPM_Type) return Natural;
overriding
function To_String(mem : SPM_Type) return Unbounded_String;
overriding
function Get_Cost(mem : SPM_Type) return Cost_Type;
overriding
procedure Generate(mem : in SPM_Type;
sigs : in out Unbounded_String;
code : in out Unbounded_String);
function Get_Size(mem : SPM_Type) return Natural;
private
type SPM_Type is new Container_Type with record
size : Natural;
latency : Time_Type;
end record;
end Memory.SPM;
|
AdaCore/langkit | Ada | 680 | adb | with Ada.Text_IO; use Ada.Text_IO;
with GNATCOLL.Traces;
with Libfoolang.Analysis; use Libfoolang.Analysis;
procedure Main is
Ctx : constant Analysis_Context := Create_Context;
U : constant Analysis_Unit := Ctx.Get_From_Buffer
(Filename => "main.txt",
Buffer => "a(c) b(a c) +c(a)");
begin
GNATCOLL.Traces.Parse_Config_File;
Put_Line ("main.adb: Running...");
if U.Has_Diagnostics then
raise Program_Error;
end if;
U.Populate_Lexical_Env;
Put_Line ("Calling P_Entity_Items..");
declare
Dummy : Ref_Array := U.Root.Child (1).As_Decl.P_Entity_Items;
begin
null;
end;
Put_Line ("main.adb: Done.");
end Main;
|
AdaCore/gpr | Ada | 57 | ads | package lib is
Msg : String := "Hello World!";
end lib; |
optikos/oasis | Ada | 4,407 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Elements.Defining_Names;
with Program.Elements.Parameter_Specifications;
with Program.Elements.Expressions;
with Program.Elements.Aspect_Specifications;
package Program.Elements.Formal_Function_Declarations is
pragma Pure (Program.Elements.Formal_Function_Declarations);
type Formal_Function_Declaration is
limited interface and Program.Elements.Declarations.Declaration;
type Formal_Function_Declaration_Access is
access all Formal_Function_Declaration'Class with Storage_Size => 0;
not overriding function Name
(Self : Formal_Function_Declaration)
return not null Program.Elements.Defining_Names.Defining_Name_Access
is abstract;
not overriding function Parameters
(Self : Formal_Function_Declaration)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is abstract;
not overriding function Result_Subtype
(Self : Formal_Function_Declaration)
return not null Program.Elements.Element_Access is abstract;
not overriding function Subprogram_Default
(Self : Formal_Function_Declaration)
return Program.Elements.Expressions.Expression_Access is abstract;
not overriding function Aspects
(Self : Formal_Function_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
not overriding function Has_Not_Null
(Self : Formal_Function_Declaration)
return Boolean is abstract;
not overriding function Has_Abstract
(Self : Formal_Function_Declaration)
return Boolean is abstract;
not overriding function Has_Box
(Self : Formal_Function_Declaration)
return Boolean is abstract;
type Formal_Function_Declaration_Text is limited interface;
type Formal_Function_Declaration_Text_Access is
access all Formal_Function_Declaration_Text'Class with Storage_Size => 0;
not overriding function To_Formal_Function_Declaration_Text
(Self : aliased in out Formal_Function_Declaration)
return Formal_Function_Declaration_Text_Access is abstract;
not overriding function With_Token
(Self : Formal_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Function_Token
(Self : Formal_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Return_Token
(Self : Formal_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Not_Token
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Null_Token
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Is_Token
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Abstract_Token
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Box_Token
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function With_Token_2
(Self : Formal_Function_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Formal_Function_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Formal_Function_Declarations;
|
onox/orka | Ada | 3,285 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.SIMD.AVX.Doubles.Compare is
pragma Pure;
function Compare (Left, Right : m256d; Mask : Integer_32) return m256d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_cmppd256";
-- Ordered means a comparison returns False if one of the values is a NaN,
-- while unordered would return True.
--
-- Signaling means an exception is raised for invalid floating-point values.
--
-- https://stackoverflow.com/questions/16988199/how-to-choose-avx-compare-predicate-variants
-- Predicates used are ordered and signaling
function "=" (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#10#));
function ">=" (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#0D#));
function ">" (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#0E#));
function "<=" (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#02#));
function "<" (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#01#));
function "/=" (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#1C#));
function Not_Nan (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#17#));
-- True if neither of the elements in Left and Right are Nan, false otherwise
function Nan (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#13#));
-- True if either or both elements in Left and Right are Nan, false otherwise
-- Negated predicates used are unordered and signaling
function Not_Greater_Or_Equal (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#09#));
function Not_Greater_Than (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#0A#));
function Not_Less_Equal (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#06#));
function Not_Less_Than (Left, Right : m256d) return m256d is
(Compare (Left, Right, 16#05#));
function Is_True (Elements : m256d; Position : Index_4D) return Boolean;
-- Return true if an element at the given position is not zero, false otherwise.
--
-- A comparison using one of the operators above may result in elements
-- consisting of all 1's. Trying to directly read such an element by
-- using an index (like 'Elements (X)' for example) may result
-- in a Constraint_Error. Use this function to check if an element is
-- not zero after comparison using one of the operators above.
function Is_Equal (Left, Right : m256d) return Boolean
with Inline_Always;
end Orka.SIMD.AVX.Doubles.Compare;
|
MinimSecure/unum-sdk | Ada | 852 | ads | -- Copyright 2004-2019 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/>.
package Bar is
type Empty is null record;
type Void_Star is access all Empty;
procedure Do_Nothing (E : Void_Star);
end Bar;
|
godunko/adawebui | Ada | 4,124 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2020, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: 5703 $ $Date: 2017-01-20 22:17:20 +0300 (Fri, 20 Jan 2017) $
------------------------------------------------------------------------------
package Web.Core.Connectables.Slots_0 is
pragma Preelaborate;
-- type Slot (<>) is abstract tagged limited private;
-- XXX GNATLLVM: instantiation erorr of Slot_1.
type Slot is abstract tagged limited private;
type Signal is limited interface;
not overriding procedure Connect
(Self : in out Signal;
Slot : Web.Core.Connectables.Slots_0.Slot'Class) is abstract;
private
type Slot_End_0 is abstract new Slot_End_Base with null record;
not overriding procedure Invoke (Self : in out Slot_End_0) is abstract;
type Slot is abstract tagged limited null record;
not overriding function Create_Slot_End
(Self : Slot) return not null Slot_End_Access;
end Web.Core.Connectables.Slots_0;
|
stcarrez/ada-ado | Ada | 1,796 | ads | -----------------------------------------------------------------------
-- ado-utils-serialize -- Utility operations for JSON/XML serialization
-- Copyright (C) 2016, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Serialize.IO;
with ADO.Objects;
with ADO.Statements;
package ADO.Utils.Serialize is
-- Write the entity to the serialization stream (JSON/XML).
procedure Write_Entity (Stream : in out Util.Serialize.IO.Output_Stream'Class;
Name : in String;
Value : in ADO.Identifier);
-- Write the entity to the serialization stream (JSON/XML).
procedure Write_Entity (Stream : in out Util.Serialize.IO.Output_Stream'Class;
Name : in String;
Value : in ADO.Objects.Object_Key);
-- Write the SQL query results to the serialization stream (JSON/XML).
procedure Write_Query (Stream : in out Util.Serialize.IO.Output_Stream'Class;
Name : in String;
Query : in out ADO.Statements.Query_Statement);
end ADO.Utils.Serialize;
|
MatrixMike/AdaDemo1 | Ada | 442 | adb | with Display; use Display;
with Display.Basic; use Display.Basic;
procedure bounce is
Ball : Shape_Id := new_Circle
(X => 0.0,
Y => 0.0,
Radius => 10.0,
Color => Blue);
begin
loop
if Get_X (ball) > 100.0 then
Step := -0.05;
elsif Get_X (ball) < -100.0 then
Step := -0.05;
end if;
Set_X (Ball, Get_X(Ball) + Step);
delay 0.001;
end loop;
end bounce;
|
zhmu/ananas | Ada | 56,771 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T C H O P --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Conversions; use Ada.Characters.Conversions;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Directories; use Ada.Directories;
with Ada.Streams.Stream_IO; use Ada.Streams;
with Ada.Text_IO; use Ada.Text_IO;
with System.CRTL; use System; use System.CRTL;
with GNAT.Byte_Order_Mark; use GNAT.Byte_Order_Mark;
with GNAT.Command_Line; use GNAT.Command_Line;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Heap_Sort_G;
with GNAT.Table;
with Switch; use Switch;
with Types;
procedure Gnatchop is
Config_File_Name : constant String_Access := new String'("gnat.adc");
-- The name of the file holding the GNAT configuration pragmas
Gcc : String_Access := new String'("gcc");
-- May be modified by switch --GCC=
Gcc_Set : Boolean := False;
-- True if a switch --GCC= is used
Gnat_Cmd : String_Access;
-- Command to execute the GNAT compiler
Gnat_Args : Argument_List_Access :=
new Argument_List'
(new String'("-c"),
new String'("-x"),
new String'("ada"),
new String'("-gnats"),
new String'("-gnatu"));
-- Arguments used in Gnat_Cmd call
EOF : constant Character := Character'Val (26);
-- Special character to signal end of file. Not required in input files,
-- but properly treated if present. Not generated in output files except
-- as a result of copying input file.
BOM_Length : Natural := 0;
-- Reset to non-zero value if BOM detected at start of file
--------------------
-- File arguments --
--------------------
subtype File_Num is Natural;
subtype File_Offset is Natural;
type File_Entry is record
Name : String_Access;
-- Name of chop file or directory
SR_Name : String_Access;
-- Null unless the chop file starts with a source reference pragma
-- in which case this field points to the file name from this pragma.
end record;
package File is new GNAT.Table
(Table_Component_Type => File_Entry,
Table_Index_Type => File_Num,
Table_Low_Bound => 1,
Table_Initial => 100,
Table_Increment => 100);
Directory : String_Access;
-- Record name of directory, or a null string if no directory given
Compilation_Mode : Boolean := False;
Overwrite_Files : Boolean := False;
Preserve_Mode : Boolean := False;
Quiet_Mode : Boolean := False;
Source_References : Boolean := False;
Verbose_Mode : Boolean := False;
Exit_On_Error : Boolean := False;
-- Global options
Write_gnat_adc : Boolean := False;
-- Gets set true if we append to gnat.adc or create a new gnat.adc.
-- Used to inhibit complaint about no units generated.
---------------
-- Unit list --
---------------
type Line_Num is new Natural;
-- Line number (for source reference pragmas)
type Unit_Count_Type is new Integer;
subtype Unit_Num is Unit_Count_Type range 1 .. Unit_Count_Type'Last;
-- Used to refer to unit number in unit table
type SUnit_Num is new Integer;
-- Used to refer to entry in sorted units table. Note that entry
-- zero is only for use by Heapsort, and is not otherwise referenced.
type Unit_Kind is (Unit_Spec, Unit_Body, Config_Pragmas);
-- Structure to contain all necessary information for one unit.
-- Entries are also temporarily used to record config pragma sequences.
type Unit_Info is record
File_Name : String_Access;
-- File name from GNAT output line
Chop_File : File_Num;
-- File number in chop file sequence
Start_Line : Line_Num;
-- Line number from GNAT output line
Offset : File_Offset;
-- Offset name from GNAT output line
SR_Present : Boolean;
-- Set True if SR parameter present
Length : File_Offset;
-- A length of 0 means that the Unit is the last one in the file
Kind : Unit_Kind;
-- Indicates kind of unit
Sorted_Index : SUnit_Num;
-- Index of unit in sorted unit list
Bufferg : String_Access;
-- Pointer to buffer containing configuration pragmas to be prepended.
-- Null if no pragmas to be prepended.
end record;
-- The following table stores the unit offset information
package Unit is new GNAT.Table
(Table_Component_Type => Unit_Info,
Table_Index_Type => Unit_Count_Type,
Table_Low_Bound => 1,
Table_Initial => 500,
Table_Increment => 100);
-- The following table is used as a sorted index to the Unit.Table.
-- The entries in Unit.Table are not moved, instead we just shuffle
-- the entries in Sorted_Units. Note that the zeroeth entry in this
-- table is used by GNAT.Heap_Sort_G.
package Sorted_Units is new GNAT.Table
(Table_Component_Type => Unit_Num,
Table_Index_Type => SUnit_Num,
Table_Low_Bound => 0,
Table_Initial => 500,
Table_Increment => 100);
function Is_Duplicated (U : SUnit_Num) return Boolean;
-- Returns true if U is duplicated by a later unit.
-- Note that this function returns false for the last entry.
procedure Sort_Units;
-- Sort units and set up sorted unit table
----------------------
-- File_Descriptors --
----------------------
function dup (handle : File_Descriptor) return File_Descriptor;
function dup2 (from, to : File_Descriptor) return File_Descriptor;
---------------------
-- Local variables --
---------------------
Warning_Count : Natural := 0;
-- Count of warnings issued so far
-----------------------
-- Local subprograms --
-----------------------
procedure Error_Msg (Message : String; Warning : Boolean := False);
-- Produce an error message on standard error output
function Files_Exist return Boolean;
-- Check Unit.Table for possible file names that already exist
-- in the file system. Returns true if files exist, False otherwise
function Get_Maximum_File_Name_Length return Integer;
pragma Import (C, Get_Maximum_File_Name_Length,
"__gnat_get_maximum_file_name_length");
-- Function to get maximum file name length for system
Maximum_File_Name_Length : constant Integer := Get_Maximum_File_Name_Length;
Maximum_File_Name_Length_String : constant String :=
Integer'Image
(Maximum_File_Name_Length);
function Locate_Executable
(Program_Name : String;
Look_For_Prefix : Boolean := True) return String_Access;
-- Locate executable for given program name. This takes into account
-- the target-prefix of the current command, if Look_For_Prefix is True.
subtype EOL_Length is Natural range 0 .. 2;
-- Possible lengths of end of line sequence
type EOL_String (Len : EOL_Length := 0) is record
Str : String (1 .. Len);
end record;
function Get_EOL
(Source : not null access String;
Start : Positive) return EOL_String;
-- Return the line terminator used in the passed string
procedure Parse_EOL
(Source : not null access String;
Ptr : in out Positive);
-- On return Source (Ptr) is the first character of the next line
-- or EOF. Source.all must be terminated by EOF.
function Parse_File (Num : File_Num) return Boolean;
-- Calls the GNAT compiler to parse the given source file and parses the
-- output using Parse_Offset_Info. Returns True if parse operation
-- completes, False if some system error (e.g. failure to read the
-- offset information) occurs.
procedure Parse_Offset_Info
(Chop_File : File_Num;
Source : not null access String);
-- Parses the output of the compiler indicating the offsets and names of
-- the compilation units in Chop_File.
procedure Parse_Token
(Source : not null access String;
Ptr : in out Positive;
Token_Ptr : out Positive);
-- Skips any separators and stores the start of the token in Token_Ptr.
-- Then stores the position of the next separator in Ptr. On return
-- Source (Token_Ptr .. Ptr - 1) is the token.
procedure Read_File
(FD : File_Descriptor;
Contents : out String_Access;
Success : out Boolean);
-- Reads file associated with FS into the newly allocated string Contents.
-- Success is true iff the number of bytes read is equal to the file size.
function Report_Duplicate_Units return Boolean;
-- Output messages about duplicate units in the input files in Unit.Table
-- Returns True if any duplicates found, False if no duplicates found.
function Scan_Arguments return Boolean;
-- Scan command line options and set global variables accordingly.
-- Also scan out file and directory arguments. Returns True if scan
-- was successful, and False if the scan fails for any reason.
procedure Usage;
-- Output message on standard output describing syntax of gnatchop command
procedure Warning_Msg (Message : String);
-- Output a warning message on standard error and update warning count
function Write_Chopped_Files (Input : File_Num) return Boolean;
-- Write all units that result from chopping the Input file
procedure Write_Config_File (Input : File_Num; U : Unit_Num);
-- Call to write configuration pragmas (append them to gnat.adc). Input is
-- the file number for the chop file and U identifies the unit entry for
-- the configuration pragmas.
function Get_Config_Pragmas
(Input : File_Num;
U : Unit_Num) return String_Access;
-- Call to read configuration pragmas from given unit entry, and return a
-- buffer containing the pragmas to be appended to following units. Input
-- is the file number for the chop file and U identifies the unit entry for
-- the configuration pragmas.
procedure Write_Source_Reference_Pragma
(Info : Unit_Info;
Line : Line_Num;
File : Stream_IO.File_Type;
EOL : EOL_String;
Success : in out Boolean);
-- If Success is True on entry, writes a source reference pragma using
-- the chop file from Info, and the given line number. On return Success
-- indicates whether the write succeeded. If Success is False on entry,
-- or if the global flag Source_References is False, then the call to
-- Write_Source_Reference_Pragma has no effect. EOL indicates the end
-- of line sequence to be written at the end of the pragma.
procedure Write_Unit
(Source : not null access String;
Num : Unit_Num;
TS_Time : OS_Time;
Write_BOM : Boolean;
Success : out Boolean);
-- Write one compilation unit of the source to file. Source is the pointer
-- to the input string, Num is the unit number, TS_Time is the timestamp,
-- Write_BOM is set True to write a UTF-8 BOM at the start of the file.
-- Success is set True unless the write attempt fails.
---------
-- dup --
---------
function dup (handle : File_Descriptor) return File_Descriptor is
begin
return File_Descriptor (System.CRTL.dup (int (handle)));
end dup;
----------
-- dup2 --
----------
function dup2 (from, to : File_Descriptor) return File_Descriptor is
begin
return File_Descriptor (System.CRTL.dup2 (int (from), int (to)));
end dup2;
---------------
-- Error_Msg --
---------------
procedure Error_Msg (Message : String; Warning : Boolean := False) is
begin
Put_Line (Standard_Error, Message);
if not Warning then
Set_Exit_Status (Failure);
if Exit_On_Error then
raise Types.Terminate_Program;
end if;
end if;
end Error_Msg;
-----------------
-- Files_Exist --
-----------------
function Files_Exist return Boolean is
Exists : Boolean := False;
begin
for SNum in 1 .. SUnit_Num (Unit.Last) loop
-- Only check and report for the last instance of duplicated files
if not Is_Duplicated (SNum) then
declare
Info : constant Unit_Info :=
Unit.Table (Sorted_Units.Table (SNum));
begin
if Is_Writable_File (Info.File_Name.all) then
Error_Msg (Info.File_Name.all
& " already exists, use -w to overwrite");
Exists := True;
end if;
end;
end if;
end loop;
return Exists;
end Files_Exist;
------------------------
-- Get_Config_Pragmas --
------------------------
function Get_Config_Pragmas
(Input : File_Num;
U : Unit_Num) return String_Access
is
Info : Unit_Info renames Unit.Table (U);
FD : File_Descriptor;
Name : aliased constant String :=
File.Table (Input).Name.all & ASCII.NUL;
Length : File_Offset;
Buffer : String_Access;
Result : String_Access;
Success : Boolean;
pragma Warnings (Off, Success);
begin
FD := Open_Read (Name'Address, Binary);
if FD = Invalid_FD then
Error_Msg ("cannot open " & File.Table (Input).Name.all);
return null;
end if;
Read_File (FD, Buffer, Success);
-- A length of 0 indicates that the rest of the file belongs to
-- this unit. The actual length must be calculated now. Take into
-- account that the last character (EOF) must not be written.
if Info.Length = 0 then
Length := Buffer'Last - (Buffer'First + Info.Offset);
else
Length := Info.Length;
end if;
Result := new String'(Buffer (1 .. Length));
Close (FD);
return Result;
end Get_Config_Pragmas;
-------------
-- Get_EOL --
-------------
function Get_EOL
(Source : not null access String;
Start : Positive) return EOL_String
is
Ptr : Positive := Start;
First : Positive;
Last : Natural;
begin
-- Skip to end of line
while Source (Ptr) /= ASCII.CR and then
Source (Ptr) /= ASCII.LF and then
Source (Ptr) /= EOF
loop
Ptr := Ptr + 1;
end loop;
Last := Ptr;
if Source (Ptr) /= EOF then
-- Found CR or LF
First := Ptr;
else
First := Ptr + 1;
end if;
-- Recognize CR/LF
if Source (Ptr) = ASCII.CR and then Source (Ptr + 1) = ASCII.LF then
Last := First + 1;
end if;
return (Len => Last + 1 - First, Str => Source (First .. Last));
end Get_EOL;
-------------------
-- Is_Duplicated --
-------------------
function Is_Duplicated (U : SUnit_Num) return Boolean is
begin
return U < SUnit_Num (Unit.Last)
and then
Unit.Table (Sorted_Units.Table (U)).File_Name.all =
Unit.Table (Sorted_Units.Table (U + 1)).File_Name.all;
end Is_Duplicated;
-----------------------
-- Locate_Executable --
-----------------------
function Locate_Executable
(Program_Name : String;
Look_For_Prefix : Boolean := True) return String_Access
is
Gnatchop_Str : constant String := "gnatchop";
Current_Command : constant String := Normalize_Pathname (Command_Name);
End_Of_Prefix : Natural;
Start_Of_Prefix : Positive;
Start_Of_Suffix : Positive;
Result : String_Access;
begin
Start_Of_Prefix := Current_Command'First;
Start_Of_Suffix := Current_Command'Last + 1;
End_Of_Prefix := Start_Of_Prefix - 1;
if Look_For_Prefix then
-- Find Start_Of_Prefix
for J in reverse Current_Command'Range loop
if Current_Command (J) = '/' or else
Current_Command (J) = Directory_Separator or else
Current_Command (J) = ':'
then
Start_Of_Prefix := J + 1;
exit;
end if;
end loop;
-- Find End_Of_Prefix
for J in Start_Of_Prefix ..
Current_Command'Last - Gnatchop_Str'Length + 1
loop
if Current_Command (J .. J + Gnatchop_Str'Length - 1) =
Gnatchop_Str
then
End_Of_Prefix := J - 1;
exit;
end if;
end loop;
end if;
if End_Of_Prefix > Current_Command'First then
Start_Of_Suffix := End_Of_Prefix + Gnatchop_Str'Length + 1;
end if;
declare
Command : constant String :=
Current_Command (Start_Of_Prefix .. End_Of_Prefix)
& Program_Name
& Current_Command (Start_Of_Suffix ..
Current_Command'Last);
begin
Result := Locate_Exec_On_Path (Command);
if Result = null then
Error_Msg
(Command & ": installation problem, executable not found");
end if;
end;
return Result;
end Locate_Executable;
---------------
-- Parse_EOL --
---------------
procedure Parse_EOL
(Source : not null access String;
Ptr : in out Positive) is
begin
-- Skip to end of line
while Source (Ptr) /= ASCII.CR and then Source (Ptr) /= ASCII.LF
and then Source (Ptr) /= EOF
loop
Ptr := Ptr + 1;
end loop;
if Source (Ptr) /= EOF then
Ptr := Ptr + 1; -- skip CR or LF
end if;
-- Skip past CR/LF or LF/CR combination
if (Source (Ptr) = ASCII.CR or else Source (Ptr) = ASCII.LF)
and then Source (Ptr) /= Source (Ptr - 1)
then
Ptr := Ptr + 1;
end if;
end Parse_EOL;
----------------
-- Parse_File --
----------------
function Parse_File (Num : File_Num) return Boolean is
Chop_Name : constant String_Access := File.Table (Num).Name;
Save_Stdout : constant File_Descriptor := dup (Standout);
Offset_Name : Temp_File_Name;
Offset_FD : File_Descriptor := Invalid_FD;
Buffer : String_Access;
Success : Boolean;
Failure : exception;
begin
-- Display copy of GNAT command if verbose mode
if Verbose_Mode then
Put (Gnat_Cmd.all);
for J in 1 .. Gnat_Args'Length loop
Put (' ');
Put (Gnat_Args (J).all);
end loop;
Put (' ');
Put_Line (Chop_Name.all);
end if;
-- Create temporary file
Create_Temp_File (Offset_FD, Offset_Name);
if Offset_FD = Invalid_FD then
Error_Msg ("gnatchop: cannot create temporary file");
Close (Save_Stdout);
return False;
end if;
-- Redirect Stdout to this temporary file in the Unix way
if dup2 (Offset_FD, Standout) = Invalid_FD then
Error_Msg ("gnatchop: cannot redirect stdout to temporary file");
Close (Save_Stdout);
Close (Offset_FD);
return False;
end if;
-- Call Gnat on the source filename argument with special options
-- to generate offset information. If this special compilation completes
-- successfully then we can do the actual gnatchop operation.
Spawn (Gnat_Cmd.all, Gnat_Args.all & Chop_Name, Success);
if not Success then
Error_Msg (Chop_Name.all & ": parse errors detected");
Error_Msg (Chop_Name.all & ": chop may not be successful");
end if;
-- Restore stdout
if dup2 (Save_Stdout, Standout) = Invalid_FD then
Error_Msg ("gnatchop: cannot restore stdout");
end if;
-- Reopen the file to start reading from the beginning
Close (Offset_FD);
Close (Save_Stdout);
Offset_FD := Open_Read (Offset_Name'Address, Binary);
if Offset_FD = Invalid_FD then
Error_Msg ("gnatchop: cannot access offset info");
raise Failure;
end if;
Read_File (Offset_FD, Buffer, Success);
if not Success then
Error_Msg ("gnatchop: error reading offset info");
Close (Offset_FD);
raise Failure;
else
Parse_Offset_Info (Num, Buffer);
end if;
-- Close and delete temporary file
Close (Offset_FD);
Delete_File (Offset_Name'Address, Success);
return Success;
exception
when Failure | Types.Terminate_Program =>
if Offset_FD /= Invalid_FD then
Close (Offset_FD);
end if;
Delete_File (Offset_Name'Address, Success);
return False;
end Parse_File;
-----------------------
-- Parse_Offset_Info --
-----------------------
procedure Parse_Offset_Info
(Chop_File : File_Num;
Source : not null access String)
is
First_Unit : constant Unit_Num := Unit.Last + 1;
Bufferg : String_Access := null;
Parse_Ptr : File_Offset := Source'First;
Token_Ptr : File_Offset;
Info : Unit_Info;
function Match (Literal : String) return Boolean;
-- Checks if given string appears at the current Token_Ptr location
-- and if so, bumps Parse_Ptr past the token and returns True. If
-- the string is not present, sets Parse_Ptr to Token_Ptr and
-- returns False.
-----------
-- Match --
-----------
function Match (Literal : String) return Boolean is
begin
Parse_Token (Source, Parse_Ptr, Token_Ptr);
if Source'Last + 1 - Token_Ptr < Literal'Length
or else
Source (Token_Ptr .. Token_Ptr + Literal'Length - 1) /= Literal
then
Parse_Ptr := Token_Ptr;
return False;
end if;
Parse_Ptr := Token_Ptr + Literal'Length;
return True;
end Match;
-- Start of processing for Parse_Offset_Info
begin
loop
-- Set default values, should get changed for all
-- units/pragmas except for the last
Info.Chop_File := Chop_File;
Info.Length := 0;
-- Parse the current line of offset information into Info
-- and exit the loop if there are any errors or on EOF.
-- First case, parse a line in the following format:
-- Unit x (spec) line 7, file offset 142, [SR, ]file name x.ads
-- Note that the unit name can be an operator name in quotes.
-- This is of course illegal, but both GNAT and gnatchop handle
-- the case so that this error does not interfere with chopping.
-- The SR ir present indicates that a source reference pragma
-- was processed as part of this unit (and that therefore no
-- Source_Reference pragma should be generated.
if Match ("Unit") then
Parse_Token (Source, Parse_Ptr, Token_Ptr);
if Match ("(body)") then
Info.Kind := Unit_Body;
elsif Match ("(spec)") then
Info.Kind := Unit_Spec;
else
exit;
end if;
exit when not Match ("line");
Parse_Token (Source, Parse_Ptr, Token_Ptr);
Info.Start_Line := Line_Num'Value
(Source (Token_Ptr .. Parse_Ptr - 1));
exit when not Match ("file offset");
Parse_Token (Source, Parse_Ptr, Token_Ptr);
Info.Offset := File_Offset'Value
(Source (Token_Ptr .. Parse_Ptr - 1));
Info.SR_Present := Match ("SR, ");
exit when not Match ("file name");
Parse_Token (Source, Parse_Ptr, Token_Ptr);
Info.File_Name := new String'
(Directory.all & Source (Token_Ptr .. Parse_Ptr - 1));
Parse_EOL (Source, Parse_Ptr);
-- Second case, parse a line of the following form
-- Configuration pragmas at line 10, file offset 223
elsif Match ("Configuration pragmas at") then
Info.Kind := Config_Pragmas;
Info.File_Name := Config_File_Name;
exit when not Match ("line");
Parse_Token (Source, Parse_Ptr, Token_Ptr);
Info.Start_Line := Line_Num'Value
(Source (Token_Ptr .. Parse_Ptr - 1));
exit when not Match ("file offset");
Parse_Token (Source, Parse_Ptr, Token_Ptr);
Info.Offset := File_Offset'Value
(Source (Token_Ptr .. Parse_Ptr - 1));
Parse_EOL (Source, Parse_Ptr);
-- Third case, parse a line of the following form
-- Source_Reference pragma for file "filename"
-- This appears at the start of the file only, and indicates
-- the name to be used on any generated Source_Reference pragmas.
elsif Match ("Source_Reference pragma for file ") then
Parse_Token (Source, Parse_Ptr, Token_Ptr);
File.Table (Chop_File).SR_Name :=
new String'(Source (Token_Ptr + 1 .. Parse_Ptr - 2));
Parse_EOL (Source, Parse_Ptr);
goto Continue;
-- Unrecognized keyword or end of file
else
exit;
end if;
-- Store the data in the Info record in the Unit.Table
Unit.Increment_Last;
Unit.Table (Unit.Last) := Info;
-- If this is not the first unit from the file, calculate
-- the length of the previous unit as difference of the offsets
if Unit.Last > First_Unit then
Unit.Table (Unit.Last - 1).Length :=
Info.Offset - Unit.Table (Unit.Last - 1).Offset;
end if;
-- If not in compilation mode combine current unit with any
-- preceding configuration pragmas.
if not Compilation_Mode
and then Unit.Last > First_Unit
and then Unit.Table (Unit.Last - 1).Kind = Config_Pragmas
then
Info.Start_Line := Unit.Table (Unit.Last - 1).Start_Line;
Info.Offset := Unit.Table (Unit.Last - 1).Offset;
-- Delete the configuration pragma entry
Unit.Table (Unit.Last - 1) := Info;
Unit.Decrement_Last;
end if;
-- If in compilation mode, and previous entry is the initial
-- entry for the file and is for configuration pragmas, then
-- they are to be appended to every unit in the file.
if Compilation_Mode
and then Unit.Last = First_Unit + 1
and then Unit.Table (First_Unit).Kind = Config_Pragmas
then
Bufferg :=
Get_Config_Pragmas
(Unit.Table (Unit.Last - 1).Chop_File, First_Unit);
Unit.Table (Unit.Last - 1) := Info;
Unit.Decrement_Last;
end if;
Unit.Table (Unit.Last).Bufferg := Bufferg;
-- If in compilation mode, and this is not the first item,
-- combine configuration pragmas with previous unit, which
-- will cause an error message to be generated when the unit
-- is compiled.
if Compilation_Mode
and then Unit.Last > First_Unit
and then Unit.Table (Unit.Last).Kind = Config_Pragmas
then
Unit.Decrement_Last;
end if;
<<Continue>>
null;
end loop;
-- Find out if the loop was exited prematurely because of
-- an error or if the EOF marker was found.
if Source (Parse_Ptr) /= EOF then
Error_Msg
(File.Table (Chop_File).Name.all & ": error parsing offset info");
return;
end if;
-- Handle case of a chop file consisting only of config pragmas
if Unit.Last = First_Unit
and then Unit.Table (Unit.Last).Kind = Config_Pragmas
then
-- In compilation mode, we append such a file to gnat.adc
if Compilation_Mode then
Write_Config_File (Unit.Table (Unit.Last).Chop_File, First_Unit);
Unit.Decrement_Last;
-- In default (non-compilation) mode, this is invalid
else
Error_Msg
(File.Table (Chop_File).Name.all &
": no units found (only pragmas)");
Unit.Decrement_Last;
end if;
end if;
-- Handle case of a chop file ending with config pragmas. This can
-- happen only in default non-compilation mode, since in compilation
-- mode such configuration pragmas are part of the preceding unit.
-- We simply concatenate such pragmas to the previous file which
-- will cause a compilation error, which is appropriate.
if Unit.Last > First_Unit
and then Unit.Table (Unit.Last).Kind = Config_Pragmas
then
Unit.Decrement_Last;
end if;
end Parse_Offset_Info;
-----------------
-- Parse_Token --
-----------------
procedure Parse_Token
(Source : not null access String;
Ptr : in out Positive;
Token_Ptr : out Positive)
is
In_Quotes : Boolean := False;
begin
-- Skip separators
while Source (Ptr) = ' ' or else Source (Ptr) = ',' loop
Ptr := Ptr + 1;
end loop;
Token_Ptr := Ptr;
-- Find end-of-token
while (In_Quotes
or else not (Source (Ptr) = ' ' or else Source (Ptr) = ','))
and then Source (Ptr) >= ' '
loop
if Source (Ptr) = '"' then
In_Quotes := not In_Quotes;
end if;
Ptr := Ptr + 1;
end loop;
end Parse_Token;
---------------
-- Read_File --
---------------
procedure Read_File
(FD : File_Descriptor;
Contents : out String_Access;
Success : out Boolean)
is
Length : constant File_Offset := File_Offset (File_Length (FD));
-- Include room for EOF char
Buffer : String_Access := new String (1 .. Length + 1);
This_Read : Integer;
Read_Ptr : File_Offset := 1;
begin
loop
This_Read := Read (FD,
A => Buffer (Read_Ptr)'Address,
N => Length + 1 - Read_Ptr);
Read_Ptr := Read_Ptr + Integer'Max (This_Read, 0);
exit when This_Read <= 0;
end loop;
Buffer (Read_Ptr) := EOF;
-- The following test can fail if there was an I/O error, in which case
-- Success will be set to False.
if Read_Ptr = Length then
Contents := Buffer;
else
Contents := new String (1 .. Read_Ptr);
Contents.all := Buffer (1 .. Read_Ptr);
Free (Buffer);
end if;
Success := Read_Ptr = Length + 1;
end Read_File;
----------------------------
-- Report_Duplicate_Units --
----------------------------
function Report_Duplicate_Units return Boolean is
US : SUnit_Num;
U : Unit_Num;
Duplicates : Boolean := False;
begin
US := 1;
while US < SUnit_Num (Unit.Last) loop
U := Sorted_Units.Table (US);
if Is_Duplicated (US) then
Duplicates := True;
-- Move to last two versions of duplicated file to make it clearer
-- to understand which file is retained in case of overwriting.
while US + 1 < SUnit_Num (Unit.Last) loop
exit when not Is_Duplicated (US + 1);
US := US + 1;
end loop;
U := Sorted_Units.Table (US);
if Overwrite_Files then
Warning_Msg (Unit.Table (U).File_Name.all
& " is duplicated (all but last will be skipped)");
elsif Unit.Table (U).Chop_File =
Unit.Table (Sorted_Units.Table (US + 1)).Chop_File
then
Error_Msg (Unit.Table (U).File_Name.all
& " is duplicated in "
& File.Table (Unit.Table (U).Chop_File).Name.all);
else
Error_Msg (Unit.Table (U).File_Name.all
& " in "
& File.Table (Unit.Table (U).Chop_File).Name.all
& " is duplicated in "
& File.Table
(Unit.Table
(Sorted_Units.Table (US + 1)).Chop_File).Name.all);
end if;
end if;
US := US + 1;
end loop;
if Duplicates and not Overwrite_Files then
Put_Line ("use -w to overwrite files and keep last version");
end if;
return Duplicates;
end Report_Duplicate_Units;
--------------------
-- Scan_Arguments --
--------------------
function Scan_Arguments return Boolean is
Kset : Boolean := False;
-- Set true if -k switch found
begin
Initialize_Option_Scan;
-- Scan options first
loop
case Getopt ("c gnat? h k? p q r v w x -GCC=!") is
when ASCII.NUL =>
exit;
when '-' =>
Gcc := new String'(Parameter);
Gcc_Set := True;
when 'c' =>
Compilation_Mode := True;
when 'g' =>
Gnat_Args :=
new Argument_List'(Gnat_Args.all &
new String'("-gnat" & Parameter));
when 'h' =>
Usage;
raise Types.Terminate_Program;
when 'k' =>
declare
Param : String_Access := new String'(Parameter);
begin
if Param.all /= "" then
for J in Param'Range loop
if Param (J) not in '0' .. '9' then
Error_Msg ("-k# requires numeric parameter");
return False;
end if;
end loop;
else
Param := new String'("8");
end if;
Gnat_Args :=
new Argument_List'(Gnat_Args.all &
new String'("-gnatk" & Param.all));
Kset := True;
end;
when 'p' =>
Preserve_Mode := True;
when 'q' =>
Quiet_Mode := True;
when 'r' =>
Source_References := True;
when 'v' =>
Verbose_Mode := True;
Display_Version ("GNATCHOP", "1998");
when 'w' =>
Overwrite_Files := True;
when 'x' =>
Exit_On_Error := True;
when others =>
null;
end case;
end loop;
if not Kset and then Maximum_File_Name_Length > 0 then
-- If this system has restricted filename lengths, tell gnat1
-- about them, removing the leading blank from the image string.
Gnat_Args :=
new Argument_List'(Gnat_Args.all
& new String'("-gnatk"
& Maximum_File_Name_Length_String
(Maximum_File_Name_Length_String'First + 1
.. Maximum_File_Name_Length_String'Last)));
end if;
-- Scan file names
loop
declare
S : constant String := Get_Argument (Do_Expansion => True);
begin
exit when S = "";
File.Increment_Last;
File.Table (File.Last).Name := new String'(S);
File.Table (File.Last).SR_Name := null;
end;
end loop;
-- Case of more than one file where last file is a directory
if File.Last > 1
and then Is_Directory (File.Table (File.Last).Name.all)
then
Directory := File.Table (File.Last).Name;
File.Decrement_Last;
-- Make sure Directory is terminated with a directory separator,
-- so we can generate the output by just appending a filename.
if Directory (Directory'Last) /= Directory_Separator
and then Directory (Directory'Last) /= '/'
then
Directory := new String'(Directory.all & Directory_Separator);
end if;
-- At least one filename must be given
elsif File.Last = 0 then
if Argument_Count = 0 then
Usage;
else
Try_Help;
end if;
return False;
-- No directory given, set directory to null, so that we can just
-- concatenate the directory name to the file name unconditionally.
else
Directory := new String'("");
end if;
-- Finally check all filename arguments
for File_Num in 1 .. File.Last loop
declare
F : constant String := File.Table (File_Num).Name.all;
begin
if Is_Directory (F) then
Error_Msg (F & " is a directory, cannot be chopped");
return False;
elsif not Is_Regular_File (F) then
Error_Msg (F & " not found");
return False;
end if;
end;
end loop;
return True;
exception
when Invalid_Switch =>
Error_Msg ("invalid switch " & Full_Switch);
return False;
when Invalid_Parameter =>
Error_Msg ("-k switch requires numeric parameter");
return False;
end Scan_Arguments;
----------------
-- Sort_Units --
----------------
procedure Sort_Units is
procedure Move (From : Natural; To : Natural);
-- Procedure used to sort the unit list
-- Unit.Table (To) := Unit_List (From); used by sort
function Lt (Left, Right : Natural) return Boolean;
-- Compares Left and Right units based on file name (first),
-- Chop_File (second) and Offset (third). This ordering is
-- important to keep the last version in case of duplicate files.
package Unit_Sort is new GNAT.Heap_Sort_G (Move, Lt);
-- Used for sorting on filename to detect duplicates
--------
-- Lt --
--------
function Lt (Left, Right : Natural) return Boolean is
L : Unit_Info renames
Unit.Table (Sorted_Units.Table (SUnit_Num (Left)));
R : Unit_Info renames
Unit.Table (Sorted_Units.Table (SUnit_Num (Right)));
begin
return L.File_Name.all < R.File_Name.all
or else (L.File_Name.all = R.File_Name.all
and then (L.Chop_File < R.Chop_File
or else (L.Chop_File = R.Chop_File
and then L.Offset < R.Offset)));
end Lt;
----------
-- Move --
----------
procedure Move (From : Natural; To : Natural) is
begin
Sorted_Units.Table (SUnit_Num (To)) :=
Sorted_Units.Table (SUnit_Num (From));
end Move;
-- Start of processing for Sort_Units
begin
Sorted_Units.Set_Last (SUnit_Num (Unit.Last));
for J in 1 .. Unit.Last loop
Sorted_Units.Table (SUnit_Num (J)) := J;
end loop;
-- Sort Unit.Table, using Sorted_Units.Table (0) as scratch
Unit_Sort.Sort (Natural (Unit.Last));
-- Set the Sorted_Index fields in the unit tables
for J in 1 .. SUnit_Num (Unit.Last) loop
Unit.Table (Sorted_Units.Table (J)).Sorted_Index := J;
end loop;
end Sort_Units;
-----------
-- Usage --
-----------
procedure Usage is
begin
Put_Line
("Usage: gnatchop [-c] [-h] [-k#] " &
"[-r] [-p] [-q] [-v] [-w] [-x] [--GCC=xx] file [file ...] [dir]");
New_Line;
Display_Usage_Version_And_Help;
Put_Line
(" -c compilation mode, configuration pragmas " &
"follow RM rules");
Put_Line
(" -gnatxxx passes the -gnatxxx switch to gnat parser");
Put_Line
(" -h help: output this usage information");
Put_Line
(" -k# krunch file names of generated files to " &
"no more than # characters");
Put_Line
(" -k krunch file names of generated files to " &
"no more than 8 characters");
Put_Line
(" -p preserve time stamp, output files will " &
"have same stamp as input");
Put_Line
(" -q quiet mode, no output of generated file " &
"names");
Put_Line
(" -r generate Source_Reference pragmas refer" &
"encing original source file");
Put_Line
(" -v verbose mode, output version and generat" &
"ed commands");
Put_Line
(" -w overwrite existing filenames");
Put_Line
(" -x exit on error");
Put_Line
(" --GCC=xx specify the path of the gnat parser to be used");
New_Line;
Put_Line
(" file... list of source files to be chopped");
Put_Line
(" dir directory location for split files (defa" &
"ult = current directory)");
end Usage;
-----------------
-- Warning_Msg --
-----------------
procedure Warning_Msg (Message : String) is
begin
Warning_Count := Warning_Count + 1;
Put_Line (Standard_Error, "warning: " & Message);
end Warning_Msg;
-------------------------
-- Write_Chopped_Files --
-------------------------
function Write_Chopped_Files (Input : File_Num) return Boolean is
Name : aliased constant String :=
File.Table (Input).Name.all & ASCII.NUL;
FD : File_Descriptor;
Buffer : String_Access;
Success : Boolean;
TS_Time : OS_Time;
BOM_Present : Boolean;
BOM : BOM_Kind;
-- Record presence of UTF8 BOM in input
begin
FD := Open_Read (Name'Address, Binary);
TS_Time := File_Time_Stamp (FD);
if FD = Invalid_FD then
Error_Msg ("cannot open " & File.Table (Input).Name.all);
return False;
end if;
Read_File (FD, Buffer, Success);
if not Success then
Error_Msg ("cannot read " & File.Table (Input).Name.all);
Close (FD);
return False;
end if;
if not Quiet_Mode then
Put_Line ("splitting " & File.Table (Input).Name.all & " into:");
end if;
-- Test for presence of BOM
Read_BOM (Buffer.all, BOM_Length, BOM, XML_Support => False);
BOM_Present := BOM /= Unknown;
-- Only chop those units that come from this file
for Unit_Number in 1 .. Unit.Last loop
if Unit.Table (Unit_Number).Chop_File = Input then
Write_Unit
(Source => Buffer,
Num => Unit_Number,
TS_Time => TS_Time,
Write_BOM => BOM_Present and then Unit_Number /= 1,
Success => Success);
exit when not Success;
end if;
end loop;
Close (FD);
return Success;
end Write_Chopped_Files;
-----------------------
-- Write_Config_File --
-----------------------
procedure Write_Config_File (Input : File_Num; U : Unit_Num) is
FD : File_Descriptor;
Name : aliased constant String := "gnat.adc" & ASCII.NUL;
Buffer : String_Access;
Success : Boolean;
Append : Boolean;
Buffera : String_Access;
Bufferl : Natural;
begin
Write_gnat_adc := True;
FD := Open_Read_Write (Name'Address, Binary);
if FD = Invalid_FD then
FD := Create_File (Name'Address, Binary);
Append := False;
if not Quiet_Mode then
Put_Line ("writing configuration pragmas from " &
File.Table (Input).Name.all & " to gnat.adc");
end if;
else
Append := True;
if not Quiet_Mode then
Put_Line
("appending configuration pragmas from " &
File.Table (Input).Name.all & " to gnat.adc");
end if;
end if;
Success := FD /= Invalid_FD;
if not Success then
Error_Msg ("cannot create gnat.adc");
return;
end if;
-- In append mode, acquire existing gnat.adc file
if Append then
Read_File (FD, Buffera, Success);
if not Success then
Error_Msg ("cannot read gnat.adc");
return;
end if;
-- Find location of EOF byte if any to exclude from append
Bufferl := 1;
while Bufferl <= Buffera'Last
and then Buffera (Bufferl) /= EOF
loop
Bufferl := Bufferl + 1;
end loop;
Bufferl := Bufferl - 1;
Close (FD);
-- Write existing gnat.adc to new gnat.adc file
FD := Create_File (Name'Address, Binary);
Success := Write (FD, Buffera (1)'Address, Bufferl) = Bufferl;
if not Success then
Error_Msg ("error writing gnat.adc");
return;
end if;
end if;
Buffer := Get_Config_Pragmas (Input, U);
if Buffer /= null then
Success := Write (FD, Buffer.all'Address, Buffer'Length) =
Buffer'Length;
if not Success then
Error_Msg ("disk full writing gnat.adc");
return;
end if;
end if;
Close (FD);
end Write_Config_File;
-----------------------------------
-- Write_Source_Reference_Pragma --
-----------------------------------
procedure Write_Source_Reference_Pragma
(Info : Unit_Info;
Line : Line_Num;
File : Stream_IO.File_Type;
EOL : EOL_String;
Success : in out Boolean)
is
FTE : File_Entry renames Gnatchop.File.Table (Info.Chop_File);
Nam : String_Access;
begin
if Success and then Source_References and then not Info.SR_Present then
if FTE.SR_Name /= null then
Nam := FTE.SR_Name;
else
Nam := FTE.Name;
end if;
declare
Reference : String :=
"pragma Source_Reference (000000, """
& Nam.all & """);" & EOL.Str;
Pos : Positive := Reference'First;
Lin : Line_Num := Line;
begin
while Reference (Pos + 1) /= ',' loop
Pos := Pos + 1;
end loop;
while Reference (Pos) = '0' loop
Reference (Pos) := Character'Val
(Character'Pos ('0') + Lin mod 10);
Lin := Lin / 10;
Pos := Pos - 1;
end loop;
-- Assume there are enough zeroes for any program length
pragma Assert (Lin = 0);
begin
String'Write (Stream_IO.Stream (File), Reference);
Success := True;
exception
when others =>
Success := False;
end;
end;
end if;
end Write_Source_Reference_Pragma;
----------------
-- Write_Unit --
----------------
procedure Write_Unit
(Source : not null access String;
Num : Unit_Num;
TS_Time : OS_Time;
Write_BOM : Boolean;
Success : out Boolean)
is
procedure OS_Filename
(Name : String;
W_Name : Wide_String;
OS_Name : Address;
N_Length : access Natural;
Encoding : Address;
E_Length : access Natural);
pragma Import (C, OS_Filename, "__gnat_os_filename");
-- Returns in OS_Name the proper name for the OS when used with the
-- returned Encoding value. For example on Windows this will return the
-- UTF-8 encoded name into OS_Name and set Encoding to encoding=utf8
-- (the form parameter for Stream_IO).
--
-- Name is the filename and W_Name the same filename in Unicode 16 bits
-- (this corresponds to Win32 Unicode ISO/IEC 10646). N_Length/E_Length
-- are the length returned in OS_Name/Encoding respectively.
Info : Unit_Info renames Unit.Table (Num);
Name : aliased constant String := Info.File_Name.all & ASCII.NUL;
W_Name : aliased constant Wide_String := To_Wide_String (Name);
EOL : constant EOL_String :=
Get_EOL (Source, Source'First + Info.Offset);
OS_Name : aliased String (1 .. Name'Length * 2);
O_Length : aliased Natural := OS_Name'Length;
Encoding : aliased String (1 .. 64);
E_Length : aliased Natural := Encoding'Length;
Length : File_Offset;
begin
-- Skip duplicated files
if Is_Duplicated (Info.Sorted_Index) then
Put_Line (" " & Info.File_Name.all & " skipped");
Success := Overwrite_Files;
return;
end if;
-- Get OS filename
OS_Filename
(Name, W_Name,
OS_Name'Address, O_Length'Access,
Encoding'Address, E_Length'Access);
declare
E_Name : constant String := OS_Name (1 .. O_Length);
OS_Encoding : constant String := Encoding (1 .. E_Length);
File : Stream_IO.File_Type;
begin
begin
if not Overwrite_Files and then Exists (E_Name) then
raise Stream_IO.Name_Error;
else
Stream_IO.Create
(File, Stream_IO.Out_File, E_Name, OS_Encoding);
Success := True;
end if;
exception
when Stream_IO.Name_Error | Stream_IO.Use_Error =>
Error_Msg ("cannot create " & Info.File_Name.all);
return;
end;
-- A length of 0 indicates that the rest of the file belongs to
-- this unit. The actual length must be calculated now. Take into
-- account that the last character (EOF) must not be written.
if Info.Length = 0 then
Length := Source'Last - (Source'First + Info.Offset);
else
Length := Info.Length;
end if;
-- Write BOM if required
if Write_BOM then
String'Write
(Stream_IO.Stream (File),
Source.all (Source'First .. Source'First + BOM_Length - 1));
end if;
-- Prepend configuration pragmas if necessary
if Success and then Info.Bufferg /= null then
Write_Source_Reference_Pragma (Info, 1, File, EOL, Success);
String'Write (Stream_IO.Stream (File), Info.Bufferg.all);
end if;
Write_Source_Reference_Pragma
(Info, Info.Start_Line, File, EOL, Success);
if Success then
begin
String'Write
(Stream_IO.Stream (File),
Source (Source'First + Info.Offset ..
Source'First + Info.Offset + Length - 1));
exception
when Stream_IO.Use_Error | Stream_IO.Device_Error =>
Error_Msg ("disk full writing " & Info.File_Name.all);
return;
end;
end if;
if not Quiet_Mode then
Put_Line (" " & Info.File_Name.all);
end if;
Stream_IO.Close (File);
if Preserve_Mode then
Set_File_Last_Modify_Time_Stamp (E_Name, TS_Time);
end if;
end;
end Write_Unit;
procedure Check_Version_And_Help is new Check_Version_And_Help_G (Usage);
-- Start of processing for gnatchop
begin
-- Add the directory where gnatchop is invoked in front of the path, if
-- gnatchop is invoked with directory information.
declare
Command : constant String := Command_Name;
begin
for Index in reverse Command'Range loop
if Command (Index) = Directory_Separator then
declare
Absolute_Dir : constant String :=
Normalize_Pathname
(Command (Command'First .. Index));
PATH : constant String :=
Absolute_Dir
& Path_Separator
& Getenv ("PATH").all;
begin
Setenv ("PATH", PATH);
end;
exit;
end if;
end loop;
end;
-- Process command line options and initialize global variables
-- First, scan to detect --version and/or --help
Check_Version_And_Help ("GNATCHOP", "1998");
if not Scan_Arguments then
Set_Exit_Status (Failure);
return;
end if;
-- Check presence of required executables
Gnat_Cmd := Locate_Executable (Gcc.all, not Gcc_Set);
if Gnat_Cmd = null then
goto No_Files_Written;
end if;
-- First parse all files and read offset information
for Num in 1 .. File.Last loop
if not Parse_File (Num) then
goto No_Files_Written;
end if;
end loop;
-- Check if any units have been found (assumes non-empty Unit.Table)
if Unit.Last = 0 then
if not Write_gnat_adc then
Error_Msg ("no compilation units found", Warning => True);
end if;
goto No_Files_Written;
end if;
Sort_Units;
-- Check if any duplicate files would be created. If so, emit a warning if
-- Overwrite_Files is true, otherwise generate an error.
if Report_Duplicate_Units and then not Overwrite_Files then
goto No_Files_Written;
end if;
-- Check if any files exist, if so do not write anything Because all files
-- have been parsed and checked already, there won't be any duplicates
if not Overwrite_Files and then Files_Exist then
goto No_Files_Written;
end if;
-- After this point, all source files are read in succession and chopped
-- into their destination files.
-- Source_File_Name pragmas are handled as logical file 0 so write it first
for F in 1 .. File.Last loop
if not Write_Chopped_Files (F) then
Set_Exit_Status (Failure);
return;
end if;
end loop;
if Warning_Count > 0 then
declare
Warnings_Msg : constant String := Warning_Count'Img & " warning(s)";
begin
Error_Msg (Warnings_Msg (2 .. Warnings_Msg'Last), Warning => True);
end;
end if;
return;
<<No_Files_Written>>
-- Special error exit for all situations where no files have
-- been written.
if not Write_gnat_adc then
Error_Msg ("no source files written", Warning => True);
end if;
return;
exception
when Types.Terminate_Program =>
null;
end Gnatchop;
|
zhmu/ananas | Ada | 241 | ads | with System.Address_To_Access_Conversions;
generic
type T is new Root with private;
package Array5_Pkg2.G is
package Ptr is new System.Address_To_Access_Conversions (T);
Data : Ptr.Object_Pointer;
end Array5_Pkg2.G;
|
reznikmm/matreshka | Ada | 6,860 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Line_Break_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Line_Break_Element_Node is
begin
return Self : Text_Line_Break_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Line_Break_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Line_Break
(ODF.DOM.Text_Line_Break_Elements.ODF_Text_Line_Break_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Line_Break_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Line_Break_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Line_Break_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Line_Break
(ODF.DOM.Text_Line_Break_Elements.ODF_Text_Line_Break_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Line_Break_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Line_Break
(Visitor,
ODF.DOM.Text_Line_Break_Elements.ODF_Text_Line_Break_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Line_Break_Element,
Text_Line_Break_Element_Node'Tag);
end Matreshka.ODF_Text.Line_Break_Elements;
|
Rodeo-McCabe/orka | Ada | 1,240 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ahven.Framework;
package Test_Transforms_Doubles_Vectors is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
private
procedure Test_Add;
procedure Test_Subtract;
procedure Test_Scale;
procedure Test_Absolute;
procedure Test_Magnitude;
procedure Test_Normalize;
procedure Test_Distance;
procedure Test_Projection;
procedure Test_Perpendicular;
procedure Test_Angle;
procedure Test_Dot_Product;
procedure Test_Cross_Product;
end Test_Transforms_Doubles_Vectors;
|
reznikmm/matreshka | Ada | 3,995 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Table_Operator_Attributes;
package Matreshka.ODF_Table.Operator_Attributes is
type Table_Operator_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Operator_Attributes.ODF_Table_Operator_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Operator_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Operator_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Operator_Attributes;
|
faelys/natools | Ada | 2,087 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.GNAT_HMAC is a root for HMAC instances using hash functions --
-- provided by GNAT. Is also provides glue functions. --
------------------------------------------------------------------------------
with Ada.Streams;
with GNAT.MD5;
with GNAT.SHA1;
with GNAT.SHA256;
package Natools.GNAT_HMAC is
generic
type Context is private;
with function Hex_Digest (C : Context) return String;
function Generic_Digest (C : Context)
return Ada.Streams.Stream_Element_Array;
function Digest (C : GNAT.MD5.Context)
return Ada.Streams.Stream_Element_Array;
function Digest (C : GNAT.SHA1.Context)
return Ada.Streams.Stream_Element_Array;
function Digest (C : GNAT.SHA256.Context)
return Ada.Streams.Stream_Element_Array;
end Natools.GNAT_HMAC;
|
zhmu/ananas | Ada | 18,190 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P A R . L A B L --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
separate (Par)
procedure Labl is
Enclosing_Body_Or_Block : Node_Id;
-- Innermost enclosing body or block statement
Label_Decl_Node : Node_Id;
-- Implicit label declaration node
Defining_Ident_Node : Node_Id;
-- Defining identifier node for implicit label declaration
Next_Label_Elmt : Elmt_Id;
-- Next element on label element list
Label_Node : Node_Id;
-- Next label node to process
function Find_Enclosing_Body_Or_Block (N : Node_Id) return Node_Id;
-- Find the innermost body or block that encloses N
function Find_Enclosing_Body (N : Node_Id) return Node_Id;
-- Find the innermost body that encloses N
procedure Check_Distinct_Labels;
-- Checks the rule in RM-5.1(11), which requires distinct identifiers
-- for all the labels in a given body.
procedure Find_Natural_Loops;
-- Recognizes loops created by backward gotos, and rewrites the
-- corresponding statements into a proper loop, for optimization
-- purposes (for example, to control reclaiming local storage).
---------------------------
-- Check_Distinct_Labels --
---------------------------
procedure Check_Distinct_Labels is
Label_Id : constant Node_Id := Identifier (Label_Node);
Enclosing_Body : constant Node_Id :=
Find_Enclosing_Body (Enclosing_Body_Or_Block);
-- Innermost enclosing body
Next_Other_Label_Elmt : Elmt_Id := First_Elmt (Label_List);
-- Next element on label element list
Other_Label : Node_Id;
-- Next label node to process
begin
-- Loop through all the labels, and if we find some other label
-- (i.e. not Label_Node) that has the same identifier,
-- and whose innermost enclosing body is the same,
-- then we have an error.
-- Note that in the worst case, this is quadratic in the number
-- of labels. However, labels are not all that common, and this
-- is only called for explicit labels.
-- ???Nonetheless, the efficiency could be improved. For example,
-- call Labl for each body, rather than once per compilation.
while Present (Next_Other_Label_Elmt) loop
Other_Label := Node (Next_Other_Label_Elmt);
exit when Label_Node = Other_Label;
if Chars (Label_Id) = Chars (Identifier (Other_Label))
and then Enclosing_Body = Find_Enclosing_Body (Other_Label)
then
Error_Msg_Sloc := Sloc (Other_Label);
Error_Msg_N ("& conflicts with label#", Label_Id);
exit;
end if;
Next_Elmt (Next_Other_Label_Elmt);
end loop;
end Check_Distinct_Labels;
-------------------------
-- Find_Enclosing_Body --
-------------------------
function Find_Enclosing_Body (N : Node_Id) return Node_Id is
Result : Node_Id := N;
begin
-- This is the same as Find_Enclosing_Body_Or_Block, except
-- that we skip block statements and accept statements, instead
-- of stopping at them.
while Present (Result)
and then Nkind (Result) /= N_Entry_Body
and then Nkind (Result) /= N_Task_Body
and then Nkind (Result) /= N_Package_Body
and then Nkind (Result) /= N_Subprogram_Body
loop
Result := Parent (Result);
end loop;
return Result;
end Find_Enclosing_Body;
----------------------------------
-- Find_Enclosing_Body_Or_Block --
----------------------------------
function Find_Enclosing_Body_Or_Block (N : Node_Id) return Node_Id is
Result : Node_Id := Parent (N);
begin
-- Climb up the parent chain until we find a body or block
while Present (Result)
and then Nkind (Result) /= N_Accept_Statement
and then Nkind (Result) /= N_Entry_Body
and then Nkind (Result) /= N_Task_Body
and then Nkind (Result) /= N_Package_Body
and then Nkind (Result) /= N_Subprogram_Body
and then Nkind (Result) /= N_Block_Statement
loop
Result := Parent (Result);
end loop;
return Result;
end Find_Enclosing_Body_Or_Block;
------------------------
-- Find_Natural_Loops --
------------------------
procedure Find_Natural_Loops is
Node_List : constant Elist_Id := New_Elmt_List;
N : Elmt_Id;
Succ : Elmt_Id;
function Goto_Id (Goto_Node : Node_Id) return Name_Id;
-- Find Name_Id of goto statement, which may be an expanded name
function Matches
(Label_Node : Node_Id;
Goto_Node : Node_Id) return Boolean;
-- A label and a goto are candidates for a loop if the names match,
-- and both nodes appear in the same body. In addition, both must
-- appear in the same statement list. If they are not in the same
-- statement list, the goto is from within an nested structure, and
-- the label is not a header. We ignore the case where the goto is
-- within a conditional structure, and capture only infinite loops.
procedure Merge;
-- Merge labels and goto statements in order of increasing sloc value.
-- Discard labels of loop and block statements.
procedure No_Header (N : Elmt_Id);
-- The label N is known not to be a loop header. Scan forward and
-- remove all subsequent gotos that may have this node as a target.
procedure Process_Goto (N : Elmt_Id);
-- N is a forward jump. Scan forward and remove all subsequent gotos
-- that may have the same target, to preclude spurious loops.
procedure Rewrite_As_Loop
(Loop_Header : Node_Id;
Loop_End : Node_Id);
-- Given a label and a backwards goto, rewrite intervening statements
-- as a loop. Remove the label from the node list, and rewrite the
-- goto with the body of the new loop.
procedure Try_Loop (N : Elmt_Id);
-- N is a label that may be a loop header. Scan forward to find some
-- backwards goto with which to make a loop. Do nothing if there is
-- an intervening label that is not part of a loop, or more than one
-- goto with this target.
-------------
-- Goto_Id --
-------------
function Goto_Id (Goto_Node : Node_Id) return Name_Id is
begin
if Nkind (Name (Goto_Node)) = N_Identifier then
return Chars (Name (Goto_Node));
elsif Nkind (Name (Goto_Node)) = N_Selected_Component then
return Chars (Selector_Name (Name (Goto_Node)));
else
-- In case of error, return Id that can't match anything
return Name_Null;
end if;
end Goto_Id;
-------------
-- Matches --
-------------
function Matches
(Label_Node : Node_Id;
Goto_Node : Node_Id) return Boolean
is
begin
return Chars (Identifier (Label_Node)) = Goto_Id (Goto_Node)
and then Find_Enclosing_Body (Label_Node) =
Find_Enclosing_Body (Goto_Node);
end Matches;
-----------
-- Merge --
-----------
procedure Merge is
L1 : Elmt_Id;
G1 : Elmt_Id;
begin
L1 := First_Elmt (Label_List);
G1 := First_Elmt (Goto_List);
while Present (L1)
and then Present (G1)
loop
if Sloc (Node (L1)) < Sloc (Node (G1)) then
-- Optimization: remove labels of loops and blocks, which
-- play no role in what follows.
if Nkind (Node (L1)) /= N_Loop_Statement
and then Nkind (Node (L1)) /= N_Block_Statement
then
Append_Elmt (Node (L1), Node_List);
end if;
Next_Elmt (L1);
else
Append_Elmt (Node (G1), Node_List);
Next_Elmt (G1);
end if;
end loop;
while Present (L1) loop
Append_Elmt (Node (L1), Node_List);
Next_Elmt (L1);
end loop;
while Present (G1) loop
Append_Elmt (Node (G1), Node_List);
Next_Elmt (G1);
end loop;
end Merge;
---------------
-- No_Header --
---------------
procedure No_Header (N : Elmt_Id) is
S1, S2 : Elmt_Id;
begin
S1 := Next_Elmt (N);
while Present (S1) loop
S2 := Next_Elmt (S1);
if Nkind (Node (S1)) = N_Goto_Statement
and then Matches (Node (N), Node (S1))
then
Remove_Elmt (Node_List, S1);
end if;
S1 := S2;
end loop;
end No_Header;
------------------
-- Process_Goto --
------------------
procedure Process_Goto (N : Elmt_Id) is
Goto1 : constant Node_Id := Node (N);
Goto2 : Node_Id;
S, S1 : Elmt_Id;
begin
S := Next_Elmt (N);
while Present (S) loop
S1 := Next_Elmt (S);
Goto2 := Node (S);
if Nkind (Goto2) = N_Goto_Statement
and then Goto_Id (Goto1) = Goto_Id (Goto2)
and then Find_Enclosing_Body (Goto1) =
Find_Enclosing_Body (Goto2)
then
-- Goto2 may have the same target, remove it from
-- consideration.
Remove_Elmt (Node_List, S);
end if;
S := S1;
end loop;
end Process_Goto;
---------------------
-- Rewrite_As_Loop --
---------------------
procedure Rewrite_As_Loop
(Loop_Header : Node_Id;
Loop_End : Node_Id)
is
Loop_Body : constant List_Id := New_List;
Loop_Stmt : constant Node_Id :=
New_Node (N_Loop_Statement, Sloc (Loop_Header));
Stat : Node_Id;
Next_Stat : Node_Id;
begin
Stat := Next (Loop_Header);
while Stat /= Loop_End loop
Next_Stat := Next (Stat);
Remove (Stat);
Append (Stat, Loop_Body);
Stat := Next_Stat;
end loop;
Set_Statements (Loop_Stmt, Loop_Body);
Set_Identifier (Loop_Stmt, Identifier (Loop_Header));
Remove (Loop_Header);
Rewrite (Loop_End, Loop_Stmt);
Error_Msg_N
("info: code between label and backwards goto rewritten as loop??",
Loop_End);
end Rewrite_As_Loop;
--------------
-- Try_Loop --
--------------
procedure Try_Loop (N : Elmt_Id) is
Source : Elmt_Id;
Found : Boolean := False;
S1 : Elmt_Id;
begin
S1 := Next_Elmt (N);
while Present (S1) loop
if Nkind (Node (S1)) = N_Goto_Statement
and then Matches (Node (N), Node (S1))
then
if not Found then
-- If the label and the goto are both in the same statement
-- list, then we've found a loop. Note that labels and goto
-- statements are always part of some list, so In_Same_List
-- always makes sense.
if In_Same_List (Node (N), Node (S1)) then
Source := S1;
Found := True;
-- The goto is within some nested structure
else
No_Header (N);
return;
end if;
else
-- More than one goto with the same target
No_Header (N);
return;
end if;
elsif Nkind (Node (S1)) = N_Label
and then not Found
then
-- Intervening label before possible end of loop. Current
-- label is not a candidate. This is conservative, because
-- the label might not be the target of any jumps, but not
-- worth dealing with useless labels.
No_Header (N);
return;
else
-- If the node is a loop_statement, it corresponds to a
-- label-goto pair rewritten as a loop. Continue forward scan.
null;
end if;
Next_Elmt (S1);
end loop;
if Found then
Rewrite_As_Loop (Node (N), Node (Source));
Remove_Elmt (Node_List, N);
Remove_Elmt (Node_List, Source);
end if;
end Try_Loop;
begin
-- Start of processing for Find_Natural_Loops
Merge;
N := First_Elmt (Node_List);
while Present (N) loop
Succ := Next_Elmt (N);
if Nkind (Node (N)) = N_Label then
if No (Succ) then
exit;
elsif Nkind (Node (Succ)) = N_Label then
Try_Loop (Succ);
-- If a loop was found, the label has been removed, and
-- the following goto rewritten as the loop body.
Succ := Next_Elmt (N);
if Nkind (Node (Succ)) = N_Label then
-- Following label was not removed, so current label
-- is not a candidate header.
No_Header (N);
else
-- Following label was part of inner loop. Current
-- label is still a candidate.
Try_Loop (N);
Succ := Next_Elmt (N);
end if;
elsif Nkind (Node (Succ)) = N_Goto_Statement then
Try_Loop (N);
Succ := Next_Elmt (N);
end if;
elsif Nkind (Node (N)) = N_Goto_Statement then
Process_Goto (N);
Succ := Next_Elmt (N);
end if;
N := Succ;
end loop;
end Find_Natural_Loops;
-- Start of processing for Par.Labl
begin
Next_Label_Elmt := First_Elmt (Label_List);
while Present (Next_Label_Elmt) loop
Label_Node := Node (Next_Label_Elmt);
if not Comes_From_Source (Label_Node) then
goto Next_Label;
end if;
-- Find the innermost enclosing body or block, which is where
-- we need to implicitly declare this label
Enclosing_Body_Or_Block := Find_Enclosing_Body_Or_Block (Label_Node);
-- If we didn't find a parent, then the label in question never got
-- hooked into a reasonable declarative part. This happens only in
-- error situations, and we simply ignore the entry (we aren't going
-- to get into the semantics in any case given the error).
if Present (Enclosing_Body_Or_Block) then
Check_Distinct_Labels;
-- Now create the implicit label declaration node and its
-- corresponding defining identifier. Note that the defining
-- occurrence of a label is the implicit label declaration that
-- we are creating. The label itself is an applied occurrence.
Label_Decl_Node :=
New_Node (N_Implicit_Label_Declaration, Sloc (Label_Node));
Defining_Ident_Node :=
New_Entity (N_Defining_Identifier, Sloc (Identifier (Label_Node)));
Set_Chars (Defining_Ident_Node, Chars (Identifier (Label_Node)));
Set_Defining_Identifier (Label_Decl_Node, Defining_Ident_Node);
Set_Label_Construct (Label_Decl_Node, Label_Node);
-- The following makes sure that Comes_From_Source is appropriately
-- set for the entity, depending on whether the label appeared in
-- the source explicitly or not.
Set_Comes_From_Source
(Defining_Ident_Node, Comes_From_Source (Identifier (Label_Node)));
-- Now attach the implicit label declaration to the appropriate
-- declarative region, creating a declaration list if none exists
if No (Declarations (Enclosing_Body_Or_Block)) then
Set_Declarations (Enclosing_Body_Or_Block, New_List);
end if;
Append (Label_Decl_Node, Declarations (Enclosing_Body_Or_Block));
end if;
<<Next_Label>>
Next_Elmt (Next_Label_Elmt);
end loop;
Find_Natural_Loops;
end Labl;
|
reznikmm/matreshka | Ada | 4,035 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Register_True_Attributes;
package Matreshka.ODF_Style.Register_True_Attributes is
type Style_Register_True_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Register_True_Attributes.ODF_Style_Register_True_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Register_True_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Register_True_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Register_True_Attributes;
|
reznikmm/matreshka | Ada | 4,631 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Caption_Angle_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Caption_Angle_Attribute_Node is
begin
return Self : Draw_Caption_Angle_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Caption_Angle_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Caption_Angle_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Caption_Angle_Attribute,
Draw_Caption_Angle_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Caption_Angle_Attributes;
|
zhmu/ananas | Ada | 1,232 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . L O N G _ L O N G _ I N T E G E R _ W I D E _ T E X T _ I O --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
with Ada.Wide_Text_IO;
package Ada.Long_Long_Integer_Wide_Text_IO is
new Ada.Wide_Text_IO.Integer_IO (Long_Long_Integer);
|
faelys/natools | Ada | 11,510 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Time_IO provides subprograms to serialize and deserialize times --
-- to and from various String representations. --
------------------------------------------------------------------------------
with Ada.Calendar.Formatting;
package body Natools.Time_IO.RFC_3339 is
---------------------
-- Validity Checks --
---------------------
function Is_Valid_Prefix (Image : String) return Boolean
is (Image (Image'First) in Digit_Character
and then Image (Image'First + 1) in Digit_Character
and then Image (Image'First + 2) in Digit_Character
and then Image (Image'First + 3) in Digit_Character
and then Image (Image'First + 4) = Date_Separator
and then Image (Image'First + 5) in Digit_Character
and then Image (Image'First + 6) in Digit_Character
and then Image (Image'First + 7) = Date_Separator
and then Image (Image'First + 8) in Digit_Character
and then Image (Image'First + 9) in Digit_Character
and then Image (Image'First + 10) = Date_Time_Separator
and then Image (Image'First + 11) in Digit_Character
and then Image (Image'First + 12) in Digit_Character
and then Image (Image'First + 13) = Time_Separator
and then Image (Image'First + 14) in Digit_Character
and then Image (Image'First + 15) in Digit_Character
and then Image (Image'First + 16) = Time_Separator
and then Image (Image'First + 17) in Digit_Character
and then Image (Image'First + 18) in Digit_Character);
function Is_Valid_Time_Zone (Image : String) return Boolean
is (Image (Image'Last - 5) in '+' | '-'
and then Image (Image'Last - 4) in Digit_Character
and then Image (Image'Last - 3) in Digit_Character
and then Image (Image'Last - 2) = Time_Separator
and then Image (Image'Last - 1) in Digit_Character
and then Image (Image'Last) in Digit_Character);
function Is_Valid_Subsecond (Sub_Image : String) return Boolean
is (Sub_Image'Length = 0
or else (Sub_Image'Length >= 2
and then Sub_Image (Sub_Image'First) = Subsecond_Separator
and then (for all I in Sub_Image'First + 1 .. Sub_Image'Last
=> Sub_Image (I) in Digit_Character)));
function Is_Valid (Image : String) return Boolean is
begin
return Image'Length >= 20
and then Is_Valid_Prefix (Image)
and then ((Image (Image'Last) = 'Z'
and then Is_Valid_Subsecond
(Image (Image'First + 19 .. Image'Last - 1)))
or else (Is_Valid_Time_Zone (Image)
and then Is_Valid_Subsecond
(Image (Image'First + 19 .. Image'Last - 6))));
end Is_Valid;
--------------------
-- Time To String --
--------------------
function Image
(Date : Ada.Calendar.Time;
Subsecond_Digits : Natural := 0;
Force_Leap_Second : Boolean := False)
return String is
begin
return Image
(Date,
Ada.Calendar.Time_Zones.UTC_Time_Offset (Date),
Subsecond_Digits,
Force_Leap_Second);
end Image;
function Image
(Date : Ada.Calendar.Time;
Time_Zone : Ada.Calendar.Time_Zones.Time_Offset;
Subsecond_Digits : Natural := 0;
Force_Leap_Second : Boolean := False)
return String
is
function Subsecond_Image
(Subsecond : Ada.Calendar.Formatting.Second_Duration)
return String;
function Time_Zone_Image return String;
function Subsecond_Image
(Subsecond : Ada.Calendar.Formatting.Second_Duration)
return String
is
Remaining : Duration := Subsecond;
Number : Digit_Number;
N : Natural;
begin
if Subsecond_Digits = 0 then
return "";
end if;
return Result : String (1 .. Subsecond_Digits + 1) do
Result (1) := Subsecond_Separator;
for I in 2 .. Subsecond_Digits + 1 loop
Remaining := Remaining * 10;
N := Natural (Remaining);
if Duration (N) > Remaining then
Number := N - 1;
else
Number := N;
end if;
Remaining := Remaining - Duration (Number);
Result (I) := Image (Number);
end loop;
end return;
end Subsecond_Image;
function Time_Zone_Image return String is
use type Ada.Calendar.Time_Zones.Time_Offset;
begin
if Time_Zone = 0 then
return "Z";
else
declare
Hour : constant Ada.Calendar.Time_Zones.Time_Offset
:= (abs Time_Zone) / 60;
Minute : constant Ada.Calendar.Time_Zones.Time_Offset
:= (abs Time_Zone) mod 60;
Sign : Character;
begin
if Time_Zone < 0 then
Sign := '-';
else
Sign := '+';
end if;
return String'(Sign,
Image (Digit_Number (Hour / 10)),
Image (Digit_Number (Hour mod 10)),
Time_Separator,
Image (Digit_Number (Minute / 10)),
Image (Digit_Number (Minute mod 10)));
end;
end if;
end Time_Zone_Image;
Year : Ada.Calendar.Year_Number;
Month : Ada.Calendar.Month_Number;
Day : Ada.Calendar.Day_Number;
Hour : Ada.Calendar.Formatting.Hour_Number;
Minute : Ada.Calendar.Formatting.Minute_Number;
Second : Ada.Calendar.Formatting.Second_Number;
Subsecond : Ada.Calendar.Formatting.Second_Duration;
Leap_Second : Boolean;
Used_Second : Natural;
begin
Ada.Calendar.Formatting.Split
(Date,
Year, Month, Day,
Hour, Minute, Second,
Subsecond,
Leap_Second,
Time_Zone);
if Leap_Second or Force_Leap_Second then
pragma Assert (Second = 59);
Used_Second := 60;
else
Used_Second := Second;
end if;
return
(Image (Year / 1000),
Image ((Year / 100) mod 10),
Image ((Year / 10) mod 10),
Image (Year mod 10),
Date_Separator,
Image (Month / 10),
Image (Month mod 10),
Date_Separator,
Image (Day / 10),
Image (Day mod 10),
Date_Time_Separator,
Image (Hour / 10),
Image (Hour mod 10),
Time_Separator,
Image (Minute / 10),
Image (Minute mod 10),
Time_Separator,
Image (Used_Second / 10),
Image (Used_Second mod 10))
& Subsecond_Image (Subsecond)
& Time_Zone_Image;
end Image;
--------------------
-- String To Time --
--------------------
function Value (Image : String) return Ada.Calendar.Time is
Result : Ada.Calendar.Time;
Discarded : Ada.Calendar.Time_Zones.Time_Offset;
begin
Value (Image, Result, Discarded);
return Result;
end Value;
procedure Value
(Image : in String;
Date : out Ada.Calendar.Time;
Time_Zone : out Ada.Calendar.Time_Zones.Time_Offset)
is
Discarded : Boolean;
begin
Value (Image, Date, Time_Zone, Discarded);
end Value;
procedure Value
(Image : in String;
Date : out Ada.Calendar.Time;
Time_Zone : out Ada.Calendar.Time_Zones.Time_Offset;
Leap_Second : out Boolean)
is
Year : Ada.Calendar.Year_Number;
Month : Ada.Calendar.Month_Number;
Day : Ada.Calendar.Day_Number;
Hour : Ada.Calendar.Formatting.Hour_Number;
Minute : Ada.Calendar.Formatting.Minute_Number;
Second : Ada.Calendar.Formatting.Second_Number;
Subsecond : Ada.Calendar.Formatting.Second_Duration := 0.0;
begin
Year := Natural'Value (Image (Image'First .. Image'First + 3));
Month := Natural'Value (Image (Image'First + 5 .. Image'First + 6));
Day := Natural'Value (Image (Image'First + 8 .. Image'First + 9));
Hour := Natural'Value (Image (Image'First + 11 .. Image'First + 12));
Minute := Natural'Value
(Image (Image'First + 14 .. Image'First + 15));
declare
Number : constant Natural
:= Natural'Value (Image (Image'First + 17 .. Image'First + 18));
begin
if Number = 60 then
Leap_Second := True;
Second := 59;
else
Leap_Second := False;
Second := Number;
end if;
end;
if Image (Image'First + 19) = Subsecond_Separator then
declare
I : Positive := Image'First + 20;
Current : Duration := 0.1;
begin
while Image (I) in Digit_Character loop
Subsecond := Subsecond + Current
* (Character'Pos (Image (I)) - Character'Pos ('0'));
Current := Current / 10;
I := I + 1;
end loop;
end;
end if;
if Image (Image'Last) = 'Z' then
Time_Zone := 0;
else
Time_Zone := Ada.Calendar.Time_Zones.Time_Offset
(Natural'Value (Image (Image'Last - 4 .. Image'Last - 3)) * 60
+ Natural'Value (Image (Image'Last - 1 .. Image'Last)));
case Image (Image'Last - 5) is
when '-' =>
Time_Zone := Ada.Calendar.Time_Zones."-" (Time_Zone);
when '+' =>
null;
when others =>
raise Constraint_Error
with "Invalid time zone separator in RFC 3339 date";
end case;
end if;
if Leap_Second then
begin
Date := Ada.Calendar.Formatting.Time_Of
(Year, Month, Day,
Hour, Minute, Second,
Subsecond, True, Time_Zone);
return;
exception
when Ada.Calendar.Time_Error =>
null;
end;
end if;
Date := Ada.Calendar.Formatting.Time_Of
(Year, Month, Day,
Hour, Minute, Second,
Subsecond, False, Time_Zone);
end Value;
end Natools.Time_IO.RFC_3339;
|
MinimSecure/unum-sdk | Ada | 773 | ads | -- Copyright 2012-2019 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/>.
package IO is
procedure Put_Line (S : String);
end IO;
|
reznikmm/matreshka | Ada | 3,709 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Mime_Type_Attributes is
pragma Preelaborate;
type ODF_Draw_Mime_Type_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Mime_Type_Attribute_Access is
access all ODF_Draw_Mime_Type_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Mime_Type_Attributes;
|
persan/A-gst | Ada | 9,642 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstbasesink_h;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with glib;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_app_gstappsink_h is
-- unsupported macro: GST_TYPE_APP_SINK (gst_app_sink_get_type())
-- arg-macro: function GST_APP_SINK (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_SINK,GstAppSink);
-- arg-macro: function GST_APP_SINK_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_SINK,GstAppSinkClass);
-- arg-macro: function GST_IS_APP_SINK (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_SINK);
-- arg-macro: function GST_IS_APP_SINK_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_SINK);
-- arg-macro: function GST_APP_SINK_CAST (obj)
-- return (GstAppSink*)(obj);
-- GStreamer
-- * Copyright (C) 2007 David Schleef <[email protected]>
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- Since 0.10.23
type GstAppSink;
type u_GstAppSink_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstAppSink is u_GstAppSink; -- gst/app/gstappsink.h:42
type GstAppSinkClass;
type u_GstAppSinkClass_u_gst_reserved_array is array (0 .. 1) of System.Address;
--subtype GstAppSinkClass is u_GstAppSinkClass; -- gst/app/gstappsink.h:43
-- skipped empty struct u_GstAppSinkPrivate
-- skipped empty struct GstAppSinkPrivate
--*
-- * GstAppSinkCallbacks:
-- * @eos: Called when the end-of-stream has been reached. This callback
-- * is called from the steaming thread.
-- * @new_preroll: Called when a new preroll buffer is available.
-- * This callback is called from the steaming thread.
-- * The new preroll buffer can be retrieved with
-- * gst_app_sink_pull_preroll() either from this callback
-- * or from any other thread.
-- * @new_buffer: Called when a new buffer is available.
-- * This callback is called from the steaming thread.
-- * The new buffer can be retrieved with
-- * gst_app_sink_pull_buffer() either from this callback
-- * or from any other thread.
-- * @new_buffer_list: Called when a new bufferlist is available.
-- * This callback is called from the steaming thread.
-- * The new bufferlist can be retrieved with
-- * gst_app_sink_pull_buffer_list() either from this callback
-- * or from any other thread.
-- *
-- * A set of callbacks that can be installed on the appsink with
-- * gst_app_sink_set_callbacks().
-- *
-- * Since: 0.10.23
--
type GstAppSinkCallbacks_u_gst_reserved_array is array (0 .. 2) of System.Address;
type GstAppSinkCallbacks is record
eos : access procedure (arg1 : access GstAppSink; arg2 : System.Address); -- gst/app/gstappsink.h:72
new_preroll : access function (arg1 : access GstAppSink; arg2 : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/app/gstappsink.h:73
new_buffer : access function (arg1 : access GstAppSink; arg2 : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/app/gstappsink.h:74
new_buffer_list : access function (arg1 : access GstAppSink; arg2 : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/app/gstappsink.h:75
u_gst_reserved : GstAppSinkCallbacks_u_gst_reserved_array; -- gst/app/gstappsink.h:78
end record;
pragma Convention (C_Pass_By_Copy, GstAppSinkCallbacks); -- gst/app/gstappsink.h:79
-- skipped anonymous struct anon_370
--< private >
type GstAppSink is record
basesink : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstbasesink_h.GstBaseSink; -- gst/app/gstappsink.h:83
priv : System.Address; -- gst/app/gstappsink.h:86
u_gst_reserved : u_GstAppSink_u_gst_reserved_array; -- gst/app/gstappsink.h:89
end record;
pragma Convention (C_Pass_By_Copy, GstAppSink); -- gst/app/gstappsink.h:81
--< private >
--< private >
type GstAppSinkClass is record
basesink_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstbasesink_h.GstBaseSinkClass; -- gst/app/gstappsink.h:94
eos : access procedure (arg1 : access GstAppSink); -- gst/app/gstappsink.h:97
new_preroll : access procedure (arg1 : access GstAppSink); -- gst/app/gstappsink.h:98
new_buffer : access procedure (arg1 : access GstAppSink); -- gst/app/gstappsink.h:99
pull_preroll : access function (arg1 : access GstAppSink) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/app/gstappsink.h:102
pull_buffer : access function (arg1 : access GstAppSink) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/app/gstappsink.h:103
new_buffer_list : access function (arg1 : access GstAppSink) return System.Address; -- gst/app/gstappsink.h:106
pull_buffer_list : access function (arg1 : access GstAppSink) return System.Address; -- gst/app/gstappsink.h:107
u_gst_reserved : u_GstAppSinkClass_u_gst_reserved_array; -- gst/app/gstappsink.h:110
end record;
pragma Convention (C_Pass_By_Copy, GstAppSinkClass); -- gst/app/gstappsink.h:92
-- signals
-- actions
-- ABI added
--< private >
function gst_app_sink_get_type return GLIB.GType; -- gst/app/gstappsink.h:113
pragma Import (C, gst_app_sink_get_type, "gst_app_sink_get_type");
procedure gst_app_sink_set_caps (appsink : access GstAppSink; caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/app/gstappsink.h:115
pragma Import (C, gst_app_sink_set_caps, "gst_app_sink_set_caps");
function gst_app_sink_get_caps (appsink : access GstAppSink) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/app/gstappsink.h:116
pragma Import (C, gst_app_sink_get_caps, "gst_app_sink_get_caps");
function gst_app_sink_is_eos (appsink : access GstAppSink) return GLIB.gboolean; -- gst/app/gstappsink.h:118
pragma Import (C, gst_app_sink_is_eos, "gst_app_sink_is_eos");
procedure gst_app_sink_set_emit_signals (appsink : access GstAppSink; emit : GLIB.gboolean); -- gst/app/gstappsink.h:120
pragma Import (C, gst_app_sink_set_emit_signals, "gst_app_sink_set_emit_signals");
function gst_app_sink_get_emit_signals (appsink : access GstAppSink) return GLIB.gboolean; -- gst/app/gstappsink.h:121
pragma Import (C, gst_app_sink_get_emit_signals, "gst_app_sink_get_emit_signals");
procedure gst_app_sink_set_max_buffers (appsink : access GstAppSink; max : GLIB.guint); -- gst/app/gstappsink.h:123
pragma Import (C, gst_app_sink_set_max_buffers, "gst_app_sink_set_max_buffers");
function gst_app_sink_get_max_buffers (appsink : access GstAppSink) return GLIB.guint; -- gst/app/gstappsink.h:124
pragma Import (C, gst_app_sink_get_max_buffers, "gst_app_sink_get_max_buffers");
procedure gst_app_sink_set_drop (appsink : access GstAppSink; drop : GLIB.gboolean); -- gst/app/gstappsink.h:126
pragma Import (C, gst_app_sink_set_drop, "gst_app_sink_set_drop");
function gst_app_sink_get_drop (appsink : access GstAppSink) return GLIB.gboolean; -- gst/app/gstappsink.h:127
pragma Import (C, gst_app_sink_get_drop, "gst_app_sink_get_drop");
function gst_app_sink_pull_preroll (appsink : access GstAppSink) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/app/gstappsink.h:129
pragma Import (C, gst_app_sink_pull_preroll, "gst_app_sink_pull_preroll");
function gst_app_sink_pull_buffer (appsink : access GstAppSink) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/app/gstappsink.h:130
pragma Import (C, gst_app_sink_pull_buffer, "gst_app_sink_pull_buffer");
function gst_app_sink_pull_buffer_list (appsink : access GstAppSink) return System.Address; -- gst/app/gstappsink.h:131
pragma Import (C, gst_app_sink_pull_buffer_list, "gst_app_sink_pull_buffer_list");
procedure gst_app_sink_set_callbacks
(appsink : access GstAppSink;
callbacks : access GstAppSinkCallbacks;
user_data : System.Address;
notify : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify); -- gst/app/gstappsink.h:133
pragma Import (C, gst_app_sink_set_callbacks, "gst_app_sink_set_callbacks");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_app_gstappsink_h;
|
reznikmm/matreshka | Ada | 4,240 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body League.JSON.Values.Internals is
------------
-- Create --
------------
function Create
(Data : not null Matreshka.JSON_Types.Shared_JSON_Value_Access)
return League.JSON.Values.JSON_Value is
begin
Matreshka.JSON_Types.Reference (Data);
return (Ada.Finalization.Controlled with Data => Data);
end Create;
--------------
-- Internal --
--------------
function Internal
(Self : League.JSON.Values.JSON_Value)
return not null Matreshka.JSON_Types.Shared_JSON_Value_Access is
begin
return Self.Data;
end Internal;
----------
-- Wrap --
----------
function Wrap
(Data : not null Matreshka.JSON_Types.Shared_JSON_Value_Access)
return League.JSON.Values.JSON_Value is
begin
return (Ada.Finalization.Controlled with Data => Data);
end Wrap;
end League.JSON.Values.Internals;
|
MatrixMike/AdaDemo1 | Ada | 1,974 | adb | with Ada.Text_IO;
use Ada.Text_IO;
procedure adademo2 is
type Day_type is range 1 .. 31;
type Month_type is range 1 .. 12;
type Year_type is range 1800 .. 2100;
type Hours is mod 24;
type Weekday is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
type Date is
record
Day : Day_type;
Month : Month_type;
Year : Year_type;
end record;
subtype Working_Hours is Hours range 0 .. 12; -- at most 12 Hours to work a day
subtype Working_Day is Weekday range Monday .. Friday; -- Days to work
--begin
--Work_Load: constant array(Working_Day) of Working_Hours -- implicit type declaration
-- := (Friday => 6, Monday => 4, others => 10); -- lookup table for working hours with initialization
-- while a is not equal to b, loop.
--while a /= b loop
-- Ada.Text_IO.Put_Line ("Waiting");
--end loop;
--make into a procedure or function
--if a > b then
-- Ada.Text_IO.Put_Line ("Condition met");
--else
-- Ada.Text_IO.Put_Line ("Condition not met");
--end if;
procedure testCase (i: Natural) is
begin
case i is
when 0 => Ada.Text_IO.Put ("zero");
when 1 => Ada.Text_IO.Put ("one");
when 2 => Ada.Text_IO.Put ("two");
-- case statements have to cover all possible cases:
when others => Ada.Text_IO.Put ("none of the above");
end case;
end testCase;
procedure forLoop() is
begin
for i in 1 .. 10 loop
Ada.Text_IO.Put ("Iteration: ");
Ada.Text_IO.Put (i);
Ada.Text_IO.Put_Line;
end loop;
end forLoop;
loop
a := a + 1;
exit when a = 10;
end loop;
for aWeekday in Weekday'Range loop -- loop over an enumeration
Put_Line ( Weekday'Image(aWeekday) ); -- output string representation of an enumeration
if aWeekday in Working_Day then -- check of a subtype of an enumeration
Put_Line ( " to work for " &
Working_Hours'Image (Work_Load(aWeekday)) ); -- access into a lookup table
end if;
end loop;
end AdaDemo2;
|
charlie5/lace | Ada | 55,053 | adb | with
gel.Events,
physics.Object,
physics.Forge,
openGL.Renderer.lean,
lace.Response,
ada.Text_IO,
ada.Exceptions,
ada.unchecked_Deallocation,
ada.Containers.hashed_Sets;
package body gel.World
is
use gel.Sprite,
linear_Algebra_3D,
-- lace.Event,
ada.Exceptions,
ada.Text_IO;
procedure log (Message : in String) renames ada.Text_IO.put_Line;
---------
--- Forge
--
procedure free (Self : in out View)
is
procedure deallocate is new ada.unchecked_Deallocation (Item'Class, View);
begin
deallocate (Self);
end free;
procedure free is new ada.unchecked_Deallocation (lace.Any.limited_item'Class, Any_limited_view);
procedure define (Self : in out Item'Class; Name : in String;
Id : in world_Id;
space_Kind : in physics.space_Kind;
Renderer : access openGL.Renderer.lean.item'Class);
overriding
procedure destroy (Self : in out Item)
is
begin
-- Free record components.
--
physics.Space.free (Self.physics_Space);
lace.Subject_and_deferred_Observer.item (Self).destroy; -- Destroy base class.
lace.Subject_and_deferred_Observer.free (Self.local_Subject_and_deferred_Observer);
end destroy;
function local_Observer (Self : in Item) return lace.Observer.view
is
begin
return lace.Observer.view (Self.local_Subject_and_deferred_Observer);
end local_Observer;
function local_Subject (Self : in Item) return lace.Subject.view
is
begin
return lace.Subject.view (Self.local_Subject_and_deferred_Observer);
end local_Subject;
function Id (Self : in Item) return world_Id
is
begin
return Self.Id;
end Id;
function to_Sprite (the_Pair : in remote.World.sprite_model_Pair;
the_Models : in Id_Maps_of_Model .Map;
the_physics_Models : in Id_Maps_of_physics_Model.Map;
the_World : in gel.World.view) return gel.Sprite.view
is
the_graphics_Model : access openGL .Model.item'Class;
the_physics_Model : access physics.Model.item'Class;
the_Sprite : gel.Sprite.view;
use openGL;
begin
the_graphics_Model := openGL .Model.view (the_Models .Element (the_Pair.graphics_Model_Id));
the_physics_Model := physics.Model.view (the_physics_Models.Element (the_Pair. physics_Model_Id));
the_Sprite := gel.Sprite.forge.new_Sprite ("Sprite" & the_Pair.sprite_Id'Image,
sprite.World_view (the_World),
get_Translation (the_Pair.Transform),
the_graphics_Model,
the_physics_Model,
owns_Graphics => False,
owns_Physics => False,
is_Kinematic => the_Pair.Mass /= 0.0);
the_Sprite.Id_is (Now => the_Pair.sprite_Id);
the_Sprite.is_Visible (Now => the_Pair.is_Visible);
the_Sprite.Site_is (get_Translation (the_Pair.Transform));
the_Sprite.Spin_is (get_Rotation (the_Pair.Transform));
the_Sprite.desired_Dynamics_are (Site => the_Sprite.Site,
Spin => to_Quaternion (get_Rotation (the_Sprite.Transform)));
return the_Sprite;
end to_Sprite;
--------------------------------
--- 'create_new_Sprite' Response
--
type create_new_Sprite is new lace.Response.item with
record
World : gel.World.view;
Models : access id_Maps_of_model .Map;
physics_Models : access id_Maps_of_physics_model.Map;
end record;
overriding
function Name (Self : in create_new_Sprite) return String;
overriding
procedure respond (Self : in out create_new_Sprite; to_Event : in lace.Event.item'Class)
is
begin
declare
the_Event : constant gel.Events.new_sprite_Event := gel.Events.new_sprite_Event (to_Event);
the_Sprite : constant gel.Sprite.view := to_Sprite (the_Event.Pair,
Self.Models.all,
Self.physics_Models.all,
Self.World);
begin
Self.World.add (the_Sprite, and_children => False);
end;
end respond;
procedure define (Self : in out create_new_Sprite; World : in gel.World.view;
Models : access id_Maps_of_model.Map)
is
begin
Self.World := World;
Self.Models := Models;
end define;
overriding
function Name (Self : in create_new_Sprite) return String
is
pragma Unreferenced (Self);
begin
return "create_new_Sprite";
end Name;
----------
--- Define
--
procedure define (Self : in out Item'Class; Name : in String;
Id : in world_Id;
space_Kind : in physics.space_Kind;
Renderer : access openGL.Renderer.lean.Item'Class)
is
use lace.Subject_and_deferred_Observer.Forge;
begin
Self.local_Subject_and_deferred_Observer := new_Subject_and_Observer (name => Name & " world" & Id'Image);
Self.Id := Id;
Self.space_Kind := space_Kind;
Self.Renderer := Renderer;
Self.physics_Space := physics.Forge.new_Space (space_Kind);
end define;
-------------------------
--- all_sprite_Transforms
--
function to_Integer is new ada.unchecked_Conversion (gel.Sprite.view, Integer);
protected
body all_sprite_Transforms
is
procedure add (the_Sprite : in Sprite.view;
Transform : in Matrix_4x4)
is
begin
sprite_Map_of_transforms.insert (the_Sprite, Transform);
end add;
procedure set (To : in sprite_Maps_of_transforms.Map)
is
begin
sprite_Map_of_transforms := To;
end set;
function fetch return sprite_Maps_of_transforms.Map
is
begin
return sprite_Map_of_transforms;
end Fetch;
end all_sprite_Transforms;
-----------------
--- Duration_safe
--
protected
body Duration_safe
is
procedure Duration_is (Now : in standard.Duration)
is
begin
the_Duration := Now;
end Duration_is;
function Duration return standard.Duration
is
begin
return the_Duration;
end Duration;
end Duration_safe;
--------------------
--- Breakable Joints
--
protected body safe_joint_Set
is
function is_Empty return Boolean
is
begin
return the_Count = 0;
end is_Empty;
procedure add (the_Joint : in gel.Joint.view)
is
begin
the_Count := the_Count + 1;
Set (the_Count) := the_Joint;
end add;
procedure fetch (To : out safe_Joints;
Count : out Natural)
is
begin
To (1 .. the_Count) := Set (1 .. the_Count);
Count := the_Count;
the_Count := 0;
end Fetch;
end safe_joint_Set;
--------------
--- Collisions
--
task
type impact_Responder
is
entry start (the_World : in gel.World.view;
Filter : in impact_Filter;
Response : in impact_Response;
responses_Done : in Signal_Object_view);
entry stop;
entry respond; -- Filter and do responses.
end impact_Responder;
type impact_Responder_view is access all impact_Responder;
procedure free (Self : in out impact_Responder_view)
is
procedure deallocate is new ada.unchecked_Deallocation (impact_Responder, impact_Responder_view);
begin
deallocate (Self);
end free;
type filtered_impact_Response is
record
Filter : impact_Filter;
Response : impact_Response;
Responder : impact_Responder_view;
responses_Done : signal_Object_view := new Signal_Object;
end record;
function Hash (Self : in filtered_impact_Response) return ada.Containers.Hash_type;
package filtered_impact_Response_Sets is new ada.Containers.hashed_Sets (filtered_impact_Response,
Hash, "=");
protected body Signal_Object
is
entry Wait
when Open
is
begin
Open := False;
end Wait;
procedure Signal
is
begin
Open := True;
end Signal;
end Signal_Object;
function local_graphics_Models (Self : in Item) return id_Maps_of_model.Map
is
begin
return Self.graphics_Models;
end local_graphics_Models;
function local_physics_Models (Self : in Item) return id_Maps_of_physics_model.Map
is
begin
return Self.physics_Models;
end local_physics_Models;
--------------
--- Attributes
--
function space_Kind (Self : in Item) return physics.space_Kind
is
begin
return Self.space_Kind;
end space_Kind;
function Space (Self : in Item) return physics.Space.view
is
begin
return Self.physics_Space;
end Space;
procedure update_Bounds (Self : in out Item; of_Sprite : in gel.Sprite.view)
is
begin
null; -- TODO
-- Self.physics_Engine.update_Bounds (of_Sprite.Solid);
end update_Bounds;
procedure update_Site (Self : in out Item; of_Sprite : in gel.Sprite.view; -- TODO: Probably obsolete.
To : in Vector_3)
is
begin
of_Sprite.Solid.Site_is (To);
-- Self.physics_Engine.update_Site (of_Sprite.Solid, To);
end update_Site;
procedure set_Speed (Self : in out Item; of_Sprite : in gel.Sprite.view; -- TODO: Probably obsolete.
To : in Vector_3)
is
begin
null;
-- Self.physics_Engine.set_Speed (of_Sprite.Solid, To);
end set_Speed;
procedure set_xy_Spin (Self : in out Item; of_Sprite : in gel.Sprite.view; -- TODO: Probably obsolete.
To : in Radians)
is
begin
of_Sprite.Solid.xy_Spin_is (To);
-- Self.physics_Engine.set_xy_Spin (of_Sprite.Solid, To);
end set_xy_Spin;
procedure update_Scale (Self : in out Item; of_Sprite : in gel.Sprite.view; -- TODO: Probably obsolete.
To : in Vector_3)
is
begin
null;
-- Self.physics_Engine.update_Scale (of_Sprite.Solid, To);
-- Self.physics_Engine.add (std_Physics.Engine.Command' (Kind => scale_Object,
-- Sprite => the_Command.Sprite.Solid,
-- Scale => the_Command.Scale));
end update_Scale;
procedure apply_Force (Self : in out Item; to_Sprite : in gel.Sprite.view; -- TODO: Probably obsolete.
Force : in Vector_3)
is
begin
null;
-- Self.physics_Engine.apply_Force (to_Sprite.Solid, Force);
end apply_Force;
function Age (Self : in Item) return Duration
is
begin
return Self.Age;
end Age;
procedure Age_is (Self : in out Item; Now : in Duration)
is
begin
Self.Age := Now;
end Age_is;
procedure Gravity_is (Self : in out Item; Now : in Vector_3)
is
begin
Self.physics_Space.Gravity_is (Now);
end Gravity_is;
function cast_Ray (Self : in Item; From, To : in Vector_3) return ray_Collision
is
use type physics.Object.view;
physics_Collision : constant physics.Space.ray_Collision := Self.physics_Space.cast_Ray (From, To);
begin
if physics_Collision.near_Object = null
then
return ray_Collision' (near_Sprite => null,
others => <>);
else
return ray_Collision' (to_GEL (physics_Collision.near_Object),
physics_Collision.hit_Fraction,
physics_Collision.Normal_world,
physics_Collision. Site_world);
end if;
end cast_Ray;
--------------
--- Collisions
--
function manifold_Count (Self : in Item) return Natural
is
begin
return Self.manifold_Count;
end manifold_Count;
function Manifold (Self : in Item; Index : in Positive) return a_Manifold
is
begin
return Self.Manifolds (Index);
end Manifold;
function Manifolds (Self : in Item) return Manifold_array
is
begin
return Self.Manifolds (1 .. Self.manifold_Count);
end Manifolds;
-----------
--- Sprites
--
function new_sprite_Id (Self : access Item) return sprite_Id
is
begin
Self.last_used_sprite_Id := Self.last_used_sprite_Id + 1;
return Self.last_used_sprite_Id;
end new_sprite_Id;
procedure destroy (Self : in out Item; the_Sprite : in gel.Sprite.view)
is
begin
null; -- TODO
-- Self.Commands.add ((Kind => destroy_Sprite,
-- Sprite => the_Sprite));
end destroy;
function free_sprite_Set (Self : access Item) return gel.Sprite.views
is
prior_set_Index : Integer;
begin
if Self.current_free_Set = 1
then prior_set_Index := 2;
else prior_set_Index := 1;
end if;
declare
the_Set : constant gel.Sprite.views
:= Self.free_Sets (prior_set_Index).Sprites (1 .. Self.free_Sets (prior_set_Index).Count);
begin
Self.free_Sets (prior_set_Index).Count := 0;
Self.current_free_Set := prior_set_Index;
return the_Set;
end;
end free_sprite_Set;
function fetch_Sprite (Self : in out Item'Class; Id : in sprite_Id) return gel.Sprite.view
is
begin
return Self.all_Sprites.fetch.Element (Id);
end fetch_Sprite;
procedure set_Scale (Self : in out Item; for_Sprite : in gel.Sprite.view;
To : in Vector_3)
is
Pad : constant Vector_3 := for_Sprite.Site;
begin
Self.rid (for_Sprite, and_children => False);
for_Sprite.Scale_is (To);
Self.add (for_Sprite, and_children => False);
for_Sprite.Site_is (Pad); -- TODO: Fix this hack !
end set_Scale;
function sprite_Transforms (Self : in out Item'Class) return sprite_transform_Pairs
is
use id_Maps_of_sprite;
all_Sprites : constant id_Maps_of_sprite.Map := Self.all_Sprites.fetch;
Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First;
the_sprite_Transforms : sprite_transform_Pairs (1 .. Natural (all_Sprites.Length)) := (others => <>);
Count : Natural := 0;
the_Sprite : Sprite.view;
begin
while has_Element (Cursor)
loop
the_Sprite := Element (Cursor);
if not the_Sprite.is_Destroyed
then
Count := Count + 1;
the_sprite_Transforms (Count) := (Sprite => the_Sprite,
Transform => the_Sprite.Transform);
end if;
next (Cursor);
end loop;
return the_sprite_Transforms (1 .. Count);
end sprite_Transforms;
----------
--- Joints
--
procedure destroy (Self : in out Item; the_Joint : in gel.Joint.view)
is
begin
null; -- TODO
-- Self.Commands.add ((kind => free_Joint,
-- sprite => null,
-- joint => the_Joint));
end destroy;
procedure set_local_Anchor_on_A (Self : in out Item; for_Joint : in gel.Joint.view;
To : in Vector_3)
is
begin
null; -- TODO
-- Self.physics_Engine.set_local_Anchor (for_Joint.Physics.all'Access,
-- to => To,
-- is_Anchor_A => True);
-- the_World.physics_Space.set_Joint_local_Anchor (the_Command.anchor_Joint.Physics.all'Access,
-- the_Command.is_Anchor_A,
-- the_Command.local_Anchor);
--
--
-- Self.Commands.add ((Kind => set_Joint_local_Anchor,
-- Sprite => null,
-- anchor_Joint => for_Joint,
-- is_Anchor_A => True,
-- local_Anchor => To));
end set_local_Anchor_on_A;
procedure set_local_Anchor_on_B (Self : in out Item; for_Joint : in gel.Joint.view;
To : in Vector_3)
is
begin
null; -- TODO
-- Self.physics_Engine.set_local_Anchor (for_Joint.Physics.all'Access,
-- To => To,
-- is_Anchor_A => False);
-- Self.Commands.add ((Kind => set_Joint_local_Anchor,
-- Sprite => null,
-- anchor_Joint => for_Joint,
-- is_Anchor_A => False,
-- local_Anchor => To));
end set_local_anchor_on_B;
-- type graphics_Model_iface_view is access all openGL.remote_Model.item'Class;
-- type graphics_Model_view is access all openGL. Model.item'Class;
--
-- type physics_Model_iface_view is access all Standard.physics.remote.Model.item'Class;
-- type physics_Model_view is access all Standard.physics.Model .item'Class;
procedure add (Self : access Item; the_Sprite : in gel.Sprite.view;
and_Children : in Boolean := False)
is
procedure add_single_Sprite (Single : in out Sprite.item'Class)
is
begin
if Single.Id = null_sprite_Id
then
raise Error with "Null sprite detected.";
end if;
Self.add (Single.graphics_Model);
Self.add (Single. physics_Model);
Single.Solid.user_Data_is (Single'Access);
Single.Solid. Model_is (Single.physics_Model);
if Single.physics_Model.is_Tangible
then
Self.physics_Space.add (physics.Object.view (Single.Solid));
end if;
Item'Class (Self.all).all_Sprites.add (Single'unchecked_Access);
end add_single_Sprite;
begin
pragma assert (the_Sprite.World = Self, "Trying to add sprite to the wrong world."); -- TODO: Use an exception.
if and_Children
then
declare
procedure add_the_Joint (the_Sprite : in out Sprite.item'Class)
is
use type gel.Joint.view;
the_Joint : constant gel.Joint.view := the_Sprite.parent_Joint;
begin
if the_Joint /= null
then
Self.physics_Space.add (the_Joint.Physics.all'Access);
the_Joint.Physics.user_Data_is (the_Joint);
end if;
end add_the_Joint;
begin
the_Sprite.apply (add_single_Sprite'unrestricted_Access);
the_Sprite.apply (add_the_Joint 'unrestricted_Access);
end;
else
add_single_Sprite (the_Sprite.all);
end if;
end add;
procedure rid (Self : in out Item'Class; the_Sprite : in gel.Sprite.view;
and_Children : in Boolean := False)
is
procedure rid_single_Sprite (Single : in out Sprite.item'Class)
is
begin
-- Self.Commands.add ((Kind => rid_Sprite,
-- Sprite => the_Sprite'unchecked_Access,
-- rid_Children => False));
Self.all_Sprites.rid (Single'unchecked_Access); -- TODO: Handle grandchildren and so on.
end rid_single_Sprite;
begin
if and_Children
then
the_Sprite.apply (rid_single_Sprite'unrestricted_Access);
else
rid_single_Sprite (the_Sprite.all);
end if;
end rid;
procedure add (Self : in out Item; the_Model : in openGL.Model.view)
is
begin
if the_Model.Id = null_graphics_model_Id
then
Self.last_used_model_Id := Self.last_used_model_Id + 1;
the_Model.Id_is (Self.last_used_model_Id);
end if;
if not Self.graphics_Models.contains (the_Model.Id)
then
Self.graphics_Models.insert (the_Model.Id, the_Model);
-- Emit a new model event.
--
declare
the_Event : remote.World.new_model_Event;
begin
the_Event.Model := the_Model;
Self.emit (the_Event);
end;
end if;
end add;
procedure add (Self : in out Item; the_Model : in physics.Model.view)
is
begin
if the_Model.Id = Physics.null_model_Id
then
Self.last_used_physics_model_Id := Self.last_used_physics_model_Id + 1;
the_Model.Id_is (Self.last_used_physics_model_Id);
end if;
if not Self.physics_Models.contains (the_Model.Id)
then
Self.physics_Models.insert (the_Model.Id, the_Model);
end if;
end add;
procedure add (Self : in out Item; the_Joint : in gel.Joint.view)
is
begin
Self.physics_Space.add (the_Joint.Physics.all'Access);
the_Joint.Physics.user_Data_is (the_Joint);
end add;
procedure rid (Self : in out Item; the_Joint : in gel.Joint.view)
is
begin
null; -- TODO
-- Self.physics_Engine.rid (the_Joint.Physics.all'Access);
-- Self.Commands.add ((kind => rid_Joint,
-- sprite => null,
-- joint => the_Joint));
end rid;
--------------
--- Operations
--
procedure start (Self : access Item)
is
begin
null;
end start;
--------------------
--- World Mirroring
--
overriding
procedure register (Self : access Item; the_Mirror : in remote.World.view;
Mirror_as_observer : in lace.Observer.view) is null;
overriding
procedure deregister (Self : access Item; the_Mirror : in remote.World.view) is null;
overriding
procedure motion_Updates_are (Self : in Item; Now : in remote.World.motion_Updates) is null;
----------
--- Joints
--
procedure allow_broken_Joints (Self : out Item)
is
begin
Self.broken_joints_Allowed := True;
end allow_broken_Joints;
procedure handle_broken_Joints (Self : in out Item; the_Joints :in Joint.views)
is
begin
for i in the_Joints'Range
loop
begin
if ( the_Joints (i).Sprite_A /= null
and the_Joints (i).Sprite_B /= null)
and then ( not the_Joints (i).Sprite_A.is_Destroyed
and not the_Joints (i).Sprite_B.is_Destroyed)
then
begin
the_Joints (i).Sprite_A.detach (the_Joints (i).Sprite_B);
exception
when no_such_Child =>
put_Line ("handle_broken_Joints: Cannot detach sprite: no_such_Child." );
end;
end if;
exception
when storage_Error =>
put_Line ("handle_broken_Joints: Cannot tell if sprite exists: storage_Error." );
end;
end loop;
end handle_broken_Joints;
procedure evolve (Self : in out Item)
is
begin
Self.Age := Self.Age + evolve_Period;
-- Evolve the physics.
--
Self.physics_Space.evolve (evolve_Period); -- Evolve the physics space.
-- Handle evnts.
--
Self.respond;
Self.local_Subject_and_deferred_Observer.respond;
-- Broken joints.
--
declare
the_Joints : safe_Joints;
Count : Natural;
begin
Self.broken_Joints.fetch (the_Joints, Count);
Self.handle_broken_Joints (the_Joints (1 .. Count));
end;
-- Perform responses to events for all sprites.
--
declare
use id_Maps_of_sprite;
all_Sprites : constant id_Maps_of_sprite.Map := Item'Class (Self).all_Sprites.fetch;
Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First;
the_Sprite : Sprite.view;
begin
while has_Element (Cursor)
loop
the_Sprite := Element (Cursor);
begin
if not the_Sprite.is_Destroyed
then
the_Sprite.respond;
end if;
exception
when E : others =>
new_Line (2);
put_Line ("Error in 'gel.World.evolve' sprite response.");
new_Line;
put_Line (ada.Exceptions.exception_Information (E));
new_Line (2);
end;
next (Cursor);
end loop;
end;
end evolve;
overriding
function graphics_Models (Self : in Item) return remote.World.graphics_Model_Set
is
use id_Maps_of_model;
the_Models : remote.World.graphics_Model_Set;
Cursor : id_Maps_of_model.Cursor := Self.graphics_Models.First;
begin
while has_Element (Cursor)
loop
the_Models.include (Element (Cursor).Id,
Element (Cursor).all);
next (Cursor);
end loop;
return the_Models;
end graphics_Models;
overriding
function physics_Models (Self : in Item) return remote.World.physics_model_Set
is
use id_Maps_of_physics_model;
the_Models : remote.World.physics_model_Set;
Cursor : id_Maps_of_physics_model.Cursor := Self.physics_Models.First;
begin
while has_Element (Cursor)
loop
the_Models.include (Element (Cursor).Id,
Element (Cursor).all);
next (Cursor);
end loop;
return the_Models;
end physics_Models;
overriding
function Sprites (Self : in out Item) return remote.World.sprite_model_Pairs
is
use id_Maps_of_sprite;
all_Sprites : constant id_Maps_of_sprite.Map := Item'Class (Self).all_Sprites.fetch;
Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First;
the_Pairs : remote.World.sprite_model_Pairs (1 .. Natural (all_Sprites.Length));
the_Sprite : Sprite.view;
i : Natural := 0;
begin
while has_Element (Cursor)
loop
i := i + 1;
the_Sprite := Element (Cursor);
the_Pairs (i) := (sprite_Id => the_Sprite.Id,
graphics_model_Id => the_Sprite.graphics_Model.Id,
physics_model_Id => the_Sprite. physics_Model.Id,
Mass => the_Sprite.Mass,
Transform => the_Sprite.Transform,
is_Visible => the_Sprite.is_Visible);
next (Cursor);
end loop;
return the_Pairs;
end Sprites;
--------------
--- Collisions
--
function Hash (Self : in filtered_impact_Response) return ada.Containers.Hash_type
is
use type ada.Containers.Hash_type;
function to_Hash is new ada.unchecked_Conversion (impact_Filter, ada.Containers.Hash_type);
function to_Hash is new ada.unchecked_Conversion (impact_Response, ada.Containers.Hash_type);
begin
return to_Hash (Self.Filter)
+ to_Hash (Self.Response);
end Hash;
procedure add_impact_Response (Self : in out Item; Filter : in impact_Filter;
Response : in impact_Response)
is
begin
null; -- TODO
-- Self.Commands.add ((new_impact_Response,
-- null,
-- Filter,
-- Response));
end add_impact_Response;
task body impact_Responder
is
the_World : gel.World.view;
Done : Boolean := False;
Filters_through : impact_Filter;
the_Response : impact_Response;
the_responses_Done : access Signal_Object;
begin
accept start (the_World : in gel.World.view;
Filter : in impact_Filter;
Response : in impact_Response;
responses_Done : in Signal_Object_view)
do
impact_Responder.the_World := the_World;
Filters_through := Filter;
the_Response := Response;
the_responses_Done := responses_Done;
end start;
loop
begin
select
accept stop
do
Done := True;
end stop;
or
accept respond;
end select;
exit when Done;
-- Filter and call response.
--
for i in 1 .. the_World.manifold_Count
loop
if not the_World.Manifolds (i).Sprites (1).is_Destroyed
and then not the_World.Manifolds (i).Sprites (2).is_Destroyed
and then Filters_through (the_World.Manifolds (i))
then
the_Response (the_World.Manifolds (i),
the_World);
end if;
end loop;
the_responses_Done.signal;
exception
when E : others =>
put_Line ("Exception in impact_Responder.");
put_Line (Exception_Information (E));
the_responses_Done.signal;
end;
end loop;
end impact_Responder;
-----------
-- Testing
--
overriding
procedure kick_Sprite (Self : in out Item; sprite_Id : in gel.sprite_Id)
is
the_Sprite : constant gel.Sprite.view := Item'Class (Self).all_Sprites.fetch.Element (sprite_Id);
begin
the_Sprite.Speed_is ([0.0, 10.0, 0.0]);
end kick_Sprite;
end gel.World;
-- Old engine code left for reference ...
----------
--- Engine
--
-- task body Engine
-- is
-- use type gel.Joint.view,
-- ada.Containers.Count_type;
--
-- Stopped : Boolean := True;
-- Cycle : ada.Containers.Count_type := 0;
-- next_render_Time : ada.Calendar.Time;
--
-- the_filtered_impact_Response_Set : filtered_impact_Response_Sets.Set;
--
-- max_joint_Force,
-- max_joint_Torque : Real := 0.0;
-- procedure free_Sprites
-- is
-- the_free_Sprites : gel.Sprite.views := the_World.free_sprite_Set;
-- begin
-- for i in the_free_Sprites'Range
-- loop
-- log ("Engine is freeing sprite id:" & the_free_Sprites (i).Id'Image);
--
-- if the_free_Sprites (i).owns_Graphics
-- then
-- the_World.Renderer.free (the_free_Sprites (i).Visual.Model);
-- end if;
--
-- gel.Sprite.free (the_free_Sprites (i));
-- end loop;
-- end free_Sprites;
-- procedure free_graphics_Models
-- is
-- use id_Maps_of_model;
-- Cursor : id_Maps_of_model.Cursor := the_World.graphics_Models.First;
-- begin
-- while has_Element (Cursor)
-- loop
-- the_World.Renderer.free (Element (Cursor));
-- next (Cursor);
-- end loop;
-- end free_graphics_Models;
-- procedure evolve
-- is
-- the_sprite_Transforms : sprite_Maps_of_transforms.Map := the_World.all_sprite_Transforms.Fetch;
-- begin
-- Cycle := Cycle + 1;
-- do_engine_Commands:
-- declare
-- the_Commands : World.Commands;
-- Count : Natural;
-- command_Count : array (command_Kind) of Natural := (others => 0);
-- begin
-- the_World.Commands.fetch (the_Commands, Count);
-- for Each in 1 .. Count
-- loop
-- declare
-- use Physics.Engine;
-- the_Command : World.Command renames the_Commands (Each);
-- begin
-- command_Count (the_Command.Kind) := command_Count (the_Command.Kind) + 1;
-- case the_Command.Kind
-- is
-- when scale_Sprite =>
-- the_World.physics_Engine.add (std_Physics.Engine.Command' (Kind => scale_Object,
-- Sprite => the_Command.Sprite.Solid,
-- Scale => the_Command.Scale));
-- the_Command.Sprite.Solid.activate;
-- the_Command.Sprite.Shape.Scale_is (the_Command.Scale);
-- the_Command.Sprite.Solid.Scale_is (the_Command.Scale);
--
-- the_World.physics_Space.update_Bounds (std_physics.Object.view (the_Command.Sprite.Solid));
-- when update_Bounds =>
-- the_World.physics_Space.update_Bounds (std_physics.Object.view (the_Command.Sprite.Solid));
-- when update_Site =>
-- the_World.physics_Engine.update_Site (the_Command.Sprite.Solid,
-- the_Command.Site);
-- std_physics.Object.view (the_Command.Sprite.Solid).Site_is (the_Command.Site);
-- when set_Speed =>
-- std_physics.Object.view (the_Command.Sprite.Solid).Speed_is (the_Command.Speed);
-- when set_xy_Spin =>
-- std_physics.Object.view (the_Command.Sprite.Solid).xy_Spin_is (the_Command.xy_Spin);
-- when add_Sprite =>
-- declare
-- procedure add (the_Sprite : in Sprite.view)
-- is
-- begin
-- if the_Sprite.Id = null_sprite_Id
-- then
-- raise Program_Error;
-- end if;
--
-- the_World.add (the_Sprite.graphics_Model);
-- the_World.add (the_Sprite. physics_Model);
--
-- the_sprite_Transforms.insert (the_Sprite, Identity_4x4);
--
-- the_Sprite.Solid.user_Data_is (the_Sprite);
-- the_Sprite.Solid.Model_is (the_Sprite.physics_Model);
--
-- if the_Sprite.physics_Model.is_Tangible
-- then
-- the_World.physics_Engine.add (physics.Object.view (the_Sprite.Solid));
-- end if;
--
-- the_World.sprite_Count := the_World.sprite_Count + 1;
-- the_World.Sprites (the_World.sprite_Count) := the_Sprite;
-- end add;
--
-- begin
-- add (the_Command.Sprite);
-- end;
-- when rid_Sprite =>
-- declare
-- function find (the_Sprite : in Sprite.view) return Index
-- is
-- begin
-- for i in 1 .. the_World.sprite_Count
-- loop
-- if the_World.Sprites (i) = the_Sprite
-- then
-- return i;
-- end if;
-- end loop;
--
-- raise constraint_Error with "No such sprite in world.";
-- return 0;
-- end find;
--
--
-- procedure rid (the_Sprite : in Sprite.view)
-- is
-- use type physics.Object.view;
-- begin
-- if the_Sprite.Solid /= null
-- then
-- if the_Sprite.physics_Model.is_Tangible
-- then
-- the_World.physics_Engine.rid (the_Sprite.Solid);
-- end if;
--
-- if the_sprite_Transforms.contains (the_Sprite) then
-- the_sprite_Transforms.delete (the_Sprite);
-- end if;
--
-- else
-- raise program_Error;
-- end if;
--
-- declare
-- Id : Index;
-- begin
-- Id := find (the_Sprite);
--
-- if Id <= the_World.sprite_Count
-- then
-- the_World.Sprites (1 .. the_World.sprite_Count - 1)
-- := the_World.Sprites ( 1 .. Id - 1)
-- & the_World.Sprites (Id + 1 .. the_World.sprite_Count);
-- end if;
--
-- the_World.sprite_Count := the_World.sprite_Count - 1;
-- end;
-- end rid;
--
-- begin
-- rid (the_Command.Sprite);
-- end;
-- when apply_Force =>
-- the_Command.Sprite.Solid.apply_Force (the_Command.Force);
-- when destroy_Sprite =>
-- declare
-- the_free_Set : free_Set renames the_World.free_Sets (the_World.current_free_Set);
-- begin
-- the_free_Set.Count := the_free_Set.Count + 1;
-- the_free_Set.Sprites (the_free_Set.Count) := the_Command.Sprite;
-- end;
-- when add_Joint =>
-- the_World.physics_Space.add (the_Command.Joint.Physics.all'Access);
-- the_Command.Joint.Physics.user_Data_is (the_Command.Joint);
-- when rid_Joint =>
-- the_World.physics_Space.rid (the_Command.Joint.Physics.all'Access);
-- when set_Joint_local_Anchor =>
-- the_World.physics_Space.set_Joint_local_Anchor (the_Command.anchor_Joint.Physics.all'Access,
-- the_Command.is_Anchor_A,
-- the_Command.local_Anchor);
-- when free_Joint =>
-- gel.Joint.free (the_Command.Joint);
-- when cast_Ray =>
-- declare
-- function cast_Ray (Self : in Item'Class; From, To : in Vector_3) return ray_Collision
-- is
-- use type physics.Object.view;
--
-- physics_Collision : constant physics.Space.ray_Collision := Self.physics_Space.cast_Ray (From, To);
-- begin
-- if physics_Collision.near_Object = null
-- then
-- return ray_Collision' (near_Sprite => null,
-- others => <>);
-- else
-- return ray_Collision' (to_GEL (physics_Collision.near_Object),
-- physics_Collision.hit_Fraction,
-- physics_Collision.Normal_world,
-- physics_Collision. Site_world);
-- end if;
-- end cast_Ray;
--
-- the_Collision : constant ray_Collision := cast_Ray (the_World.all,
-- the_Command.From,
-- the_Command.To);
-- begin
-- if the_Collision.near_Sprite = null
-- or else the_Collision.near_Sprite.is_Destroyed
-- then
-- free (the_Command.Context);
--
-- else
-- declare
-- no_Params : aliased no_Parameters;
-- the_Event : raycast_collision_Event'Class
-- := raycast_collision_Event_dispatching_Constructor (the_Command.event_Kind,
-- no_Params'Access);
-- begin
-- the_Event.Context := the_Command.Context;
-- the_Event.near_Sprite := the_Collision.near_Sprite;
-- the_Event.Site_world := the_Collision.Site_world;
--
-- the_Command.Observer.receive (the_Event, from_Subject => the_World.Name);
-- end;
-- end if;
-- end;
-- when new_impact_Response =>
-- declare
-- the_impact_Responder : constant impact_Responder_view := new impact_Responder;
-- the_responses_done_Signal : constant Signal_Object_view := new signal_Object;
-- begin
-- the_filtered_impact_Response_Set.insert ((the_Command.Filter,
-- the_Command.Response,
-- the_impact_Responder,
-- the_responses_done_Signal));
-- the_impact_Responder.start (the_World,
-- the_Command.Filter,
-- the_Command.Response,
-- the_responses_done_Signal);
-- end;
-- when set_Gravity =>
-- the_World.physics_Space.Gravity_is (the_Command.Gravity);
-- end case;
-- end;
-- end loop;
-- end do_engine_Commands;
-- Evolve the physics.
--
-- if not the_World.is_a_Mirror
-- then
-- the_World.physics_Space.evolve (by => 1.0 / 60.0); -- Evolve the world.
-- end if;
-- -- Contact Manifolds
-- --
-- declare
-- Count : Natural := 0;
-- begin
-- for i in 1 .. the_World.physics_Space.manifold_Count
-- loop
-- declare
-- function to_Integer is new ada.unchecked_Conversion (physics_Object_view, Integer);
--
-- the_physics_Manifold : constant physics.Space.a_Manifold
-- := the_World.physics_Space.Manifold (i);
-- begin
-- Count := Count + 1;
-- the_World.Manifolds (Count) := (sprites => (to_GEL (the_physics_Manifold.Objects (1)),
-- to_GEL (the_physics_Manifold.Objects (2))),
-- contact => (Site => the_physics_Manifold.Contact.Site));
-- exception
-- when others =>
-- put_Line ("Error in 'gel.world.Engine.evolve' contact manifolds.");
-- Count := Count - 1;
-- end;
-- end loop;
--
-- the_World.manifold_Count := the_World.physics_Space.manifold_Count;
--
-- exception
-- when E : others =>
-- put_Line ("'gel.World.local.Engine.Contact Manifolds' has an unhandled exception ...");
-- put_Line (exception_Information (E));
-- end;
-- -- For each registered impact response, tell the associated responder task to respond.
-- --
-- declare
-- use filtered_impact_Response_Sets;
-- Cursor : filtered_impact_Response_Sets.Cursor := the_filtered_impact_Response_Set.First;
--
-- begin
-- while has_Element (Cursor)
-- loop
-- Element (Cursor).Responder.respond;
-- next (Cursor);
-- end loop;
--
-- -- Wait for all responders to complete.
-- --
-- Cursor := the_filtered_impact_Response_Set.First;
--
-- while has_Element (Cursor)
-- loop
-- select
-- Element (Cursor).responses_Done.wait;
-- or
-- delay Duration'Last;
-- end select;
--
-- next (Cursor);
-- end loop;
--
-- exception
-- when E : others =>
-- put_Line ("'gel.World.local.Engine.impact response' has an unhandled exception ...");
-- put_Line (exception_Information (E));
-- end;
-- -- Update sprite transforms.
-- --
-- declare
-- use sprite_Maps_of_transforms;
--
-- Cursor : sprite_Maps_of_transforms.Cursor := the_sprite_Transforms.First;
-- the_Sprite : gel.Sprite.view;
-- begin
-- while has_Element (Cursor)
-- loop
-- the_Sprite := Key (Cursor);
-- declare
-- the_Transform : constant Matrix_4x4 := the_Sprite.Solid.get_Dynamics;
-- begin
-- the_sprite_Transforms.replace_Element (Cursor, the_Transform);
-- end;
-- next (Cursor);
-- end loop;
-- end;
--
-- the_World.all_sprite_Transforms.set (To => the_sprite_Transforms);
--
-- free_Sprites;
-- end evolve;
-- use type physics.Space.view;
--
-- begin
-- accept start (space_Kind : in physics.space_Kind)
-- do
-- Stopped := False;
-- the_World.physics_Space := physics.Forge.new_Space (space_Kind);
-- end start;
-- next_render_Time := ada.Calendar.Clock;
-- loop
-- select
-- accept stop
-- do
-- Stopped := True;
--
-- -- Add 'destroy' commands for all sprites.
-- --
-- declare
-- the_Sprites : Sprite.views renames the_World.Sprites;
-- begin
-- for i in 1 .. the_World.sprite_Count
-- loop
-- the_Sprites (i).destroy (and_Children => False);
-- end loop;
-- end;
-- Evolve the world til there are no commands left.
--
-- while not the_World.Commands.is_Empty
-- loop
-- evolve;
-- end loop;
-- Stop all impact responders tasks.
--
-- declare
-- use filtered_impact_Response_Sets;
--
-- procedure free is new ada.unchecked_Deallocation (Signal_Object,
-- Signal_Object_view);
--
-- Cursor : filtered_impact_Response_Sets.Cursor := the_filtered_impact_Response_Set.First;
--
-- the_Responder : impact_Responder_view;
-- the_Signal : Signal_Object_view;
--
-- begin
-- while has_Element (Cursor)
-- loop
-- the_Signal := Element (Cursor).responses_Done;
-- the_Responder := Element (Cursor).Responder;
-- the_Responder.stop;
--
-- while not the_Responder.all'Terminated
-- loop
-- delay 0.01;
-- end loop;
--
-- free (the_Responder);
-- free (the_Signal);
--
-- next (Cursor);
-- end loop;
-- end;
-- Free both sets of freeable sprites.
--
-- free_Sprites;
-- free_Sprites;
-- end stop;
-- exit when Stopped;
--
-- or
-- accept reset_Age
-- do
-- the_World.Age_is (0.0);
-- end reset_Age;
--
-- else
-- null;
-- end select;
--
--
-- if not the_World.is_a_Mirror
-- then
-- evolve;
-- end if;
--
--
-- the_World.new_sprite_transforms_Available.signal;
-- the_World.evolver_Done .signal;
--
--
-- -- Check for joint breakage.
-- --
-- if the_World.broken_joints_Allowed
-- then
-- declare
-- use gel.Joint,
-- physics.Space;
--
-- the_Joint : gel.Joint.view;
-- reaction_Force,
-- reaction_Torque : Real;
--
-- Cursor : physics.Space.joint_Cursor'Class := the_World.physics_Space.first_Joint;
-- begin
-- while has_Element (Cursor)
-- loop
-- the_Joint := to_GEL (Element (Cursor));
--
-- if the_Joint /= null
-- then
-- reaction_Force := abs (the_Joint.reaction_Force);
-- reaction_Torque := abs (the_Joint.reaction_Torque);
--
-- if reaction_Force > 50.0 / 8.0
-- or reaction_Torque > 100.0 / 8.0
-- then
-- begin
-- the_World.physics_Space .rid (the_Joint.Physics.all'Access);
-- the_World.broken_Joints.add (the_Joint);
--
-- exception
-- when no_such_Child =>
-- put_Line ("Error when breaking joint due to reaction Force: no_such_Child.");
-- end;
-- end if;
--
-- if reaction_Force > max_joint_Force
-- then
-- max_joint_Force := reaction_Force;
-- end if;
--
-- if reaction_Torque > max_joint_Torque
-- then
-- max_joint_Torque := reaction_Torque;
-- end if;
-- end if;
--
-- next (Cursor);
-- end loop;
-- end;
-- end if;
--
-- next_render_Time := next_render_Time + Duration (1.0 / 60.0);
-- end loop;
--
-- exception
-- when E : others =>
-- new_Line (2);
-- put_Line ("Error in gel.World.Engine");
-- new_Line;
-- put_Line (exception_Information (E));
-- put_Line ("Engine has terminated !");
-- new_Line (2);
-- end Engine;
|
optikos/oasis | Ada | 1,406 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Lexical_Elements;
generic
type Vector_Interface is limited interface and
Program.Element_Vectors.Element_Vector;
package Program.Nodes.Generic_Vectors is
pragma Preelaborate;
type Vector;
function Create
(Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Vector;
type Vector (<>) is new Vector_Interface with private;
overriding function Get_Length (Self : Vector) return Positive;
overriding function Element
(Self : Vector;
Index : Positive)
return not null Program.Elements.Element_Access;
overriding function Delimiter
(Self : Vector;
Index : Positive)
return Program.Lexical_Elements.Lexical_Element_Access;
private
type Element_Array is array (Positive range <>)
of Program.Elements.Element_Access;
type Lexical_Element_Array is array (Positive range <>)
of Program.Lexical_Elements.Lexical_Element_Access;
type Vector (Elements, Tokens : Natural) is new Vector_Interface with record
Element_List : Element_Array (1 .. Elements);
Token_List : Lexical_Element_Array (1 .. Tokens);
end record;
end Program.Nodes.Generic_Vectors;
|
reznikmm/matreshka | Ada | 4,700 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.ODF_Elements.Style.Page_Layout is
type Style_Page_Layout_Node is
new Matreshka.ODF_Elements.Style.Style_Node_Base with null record;
type Style_Page_Layout_Access is access all Style_Page_Layout_Node'Class;
overriding procedure Enter_Element
(Self : not null access Style_Page_Layout_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding function Get_Local_Name
(Self : not null access constant Style_Page_Layout_Node)
return League.Strings.Universal_String;
overriding procedure Leave_Element
(Self : not null access Style_Page_Layout_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access Style_Page_Layout_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.ODF_Elements.Style.Page_Layout;
|
ebolar/Unbounded | Ada | 13,526 | adb | -- Lambda Calculus interpreter
-- ---------------------------
-- Parses and reduces Lamdba Calculus statements.
--
--
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.IO_Exceptions;
with Ada.Containers; use Ada.Containers;
with Ada.Containers.Multiway_Trees;
with Lambda; use Lambda;
Package body Lambda_Parser is
-- ----------------------------------------------
-- Recursive descent parser for Lambda statements
-- ----------------------------------------------
-- The simplest parser for the simplest computer language.
--
-- Name_Type : [a-z] : Variable
-- Synonym_Type : [A-Z] : Synonym - name of a function
-- : [?|&|\] : Start of a Function definition.
-- : [.] : separates Function Variables from Expression
-- : [(] : starts a new Expression
-- : [)] : ends an Expression
-- : [=] : assigns a Function to a Synonym
-- : [_| ] : Spaces. Ignore these for now.
-- : - May be useful down the track to collapse these into a single spacer element.
-- : This would enable the definition of multicharacter Synonyms, eg KI.
--
function parse_Statement( S: Statement ) return Instructions.Tree is
Default : Instructions.Tree;
Index : Instructions.Cursor;
X : Statement := trim(S, Left);
C : Natural := 1;
begin
Level := 0;
Index := Instructions.Root(Default);
Log ("Parse " & X);
parse_expression( S, C, Default, Index);
return Default;
end parse_Statement;
-- TBD:
-- - Break these out into multiple functions.
-- - Stmt'Last is more correct than Stmt'Length as strings do not have to start at position 1
--
-- parse_expression()
procedure parse_expression( Stmt : Statement; Posn : in out Natural; Inst : in out Instructions.Tree; Curs : Instructions.Cursor ) is
E : Character;
Node : Element_Record;
Index : Instructions.Cursor;
begin
while Posn <= Stmt'Length loop
E := Stmt(Posn);
case E is
when Name_Type =>
if Instructions.Is_Empty (Inst)
then
-- Insert(L_Expression)
Node := (Element => L_Expression, Name => '_', Is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
-- move Cursor and reprocess
parse_expression(Stmt, Posn, Inst, Instructions.First_Child(Parent => Curs));
else
Log(Log_Parse, Indent(Level) & "Variable: " & E);
-- Insert(L_Variable)
Node := (Element => L_Variable, Name => E, is_Explicit => true);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
end if;
-- parse_synonym()
when Synonym_Type =>
-- if empty tree and next character is '=' then
if Instructions.Is_Empty(Inst) and next_is( Stmt, Posn, '=') then
-- Insert (L_Definition (L_Symbol, L_Expression ...)
Log(Log_Parse, Indent (Level) & "Synonym: " & E);
Log(Log_Parse, Indent (Level) & "= ");
Node := (Element => L_Definition, Name => E, is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
Posn := Locate(Stmt, Posn, '=');
Index := Instructions.Last_Child(Parent => Curs);
-- if next_is( Stmt, Posn, '(')
-- then
-- Posn := Locate(Stmt, Posn, '(');
-- parse_expression(Stmt, Posn, Inst, Index);
-- else
Node := (Element => L_Expression, Name => '_', Is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Index,
New_Item => Node);
Posn := Posn + 1;
parse_expression(Stmt, Posn, Inst, Instructions.Last_Child(Parent => Index));
-- end if;
Add_Synonym( Source=> Index );
else
if Instructions.Is_Empty (Inst)
then
-- Insert(L_Expression)
Node := (Element => L_Expression, Name => '_', is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
-- move Cursor and reprocess
parse_expression(Stmt, Posn, Inst, Instructions.Last_Child(Parent => Curs));
else
Log(Log_Parse, Indent (Level) & "Synonym: " & E);
-- Insert (L_Synonym)
Node := (Element => L_Synonym, Name => E, is_Explicit => true);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
end if;
end if;
-- parse_function()
when '?' | '&' | '\' =>
if Instructions.Is_Empty (Inst)
then
-- Insert(L_Expression)
Node := (Element => L_Expression, Name => '_', is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
-- move Cursor and reprocess
parse_expression(Stmt, Posn, Inst, Instructions.Last_Child(Parent => Curs));
else
-- Functions are an implicitly defined container
Node := (Element => L_Function, Name => E, is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
Index := Instructions.Last_Child(Parent => Curs);
Log(Log_Parse, Indent (Level) & "Function - Variables");
Level := Level + 1;
Posn := Posn + 1;
while Posn <= Stmt'Length loop
E := Stmt(Posn);
exit when E = '.';
case E is
when Name_Type =>
Log(Log_Parse, Indent(Level) & "Variable: " & E);
-- Insert(L_Variable)
Node := (Element => L_Variable, Name => E, is_Explicit => true);
Instructions.Append_Child(Container => Inst,
Parent => Index,
New_Item => Node);
when others => raise Syntax_Error with "Malformed function declaration";
end case;
Posn := Posn + 1;
end loop;
if Posn >= Stmt'Length then
raise Program_Error with "Buffer overflow";
end if;
Log(Log_Parse, Indent (Level - 1) & "Function - Expression");
-- if next character is not '('
if not Next_is( Stmt, Posn, '(' )
then
-- Insert(implied L_Expression)
Node := (Element => L_Expression, Name => '_', is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Index,
New_Item => Node);
Index := Instructions.Last_Child(Parent => Index);
end if;
Node := Instructions.Element(Index);
-- Process the expression
Posn := Posn + 1;
parse_expression(Stmt, Posn, Inst, Index);
end if;
when '(' =>
if Instructions.Is_Empty (Inst)
then
-- Insert(L_Expression)
Node := (Element => L_Expression, Name => '_', Is_Explicit => false);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
-- move Cursor and reprocess
parse_expression(Stmt, Posn, Inst, Instructions.First_Child(Parent => Curs));
else
Log(Log_Parse, Indent (Level) & "(");
Level := Level + 1;
-- Insert(L_Expression)
Node := (Element => L_Expression, Name => '(', is_Explicit => true);
Instructions.Append_Child(Container => Inst,
Parent => Curs,
New_Item => Node);
-- move Cursor and parse the sub-expression
Posn := Posn + 1;
parse_expression(Stmt, Posn, Inst, Instructions.Last_Child(Parent => Curs));
if Posn > Stmt'Length
then
raise Syntax_Error with "Missing ')'";
end if;
end if;
when ')' =>
begin
Node := Instructions.Element(Curs);
Level := Level - 1;
if Node.is_Explicit then
Log(Log_Parse, Indent (Level) & ")");
else
-- If we are dealing with an implicitly defined container
-- and we encounter a ')',
-- it belongs to the enclosing expression and not this one!
Log(Log_Parse, Indent (Level) & ".");
Posn := Posn - 1;
end if;
return;
exception
when Constraint_Error =>
raise Syntax_Error with "Unmatched ')'";
end;
-- parse_comments()
when '#' =>
Log(Log_Parse, Indent (Level) & "#");
-- Insert(L_Comments)
Node := (Element => L_Comments, Name => '#', is_Explicit => true, Comments => Empty_Statement);
Node.Comments := Ada.Strings.Fixed.Head(Stmt(Posn+1..Stmt'Last), Max_Statement_Length, ' ');
declare
First : Element_Record;
Location : Instructions.Cursor := Instructions.Root(Inst);
begin
-- if first child is a symbol definition then append to the definition
if not Instructions.Is_Empty(Inst)
then
First := Instructions.First_Child_Element(Location);
if First.Element = L_Definition
then
Location := Instructions.First_Child(Location);
end if;
end if;
Instructions.Append_Child(Container => Inst,
Parent => Location,
New_Item => Node);
end;
-- Skip forward to the end of line
Posn := Stmt'Length + 1;
-- and bug out!
return;
-- Ignore spaces
when '_' | ' ' => null;
-- Various syntax errors
when '.' =>
raise Syntax_Error with "Unexpected '.' - no function declared";
when '=' =>
raise Syntax_Error with "Unexpected Synonym assignment";
when others => raise Syntax_Error with "Invalid character";
end case;
Posn := Posn + 1;
end loop;
end;
function Next_Is(Stmt : Statement; Posn : Natural; Expected : Character) return boolean is
Loc : Natural;
E : Character;
begin
Loc := Posn + 1;
while Loc <= Stmt'Length loop
E := Stmt(Loc);
if E = Expected then
return true;
else
case E is
when '_' | ' ' => Loc := Loc + 1;
when others => return false;
end case;
end if;
end loop;
return false;
end;
function Locate(Stmt : Statement; Posn : Natural; Expected : Character) return natural is
Loc : Natural := Posn;
E : Character;
begin
while Loc <= Stmt'Length loop
E := Stmt(Loc);
if E = Expected then
return Loc;
else
Loc := Loc + 1;
end if;
end loop;
return Loc;
end;
end Lambda_Parser;
|
zhmu/ananas | Ada | 2,755 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A . N U M E R I C S . A U X . C O M P A T --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2022, 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 is used to provide the default type for the
-- backward-compatibility Ada.Numerics.Aux interface. This is a
-- version for x86 and x86_64, that uses the Long_Long_Float type.
-- This package should not be directly with'ed by an application program
with Ada.Numerics.Aux_Long_Long_Float;
package Ada.Numerics.Aux_Compat renames Ada.Numerics.Aux_Long_Long_Float;
|
AdaCore/Ada-IntelliJ | Ada | 634 | ads | <fold text='with Play_Control, Record_Control, Ada.Text_IO, Sequencer; ...' expand='false'>with Play_Control, Record_Control, Ada.Text_IO, Sequencer;
with Ada.Text_IO;
with Pattern_Control;</fold>
<fold text='package Bens_New_Package is ...' expand='true'>package Bens_New_Package is
<fold text=' function test_1 return Integer is ...' expand='true'> function test_1 return Integer is
begin
return 1;
End Test_1;</fold>
<fold text=' function test_2 return Integer is ...' expand='true'> function test_2 return Integer is
begin
return 2;
End Test_2;</fold>
end Bens_New_Package;</fold> |
godunko/adawebpack | Ada | 9,988 | adb | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2020-2021, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Interfaces;
with System;
with WASM.Attributes;
with WASM.Methods;
with WASM.Objects.Attributes;
with WASM.Objects.Methods;
with Web.DOM.Documents;
with Web.DOM.Elements;
with Web.DOM.Events;
with Web.HTML.Elements;
with Web.Strings.WASM_Helpers;
with Web.Utilities;
package body Web.DOM.Nodes is
function "+" (Item : Wide_Wide_String) return Web.Strings.Web_String
renames Web.Strings.To_Web_String;
procedure Dispatch_Event
(Callback : System.Address;
Identifier : WASM.Objects.Object_Identifier)
with Export => True,
Convention => C,
Link_Name => "__adawebpack__dom__Node__dispatch_event";
------------------------
-- Add_Event_Listener --
------------------------
overriding procedure Add_Event_Listener
(Self : in out Node;
Name : Web.Strings.Web_String;
Callback : not null Web.DOM.Event_Listeners.Event_Listener_Access;
Capture : Boolean := False)
is
procedure Imported
(Identifier : WASM.Objects.Object_Identifier;
Name_Address : System.Address;
Name_Size : Interfaces.Unsigned_32;
Callback : System.Address;
Capture : Interfaces.Unsigned_32)
with Import => True,
Convention => C,
Link_Name => "__adawebpack__dom__Node__addEventListener";
A : System.Address;
S : Interfaces.Unsigned_32;
begin
Web.Strings.WASM_Helpers.To_JS (Name, A, S);
Imported
(Self.Identifier, A, S, Callback.all'Address, (if Capture then 1 else 0));
end Add_Event_Listener;
------------------
-- Append_Child --
------------------
function Append_Child
(Self : in out Node'Class;
Node : Web.DOM.Nodes.Node'Class) return Web.DOM.Nodes.Node
is
function Imported
(Identifier : WASM.Objects.Object_Identifier;
Node_Identifier : WASM.Objects.Object_Identifier)
return WASM.Objects.Object_Identifier
with Import => True,
Convention => C,
Link_Name => "__adawebpack__dom__Node__appendChild";
begin
return
Web.DOM.Nodes.Instantiate
(Imported (Self.Identifier, Node.Identifier));
end Append_Child;
------------------
-- Append_Child --
------------------
procedure Append_Child
(Self : in out Node'Class;
Node : Web.DOM.Nodes.Node'Class)
is
Dummy : Web.DOM.Nodes.Node;
begin
Dummy := Self.Append_Child (Node);
end Append_Child;
---------------------
-- As_HTML_Element --
---------------------
function As_HTML_Element
(Self : Node'Class) return Web.HTML.Elements.HTML_Element is
begin
if not Self.Is_Null
and then not Web.Utilities.Is_Instance_Of (Self, +"HTMLElement")
then
raise Constraint_Error;
else
return Web.HTML.Elements.Instantiate (Self.Identifier);
end if;
end As_HTML_Element;
----------------
-- Clone_Node --
----------------
function Clone_Node
(Self : Node'Class; Deep : Boolean := False) return Web.DOM.Nodes.Node is
begin
return
Web.DOM.Nodes.Instantiate
(WASM.Objects.Methods.Call_Object_Boolean
(Self, WASM.Methods.Clone_Node, Deep));
end Clone_Node;
--------------------
-- Dispatch_Event --
--------------------
procedure Dispatch_Event
(Callback : System.Address;
Identifier : WASM.Objects.Object_Identifier)
is
function To_Object is
new Ada.Unchecked_Conversion
(System.Address, Web.DOM.Event_Listeners.Event_Listener_Access);
E : Web.DOM.Events.Event := Web.DOM.Events.Instantiate (Identifier);
begin
To_Object (Callback).Handle_Event (E);
end Dispatch_Event;
---------------------
-- Get_First_Child --
---------------------
function Get_First_Child (Self : Node'Class) return Web.DOM.Nodes.Node is
begin
return
Web.DOM.Nodes.Instantiate
(WASM.Objects.Attributes.Get_Object
(Self, WASM.Attributes.First_Child));
end Get_First_Child;
----------------------
-- Get_Next_Sibling --
----------------------
function Get_Next_Sibling (Self : Node'Class) return Web.DOM.Nodes.Node is
function Imported
(Identifier : WASM.Objects.Object_Identifier)
return WASM.Objects.Object_Identifier
with Import => True,
Convention => C,
Link_Name => "__adawebpack__dom__Node__nextSibling_getter";
begin
return Web.DOM.Nodes.Instantiate (Imported (Self.Identifier));
end Get_Next_Sibling;
-------------------
-- Get_Node_Type --
-------------------
function Get_Node_Type (Self : Node'Class) return Web.DOM.Nodes.Node_Types is
function Imported
(Identifier : WASM.Objects.Object_Identifier)
return Web.DOM_Unsigned_Short
with Import => True,
Convention => C,
Link_Name => "__adawebpack__dom__Node__nodeType_getter";
function To_Node_Types is
new Ada.Unchecked_Conversion
(Web.DOM_Unsigned_Short, Web.DOM.Nodes.Node_Types);
begin
return To_Node_Types (Imported (Self.Identifier));
end Get_Node_Type;
------------------------
-- Get_Owner_Document --
------------------------
function Get_Owner_Document
(Self : Node'Class) return Web.DOM.Documents.Document
is
function Imported
(Identifier : WASM.Objects.Object_Identifier)
return WASM.Objects.Object_Identifier
with Import => True,
Convention => C,
Link_Name => "__adawebpack__dom__Node__ownerDocument_getter";
begin
return Web.DOM.Documents.Instantiate (Imported (Self.Identifier));
end Get_Owner_Document;
------------------------
-- Get_Parent_Element --
------------------------
function Get_Parent_Element
(Self : Node'Class) return Web.DOM.Elements.Element is
begin
return
Web.DOM.Elements.Instantiate
(WASM.Objects.Attributes.Get_Object
(Self, WASM.Attributes.Parent_Element));
end Get_Parent_Element;
------------------
-- Remove_Child --
------------------
function Remove_Child
(Self : in out Node'Class;
Node : Web.DOM.Nodes.Node'Class) return Web.DOM.Nodes.Node
is
function Imported
(Identifier : WASM.Objects.Object_Identifier;
Node_Identifier : WASM.Objects.Object_Identifier)
return WASM.Objects.Object_Identifier
with Import => True,
Convention => C,
Link_Name => "__adawebpack__dom__Node__removeChild";
begin
return
Web.DOM.Nodes.Instantiate
(Imported (Self.Identifier, Node.Identifier));
end Remove_Child;
------------------
-- Remove_Child --
------------------
procedure Remove_Child
(Self : in out Node'Class;
Node : Web.DOM.Nodes.Node'Class)
is
Dummy : Web.DOM.Nodes.Node;
begin
Dummy := Self.Remove_Child (Node);
end Remove_Child;
end Web.DOM.Nodes;
|
reznikmm/matreshka | Ada | 4,534 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Svg.Cx_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Cx_Attribute_Node is
begin
return Self : Svg_Cx_Attribute_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Svg_Cx_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Cx_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Cx_Attribute,
Svg_Cx_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Cx_Attributes;
|
DavJo-dotdotdot/Ada_Drivers_Library | Ada | 104 | ads | package Controller is
task Sense with Priority => 2;
task Act with Priority => 1;
end Controller;
|
reznikmm/increment | Ada | 1,955 | adb | -- Copyright (c) 2015-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Incr.Nodes.Tokens;
with Incr.Nodes.Ultra_Roots;
package body Incr.Documents is
package body Constructors is
procedure Initialize
(Self : aliased in out Document'Class;
Root : Nodes.Node_Access)
is
Child : constant Nodes.Ultra_Roots.Ultra_Root_Access :=
new Nodes.Ultra_Roots.Ultra_Root (Self'Unchecked_Access);
begin
Nodes.Ultra_Roots.Constructors.Initialize (Child.all, Root);
Self.Ultra_Root := Child;
end Initialize;
end Constructors;
------------
-- Commit --
------------
not overriding procedure Commit (Self : in out Document) is
Next : Version_Trees.Version;
begin
Self.Ultra_Root.On_Commit (null);
Self.History.Start_Change (Self.History.Changing, Next);
end Commit;
-------------------
-- End_Of_Stream --
-------------------
function End_Of_Stream
(Self : Document) return Nodes.Tokens.Token_Access
is
Result : constant Nodes.Node_Access :=
Self.Ultra_Root.Child (Index => 3, Time => Self.History.Changing);
begin
return Nodes.Tokens.Token_Access (Result);
end End_Of_Stream;
---------------------
-- Start_Of_Stream --
---------------------
function Start_Of_Stream
(Self : Document) return Nodes.Tokens.Token_Access
is
Result : constant Nodes.Node_Access :=
Self.Ultra_Root.Child (Index => 1, Time => Self.History.Changing);
begin
return Nodes.Tokens.Token_Access (Result);
end Start_Of_Stream;
----------------
-- Ultra_Root --
----------------
not overriding function Ultra_Root
(Self : Document) return Nodes.Node_Access is
begin
return Self.Ultra_Root;
end Ultra_Root;
end Incr.Documents;
|
zhmu/ananas | Ada | 265 | adb | -- { dg-do compile }
procedure Warn24 is
type List_D (D : Boolean);
type List_Acc is access List_D;
type List_D (D : Boolean) is record
Next : List_Acc (D);
end record;
X : List_D (True);
begin
X.Next := new List_D (False);
end Warn24;
|
iyan22/AprendeAda | Ada | 243 | adb |
function multporsumas (numero, multiplicador: in Integer) return Integer is
resultado: Integer;
begin
resultado:=0;
for I in 1..multiplicador loop
resultado:=resultado+numero;
end loop;
return resultado;
end multporsumas; |
onox/orka | Ada | 864 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Streams;
private package Orka.Base64 is
pragma Pure;
use Ada.Streams;
function Decode (Input : String) return Stream_Element_Array;
Encoding_Error : exception;
end Orka.Base64;
|
reznikmm/matreshka | Ada | 3,368 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
procedure Modeler.Driver;
|
Hamster-Furtif/JeremyPlusPlus | Ada | 3,598 | ads | with utils, read_preflop;
use utils, read_preflop;
package opstrat is
-- Represente le mouvement qu'on veut effectuer
type T_round is private;
-- Represente la psychologie de l'adversaire
type T_logic is private;
--E/op_hand : T_set
--Necessite : Op_hand contient 2 cartes
--S/proba : Float
--Entraine : Calcule la probabilite que l'adversaire ait bluffe lors d'un round
function opIsBluffing(op_hand : in T_set) return float;
--E/r : Float
--E/S/ logic : T_logic
--Necessite : None
--Entraine : actualise le nombre de bluff de l'adversaire dans la partie et le booleen can_bluff
procedure add_bluff(logic : in out T_logic; r : in Float);
--E/r : Float
--E/S/ logic : T_logic
--Necessite : None
--Entraine : actualise le nombre de semi-bluff de l'adversaire dans la partie et le booleen can_semi_bluff
procedure add_semi_bluff(logic : in out T_logic; r : in Float);
--E/r : Float
--E/S/ logic : T_logic
--Necessite : None
--Entraine : actualise le nombre de fois ou l'adversaire nous a bluffe
procedure add_bluffed(logic : in out T_logic; r : in Float);
--accesseurs en lecture
function can_bluff(logic : T_logic) return Boolean;
function can_semi_bluff(logic : T_logic) return Boolean;
function can_get_bluffed(logic : T_logic) return Boolean;
function has_logic(logic : T_logic) return Boolean;
function get_winning_chances(logic : T_logic) return Float;
function get_nbr_of_bluff(logic : T_logic) return Float;
function get_nbr_of_semi_bluff(logic : T_logic) return Float;
function get_nbr_of_bluffed(logic : T_logic) return Float;
function get_current_move(logic : in T_logic) return T_move;
--constructeur d'un T_round
function create_round(move : T_move; bet : Integer) return T_round;
--E/T_round : round
--Necessite : None
--S/ String : message
--Entraine : Convertit notre round (qui represente le mouvement qu'on veut effectuer)
-- en une chaine de caractres comprehensible par le moteur
function toString(round: T_round) return String;
--accesseurs en ecriture
procedure set_winning_chances(logic : in out T_logic;chances : Float);
procedure set_current_move(logic : in out T_logic; move: T_move);
-- E/ logic T_logic
-- E/ game T_game
-- Necessite : None
-- S/ esp Float
-- Entraine esp l'estimation de l'esperance de gain de la main en cours, avec les probabilites de bluff de l'adversaire
function get_expectation(logic : T_logic; game : T_game) return Float;
private
-- Correspond à l'action prise lors d'un tour par l'adversaire, ainsi que la table, le bet et la main de l'adversaire.
type T_round is record
move : T_move;
table : T_set;
op_hand : T_set;
bet : Integer := -1;
end record;
type T_logic is record
can_bluff : Boolean := FALSE;
can_semi_bluff : Boolean := FALSE;
can_get_bluffed : Boolean := FALSE;
has_logic : Boolean := TRUE;
current_move : T_move := none;
nbr_of_bluff : Float := 0.0;
nbr_of_semi_bluff : Float := 0.0;
nbr_of_bluffed : Float := 0.0;
bluff_possibilities : Float := 0.0;
semi_bluff_possibilities : Float := 0.0;
bluffed_possibilities : Float := 0.0;
p_bluff : Float := 0.0;
p_bluffed : Float := 0.0;
p_semi_bluffed : Float := 0.0;
winning_chances : Float := 0.0;
esp_gain : Float := 0.0;
end record;
end opstrat;
|
reznikmm/matreshka | Ada | 6,784 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009-2010, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body League.Strings.Cursors.Characters is
use Matreshka.Internals.Strings;
use Matreshka.Internals.Utf16;
-------------
-- Element --
-------------
function Element (Self : Character_Cursor'Class)
return Wide_Wide_Character
is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
declare
D : constant Shared_String_Access := Self.Object.Data;
begin
if Self.Current >= D.Unused then
raise Constraint_Error with "Cursor out of range";
end if;
return
Wide_Wide_Character'Val
(Unchecked_To_Code_Point (D.Value, Self.Current));
end;
end Element;
-----------
-- First --
-----------
procedure First
(Self : in out Character_Cursor'Class;
Item : in out Universal_String)
is
begin
Self.Attach (Item);
Self.Current := Self.Object.Data.Value'First;
end First;
-----------------
-- Has_Element --
-----------------
function Has_Element (Self : Character_Cursor'Class) return Boolean is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
return Self.Current < Self.Object.Data.Unused;
end Has_Element;
----------
-- Last --
----------
procedure Last
(Self : in out Character_Cursor'Class;
Item : in out Universal_String)
is
begin
Self.Attach (Item);
Self.Current := Self.Object.Data.Unused;
if Self.Object.Data.Length /= 0 then
Unchecked_Previous (Self.Object.Data.Value, Self.Current);
end if;
end Last;
----------
-- Next --
----------
procedure Next (Self : in out Character_Cursor'Class) is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
declare
D : constant Shared_String_Access := Self.Object.Data;
begin
if Self.Current < D.Unused then
Unchecked_Next (D.Value, Self.Current);
elsif Self.Current = Utf16_String_Index'Last then
Self.Current := 0;
end if;
end;
end Next;
----------------
-- On_Changed --
----------------
overriding procedure On_Changed
(Self : not null access Character_Cursor;
Changed_First : Positive;
Removed_Last : Natural;
Inserted_Last : Natural)
is
pragma Unreferenced (Changed_First);
pragma Unreferenced (Removed_Last);
pragma Unreferenced (Inserted_Last);
begin
-- if Self.Current in Changed_First .. Removed_Last then
Self.Object := null;
-- elsif Self.Current > Removed_Last then
-- Self.Current := Self.Current + Inserted_Last - Removed_Last;
-- end if;
end On_Changed;
--------------
-- Previous --
--------------
procedure Previous (Self : in out Character_Cursor'Class) is
begin
if Self.Object = null then
raise Program_Error with "Invalid iterator";
end if;
declare
D : constant Shared_String_Access := Self.Object.Data;
begin
if Self.Current = 0 then
Self.Current := Utf16_String_Index'Last;
elsif Self.Current in 1 .. D.Unused then
Unchecked_Previous (D.Value, Self.Current);
end if;
end;
end Previous;
end League.Strings.Cursors.Characters;
|
docandrew/troodon | Ada | 10,256 | adb | with Ada.Numerics.Elementary_Functions;
with Ada.Text_IO;
with Interfaces.C; use Interfaces.C;
with System;
with GL;
with GLext;
with Render.Shaders;
with Render.Util;
package body Render.Widgets is
---------------------------------------------------------------------------
-- drawCircle
---------------------------------------------------------------------------
procedure drawCircle (x : Float;
y : Float;
radius : Float;
r : Float;
g : Float;
b : Float;
a : Float;
windowW : Float;
windowH : Float) is
glErr : GL.GLuint;
circleBox : Render.Util.Box2D;
orthoM : Render.Util.Mat4 := Render.Util.ortho (0.0, windowW, windowH, 0.0, -1.0, 1.0);
begin
-- Use our circle shader program
GLext.glUseProgram (Render.Shaders.circleShaderProg);
-- glErr := GL.glGetError;
-- Ada.Text_IO.Put_Line ("drawCircle: glUseProgram error? " & glErr'Image);
-- projection
GLext.glUniformMatrix4fv (location => Render.Shaders.circleUniformOrtho,
count => 1,
transpose => GL.GL_TRUE,
value => orthoM(1)'Access);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glUniformMatrix4fv error? " & glErr'Image);
-- Set up fragment shader
-- Circle color
GLext.glUniform4f (location => Render.Shaders.circleUniformColor,
v0 => r,
v1 => g,
v2 => b,
v3 => a);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glUniform4f error? " & glErr'Image);
-- Not sure if we can re-use the coord from the vertex stage or not
GLext.glUniform2f (location => Render.Shaders.circleUniformCenter,
v0 => x,
v1 => y);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glUniform2f error? " & glErr'Image);
GLext.glUniform1f (location => Render.Shaders.circleUniformScrH,
v0 => windowH);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glUniform1f error? " & glErr'Image);
GLext.glUniform1f (location => Render.Shaders.circleUniformRadius,
v0 => radius);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glUniform1f error? " & glErr'Image);
GL.glViewport (x => 0,
y => 0,
width => GL.GLsizei(windowW),
height => GL.GLsizei(windowH));
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glViewport error? " & glErr'Image);
-- Set up VBO
GLext.glGenBuffers (1, Render.Shaders.circleVBO'Access);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glGenBuffers error? " & glErr'Image);
-- Set up vertex shader
GLext.glEnableVertexAttribArray (GL.GLuint(Render.Shaders.circleAttribCoord));
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glEnableVertexAttribArray error? " & glErr'Image);
GLext.glBindBuffer (target => GLext.GL_ARRAY_BUFFER,
buffer => Render.Shaders.circleVBO);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glBindBuffer error? " & glErr'Image);
-- center of the circle
GLext.glVertexAttribPointer (index => GL.GLuint(Render.Shaders.circleAttribCoord),
size => 2,
c_type => GL.GL_FLOAT,
normalized => GL.GL_FALSE,
stride => 0,
pointer => System.Null_Address);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glVertexAttrib error? " & glErr'Image);
-- Four corners of the "square" containing our circle (texture coords not used yet)
circleBox := (
1 => (x - radius, y + radius), -- bottom left
2 => (x - radius, y - radius), -- top left
3 => (x + radius, y + radius), -- bottom right
4 => (x + radius, y - radius) -- top right
);
GLext.glBufferData (target => GLext.GL_ARRAY_BUFFER,
size => circleBox'Size / 8,
data => circleBox'Address,
usage => GLext.GL_DYNAMIC_DRAW);
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glBufferData error? " & glErr'Image);
GL.glDrawArrays (mode => GL.GL_TRIANGLE_STRIP,
first => 0,
count => Interfaces.C.int(circleBox'Last));
-- glErr := GL.glGetError;
--Ada.Text_IO.Put_Line ("drawCircle: glDrawArrays error? " & glErr'Image);
GLext.glDisableVertexAttribArray (GL.GLuint(Render.Shaders.circleAttribCoord));
GLext.glDeleteBuffers (1, Render.Shaders.circleVBO'Access);
GLext.glUseProgram (0);
end drawCircle;
---------------------------------------------------------------------------
-- drawLine
-- @TODO - might be a good idea to bundle up all these draw calls, esp. if
-- a bunch of lines are being drawn.
---------------------------------------------------------------------------
procedure drawLine (fromX : Float;
fromY : Float;
toX : Float;
toY : Float;
width : Float;
r : Float;
g : Float;
b : Float;
a : Float;
windowW : Float;
windowH : Float;
antiAliased : Boolean := True) is
use Ada.Numerics.Elementary_Functions; -- for ceil, sqrt
glErr : GL.GLuint;
-- If antialiasing, we add a little thickness to the line and blend it in shader.
newWidth : Float := (if antiAliased then width + 2.0 else width);
aaInt : GL.GLint := (if antiAliased then 1 else 0);
line : Render.Util.Line2D;
orthoM : Render.Util.Mat4 := Render.Util.ortho (0.0, windowW, windowH, 0.0, -1.0, 1.0);
begin
GLext.glUseProgram (Render.Shaders.lineShaderProg);
-- need to set line width a bit wider than we requested for fragment shader to work
-- From nVidia GPU Gems 22
GL.glLineWidth (newWidth);
line := (1 => (fromX, fromY), 2 => (toX, toY));
GLext.glUniform1i (location => Render.Shaders.lineUniformAA,
v0 => aaInt);
-- projection
GLext.glUniformMatrix4fv (location => Render.Shaders.lineUniformOrtho,
count => 1,
transpose => GL.GL_TRUE,
value => orthoM(1)'Access);
GLext.glUniform2f (location => Render.Shaders.lineUniformFrom,
v0 => fromX,
v1 => fromY);
GLext.glUniform2f (location => Render.Shaders.lineUniformTo,
v0 => toX,
v1 => toY);
GLext.glUniform1f (location => Render.Shaders.lineUniformWidth,
v0 => newWidth);
GLext.glUniform4f (location => Render.Shaders.lineUniformColor,
v0 => r,
v1 => g,
v2 => b,
v3 => a);
GLext.glUniform1f (location => Render.Shaders.lineUniformScrH,
v0 => windowH);
GL.glViewport (x => 0,
y => 0,
width => GL.GLsizei(windowW),
height => GL.GLsizei(windowH));
-- Set up VBO
GLext.glGenBuffers (1, Render.Shaders.lineVBO'Access);
-- Set up vertex shader
GLext.glEnableVertexAttribArray (GL.GLuint(Render.Shaders.lineAttribCoord));
GLext.glBindBuffer (target => GLext.GL_ARRAY_BUFFER,
buffer => Render.Shaders.lineVBO);
-- Pass 2-D coords for the line segment.
GLext.glVertexAttribPointer (index => GL.GLuint(Render.Shaders.lineAttribCoord),
size => 2,
c_type => GL.GL_FLOAT,
normalized => GL.GL_FALSE,
stride => 0,
pointer => System.Null_Address);
-- Four corners of the "square" containing our circle (texture coords not used yet)
-- Ada.Text_IO.Put_Line ("Drawing line from (" & fromX'Image & "," & fromY'Image & ") to (" & toX'Image & "," & toY'Image & ")");
GLext.glBufferData (target => GLext.GL_ARRAY_BUFFER,
size => line'Size / 8,
data => line'Address,
usage => GLext.GL_DYNAMIC_DRAW);
GL.glDrawArrays (mode => GL.GL_LINES,
first => 0,
count => Interfaces.C.int(line'Last));
GLext.glDisableVertexAttribArray (GL.GLuint(Render.Shaders.lineAttribCoord));
GLext.glDeleteBuffers (1, Render.Shaders.lineVBO'Access);
GLext.glUseProgram (0);
end drawLine;
end Render.Widgets;
|
onox/orka | Ada | 5,175 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with AUnit.Assertions;
with AUnit.Test_Caller;
with Orka.SIMD.AVX.Doubles.Arithmetic;
with Orka.SIMD.AVX.Doubles.Compare;
package body Test_SIMD_AVX_Compare is
use Orka;
use Orka.SIMD.AVX.Doubles;
use Orka.SIMD.AVX.Doubles.Compare;
type Is_True_Array is array (Index_4D) of Boolean;
use AUnit.Assertions;
package Caller is new AUnit.Test_Caller (Test);
Test_Suite : aliased AUnit.Test_Suites.Test_Suite;
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Name : constant String := "(SIMD - AVX - Compare) ";
begin
Test_Suite.Add_Test (Caller.Create
(Name & "Test '=' operator", Test_Equal'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test '/=' operator", Test_Not_Equal'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test '>' operator", Test_Greater_Than'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test '<' operator", Test_Less_Than'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test NaN function", Test_Nan'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Not_NaN function", Test_Not_Nan'Access));
return Test_Suite'Access;
end Suite;
procedure Test_Equal (Object : in out Test) is
Left : constant m256d := (-0.2, 1.0, 1.5, 0.0);
Right : constant m256d := (0.0, 0.0, 1.5, 2.0);
Expected : constant Is_True_Array := (False, False, True, False);
Result : constant m256d := Left = Right;
begin
for I in Index_4D loop
Assert (Expected (I) = Is_True (Result, I), "Unexpected result at " & I'Image);
end loop;
end Test_Equal;
procedure Test_Not_Equal (Object : in out Test) is
Left : constant m256d := (-0.2, 1.0, 1.5, 0.0);
Right : constant m256d := (0.0, 0.0, 1.5, 2.0);
Expected : constant Is_True_Array := (True, True, False, True);
Result : constant m256d := Left /= Right;
begin
for I in Index_4D loop
Assert (Expected (I) = Is_True (Result, I), "Unexpected result at " & I'Image);
end loop;
end Test_Not_Equal;
procedure Test_Greater_Than (Object : in out Test) is
Left : constant m256d := (-0.2, 1.0, 1.5, 0.0);
Right : constant m256d := (0.0, 0.0, 1.5, 2.0);
Expected : constant Is_True_Array := (False, True, False, False);
Result : constant m256d := Left > Right;
begin
for I in Index_4D loop
Assert (Expected (I) = Is_True (Result, I), "Unexpected result at " & I'Image);
end loop;
end Test_Greater_Than;
procedure Test_Less_Than (Object : in out Test) is
Left : constant m256d := (-0.2, 1.0, 1.5, 0.0);
Right : constant m256d := (0.0, 0.0, 1.5, 2.0);
Expected : constant Is_True_Array := (True, False, False, True);
Result : constant m256d := Left < Right;
begin
for I in Index_4D loop
Assert (Expected (I) = Is_True (Result, I), "Unexpected result at " & I'Image);
end loop;
end Test_Less_Than;
procedure Test_Nan (Object : in out Test) is
use Orka.SIMD.AVX.Doubles.Arithmetic;
-- Nan, 0.0, 1.0, Nan
A : constant m256d := (0.0, 0.0, 1.0, 0.0);
B : constant m256d := (0.0, 1.0, 1.0, 0.0);
-- 0.0, 1.0, Nan, Nan
C : constant m256d := (0.0, 1.0, 0.0, 0.0);
D : constant m256d := (1.0, 1.0, 0.0, 0.0);
Left : constant m256d := A / B;
Right : constant m256d := C / D;
Expected : constant Is_True_Array := (True, False, True, True);
Result : constant m256d := Nan (Left, Right);
begin
for I in Index_4D loop
Assert (Expected (I) = Is_True (Result, I), "Unexpected result at " & I'Image);
end loop;
end Test_Nan;
procedure Test_Not_Nan (Object : in out Test) is
use Orka.SIMD.AVX.Doubles.Arithmetic;
-- Nan, 0.0, 1.0, Nan
A : constant m256d := (0.0, 0.0, 1.0, 0.0);
B : constant m256d := (0.0, 1.0, 1.0, 0.0);
-- 0.0, 1.0, Nan, Nan
C : constant m256d := (0.0, 1.0, 0.0, 0.0);
D : constant m256d := (1.0, 1.0, 0.0, 0.0);
Left : constant m256d := A / B;
Right : constant m256d := C / D;
Expected : constant Is_True_Array := (False, True, False, False);
Result : constant m256d := Not_Nan (Left, Right);
begin
for I in Index_4D loop
Assert (Expected (I) = Is_True (Result, I), "Unexpected result at " & I'Image);
end loop;
end Test_Not_Nan;
end Test_SIMD_AVX_Compare;
|
stcarrez/ada-mail | Ada | 1,093 | ads | -----------------------------------------------------------------------
-- mail-headers-tests -- Tests for headers
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Mail.Headers.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Decode (T : in out Test);
end Mail.Headers.Tests;
|
AdaCore/training_material | Ada | 5,966 | adb | package body Trains with
SPARK_Mode
is
procedure Update_Track_Signal (Track : Track_Id) with
Global => (Input => (Trains, Cur_Num_Trains),
In_Out => Track_Signals),
Pre => Track_Signals (Track) = Orange,
Post => (if (for some T in Train_Id range 1 .. Cur_Num_Trains =>
Is_Previous_Track (Trains (T), Track))
then
Track_Signals (Track) = Orange
else
Track_Signals (Track) = Green)
and then
(for all Other_Track in Track_Id =>
(if Other_Track /= Track then
Track_Signals (Other_Track) = Track_Signals'Old (Other_Track)));
-- Possibly update a signal for a track from Orange to Green if it's ok to
-- do so.
-------------------------
-- Update_Track_Signal --
-------------------------
procedure Update_Track_Signal (Track : Track_Id) is
begin
for Train in Train_Id range 1 .. Cur_Num_Trains - 1 loop
if Is_Previous_Track (Trains (Train), Track) then
return;
end if;
pragma Loop_Invariant
(for all T in 1 .. Train =>
not Is_Previous_Track (Trains (T), Track));
end loop;
Track_Signals (Track) := Green;
end Update_Track_Signal;
----------
-- Move --
----------
procedure Move
(Train : Train_Id;
New_Position : Train_Position;
Result : out Move_Result)
is
Cur_Position : constant Train_Position := Trains (Train);
Prev : Track_Opt_Id;
begin
if Moving_Inside_Current_Tracks (Cur_Position, New_Position) then
Result := Keep_Going;
Trains (Train) := New_Position;
pragma Assert (Occupied_Tracks_On_Red);
pragma Assert (Previous_Tracks_On_Orange_Or_Red);
pragma Assert (Safe_Signaling);
elsif Moving_Away_From_Current_Track (Cur_Position, New_Position) then
Result := Keep_Going;
Trains (Train) := New_Position;
pragma Assert (Previous_Tracks_On_Orange_Or_Red);
-- the track leaved goes from Red to Orange
Track_Signals (Cur_Position.Track_End) := Orange;
pragma Assume (No_Track_Precedes_Itself);
pragma Assert (Occupied_Tracks_On_Red);
pragma Assert (Previous_Tracks_On_Orange_Or_Red);
-- the signal for tracks that precede the track leaved must be
-- updated, depending on the position of other trains. No update is
-- needed if the signal on such a track is Red, as this means some
-- train is on the track. So only update the signal if it is Orange.
for Id in Prev_Id loop
Prev := Get_Previous_Track (Cur_Position, Id);
if Prev /= No_Track_Id
and then Track_Signals (Prev) = Orange
then
Update_Track_Signal (Prev);
end if;
pragma Loop_Invariant
(for all J in Track_Id =>
((if Track_Signals'Loop_Entry (J) = Red then Track_Signals (J) = Red)
and then
(if Track_Signals'Loop_Entry (J) = Orange and then
(for some T in Train_Id range 1 .. Cur_Num_Trains =>
Is_Previous_Track (Trains (T), J))
then Track_Signals (J) = Orange)));
end loop;
pragma Assume (No_Track_Precedes_Itself);
pragma Assert (Occupied_Tracks_On_Red);
-- Inline definition of Previous_Tracks_On_Orange_Or_Red
pragma Assert
(for all Train in Train_Id range 1 .. Cur_Num_Trains =>
(for all Id in Prev_Id =>
(if Get_Previous_Track (Trains (Train), Id) /= No_Track_Id then
Track_Signals (Get_Previous_Track (Trains (Train), Id)) in
Orange | Red)
and then
(if Get_Other_Previous_Track (Trains (Train), Id) /= No_Track_Id then
Track_Signals (Get_Other_Previous_Track (Trains (Train), Id)) in
Orange | Red)));
pragma Assert (Previous_Tracks_On_Orange_Or_Red);
pragma Assert (Safe_Signaling);
-- otherwise, the train is moving in a new track
else
case Track_Signals (New_Position.Track_Begin) is
when Red =>
Result := Stop;
when others =>
if Track_Signals (New_Position.Track_Begin) = Green then
Result := Full_Speed;
else
Result := Slow_Down;
end if;
Trains (Train) := New_Position;
Track_Signals (New_Position.Track_Begin) := Red;
for Id in Prev_Id loop
Prev := Get_Other_Previous_Track (New_Position, Id);
if Prev /= No_Track_Id
and then Track_Signals (Prev) = Green
then
Track_Signals (Prev) := Orange;
end if;
pragma Loop_Invariant
(for all K in Track_Ids'First .. Id =>
(if Get_Other_Previous_Track (New_Position, K) /= No_Track_Id then
Track_Signals (Get_Other_Previous_Track (New_Position, K)) in
Orange | Red));
pragma Loop_Invariant
(for all J in Track_Id =>
((if Track_Signals'Loop_Entry (J) = Red then Track_Signals (J) = Red)
and then
(if Track_Signals'Loop_Entry (J) = Orange then Track_Signals (J) = Orange)));
end loop;
pragma Assert (Occupied_Tracks_On_Red);
pragma Assert (Previous_Tracks_On_Orange_Or_Red);
pragma Assert (Safe_Signaling);
end case;
end if;
end Move;
end Trains;
|
peterfrankjohnson/assembler | Ada | 174 | adb | with Ada.Text_IO; use Ada.Text_IO;
package body Test is
protected body TestA is
procedure TestProc is
begin
Put_Line("test");
end TestProc;
end TestA;
end Test; |
AdaCore/libadalang | Ada | 287 | adb | procedure Test is
package Pkg is
procedure Hello;
end Pkg;
package body Pkg is
procedure Hello is null;
end Pkg;
begin
Pkg.Hello (2);
--% node.f_call.f_name.p_referenced_decl()
--% node.f_call.f_name.p_referenced_decl(imprecise_fallback=True)
end Test;
|
afrl-rq/OpenUxAS | Ada | 30,200 | adb | with String_Utils; use String_Utils;
with AVTAS.LMCP.ByteBuffers; use AVTAS.LMCP.ByteBuffers;
with AVTAS.LMCP.Factory;
with UxAS.Common.Configuration_Manager;
with UxAS.Messages.UxNative.KillService;
with Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Strings.Fixed;
package body UxAS.Comms.LMCP_Net_Client is
-- The initializeNetworkClient method is invoked by
-- the initializeAndStart method to perform
-- LmcpObjectNetworkClientBase-specific initialization
--
-- @return true if initialization succeeds; false if initialization fails.
--
-- bool
-- initializeNetworkClient();
procedure Initialize_Network_Client
(This : in out LMCP_Object_Network_Client_Base;
Success : out Boolean);
-- If m_receiveProcessingType == ReceiveProcessingType::LMCP, then
-- the executeNetworkClient method repeatedly invokes
-- the processReceivedLmcpMessage in an infinite loop until
-- termination. Otherwise, the executeNetworkClient method is
-- not invoked.
--
-- void
-- executeNetworkClient();
procedure Execute_Network_Client (This : in out LMCP_Object_Network_Client_Base);
-- If m_receiveProcessingType == ReceiveProcessingType::SERIALIZED_LMCP, then
-- the executeSerializedNetworkClient method repeatedly invokes
-- the processReceivedSerializedLmcpMessage in an infinite loop until
-- termination. Otherwise, the executeSerializedNetworkClient method is
-- not invoked.
--
-- void
-- executeSerializedNetworkClient();
procedure Execute_Serialized_Network_Client (This : in out LMCP_Object_Network_Client_Base);
-- The deserializeMessage method deserializes an LMCP
-- string into an LMCP object.
--
-- @return unique pointer to LMCP object if succeeds; unique pointer with
-- unassigned native pointer.
--
-- std::shared_ptr<AVTAS::lmcp::Object>
-- deserializeMessage(const std::string& payload);
function Deserialzed_Message (Payload : String) return AVTAS.LMCP.Object.Object_Any;
function Should_Kill_This_Service
(This : LMCP_Object_Network_Client_Base;
Msg : Any_LMCP_Message)
return Boolean;
function Should_Kill_This_Service
(This : LMCP_Object_Network_Client_Base;
Msg : AVTAS.LMCP.Object.Object_Any)
return Boolean;
-- a refactored convenience routine
function Has_KillService_Subscription (Msg : Addressed_Attributed_Message_Ref) return Boolean;
-- a refactored convenience routine
----------------------
-- Construct_Client --
----------------------
procedure Construct_Client (This : in out LMCP_Object_Network_Client_Base)
is
begin
-- from the default ctor
This.Network_Id := Next_Network_Client_Id;
Next_Network_Client_Id := Next_Network_Client_Id + 1;
Copy (To_String (This.Network_Id), To => This.Network_Id_String);
-- from static elaboration (see top of OpenUxAS\src\Communications\LmcpObjectNetworkClientBase.cpp)
Copy (Get_Entity_Services_Cast_All_Address (UxAS.Common.Configuration_Manager.Instance.Get_Entity_Id),
To => Entity_Services_Cast_All_Address);
end Construct_Client;
----------------
-- Initialize --
----------------
procedure Initialize
(This : in out LMCP_Object_Network_Client_Base;
Result : out Boolean)
is
pragma Unreferenced (This); -- by design
begin
Result := True;
end Initialize;
-------------------------------
-- Initialize_Network_Client --
-------------------------------
procedure Initialize_Network_Client
(This : in out LMCP_Object_Network_Client_Base;
Success : out Boolean)
is
Unused : Boolean;
begin
This.Message_Receiver_Pipe.Initialize_Subscription
(Entity_Id => This.Entity_Id,
Service_Id => UInt32 (This.Network_Id));
for Address of This.Pre_Start_LMCP_Subscription_Addresses loop
This.Message_Receiver_Pipe.Add_Lmcp_Object_Subscription_Address (Value (Address), Unused);
end loop;
This.Message_Sender_Pipe.Initialize_Push
(Source_Group => Value (This.Message_Source_Group),
Entity_Id => This.Entity_Id,
Service_Id => UInt32 (This.Network_Id));
Success := True; -- per the C++ code
end Initialize_Network_Client;
-------------------------
-- Deserialzed_Message --
-------------------------
function Deserialzed_Message (Payload : String) return AVTAS.LMCP.Object.Object_Any is
Result : AVTAS.LMCP.Object.Object_Any;
Buffer : ByteBuffer (Capacity => Payload'Length);
begin
-- // allocate memory
-- AVTAS::lmcp::ByteBuffer lmcpByteBuffer;
-- lmcpByteBuffer.allocate(payload.size());
-- lmcpByteBuffer.rewind();
-- for (size_t charIndex = 0; charIndex < payload.size(); charIndex++)
-- {
-- lmcpByteBuffer.putByte(payload[charIndex]); // TODO REVIEW
-- }
-- PDR: note we don't just call Put_String because that would first put
-- the length, which the C++ code doesn't do
for C of Payload loop
Buffer.Put_Byte (Character'Pos (C));
end loop;
-- lmcpByteBuffer.rewind();
Buffer.Rewind;
-- lmcpObject.reset(AVTAS::lmcp::Factory::getObject(lmcpByteBuffer));
AVTAS.LMCP.Factory.getObject (Buffer, Result);
return Result;
end Deserialzed_Message;
----------------------
-- Entity_Id_Prefix --
----------------------
function Entity_Id_Prefix return String is
("eid");
-----------------------
-- Service_Id_Prefix --
-----------------------
function Service_Id_Prefix return String is
(".sid");
---------------------------
-- Service_Id_All_Suffix --
---------------------------
function Service_Id_All_Suffix return String is
(".sidall");
-------------------------
-- Entity_Cast_Address --
-------------------------
function Entity_Cast_Address (Entity_Id : UInt32) return String is
(Entity_Id_Prefix & To_String (Entity_Id));
-------------------------
-- Entity_Cast_Address --
-------------------------
function Entity_Cast_Address (Entity_Id : String) return String is
(Entity_Id_Prefix & Entity_Id);
--------------------------------------
-- Entity_Services_Cast_All_Address --
--------------------------------------
function Get_Entity_Services_Cast_All_Address (Entity_Id : UInt32) return String is
(Entity_Cast_Address (Entity_Id) & Service_Id_All_Suffix);
------------------------------------
-- Network_Client_Unicast_Address --
------------------------------------
function Network_Client_Unicast_Address
(Entity_Id : UInt32;
Network_Client_Id : Int64)
return String
is
(Entity_Cast_Address (Entity_Id) & Service_Id_Prefix & To_String (Network_Client_Id));
----------------------------------------
-- Get_Network_Client_Unicast_Address --
----------------------------------------
function Get_Network_Client_Unicast_Address
(Entity_Id : UInt32;
Network_Client_Id : String)
return String
is
(Entity_Cast_Address (Entity_Id) & Service_Id_Prefix & Network_Client_Id);
----------------------------------------
-- Get_Network_Client_Unicast_Address --
----------------------------------------
function Get_Network_Client_Unicast_Address
(Entity_Id : String;
Network_Client_Id : String)
return String
is
(Entity_Cast_Address (Entity_Id) & Service_Id_Prefix & Network_Client_Id);
----------------------------------------
-- Get_Network_Client_Unicast_Address --
----------------------------------------
function Get_Network_Client_Unicast_Address
(Entity_Id : String;
Network_Client_Id : Int64)
return String
is
(Entity_Cast_Address (Entity_Id) & Service_Id_Prefix & To_String (Network_Client_Id));
---------------------------------------
-- Get_Unique_Entity_Send_Message_Id --
---------------------------------------
procedure Get_Unique_Entity_Send_Message_Id (Value : out Int64) is
begin
-- return (s_uniqueEntitySendMessageId++);
Value := Unique_Entity_Send_Message_Id;
Unique_Entity_Send_Message_Id := Unique_Entity_Send_Message_Id + 1;
end Get_Unique_Entity_Send_Message_Id;
----------------------------------
-- Get_Unique_Network_Client_Id --
----------------------------------
procedure Get_Unique_Network_Client_Id (Value : out Int64) is
begin
Next_Network_Client_Id := Next_Network_Client_Id + 1;
Value := Next_Network_Client_Id;
end Get_Unique_Network_Client_Id;
-----------------------------
-- Is_Termination_Finished --
-----------------------------
function Is_Termination_Finished (This : LMCP_Object_Network_Client_Base) return Boolean is
(This.Is_Base_Class_Termination_Finished and This.Is_Subclass_Termination_Finished);
------------------------------
-- Configure_Network_Client --
------------------------------
procedure Configure_Network_Client
(This : in out LMCP_Object_Network_Client_Base;
Subclass_Type_Name : String;
Processing_Kind : Receive_Processing_Type;
Network_Client_XML_Node : DOM.Core.Element;
Result : out Boolean)
is
Unused : Boolean;
begin
-- m_entityId = uxas::common::ConfigurationManager::getInstance().getEntityId();
This.Entity_Id := UxAS.Common.Configuration_Manager.Instance.Get_Entity_Id;
-- m_entityIdString = std::to_string(m_entityId);
Copy (To_String (This.Entity_Id), To => This.Entity_Id_String);
-- m_entityType = uxas::common::ConfigurationManager::getInstance().getEntityType();
Copy (UxAS.Common.Configuration_Manager.Instance.Get_Entity_Type, To => This.Entity_Type);
-- m_networkClientTypeName = subclassTypeName;
Copy (Subclass_Type_Name, To => This.Network_Client_Type_Name);
-- m_receiveProcessingType = receiveProcessingType;
This.Processing_Type := Processing_Kind;
-- // subscribe to messages addressed to network client (bridge, service, etc.)
-- m_entityIdNetworkIdUnicastString = getNetworkClientUnicastAddress(m_entityId, m_networkId);
Copy (Get_Network_Client_Unicast_Address (This.Entity_Id, To_String (This.Network_Id)),
To => This.Entity_Id_Network_Id_Unicast_String);
-- addSubscriptionAddress(m_entityIdNetworkIdUnicastString);
This.Add_Subscription_Address (Entity_Id_Network_Id_Unicast_String (This), Unused);
-- s_entityServicesCastAllAddress = getEntityServicesCastAllAddress(m_entityId);
Copy (Get_Entity_Services_Cast_All_Address (This.Entity_Id),
To => Entity_Services_Cast_All_Address);
-- addSubscriptionAddress(s_entityServicesCastAllAddress);
This.Add_Subscription_Address (Value (Entity_Services_Cast_All_Address), Unused);
-- // network client can be terminated via received KillService message
-- addSubscriptionAddress(uxas::messages::uxnative::KillService::Subscription);
This.Add_Subscription_Address (UxAS.Messages.UxNative.KillService.Subscription, Unused);
-- m_isConfigured = configure(networkClientXmlNode);
Configure (LMCP_Object_Network_Client_Base'Class (This),
XML_Node => Network_Client_XML_Node,
Result => Result);
end Configure_Network_Client;
--------------------------
-- Initialize_And_Start --
--------------------------
procedure Initialize_And_Start (This : in out LMCP_Object_Network_Client_Base; Result : out Boolean) is
begin
if not This.Is_Configured then
Result := False;
return;
end if;
Initialize_Network_Client (This, Result);
if not Result then
return;
end if;
Initialize (LMCP_Object_Network_Client_Base'Class (This), Result); -- dispatch to subclass, which will call this baseclass' version
if not Result then
return;
end if;
Start (LMCP_Object_Network_Client_Base'Class (This), Result); -- dispatch to subclass
if not Result then
return;
end if;
This.Network_Client_Thread := new Network_Client_Processor (This'Unchecked_Access);
end Initialize_And_Start;
------------------------------
-- Network_Client_Processor --
------------------------------
task body Network_Client_Processor is
use Ada.Text_IO;
begin
case Client.Processing_Type is
when LMCP =>
Execute_Network_Client (Client.all); -- loops until shut down
when Serialized_LMCP =>
Execute_Serialized_Network_Client (Client.all); -- loops until shut down
end case;
exception
when Error : others =>
Put_Line ("A Network_Client_Processor task has failed: ");
Put_Line (Exception_Information (Error));
end Network_Client_Processor;
----------------------------
-- Execute_Network_Client --
----------------------------
procedure Execute_Network_Client (This : in out LMCP_Object_Network_Client_Base) is
ReceivedLmcpMessage : Any_LMCP_Message;
use Ada.Text_IO;
begin
This.Is_Thread_Started := True;
while not This.Is_Terminate_Network_Client loop
begin
This.Message_Receiver_Pipe.Get_Next_Message_Object (ReceivedLmcpMessage);
if ReceivedLmcpMessage /= null then
if Should_Kill_This_Service (This, ReceivedLmcpMessage) then
This.Is_Terminate_Network_Client := True;
else
Process_Received_LMCP_Message
(LMCP_Object_Network_Client_Base'Class (This), -- dispatch to subclass version
Received_Message => ReceivedLmcpMessage,
Should_Terminate => This.Is_Terminate_Network_Client);
end if;
end if;
exception
when Error : others =>
Put_Line ("Execute_Network_Client: ");
Put_Line (Exception_Information (Error));
Put_Line ("Execute_Network_Client: continuing");
end;
end loop;
This.Is_Base_Class_Termination_Finished := True;
loop
Stop (LMCP_Object_Network_Client_Base'Class (This), This.Is_Subclass_Termination_Finished); -- dispatch to subclass version
exit when This.Is_Subclass_Termination_Finished;
-- std::this_thread::sleep_for(std::chrono::milliseconds(m_subclassTerminationAttemptPeriod_ms));
delay This.Subclass_Termination_Attempt_Period;
-- subclassTerminateDuration_ms += m_subclassTerminationAttemptPeriod_ms;
-- if (subclassTerminateDuration_ms > m_subclassTerminationWarnDuration_ms)
-- {
-- UXAS_LOG_WARN(m_networkClientTypeName, "::executeNetworkClient has not terminated subclass processing after [", subclassTerminateDuration_ms, "] milliseconds on thread [", std::this_thread::get_id(), "]");
-- }
-- else if (subclassTerminateDuration_ms > m_subclassTerminationAbortDuration_ms)
-- {
-- UXAS_LOG_ERROR(m_networkClientTypeName, "::executeNetworkClient aborting termination of subclass processing after [", subclassTerminateDuration_ms, "] milliseconds on thread [", std::this_thread::get_id(), "]");
-- break;
-- }
end loop;
end Execute_Network_Client;
---------------------------------------
-- Execute_Serialized_Network_Client --
---------------------------------------
procedure Execute_Serialized_Network_Client (This : in out LMCP_Object_Network_Client_Base) is
Next_Received_Serialized_Lmcp_Object : Addressed_Attributed_Message_Ref;
use Ada.Text_IO;
begin
This.Is_Thread_Started := True;
while not This.Is_Terminate_Network_Client loop
begin
This.Message_Receiver_Pipe.Get_Next_Serialized_Message (Next_Received_Serialized_Lmcp_Object);
if Next_Received_Serialized_Lmcp_Object /= null then
if This.Is_Base_Class_Kill_Service_Processing_Permitted and then
Has_KillService_Subscription (Next_Received_Serialized_Lmcp_Object)
then -- reconstitute LMCP object
declare
Lmcp_Object : AVTAS.LMCP.Object.Object_Any;
begin
Lmcp_Object := Deserialzed_Message (Next_Received_Serialized_Lmcp_Object.Payload);
if Should_Kill_This_Service (This, Lmcp_Object) then
This.Is_Terminate_Network_Client := True;
else
Process_Received_Serialized_LMCP_Message
(LMCP_Object_Network_Client_Base'Class (This), -- dispatch to subclass version
Received_Message => Any_Addressed_Attributed_Message (Next_Received_Serialized_Lmcp_Object),
Should_Terminate => This.Is_Terminate_Network_Client);
end if;
end;
end if;
end if;
exception
when Error : others =>
Put_Line ("Execute_Serialized_Network_Client: ");
Put_Line (Exception_Information (Error));
Put_Line ("Execute_Serialized_Network_Client: continuing");
end;
end loop;
This.Is_Base_Class_Termination_Finished := True;
loop
Stop (LMCP_Object_Network_Client_Base'Class (This), This.Is_Subclass_Termination_Finished); -- dispatch to subclass version
exit when This.Is_Subclass_Termination_Finished;
-- std::this_thread::sleep_for(std::chrono::milliseconds(m_subclassTerminationAttemptPeriod_ms));
delay This.Subclass_Termination_Attempt_Period;
-- subclassTerminateDuration_ms += m_subclassTerminationAttemptPeriod_ms;
-- if (subclassTerminateDuration_ms > m_subclassTerminationWarnDuration_ms)
-- {
-- UXAS_LOG_WARN(m_networkClientTypeName, "::executeSerializedNetworkClient has not terminated subclass processing after [", subclassTerminateDuration_ms, "] milliseconds on thread [", std::this_thread::get_id(), "]");
-- }
-- else if (subclassTerminateDuration_ms > m_subclassTerminationAbortDuration_ms)
-- {
-- m_isSubclassTerminationFinished = true;
-- break;
-- }
end loop;
end Execute_Serialized_Network_Client;
-----------------------------------
-- Process_Received_LMCP_Message --
-----------------------------------
procedure Process_Received_LMCP_Message
(This : in out LMCP_Object_Network_Client_Base;
Received_Message : not null Any_LMCP_Message;
Should_Terminate : out Boolean)
is
pragma Unreferenced (This, Received_Message);
begin
Should_Terminate := False; -- per the C++ version
end Process_Received_LMCP_Message;
----------------------------------------------
-- Process_Received_Serialized_LMCP_Message --
----------------------------------------------
procedure Process_Received_Serialized_LMCP_Message
(This : in out LMCP_Object_Network_Client_Base;
Received_Message : not null Any_Addressed_Attributed_Message;
Should_Terminate : out Boolean)
is
pragma Unreferenced (This, Received_Message);
begin
Should_Terminate := False; -- per the C++ version
end Process_Received_Serialized_LMCP_Message;
------------------------------
-- Add_Subscription_Address --
------------------------------
procedure Add_Subscription_Address
(This : in out LMCP_Object_Network_Client_Base;
Address : String;
Success : out Boolean)
is
Target : constant Subscription_Address := Instance (Subscription_Address_Max_Length, Content => Address);
Unused : Boolean;
begin
if This.Is_Thread_Started then
This.Message_Receiver_Pipe.Add_Lmcp_Object_Subscription_Address (Address, Unused);
else
-- replace if already present
Subscription_Addresses.Include (This.Pre_Start_LMCP_Subscription_Addresses, Target);
end if;
Success := True; -- per the C++ implementation
end Add_Subscription_Address;
---------------------------------
-- Remove_Subscription_Address --
---------------------------------
procedure Remove_Subscription_Address
(This : in out LMCP_Object_Network_Client_Base;
Address : String;
Success : out Boolean)
is
Target : constant Subscription_Address := Instance (Subscription_Address_Max_Length, Content => Address);
Unused : Boolean;
begin
if This.Is_Thread_Started then
This.Message_Receiver_Pipe.Remove_Lmcp_Object_Subscription_Address (Address, Unused);
else
-- remove if present
Subscription_Addresses.Exclude (This.Pre_Start_LMCP_Subscription_Addresses, Target);
end if;
Success := False; -- per the C++ implementation!!!!
end Remove_Subscription_Address;
---------------------------------------
-- Remove_All_Subscription_Addresses --
---------------------------------------
procedure Remove_All_Subscription_Addresses
(This : in out LMCP_Object_Network_Client_Base;
Success : out Boolean)
is
Unused : Boolean;
begin
if This.Is_Thread_Started then
This.Message_Receiver_Pipe.Remove_All_Lmcp_Object_Subscription_Address (Unused);
else
Subscription_Addresses.Clear (This.Pre_Start_LMCP_Subscription_Addresses);
end if;
Success := False; -- per the C++ implementation!!!!
end Remove_All_Subscription_Addresses;
-------------------------------------------
-- Send_LMCP_Object_Limited_Cast_Message --
-------------------------------------------
procedure Send_LMCP_Object_Limited_Cast_Message
(This : in out LMCP_Object_Network_Client_Base;
CastAddress : String;
Msg : not null AVTAS.LMCP.Object.Object_Any)
is
begin
Unique_Entity_Send_Message_Id := Unique_Entity_Send_Message_Id + 1;
This.Message_Sender_Pipe.Send_LimitedCast_Message (CastAddress, Msg);
end Send_LMCP_Object_Limited_Cast_Message;
----------------------------------------
-- Send_LMCP_Object_Broadcast_Message --
----------------------------------------
procedure Send_LMCP_Object_Broadcast_Message
(This : in out LMCP_Object_Network_Client_Base;
Msg : not null AVTAS.LMCP.Object.Object_Any)
is
begin
Unique_Entity_Send_Message_Id := Unique_Entity_Send_Message_Id + 1;
This.Message_Sender_Pipe.Send_Broadcast_Message (Msg);
end Send_LMCP_Object_Broadcast_Message;
-----------------------------------------
-- Send_Serialized_LMCP_Object_Message --
-----------------------------------------
procedure Send_Serialized_LMCP_Object_Message
(This : in out LMCP_Object_Network_Client_Base;
Msg : not null Addressed_Attributed_Message_Ref)
is
begin
Unique_Entity_Send_Message_Id := Unique_Entity_Send_Message_Id + 1;
This.Message_Sender_Pipe.Send_Serialized_Message (Msg);
end Send_Serialized_LMCP_Object_Message;
-----------------------------------------------
-- Send_Shared_LMCP_Object_Broadcast_Message --
-----------------------------------------------
procedure Send_Shared_LMCP_Object_Broadcast_Message
(This : in out LMCP_Object_Network_Client_Base;
Msg : not null AVTAS.LMCP.Object.Object_Any)
is
begin
Unique_Entity_Send_Message_Id := Unique_Entity_Send_Message_Id + 1;
This.Message_Sender_Pipe.Send_Shared_Broadcast_Message (Msg);
end Send_Shared_LMCP_Object_Broadcast_Message;
--------------------------------------------------
-- Send_Shared_LMCP_Object_Limited_Cast_Message --
--------------------------------------------------
procedure Send_Shared_LMCP_Object_Limited_Cast_Message
(This : in out LMCP_Object_Network_Client_Base;
Cast_Address : String;
Msg : not null AVTAS.LMCP.Object.Object_Any)
is
begin
Unique_Entity_Send_Message_Id := Unique_Entity_Send_Message_Id + 1;
This.Message_Sender_Pipe.Send_Shared_LimitedCast_Message (Cast_Address, Msg);
end Send_Shared_LMCP_Object_Limited_Cast_Message;
---------------
-- Entity_Id --
---------------
function Entity_Id (This : LMCP_Object_Network_Client_Base) return UInt32 is
(This.Entity_Id);
----------------------
-- Entity_Id_String --
----------------------
function Entity_Id_String (This : LMCP_Object_Network_Client_Base) return String is
(Value (This.Entity_Id_String));
----------------
-- Network_Id --
----------------
function Network_Id (This : LMCP_Object_Network_Client_Base) return Int64 is
(This.Network_Id);
-----------------------
-- Network_Id_String --
-----------------------
function Network_Id_String (This : LMCP_Object_Network_Client_Base) return String is
(Value (This.Network_Id_String));
-----------------------------------------
-- Entity_Id_Network_Id_Unicast_String --
-----------------------------------------
function Entity_Id_Network_Id_Unicast_String (This : LMCP_Object_Network_Client_Base) return String is
(Value (This.Entity_Id_Network_Id_Unicast_String));
------------------------------
-- Network_Client_Type_Name --
------------------------------
function Network_Client_Type_Name (This : LMCP_Object_Network_Client_Base) return String is
(Value (This.Network_Client_Type_Name));
-----------
-- Start --
-----------
procedure Start
(This : in out LMCP_Object_Network_Client_Base;
Result : out Boolean)
is
pragma Unreferenced (This); -- by design
begin
Result := True;
end Start;
----------
-- Stop --
----------
procedure Stop
(This : in out LMCP_Object_Network_Client_Base;
Result : out Boolean)
is
pragma Unreferenced (This); -- by design
begin
Result := True;
end Stop;
------------------------------
-- Should_Kill_This_Service --
------------------------------
function Should_Kill_This_Service
(This : LMCP_Object_Network_Client_Base;
Msg : Any_LMCP_Message)
return Boolean
is
use UxAS.Messages.UxNative.KillService;
-- the lmcpgen C++ generated code in class KillService has these static functions:
--
-- // Subscription string is namespace separated by '.' followed by type name
-- const std::string KillService::Subscription = "uxas.messages.uxnative.KillService";
-- const std::string KillService::TypeName = "KillService";
-- const std::string KillService::SeriesName = "UXNATIVE";
-- const int64_t KillService::SeriesId = 6149751333668345413LL;
-- const uint16_t KillService::SeriesVersion = 9;
-- const uint32_t KillService::TypeId = 4;
--
-- bool isKillService(AVTAS::lmcp::Object* obj)
-- {
-- if(!obj) return false;
-- if(obj->getSeriesNameAsLong() != 6149751333668345413LL) return false;
-- if(obj->getSeriesVersion() != 9) return false;
-- if(obj->getLmcpType() != 4) return false;
-- return true;
-- }
begin
if not This.Is_Base_Class_Kill_Service_Processing_Permitted then
return False;
end if;
-- && uxas::messages::uxnative::isKillService(receivedLmcpMessage->m_object)
if Msg.Payload.all not in KillService'Class then
return False;
end if;
-- check KillService serviceID == my serviceID
-- && m_networkIdString.compare
-- (std::to_string(std::static_pointer_cast<uxas::messages::uxnative::KillService>(receivedLmcpMessage->m_object)->getServiceID()))
-- == 0)
return This.Network_Id_String = To_String (KillService (Msg.Payload.all).getServiceID);
end Should_Kill_This_Service;
------------------------------
-- Should_Kill_This_Service --
------------------------------
function Should_Kill_This_Service
(This : LMCP_Object_Network_Client_Base;
Msg : AVTAS.LMCP.Object.Object_Any)
return Boolean
is
use UxAS.Messages.UxNative.KillService;
begin
if not This.Is_Base_Class_Kill_Service_Processing_Permitted then
return False;
end if;
-- if (uxas::messages::uxnative::isKillService(lmcpObject)
if Msg.all not in KillService'Class then
return False;
end if;
-- check KillService serviceID == my serviceID
-- //&& m_entityIdString.compare(std::static_pointer_cast<uxas::messages::uxnative::KillService>(lmcpObject)->getEntityID()) == 0//TODO check entityID
-- && m_networkIdString.compare(std::to_string(std::static_pointer_cast<uxas::messages::uxnative::KillService>(lmcpObject)->getServiceID())) == 0)
return This.Network_Id_String = To_String (KillService (Msg.all).getServiceID);
end Should_Kill_This_Service;
----------------------------------
-- Has_KillService_Subscription --
----------------------------------
function Has_KillService_Subscription (Msg : Addressed_Attributed_Message_Ref) return Boolean is
Descriptor : constant String := Msg.Message_Attributes_Reference.Payload_Descriptor;
Target : constant String := UxAS.Messages.UxNative.KillService.Subscription;
Pos : Natural;
use Ada.Strings;
begin
-- && nextReceivedSerializedLmcpObject->getMessageAttributesReference()->getDescriptor()
-- .rfind(uxas::messages::uxnative::KillService::Subscription) != std::string::npos)
Pos := Ada.Strings.Fixed.Index (Source => Descriptor, Pattern => Target, Going => Backward);
return Pos /= 0;
end Has_KillService_Subscription;
end UxAS.Comms.LMCP_Net_Client;
|
reznikmm/matreshka | Ada | 4,998 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Final_States.Collections is
pragma Preelaborate;
package UML_Final_State_Collections is
new AMF.Generic_Collections
(UML_Final_State,
UML_Final_State_Access);
type Set_Of_UML_Final_State is
new UML_Final_State_Collections.Set with null record;
Empty_Set_Of_UML_Final_State : constant Set_Of_UML_Final_State;
type Ordered_Set_Of_UML_Final_State is
new UML_Final_State_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Final_State : constant Ordered_Set_Of_UML_Final_State;
type Bag_Of_UML_Final_State is
new UML_Final_State_Collections.Bag with null record;
Empty_Bag_Of_UML_Final_State : constant Bag_Of_UML_Final_State;
type Sequence_Of_UML_Final_State is
new UML_Final_State_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Final_State : constant Sequence_Of_UML_Final_State;
private
Empty_Set_Of_UML_Final_State : constant Set_Of_UML_Final_State
:= (UML_Final_State_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Final_State : constant Ordered_Set_Of_UML_Final_State
:= (UML_Final_State_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Final_State : constant Bag_Of_UML_Final_State
:= (UML_Final_State_Collections.Bag with null record);
Empty_Sequence_Of_UML_Final_State : constant Sequence_Of_UML_Final_State
:= (UML_Final_State_Collections.Sequence with null record);
end AMF.UML.Final_States.Collections;
|
AdaCore/langkit | Ada | 2,643 | adb | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with GNATCOLL.GMP.Integers; use GNATCOLL.GMP.Integers;
with Libfoolang.Analysis; use Libfoolang.Analysis;
procedure Main is
type Integer_Array is array (Positive range <>) of Integer;
procedure BIA (Big_Ints : out Big_Integer_Array; Ints : Integer_Array);
-- Build the array of big integers corresponding to the ``Values`` array of
-- integers.
function Image (Values : Big_Integer_Array) return String;
-- Serialize an array of big integers
procedure Check (Left, Right : Big_Integer_Array);
-- Report about the result of ``Left = Right``
---------
-- BIA --
---------
procedure BIA (Big_Ints : out Big_Integer_Array; Ints : Integer_Array) is
begin
for I in 0 .. Big_Ints'Length - 1 loop
Big_Ints (Big_Ints'First + I).Set
(GNATCOLL.GMP.Long (Ints (Ints'First + I)));
end loop;
end BIA;
-----------
-- Image --
-----------
function Image (Values : Big_Integer_Array) return String is
Result : Unbounded_String;
begin
Append (Result, "(");
Append (Result, Integer'Image (Values'First));
Append (Result, " .. ");
Append (Result, Integer'Image (Values'Last));
Append (Result, " => ");
if Values'Length = 0 then
Append (Result, "<>");
end if;
for I in Values'Range loop
if I > Values'First then
Append (Result, ", ");
end if;
Append (Result, Image (Values (I)));
end loop;
Append (Result, ")");
return To_String (Result);
end Image;
-----------
-- Check --
-----------
procedure Check (Left, Right : Big_Integer_Array) is
begin
Put_Line (Image (Left) & " = " & Image (Right) & " = "
& Boolean'Image (Left = Right));
end Check;
Empty_1 : constant Big_Integer_Array (1 .. 0) := (1 .. 0 => <>);
Empty_2 : constant Big_Integer_Array (10 .. 9) := (10 .. 9 => <>);
Single_10_A : Big_Integer_Array (1 .. 1);
Single_10_B : Big_Integer_Array (10 .. 10);
Triple_1 : Big_Integer_Array (1 .. 3);
Triple_2 : Big_Integer_Array (1 .. 3);
Triple_3 : Big_Integer_Array (1 .. 3);
begin
BIA (Single_10_A, (1 => 10));
BIA (Single_10_B, (1 => 20));
BIA (Triple_1, (1, 2, 3));
BIA (Triple_2, (1, 2, 3));
BIA (Triple_3, (1, 3, 2));
Check (Empty_1, Empty_2);
Check (Empty_1, Single_10_A);
Check (Empty_1, Triple_1);
Check (Single_10_A, Single_10_B);
Check (Triple_1, Triple_2);
Check (Triple_1, Triple_3);
Put_Line ("Done.");
end Main;
|
zhmu/ananas | Ada | 5,454 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . E X C E P T I O N _ T R A C E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2000-2022, 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. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with System.Standard_Library; use System.Standard_Library;
with System.Soft_Links; use System.Soft_Links;
package body System.Exception_Traces is
-- Calling the decorator directly from where it is needed would require
-- introducing nasty dependencies upon the spec of this package (typically
-- in a-except.adb). We also have to deal with the fact that the traceback
-- array within an exception occurrence and the one the decorator accepts
-- are of different types. These are two reasons for which a wrapper with
-- a System.Address argument is indeed used to call the decorator provided
-- by the user of this package. This wrapper is called via a soft-link,
-- which either is null when no decorator is in place or "points to" the
-- following function otherwise.
function Decorator_Wrapper
(Traceback : System.Address;
Len : Natural) return String;
-- The wrapper to be called when a decorator is in place for exception
-- backtraces.
--
-- Traceback is the address of the call chain array as stored in the
-- exception occurrence and Len is the number of significant addresses
-- contained in this array.
Current_Decorator : Traceback_Decorator := null;
-- The decorator to be called by the wrapper when it is not null, as set
-- by Set_Trace_Decorator. When this access is null, the wrapper is null
-- also and shall then not be called.
-----------------------
-- Decorator_Wrapper --
-----------------------
function Decorator_Wrapper
(Traceback : System.Address;
Len : Natural) return String
is
subtype Trace_Array is Traceback_Entries.Tracebacks_Array (1 .. Len);
type Trace_Array_Access is access all Trace_Array;
function To_Trace_Array is new
Ada.Unchecked_Conversion (Address, Trace_Array_Access);
Decorator_Traceback : constant Trace_Array_Access :=
To_Trace_Array (Traceback);
begin
return Current_Decorator.all (Decorator_Traceback.all);
end Decorator_Wrapper;
-------------------------
-- Set_Trace_Decorator --
-------------------------
procedure Set_Trace_Decorator (Decorator : Traceback_Decorator) is
begin
Current_Decorator := Decorator;
Traceback_Decorator_Wrapper :=
(if Current_Decorator /= null
then Decorator_Wrapper'Access else null);
end Set_Trace_Decorator;
---------------
-- Trace_Off --
---------------
procedure Trace_Off is
begin
Exception_Trace := RM_Convention;
end Trace_Off;
--------------
-- Trace_On --
--------------
procedure Trace_On (Kind : Trace_Kind) is
begin
case Kind is
when Every_Raise =>
Exception_Trace := Every_Raise;
when Unhandled_Raise =>
Exception_Trace := Unhandled_Raise;
when Unhandled_Raise_In_Main =>
Exception_Trace := Unhandled_Raise_In_Main;
end case;
end Trace_On;
end System.Exception_Traces;
|
AdaCore/gpr | Ada | 44 | ads | package adalib is
pragma Pure;
end adalib; |
stcarrez/ada-rest-api-server-benchmark | Ada | 1,230 | adb | -----------------------------------------------------------------------
-- rest_api - REST API with EWS
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EWS.Types;
package body Rest_Api is
function Get (Request : EWS.HTTP.Request_P) return EWS.Dynamic.Dynamic_Response'Class is
Result : EWS.Dynamic.Dynamic_Response (Request);
begin
EWS.Dynamic.Set_Content_Type (Result, To => EWS.Types.JSON);
EWS.Dynamic.Set_Content (Result, "{""greeting"":""Hello World!""}");
return Result;
end Get;
end Rest_Api;
|
stcarrez/babel | Ada | 1,934 | ads | -----------------------------------------------------------------------
-- babel-strategies-workers -- Tasks that perform strategy work
-- Copyright (C) 2014 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
generic
type Worker_Strategy is limited new Babel.Strategies.Strategy_Type with private;
package Babel.Strategies.Workers is
type Worker_Type (Count : Positive) is limited private;
procedure Configure (Worker : in out Worker_Type;
Process : not null access procedure (S : in out Worker_Strategy));
procedure Start (Worker : in out Worker_Type);
procedure Finish (Worker : in out Worker_Type;
Database : in out Babel.Base.Database'Class);
private
task type Worker_Task is
entry Start (Strategy : in Babel.Strategies.Strategy_Type_Access);
entry Finish (Database : in out Babel.Base.Database'Class);
end Worker_Task;
type Worker_Task_Array is array (Positive range <>) of Worker_Task;
type Strategy_Array is array (Positive range <>) of aliased Worker_Strategy;
type Worker_Type (Count : Positive) is limited record
Workers : Worker_Task_Array (1 .. Count);
Strategies : Strategy_Array (1 .. Count);
end record;
end Babel.Strategies.Workers;
|
stcarrez/ada-util | Ada | 1,721 | adb | -----------------------------------------------------------------------
-- wget -- A simple wget command to fetch a page
-- Copyright (C) 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Command_Line;
with Util.Http.Clients;
with Util.Http.Clients.Curl;
procedure Wget is
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count = 0 then
Ada.Text_IO.Put_Line ("Usage: wget url ...");
Ada.Text_IO.Put_Line ("Example: wget http://www.adacore.com");
return;
end if;
Util.Http.Clients.Curl.Register;
for I in 1 .. Count loop
declare
Http : Util.Http.Clients.Client;
URI : constant String := Ada.Command_Line.Argument (I);
Response : Util.Http.Clients.Response;
begin
Http.Add_Header ("X-Requested-By", "wget");
Http.Get (URI, Response);
Ada.Text_IO.Put_Line ("Code: " & Natural'Image (Response.Get_Status));
Ada.Text_IO.Put_Line (Response.Get_Body);
end;
end loop;
end Wget;
|
tum-ei-rcs/StratoX | Ada | 3,072 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . M C U _ P A R A M E T E R S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2016, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
-- This package defines MCU parameters for the STM32F429x family
with Interfaces.STM32.PWR;
with Interfaces.Bit_Types;
package System.BB.MCU_Parameters is
pragma Preelaborate;
use type Interfaces.Bit_Types.Bit;
Number_Of_Interrupts : constant := 92;
procedure PWR_Initialize;
procedure PWR_Overdrive_Enable;
function Is_PWR_Stabilized return Boolean
is (Interfaces.STM32.PWR.PWR_Periph.CSR.VOSRDY = 1);
end System.BB.MCU_Parameters;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 17,214 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF51_SVD.MPU is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- POWER_CLOCK region configuration.
type PERR0_POWER_CLOCK_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_POWER_CLOCK_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- RADIO region configuration.
type PERR0_RADIO_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_RADIO_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- UART0 region configuration.
type PERR0_UART0_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_UART0_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- SPI0 and TWI0 region configuration.
type PERR0_SPI0_TWI0_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_SPI0_TWI0_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- SPI1 and TWI1 region configuration.
type PERR0_SPI1_TWI1_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_SPI1_TWI1_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- GPIOTE region configuration.
type PERR0_GPIOTE_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_GPIOTE_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- ADC region configuration.
type PERR0_ADC_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_ADC_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- TIMER0 region configuration.
type PERR0_TIMER0_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_TIMER0_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- PERR0_TIMER array
type PERR0_TIMER_Field_Array is array (0 .. 2) of PERR0_TIMER0_Field
with Component_Size => 1, Size => 3;
-- Type definition for PERR0_TIMER
type PERR0_TIMER_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TIMER as a value
Val : HAL.UInt3;
when True =>
-- TIMER as an array
Arr : PERR0_TIMER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 3;
for PERR0_TIMER_Field use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- RTC0 region configuration.
type PERR0_RTC0_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_RTC0_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- TEMP region configuration.
type PERR0_TEMP_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_TEMP_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- RNG region configuration.
type PERR0_RNG_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_RNG_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- ECB region configuration.
type PERR0_ECB_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_ECB_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- CCM and AAR region configuration.
type PERR0_CCM_AAR_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_CCM_AAR_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- WDT region configuration.
type PERR0_WDT_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_WDT_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- RTC1 region configuration.
type PERR0_RTC1_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_RTC1_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- QDEC region configuration.
type PERR0_QDEC_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_QDEC_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- LPCOMP region configuration.
type PERR0_LPCOMP_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_LPCOMP_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- NVMC region configuration.
type PERR0_NVMC_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_NVMC_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- PPI region configuration.
type PERR0_PPI_Field is
(
-- Peripheral configured in region 1.
Inregion1,
-- Peripheral configured in region 0.
Inregion0)
with Size => 1;
for PERR0_PPI_Field use
(Inregion1 => 0,
Inregion0 => 1);
-- Configuration of peripherals in mpu regions.
type PERR0_Register is record
-- POWER_CLOCK region configuration.
POWER_CLOCK : PERR0_POWER_CLOCK_Field := NRF51_SVD.MPU.Inregion1;
-- RADIO region configuration.
RADIO : PERR0_RADIO_Field := NRF51_SVD.MPU.Inregion1;
-- UART0 region configuration.
UART0 : PERR0_UART0_Field := NRF51_SVD.MPU.Inregion1;
-- SPI0 and TWI0 region configuration.
SPI0_TWI0 : PERR0_SPI0_TWI0_Field := NRF51_SVD.MPU.Inregion1;
-- SPI1 and TWI1 region configuration.
SPI1_TWI1 : PERR0_SPI1_TWI1_Field := NRF51_SVD.MPU.Inregion1;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- GPIOTE region configuration.
GPIOTE : PERR0_GPIOTE_Field := NRF51_SVD.MPU.Inregion1;
-- ADC region configuration.
ADC : PERR0_ADC_Field := NRF51_SVD.MPU.Inregion1;
-- TIMER0 region configuration.
TIMER : PERR0_TIMER_Field := (As_Array => False, Val => 16#0#);
-- RTC0 region configuration.
RTC0 : PERR0_RTC0_Field := NRF51_SVD.MPU.Inregion1;
-- TEMP region configuration.
TEMP : PERR0_TEMP_Field := NRF51_SVD.MPU.Inregion1;
-- RNG region configuration.
RNG : PERR0_RNG_Field := NRF51_SVD.MPU.Inregion1;
-- ECB region configuration.
ECB : PERR0_ECB_Field := NRF51_SVD.MPU.Inregion1;
-- CCM and AAR region configuration.
CCM_AAR : PERR0_CCM_AAR_Field := NRF51_SVD.MPU.Inregion1;
-- WDT region configuration.
WDT : PERR0_WDT_Field := NRF51_SVD.MPU.Inregion1;
-- RTC1 region configuration.
RTC1 : PERR0_RTC1_Field := NRF51_SVD.MPU.Inregion1;
-- QDEC region configuration.
QDEC : PERR0_QDEC_Field := NRF51_SVD.MPU.Inregion1;
-- LPCOMP region configuration.
LPCOMP : PERR0_LPCOMP_Field := NRF51_SVD.MPU.Inregion1;
-- unspecified
Reserved_20_29 : HAL.UInt10 := 16#0#;
-- NVMC region configuration.
NVMC : PERR0_NVMC_Field := NRF51_SVD.MPU.Inregion1;
-- PPI region configuration.
PPI : PERR0_PPI_Field := NRF51_SVD.MPU.Inregion1;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PERR0_Register use record
POWER_CLOCK at 0 range 0 .. 0;
RADIO at 0 range 1 .. 1;
UART0 at 0 range 2 .. 2;
SPI0_TWI0 at 0 range 3 .. 3;
SPI1_TWI1 at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
GPIOTE at 0 range 6 .. 6;
ADC at 0 range 7 .. 7;
TIMER at 0 range 8 .. 10;
RTC0 at 0 range 11 .. 11;
TEMP at 0 range 12 .. 12;
RNG at 0 range 13 .. 13;
ECB at 0 range 14 .. 14;
CCM_AAR at 0 range 15 .. 15;
WDT at 0 range 16 .. 16;
RTC1 at 0 range 17 .. 17;
QDEC at 0 range 18 .. 18;
LPCOMP at 0 range 19 .. 19;
Reserved_20_29 at 0 range 20 .. 29;
NVMC at 0 range 30 .. 30;
PPI at 0 range 31 .. 31;
end record;
-- Protection enable for region 0.
type PROTENSET0_PROTREG0_Field is
(
-- Protection disabled.
Disabled,
-- Protection enabled.
Enabled)
with Size => 1;
for PROTENSET0_PROTREG0_Field use
(Disabled => 0,
Enabled => 1);
-- Protection enable for region 0.
type PROTENSET0_PROTREG0_Field_1 is
(
-- Reset value for the field
Protenset0_Protreg0_Field_Reset,
-- Enable protection on write.
Set)
with Size => 1;
for PROTENSET0_PROTREG0_Field_1 use
(Protenset0_Protreg0_Field_Reset => 0,
Set => 1);
-- PROTENSET0_PROTREG array
type PROTENSET0_PROTREG_Field_Array is array (0 .. 31)
of PROTENSET0_PROTREG0_Field_1
with Component_Size => 1, Size => 32;
-- Erase and write protection bit enable set register.
type PROTENSET0_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PROTREG as a value
Val : HAL.UInt32;
when True =>
-- PROTREG as an array
Arr : PROTENSET0_PROTREG_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for PROTENSET0_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Protection enable for region 32.
type PROTENSET1_PROTREG32_Field is
(
-- Protection disabled.
Disabled,
-- Protection enabled.
Enabled)
with Size => 1;
for PROTENSET1_PROTREG32_Field use
(Disabled => 0,
Enabled => 1);
-- Protection enable for region 32.
type PROTENSET1_PROTREG32_Field_1 is
(
-- Reset value for the field
Protenset1_Protreg32_Field_Reset,
-- Enable protection on write.
Set)
with Size => 1;
for PROTENSET1_PROTREG32_Field_1 use
(Protenset1_Protreg32_Field_Reset => 0,
Set => 1);
-- PROTENSET1_PROTREG array
type PROTENSET1_PROTREG_Field_Array is array (32 .. 63)
of PROTENSET1_PROTREG32_Field_1
with Component_Size => 1, Size => 32;
-- Erase and write protection bit enable set register.
type PROTENSET1_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PROTREG as a value
Val : HAL.UInt32;
when True =>
-- PROTREG as an array
Arr : PROTENSET1_PROTREG_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for PROTENSET1_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Disable protection mechanism in debug mode.
type DISABLEINDEBUG_DISABLEINDEBUG_Field is
(
-- Protection enabled.
Enabled,
-- Protection disabled.
Disabled)
with Size => 1;
for DISABLEINDEBUG_DISABLEINDEBUG_Field use
(Enabled => 0,
Disabled => 1);
-- Disable erase and write protection mechanism in debug mode.
type DISABLEINDEBUG_Register is record
-- Disable protection mechanism in debug mode.
DISABLEINDEBUG : DISABLEINDEBUG_DISABLEINDEBUG_Field :=
NRF51_SVD.MPU.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DISABLEINDEBUG_Register use record
DISABLEINDEBUG at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Erase and write protection block size.
type PROTBLOCKSIZE_PROTBLOCKSIZE_Field is
(
-- Erase and write protection block size is 4k.
PROTBLOCKSIZE_PROTBLOCKSIZE_Field_4K)
with Size => 2;
for PROTBLOCKSIZE_PROTBLOCKSIZE_Field use
(PROTBLOCKSIZE_PROTBLOCKSIZE_Field_4K => 0);
-- Erase and write protection block size.
type PROTBLOCKSIZE_Register is record
-- Erase and write protection block size.
PROTBLOCKSIZE : PROTBLOCKSIZE_PROTBLOCKSIZE_Field :=
NRF51_SVD.MPU.PROTBLOCKSIZE_PROTBLOCKSIZE_Field_4K;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PROTBLOCKSIZE_Register use record
PROTBLOCKSIZE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Memory Protection Unit.
type MPU_Peripheral is record
-- Configuration of peripherals in mpu regions.
PERR0 : aliased PERR0_Register;
-- Length of RAM region 0.
RLENR0 : aliased HAL.UInt32;
-- Erase and write protection bit enable set register.
PROTENSET0 : aliased PROTENSET0_Register;
-- Erase and write protection bit enable set register.
PROTENSET1 : aliased PROTENSET1_Register;
-- Disable erase and write protection mechanism in debug mode.
DISABLEINDEBUG : aliased DISABLEINDEBUG_Register;
-- Erase and write protection block size.
PROTBLOCKSIZE : aliased PROTBLOCKSIZE_Register;
end record
with Volatile;
for MPU_Peripheral use record
PERR0 at 16#528# range 0 .. 31;
RLENR0 at 16#52C# range 0 .. 31;
PROTENSET0 at 16#600# range 0 .. 31;
PROTENSET1 at 16#604# range 0 .. 31;
DISABLEINDEBUG at 16#608# range 0 .. 31;
PROTBLOCKSIZE at 16#60C# range 0 .. 31;
end record;
-- Memory Protection Unit.
MPU_Periph : aliased MPU_Peripheral
with Import, Address => System'To_Address (16#40000000#);
end NRF51_SVD.MPU;
|
reznikmm/matreshka | Ada | 3,644 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Text_Note_Elements is
pragma Preelaborate;
type ODF_Text_Note is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Note_Access is
access all ODF_Text_Note'Class
with Storage_Size => 0;
end ODF.DOM.Text_Note_Elements;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.