repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
joakim-strandberg/wayland_ada_binding | Ada | 7,726 | ads | with Ada.Containers;
package Aida with Pure, SPARK_Mode is
subtype Digit_Character is Character with
Predicate =>
Digit_Character = '0' or
Digit_Character = '1' or
Digit_Character = '2' or
Digit_Character = '3' or
Digit_Character = '4' or
Digit_Character = '5' or
Digit_Character = '6' or
Digit_Character = '7' or
Digit_Character = '8' or
Digit_Character = '9';
-- It is more useful with a subtype for digit characters than
-- an function Is_Digit (C : Character) return Boolean;
-- Consider for example case-statements:
--
-- C : Character;
--
-- case Digit_Character (C) is
-- when '0' => ..
-- ...
-- when '9' => ..
-- end case;
function To_Integer (Source : in Digit_Character) return Integer with
Post => To_Integer'Result in 0 .. 9;
procedure To_Integer (Source : in Character;
Target : out Integer) with
Pre => Source in Digit_Character,
Post => Target in 0 .. 9 and Target = To_Integer (Source);
function Is_One_Byte_UTF8 (C : Character) return Boolean is
(Character'Pos (C) <= 127);
-- A UTF8 code point can be represented by 1-4 characters.
-- The first 128 characters (US-ASCII) need only one byte.
function To_Hash_Type (This : Integer) return Ada.Containers.Hash_Type with
Global => null;
-- Calculates the hash of an 32-bit Integer based upon the following post
-- on Stackoverlow:
-- http://stackoverflow.com/questions/664014/
-- what-Integer-hash-function-are-good-that-accepts-an-Integer-hash-key
--
-- I found the following algorithm provides
-- a very good statistical distribution.
-- Each input bit affects each output bit with about 50% probability.
-- There are no collisions (each input results in a different output).
-- The algorithm is fast except if the CPU doesn't have a
-- built-in Integer multiplication unit. C-Code:
--
-- unsigned int hash(unsigned int x) {
-- x = ((x >> 16) ^ x) * 0x45d9f3b;
-- x = ((x >> 16) ^ x) * 0x45d9f3b;
-- x = (x >> 16) ^ x;
-- return x;
-- }
--
-- The magic number was calculated using a special multi-threaded
-- test program that ran for many hours,
-- which calculates the avalanche effect
-- (the number of output bits that change if a single input bit is changed;
-- should be nearly 16 on average), independence of output bit changes
-- (output bits should not depend on each other),
-- and the probability of a change in each output bit if any input bit
-- is changed. The calculated values are better than the 32-bit finalizer
-- used by MurmurHash, and nearly as good (not quite) as when using AES.
function To_Hash_Type (This : String) return Ada.Containers.Hash_Type with
Global => null;
function To_String (This : Integer) return String with
Global => null,
Post =>
(if This < 0 then
To_String'Result'Length >= 2 and To_String'Result'Length <= 11
else
To_String'Result'Length >= 1 and To_String'Result'Length <= 10);
function To_Char (This : Integer) return Character with
Global => null,
Pre => This >= 0 and This <= 9;
function To_String (This : Float) return String with
Global => null,
Post => To_String'Result'Length >= 1 and To_String'Result'Length <= 11;
procedure To_Integer
(Source : in String;
Target : out Integer;
Has_Failed : out Boolean) with
Global => null;
procedure To_Float (Source : in String;
Target : out Float;
Has_Failed : out Boolean) with
Global => null;
function Is_Latin1_Graphic_Characters (Text : String) return Boolean with
Global => null;
function Starts_With (This : String;
Searched_For : String) return Boolean with
Global => null,
Pre => Searched_For'Length > 0;
function Concat (Left, Right : String) return String with
Global => null,
Pre =>
(Left'Length < Positive'Last / 2 and
Right'Length < Positive'Last / 2),
Post => Concat'Result'Length = Left'Length + Right'Length;
type Max_Hash_Map_Size_T is range 3 .. 2**31;
type Bounded_String (Maximum_Length : Positive) is limited private with
Default_Initial_Condition => Length (Bounded_String) = 0;
procedure Initialize (This : in out Bounded_String; Text : String) with
Global => null,
Pre => Text'Length <= This.Maximum_Length,
Post => Length (This) = Text'Length;
procedure Initialize2 (This : out Bounded_String; Text : String) with
Global => null,
Pre => Text'Length <= This.Maximum_Length,
Post => Length (This) = Text'Length;
procedure Append (Target : in out Bounded_String; Source : String) with
Global => null,
Pre => Source'Length <= Target.Maximum_Length - Length (Target),
Post => Length (Target) <= Target.Maximum_Length;
function Length (This : Bounded_String) return Natural with
Global => null;
-- Compare the Length function with the Length function
-- in Ada.Containers.Formal_Vectors. Notice the post-condition!
function Equals (This : Bounded_String; Object : String) return Boolean with
Global => null,
Pre => Length (This) <= This.Maximum_Length;
function "=" (Left, Right : Bounded_String) return Boolean with
Global => null,
Pre => Length (Left) <= Left.Maximum_Length and
Length (Right) <= Right.Maximum_Length;
function "=" (Left : Bounded_String; Right : String) return Boolean with
Global => null,
Pre => Length (Left) <= Left.Maximum_Length;
-- Although the arguments are of different types,
-- they may still represent the same String.
function To_Hash_Type
(This : Bounded_String) return Ada.Containers.Hash_Type with
Global => null,
Pre => Length (This) <= This.Maximum_Length;
function To_String (This : Bounded_String) return String with
Global => null,
Pre => Length (This) <= This.Maximum_Length;
type Call_Result is tagged limited private with
Default_Initial_Condition => Call_Result.Has_Failed = False;
procedure Initialize (This : in out Call_Result;
Code_1 : Integer;
Code_2 : Integer) with
Global => null,
Pre'Class => not Has_Failed (This),
Post'Class => This.Has_Failed = True;
function Has_Failed (This : Call_Result) return Boolean with
Global => null;
function Message (This : Call_Result) return String with
Global => null;
private
type Bounded_String (Maximum_Length : Positive) is limited record
Text : String (1 .. Maximum_Length) := (others => ' ');
Text_Length : Natural := 0;
end record;
function Length (This : Bounded_String) return Natural is (This.Text_Length);
function "=" (Left, Right : Bounded_String) return Boolean is
(Length (Left) = Length (Right)
and then
(for all I in Positive range 1 .. Left.Text_Length =>
Left.Text (I) = Right.Text (I)));
function "=" (Left : Bounded_String; Right : String) return Boolean is
(Equals (Left, Right));
type Call_Result is tagged limited
record
My_Code_1 : Integer := 0;
My_Code_2 : Integer := 0;
My_Has_Failed : Boolean := False;
end record;
function Has_Failed (This : Call_Result) return Boolean is
(This.My_Has_Failed);
end Aida;
|
zhmu/ananas | Ada | 338 | ads | with Atomic11_Pkg2;
package Atomic11_Pkg1 is
type Rec1 is record
I : Integer;
end record;
procedure Proc1 (R : Rec1);
pragma Import (C, Proc1);
type Arr is array (Positive range <>) of Integer;
type Rec2 is record
A : Arr (1 .. Atomic11_Pkg2.Max);
end record;
procedure Proc2 (R : Rec2);
end Atomic11_Pkg1;
|
reznikmm/matreshka | Ada | 4,027 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Leader_Color_Attributes;
package Matreshka.ODF_Style.Leader_Color_Attributes is
type Style_Leader_Color_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Leader_Color_Attributes.ODF_Style_Leader_Color_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Leader_Color_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Leader_Color_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Leader_Color_Attributes;
|
reznikmm/matreshka | Ada | 18,334 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.Tables.CMOF_Attributes;
with AMF.Internals.Element_Collections;
with AMF.Visitors.CMOF_Iterators;
with AMF.Visitors.CMOF_Visitors;
package body AMF.Internals.CMOF_Associations is
use AMF.Internals.Tables.CMOF_Attributes;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant CMOF_Association_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then
AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class
(Visitor).Enter_Association
(AMF.CMOF.Associations.CMOF_Association_Access (Self),
Control);
end if;
end Enter_Element;
------------------
-- Get_End_Type --
------------------
overriding function Get_End_Type
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Types.Collections.Set_Of_CMOF_Type is
begin
return
AMF.CMOF.Types.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_End_Type (Self.Element)));
end Get_End_Type;
--------------------
-- Get_Is_Derived --
--------------------
overriding function Get_Is_Derived
(Self : not null access constant CMOF_Association_Proxy) return Boolean is
begin
return Internal_Get_Is_Derived (Self.Element);
end Get_Is_Derived;
--------------------
-- Get_Member_End --
--------------------
overriding function Get_Member_End
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property is
begin
return
AMF.CMOF.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Member_End (Self.Element)));
end Get_Member_End;
-----------------------------
-- Get_Navigable_Owned_End --
-----------------------------
overriding function Get_Navigable_Owned_End
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property is
begin
return
AMF.CMOF.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Navigable_Owned_End (Self.Element)));
end Get_Navigable_Owned_End;
-------------------
-- Get_Owned_End --
-------------------
overriding function Get_Owned_End
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property is
begin
return
AMF.CMOF.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Owned_End (Self.Element)));
end Get_Owned_End;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant CMOF_Association_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then
AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class
(Visitor).Leave_Association
(AMF.CMOF.Associations.CMOF_Association_Access (Self),
Control);
end if;
end Leave_Element;
--------------------
-- Set_Is_Derived --
--------------------
overriding procedure Set_Is_Derived
(Self : not null access CMOF_Association_Proxy;
To : Boolean) is
begin
Internal_Set_Is_Derived (Self.Element, To);
end Set_Is_Derived;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant CMOF_Association_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.CMOF_Iterators.CMOF_Iterator'Class then
AMF.Visitors.CMOF_Iterators.CMOF_Iterator'Class
(Iterator).Visit_Association
(Visitor,
AMF.CMOF.Associations.CMOF_Association_Access (Self),
Control);
end if;
end Visit_Element;
------------------------
-- All_Owned_Elements --
------------------------
overriding function All_Owned_Elements
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented");
raise Program_Error;
return All_Owned_Elements (Self);
end All_Owned_Elements;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant CMOF_Association_Proxy)
return Optional_String
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Qualified_Name unimplemented");
raise Program_Error;
return Get_Qualified_Name (Self);
end Get_Qualified_Name;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant CMOF_Association_Proxy;
N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access;
Ns : AMF.CMOF.Namespaces.CMOF_Namespace_Access)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error;
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
-----------------
-- Set_Package --
-----------------
overriding procedure Set_Package
(Self : not null access CMOF_Association_Proxy;
To : AMF.CMOF.Packages.CMOF_Package_Access)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Set_Package unimplemented");
raise Program_Error;
end Set_Package;
---------------------
-- Imported_Member --
---------------------
overriding function Imported_Member
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Imported_Member unimplemented");
raise Program_Error;
return Imported_Member (Self);
end Imported_Member;
-------------------------
-- Get_Names_Of_Member --
-------------------------
overriding function Get_Names_Of_Member
(Self : not null access constant CMOF_Association_Proxy;
Element : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access)
return AMF.String_Collections.Set_Of_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Names_Of_Member unimplemented");
raise Program_Error;
return Get_Names_Of_Member (Self, Element);
end Get_Names_Of_Member;
--------------------
-- Import_Members --
--------------------
overriding function Import_Members
(Self : not null access constant CMOF_Association_Proxy;
Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element)
return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Import_Members unimplemented");
raise Program_Error;
return Import_Members (Self, Imps);
end Import_Members;
------------------------
-- Exclude_Collisions --
------------------------
overriding function Exclude_Collisions
(Self : not null access constant CMOF_Association_Proxy;
Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element)
return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Exclude_Collisions unimplemented");
raise Program_Error;
return Exclude_Collisions (Self, Imps);
end Exclude_Collisions;
---------------------------------
-- Members_Are_Distinguishable --
---------------------------------
overriding function Members_Are_Distinguishable
(Self : not null access constant CMOF_Association_Proxy)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Members_Are_Distinguishable unimplemented");
raise Program_Error;
return Members_Are_Distinguishable (Self);
end Members_Are_Distinguishable;
---------------------------------
-- Set_Is_Final_Specialization --
---------------------------------
overriding procedure Set_Is_Final_Specialization
(Self : not null access CMOF_Association_Proxy;
To : Boolean)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Set_Is_Final_Specialization unimplemented");
raise Program_Error;
end Set_Is_Final_Specialization;
-----------------
-- Conforms_To --
-----------------
overriding function Conforms_To
(Self : not null access constant CMOF_Association_Proxy;
Other : AMF.CMOF.Classifiers.CMOF_Classifier_Access)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Conforms_To unimplemented");
raise Program_Error;
return Conforms_To (Self, Other);
end Conforms_To;
------------------
-- All_Features --
------------------
overriding function All_Features
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Features.Collections.Set_Of_CMOF_Feature
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Features unimplemented");
raise Program_Error;
return All_Features (Self);
end All_Features;
-------------
-- General --
-------------
overriding function General
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "General unimplemented");
raise Program_Error;
return General (Self);
end General;
-------------
-- Parents --
-------------
overriding function Parents
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Parents unimplemented");
raise Program_Error;
return Parents (Self);
end Parents;
----------------------
-- Inherited_Member --
----------------------
overriding function Inherited_Member
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inherited_Member unimplemented");
raise Program_Error;
return Inherited_Member (Self);
end Inherited_Member;
-----------------
-- All_Parents --
-----------------
overriding function All_Parents
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Parents unimplemented");
raise Program_Error;
return All_Parents (Self);
end All_Parents;
-------------------------
-- Inheritable_Members --
-------------------------
overriding function Inheritable_Members
(Self : not null access constant CMOF_Association_Proxy;
C : AMF.CMOF.Classifiers.CMOF_Classifier_Access)
return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inheritable_Members unimplemented");
raise Program_Error;
return Inheritable_Members (Self, C);
end Inheritable_Members;
-----------------------
-- Has_Visibility_Of --
-----------------------
overriding function Has_Visibility_Of
(Self : not null access constant CMOF_Association_Proxy;
N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Has_Visibility_Of unimplemented");
raise Program_Error;
return Has_Visibility_Of (Self, N);
end Has_Visibility_Of;
-------------
-- Inherit --
-------------
overriding function Inherit
(Self : not null access constant CMOF_Association_Proxy;
Inhs : AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element)
return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inherit unimplemented");
raise Program_Error;
return Inherit (Self, Inhs);
end Inherit;
-------------------------
-- May_Specialize_Type --
-------------------------
overriding function May_Specialize_Type
(Self : not null access constant CMOF_Association_Proxy;
C : AMF.CMOF.Classifiers.CMOF_Classifier_Access)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "May_Specialize_Type unimplemented");
raise Program_Error;
return May_Specialize_Type (Self, C);
end May_Specialize_Type;
--------------
-- End_Type --
--------------
overriding function End_Type
(Self : not null access constant CMOF_Association_Proxy)
return AMF.CMOF.Types.Collections.Ordered_Set_Of_CMOF_Type
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "End_Type unimplemented");
raise Program_Error;
return End_Type (Self);
end End_Type;
end AMF.Internals.CMOF_Associations;
|
edin/raytracer | Ada | 719 | ads | with Colors; use Colors;
with Vectors; use Vectors;
-- @summary Lights that shine onto a Scene
package Lights is
type Light_Type is private;
-- Light_Type has a position and a color
type Light_Array is array( Positive range <> ) of Light_Type;
function Create_Light(Position: Vector; Color: Color_Type) return Light_Type;
function Position_Of(Light: Light_Type) return Vector;
-- the position vector of this Light
pragma Inline_Always(Position_Of);
function Color_Of(Light: Light_Type) return Color_Type;
-- the RGB color of this Light
pragma Inline_Always(Color_Of);
private
type Light_Type is record
Position: Vector;
Color: Color_Type;
end record;
end Lights;
|
sungyeon/drake | Ada | 469 | ads | pragma License (Unrestricted);
-- implementation unit specialized for FreeBSD (or Linux)
with Ada.Directories.Volumes;
package System.Native_Directories.File_Names is
function Equal_File_Names (
FS : Ada.Directories.Volumes.File_System;
Left, Right : String)
return Boolean;
function Less_File_Names (
FS : Ada.Directories.Volumes.File_System;
Left, Right : String)
return Boolean;
end System.Native_Directories.File_Names;
|
AdaCore/gpr | Ada | 43 | adb | procedure main is
begin
null;
end main;
|
charlie5/lace | Ada | 327 | adb | with
lace.Event.Logger;
package body lace.Subject
is
the_Logger : Event.Logger.view;
procedure Logger_is (Now : in Event.Logger.view)
is
begin
the_Logger := Now;
end Logger_is;
function Logger return Event.Logger.view
is
begin
return the_Logger;
end Logger;
end lace.Subject;
|
reznikmm/matreshka | Ada | 4,744 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Holders.Reflective_Collections;
with AMF.Internals.Collections.Strings.Proxies;
with AMF.Reflective_Collections.Internals;
package body AMF.String_Collections.Internals is
---------------
-- To_Holder --
---------------
function To_Holder
(Item : Collection_Of_String'Class) return League.Holders.Holder is
begin
return
AMF.Holders.Reflective_Collections.To_Holder
(AMF.Reflective_Collections.Internals.Create
(AMF.Internals.Collections.Shared_Collection_Access
(Item.Collection)));
end To_Holder;
----------
-- Wrap --
----------
function Wrap
(Collection : AMF.Internals.AMF_Collection_Of_String)
return Sequence_Of_String is
begin
return
(Ada.Finalization.Controlled with
Collection =>
new AMF.Internals.Collections.Strings.Proxies.Shared_String_Collection_Proxy'
(Collection => Collection));
end Wrap;
----------
-- Wrap --
----------
function Wrap
(Collection : AMF.Internals.AMF_Collection_Of_String)
return Ordered_Set_Of_String is
begin
return
(Ada.Finalization.Controlled with
Collection =>
new AMF.Internals.Collections.Strings.Proxies.Shared_String_Collection_Proxy'
(Collection => Collection));
end Wrap;
end AMF.String_Collections.Internals;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 49,853 | ads | -- This spec has been automatically generated from STM32F103.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.ETHERNET is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype DMABMR_SR_Field is STM32_SVD.Bit;
subtype DMABMR_DA_Field is STM32_SVD.Bit;
subtype DMABMR_DSL_Field is STM32_SVD.UInt5;
subtype DMABMR_PBL_Field is STM32_SVD.UInt6;
subtype DMABMR_RTPR_Field is STM32_SVD.UInt2;
subtype DMABMR_FB_Field is STM32_SVD.Bit;
subtype DMABMR_RDP_Field is STM32_SVD.UInt6;
subtype DMABMR_USP_Field is STM32_SVD.Bit;
subtype DMABMR_FPM_Field is STM32_SVD.Bit;
subtype DMABMR_AAB_Field is STM32_SVD.Bit;
-- Ethernet DMA bus mode register
type DMABMR_Register is record
-- Software reset
SR : DMABMR_SR_Field := 16#1#;
-- DMA Arbitration
DA : DMABMR_DA_Field := 16#0#;
-- Descriptor skip length
DSL : DMABMR_DSL_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- Programmable burst length
PBL : DMABMR_PBL_Field := 16#1#;
-- Rx Tx priority ratio
RTPR : DMABMR_RTPR_Field := 16#0#;
-- Fixed burst
FB : DMABMR_FB_Field := 16#0#;
-- Rx DMA PBL
RDP : DMABMR_RDP_Field := 16#1#;
-- Use separate PBL
USP : DMABMR_USP_Field := 16#0#;
-- 4xPBL mode
FPM : DMABMR_FPM_Field := 16#0#;
-- Address-aligned beats
AAB : DMABMR_AAB_Field := 16#0#;
-- unspecified
Reserved_26_31 : STM32_SVD.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMABMR_Register use record
SR at 0 range 0 .. 0;
DA at 0 range 1 .. 1;
DSL at 0 range 2 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
PBL at 0 range 8 .. 13;
RTPR at 0 range 14 .. 15;
FB at 0 range 16 .. 16;
RDP at 0 range 17 .. 22;
USP at 0 range 23 .. 23;
FPM at 0 range 24 .. 24;
AAB at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
subtype DMASR_TS_Field is STM32_SVD.Bit;
subtype DMASR_TPSS_Field is STM32_SVD.Bit;
subtype DMASR_TBUS_Field is STM32_SVD.Bit;
subtype DMASR_TJTS_Field is STM32_SVD.Bit;
subtype DMASR_ROS_Field is STM32_SVD.Bit;
subtype DMASR_TUS_Field is STM32_SVD.Bit;
subtype DMASR_RS_Field is STM32_SVD.Bit;
subtype DMASR_RBUS_Field is STM32_SVD.Bit;
subtype DMASR_RPSS_Field is STM32_SVD.Bit;
subtype DMASR_PWTS_Field is STM32_SVD.Bit;
subtype DMASR_ETS_Field is STM32_SVD.Bit;
subtype DMASR_FBES_Field is STM32_SVD.Bit;
subtype DMASR_ERS_Field is STM32_SVD.Bit;
subtype DMASR_AIS_Field is STM32_SVD.Bit;
subtype DMASR_NIS_Field is STM32_SVD.Bit;
subtype DMASR_RPS_Field is STM32_SVD.UInt3;
subtype DMASR_TPS_Field is STM32_SVD.UInt3;
subtype DMASR_EBS_Field is STM32_SVD.UInt3;
subtype DMASR_MMCS_Field is STM32_SVD.Bit;
subtype DMASR_PMTS_Field is STM32_SVD.Bit;
subtype DMASR_TSTS_Field is STM32_SVD.Bit;
-- Ethernet DMA status register
type DMASR_Register is record
-- Transmit status
TS : DMASR_TS_Field := 16#0#;
-- Transmit process stopped status
TPSS : DMASR_TPSS_Field := 16#0#;
-- Transmit buffer unavailable status
TBUS : DMASR_TBUS_Field := 16#0#;
-- Transmit jabber timeout status
TJTS : DMASR_TJTS_Field := 16#0#;
-- Receive overflow status
ROS : DMASR_ROS_Field := 16#0#;
-- Transmit underflow status
TUS : DMASR_TUS_Field := 16#0#;
-- Receive status
RS : DMASR_RS_Field := 16#0#;
-- Receive buffer unavailable status
RBUS : DMASR_RBUS_Field := 16#0#;
-- Receive process stopped status
RPSS : DMASR_RPSS_Field := 16#0#;
-- Receive watchdog timeout status
PWTS : DMASR_PWTS_Field := 16#0#;
-- Early transmit status
ETS : DMASR_ETS_Field := 16#0#;
-- unspecified
Reserved_11_12 : STM32_SVD.UInt2 := 16#0#;
-- Fatal bus error status
FBES : DMASR_FBES_Field := 16#0#;
-- Early receive status
ERS : DMASR_ERS_Field := 16#0#;
-- Abnormal interrupt summary
AIS : DMASR_AIS_Field := 16#0#;
-- Normal interrupt summary
NIS : DMASR_NIS_Field := 16#0#;
-- Read-only. Receive process state
RPS : DMASR_RPS_Field := 16#0#;
-- Read-only. Transmit process state
TPS : DMASR_TPS_Field := 16#0#;
-- Read-only. Error bits status
EBS : DMASR_EBS_Field := 16#0#;
-- unspecified
Reserved_26_26 : STM32_SVD.Bit := 16#0#;
-- Read-only. MMC status
MMCS : DMASR_MMCS_Field := 16#0#;
-- Read-only. PMT status
PMTS : DMASR_PMTS_Field := 16#0#;
-- Read-only. Time stamp trigger status
TSTS : DMASR_TSTS_Field := 16#0#;
-- unspecified
Reserved_30_31 : STM32_SVD.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMASR_Register use record
TS at 0 range 0 .. 0;
TPSS at 0 range 1 .. 1;
TBUS at 0 range 2 .. 2;
TJTS at 0 range 3 .. 3;
ROS at 0 range 4 .. 4;
TUS at 0 range 5 .. 5;
RS at 0 range 6 .. 6;
RBUS at 0 range 7 .. 7;
RPSS at 0 range 8 .. 8;
PWTS at 0 range 9 .. 9;
ETS at 0 range 10 .. 10;
Reserved_11_12 at 0 range 11 .. 12;
FBES at 0 range 13 .. 13;
ERS at 0 range 14 .. 14;
AIS at 0 range 15 .. 15;
NIS at 0 range 16 .. 16;
RPS at 0 range 17 .. 19;
TPS at 0 range 20 .. 22;
EBS at 0 range 23 .. 25;
Reserved_26_26 at 0 range 26 .. 26;
MMCS at 0 range 27 .. 27;
PMTS at 0 range 28 .. 28;
TSTS at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype DMAOMR_SR_Field is STM32_SVD.Bit;
subtype DMAOMR_OSF_Field is STM32_SVD.Bit;
subtype DMAOMR_RTC_Field is STM32_SVD.UInt2;
subtype DMAOMR_FUGF_Field is STM32_SVD.Bit;
subtype DMAOMR_FEF_Field is STM32_SVD.Bit;
subtype DMAOMR_ST_Field is STM32_SVD.Bit;
subtype DMAOMR_TTC_Field is STM32_SVD.UInt3;
subtype DMAOMR_FTF_Field is STM32_SVD.Bit;
subtype DMAOMR_TSF_Field is STM32_SVD.Bit;
subtype DMAOMR_DFRF_Field is STM32_SVD.Bit;
subtype DMAOMR_RSF_Field is STM32_SVD.Bit;
subtype DMAOMR_DTCEFD_Field is STM32_SVD.Bit;
-- Ethernet DMA operation mode register
type DMAOMR_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit := 16#0#;
-- SR
SR : DMAOMR_SR_Field := 16#0#;
-- OSF
OSF : DMAOMR_OSF_Field := 16#0#;
-- RTC
RTC : DMAOMR_RTC_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- FUGF
FUGF : DMAOMR_FUGF_Field := 16#0#;
-- FEF
FEF : DMAOMR_FEF_Field := 16#0#;
-- unspecified
Reserved_8_12 : STM32_SVD.UInt5 := 16#0#;
-- ST
ST : DMAOMR_ST_Field := 16#0#;
-- TTC
TTC : DMAOMR_TTC_Field := 16#0#;
-- unspecified
Reserved_17_19 : STM32_SVD.UInt3 := 16#0#;
-- FTF
FTF : DMAOMR_FTF_Field := 16#0#;
-- TSF
TSF : DMAOMR_TSF_Field := 16#0#;
-- unspecified
Reserved_22_23 : STM32_SVD.UInt2 := 16#0#;
-- DFRF
DFRF : DMAOMR_DFRF_Field := 16#0#;
-- RSF
RSF : DMAOMR_RSF_Field := 16#0#;
-- DTCEFD
DTCEFD : DMAOMR_DTCEFD_Field := 16#0#;
-- unspecified
Reserved_27_31 : STM32_SVD.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAOMR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
SR at 0 range 1 .. 1;
OSF at 0 range 2 .. 2;
RTC at 0 range 3 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
FUGF at 0 range 6 .. 6;
FEF at 0 range 7 .. 7;
Reserved_8_12 at 0 range 8 .. 12;
ST at 0 range 13 .. 13;
TTC at 0 range 14 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
FTF at 0 range 20 .. 20;
TSF at 0 range 21 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
DFRF at 0 range 24 .. 24;
RSF at 0 range 25 .. 25;
DTCEFD at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype DMAIER_TIE_Field is STM32_SVD.Bit;
subtype DMAIER_TPSIE_Field is STM32_SVD.Bit;
subtype DMAIER_TBUIE_Field is STM32_SVD.Bit;
subtype DMAIER_TJTIE_Field is STM32_SVD.Bit;
subtype DMAIER_ROIE_Field is STM32_SVD.Bit;
subtype DMAIER_TUIE_Field is STM32_SVD.Bit;
subtype DMAIER_RIE_Field is STM32_SVD.Bit;
subtype DMAIER_RBUIE_Field is STM32_SVD.Bit;
subtype DMAIER_RPSIE_Field is STM32_SVD.Bit;
subtype DMAIER_RWTIE_Field is STM32_SVD.Bit;
subtype DMAIER_ETIE_Field is STM32_SVD.Bit;
subtype DMAIER_FBEIE_Field is STM32_SVD.Bit;
subtype DMAIER_ERIE_Field is STM32_SVD.Bit;
subtype DMAIER_AISE_Field is STM32_SVD.Bit;
subtype DMAIER_NISE_Field is STM32_SVD.Bit;
-- Ethernet DMA interrupt enable register
type DMAIER_Register is record
-- Transmit interrupt enable
TIE : DMAIER_TIE_Field := 16#0#;
-- Transmit process stopped interrupt enable
TPSIE : DMAIER_TPSIE_Field := 16#0#;
-- Transmit buffer unavailable interrupt enable
TBUIE : DMAIER_TBUIE_Field := 16#0#;
-- Transmit jabber timeout interrupt enable
TJTIE : DMAIER_TJTIE_Field := 16#0#;
-- Overflow interrupt enable
ROIE : DMAIER_ROIE_Field := 16#0#;
-- Underflow interrupt enable
TUIE : DMAIER_TUIE_Field := 16#0#;
-- Receive interrupt enable
RIE : DMAIER_RIE_Field := 16#0#;
-- Receive buffer unavailable interrupt enable
RBUIE : DMAIER_RBUIE_Field := 16#0#;
-- Receive process stopped interrupt enable
RPSIE : DMAIER_RPSIE_Field := 16#0#;
-- receive watchdog timeout interrupt enable
RWTIE : DMAIER_RWTIE_Field := 16#0#;
-- Early transmit interrupt enable
ETIE : DMAIER_ETIE_Field := 16#0#;
-- unspecified
Reserved_11_12 : STM32_SVD.UInt2 := 16#0#;
-- Fatal bus error interrupt enable
FBEIE : DMAIER_FBEIE_Field := 16#0#;
-- Early receive interrupt enable
ERIE : DMAIER_ERIE_Field := 16#0#;
-- Abnormal interrupt summary enable
AISE : DMAIER_AISE_Field := 16#0#;
-- Normal interrupt summary enable
NISE : DMAIER_NISE_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAIER_Register use record
TIE at 0 range 0 .. 0;
TPSIE at 0 range 1 .. 1;
TBUIE at 0 range 2 .. 2;
TJTIE at 0 range 3 .. 3;
ROIE at 0 range 4 .. 4;
TUIE at 0 range 5 .. 5;
RIE at 0 range 6 .. 6;
RBUIE at 0 range 7 .. 7;
RPSIE at 0 range 8 .. 8;
RWTIE at 0 range 9 .. 9;
ETIE at 0 range 10 .. 10;
Reserved_11_12 at 0 range 11 .. 12;
FBEIE at 0 range 13 .. 13;
ERIE at 0 range 14 .. 14;
AISE at 0 range 15 .. 15;
NISE at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype DMAMFBOCR_MFC_Field is STM32_SVD.UInt16;
subtype DMAMFBOCR_OMFC_Field is STM32_SVD.Bit;
subtype DMAMFBOCR_MFA_Field is STM32_SVD.UInt11;
subtype DMAMFBOCR_OFOC_Field is STM32_SVD.Bit;
-- Ethernet DMA missed frame and buffer overflow counter register
type DMAMFBOCR_Register is record
-- Read-only. Missed frames by the controller
MFC : DMAMFBOCR_MFC_Field;
-- Read-only. Overflow bit for missed frame counter
OMFC : DMAMFBOCR_OMFC_Field;
-- Read-only. Missed frames by the application
MFA : DMAMFBOCR_MFA_Field;
-- Read-only. Overflow bit for FIFO overflow counter
OFOC : DMAMFBOCR_OFOC_Field;
-- unspecified
Reserved_29_31 : STM32_SVD.UInt3;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAMFBOCR_Register use record
MFC at 0 range 0 .. 15;
OMFC at 0 range 16 .. 16;
MFA at 0 range 17 .. 27;
OFOC at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype MACCR_RE_Field is STM32_SVD.Bit;
subtype MACCR_TE_Field is STM32_SVD.Bit;
subtype MACCR_DC_Field is STM32_SVD.Bit;
subtype MACCR_BL_Field is STM32_SVD.UInt2;
subtype MACCR_APCS_Field is STM32_SVD.Bit;
subtype MACCR_RD_Field is STM32_SVD.Bit;
subtype MACCR_IPCO_Field is STM32_SVD.Bit;
subtype MACCR_DM_Field is STM32_SVD.Bit;
subtype MACCR_LM_Field is STM32_SVD.Bit;
subtype MACCR_ROD_Field is STM32_SVD.Bit;
subtype MACCR_FES_Field is STM32_SVD.Bit;
subtype MACCR_CSD_Field is STM32_SVD.Bit;
subtype MACCR_IFG_Field is STM32_SVD.UInt3;
subtype MACCR_JD_Field is STM32_SVD.Bit;
subtype MACCR_WD_Field is STM32_SVD.Bit;
-- Ethernet MAC configuration register (ETH_MACCR)
type MACCR_Register is record
-- unspecified
Reserved_0_1 : STM32_SVD.UInt2 := 16#0#;
-- Receiver enable
RE : MACCR_RE_Field := 16#0#;
-- Transmitter enable
TE : MACCR_TE_Field := 16#0#;
-- Deferral check
DC : MACCR_DC_Field := 16#0#;
-- Back-off limit
BL : MACCR_BL_Field := 16#0#;
-- Automatic pad/CRC stripping
APCS : MACCR_APCS_Field := 16#0#;
-- unspecified
Reserved_8_8 : STM32_SVD.Bit := 16#0#;
-- Retry disable
RD : MACCR_RD_Field := 16#0#;
-- IPv4 checksum offload
IPCO : MACCR_IPCO_Field := 16#0#;
-- Duplex mode
DM : MACCR_DM_Field := 16#0#;
-- Loopback mode
LM : MACCR_LM_Field := 16#0#;
-- Receive own disable
ROD : MACCR_ROD_Field := 16#0#;
-- Fast Ethernet speed
FES : MACCR_FES_Field := 16#0#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#1#;
-- Carrier sense disable
CSD : MACCR_CSD_Field := 16#0#;
-- Interframe gap
IFG : MACCR_IFG_Field := 16#0#;
-- unspecified
Reserved_20_21 : STM32_SVD.UInt2 := 16#0#;
-- Jabber disable
JD : MACCR_JD_Field := 16#0#;
-- Watchdog disable
WD : MACCR_WD_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACCR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
RE at 0 range 2 .. 2;
TE at 0 range 3 .. 3;
DC at 0 range 4 .. 4;
BL at 0 range 5 .. 6;
APCS at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
RD at 0 range 9 .. 9;
IPCO at 0 range 10 .. 10;
DM at 0 range 11 .. 11;
LM at 0 range 12 .. 12;
ROD at 0 range 13 .. 13;
FES at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
CSD at 0 range 16 .. 16;
IFG at 0 range 17 .. 19;
Reserved_20_21 at 0 range 20 .. 21;
JD at 0 range 22 .. 22;
WD at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype MACFFR_PM_Field is STM32_SVD.Bit;
subtype MACFFR_HU_Field is STM32_SVD.Bit;
subtype MACFFR_HM_Field is STM32_SVD.Bit;
subtype MACFFR_DAIF_Field is STM32_SVD.Bit;
subtype MACFFR_PAM_Field is STM32_SVD.Bit;
subtype MACFFR_BFD_Field is STM32_SVD.Bit;
subtype MACFFR_PCF_Field is STM32_SVD.UInt2;
subtype MACFFR_SAIF_Field is STM32_SVD.Bit;
subtype MACFFR_SAF_Field is STM32_SVD.Bit;
subtype MACFFR_HPF_Field is STM32_SVD.Bit;
subtype MACFFR_RA_Field is STM32_SVD.Bit;
-- Ethernet MAC frame filter register (ETH_MACCFFR)
type MACFFR_Register is record
-- Promiscuous mode
PM : MACFFR_PM_Field := 16#0#;
-- Hash unicast
HU : MACFFR_HU_Field := 16#0#;
-- Hash multicast
HM : MACFFR_HM_Field := 16#0#;
-- Destination address inverse filtering
DAIF : MACFFR_DAIF_Field := 16#0#;
-- Pass all multicast
PAM : MACFFR_PAM_Field := 16#0#;
-- Broadcast frames disable
BFD : MACFFR_BFD_Field := 16#0#;
-- Pass control frames
PCF : MACFFR_PCF_Field := 16#0#;
-- Source address inverse filtering
SAIF : MACFFR_SAIF_Field := 16#0#;
-- Source address filter
SAF : MACFFR_SAF_Field := 16#0#;
-- Hash or perfect filter
HPF : MACFFR_HPF_Field := 16#0#;
-- unspecified
Reserved_11_30 : STM32_SVD.UInt20 := 16#0#;
-- Receive all
RA : MACFFR_RA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACFFR_Register use record
PM at 0 range 0 .. 0;
HU at 0 range 1 .. 1;
HM at 0 range 2 .. 2;
DAIF at 0 range 3 .. 3;
PAM at 0 range 4 .. 4;
BFD at 0 range 5 .. 5;
PCF at 0 range 6 .. 7;
SAIF at 0 range 8 .. 8;
SAF at 0 range 9 .. 9;
HPF at 0 range 10 .. 10;
Reserved_11_30 at 0 range 11 .. 30;
RA at 0 range 31 .. 31;
end record;
subtype MACMIIAR_MB_Field is STM32_SVD.Bit;
subtype MACMIIAR_MW_Field is STM32_SVD.Bit;
subtype MACMIIAR_CR_Field is STM32_SVD.UInt3;
subtype MACMIIAR_MR_Field is STM32_SVD.UInt5;
subtype MACMIIAR_PA_Field is STM32_SVD.UInt5;
-- Ethernet MAC MII address register (ETH_MACMIIAR)
type MACMIIAR_Register is record
-- MII busy
MB : MACMIIAR_MB_Field := 16#0#;
-- MII write
MW : MACMIIAR_MW_Field := 16#0#;
-- Clock range
CR : MACMIIAR_CR_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- MII register
MR : MACMIIAR_MR_Field := 16#0#;
-- PHY address
PA : MACMIIAR_PA_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACMIIAR_Register use record
MB at 0 range 0 .. 0;
MW at 0 range 1 .. 1;
CR at 0 range 2 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
MR at 0 range 6 .. 10;
PA at 0 range 11 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype MACMIIDR_MD_Field is STM32_SVD.UInt16;
-- Ethernet MAC MII data register (ETH_MACMIIDR)
type MACMIIDR_Register is record
-- MII data
MD : MACMIIDR_MD_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACMIIDR_Register use record
MD at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype MACFCR_FCB_BPA_Field is STM32_SVD.Bit;
subtype MACFCR_TFCE_Field is STM32_SVD.Bit;
subtype MACFCR_RFCE_Field is STM32_SVD.Bit;
subtype MACFCR_UPFD_Field is STM32_SVD.Bit;
subtype MACFCR_PLT_Field is STM32_SVD.UInt2;
subtype MACFCR_ZQPD_Field is STM32_SVD.Bit;
subtype MACFCR_PT_Field is STM32_SVD.UInt16;
-- Ethernet MAC flow control register (ETH_MACFCR)
type MACFCR_Register is record
-- Flow control busy/back pressure activate
FCB_BPA : MACFCR_FCB_BPA_Field := 16#0#;
-- Transmit flow control enable
TFCE : MACFCR_TFCE_Field := 16#0#;
-- Receive flow control enable
RFCE : MACFCR_RFCE_Field := 16#0#;
-- Unicast pause frame detect
UPFD : MACFCR_UPFD_Field := 16#0#;
-- Pause low threshold
PLT : MACFCR_PLT_Field := 16#0#;
-- unspecified
Reserved_6_6 : STM32_SVD.Bit := 16#0#;
-- Zero-quanta pause disable
ZQPD : MACFCR_ZQPD_Field := 16#0#;
-- unspecified
Reserved_8_15 : STM32_SVD.Byte := 16#0#;
-- Pass control frames
PT : MACFCR_PT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACFCR_Register use record
FCB_BPA at 0 range 0 .. 0;
TFCE at 0 range 1 .. 1;
RFCE at 0 range 2 .. 2;
UPFD at 0 range 3 .. 3;
PLT at 0 range 4 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
ZQPD at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
PT at 0 range 16 .. 31;
end record;
subtype MACVLANTR_VLANTI_Field is STM32_SVD.UInt16;
subtype MACVLANTR_VLANTC_Field is STM32_SVD.Bit;
-- Ethernet MAC VLAN tag register (ETH_MACVLANTR)
type MACVLANTR_Register is record
-- VLAN tag identifier (for receive frames)
VLANTI : MACVLANTR_VLANTI_Field := 16#0#;
-- 12-bit VLAN tag comparison
VLANTC : MACVLANTR_VLANTC_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACVLANTR_Register use record
VLANTI at 0 range 0 .. 15;
VLANTC at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype MACPMTCSR_PD_Field is STM32_SVD.Bit;
subtype MACPMTCSR_MPE_Field is STM32_SVD.Bit;
subtype MACPMTCSR_WFE_Field is STM32_SVD.Bit;
subtype MACPMTCSR_MPR_Field is STM32_SVD.Bit;
subtype MACPMTCSR_WFR_Field is STM32_SVD.Bit;
subtype MACPMTCSR_GU_Field is STM32_SVD.Bit;
subtype MACPMTCSR_WFFRPR_Field is STM32_SVD.Bit;
-- Ethernet MAC PMT control and status register (ETH_MACPMTCSR)
type MACPMTCSR_Register is record
-- Power down
PD : MACPMTCSR_PD_Field := 16#0#;
-- Magic Packet enable
MPE : MACPMTCSR_MPE_Field := 16#0#;
-- Wakeup frame enable
WFE : MACPMTCSR_WFE_Field := 16#0#;
-- unspecified
Reserved_3_4 : STM32_SVD.UInt2 := 16#0#;
-- Magic packet received
MPR : MACPMTCSR_MPR_Field := 16#0#;
-- Wakeup frame received
WFR : MACPMTCSR_WFR_Field := 16#0#;
-- unspecified
Reserved_7_8 : STM32_SVD.UInt2 := 16#0#;
-- Global unicast
GU : MACPMTCSR_GU_Field := 16#0#;
-- unspecified
Reserved_10_30 : STM32_SVD.UInt21 := 16#0#;
-- Wakeup frame filter register pointer reset
WFFRPR : MACPMTCSR_WFFRPR_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACPMTCSR_Register use record
PD at 0 range 0 .. 0;
MPE at 0 range 1 .. 1;
WFE at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
MPR at 0 range 5 .. 5;
WFR at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
GU at 0 range 9 .. 9;
Reserved_10_30 at 0 range 10 .. 30;
WFFRPR at 0 range 31 .. 31;
end record;
subtype MACSR_PMTS_Field is STM32_SVD.Bit;
subtype MACSR_MMCS_Field is STM32_SVD.Bit;
subtype MACSR_MMCRS_Field is STM32_SVD.Bit;
subtype MACSR_MMCTS_Field is STM32_SVD.Bit;
subtype MACSR_TSTS_Field is STM32_SVD.Bit;
-- Ethernet MAC interrupt status register (ETH_MACSR)
type MACSR_Register is record
-- unspecified
Reserved_0_2 : STM32_SVD.UInt3 := 16#0#;
-- PMT status
PMTS : MACSR_PMTS_Field := 16#0#;
-- MMC status
MMCS : MACSR_MMCS_Field := 16#0#;
-- MMC receive status
MMCRS : MACSR_MMCRS_Field := 16#0#;
-- MMC transmit status
MMCTS : MACSR_MMCTS_Field := 16#0#;
-- unspecified
Reserved_7_8 : STM32_SVD.UInt2 := 16#0#;
-- Time stamp trigger status
TSTS : MACSR_TSTS_Field := 16#0#;
-- unspecified
Reserved_10_31 : STM32_SVD.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACSR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
PMTS at 0 range 3 .. 3;
MMCS at 0 range 4 .. 4;
MMCRS at 0 range 5 .. 5;
MMCTS at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
TSTS at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
subtype MACIMR_PMTIM_Field is STM32_SVD.Bit;
subtype MACIMR_TSTIM_Field is STM32_SVD.Bit;
-- Ethernet MAC interrupt mask register (ETH_MACIMR)
type MACIMR_Register is record
-- unspecified
Reserved_0_2 : STM32_SVD.UInt3 := 16#0#;
-- PMT interrupt mask
PMTIM : MACIMR_PMTIM_Field := 16#0#;
-- unspecified
Reserved_4_8 : STM32_SVD.UInt5 := 16#0#;
-- Time stamp trigger interrupt mask
TSTIM : MACIMR_TSTIM_Field := 16#0#;
-- unspecified
Reserved_10_31 : STM32_SVD.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACIMR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
PMTIM at 0 range 3 .. 3;
Reserved_4_8 at 0 range 4 .. 8;
TSTIM at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
subtype MACA0HR_MACA0H_Field is STM32_SVD.UInt16;
subtype MACA0HR_MO_Field is STM32_SVD.Bit;
-- Ethernet MAC address 0 high register (ETH_MACA0HR)
type MACA0HR_Register is record
-- MAC address0 high
MACA0H : MACA0HR_MACA0H_Field := 16#FFFF#;
-- unspecified
Reserved_16_30 : STM32_SVD.UInt15 := 16#10#;
-- Read-only. Always 1
MO : MACA0HR_MO_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA0HR_Register use record
MACA0H at 0 range 0 .. 15;
Reserved_16_30 at 0 range 16 .. 30;
MO at 0 range 31 .. 31;
end record;
subtype MACA1HR_MACA1H_Field is STM32_SVD.UInt16;
subtype MACA1HR_MBC_Field is STM32_SVD.UInt6;
subtype MACA1HR_SA_Field is STM32_SVD.Bit;
subtype MACA1HR_AE_Field is STM32_SVD.Bit;
-- Ethernet MAC address 1 high register (ETH_MACA1HR)
type MACA1HR_Register is record
-- MAC address1 high
MACA1H : MACA1HR_MACA1H_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : STM32_SVD.Byte := 16#0#;
-- Mask byte control
MBC : MACA1HR_MBC_Field := 16#0#;
-- Source address
SA : MACA1HR_SA_Field := 16#0#;
-- Address enable
AE : MACA1HR_AE_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA1HR_Register use record
MACA1H at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
subtype MACA2HR_ETH_MACA2HR_Field is STM32_SVD.UInt16;
subtype MACA2HR_MBC_Field is STM32_SVD.UInt6;
subtype MACA2HR_SA_Field is STM32_SVD.Bit;
subtype MACA2HR_AE_Field is STM32_SVD.Bit;
-- Ethernet MAC address 2 high register (ETH_MACA2HR)
type MACA2HR_Register is record
-- Ethernet MAC address 2 high register
ETH_MACA2HR : MACA2HR_ETH_MACA2HR_Field := 16#50#;
-- unspecified
Reserved_16_23 : STM32_SVD.Byte := 16#0#;
-- Mask byte control
MBC : MACA2HR_MBC_Field := 16#0#;
-- Source address
SA : MACA2HR_SA_Field := 16#0#;
-- Address enable
AE : MACA2HR_AE_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA2HR_Register use record
ETH_MACA2HR at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
subtype MACA2LR_MACA2L_Field is STM32_SVD.UInt31;
-- Ethernet MAC address 2 low register
type MACA2LR_Register is record
-- MAC address2 low
MACA2L : MACA2LR_MACA2L_Field := 16#7FFFFFFF#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#1#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA2LR_Register use record
MACA2L at 0 range 0 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype MACA3HR_MACA3H_Field is STM32_SVD.UInt16;
subtype MACA3HR_MBC_Field is STM32_SVD.UInt6;
subtype MACA3HR_SA_Field is STM32_SVD.Bit;
subtype MACA3HR_AE_Field is STM32_SVD.Bit;
-- Ethernet MAC address 3 high register (ETH_MACA3HR)
type MACA3HR_Register is record
-- MAC address3 high
MACA3H : MACA3HR_MACA3H_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : STM32_SVD.Byte := 16#0#;
-- Mask byte control
MBC : MACA3HR_MBC_Field := 16#0#;
-- Source address
SA : MACA3HR_SA_Field := 16#0#;
-- Address enable
AE : MACA3HR_AE_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA3HR_Register use record
MACA3H at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
subtype MMCCR_CR_Field is STM32_SVD.Bit;
subtype MMCCR_CSR_Field is STM32_SVD.Bit;
subtype MMCCR_ROR_Field is STM32_SVD.Bit;
subtype MMCCR_MCF_Field is STM32_SVD.Bit;
-- Ethernet MMC control register (ETH_MMCCR)
type MMCCR_Register is record
-- Counter reset
CR : MMCCR_CR_Field := 16#0#;
-- Counter stop rollover
CSR : MMCCR_CSR_Field := 16#0#;
-- Reset on read
ROR : MMCCR_ROR_Field := 16#0#;
-- unspecified
Reserved_3_30 : STM32_SVD.UInt28 := 16#0#;
-- MMC counter freeze
MCF : MMCCR_MCF_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCCR_Register use record
CR at 0 range 0 .. 0;
CSR at 0 range 1 .. 1;
ROR at 0 range 2 .. 2;
Reserved_3_30 at 0 range 3 .. 30;
MCF at 0 range 31 .. 31;
end record;
subtype MMCRIR_RFCES_Field is STM32_SVD.Bit;
subtype MMCRIR_RFAES_Field is STM32_SVD.Bit;
subtype MMCRIR_RGUFS_Field is STM32_SVD.Bit;
-- Ethernet MMC receive interrupt register (ETH_MMCRIR)
type MMCRIR_Register is record
-- unspecified
Reserved_0_4 : STM32_SVD.UInt5 := 16#0#;
-- Received frames CRC error status
RFCES : MMCRIR_RFCES_Field := 16#0#;
-- Received frames alignment error status
RFAES : MMCRIR_RFAES_Field := 16#0#;
-- unspecified
Reserved_7_16 : STM32_SVD.UInt10 := 16#0#;
-- Received Good Unicast Frames Status
RGUFS : MMCRIR_RGUFS_Field := 16#0#;
-- unspecified
Reserved_18_31 : STM32_SVD.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCRIR_Register use record
Reserved_0_4 at 0 range 0 .. 4;
RFCES at 0 range 5 .. 5;
RFAES at 0 range 6 .. 6;
Reserved_7_16 at 0 range 7 .. 16;
RGUFS at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype MMCTIR_TGFSCS_Field is STM32_SVD.Bit;
subtype MMCTIR_TGFMSCS_Field is STM32_SVD.Bit;
subtype MMCTIR_TGFS_Field is STM32_SVD.Bit;
-- Ethernet MMC transmit interrupt register (ETH_MMCTIR)
type MMCTIR_Register is record
-- unspecified
Reserved_0_13 : STM32_SVD.UInt14 := 16#0#;
-- Transmitted good frames single collision status
TGFSCS : MMCTIR_TGFSCS_Field := 16#0#;
-- Transmitted good frames more single collision status
TGFMSCS : MMCTIR_TGFMSCS_Field := 16#0#;
-- unspecified
Reserved_16_20 : STM32_SVD.UInt5 := 16#0#;
-- Transmitted good frames status
TGFS : MMCTIR_TGFS_Field := 16#0#;
-- unspecified
Reserved_22_31 : STM32_SVD.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCTIR_Register use record
Reserved_0_13 at 0 range 0 .. 13;
TGFSCS at 0 range 14 .. 14;
TGFMSCS at 0 range 15 .. 15;
Reserved_16_20 at 0 range 16 .. 20;
TGFS at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype MMCRIMR_RFCEM_Field is STM32_SVD.Bit;
subtype MMCRIMR_RFAEM_Field is STM32_SVD.Bit;
subtype MMCRIMR_RGUFM_Field is STM32_SVD.Bit;
-- Ethernet MMC receive interrupt mask register (ETH_MMCRIMR)
type MMCRIMR_Register is record
-- unspecified
Reserved_0_4 : STM32_SVD.UInt5 := 16#0#;
-- Received frame CRC error mask
RFCEM : MMCRIMR_RFCEM_Field := 16#0#;
-- Received frames alignment error mask
RFAEM : MMCRIMR_RFAEM_Field := 16#0#;
-- unspecified
Reserved_7_16 : STM32_SVD.UInt10 := 16#0#;
-- Received good unicast frames mask
RGUFM : MMCRIMR_RGUFM_Field := 16#0#;
-- unspecified
Reserved_18_31 : STM32_SVD.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCRIMR_Register use record
Reserved_0_4 at 0 range 0 .. 4;
RFCEM at 0 range 5 .. 5;
RFAEM at 0 range 6 .. 6;
Reserved_7_16 at 0 range 7 .. 16;
RGUFM at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype MMCTIMR_TGFSCM_Field is STM32_SVD.Bit;
subtype MMCTIMR_TGFMSCM_Field is STM32_SVD.Bit;
subtype MMCTIMR_TGFM_Field is STM32_SVD.Bit;
-- Ethernet MMC transmit interrupt mask register (ETH_MMCTIMR)
type MMCTIMR_Register is record
-- unspecified
Reserved_0_13 : STM32_SVD.UInt14 := 16#0#;
-- Transmitted good frames single collision mask
TGFSCM : MMCTIMR_TGFSCM_Field := 16#0#;
-- Transmitted good frames more single collision mask
TGFMSCM : MMCTIMR_TGFMSCM_Field := 16#0#;
-- unspecified
Reserved_16_20 : STM32_SVD.UInt5 := 16#0#;
-- Transmitted good frames mask
TGFM : MMCTIMR_TGFM_Field := 16#0#;
-- unspecified
Reserved_22_31 : STM32_SVD.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCTIMR_Register use record
Reserved_0_13 at 0 range 0 .. 13;
TGFSCM at 0 range 14 .. 14;
TGFMSCM at 0 range 15 .. 15;
Reserved_16_20 at 0 range 16 .. 20;
TGFM at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype PTPTSCR_TSE_Field is STM32_SVD.Bit;
subtype PTPTSCR_TSFCU_Field is STM32_SVD.Bit;
subtype PTPTSCR_TSSTI_Field is STM32_SVD.Bit;
subtype PTPTSCR_TSSTU_Field is STM32_SVD.Bit;
subtype PTPTSCR_TSITE_Field is STM32_SVD.Bit;
subtype PTPTSCR_TSARU_Field is STM32_SVD.Bit;
-- Ethernet PTP time stamp control register (ETH_PTPTSCR)
type PTPTSCR_Register is record
-- Time stamp enable
TSE : PTPTSCR_TSE_Field := 16#0#;
-- Time stamp fine or coarse update
TSFCU : PTPTSCR_TSFCU_Field := 16#0#;
-- Time stamp system time initialize
TSSTI : PTPTSCR_TSSTI_Field := 16#0#;
-- Time stamp system time update
TSSTU : PTPTSCR_TSSTU_Field := 16#0#;
-- Time stamp interrupt trigger enable
TSITE : PTPTSCR_TSITE_Field := 16#0#;
-- Time stamp addend register update
TSARU : PTPTSCR_TSARU_Field := 16#0#;
-- unspecified
Reserved_6_31 : STM32_SVD.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSCR_Register use record
TSE at 0 range 0 .. 0;
TSFCU at 0 range 1 .. 1;
TSSTI at 0 range 2 .. 2;
TSSTU at 0 range 3 .. 3;
TSITE at 0 range 4 .. 4;
TSARU at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype PTPSSIR_STSSI_Field is STM32_SVD.Byte;
-- Ethernet PTP subsecond increment register
type PTPSSIR_Register is record
-- System time subsecond increment
STSSI : PTPSSIR_STSSI_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPSSIR_Register use record
STSSI at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype PTPTSLR_STSS_Field is STM32_SVD.UInt31;
subtype PTPTSLR_STPNS_Field is STM32_SVD.Bit;
-- Ethernet PTP time stamp low register (ETH_PTPTSLR)
type PTPTSLR_Register is record
-- Read-only. System time subseconds
STSS : PTPTSLR_STSS_Field;
-- Read-only. System time positive or negative sign
STPNS : PTPTSLR_STPNS_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSLR_Register use record
STSS at 0 range 0 .. 30;
STPNS at 0 range 31 .. 31;
end record;
subtype PTPTSLUR_TSUSS_Field is STM32_SVD.UInt31;
subtype PTPTSLUR_TSUPNS_Field is STM32_SVD.Bit;
-- Ethernet PTP time stamp low update register (ETH_PTPTSLUR)
type PTPTSLUR_Register is record
-- Time stamp update subseconds
TSUSS : PTPTSLUR_TSUSS_Field := 16#0#;
-- Time stamp update positive or negative sign
TSUPNS : PTPTSLUR_TSUPNS_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSLUR_Register use record
TSUSS at 0 range 0 .. 30;
TSUPNS at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Ethernet: DMA controller operation
type ETHERNET_DMA_Peripheral is record
-- Ethernet DMA bus mode register
DMABMR : aliased DMABMR_Register;
-- Ethernet DMA transmit poll demand register
DMATPDR : aliased STM32_SVD.UInt32;
-- EHERNET DMA receive poll demand register
DMARPDR : aliased STM32_SVD.UInt32;
-- Ethernet DMA receive descriptor list address register
DMARDLAR : aliased STM32_SVD.UInt32;
-- Ethernet DMA transmit descriptor list address register
DMATDLAR : aliased STM32_SVD.UInt32;
-- Ethernet DMA status register
DMASR : aliased DMASR_Register;
-- Ethernet DMA operation mode register
DMAOMR : aliased DMAOMR_Register;
-- Ethernet DMA interrupt enable register
DMAIER : aliased DMAIER_Register;
-- Ethernet DMA missed frame and buffer overflow counter register
DMAMFBOCR : aliased DMAMFBOCR_Register;
-- Ethernet DMA current host transmit descriptor register
DMACHTDR : aliased STM32_SVD.UInt32;
-- Ethernet DMA current host receive descriptor register
DMACHRDR : aliased STM32_SVD.UInt32;
-- Ethernet DMA current host transmit buffer address register
DMACHTBAR : aliased STM32_SVD.UInt32;
-- Ethernet DMA current host receive buffer address register
DMACHRBAR : aliased STM32_SVD.UInt32;
end record
with Volatile;
for ETHERNET_DMA_Peripheral use record
DMABMR at 16#0# range 0 .. 31;
DMATPDR at 16#4# range 0 .. 31;
DMARPDR at 16#8# range 0 .. 31;
DMARDLAR at 16#C# range 0 .. 31;
DMATDLAR at 16#10# range 0 .. 31;
DMASR at 16#14# range 0 .. 31;
DMAOMR at 16#18# range 0 .. 31;
DMAIER at 16#1C# range 0 .. 31;
DMAMFBOCR at 16#20# range 0 .. 31;
DMACHTDR at 16#48# range 0 .. 31;
DMACHRDR at 16#4C# range 0 .. 31;
DMACHTBAR at 16#50# range 0 .. 31;
DMACHRBAR at 16#54# range 0 .. 31;
end record;
-- Ethernet: DMA controller operation
ETHERNET_DMA_Periph : aliased ETHERNET_DMA_Peripheral
with Import, Address => System'To_Address (16#40029000#);
-- Ethernet: media access control
type ETHERNET_MAC_Peripheral is record
-- Ethernet MAC configuration register (ETH_MACCR)
MACCR : aliased MACCR_Register;
-- Ethernet MAC frame filter register (ETH_MACCFFR)
MACFFR : aliased MACFFR_Register;
-- Ethernet MAC hash table high register
MACHTHR : aliased STM32_SVD.UInt32;
-- Ethernet MAC hash table low register
MACHTLR : aliased STM32_SVD.UInt32;
-- Ethernet MAC MII address register (ETH_MACMIIAR)
MACMIIAR : aliased MACMIIAR_Register;
-- Ethernet MAC MII data register (ETH_MACMIIDR)
MACMIIDR : aliased MACMIIDR_Register;
-- Ethernet MAC flow control register (ETH_MACFCR)
MACFCR : aliased MACFCR_Register;
-- Ethernet MAC VLAN tag register (ETH_MACVLANTR)
MACVLANTR : aliased MACVLANTR_Register;
-- Ethernet MAC remote wakeup frame filter register (ETH_MACRWUFFR)
MACRWUFFR : aliased STM32_SVD.UInt32;
-- Ethernet MAC PMT control and status register (ETH_MACPMTCSR)
MACPMTCSR : aliased MACPMTCSR_Register;
-- Ethernet MAC interrupt status register (ETH_MACSR)
MACSR : aliased MACSR_Register;
-- Ethernet MAC interrupt mask register (ETH_MACIMR)
MACIMR : aliased MACIMR_Register;
-- Ethernet MAC address 0 high register (ETH_MACA0HR)
MACA0HR : aliased MACA0HR_Register;
-- Ethernet MAC address 0 low register
MACA0LR : aliased STM32_SVD.UInt32;
-- Ethernet MAC address 1 high register (ETH_MACA1HR)
MACA1HR : aliased MACA1HR_Register;
-- Ethernet MAC address1 low register
MACA1LR : aliased STM32_SVD.UInt32;
-- Ethernet MAC address 2 high register (ETH_MACA2HR)
MACA2HR : aliased MACA2HR_Register;
-- Ethernet MAC address 2 low register
MACA2LR : aliased MACA2LR_Register;
-- Ethernet MAC address 3 high register (ETH_MACA3HR)
MACA3HR : aliased MACA3HR_Register;
-- Ethernet MAC address 3 low register
MACA3LR : aliased STM32_SVD.UInt32;
end record
with Volatile;
for ETHERNET_MAC_Peripheral use record
MACCR at 16#0# range 0 .. 31;
MACFFR at 16#4# range 0 .. 31;
MACHTHR at 16#8# range 0 .. 31;
MACHTLR at 16#C# range 0 .. 31;
MACMIIAR at 16#10# range 0 .. 31;
MACMIIDR at 16#14# range 0 .. 31;
MACFCR at 16#18# range 0 .. 31;
MACVLANTR at 16#1C# range 0 .. 31;
MACRWUFFR at 16#28# range 0 .. 31;
MACPMTCSR at 16#2C# range 0 .. 31;
MACSR at 16#38# range 0 .. 31;
MACIMR at 16#3C# range 0 .. 31;
MACA0HR at 16#40# range 0 .. 31;
MACA0LR at 16#44# range 0 .. 31;
MACA1HR at 16#48# range 0 .. 31;
MACA1LR at 16#4C# range 0 .. 31;
MACA2HR at 16#50# range 0 .. 31;
MACA2LR at 16#54# range 0 .. 31;
MACA3HR at 16#58# range 0 .. 31;
MACA3LR at 16#5C# range 0 .. 31;
end record;
-- Ethernet: media access control
ETHERNET_MAC_Periph : aliased ETHERNET_MAC_Peripheral
with Import, Address => System'To_Address (16#40028000#);
-- Ethernet: MAC management counters
type ETHERNET_MMC_Peripheral is record
-- Ethernet MMC control register (ETH_MMCCR)
MMCCR : aliased MMCCR_Register;
-- Ethernet MMC receive interrupt register (ETH_MMCRIR)
MMCRIR : aliased MMCRIR_Register;
-- Ethernet MMC transmit interrupt register (ETH_MMCTIR)
MMCTIR : aliased MMCTIR_Register;
-- Ethernet MMC receive interrupt mask register (ETH_MMCRIMR)
MMCRIMR : aliased MMCRIMR_Register;
-- Ethernet MMC transmit interrupt mask register (ETH_MMCTIMR)
MMCTIMR : aliased MMCTIMR_Register;
-- Ethernet MMC transmitted good frames after a single collision counter
MMCTGFSCCR : aliased STM32_SVD.UInt32;
-- Ethernet MMC transmitted good frames after more than a single
-- collision
MMCTGFMSCCR : aliased STM32_SVD.UInt32;
-- Ethernet MMC transmitted good frames counter register
MMCTGFCR : aliased STM32_SVD.UInt32;
-- Ethernet MMC received frames with CRC error counter register
MMCRFCECR : aliased STM32_SVD.UInt32;
-- Ethernet MMC received frames with alignment error counter register
MMCRFAECR : aliased STM32_SVD.UInt32;
-- MMC received good unicast frames counter register
MMCRGUFCR : aliased STM32_SVD.UInt32;
end record
with Volatile;
for ETHERNET_MMC_Peripheral use record
MMCCR at 16#0# range 0 .. 31;
MMCRIR at 16#4# range 0 .. 31;
MMCTIR at 16#8# range 0 .. 31;
MMCRIMR at 16#C# range 0 .. 31;
MMCTIMR at 16#10# range 0 .. 31;
MMCTGFSCCR at 16#4C# range 0 .. 31;
MMCTGFMSCCR at 16#50# range 0 .. 31;
MMCTGFCR at 16#68# range 0 .. 31;
MMCRFCECR at 16#94# range 0 .. 31;
MMCRFAECR at 16#98# range 0 .. 31;
MMCRGUFCR at 16#C4# range 0 .. 31;
end record;
-- Ethernet: MAC management counters
ETHERNET_MMC_Periph : aliased ETHERNET_MMC_Peripheral
with Import, Address => System'To_Address (16#40028100#);
-- Ethernet: Precision time protocol
type ETHERNET_PTP_Peripheral is record
-- Ethernet PTP time stamp control register (ETH_PTPTSCR)
PTPTSCR : aliased PTPTSCR_Register;
-- Ethernet PTP subsecond increment register
PTPSSIR : aliased PTPSSIR_Register;
-- Ethernet PTP time stamp high register
PTPTSHR : aliased STM32_SVD.UInt32;
-- Ethernet PTP time stamp low register (ETH_PTPTSLR)
PTPTSLR : aliased PTPTSLR_Register;
-- Ethernet PTP time stamp high update register
PTPTSHUR : aliased STM32_SVD.UInt32;
-- Ethernet PTP time stamp low update register (ETH_PTPTSLUR)
PTPTSLUR : aliased PTPTSLUR_Register;
-- Ethernet PTP time stamp addend register
PTPTSAR : aliased STM32_SVD.UInt32;
-- Ethernet PTP target time high register
PTPTTHR : aliased STM32_SVD.UInt32;
-- Ethernet PTP target time low register
PTPTTLR : aliased STM32_SVD.UInt32;
end record
with Volatile;
for ETHERNET_PTP_Peripheral use record
PTPTSCR at 16#0# range 0 .. 31;
PTPSSIR at 16#4# range 0 .. 31;
PTPTSHR at 16#8# range 0 .. 31;
PTPTSLR at 16#C# range 0 .. 31;
PTPTSHUR at 16#10# range 0 .. 31;
PTPTSLUR at 16#14# range 0 .. 31;
PTPTSAR at 16#18# range 0 .. 31;
PTPTTHR at 16#1C# range 0 .. 31;
PTPTTLR at 16#20# range 0 .. 31;
end record;
-- Ethernet: Precision time protocol
ETHERNET_PTP_Periph : aliased ETHERNET_PTP_Peripheral
with Import, Address => System'To_Address (16#40028700#);
end STM32_SVD.ETHERNET;
|
sondrehf/Sanntid | Ada | 3,397 | adb | with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
procedure exercise8 is
Count_Failed : exception; -- Exception to be raised when counting fails
Gen : Generator; -- Random number generator
protected type Transaction_Manager (N : Positive) is
entry Finished;
function Commit return Boolean;
procedure Signal_Abort;
private
Finished_Gate_Open : Boolean := False;
Aborted : Boolean := False;
end Transaction_Manager;
protected body Transaction_Manager is
entry Finished when Finished_Gate_Open or Finished'Count = N is
begin
------------------------------------------
-- PART 3: Modify the Finished entry
------------------------------------------
if Finished'Count = N-1 then
Finished_Gate_Open := True;
-- removed from ex7, Should_Commit := not Aborted;
end if;
if Finished'Count = 0 then
Finished_Gate_Open := False;
-- removed from ex7, Aborted := False;
end if;
end Finished;
------------------------------------------
-- PART 2: Create the Wait_Until_Aborted entry
entry Wait_Until_Aborted when Aborted is
begin
if Wait_Until_Aborted'Count = 0 then
Aborted := False;
end if;
end Wait_Until_Aborted;
------------------------------------------
procedure Signal_Abort is
begin
Aborted := True;
end Signal_Abort;
end Transaction_Manager;
function Unreliable_Slow_Add (x : Integer) return Integer is
Error_Rate : Constant := 0.15; -- (between 0 and 1)
begin
if Random(Gen) > Error_Rate then
delay Duration(Random(Gen) * 5.0);
return X + 10;
else
delay Duration(Random(Gen) * 1.0);
raise Count_Failed;
end if;
end Unreliable_Slow_Add;
task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager);
task body Transaction_Worker is
Num : Integer := Initial;
Prev : Integer := Num;
Round_Num : Integer := 0;
begin
Put_Line ("Worker" & Integer'Image(Initial) & " started");
loop
Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num));
Round_Num := Round_Num + 1;
------------------------------------------
-- PART 1: Select-Then-Abort statement
select
Manger.Wait_Until_Aborted;
Num := Prev + 5;
then abort
------------------------------------------
begin
Num := Unreliable_Slow_Add(Num);
exception
when Count_Failed =>
Manager.Signal_Abort;
end;
Manager.Finished;
Put_Line (" Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num));
end select;
Prev := Num;
delay 0.5;
end loop;
end Transaction_Worker;
Manager : aliased Transaction_Manager (3);
Worker_1 : Transaction_Worker (0, Manager'Access);
Worker_2 : Transaction_Worker (1, Manager'Access);
Worker_3 : Transaction_Worker (2, Manager'Access);
begin
Reset(Gen); -- Seed the random number generator
end exercise8;
|
faelys/natools | Ada | 4,861 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2011, 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. --
------------------------------------------------------------------------------
package body Natools.Tests is
------------------------
-- Helper Subprograms --
------------------------
function To_Result (Succeeded : Boolean) return Result is
begin
if Succeeded then
return Success;
else
return Fail;
end if;
end To_Result;
procedure Report_Exception
(Report : in out Reporter'Class;
Test_Name : String;
Ex : Ada.Exceptions.Exception_Occurrence;
Code : Result := Error) is
begin
Item (Report, Test_Name, Code);
Info (Report,
"Exception " & Ada.Exceptions.Exception_Name (Ex) & " raised:");
Info (Report, Ada.Exceptions.Exception_Message (Ex));
end Report_Exception;
-----------------
-- Test Object --
-----------------
function Item
(Report : access Reporter'Class;
Name : String;
Default_Outcome : Result := Success)
return Test is
begin
return Test'(Ada.Finalization.Limited_Controlled with
Report => Report,
Name => Ada.Strings.Unbounded.To_Unbounded_String (Name),
Info => Info_Lists.Empty_List,
Outcome => Default_Outcome,
Finalized => False);
end Item;
procedure Set_Result (Object : in out Test; Outcome : in Result) is
begin
Object.Outcome := Outcome;
end Set_Result;
procedure Info (Object : in out Test; Text : in String) is
begin
Object.Info.Append (Text);
end Info;
procedure Report_Exception
(Object : in out Test;
Ex : in Ada.Exceptions.Exception_Occurrence;
Code : in Result := Error) is
begin
Set_Result (Object, Code);
Info
(Object,
"Exception " & Ada.Exceptions.Exception_Name (Ex) & " raised:");
Info (Object, Ada.Exceptions.Exception_Message (Ex));
end Report_Exception;
procedure Fail (Object : in out Test; Text : in String := "") is
begin
Set_Result (Object, Fail);
if Text /= "" then
Info (Object, Text);
end if;
end Fail;
procedure Error (Object : in out Test; Text : in String := "") is
begin
Set_Result (Object, Error);
if Text /= "" then
Info (Object, Text);
end if;
end Error;
procedure Skip (Object : in out Test; Text : in String := "") is
begin
Set_Result (Object, Skipped);
if Text /= "" then
Info (Object, Text);
end if;
end Skip;
overriding procedure Finalize (Object : in out Test) is
Cursor : Info_Lists.Cursor;
begin
if not Object.Finalized then
Object.Finalized := True;
Object.Report.Item
(Ada.Strings.Unbounded.To_String (Object.Name),
Object.Outcome);
Cursor := Object.Info.First;
while Info_Lists.Has_Element (Cursor) loop
Object.Report.Info (Info_Lists.Element (Cursor));
Info_Lists.Next (Cursor);
end loop;
end if;
end Finalize;
procedure Generic_Check
(Object : in out Test;
Expected : in Result;
Found : in Result;
Label : in String := "") is
begin
if Expected /= Found then
if Multiline then
Fail (Object, Label);
Info (Object, "Expected: " & Image (Expected));
Info (Object, "Found: " & Image (Found));
elsif Label /= "" then
Fail (Object, Label
& ": expected " & Image (Expected)
& ", found " & Image (Found));
else
Fail (Object, "Expected " & Image (Expected)
& ", found " & Image (Found));
end if;
end if;
end Generic_Check;
end Natools.Tests;
|
jhumphry/auto_counters | Ada | 4,355 | adb | -- flyweight_example.adb
-- An example of using the Flyweight package
-- Copyright (c) 2016-2023, James Humphry
--
-- 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.
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Strings.Hash;
with Basic_Refcounted_Flyweights;
-- with Basic_Untracked_Flyweights;
-- with Protected_Refcounted_Flyweights;
-- with Protected_Untracked_Flyweights;
procedure Flyweight_Example is
type String_Ptr is access String;
package String_Flyweights is
new Basic_Refcounted_Flyweights(Element => String,
Element_Access => String_Ptr,
Hash => Ada.Strings.Hash,
Capacity => 16);
-- By commenting out the definition above and uncommenting one of the
-- definitions below, this example can use one of the other versions of the
-- Flyweights with no other changes required. The gnatmem tool can be used
-- to demonstrate the difference between the reference-counted and untracked
-- versions.
-- package String_Flyweights is
-- new Basic_Untracked_Flyweights(Element => String,
-- Element_Access => String_Ptr,
-- Hash => Ada.Strings.Hash,
-- Capacity => 16);
-- package String_Flyweights is
-- new Protected_Refcounted_Flyweights(Element => String,
-- Element_Access => String_Ptr,
-- Hash => Ada.Strings.Hash,
-- Capacity => 16);
-- package String_Flyweights is
-- new Protected_Untracked_Flyweights(Element => String,
-- Element_Access => String_Ptr,
-- Hash => Ada.Strings.Hash,
-- Capacity => 16);
use String_Flyweights;
Resources : aliased Flyweight;
HelloWorld_Raw_Ptr : String_Ptr := new String'("Hello, World!");
HelloWorld_Ref : constant Element_Ref
:= Insert_Ref (F => Resources, E => HelloWorld_Raw_Ptr);
HelloWorld_Ptr : constant Element_Ptr
:= Insert_Ptr (F => Resources, E => HelloWorld_Raw_Ptr);
begin
Put_Line("An example of using the Flyweights package."); New_Line;
Put_Line("The string ""Hello, World!"" has been added to the Resources");
Put_Line("Retrieving string via reference HelloWorld_Ref: " &
HelloWorld_Ref);
Put_Line("Retrieving string via pointer HelloWorld_Ptr: " &
HelloWorld_Ptr.Get.all);
Put_Line("Adding the same string again..."); Flush;
declare
HelloWorld2_Raw_Ptr : String_Ptr := new String'("Hello, World!");
HelloWorld2_Ref : constant Element_Ref
:= Insert_Ref (F => Resources, E => HelloWorld2_Raw_Ptr);
begin
Put_Line("Retrieving string via reference HelloWorld2_Ref: " &
HelloWorld2_Ref);
Put("Check references point to same copy: ");
Put((if HelloWorld2_Ref.E = HelloWorld_Ref.E then "OK" else "ERROR"));
New_Line; Flush;
declare
HelloWorld3_Ptr : constant Element_Ptr
:= Make_Ptr (HelloWorld2_Ref);
begin
Put_Line("Make a pointer HelloWorld3_Ptr from ref HelloWorld2_Ref: " &
HelloWorld3_Ptr.P); Flush;
end;
end;
Put_Line("Now HelloWorld2 is out of scope."); Flush;
Put_Line("HelloWorld should still point to the string: " & HelloWorld_Ref);
end Flyweight_Example;
|
reznikmm/matreshka | Ada | 6,921 | 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_Table.Table_Source_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Table_Source_Element_Node is
begin
return Self : Table_Table_Source_Element_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Table_Table_Source_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_Table_Table_Source
(ODF.DOM.Table_Table_Source_Elements.ODF_Table_Table_Source_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 Table_Table_Source_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Table_Source_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Table_Source_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_Table_Table_Source
(ODF.DOM.Table_Table_Source_Elements.ODF_Table_Table_Source_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 Table_Table_Source_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_Table_Table_Source
(Visitor,
ODF.DOM.Table_Table_Source_Elements.ODF_Table_Table_Source_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.Table_URI,
Matreshka.ODF_String_Constants.Table_Source_Element,
Table_Table_Source_Element_Node'Tag);
end Matreshka.ODF_Table.Table_Source_Elements;
|
reznikmm/matreshka | Ada | 3,585 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.DG.Texts.Hash is
new AMF.Elements.Generic_Hash (DG_Text, DG_Text_Access);
|
MinimSecure/unum-sdk | Ada | 876 | adb | -- Copyright 2015-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
procedure Foo is
procedure P (S : String) is
begin
null; -- BREAK
end P;
begin
P ((2 => 'a', 3 => 'b'));
P ((4 => 'c', 5 => 'd'));
end Foo;
|
AdaCore/libadalang | Ada | 1,991 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
package Pkg is
type T is tagged null record;
function F0 return T;
function F1 (X : T) return T;
function F2 (X, Y : T) return T;
procedure P2 (X, Y : T);
end Pkg;
package body Pkg is
function F0 return T is
begin
Put_Line ("F0 of T");
return (null record);
end F0;
function F1 (X : T) return T is
begin
Put_Line ("F1 of T");
return X;
end F1;
function F2 (X, Y : T) return T is
begin
Put_Line ("F2 of T");
return X;
end F2;
procedure P2 (X, Y : T) is
begin
Put_Line ("P2 of T");
end P2;
end Pkg;
package Der is
type U is new Pkg.T with null record;
function F0 return U;
function F1 (X : U) return U;
function F2 (X, Y : U) return U;
procedure P2 (X, Y : U);
end Der;
package body Der is
function F0 return U is
begin
Put_Line ("F0 of U");
return (null record);
end F0;
function F1 (X : U) return U is
begin
Put_Line ("F1 of U");
return X;
end F1;
function F2 (X, Y : U) return U is
begin
Put_Line ("F2 of U");
return X;
end F2;
procedure P2 (X, Y : U) is
begin
Put_Line ("P2 of U");
end P2;
end Der;
use Pkg;
X : T'Class := Der.U'(null record);
begin
Put_Line ("Test 1");
P2 (F0, F0);
-- no dynamic controlling operand, so none of these are dispatching
Put_Line ("Test 2");
P2 (X, F0);
-- X is dynamically tagged, so both F0 and P2 are dispatching
Put_Line ("Test 3");
P2 (F0, X);
-- Same as above
Put_Line ("Test 4");
P2 (F1 (F1 (F0)), F1 (F1 (X)));
-- Same as above but with more nesting
Put_Line ("Test 5");
P2 (F2 (F0, T'Class'(X)),
F2 (F0, F1 (T'(F0))));
-- Same but with more complex expressions
end Test;
|
zhmu/ananas | Ada | 218 | adb | -- { dg-do run }
-- This program used to fail with a runtime built with assertions
procedure RT_Signals is
task Task_A;
task body Task_A is
begin
null;
end Task_A;
begin
null;
end RT_Signals;
|
reznikmm/matreshka | Ada | 4,655 | 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.Marker_End_Width_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Marker_End_Width_Attribute_Node is
begin
return Self : Draw_Marker_End_Width_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_Marker_End_Width_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Marker_End_Width_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Marker_End_Width_Attribute,
Draw_Marker_End_Width_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Marker_End_Width_Attributes;
|
reznikmm/matreshka | Ada | 4,329 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes;
with XML.DOM.Attributes.Internals;
package body ODF.DOM.Attributes.Style.Print_Orientation.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Attributes.Style.Print_Orientation.Style_Print_Orientation_Access)
return ODF.DOM.Attributes.Style.Print_Orientation.ODF_Style_Print_Orientation is
begin
return
(XML.DOM.Attributes.Internals.Create
(Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Attributes.Style.Print_Orientation.Style_Print_Orientation_Access)
return ODF.DOM.Attributes.Style.Print_Orientation.ODF_Style_Print_Orientation is
begin
return
(XML.DOM.Attributes.Internals.Wrap
(Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Attributes.Style.Print_Orientation.Internals;
|
reznikmm/matreshka | Ada | 8,879 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-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$
------------------------------------------------------------------------------
private with Ada.Containers.Hashed_Maps;
with League.Holders;
with League.Strings;
private with League.Strings.Hash;
private with XML.SAX.Attributes;
with XML.SAX.Content_Handlers;
with XML.SAX.Lexical_Handlers;
private with XML.SAX.Locators;
with XML.SAX.Readers;
private with XML.Utilities.Namespace_Supports;
private with XML.Templates.Streams;
package XML.Templates.Processors is
type Template_Processor is
limited new XML.SAX.Content_Handlers.SAX_Content_Handler
and XML.SAX.Lexical_Handlers.SAX_Lexical_Handler with private;
procedure Set_Content_Handler
(Self : in out Template_Processor'Class;
Handler : XML.SAX.Readers.SAX_Content_Handler_Access);
procedure Set_Lexical_Handler
(Self : in out Template_Processor'Class;
Handler : XML.SAX.Readers.SAX_Lexical_Handler_Access);
procedure Set_Parameter
(Self : in out Template_Processor'Class;
Name : League.Strings.Universal_String;
Value : League.Holders.Holder);
private
package String_Holder_Maps is
new Ada.Containers.Hashed_Maps
(League.Strings.Universal_String,
League.Holders.Holder,
League.Strings.Hash,
League.Strings."=",
League.Holders."=");
type Boolean_Stack is mod 2 ** 64;
procedure Push (Self : in out Boolean_Stack; Value : Boolean);
procedure Pop (Self : in out Boolean_Stack; Value : out Boolean);
type Template_Processor is
limited new XML.SAX.Content_Handlers.SAX_Content_Handler
and XML.SAX.Lexical_Handlers.SAX_Lexical_Handler with record
Diagnosis : League.Strings.Universal_String;
Content_Handler : XML.SAX.Readers.SAX_Content_Handler_Access;
Lexical_Handler : XML.SAX.Readers.SAX_Lexical_Handler_Access;
Locator : XML.SAX.Locators.SAX_Locator;
Namespaces : XML.Utilities.Namespace_Supports.XML_Namespace_Support;
Parameters : String_Holder_Maps.Map;
Stream :
XML.Templates.Streams.XML_Stream_Element_Vectors.Vector;
Accumulate : Natural := 0;
Skip : Natural := 0;
-- Skip all events. Used to process 'if' directive.
Run_Else : Boolean := False;
-- All conditions on current 'if' level are evaluated to False
Run_Else_Stack : Boolean_Stack := 0;
-- Stack of Run_Else values
Accumulated_Text : League.Strings.Universal_String;
-- Character data is accumulated in this member to simplify processing.
Object_Name : League.Strings.Universal_String;
Container_Value : League.Holders.Holder;
end record;
-- Override SAX event handling subprogram.
overriding procedure Characters
(Self : in out Template_Processor;
Text : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure Comment
(Self : in out Template_Processor;
Text : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure End_CDATA
(Self : in out Template_Processor;
Success : in out Boolean);
overriding procedure End_Document
(Self : in out Template_Processor;
Success : in out Boolean);
overriding procedure End_DTD
(Self : in out Template_Processor;
Success : in out Boolean);
overriding procedure End_Element
(Self : in out Template_Processor;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure End_Prefix_Mapping
(Self : in out Template_Processor;
Prefix : League.Strings.Universal_String;
Success : in out Boolean);
overriding function Error_String
(Self : Template_Processor) return League.Strings.Universal_String;
overriding procedure Ignorable_Whitespace
(Self : in out Template_Processor;
Text : League.Strings.Universal_String;
Success : in out Boolean) renames Characters;
overriding procedure Processing_Instruction
(Self : in out Template_Processor;
Target : League.Strings.Universal_String;
Data : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure Set_Document_Locator
(Self : in out Template_Processor;
Locator : XML.SAX.Locators.SAX_Locator);
overriding procedure Start_CDATA
(Self : in out Template_Processor;
Success : in out Boolean);
overriding procedure Start_Document
(Self : in out Template_Processor;
Success : in out Boolean);
overriding procedure Start_DTD
(Self : in out Template_Processor;
Name : League.Strings.Universal_String;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure Start_Element
(Self : in out Template_Processor;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
overriding procedure Start_Prefix_Mapping
(Self : in out Template_Processor;
Prefix : League.Strings.Universal_String;
Namespace_URI : League.Strings.Universal_String;
Success : in out Boolean);
end XML.Templates.Processors;
|
zhmu/ananas | Ada | 6,084 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . T A B L E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-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 a singleton version of GNAT.Dynamic_Tables
-- (g-dyntab.ads). See that package for documentation. This package just
-- declares a single instance of GNAT.Dynamic_Tables.Instance, and provides
-- wrappers for all the subprograms, passing that single instance.
-- Note that these three interfaces should remain synchronized to keep as much
-- coherency as possible among these related units:
--
-- GNAT.Dynamic_Tables
-- GNAT.Table
-- Table (the compiler unit)
with GNAT.Dynamic_Tables;
generic
type Table_Component_Type is private;
type Table_Index_Type is range <>;
Table_Low_Bound : Table_Index_Type := Table_Index_Type'First;
Table_Initial : Positive := 8;
Table_Increment : Natural := 100;
Table_Name : String := ""; -- for debugging printouts
pragma Unreferenced (Table_Name);
Release_Threshold : Natural := 0;
package GNAT.Table is
pragma Elaborate_Body;
package Tab is new GNAT.Dynamic_Tables
(Table_Component_Type,
Table_Index_Type,
Table_Low_Bound,
Table_Initial,
Table_Increment,
Release_Threshold);
subtype Valid_Table_Index_Type is Tab.Valid_Table_Index_Type;
subtype Table_Last_Type is Tab.Table_Last_Type;
subtype Table_Type is Tab.Table_Type;
function "=" (X, Y : Table_Type) return Boolean renames Tab."=";
subtype Table_Ptr is Tab.Table_Ptr;
The_Instance : Tab.Instance;
Table : Table_Ptr renames The_Instance.Table;
Locked : Boolean renames The_Instance.Locked;
function Is_Empty return Boolean;
procedure Init;
pragma Inline (Init);
procedure Free;
pragma Inline (Free);
function First return Table_Index_Type;
pragma Inline (First);
function Last return Table_Last_Type;
pragma Inline (Last);
procedure Release;
pragma Inline (Release);
procedure Set_Last (New_Val : Table_Last_Type);
pragma Inline (Set_Last);
procedure Increment_Last;
pragma Inline (Increment_Last);
procedure Decrement_Last;
pragma Inline (Decrement_Last);
procedure Append (New_Val : Table_Component_Type);
pragma Inline (Append);
procedure Append_All (New_Vals : Table_Type);
pragma Inline (Append_All);
procedure Set_Item
(Index : Valid_Table_Index_Type;
Item : Table_Component_Type);
pragma Inline (Set_Item);
subtype Saved_Table is Tab.Instance;
-- Type used for Save/Restore subprograms
function Save return Saved_Table;
pragma Inline (Save);
-- Resets table to empty, but saves old contents of table in returned
-- value, for possible later restoration by a call to Restore.
procedure Restore (T : in out Saved_Table);
pragma Inline (Restore);
-- Given a Saved_Table value returned by a prior call to Save, restores
-- the table to the state it was in at the time of the Save call.
procedure Allocate (Num : Integer := 1);
function Allocate (Num : Integer := 1) return Valid_Table_Index_Type;
pragma Inline (Allocate);
-- Adds Num to Last. The function version also returns the old value of
-- Last + 1. Note that this function has the possible side effect of
-- reallocating the table. This means that a reference X.Table (X.Allocate)
-- is incorrect, since the call to X.Allocate may modify the results of
-- calling X.Table.
generic
with procedure Action
(Index : Valid_Table_Index_Type;
Item : Table_Component_Type;
Quit : in out Boolean) is <>;
procedure For_Each;
pragma Inline (For_Each);
generic
with function Lt (Comp1, Comp2 : Table_Component_Type) return Boolean;
procedure Sort_Table;
pragma Inline (Sort_Table);
end GNAT.Table;
|
charlie5/lace | Ada | 1,953 | adb | with
ada.Numerics.generic_elementary_Functions;
package body cached_Trigonometry
is
Sin_Cache : array (0 .. slot_Count - 1) of Float_Type;
Cos_Cache : array (0 .. slot_Count - 1) of Float_Type;
Pi_x_2 : constant := ada.Numerics.Pi * 2.0;
last_slot_Index : constant Float_Type := Float_Type (slot_Count - 1);
index_Factor : constant Float_Type := last_slot_Index / Pi_x_2;
function Cos (Angle : in Float_Type) return Float_Type
is
Index : standard.Integer := standard.Integer (Angle * index_Factor) mod slot_Count;
begin
if Index < 0 then
Index := Index + slot_Count;
end if;
return Cos_Cache (Index);
end Cos;
function Sin (Angle : in Float_Type) return Float_Type
is
Index : standard.Integer := standard.Integer (Angle * index_Factor) mod slot_Count;
begin
if Index < 0 then
Index := Index + slot_Count;
end if;
return Sin_Cache (Index);
end Sin;
procedure get (Angle : in Float_Type; the_Cos : out Float_Type;
the_Sin : out Float_Type)
is
Index : standard.Integer := standard.Integer (Angle * index_Factor) mod slot_Count;
begin
if Index < 0 then
Index := Index + slot_Count;
end if;
the_Sin := Sin_Cache (Index);
the_Cos := Cos_Cache (Index);
end get;
-- TODO: Tan, arcCos, etc
package Functions is new Ada.Numerics.generic_elementary_Functions (Float_Type);
begin
for Each in cos_Cache'Range
loop
cos_Cache (Each) := Functions.cos ( Float_Type (Each) / Float_Type (slot_Count - 1)
* Pi_x_2);
end loop;
for Each in sin_Cache'Range
loop
sin_Cache (Each) := Functions.sin ( Float_Type (Each) / Float_Type (slot_Count - 1)
* Pi_x_2);
end loop;
end cached_Trigonometry;
|
stcarrez/ada-awa | Ada | 2,142 | ads | -----------------------------------------------------------------------
-- awa-commands-migrate -- Database schema migration command
-- Copyright (C) 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.Command_Line;
with AWA.Commands.Drivers;
with AWA.Applications;
with ASF.Locales;
generic
with package Command_Drivers is new AWA.Commands.Drivers (<>);
package AWA.Commands.Migrate is
type Command_Type is new Command_Drivers.Application_Command_Type with record
Bundle : ASF.Locales.Bundle;
Execute : aliased Boolean := False;
end record;
-- Check and run the SQL migration scripts if necessary.
overriding
procedure Execute (Command : in out Command_Type;
Application : in out AWA.Applications.Application'Class;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Setup the command before parsing the arguments and executing it.
overriding
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type);
-- Write the help associated with the command.
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type);
Command : aliased Command_Type;
end AWA.Commands.Migrate;
|
AdaCore/libadalang | Ada | 24 | ads | package AWS is
end AWS;
|
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_Password_Attributes;
package Matreshka.ODF_Table.Password_Attributes is
type Table_Password_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Password_Attributes.ODF_Table_Password_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Password_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Password_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Password_Attributes;
|
reznikmm/matreshka | Ada | 3,868 | 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_Attributes.FO.Hyphenation_Remain_Char_Count is
type FO_Hyphenation_Remain_Char_Count_Node is
new Matreshka.ODF_Attributes.FO.FO_Node_Base with null record;
type FO_Hyphenation_Remain_Char_Count_Access is
access all FO_Hyphenation_Remain_Char_Count_Node'Class;
overriding function Get_Local_Name
(Self : not null access constant FO_Hyphenation_Remain_Char_Count_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Attributes.FO.Hyphenation_Remain_Char_Count;
|
sungyeon/drake | Ada | 2,165 | adb | -- Demonstration for the behaviors of unhandled exceptions.
with Ada.Exceptions;
with Ada.Interrupts.Names;
with Ada.Task_Identification;
with Ada.Task_Termination;
procedure exception_unhandled is
begin
-- terminate a task by unhandled exception
declare
task T;
task body T is
begin
Ada.Debug.Put ("in task T");
raise Program_Error; -- will be reported by default
end T;
begin
null;
end;
declare -- it can replace the report by a termination handler
Handled : Boolean := False;
protected Handlers is
procedure Handle_T2 (
Cause : Ada.Task_Termination.Cause_Of_Termination;
T : Ada.Task_Identification.Task_Id;
X : Ada.Exceptions.Exception_Occurrence);
end Handlers;
protected body Handlers is
procedure Handle_T2 (
Cause : Ada.Task_Termination.Cause_Of_Termination;
T : Ada.Task_Identification.Task_Id;
X : Ada.Exceptions.Exception_Occurrence)
is
pragma Unreferenced (T);
begin
case Cause is
when Ada.Task_Termination.Normal
| Ada.Task_Termination.Abnormal =>
null;
when Ada.Task_Termination.Unhandled_Exception =>
Ada.Debug.Put (Ada.Exceptions.Exception_Name (X));
Handled := True;
end case;
end Handle_T2;
end Handlers;
begin
declare
task T2;
task body T2 is
begin
Ada.Debug.Put ("in task T2");
Ada.Task_Termination.Set_Specific_Handler (
T2'Identity,
Handlers.Handle_T2'Unrestricted_Access);
raise Program_Error; -- will be handled by Handlers.Handle_T2
end T2;
begin
null;
end;
pragma Assert (Handled);
end;
-- terminate a interrupt handler by unhandled exception
declare
protected Handlers is
procedure Handle_SIGINT;
end Handlers;
protected body Handlers is
procedure Handle_SIGINT is
begin
Ada.Debug.Put ("in interrupt SIGINT");
raise Program_Error;
end Handle_SIGINT;
end Handlers;
begin
Ada.Interrupts.Unchecked_Attach_Handler (Handlers.Handle_SIGINT'Unrestricted_Access, Ada.Interrupts.Names.SIGINT);
Ada.Interrupts.Raise_Interrupt (Ada.Interrupts.Names.SIGINT);
end;
Ada.Debug.Put ("in environment task");
raise Program_Error;
end exception_unhandled;
|
stcarrez/ada-ado | Ada | 1,182 | ads | -----------------------------------------------------------------------
-- ado-audits-tests -- Audit tests
-- Copyright (C) 2018, 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 Util.Tests;
package ADO.Audits.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
overriding
procedure Set_Up (T : in out Test);
-- Test populating Audit_Fields
procedure Test_Audit_Field (T : in out Test);
end ADO.Audits.Tests;
|
io7m/coreland-posix-ada | Ada | 655 | adb | with POSIX.Error;
use type POSIX.Error.Error_t;
with POSIX.File;
use type POSIX.File.Offset_t;
with POSIX.File_Status;
use type POSIX.File_Status.Link_Count_t;
with Test;
procedure T_Stat1 is
Error_Value : POSIX.Error.Error_t;
Status : POSIX.File_Status.Status_t;
begin
POSIX.File_Status.Get_Status
(File_Name => "tmp/stat1",
Status => Status,
Error_Value => Error_Value);
Test.Assert (Error_Value = POSIX.Error.Error_None);
Test.Assert (POSIX.File_Status.Is_Valid (Status));
Test.Assert (POSIX.File_Status.Get_Size (Status) = 5);
Test.Assert (POSIX.File_Status.Get_Number_Of_Links (Status) = 1);
end T_Stat1;
|
tum-ei-rcs/StratoX | Ada | 1,894 | ads | -- This spec has been automatically generated from STM32F427x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with System;
with HAL;
package STM32_SVD.CRC is
pragma Preelaborate;
---------------
-- Registers --
---------------
------------------
-- IDR_Register --
------------------
subtype IDR_IDR_Field is HAL.Byte;
-- Independent Data register
type IDR_Register is record
-- Independent Data register
IDR : IDR_IDR_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IDR_Register use record
IDR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- CR_Register --
-----------------
-- Control register
type CR_Register is record
-- Write-only. Control regidter
CR : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
CR at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Cryptographic processor
type CRC_Peripheral is record
-- Data register
DR : HAL.Word;
-- Independent Data register
IDR : IDR_Register;
-- Control register
CR : CR_Register;
end record
with Volatile;
for CRC_Peripheral use record
DR at 0 range 0 .. 31;
IDR at 4 range 0 .. 31;
CR at 8 range 0 .. 31;
end record;
-- Cryptographic processor
CRC_Periph : aliased CRC_Peripheral
with Import, Address => CRC_Base;
end STM32_SVD.CRC;
|
reznikmm/matreshka | Ada | 3,968 | 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$
------------------------------------------------------------------------------
with Matreshka.ODF_Elements.Style.Table_Column_Properties;
package ODF.DOM.Elements.Style.Table_Column_Properties.Internals is
function Create
(Node : Matreshka.ODF_Elements.Style.Table_Column_Properties.Style_Table_Column_Properties_Access)
return ODF.DOM.Elements.Style.Table_Column_Properties.ODF_Style_Table_Column_Properties;
function Wrap
(Node : Matreshka.ODF_Elements.Style.Table_Column_Properties.Style_Table_Column_Properties_Access)
return ODF.DOM.Elements.Style.Table_Column_Properties.ODF_Style_Table_Column_Properties;
end ODF.DOM.Elements.Style.Table_Column_Properties.Internals;
|
nerilex/ada-util | Ada | 9,487 | ads | -----------------------------------------------------------------------
-- util-serialize-io -- IO Drivers for serialization
-- Copyright (C) 2010, 2011, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers;
with Ada.Strings.Unbounded;
with Ada.Calendar;
with Util.Beans.Objects;
with Util.Streams;
with Util.Streams.Buffered;
with Util.Serialize.Contexts;
with Util.Serialize.Mappers;
with Util.Log.Loggers;
with Util.Stacks;
package Util.Serialize.IO is
Parse_Error : exception;
-- ------------------------------
-- Output stream for serialization
-- ------------------------------
-- The <b>Output_Stream</b> interface defines the abstract operations for
-- the serialization framework to write objects on the stream according to
-- a target format such as XML or JSON.
type Output_Stream is limited interface and Util.Streams.Output_Stream;
-- Start a document.
procedure Start_Document (Stream : in out Output_Stream) is null;
-- Finish a document.
procedure End_Document (Stream : in out Output_Stream) is null;
procedure Start_Entity (Stream : in out Output_Stream;
Name : in String) is null;
procedure End_Entity (Stream : in out Output_Stream;
Name : in String) is null;
-- Write the attribute name/value pair.
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in String) is abstract;
procedure Write_Wide_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is abstract;
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is abstract;
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is abstract;
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is abstract;
procedure Write_Attribute (Stream : in out Output_Stream'Class;
Name : in String;
Value : in Ada.Strings.Unbounded.Unbounded_String);
-- Write the entity value.
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is abstract;
procedure Write_Wide_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is abstract;
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is abstract;
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is abstract;
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Ada.Calendar.Time) is abstract;
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Integer) is abstract;
procedure Write_Enum_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is abstract;
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is abstract;
procedure Write_Entity (Stream : in out Output_Stream'Class;
Name : in String;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Start_Array (Stream : in out Output_Stream;
Name : in String) is null;
procedure End_Array (Stream : in out Output_Stream;
Name : in String) is null;
type Parser is abstract new Util.Serialize.Contexts.Context with private;
-- Parse the stream using the JSON parser.
procedure Parse (Handler : in out Parser;
Stream : in out Util.Streams.Buffered.Buffered_Stream'Class) is abstract;
-- Read the file and parse it using the parser.
procedure Parse (Handler : in out Parser;
File : in String);
-- Parse the content string.
procedure Parse_String (Handler : in out Parser;
Content : in String);
-- Returns true if the <b>Parse</b> operation detected at least one error.
function Has_Error (Handler : in Parser) return Boolean;
-- Set the error logger to report messages while parsing and reading the input file.
procedure Set_Logger (Handler : in out Parser;
Logger : in Util.Log.Loggers.Logger_Access);
-- Start a new object associated with the given name. This is called when
-- the '{' is reached. The reader must be updated so that the next
-- <b>Set_Member</b> procedure will associate the name/value pair on the
-- new object.
procedure Start_Object (Handler : in out Parser;
Name : in String);
-- Finish an object associated with the given name. The reader must be
-- updated to be associated with the previous object.
procedure Finish_Object (Handler : in out Parser;
Name : in String);
procedure Start_Array (Handler : in out Parser;
Name : in String);
procedure Finish_Array (Handler : in out Parser;
Name : in String);
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
procedure Set_Member (Handler : in out Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Attribute : in Boolean := False);
-- Get the current location (file and line) to report an error message.
function Get_Location (Handler : in Parser) return String;
-- Report an error while parsing the input stream. The error message will be reported
-- on the logger associated with the parser. The parser will be set as in error so that
-- the <b>Has_Error</b> function will return True after parsing the whole file.
procedure Error (Handler : in out Parser;
Message : in String);
procedure Add_Mapping (Handler : in out Parser;
Path : in String;
Mapper : in Util.Serialize.Mappers.Mapper_Access);
-- Dump the mapping tree on the logger using the INFO log level.
procedure Dump (Handler : in Parser'Class;
Logger : in Util.Log.Loggers.Logger'Class);
private
-- Implementation limitation: the max number of active mapping nodes
MAX_NODES : constant Positive := 10;
type Mapper_Access_Array is array (1 .. MAX_NODES) of Serialize.Mappers.Mapper_Access;
procedure Push (Handler : in out Parser);
-- Pop the context and restore the previous context when leaving an element
procedure Pop (Handler : in out Parser);
function Find_Mapper (Handler : in Parser;
Name : in String) return Util.Serialize.Mappers.Mapper_Access;
type Element_Context is record
-- The object mapper being process.
Object_Mapper : Util.Serialize.Mappers.Mapper_Access;
-- The active mapping nodes.
Active_Nodes : Mapper_Access_Array;
end record;
type Element_Context_Access is access all Element_Context;
package Context_Stack is new Util.Stacks (Element_Type => Element_Context,
Element_Type_Access => Element_Context_Access);
type Parser is abstract new Util.Serialize.Contexts.Context with record
Error_Flag : Boolean := False;
Stack : Context_Stack.Stack;
Mapping_Tree : aliased Mappers.Mapper;
Current_Mapper : Util.Serialize.Mappers.Mapper_Access;
-- The file name to use when reporting errors.
File : Ada.Strings.Unbounded.Unbounded_String;
-- The logger which is used to report error messages when parsing an input file.
Error_Logger : Util.Log.Loggers.Logger_Access := null;
end record;
end Util.Serialize.IO;
|
godunko/adawebui | Ada | 4,476 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017-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: 5726 $ $Date: 2017-01-26 00:26:30 +0300 (Thu, 26 Jan 2017) $
------------------------------------------------------------------------------
package body Web.UI.Widgets.Buttons is
-- -----------------
-- -- Click_Event --
-- -----------------
--
-- overriding procedure Click_Event
-- (Self : in out Abstract_Button;
-- Event : in out WUI.Events.Mouse.Click.Click_Event'Class) is
-- begin
-- Self.Clicked.Emit;
-- end Click_Event;
--
-- --------------------
-- -- Clicked_Signal --
-- --------------------
--
-- not overriding function Clicked_Signal
-- (Self : in out Abstract_Button)
-- return not null access Core.Slots_0.Signal'Class is
-- begin
-- return Self.Clicked'Unchecked_Access;
-- end Clicked_Signal;
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Abstract_Button'Class;
Element : Web.HTML.Elements.HTML_Element'Class) is
begin
Web.UI.Widgets.Constructors.Initialize (Self, Element);
end Initialize;
end Constructors;
end Web.UI.Widgets.Buttons;
|
onox/orka | Ada | 11,711 | adb | -- 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 Ada.Numerics.Generic_Elementary_Functions;
with AUnit.Assertions;
with AUnit.Test_Caller;
with AUnit.Test_Fixtures;
package body Generic_Test_Transforms_Quaternions is
use Orka;
use Quaternions;
use AUnit.Assertions;
use type Vector4;
subtype Element_Type is Vectors.Element_Type;
use type Element_Type;
package EF is new Ada.Numerics.Generic_Elementary_Functions (Element_Type);
function To_Radians (Angle : Element_Type) return Element_Type renames Vectors.To_Radians;
function Is_Equivalent (Expected, Result : Element_Type) return Boolean is
(abs (Result - Expected) <= Element_Type'Model_Epsilon + 1.0e-05 * abs Expected);
procedure Assert_Equivalent (Expected, Result : Vector4) is
begin
for I in Index_4D loop
Assert (Is_Equivalent (Expected (I), Result (I)),
"Unexpected element " & Expected (I)'Image & " instead of " & Result (I)'Image &
" at " & I'Image);
end loop;
end Assert_Equivalent;
procedure Assert_Equivalent (Expected, Result : Quaternion) is
begin
for I in Index_4D loop
Assert (Is_Equivalent (Expected (I), Result (I)),
"Unexpected element " & Expected (I)'Image & " instead of " & Result (I)'Image &
" at " & I'Image);
end loop;
end Assert_Equivalent;
type Test is new AUnit.Test_Fixtures.Test_Fixture with null record;
procedure Test_Multiplication (Object : in out Test) is
Half_Angle : constant Element_Type := 45.0;
begin
declare
Axis : constant Vector4 := Vectors.Normalize ((1.0, 2.0, 3.0, 0.0));
Sin_Value : constant Element_Type := EF.Sin (Half_Angle, 360.0);
Cos_Value : constant Element_Type := EF.Cos (Half_Angle, 360.0);
Result : constant Quaternion :=
R (Axis, To_Radians (Half_Angle)) * R (Axis, To_Radians (Half_Angle));
Expected : constant Quaternion := (Axis (X) * Sin_Value,
Axis (Y) * Sin_Value,
Axis (Z) * Sin_Value,
Cos_Value);
begin
Assert_Equivalent (Expected, Result);
Assert (Normalized (Result), "Result not normalized");
end;
declare
Axis : constant Vector4 := (1.0, 0.0, 0.0, 0.0);
Angle_Radians : constant Element_Type := To_Radians (30.0);
Rotation : constant Quaternion :=
R (Axis, Angle_Radians) * R (Axis, Angle_Radians) * R (Axis, Angle_Radians);
Expected : constant Vector4 := (0.0, 0.0, 1.0, 0.0);
Result : constant Vector4 := Rotate ((0.0, 1.0, 0.0, 0.0), Rotation);
begin
Assert_Equivalent (Expected, Result);
end;
end Test_Multiplication;
procedure Test_Conjugate (Object : in out Test) is
Elements : constant Quaternion := (1.0, 2.0, 3.0, 4.0);
Expected : constant Quaternion := (-1.0, -2.0, -3.0, 4.0);
Result : constant Quaternion := Conjugate (Elements);
begin
Assert_Equivalent (Expected, Result);
end Test_Conjugate;
procedure Test_Norm (Object : in out Test) is
Elements_1 : constant Quaternion := (1.0, 2.0, 3.0, 4.0);
Elements_2 : constant Quaternion := (-1.0, 2.0, -3.0, 4.0);
Elements_3 : constant Quaternion := (0.0, 0.0, 0.0, 0.0);
Result_1 : constant Element_Type := Norm (Elements_1);
Result_2 : constant Element_Type := Norm (Elements_2);
Result_3 : constant Element_Type := Norm (Elements_3);
Expected_1 : constant Element_Type := EF.Sqrt (30.0);
Expected_2 : constant Element_Type := EF.Sqrt (30.0);
Expected_3 : constant Element_Type := 0.0;
begin
Assert (Is_Equivalent (Expected_1, Result_1), "Unexpected Single " & Result_1'Image);
Assert (Is_Equivalent (Expected_2, Result_2), "Unexpected Single " & Result_2'Image);
Assert (Is_Equivalent (Expected_3, Result_3), "Unexpected Single " & Result_3'Image);
end Test_Norm;
procedure Test_Normalize (Object : in out Test) is
Elements : constant Quaternion := (1.0, 2.0, 3.0, 4.0);
begin
Assert (not Normalized (Elements), "Elements is unexpectedly a unit quaternion");
declare
Result : constant Quaternion := Normalize (Elements);
begin
Assert (Normalized (Result), "Result not normalized");
end;
end Test_Normalize;
procedure Test_Normalized (Object : in out Test) is
Elements_1 : constant Quaternion := (0.0, 0.0, 0.0, 1.0);
Elements_2 : constant Quaternion := (0.5, 0.5, 0.5, -0.5);
Elements_3 : constant Quaternion := (0.0, -1.0, 0.0, 0.0);
Elements_4 : constant Quaternion := (1.0, 2.0, 3.0, 4.0);
begin
Assert (Normalized (Elements_1), "Elements_1 not normalized");
Assert (Normalized (Elements_2), "Elements_2 not normalized");
Assert (Normalized (Elements_3), "Elements_3 not normalized");
Assert (not Normalized (Elements_4), "Elements_4 normalized");
end Test_Normalized;
procedure Test_Rotate_Axis_Angle (Object : in out Test) is
Axis : constant Vector4 := Vectors.Normalize ((1.0, 2.0, 3.0, 0.0));
Angle : constant Element_Type := 90.0;
Sin_Value : constant Element_Type := EF.Sin (45.0, 360.0);
Cos_Value : constant Element_Type := EF.Cos (45.0, 360.0);
Result : constant Quaternion := R (Axis, To_Radians (Angle));
Expected : constant Quaternion := (Axis (X) * Sin_Value,
Axis (Y) * Sin_Value,
Axis (Z) * Sin_Value,
Cos_Value);
begin
Assert_Equivalent (Expected, Result);
Assert (Normalized (Result), "Result not normalized");
end Test_Rotate_Axis_Angle;
procedure Test_Axis_Angle (Object : in out Test) is
Axis : constant Vector4 := Vectors.Normalize ((1.0, 2.0, 3.0, 0.0));
Angle : constant Element_Type := 90.0;
Expected : constant Axis_Angle := (Axis => Vectors.Direction (Axis),
Angle => To_Radians (Angle));
Actual : constant Axis_Angle := To_Axis_Angle (From_Axis_Angle (Expected));
begin
Assert_Equivalent (Vector4 (Expected.Axis), Vector4 (Actual.Axis));
Assert (Is_Equivalent (Expected.Angle, Actual.Angle),
"Unexpected angle " & Actual.Angle'Image);
end Test_Axis_Angle;
procedure Test_Axis_Angle_No_Rotation (Object : in out Test) is
Actual : constant Element_Type := To_Axis_Angle (Identity).Angle;
Expected : constant Element_Type := 0.0;
begin
Assert (Is_Equivalent (Expected, Actual), "Unexpected angle " & Actual'Image);
end Test_Axis_Angle_No_Rotation;
procedure Test_Rotate_Vectors (Object : in out Test) is
Start_Vector : constant Vector4 := (0.0, 1.0, 0.0, 0.0);
End_Vector : constant Vector4 := (0.0, 0.0, 1.0, 0.0);
Axis : constant Vector4 := (1.0, 0.0, 0.0, 0.0);
Angle : constant Element_Type := 90.0;
Expected_1 : constant Quaternion := R (Axis, To_Radians (Angle));
Result_1 : constant Quaternion := R (Start_Vector, End_Vector);
Expected_2 : constant Quaternion := R (Axis, To_Radians (-Angle));
Result_2 : constant Quaternion := R (End_Vector, Start_Vector);
begin
Assert_Equivalent (Expected_1, Result_1);
Assert_Equivalent (Expected_2, Result_2);
end Test_Rotate_Vectors;
procedure Test_Rotate (Object : in out Test) is
Axis : constant Vector4 := (1.0, 0.0, 0.0, 0.0);
Angle : constant Element_Type := 90.0;
Rotation : constant Quaternion := R (Axis, To_Radians (Angle));
Expected : constant Vector4 := (0.0, 0.0, 1.0, 0.0);
Result : constant Vector4 := Rotate ((0.0, 1.0, 0.0, 0.0), Rotation);
begin
Assert_Equivalent (Expected, Result);
end Test_Rotate;
procedure Test_Difference (Object : in out Test) is
Axis : constant Vector4 := (1.0, 0.0, 0.0, 0.0);
Angle_A : constant Element_Type := 30.0;
Angle_B : constant Element_Type := 90.0;
Rotation_A : constant Quaternion := R (Axis, To_Radians (Angle_A));
Rotation_B : constant Quaternion := R (Axis, To_Radians (Angle_B));
Actual : constant Axis_Angle := To_Axis_Angle (Difference (Rotation_A, Rotation_B));
Expected : constant Axis_Angle := (Axis => Vectors.Direction (Axis),
Angle => To_Radians (60.0));
begin
Assert_Equivalent (Vector4 (Expected.Axis), Vector4 (Actual.Axis));
Assert (Is_Equivalent (Expected.Angle, Actual.Angle),
"Unexpected angle " & Actual.Angle'Image);
end Test_Difference;
procedure Test_Slerp (Object : in out Test) is
Axis : constant Vector4 := (1.0, 0.0, 0.0, 0.0);
Angle : constant Element_Type := 45.0;
Start_Quaternion : constant Quaternion := R (Axis, To_Radians (0.0));
End_Quaternion : constant Quaternion := R (Axis, To_Radians (90.0));
Expected : constant Quaternion := R (Axis, To_Radians (Angle));
Result : constant Quaternion := Slerp (Start_Quaternion, End_Quaternion, 0.5);
begin
Assert_Equivalent (Expected, Result);
end Test_Slerp;
----------------------------------------------------------------------------
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 := "(Transforms - " & Suite_Name & " - Quaternions) ";
begin
Test_Suite.Add_Test (Caller.Create
(Name & "Test '*' operator", Test_Multiplication'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Conjugate function", Test_Conjugate'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Norm function", Test_Norm'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Normalize function", Test_Normalize'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Normalized function", Test_Normalized'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test to/from Axis_Angle functions", Test_Axis_Angle'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test To_Axis_Angle function with Identity", Test_Axis_Angle_No_Rotation'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Rotate_Axis_Angle function", Test_Rotate_Axis_Angle'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Rotate_Vectors function", Test_Rotate_Vectors'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Rotate function", Test_Rotate'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Difference function", Test_Difference'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Slerp function", Test_Slerp'Access));
return Test_Suite'Access;
end Suite;
end Generic_Test_Transforms_Quaternions;
|
jscparker/math_packages | Ada | 68,377 | adb |
-----------------------------------------------------------------------
-- package body Extended_Real.Elementary_Functions, extended precision functions
-- Copyright (C) 2008-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 body Extended_Real.Elementary_Functions is
Max_Available_Bits : constant e_Integer
:= Desired_No_Of_Bits_in_Radix * e_Real_Machine_Mantissa;
-- This equals: Bits_per_Mantissa = Bits_per_Digit * No_of_Digits_per_Mantissa
-- (e_Real_Machine_Mantissa = Mantissa'Length = No_of_Digits_per_Mantissa).
-- The following are frequently used global constants:
Radix : constant Real := e_Real_Machine_Radix;
Half_Digit : constant E_Digit := Make_E_Digit (0.5);
Two_Digit : constant E_Digit := Make_E_Digit (2.0);
Three_Digit : constant E_Digit := Make_E_Digit (3.0);
Four_Digit : constant E_Digit := Make_E_Digit (4.0);
Nine_Digit : constant E_Digit := Make_E_Digit (9.0);
Twelve_Digit : constant E_Digit := Make_E_Digit (12.0);
--One : constant e_Real := +1.0; -- in Extended_Real spec
--Zero : constant e_Real := +0.0;
Two : constant e_Real := +2.0;
Three : constant e_Real := +3.0;
Half : constant e_Real := +0.5;
Three_Quarters : constant e_Real := +(0.75);
Less_Than_Half_Pi : constant e_Real := +(3.14159265 / 2.0);
-- Global memory for important constants. They're initialized
-- on the first call to the functions that return them, and
-- there after are simply returned from memory:
-- Pi, Sqrt_2, etc
type Pi_mem is record
Val : e_Real; -- automatically initialized to Zero.
Initialized : Boolean := False;
end record;
Pi_Memory : Pi_Mem;
type Inverse_Pi_mem is record
Val : e_Real; -- automatically initialized to Zero.
Initialized : Boolean := False;
end record;
Inverse_Pi_Memory : Inverse_Pi_Mem;
type Quarter_Pi_mem is record
Val : e_Real; -- automatically initialized to Zero.
Initialized : Boolean := False;
end record;
Quarter_Pi_Memory : Quarter_Pi_Mem;
type Inverse_Sqrt_2_mem is record
Val : e_Real;
Initialized : Boolean := False;
end record;
Inverse_Sqrt_2_memory : Inverse_Sqrt_2_mem;
type Half_Inverse_Log_2_mem is record
Val : e_Real;
Initialized : Boolean := False;
end record;
Half_Inverse_Log_2_memory : Half_Inverse_Log_2_mem;
type Log_2_mem is record
Val : e_Real;
Initialized : Boolean := False;
end record;
Log_2_memory : Log_2_mem;
------------
-- Arcsin --
------------
-- The result of the Arcsin function is in the quadrant containing
-- the point (1.0, x), where x is the value of the parameter X. This
-- quadrant is I or IV; thus, the range of the Arcsin function is
-- approximately -Pi/2.0 to Pi/2.0 (-Cycle/4.0 to Cycle/4.0, if the
-- parameter Cycle is specified).
-- Argument_Error is raised by Arcsin when the absolute
-- value of the parameter X exceeds one.
--
-- Uses Newton's method: Y_k+1 = Y_k + (A - Sin(Y_k)) / Cos(Y_k)
-- to get Arcsin(A).
-- Requires call to Arcsin (Real) and assumes that this call gets
-- the first two radix digits correct: 48 bits usually. (It almost
-- always gets 53 bits correct.)
--
-- Arcsin(x) = x + x^3/6 + 3*x^5/40 ...
-- (so Arctan(x) = x if x < e_Real_Model_Epsilon)
function Arcsin (X : e_Real)
return e_Real
is
Y_0 : e_Real;
X_Abs : e_Real := Abs (X);
No_Correct_Bits : E_Integer;
Sign_Is_Negative : Boolean := False;
Scaling_Performed : Boolean := False;
begin
if Are_Equal (X_Abs, Positive_Infinity) then
raise E_Argument_Error;
end if;
if One < X_Abs then
raise E_Argument_Error;
end if;
if X_Abs < e_Real_Model_Epsilon then
return X; -- series solution: arcsin = x + x^3/6 + ...
end if;
Sign_Is_Negative := False;
if X < Zero then
Sign_Is_Negative := True;
end if;
if Are_Equal (X_Abs, One) then
Y_0 := Two_Digit * e_Quarter_Pi;
if Sign_Is_Negative then Y_0 := -Y_0; end if;
return Y_0;
end if;
-- STEP 2. We may have to scale the argument if it's near 1. Newton_Raphson
-- doesn't do well there. So we use identity:
--
-- arcsin(x) - arcsin(y) = arcsin(x*Sqrt(1-y*y) - y*Sqrt(1-x*x)),
--
-- so setting y = 1 (get the arccos(x) = Pi/2 - Arcsin(x)):
--
-- arcsin(x) = -arcsin(Sqrt(1-x*x)) + Pi/2.
--
-- Well, we can't use Sqrt(1-x*x) because there's too much error near
-- X = small. We can use Sqrt(1-X) * Sqrt(1+X) but don't want the 2 sqrts.
-- So! we want Arcsin (Sqrt(1-X) * Sqrt(1+X)) = Y, or
-- Sin(Y) = 2 * Sqrt((1-X)/2) * Sqrt((1+X)/2). Then Sin(Y) = 2*Sin(Z)Cos(Z)
-- where Z = Arcsin(Sqrt((1-X)/2)). So, Y = Arcsin (Sin(Z + Z)) = 2*Z.
-- The final answer is Arcsin(X) = Pi/2 - 2*Arcsin(Sqrt((1-X)/2)).
--
-- IMPORTANT: We can't scale if X_Abs <= 0.5 because we use this
-- routine with an argument of 0.5 to calculate Pi, and scaling
-- requires a knowledge of Pi.
Scaling_Performed := False;
if Three_Quarters < X_Abs then
X_Abs := Sqrt (Half - Half_Digit * X_Abs);
Scaling_Performed := True;
end if;
-- Need starting value for Newton's iteration of Arcsin (X_scaled).
-- Assume positive arg to improve likelihood that
-- external Arcsin fctn. does what we want.
Y_0 := Make_Extended (Arcsin (Make_Real (X_Abs)));
No_Correct_Bits := Real'Machine_Mantissa - 2;
loop
--Y_0 := Y_0 + (X_Abs - Sin(Y_0)) / Cos(Y_0);
Y_0 := Y_0 + Divide ((X_Abs - Sin(Y_0)) , Cos(Y_0));
-- Cos is never near 0.
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits >= Max_Available_Bits;
end loop;
if Scaling_Performed then
Y_0 := Two_Digit * (e_Quarter_Pi - Y_0);
end if;
if Sign_Is_Negative then
Y_0 := -Y_0;
end if;
return Y_0;
end Arcsin;
------------
-- Arccos --
------------
-- The result of the Arccos function is in the quadrant containing
-- the point (x, 1.0), where x is the value of the parameter X. This
-- quadrant is I or II; thus, the Arccos function ranges from 0.0 to
-- approximately Pi (Cycle/2.0, if the parameter Cycle is
-- specified).
--
-- Argument_Error is raised by Arccos when the absolute
-- value of the parameter X exceeds one.
--
-- In all cases use Arccos(X) = Pi/2 - Arcsin(X).
-- When Abs(X) < 0.5 we use Pi/2 - Arcsin(X). When
-- Abs(X) > 0.5 it's better to use the following formula for Arcsin:
-- Arcsin(X) = Pi/2 - 2*Arcsin(Sqrt((1-|X|)/2)). (X > 0.0)
-- Arcsin(X) = -Pi/2 + 2*Arcsin(Sqrt((1-|X|)/2)). (X < 0.0)
--
function Arccos (X : e_Real)
return e_Real
is
Result : e_Real;
X_Abs : constant e_Real := Abs (X);
begin
if X_Abs > One then
raise Constraint_Error;
end if;
if Are_Equal (X, Zero) then
return Two_Digit * e_Quarter_Pi;
end if;
if Are_Equal (X, One) then
return Zero;
end if;
if Are_Equal (X, -One) then
return e_Pi;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
if X > Half then
Result := Two_Digit * Arcsin (Sqrt (Half - Half_Digit*X_Abs));
elsif X < -Half then
Result := Four_Digit*
(e_Quarter_Pi - Half_Digit*Arcsin (Sqrt (Half - Half_Digit*X_Abs)));
else
Result := (e_Quarter_Pi - Arcsin(X)) + e_Quarter_Pi;
end if;
-- e_Quarter_Pi is stored with more correct binary digits than
-- E_Half_Pi because it's slightly less than 1.0.
return Result;
end Arccos;
------------
-- Arctan --
------------
-- Newton's method avoids divisions:
--
-- Result := Result + Cos(Result) * (Cos(Result) * Arg - Sin(Result))
--
-- Arctan(x) = Pi/2 - Arctan(1/x)
-- Arctan(x) = -Pi/2 + Arctan(1/x) (x<0)
--
-- Arctan(x) = x - x^3/3 + x^5/5 - x^7/7 ...
-- (so Arctan(x) = x if x < e_Real_Model_Epsilon)
--
-- Arctan (X) = Arcsin(X / Sqrt(1 + X**2)).
--
-- Not really Ada95-ish for Arctan.
--
function Arctan
(X : e_Real)
return e_Real
is
Y_0, Arg, Cos_Y_0, Sin_Y_0 : e_Real;
X_Abs : constant e_Real := Abs (X);
X_real : Real;
Sign_Is_Negative : Boolean := False;
Argument_Reduced : Boolean := False;
No_Correct_Bits : E_Integer;
begin
if X_Abs < e_Real_Model_Epsilon then
return X; -- series solution: arctan = x - x^3/3 + ...
end if;
Sign_Is_Negative := False;
if X < Zero then
Sign_Is_Negative := True;
end if;
-- returns Pi/2 at +/- inf. (Note Reciprocal returns 1/inf as Zero.)
-- inf is regarded as large finite number. Raising exceptions
-- in these cases may also be good idea. Which is right?
if Are_Equal (X_Abs, Positive_Infinity) then
Y_0 := Two_Digit * e_Quarter_Pi;
if Sign_Is_Negative then Y_0 := -Y_0; end if;
return Y_0;
end if;
-- function Make_Real underflows to 0.0 as desired for small X_Abs.
if X_abs < Two then
Argument_Reduced := False;
Arg := X_abs;
else
-- use: Arctan(x) = Pi/2 - Arctan(1/x)
Argument_Reduced := True;
Arg := Reciprocal (X_abs);
end if;
X_real := Make_Real (Arg);
Y_0 := Make_Extended (Arctan (X_real));
No_Correct_Bits := Real'Machine_Mantissa - 2;
loop
Sin_Y_0 := Sin (Y_0);
Cos_Y_0 := Cos (Y_0); -- bst accuracy.
--Cos_Y_0 := Sqrt (One - Sin_Y_0*Sin_Y_0); -- fstr, not too bad accuracy-wise.
Y_0 := Y_0 + (Arg*Cos_Y_0 - Sin_Y_0) * Cos_Y_0;
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits >= Max_Available_Bits;
end loop;
if Argument_Reduced then
Y_0 := Two_Digit * (e_Quarter_Pi - Half_Digit*Y_0);
end if;
-- Lose a whole guard digit of precision when we double e_Quarter_Pi.
-- (It becomes slightly > 1, pushes a digit off the end of the mantissa.)
-- So do the subtraction 1st.
if Sign_Is_Negative then
Y_0 := -Y_0;
end if;
return Y_0;
end Arctan;
---------
-- Log --
---------
-- Uses Newton's method: Y_k+1 = Y_k + (A - Exp(Y_k)) / Exp(Y_k)
-- to get Log(A) = Natural Log, the inverse of Exp.
-- Requires call to Log (Real) and assumes that this call gets
-- the first two radix digits correct: 48 bits usually. (It almost
-- always gets 53 bits correct.) Argument reduction due to Brent:
-- 1st step is to get a rough approximate value of Log(X), called
-- Log_X_approx. Then get Y = Log(X/exp(Log_X_approx)).
-- The final answer is Log(X) = Y + Log_X_approx. (Disabled at present.)
-- This gets Y very near 0, which greatly speeds up subsequent
-- calls to Exp in the Newton iteration above. Actually,
-- the scaling business is commented out below. If you uncomment it,
-- the routine runs 60% faster, in some tests, but is less accurate.
-- We'll err on the side of accuracy and use an unscaled X. But
-- if you use extended floating point with 2 guard digits, it would
-- be sensible to use the scaled X, because the loss in accuracy is
-- negligable compared to the extra precision of another guard digit.
-- Test for X = One: must return Zero.
--
-- The exception Constraint_Error is raised, signaling a pole of the
-- mathematical function (analogous to dividing by zero), in the following
-- cases, provided that Float_Type'Machine_Overflows is True:
-- by the Log, Cot, and Coth functions, when the value of the
-- parameter X is zero;
function Log (X : e_Real)
return e_Real
is
Result, X_scaled, Y_0 : e_Real;
X_Exp : E_Integer;
No_Correct_Bits : E_Integer;
Log_X_approx_real : Real;
begin
if X < Zero then
raise E_Argument_Error;
end if;
if Are_Equal (X, Zero) then
raise Constraint_Error;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, One) then
return Zero;
end if;
-- STEP 1. First argument reduction step. Get Log_X_approx_real using
-- a call to log(real). If X=0 or inf, then X_scaled=0..get exception.
X_Exp := Exponent (X);
X_scaled := Fraction (X); -- not zero or infinity.
Log_X_approx_real := Log (Make_Real(X_scaled)) + Log (Radix) * Real (X_Exp);
X_scaled := X;
-- Log_X_approx := Make_Extended (Log_X_approx_real);
-- X_scaled := X / Exp (Log_X_approx);
-- The above Scaling is the fastest, since then Exp does no scaling.
-- It is clearly less accurate, tho' tolerably so, especially if you
-- use two guard digits instead of 1. We use the unscaled X here,
-- because it (for example) returns a value of Log(2.0)
-- with an error that is about 50 times smaller than the above.
-- STEP 2. Need starting value for Newton's iteration of Log (X_scaled).
--Y_0 := Make_Extended (Log (Make_Real (X_scaled))); -- slightly > Zero
Y_0 := Make_Extended (Log_X_approx_real);
-- STEP 3. Start the iteration. Calculate the number of iterations
-- required as follows. num correct digits doubles each iteration.
-- 1st iteration gives 4 digits, etc. Each step set desired precision
-- to one digit more than that we expect from the Iteration.
No_Correct_Bits := Real'Machine_Mantissa - 2;
loop
Y_0 := Y_0 + (X_scaled * Exp(-Y_0) - One);
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits >= Max_Available_Bits;
end loop;
--Result := Y_0 + Log_X_approx; -- for use with scaled version (Step 2)
Result := Y_0;
return Result;
end Log;
--------------------------
-- Log (arbitrary base) --
--------------------------
-- The exception E_Argument_Error is raised, signaling a parameter
-- value outside the domain of the corresponding mathematical function,
-- in the following cases:
-- by the Log function with specified base, when the value of the
-- parameter Base is zero, one, or negative;
--
-- The exception Constraint_Error is raised, signaling a pole of the
-- mathematical function (analogous to dividing by zero), in the following
-- cases, provided that Float_Type'Machine_Overflows is True:
-- by the Log, Cot, and Coth functions, when the value of the
-- parameter X is zero.
--
-- Struggling to remember: Z = Log(X, Base) implies X = Base**Z
-- or X = Exp (Log(Base)*Z) which implies Log(X) = Log(Base) * Z, so
-- Log(X, Base) = Z = Log(X) / Log(Base).
--
function Log (X : e_Real; Base : e_Real) return e_Real is
Result : e_Real;
begin
if Are_Equal (Base,Zero) then
raise E_Argument_Error;
end if;
if Base < Zero then
raise E_Argument_Error;
end if;
if Are_Equal (Base,One) then
raise E_Argument_Error;
end if;
if Are_Equal (Base,Two) then
Result := Two_Digit * (Log(X) * e_Half_Inverse_Log_2);
-- Divide by e_log_2. Multiply by 0.5/Log(2) not 1/log(2), because
-- 0.5/Log(2) is slightly less than 1, hence contains more correct
-- digits. (And multiplication is preferred for efficiency.)
else
Result := Log(X) / Log(Base);
end if;
return Result;
end Log;
----------
-- "**' --
----------
-- Say X**N = Exp (Log (X) * N).
--
-- Exponentiation by a zero exponent yields the value one.
-- Exponentiation by a unit exponent yields the value of the left
-- operand. Exponentiation of the value one yields the value one.
-- Exponentiation of the value zero yields the value zero.
-- The results of the Sqrt and Arccosh functions and that of the
-- exponentiation operator are nonnegative.
--
-- Argument_Error is raised by "**" operator, when the value of the left
-- operand is negative or when both operands have the value zero;
--
function "**" (Left : e_Real; Right : e_Real) return e_Real is
Result : e_Real;
begin
-- Errors:
if Left < Zero then
raise E_Argument_Error;
end if;
if Are_Equal (Left, Zero) and then Are_Equal (Right, Zero) then
raise E_Argument_Error;
end if;
-- Special Cases. We now know that they aren't both Zero:
if Are_Equal (Right, Zero) then -- Left is not Zero
return One;
end if;
if Are_Equal (Left, Zero) then -- Right is not Zero
return Zero;
end if;
if Are_Equal (Right, One) then
return Left;
end if;
if Are_Equal (Left, One) then -- Still OK if Right = Zero
return One;
end if;
-- Should we optimize for integer N?
Result := Exp (Log (Left) * Right);
return Result;
end "**";
---------
-- Exp --
---------
-- Sum Taylor series for Exp(X).
-- Actually, we sum series for Exp(X) - 1 - X, because scaling makes
-- X small, and Exp(X) - 1 - X has more correct digits for small X.
-- [get max arg size and test for it.]
--
function Exp
(X : e_Real)
return e_Real
is
Order : Real := 0.0;
Delta_Exponent : E_Integer := 0;
Next_Term, Sum : e_Real;
X_Scaled_2, X_scaled_1 : e_Real;
Total_Digits_To_Use : E_Integer;
N : Integer;
N_e_Real : e_Real;
J : constant Integer := 11;
Scale_Factor_2 : constant Integer := 2**J;
-- Must be power of 2 for function call to Make_E_Digit.
-- The optimal value increases with desired precision. But higher
-- order terms in the series are cheap, so it's not *too* important.
Inverse_Two_To_The_J : constant E_Digit
:= Make_E_Digit (1.0 / Real (Scale_Factor_2));
We_Flipped_The_Sign_Of_X_scaled : Boolean := False;
First_Stage_Scaling_Performed : Boolean := False;
Second_Stage_Scaling_Performed : Boolean := False;
begin
if Are_Equal (X, Zero) then
return One;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
-- STEP 1. Reduce argument in 2 stages: 1st Remainder(X, Log(2)),
-- then divide by 2**J.
-- So X_Scaled = Remainder (X, Log_2), or approximately:
-- X_Scaled = X - Unbiased_Rounding (X / Log(2)) * Log(2) = X - N * Log(2)
-- Then Exp(X) = Exp(X_Scaled) * Exp(N*Log(2)) = Exp(X_Scaled) * 2**N.
--
-- Second stage of argument reduction: divide X_Scaled by 2**J:
-- Exp(X) = Exp(X_Scaled/2**J)**2**J * 2**N.
--
-- E_log_2 is calculated by recursively calling this routine, but
-- with an argument very near 0.0, so First stage scaling is not
-- performed. (It also calls with arg of approx. log(2) = 0.69, so
-- must not allow 1st stage scaling for args that small.)
N := 0;
X_Scaled_1 := X;
First_Stage_Scaling_Performed := False;
if Three_Quarters < Abs (X) then
N_e_Real := Unbiased_Rounding (Two_Digit * (X_Scaled_1 * E_Half_Inverse_Log_2));
X_Scaled_1 := Remainder (X_Scaled_1, E_Log_2);
-- Use X_Scaled_1 := X_Scaled_1 - N_e_Real * E_Log_2; ?
-- Not much faster. Somewhat less accurate. Seems OK for small args.
if Make_Extended (Real (Integer'Last)) < Abs (N_e_Real) then
raise E_Argument_Error with "Argument too large in Exp.";
end if;
N := Integer (Make_Real (N_e_Real));
First_Stage_Scaling_Performed := True;
end if;
-- STEP 1b. We want to get Exp() slightly less than one, to maximize
-- the precision of the calculation. So make sure arg is negative.
We_Flipped_The_Sign_Of_X_scaled := False;
if not (X_scaled_1 < Zero) then
We_Flipped_The_Sign_Of_X_scaled := True;
X_scaled_1 := -X_scaled_1;
end if;
-- STEP 2. 2nd stage of argument reduction. Divide X_scaled by 2**J.
-- Don't scale if arg is already small to avoid complications due
-- to underflow of arg to zero. Arg may already be 0. It's OK.
if Exponent (X_Scaled_1) >= -2 then -- it'll do, Zero OK here
X_Scaled_2 := Inverse_Two_To_The_J * X_Scaled_1;
Second_Stage_Scaling_Performed := True;
else
X_scaled_2 := X_scaled_1;
Second_Stage_Scaling_Performed := False;
end if;
-- STEP 3. Start the sum. Calculate Exp(X_Scaled) - (1 + X_Scaled),
-- because for small X_Scaled, this contains more correct digits than Exp.
-- Start summing the series at order 2 instead of order 0.
-- We have verified above that X_scaled /= Zero.
Order := 2.0;
Next_Term := Half_Digit * X_Scaled_2 * X_Scaled_2;
Sum := Next_Term;
loop
Order := Order + 1.0;
if Order = Radix then
raise E_Argument_Error with "Too many terms needed in Exp taylor sum.";
end if;
-- Use relative Exponents of Sum and Next_Term to check convergence
-- of the sum. Exponent doesn't work for args of 0, so check.
-- Abs (Next_Term) <= Abs (Sum), so we need only check Next_Term.
if Are_Equal (Next_Term, Zero) then exit; end if;
Delta_Exponent := Exponent (Sum) - Exponent (Next_Term);
Total_Digits_To_Use := e_Real_Machine_Mantissa - Delta_Exponent + 1;
exit when Total_Digits_To_Use <= 0;
Next_Term := (X_Scaled_2 * Next_Term) / Make_E_Digit (Order);
Sum := Sum + Next_Term;
-- Sum can overflow to infinity? Not with our scaled arguments.
end loop;
-- STEP 4. Undo effect of 2nd stage of argument scaling. Recall we
-- divided the arg by 2**J, and found Exp(X_Scaled/2**J). Now to get
-- Exp(X_Scaled), must take Exp(X_Scaled/2**J)**2**J, which means
-- repeated squaring of Exp(X_Scaled/2**J) (J times). It's more complicated
-- than that because we calculated G(X) = Exp(X) - 1 - X (since G contains
-- more correct digits than Exp, expecially for small X.) So we
-- use G(2X) = Exp(2X) - 1 - 2X = (G + (1 + X))*(G + (1 + X)) - 1 - 2X
-- = G*G + 2*G*(1+X) + X*X
-- G(2X) = (G(X)+X)**2 + 2G(X).
-- G(4X) = (G(2X)+2X)**2 + 2G(2X).
-- Repeat J times to unscale G. The following also returns X_scaled*2**J.
if Second_Stage_Scaling_Performed then
for I in 1..J loop
Sum := (Sum + X_scaled_2)**2 + Two_Digit * Sum;
X_Scaled_2 := Two_Digit * X_Scaled_2;
end loop;
end if;
-- DO the following whether or not Second_Stage or First_Stage
-- scaling was performed (because the series sum neglected the
-- the 1 and the X. If there were no extra guard digit for
-- subtraction ((X_scaled_1 + Sum) is negative) then it would be best
-- to use (0.5 + (Sum + Xscaled)) + 0.5. Following is OK though to
-- get a number slightly less than one with full precision.
-- Recover Exp = G(X) + 1 + X = Sum + 1 + X = (Sum + X_scaled) + 1:
Sum := (Sum + X_scaled_1) + One;
-- Second stage unscaling. We now have Y = Exp(-|X_scaled_1|), which is
-- slightly less than 1.0. Keep
-- in Y < 1.0 form as we unscale: might preserve more precision that
-- way, cause we lose much precision if invert a number that's slightly
-- less than one.
if First_Stage_Scaling_Performed then
if We_Flipped_The_Sign_Of_X_scaled then
Sum := Sum * Two**(-N);
else
Sum := Sum * Two**(N);
end if;
end if;
if We_Flipped_The_Sign_Of_X_scaled then
Sum := Reciprocal (Sum);
-- X_scaled was positive. We flipped its sign so must invert the result.
end if;
return Sum;
end Exp;
---------------------------
-- Sin (arbitrary cycle) --
---------------------------
-- The exception E_Argument_Error is raised, signaling a parameter
-- value outside the domain of the corresponding mathematical function,
-- in the following cases:
-- by any forward or inverse trigonometric function with specified
-- cycle, when the value of the parameter Cycle is zero or negative;
-- The results of the Sin, Cos, Tan, and Cot functions with
-- specified cycle are exact when the mathematical result is zero;
-- those of the first two are also exact when the mathematical
-- result is +/-1.0.
function Sin
(X : e_Real;
Cycle : e_Real)
return e_Real
is
Fraction_Of_Cycle, Result : e_Real;
begin
-- The input parameter X is units of Cycle. For example X = Cycle
-- is same as X = 2Pi, so could call Sin (2 * Pi * X / Cycle), but we
-- want to apply the remainder function here to directly meet certain
-- requirements on returning exact results.
-- Recall: Remainder = X - Round (X/Cycle) * Cycle = X - N * Cycle
-- which is in the range -Cycle/2 .. Cycle/2. The formula will be
--
-- Sin (X, Cycle) = Sin (2 * Pi * X / Cycle)
-- = Sin (2 * Pi * (X - N * Cycle) / Cycle)
-- = Sin (2 * Pi * Remainder(X,Cycle) / Cycle)
if Are_Equal (Cycle, Zero) then
raise E_Argument_Error;
end if;
if Cycle < Zero then
raise E_Argument_Error;
end if;
Fraction_Of_Cycle := Remainder (X, Cycle) / Cycle;
if Are_Equal (Fraction_Of_Cycle, Zero) then
return Zero;
end if;
if Are_Equal (Abs (Fraction_Of_Cycle), Half) then
return Zero;
end if;
if Are_Equal (Fraction_Of_Cycle, Make_Extended(0.25)) then
return One;
end if;
if Are_Equal (Fraction_Of_Cycle, Make_Extended(-0.25)) then
return -One;
end if;
Result := Sin (Make_E_Digit(8.0) * (e_Quarter_Pi * Fraction_Of_Cycle));
-- Pi/4 is used instead of Pi/2, because it contains more correct
-- binary digits.
return Result;
end Sin;
---------
-- Sin --
---------
-- Sum Taylor series for Sin (X).
--
-- Max argument is at present set by requirement:
-- Exponent(X) < Present_Precision-1
function Sin
(X : e_Real)
return e_Real
is
Half_Sqrt_Of_Radix : constant Real := 2.0**(Desired_No_Of_Bits_in_Radix/2-1);
Order : Real := 0.0;
Delta_Exponent : E_Integer := 0;
Next_Term, Sum : e_Real;
X_Scaled_1, X_Scaled_2, X_Scaled_2_Squared : e_Real;
Total_Digits_To_Use : E_Integer;
N_e_Real, Half_N : e_Real;
J : constant Integer := 8;
Three_To_The_J : constant E_Digit := Make_E_Digit (3.0**J);
Factorial_Part : E_Digit;
Sign_Of_Term_Is_Pos : Boolean := True;
Arg_Is_Negative : Boolean := False;
N_Is_Odd : Boolean := False;
First_Stage_Scaling_Performed : Boolean := False;
Second_Stage_Scaling_Performed : Boolean := False;
begin
if Are_Equal (X, Zero) then
return Zero;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
Arg_Is_Negative := False;
if X < Zero then
Arg_Is_Negative := True;
end if;
if Exponent(X) >= e_Real_Machine_Mantissa-1 then
raise E_Argument_Error;
end if;
-- Can't figure out N below. N_e_Real has to be
-- integer valued: 0, 1, ... 2**(Radix*e_Real_Machine_Mantissa) - 1
-- This determines Max allowed Argument.
-- If Exponent(N_e_Real) is too large, then can't tell if N is even or odd.
-- STEP 1. First argument reduction: Get modulo Pi by Remainder(X, Pi).
-- Get X in range -Pi/2..Pi/2.
-- X_scaled_1 := X - N_e_Real * e_Pi;
if Less_Than_Half_Pi < Abs(X) then
X_scaled_1 := Remainder (Abs(X), e_Pi);
N_e_Real := Unbiased_Rounding ((Abs(X)-X_scaled_1) * e_Inverse_Pi);
First_Stage_Scaling_Performed := True;
else
X_Scaled_1 := Abs(X);
N_e_Real := Zero;
First_Stage_Scaling_Performed := False;
end if;
-- Need to know if N is even or odd. N is Positive.
-- If Exponent(N_e_Real) is too large, then we can't tell if N is even or
-- odd. So raise Arg error. This determines Max Arg.
N_Is_Odd := False;
if not Are_Equal (N_e_Real, Zero) then
Half_N := Half_Digit * N_e_Real;
if Truncation (Half_N) < Half_N then
N_Is_Odd := True;
end if;
end if;
-- STEP 2. Second stage of argument reduction. Divide by 3**5 = 243
-- to get Arg less than about 0.01?. Call this 3**J in what follows.
-- Later we recursively use J repetitions of the formula
-- Sin(3*Theta) = Sin(Theta)*(3 - 4*Sin(Theta)**2), to get Sin(Theta*3**J)
-- Cos(3*Theta) = -Cos(Theta)*(3 - 4*Cos(Theta)**2), to get Cos(Theta*3**J)
-- to get Sin (Original_Arg).
--
-- MUST avoid underflow to Zero in this step. So only if X_Scaled is big.
-- Actually, X_scaled = 0 may pass through, but it's OK to start out 0.
if Exponent (X_Scaled_1) >= -2 then -- it'll do
X_Scaled_2 := X_scaled_1 / Three_To_The_J;
Second_Stage_Scaling_Performed := True;
else
X_Scaled_2 := X_scaled_1;
Second_Stage_Scaling_Performed := False;
end if;
-- STEP 3. Start the sum. Terms are labeled Order = 1, 2, 3
-- but the series is X - X**3/3! + X**5/5! + ...+- X**(2*Order-1)/(2*Order-1)!.
-- Summed G(X) = Sin(X) - X, which contains more correct digits at
-- the end. We need these extra digits when we unscale the result.
X_Scaled_2_Squared := X_scaled_2 * X_Scaled_2;
Order := 2.0;
Sign_Of_Term_Is_Pos := False;
Next_Term := X_Scaled_2 * X_Scaled_2_Squared / Make_E_Digit (6.0);
Sum := -Next_Term;
-- Above we make the 1st term in G, and begin the sum.
loop
Sign_Of_Term_Is_Pos := not Sign_Of_Term_Is_Pos;
Order := Order + 1.0;
-- Can't make Factorial part if, roughly, 2*Order-1.0 > Radix-1,
-- Because max argument of Make_E_Digit is Radix-1.
if Order >= Radix / 2.0 then
raise E_Argument_Error with "Too many terms needed in Exp taylor sum.";
end if;
-- Use relative Eponents of Sum and Next_Term to check convergence
-- of the sum. Exponent doesn't work for args of 0, so check.
-- Abs (Next_Term) <= Abs (Sum), so we need only check Next_Term.
if Are_Equal (Next_Term, Zero) then exit; end if;
Delta_Exponent := Exponent (Sum) - Exponent (Next_Term);
Total_Digits_To_Use := e_Real_Machine_Mantissa - Delta_Exponent + 1;
exit when Total_Digits_To_Use <= 0;
if Order < Half_Sqrt_Of_Radix then
Factorial_Part := Make_E_Digit ((2.0*Order-1.0)*(2.0*Order-2.0));
Next_Term := (X_Scaled_2_Squared * Next_Term) / Factorial_Part;
else
Factorial_Part := Make_E_Digit ((2.0*Order-1.0));
Next_Term := (X_Scaled_2_Squared * Next_Term) / Factorial_Part;
Factorial_Part := Make_E_Digit ((2.0*Order-2.0));
Next_Term := Next_Term / Factorial_Part;
end if;
if Sign_Of_Term_Is_Pos then
Sum := Sum + Next_Term;
else
Sum := Sum - Next_Term;
end if;
end loop;
-- STEP 4. Scale the result iteratively. Recall we divided the arg by 3**J,
-- so we recursively use J repetitions of the formula
-- Sin(3*X) = Sin(X)*(3 - 4*Sin(X)**2), to get Sin(X*3**J).
-- Actually, we summed G(X) = Sin(X) - X. So the formula for G(X) is
-- G(3X) = S(3X) - 3X = S(X)*(3 - 4S(X)**2) - 3X,
-- = (G+X)*(3 - 4(G+X)**2) - 3X,
-- = 3G - 4(G+X)**3, (Cancel out the 3X),
-- G(3X) = 3G(X) - 4(G(X)+X)**3.
-- G(9X) = 3G(3X) - 4(G(3X)+3X)**3, etc.
-- Still requires only 2 (full) mults per loop, just like the original formula.
-- Notice below that we output X_scaled * 3**J, which is required next step.
if Second_Stage_Scaling_Performed then
for I in 1..J loop
Sum := Three_Digit * Sum - Four_Digit * (Sum + X_scaled_2)**3;
X_scaled_2 := Three_Digit * X_scaled_2;
end loop;
end if;
-- STEP 5. We have Sin(X - N * Pi). Want Sin(X). If N is odd, then
-- flip sign of Sum. Next, flip sign again if the
-- original argument is neg: Arg_Is_Negative = True.
-- Remember, we summed for Sum = G = Sin - X, whether or not scaling
-- was performed. (X is called X_scaled, no matter what.)
-- So we recover Sin = G + X
Sum := Sum + X_scaled_1;
if First_Stage_Scaling_Performed then
if N_Is_Odd then
Sum := -Sum;
end if;
end if;
if Arg_Is_Negative then
Sum := -Sum;
end if;
return Sum;
end Sin;
---------------------------
-- Cos (arbitrary cycle) --
---------------------------
-- The exception E_Argument_Error is raised, signaling a parameter
-- value outside the domain of the corresponding mathematical function,
-- in the following cases:
-- by any forward or inverse trigonometric function with specified
-- cycle, when the value of the parameter Cycle is zero or negative;
-- The results of the Sin, Cos, Tan, and Cot functions with
-- specified cycle are exact when the mathematical result is zero;
-- those of the first two are also exact when the mathematical
-- result is +/-1.0.
--
function Cos (X : e_Real; Cycle : e_Real) return e_Real is
Fraction_Of_Cycle, Result : e_Real;
begin
-- The input parameter X is units of Cycle. For example X = Cycle
-- is same as X = 2Pi, so could use Cos (2 * Pi * X / Cycle), but we
-- want to apply the remainder function here to directly meet certain
-- requirements on returning exact results.
-- Recall: Remainder = X - Round (X/Cycle) * Cycle = X - N * Cycle
-- which is in the range -Cycle/2 .. Cycle/2. The formula will be
--
-- Cos (X, Cycle) = Cos (2 * Pi * X / Cycle)
-- = Cos (2 * Pi * (X - N * Cycle) / Cycle)
-- = Cos (2 * Pi * Remainder(X,Cycle) / Cycle)
if Are_Equal (Cycle, Zero) then
raise E_Argument_Error;
end if;
if Cycle < Zero then
raise E_Argument_Error;
end if;
-- Now get twice the fraction of the cycle, and handle special cases:
Fraction_Of_Cycle := Remainder (X, Cycle) / Cycle;
if Are_Equal (Fraction_Of_Cycle, Zero) then
return One;
end if;
if Are_Equal (Abs (Fraction_Of_Cycle), Half) then
return -One;
end if;
if Are_Equal (Abs (Fraction_Of_Cycle), Make_Extended(0.25)) then
return Zero;
end if;
Result := Cos (Make_E_Digit(8.0) * (e_Quarter_Pi * Fraction_Of_Cycle));
-- Use Pi/4 becase it contains more correct binary digits than Pi.
return Result;
end Cos;
---------
-- Cos --
---------
-- Sum Taylor series for Cos (X). Actually sum series for G = Cos(X) - 1.
-- Reason is, G contains more correct digits than Cos, which is
-- required when we undo effects of argument reduction.
-- Max argument is at present
-- set by requirement: Exponent(X) < Present_Precision-1
--
function Cos
(X : e_Real)
return e_Real
is
Half_Sqrt_Of_Radix : constant Real := 2.0**(Desired_No_Of_Bits_in_Radix/2-1);
Order : Real := 0.0;
Delta_Exponent : E_Integer := 0;
Next_Term, Sum, Sum_2, Sum_3 : e_Real;
X_Scaled_1, X_Scaled_Squared : e_Real;
Total_Digits_To_Use : E_Integer;
N_e_Real, Half_N : e_Real;
J : constant Integer := 8;
Three_To_The_J : constant E_Digit := Make_E_Digit (3.0**J);
Factorial_Part : E_Digit;
Sign_Of_Term_Is_Pos : Boolean := True;
N_Is_Odd : Boolean := False;
First_Stage_Scaling_Performed : Boolean := False;
Second_Stage_Scaling_Performed : Boolean := False;
begin
if Are_Equal (X, Zero) then
return One;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
if Exponent(X) >= e_Real_Machine_Mantissa-1 then
raise E_Argument_Error;
end if;
-- Can't figure out N below. N_e_Real has to be
-- integer valued: 0, 1, ... 2**(Radix*e_Real_Machine_Mantissa) - 1
-- This determines Max allowed Argument.
-- STEP 1. First stage argument reduction.
-- Take X modulo Pi by Remainder(X, Pi). Get X in range -Pi/2..Pi/2.
-- X_scaled_1 := X - N_e_Real * e_Pi;
if Less_Than_Half_Pi < Abs(X) then
X_scaled_1 := Remainder (Abs(X), e_Pi);
N_e_Real := Unbiased_Rounding ((Abs(X)-X_scaled_1) * e_Inverse_Pi);
First_Stage_Scaling_Performed := True;
else
X_Scaled_1 := Abs(X);
N_e_Real := Zero;
First_Stage_Scaling_Performed := False;
end if;
-- Need to know if N is even or odd. N is Positive.
N_Is_Odd := False;
if not Are_Equal (N_e_Real, Zero) then
Half_N := Half_Digit * N_e_Real;
if Truncation (Half_N) < Half_N then
N_Is_Odd := True;
end if;
end if;
-- STEP 1b. If X_Scaled is nearing Pi/2 then it's too big for Taylor's.
-- Must call Sin (Pi/2 - X_Scaled). IMPORTANT: only do this for
-- X_scaled > Pi/6, because Arcsin(X => 0.5) = Pi/6 is used to calculate
-- Pi, and would get infinite recursive calls when Arcsin calls Cos
-- which calls Sin, while Sin and Cos call e_Quarter_Pi, which
-- calls Arcsin. e_Quarter_Pi is used instead of the less accurate Pi/2.
if One < X_Scaled_1 then
Sum := Sin ((e_Quarter_Pi - X_Scaled_1) + e_Quarter_Pi);
if N_Is_Odd then
Sum := -Sum;
end if;
return Sum;
end if;
-- STEP 2. Second stage of argument reduction. Divide by 3**8 = 81*81
-- to get argument less than about .02. Call this 3**J in what follows.
-- Later we recursively use J repetitions of the formula
-- Sin(3*Theta) = Sin(Theta)*(3 - 4*Sin(Theta)**2), to get Sin(Theta*3**J)
-- Cos(3*Theta) = -Cos(Theta)*(3 - 4*Cos(Theta)**2), to get Cos(Theta*3**J).
--
-- It's OK if X_scaled is 0 at this point, but not if the following
-- forces it to underflow to 0. Therefore only scale large args:
if Exponent (X_Scaled_1) >= -2 then -- it'll do
X_Scaled_1 := X_scaled_1 / Three_To_The_J;
Second_Stage_Scaling_Performed := True;
else
Second_Stage_Scaling_Performed := False;
end if;
-- STEP 3. Start the sum. Terms are labeled Order = 0, 1, 2, 3
-- but the series is 1 - X**2/2! + X**4/4! + ...+- X**(2*Order)/(2*Order)!.
-- Below we actually calculate Cos(X) - 1.
-- Start summing the series at order 1 instead of order 0.
Order := 1.0;
X_Scaled_Squared := X_scaled_1 * X_Scaled_1;
Next_Term := Half_Digit * X_Scaled_Squared;
Sum := -Next_Term;
Sign_Of_Term_Is_Pos := False;
loop
Sign_Of_Term_Is_Pos := not Sign_Of_Term_Is_Pos;
Order := Order + 1.0;
-- Can't make Factorial part if, roughly, 2*Order > Radix-1.
if Order >= (Radix-1.0) / 2.0 then
raise E_Argument_Error with "Too many terms needed in Exp taylor sum.";
end if;
-- Use relative Eponents of Sum and Next_Term to check convergence
-- of the sum. Exponent doesn't work for args of 0, so check.
-- Abs (Next_Term) <= Abs (Sum), so we need only check Next_Term.
-- If Next_Term is 0, we are finished anyway.
if Are_Equal (Next_Term, Zero) then exit; end if;
Delta_Exponent := Exponent (Sum) - Exponent (Next_Term);
Total_Digits_To_Use := e_Real_Machine_Mantissa - Delta_Exponent + 1;
exit when Total_Digits_To_Use <= 0;
if Order < Half_Sqrt_Of_Radix then
Factorial_Part := Make_E_Digit ((2.0*Order)*(2.0*Order-1.0));
Next_Term := (X_Scaled_Squared * Next_Term) / Factorial_Part;
else -- Do it the slow way. (Should rarely happen.)
Factorial_Part := Make_E_Digit (2.0*Order);
Next_Term := (X_Scaled_Squared * Next_Term) / Factorial_Part;
Factorial_Part := Make_E_Digit (2.0*Order-1.0);
Next_Term := Next_Term / Factorial_Part;
end if;
if Sign_Of_Term_Is_Pos then
Sum := Sum + Next_Term;
else
Sum := Sum - Next_Term;
end if;
end loop;
-- STEP 4. Scale the result iteratively. Recall we got Cos(Arg/3**J). Now
-- we want Cos(Arg). So we use J repetitions of the formula
-- Cos(3*Theta) = -Cos(Theta)*(3 - 4*Cos(Theta)**2), to get Cos(Theta*3**J).
-- Recall we summed for Cos(X) - 1, because we retain more correct digits
-- this way for small X. (The 1 would have shifted correct digits off the
-- array.) So we actually have is Sum = G(X) = Cos(X) - 1. So the formula
-- for Cos(3X) is (1+G)*(4(G+1)**2 - 3) = (1+G)*(1 + 8G + 4G**2). Then
-- G(3X) = Cos(3X) - 1 = 9G + 12G*2 + 4G**3. Next, unscale G:
if Second_Stage_Scaling_Performed then
for I in 1..J loop
--Sum := Sum * (Four_Digit * Sum * Sum - Three);
Sum_2 := Sum*Sum;
Sum_3 := Sum*Sum_2;
Sum := Nine_Digit * Sum + Twelve_Digit * Sum_2 + Four_Digit * Sum_3;
end loop;
end if;
-- STEP 5. We have Cos(X - N * Pi). Want Cos(X). If N is odd, then
-- flip sign of Sum. First remember we summed for G = Cos - 1, whether or
-- not scaling was performed. Must recover Cos next:
Sum := Sum + One; -- Get Cos(X) = G(X) + 1 = Sum + 1.
if First_Stage_Scaling_Performed then
if N_Is_Odd then
Sum := -Sum;
end if;
end if;
return Sum;
end Cos;
-------------------------
-- Reciprocal_Nth_Root --
-------------------------
-- Uses Newton's method to get A**(-1/N):
-- Y_k+1 = Y_k + (1 - A * Y_k**N) * Y_k / N.
-- Requires call to log(A) and assumes that this call gets
-- the first two radix digits correct: 48 bits usually. (It almost
-- always gets more correct.)
-- REMEMBER, this calculates to the max possible precision;
-- Does not reflect dynamic precision floating point.
-- N must be less than Radix - 1, which is usually 2**24 - 1.
function Reciprocal_Nth_Root
(X : e_Real;
N : Positive)
return e_Real is
Exponent_Of_X, Scaled_Exp_Of_X, Exp_Mod_N : E_Integer;
Result, X_Fraction, Scaled_X_Fraction, Y_0 : e_Real;
Shift_Sign, Ratio : Real := 0.0;
Log_Of_Scaled_X_Fraction, Real_X_Fraction : Real := 0.0;
No_Correct_Bits : E_Integer;
E_Digit_N, Inverse_E_Digit_N : E_Digit; -- already initialized
Optimization_Is_Possible : Boolean := False;
begin
if Are_Equal (X, Zero) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
if Real(N) > (Radix-1.0) then
raise E_Argument_Error;
end if;
-- STEP 0b. An optimization. If N is a power of two, we can speed
-- up the calculation by multiplying by 1/N rather than dividing by
-- N in the newton iteration.
Optimization_Is_Possible := False;
for I in 0..Desired_No_Of_Bits_In_Radix-2 loop
if 2**I = N then
Optimization_Is_Possible := True;
end if;
end loop;
if Optimization_Is_Possible then
Inverse_E_Digit_N := Make_E_Digit (1.0 / Real(N));
else
E_Digit_N := Make_E_Digit (Real(N));
end if;
-- STEP 1. Argument reduction. Break X into Fraction and Exponent.
-- Choose to decrement Abs(Exponent) by (Exponent MOD N),
-- and multiply fraction by Radix ** (Exponent MOD N).
-- The reason is of course, we want to divide decremented Exponent by N,
-- so we want Scaled_Exp_Of_X to be an integral multiple of -N.
Exponent_Of_X := Exponent (X); -- What if X is 0, inf, etc???
X_Fraction := Fraction (X);
Exp_Mod_N := Abs (Exponent_Of_X) MOD E_Integer(N); -- N never < 1.
-- Make sure that Scaled_Exp_Of_X is in range of e_Real, and also
-- make sure that it is scaled to an integral multiple of N.
if Exponent_Of_X < 0 then
Scaled_Exp_Of_X := Exponent_Of_X + Exp_Mod_N;
Shift_Sign := +1.0;
else
Scaled_Exp_Of_X := Exponent_Of_X - Exp_Mod_N;
Shift_Sign := -1.0;
end if;
-- Scale the fraction to compensate for the above shift in the Exponent:
if Exponent_Of_X < 0 then
Scaled_X_Fraction := Scaling (X_Fraction, - Exp_Mod_N);
else
Scaled_X_Fraction := Scaling (X_Fraction, + Exp_Mod_N);
end if;
-- STEP 2. Get starting value for Newton's iteration.
-- Want Real number estimate of Scaled_X_Fraction**(-1/N).
-- Get the first 2 radix digits correct (48 bits usually), and call it Y_0.
-- Must worry about exponents too large for type Real in the value
-- Scaled_X_Fraction prior to the **(-1/N) operation, so we do it indirectly.
-- Arg ** (-1/N): use exp (log (Arg**(-1/N))) = exp ( (-1/N)*log (Arg) ).
-- Need estimate: [ X_Fraction * Radix**(-Shift_Sign * Exp_Mod_N) ]**(-1/N).
-- First want natural Log(X_Fraction * Radix**(-Shift_Sign * Exp_Mod_N))
-- which equals Log(X_Fraction) - Shift_Sign * Log(Radix) * Exp_Mod_N.
-- Next divide this quantity by -N, and take exp():
-- Exp (-Log (X_Fraction) / N + Shift_Sign * Log(Radix) * Exp_Mod_N / N).
-- This is the estimate we want, and because Exp_Mod_N / N is always
-- < 1.0, the arguments should be well within range of Log and Exp,
-- because Exp (Shift_Sign * Log(Radix) * Exp_Mod_N / N) is less than Radix.
Real_X_Fraction := Make_Real (X_Fraction);
Ratio := Real (Exp_Mod_N) / Real(N);
Log_Of_Scaled_X_Fraction
:= -Log (Real_X_Fraction) / Real(N) + Shift_Sign * Ratio * Log (Radix);
Y_0 := Make_Extended (Exp (Log_Of_Scaled_X_Fraction));
-- Starting val in Newton's iteration.
-- STEP 3. Start the iteration. Calculate the number of iterations
-- required as follows. num correct digits doubles each iteration.
-- 1st iteration gives 4 digits, etc. Each step set desired precision
-- to one digit more than that we expect from the Iteration.
--
-- It is important to remember that e_Real_Machine_Mantissa includes
-- the 1 or 2 guard digits. The last of these may have a lot of error in
-- the end, the first of these may have some error. That's why they're
-- there. Also remember that when Set_No_Of_Digits_To_Use is
-- called, the precision it sets includes the 2 guard digits, both
-- of which may be wrong, so we add 2 to the setting below, just
-- in case.
No_Correct_Bits := Real'Machine_Mantissa - 2;
loop
if Optimization_Is_Possible then -- multiply by inverse of N:
Y_0 := Y_0 + Inverse_E_Digit_N * ((One - Scaled_X_Fraction * Y_0**N) * Y_0);
else -- divide by N:
Y_0 := Y_0 + (One - Scaled_X_Fraction * Y_0**N) * Y_0 / E_Digit_N;
end if;
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits > Max_Available_Bits;
end loop;
Result := Scaling (Y_0, (-Scaled_Exp_Of_X) / E_Integer (N));
-- Product of Y_0 = Scaled_X_Fraction**(-1/N) with
-- Radix**(-Scaled_Exponent(X) / N) equals X**(-1/N).
return Result;
end Reciprocal_Nth_Root;
------------
-- Divide --
------------
-- Uses Newton's method: Y_k+1 = Y_k + (1 - A*Y_k) * Y_k to get Z / A.
-- Requires call to 1 / Make_Real(A).
function Divide (Z, X : e_Real)
return e_Real
is
Exponent_Of_X : E_Integer;
Result, X_Fraction, Y_0 : e_Real;
No_Correct_Bits : E_Integer;
begin
if Are_Equal (X, Zero) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Positive_Infinity) then -- like underflow
return Zero;
end if;
if Are_Equal (X, Negative_Infinity) then -- like underflow
return Zero;
end if;
-- Argument reduction. Break X into Fraction and Exponent.
-- Iterate to get inverse of fraction. Negate to get inverse of Exp.
Exponent_Of_X := Exponent (X);
X_Fraction := Fraction (X);
-- Get the first 2 radix digits correct (48 bits usually). Remember that the
-- Newton's iteration here produces 1/(X_Fraction). The result will be
-- the product of the newton's iteration and Radix to the power Exp_Scale_Val.
Y_0 := Make_Extended (1.0 / Make_Real (X_Fraction));
-- Starting val in Newton's iteration.
No_Correct_Bits := Real'Machine_Mantissa - 2;
-- Iterate:
loop
--Y_0:= Y_0 *(Two_Digit + (-X_Fraction) * Y_0); -- faster, much less accurate
Mult (Y_0, (Two - X_Fraction * Y_0)); -- faster, much less accurate
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits >= Max_Available_Bits / 2 + 1;
-- final correction is outside the loop.
end loop;
Result := Z * Y_0; -- Z / X
Result := Result + (Z - X_Fraction * Result) * Y_0; --bst so far
-- Y_0 := Y_0 + (One - X_Fraction * Y_0) * Y_0;
-- The iteration for Y_0 is the final step for 1/X. Multiplied by Z to get Result.
Result := Scaling (Result, -Exponent_Of_X);
-- Product of 1/Fraction(X) with Radix**(-Exponent(X)) equals 1/X.
return Result;
end Divide;
----------------
-- Reciprocal --
----------------
-- Uses Newton's method: Y_k+1 = Y_k + (1 - A*Y_k) * Y_k to get 1 / A.
function Reciprocal (X : e_Real)
return e_Real
is
Exponent_Of_X : E_Integer;
Result, X_Fraction, Y_0 : e_Real;
No_Correct_Bits : E_Integer;
begin
if Are_Equal (X, Zero) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Positive_Infinity) then -- like underflow
return Zero;
end if;
if Are_Equal (X, Negative_Infinity) then -- like underflow
return Zero;
end if;
-- Argument reduction. Break X into Fraction and Exponent.
-- Iterate to get inverse of fraction. Negate to get inverse of Exp.
Exponent_Of_X := Exponent (X);
X_Fraction := Fraction (X);
-- Newton's iteration here produces 1/(X_Fraction). Final result will be
-- the product of the newton's iteration and Radix to the power Exp_Scale_Val.
Y_0 := Make_Extended (1.0 / Make_Real (X_Fraction));
-- Starting val in Newton's iteration.
No_Correct_Bits := Real'Machine_Mantissa - 2;
-- Iterate:
loop
--Y_0:= Y_0 *(Two_Digit + (-X_Fraction) * Y_0); -- faster, much less accurate
Mult (Y_0, (Two - X_Fraction * Y_0)); -- faster, much less accurate
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits > Max_Available_Bits / 2 + 1;
-- final correction is below.
end loop;
Y_0 := Y_0 + (One - X_Fraction * Y_0) * Y_0; -- accurate final step.
Result := Scaling (Y_0, -Exponent_Of_X);
-- Product of 1/Fraction(X) with Radix**(-Exponent(X)) equals 1/X.
return Result;
end Reciprocal;
---------------------
-- Reciprocal_Sqrt --
---------------------
-- Uses Newton's method: Y_k+1 = Y_k + (1 - A*Y_k**2) * Y_k / 2
-- to get 1 / sqrt(A). Multiply by A to get desired result; then refine.
function Reciprocal_Sqrt (X : e_Real)
return e_Real
is
Result : e_Real;
X_scaled, Y_0 : e_Real;
Exp_Scale_Val : E_Integer;
No_Correct_Bits : E_Integer;
begin
if X < Zero then
raise E_Argument_Error;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Zero) then
raise E_Argument_Error;
end if;
-- Break X into Fraction and Exponent. If Exponent is
-- odd then add or subtract 1. (Increase X if X < 1, decrease otherwise.)
-- Only important thing is scale X
-- down to somewhere near 1, and to scale X by an even power of Radix.
-- We break X up because the Newton's method works better on X_scaled than
-- than on X in general. Also we use Sqrt(Make_Real(X_scaled)) to start
-- things off for Newton's method, so we want X_scaled in range of Sqrt(Real).
Exp_Scale_Val := Exponent (X); -- what if X is 0, inf, etc..???
-- Exp is odd. Make it even, but keep things in range of e_Real:
if Abs (Exp_Scale_Val) mod 2 /= 0 then
if Exp_Scale_Val < 0 then
Exp_Scale_Val := Exp_Scale_Val + 1;
else
Exp_Scale_Val := Exp_Scale_Val - 1;
end if;
end if;
X_scaled := Scaling (X, -Exp_Scale_Val);
-- Take Sqrt by dividing the even Exp_Scale_Val by 2, and by taking
-- the SQRT of X_scaled. Start the iteration off with a call to SQRT
-- in the standard library for type Real.
Exp_Scale_Val := Exp_Scale_Val / 2;
Y_0 := Make_Extended (Sqrt (1.0 / Make_Real (X_scaled)));
-- Starting val in Newton's iteration.
No_Correct_Bits := Real'Machine_Mantissa - 2;
loop
--Y_0:= Y_0 + Half_Digit * ((One - X_scaled * (Y_0 * Y_0)) * Y_0);
--Y_0:= Y_0*(Half_Digit * (Three - X_scaled * (Y_0 * Y_0))); --inaccurate
Mult (Y_0, Half_Digit * (Three - X_scaled * (Y_0 * Y_0)));
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits > Max_Available_Bits / 2 + 1;
-- final correction is below.
end loop;
-- both work:
--Y_0 := Y_0 + Half_Digit * ((One - X_scaled * (Y_0 * Y_0)) * Y_0);
Y_0 := Y_0 - Half_Digit * (X_scaled * (Y_0 * Y_0) - One) * Y_0;
Result := Scaling (Y_0, -Exp_Scale_Val);
return Result;
end Reciprocal_Sqrt;
----------
-- Sqrt --
----------
-- Uses Newton's method: Y_k+1 = Y_k + (1 - A*Y_k**2) * Y_k / 2
-- to get 1 / sqrt(A). Multiply by A to get desired result; then refine.
-- Requires call to Sqrt(Real) and assumes that this call gets
-- the first radix digit correct. (It almost
-- always gets 53 bits correct.)
function Sqrt (X : e_Real)
return e_Real
is
Result, X_scaled, Y_0 : e_Real;
Exp_Scale_Val : E_Integer;
No_Correct_Bits : E_Integer;
begin
if X < Zero then
raise E_Argument_Error;
end if;
if Are_Equal (X, Positive_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Negative_Infinity) then
raise E_Argument_Error;
end if;
if Are_Equal (X, Zero) then
return Zero;
end if;
--if Are_Equal (X, One) then -- Ada9X.
--return One;
--end if;
-- Break X into Fraction and Exponent. If Exponent is
-- odd then add or subtract 1. (Increase X if X < 1, decrease otherwise.)
-- Only important thing is scale X
-- down to somewhere near 1, and to scale X by an even power of Radix.
-- We break X up because the Newton's method works better on X_scaled than
-- than on X in general. Also we use Sqrt(Make_Real(X_scaled)) to start
-- things off for Newton's method, so we want X_scaled in range of Sqrt(Real).
Exp_Scale_Val := Exponent (X); -- what if X is 0, inf, etc..???
-- This Exp is powers of Radix = 2**30 or 2**29.
-- Exp is odd. Make it even, but keep things in range of e_Real:
if Abs (Exp_Scale_Val) mod 2 /= 0 then
if Exp_Scale_Val < 0 then
Exp_Scale_Val := Exp_Scale_Val + 1;
else
Exp_Scale_Val := Exp_Scale_Val - 1;
end if;
end if;
X_scaled := Scaling (X, -Exp_Scale_Val);
Exp_Scale_Val := Exp_Scale_Val / 2;
Y_0 := Make_Extended (Sqrt (1.0 / Make_Real (X_scaled)));
-- Starting val in Newton's iteration.
No_Correct_Bits := Real'Machine_Mantissa - 2;
loop
--Y_0:= Y_0 + Half_Digit * ((One - X_scaled * Y_0 * Y_0) * Y_0);
--Y_0:= Y_0*(Half_Digit * (Three - X_scaled * Y_0 * Y_0)); --inaccurate
Mult (Y_0, Half_Digit * (Three - X_scaled * Y_0 * Y_0));
No_Correct_Bits := No_Correct_Bits * 2;
exit when No_Correct_Bits > Max_Available_Bits / 2 + 1;
-- Have the final correction outside the loop.
end loop;
Result := Y_0 * X_scaled; -- now it's SQRT(X_scaled); Y_0 = 1/SQRT(X_scaled)
Result := Result + Half_Digit * (X_scaled - Result*Result) * Y_0; --important
Result := Scaling (Result, Exp_Scale_Val); -- equals SQRT(X).
return Result;
end Sqrt;
-------------
-- Make_Pi --
-------------
-- This is an important independent test of Arcsin (hence Sin and Arcos).
-- Once we verify that Arcsin (hence Sin) is correct, can test other
-- arguments with (eg) Sin (A + B) = etc.
-- Has much greater error than 4*Arcsin(1/Sqrt(2)).
-- Need Pi to full precision for the trigonometic functions.
-- Here is the Salamin-Brent algorithm.
-- A_0 = 1.0, B_0 = 1.0/Sqrt(2.0), and D_0 = Sqrt(2.0) - 0.5.
--
-- A_k = (A_{k-1} + B_{k-1}) / 2
-- B_k = Sqrt (A_{k-1} * B_{k-1})
-- D_k = D_{k-1} - 2**k * (A_k - B_k)**2
--
-- Then P_k = (A_k + B_k)**2 / D_k converges quadratically to
-- Pi. All steps must be done at full precision.
--
-- function Make_Pi return e_Real is
-- A_0, B_0, D_0 : e_Real;
-- A_1, B_1, D_1 : e_Real;
-- C, Result : e_Real;
-- Two_To_The_k : E_Digit;
-- Two_To_The_20 : constant E_Digit := Make_E_Digit (2.0**20);
-- We_Are_Finished : Boolean := False;
-- No_Of_Correct_Digits : E_Integer;
-- Old_Precision : constant E_Integer := Present_Precision;
-- begin
--
-- A_0 := One;
-- B_0 := E_Inverse_Sqrt_2;
-- D_0 := Two * E_Inverse_Sqrt_2 - Half;
-- -- this give Pi_0 = 3.1877, or error of about 1.47 %. This is smaller
-- -- 1 part in 64, so 6 bits correct. There follows (k=1) 12, (k=2) 24.
-- -- So requires two more iterations to get one digit, 3 to get 2
-- -- digits. Seems to work better than this estimate.
--
-- No_Of_Correct_Digits := 1;
--
-- -- The following loop should get us up to half a million digits. In
-- -- the unlikely case you need more, then another loop follows.
-- -- k in 1..7 gives you 33 Radix 2**24 digits.
--
-- for k in 1..20 loop
--
-- Two_To_The_k := Make_E_Digit (2.0**k);
--
-- A_1 := Half_Digit * (A_0 + B_0);
-- B_1 := Sqrt (A_0 * B_0);
-- C := (A_1 - B_1);
-- D_1 := D_0 - Two_To_The_k * (C * C);
--
-- if k >= 3 then
-- -- We did 3rd iteration to get 2 correct digits.
-- -- No_Correct.. was initialized to 1.
-- No_Of_Correct_Digits := No_Of_Correct_Digits * 2;
-- end if;
-- -- Should be OK overflow-wise here. Range of E_Integer is 4 times
-- -- the limit set by Max_Available_Precision.
--
-- if No_Of_Correct_Digits > e_Real_Machine_Mantissa then
-- We_Are_Finished := True;
-- exit;
-- end if;
--
-- A_0 := A_1; B_0 := B_1; D_0 := D_1;
--
--
-- end loop;
--
-- -- We want to optimize the calculation of D_1 above by multiplying
-- -- by an E_Digit on the left (Two_To_The_k) instead of an e_Real.
-- -- Stop doing this at Two_To_The_k = 2**20 to stay in range of E_Digit.
-- -- Below we finish up if necessary by multiplying twice..still much
-- -- more efficient than e_Real*e_Real.
--
-- if not We_Are_Finished then -- keep trying
-- for k in 21..40 loop
--
-- Two_To_The_k := Make_E_Digit (2.0**(k-20));
--
-- A_1 := Half_Digit * (A_0 + B_0);
-- B_1 := Sqrt (A_0 * B_0);
-- C := (A_1 - B_1);
-- D_1 := D_0 - Two_To_The_k * (Two_To_The_20 * (C * C));
--
-- No_Of_Correct_Digits := No_Of_Correct_Digits * 2;
-- exit when No_Of_Correct_Digits > e_Real_Machine_Mantissa;
--
-- A_0 := A_1; B_0 := B_1; D_0 := D_1;
--
-- end loop;
-- end if;
--
-- C := (A_1 + B_1);
-- Result := C * C / D_1;
--
-- Set_No_Of_Digits_To_Use (Old_Precision); -- Restore precision.
--
-- return Result;
--
-- end Make_Pi;
----------------
-- Make_Log_2 --
----------------
-- Important independent test of Log(X). Verify that Log(X) is correct
-- at X = 2, and use (eg) Log(XY) = Log(X) + Log(Y) to test other vals.
-- This is for testing other routines: Has greater error than Log(X).
-- Log_2, hopefully, for testing purposes.
-- A_0 = 1.0, B_0 = Two**(2-M);
--
-- A_k = (A_{k-1} + B_{k-1}) / 2
-- B_k = Sqrt (A_{k-1} * B_{k-1})
--
-- Then Log(2) = Pi / (2 * B_k * m) ???
--
-- Here M = N/2+1 where N = 29*e_Real_Machine_Mantissa = number of bits desired.
--
-- function Make_Log_2 return e_Real is
-- A_0, B_0 : e_Real;
-- A_1, B_1 : e_Real;
-- Result : e_Real;
-- We_Are_Finished : Boolean := False;
-- No_Of_Correct_Digits : E_Integer;
-- N : Integer := 24 * Integer(e_Real_Machine_Mantissa); -- Upper estimate.
-- M : Integer := N/2 + 24; -- Need only N/2 + 1
-- begin
--
-- A_0 := One;
-- B_0 := Two**(2-M); -- clean this up with the scaling ftcn.
--
-- No_Of_Correct_Digits := 1;
--
-- -- The following loop should get us up to half a million digits. In
-- -- the unlikely case you need more, then another loop follows.
--
-- for k in 1..16 loop -- I suspect far fewer than 20 iterations required.
--
-- A_1 := Half_Digit * (A_0 + B_0);
-- B_1 := Sqrt (A_0 * B_0);
--
-- A_0 := A_1; B_0 := B_1;
--
-- end loop;
--
-- Result := Half_Digit * e_Pi / (B_1 * Make_Extended(Real(M)));
--
-- Set_No_Of_Digits_To_Use (Old_Precision); -- Restore precision.
--
-- return Result;
--
-- end Make_Log_2;
----------
-- e_Pi --
----------
-- Returns Pi to Max Available Precision. Use Arcsin, cause it has
-- much lower error than Make_Pi.
-- Used for scaling trig functions, etc.
function e_Pi return e_Real is
begin
if not Pi_memory.Initialized then
--Pi_memory.Val := Make_Pi;
Pi_memory.Val := Four_Digit * e_Quarter_Pi;
-- Only works because arg is so small no scaling by E_pi is done.
Pi_memory.Initialized := True;
end if;
return Pi_memory.Val;
end e_Pi;
------------------
-- e_Inverse_Pi --
------------------
-- Returns Pi to Max Available Precision. Use Arcsin, cause it has
-- lower error than Make_Pi.
-- Used for scaling trig functions, etc.
function e_Inverse_Pi return e_Real is
begin
if not Inverse_Pi_memory.Initialized then
Inverse_Pi_memory.Val := (+0.25) / e_Quarter_Pi;
Inverse_Pi_memory.Initialized := True;
end if;
return Inverse_Pi_memory.Val;
end e_Inverse_Pi;
------------------
-- e_Quarter_Pi --
------------------
-- Returns Pi/4 to Max Available Precision.
-- Used for scaling trig functions, etc.
function e_Quarter_Pi return e_Real is
begin
if not Quarter_Pi_memory.Initialized then
Quarter_Pi_memory.Val := (+1.5) * Arcsin (Half);
Quarter_Pi_memory.Initialized := True;
end if;
return Quarter_Pi_memory.Val;
end e_Quarter_Pi;
----------------------
-- e_Inverse_Sqrt_2 --
----------------------
-- Returns 1/Sqrt(2.0) to Max Available Precision.
-- Used for making Pi.
function e_Inverse_Sqrt_2 return e_Real is
begin
if not Inverse_Sqrt_2_memory.Initialized then
Inverse_Sqrt_2_memory.Val := Reciprocal_Nth_Root (Two, 2);
Inverse_Sqrt_2_memory.Initialized := True;
end if;
return Inverse_Sqrt_2_memory.Val;
end e_Inverse_Sqrt_2;
--------------------------
-- e_Half_Inverse_Log_2 --
--------------------------
-- Returns Exp(1.0) to Max Available Precision.
-- Used for scaling arguments of Exp.
function e_Half_Inverse_Log_2 return e_Real is
begin
if not Half_Inverse_Log_2_memory.Initialized then
Half_Inverse_Log_2_memory.Val := Half / E_Log_2;
Half_Inverse_Log_2_memory.Initialized := True;
end if;
return Half_Inverse_Log_2_memory.Val;
end e_Half_Inverse_Log_2;
--------------
-- e_Log_2 --
--------------
-- Returns Log(2.0) to Max Available Precision.
-- Used for scaling Exp(X).
function e_Log_2 return e_Real is
begin
if not Log_2_memory.Initialized then
Log_2_memory.Val := Log (Two);
Log_2_memory.Initialized := True;
end if;
return Log_2_memory.Val;
end e_Log_2;
end Extended_Real.Elementary_Functions;
|
reznikmm/matreshka | Ada | 3,654 | 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.Table_Table_Elements is
pragma Preelaborate;
type ODF_Table_Table is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Table_Access is
access all ODF_Table_Table'Class
with Storage_Size => 0;
end ODF.DOM.Table_Table_Elements;
|
Holt59/Ada-SDL | Ada | 10,330 | adb | --------------------------------------------
-- --
-- PACKAGE GAME - PARTIE ADA --
-- --
-- GAME-GAUDIO.ADB --
-- --
-- Gestion du son (musique et "chunk") --
-- --
-- Créateur : CAPELLE Mikaël --
-- Adresse : [email protected] --
-- --
-- Dernière modification : 14 / 06 / 2011 --
-- --
--------------------------------------------
with Interfaces.C; use Interfaces.C;
with Ada.Exceptions;
package body Game.gAudio is
-----------
-- MUSIC --
-----------
------------------
-- FINALIZATION --
------------------
procedure C_Close_Music(M : in SDL_Music);
pragma Import(C,C_Close_Music,"close_music");
procedure Close_Music (M : in out Music) is
begin
if M.Mus /= Null_SDL_Music then
C_Close_Music(M.Mus);
M.Mus := Null_SDL_Music;
end if;
end Close_Music;
procedure Initialize (M : in out Music) is
begin
M.Mus := Null_SDL_Music;
end Initialize;
procedure Finalize (M : in out Music) is
begin
Close_Music(M);
end Finalize;
----------------
-- LOAD_MUSIC --
----------------
function C_Load_Music(S : in Char_Array) return SDL_Music;
pragma Import(C,C_Load_Music,"load_music");
procedure Load_Music (Mus : out Music;
Name : in String) is
begin
Close_Music (Mus);
Mus.Mus := C_Load_Music(To_C(Name));
if Mus.Mus = Null_SDL_Music then
Ada.Exceptions.Raise_Exception(Audio_Error'Identity,"Impossible de charger la musique : " & Name & " : " & Game.Error);
end if;
end Load_Music;
----------------
-- PLAY_MUSIC --
----------------
function C_Play_Music(M : in SDL_Music;
Loops : in Int) return Int;
pragma Import(C,C_Play_Music,"play_music");
procedure Play_Music(Mus : in Music;
Loops : in Boolean := True;
Nb : in Positive := 1) is
Result : Int := 0;
begin
if Loops then
Result := C_Play_Music(Mus.Mus,-1);
else
Result := C_Play_Music(Mus.Mus,Int(Nb));
end if;
if Result = -1 then
Ada.Exceptions.Raise_Exception(Audio_Error'Identity,"Impossible de jouer la musique : " & Game.Error);
end if;
end Play_Music;
----------------------
-- SET_MUSIC_VOLUME --
----------------------
function C_Set_Music_Volume(V : in Int) return Int;
pragma Import(C,C_Set_Music_Volume,"set_music_volume");
procedure Set_Music_Volume(V : in Volume) is
Tmp : Int := 0;
begin
Tmp := C_Set_Music_Volume(Int(V));
end Set_Music_Volume;
-----------------
-- PAUSE_MUSIC --
-----------------
procedure C_Pause_Music;
pragma Import(C,C_Pause_Music,"pause_music");
procedure C_Resume_Music;
pragma Import(C,C_Resume_Music,"resume_music");
procedure Pause_Music(P : in Boolean := True) is
begin
if P then
C_Pause_Music;
else
C_Resume_Music;
end if;
end Pause_Music;
-------------------
-- RESTART_MUSIC --
-------------------
procedure C_Restart_Music;
pragma Import(C,C_Restart_Music,"restart_music");
procedure Restart_Music is
begin
C_Restart_Music;
end Restart_Music;
----------------
-- STOP_MUSIC --
----------------
procedure C_Stop_Music;
pragma Import(C,C_Stop_Music,"stop_music");
procedure Stop_Music is
begin
C_Stop_Music;
end Stop_Music;
----------------------------------
-- MUSIC_PAUSED - MUSIC_PLAYING --
----------------------------------
function C_Music_Paused return Int;
pragma Import(C,C_Music_Paused,"music_paused");
function C_Music_Playing return Int;
pragma Import(C,C_Music_Playing, "music_playing");
function Music_Paused return Boolean is
Tmp : Int := 0;
begin
Tmp := C_Music_Paused;
if Tmp = 0 then
return False;
else
return True;
end if;
end Music_Paused;
function Music_Playing return Boolean is
Tmp : Int := 0;
begin
Tmp := C_Music_Playing;
if Tmp = 0 then
return False;
else
return True;
end if;
end Music_Playing;
-----------
-- CHUNK --
-----------
------------------
-- FINALIZATION --
------------------
procedure C_Close_Chunk(S : in SDL_Chunk);
pragma Import(C,C_Close_Chunk,"close_chunk");
procedure Close_Chunk (C : in out Chunk) is
begin
if C.Chu /= Null_SDL_Chunk then
C_Close_Chunk(C.Chu);
C.Chu := Null_SDL_Chunk;
end if;
end Close_Chunk;
procedure Initialize (C : in out Chunk) is
begin
C.Chu := Null_SDL_Chunk;
end Initialize;
procedure Finalize (C : in out Chunk) is
begin
Close_Chunk(C);
end Finalize;
----------------
-- LOAD_CHUNK --
----------------
function C_Load_Chunk(S : in Char_Array) return SDL_Chunk;
pragma Import(C,C_Load_Chunk,"load_chunk");
procedure Load_Chunk (Ch : out Chunk;
Name : in String) is
begin
Close_Chunk(Ch);
Ch.Chu := C_Load_Chunk(To_C(Name));
if Ch.Chu = Null_SDL_Chunk then
Ada.Exceptions.Raise_Exception(Audio_Error'Identity,"Impossible de charger le son " & Name & " : " & Game.Error);
end if;
end Load_Chunk;
----------------------
-- ALLOCATE_CHANNEL --
----------------------
function C_Alloc_Chan(Nb : in Int) return Int;
pragma Import(C,C_Alloc_Chan,"alloc_chan");
procedure Allocate_Channel(Nb : in Positive) is
Tmp : Int := 0;
begin
Tmp := C_Alloc_Chan(Int(Nb));
if Tmp /= Int(Nb) then
Ada.Exceptions.Raise_Exception(Audio_Error'Identity,"Impossible d'alloué les" & Integer'Image(Nb) & " canaux." & Positive'Image(Nb-Positive(Tmp)) & " non alloué(s) : " & Game.Error);
end if;
end Allocate_Channel;
------------------
-- PLAY_CHANNEL --
------------------
function C_Play_Channel(Chan : in Int; Ch : in SDL_Chunk; Nb : in Int; Time : in Int) return Int;
pragma Import(C,C_Play_Channel,"play_chan");
procedure Play_Channel(Ch : in Chunk;
Nb : in Positive := 1;
Time : in Natural := 0) is
Tmp : Int := 0;
begin
if Time = 0 then
Tmp := C_Play_Channel(-1,Ch.Chu,Int(Nb),-1);
else
Tmp := C_Play_Channel(-1,Ch.Chu,Int(Nb),Int(Time));
end if;
if Tmp = -1 then
Ada.Exceptions.Raise_Exception(Audio_Error'Identity,"Impossible de jouer le son sur le canal : " & Game.Error);
end if;
end Play_Channel;
procedure Play_Channel(Ch : in Chunk;
Chan : in Channel;
Nb : in Positive := 1;
Time : in Natural := 0) is
Tmp : Int := 0;
begin
if Time = 0 then
Tmp := C_Play_Channel(Int(Chan),Ch.Chu,Int(Nb),-1);
else
Tmp := C_Play_Channel(Int(Chan),Ch.Chu,Int(Nb),Int(Time));
end if;
if Tmp = -1 then
Ada.Exceptions.Raise_Exception(Audio_Error'Identity,"Impossible de jouer le son sur le canal" & Channel'Image(Chan) & " : " & Game.Error);
end if;
end Play_Channel;
-------------------
-- PAUSE_CHANNEL --
-------------------
procedure C_Pause_Channel(C : in Int);
pragma Import(C,C_Pause_Channel, "pause_chan");
procedure C_Resume_Channel(C : in Int);
pragma Import(C,C_Resume_Channel,"resume_chan");
procedure Pause_Channel(P : in Boolean := True) is
begin
if P then
C_Pause_Channel(-1);
else
C_Resume_Channel(-1);
end if;
end Pause_Channel;
procedure Pause_Channel(Chan : in Channel;
P : in Boolean := True) is
begin
if P then
C_Pause_Channel(Int(Chan));
else
C_Resume_Channel(Int(Chan));
end if;
end Pause_Channel;
------------------
-- STOP_CHANNEL --
------------------
procedure C_Stop_Chan(Ch : in Int);
pragma Import(C,C_Stop_Chan,"stop_chan");
procedure Stop_Channel is
begin
C_Stop_Chan(-1);
end Stop_Channel;
procedure Stop_Channel(Ch : in Channel) is
begin
C_Stop_Chan(Int(Ch));
end Stop_Channel;
--------------------------------------
-- CHANNEL_PAUSED - CHANNEL_PLAYING --
--------------------------------------
function C_Chan_Paused(Ch : in Int) return Int;
pragma Import(C,C_Chan_Paused,"chan_paused");
function C_Chan_Playing(Ch : in Int) return Int;
pragma Import(C,C_Chan_Playing,"chan_playing");
function Channel_Paused(Ch : in Channel) return Boolean is
Tmp : Int := 0;
begin
Tmp := C_Chan_Paused(Int(Ch));
if Tmp = 0 then
return False;
else
return True;
end if;
end Channel_Paused;
function Channel_Playing(Ch : in Channel) return Boolean is
Tmp : Int := 0;
begin
Tmp := C_Chan_Playing(Int(Ch));
if Tmp = 0 then
return False;
else
return True;
end if;
end Channel_Playing;
--------------------------------------
-- NB_CHAN_PAUSED - NB_CHAN_PLAYING --
--------------------------------------
function Nb_Chan_Paused return Natural is
Res : Int := 0;
begin
Res := C_Chan_Paused(-1);
return Natural(Res);
end Nb_Chan_Paused;
function Nb_Chan_Playing return Natural is
Res : Int := 0;
begin
Res := C_Chan_Playing(-1);
return Natural(Res);
end Nb_Chan_Playing;
------------------------
-- SET_CHANNEL_VOLUME --
------------------------
procedure C_Set_Chan_Volume(C : in Int; V : in Int);
pragma Import(C,C_Set_Chan_Volume,"set_chan_volume");
procedure Set_Channel_Volume(V : in Volume) is
begin
C_Set_Chan_Volume(-1,Int(V));
end Set_Channel_Volume;
procedure Set_Channel_Volume(C : in Channel; V : in Volume) is
begin
C_Set_Chan_Volume(Int(C),Int(V));
end Set_Channel_Volume;
end Game.gAudio;
|
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.Table_Selected_Page_Attributes;
package Matreshka.ODF_Table.Selected_Page_Attributes is
type Table_Selected_Page_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Selected_Page_Attributes.ODF_Table_Selected_Page_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Selected_Page_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Selected_Page_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Selected_Page_Attributes;
|
reznikmm/matreshka | Ada | 3,684 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Kind_Attributes is
pragma Preelaborate;
type ODF_Draw_Kind_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Kind_Attribute_Access is
access all ODF_Draw_Kind_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Kind_Attributes;
|
charlie5/cBound | Ada | 71,382 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.Pointers is
-- xcb_connection_t_Pointer
--
package C_xcb_connection_t_Pointers is new interfaces.c.Pointers
(Index => interfaces.c.size_t,
Element => xcb.xcb_connection_t,
element_Array => xcb.xcb_connection_t_Array,
default_Terminator => 0);
subtype xcb_connection_t_Pointer is C_xcb_connection_t_Pointers.Pointer;
-- xcb_connection_t_Pointer_Array
--
type xcb_connection_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_connection_t_Pointer;
-- xcb_special_event_t_Pointer
--
package C_xcb_special_event_t_Pointers is new interfaces.c.Pointers
(Index => interfaces.c.size_t,
Element => xcb.xcb_special_event_t,
element_Array => xcb.xcb_special_event_t_Array,
default_Terminator => 0);
subtype xcb_special_event_t_Pointer is
C_xcb_special_event_t_Pointers.Pointer;
-- xcb_special_event_t_Pointer_Array
--
type xcb_special_event_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_special_event_t_Pointer;
-- xcb_window_t_Pointer
--
package C_xcb_window_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_window_t,
Element_Array => xcb.xcb_window_t_array,
Default_Terminator => 0);
subtype xcb_window_t_Pointer is C_xcb_window_t_Pointers.Pointer;
-- xcb_window_t_Pointer_Array
--
type xcb_window_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_window_t_Pointer;
-- xcb_pixmap_t_Pointer
--
package C_xcb_pixmap_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_pixmap_t,
Element_Array => xcb.xcb_pixmap_t_array,
Default_Terminator => 0);
subtype xcb_pixmap_t_Pointer is C_xcb_pixmap_t_Pointers.Pointer;
-- xcb_pixmap_t_Pointer_Array
--
type xcb_pixmap_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_pixmap_t_Pointer;
-- xcb_cursor_t_Pointer
--
package C_xcb_cursor_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_cursor_t,
Element_Array => xcb.xcb_cursor_t_array,
Default_Terminator => 0);
subtype xcb_cursor_t_Pointer is C_xcb_cursor_t_Pointers.Pointer;
-- xcb_cursor_t_Pointer_Array
--
type xcb_cursor_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_cursor_t_Pointer;
-- xcb_font_t_Pointer
--
package C_xcb_font_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_font_t,
Element_Array => xcb.xcb_font_t_array,
Default_Terminator => 0);
subtype xcb_font_t_Pointer is C_xcb_font_t_Pointers.Pointer;
-- xcb_font_t_Pointer_Array
--
type xcb_font_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_font_t_Pointer;
-- xcb_gcontext_t_Pointer
--
package C_xcb_gcontext_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_gcontext_t,
Element_Array => xcb.xcb_gcontext_t_array,
Default_Terminator => 0);
subtype xcb_gcontext_t_Pointer is C_xcb_gcontext_t_Pointers.Pointer;
-- xcb_gcontext_t_Pointer_Array
--
type xcb_gcontext_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_gcontext_t_Pointer;
-- xcb_colormap_t_Pointer
--
package C_xcb_colormap_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_colormap_t,
Element_Array => xcb.xcb_colormap_t_array,
Default_Terminator => 0);
subtype xcb_colormap_t_Pointer is C_xcb_colormap_t_Pointers.Pointer;
-- xcb_colormap_t_Pointer_Array
--
type xcb_colormap_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_colormap_t_Pointer;
-- xcb_atom_t_Pointer
--
package C_xcb_atom_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_atom_t,
Element_Array => xcb.xcb_atom_t_array,
Default_Terminator => 0);
subtype xcb_atom_t_Pointer is C_xcb_atom_t_Pointers.Pointer;
-- xcb_atom_t_Pointer_Array
--
type xcb_atom_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_atom_t_Pointer;
-- xcb_drawable_t_Pointer
--
package C_xcb_drawable_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_drawable_t,
Element_Array => xcb.xcb_drawable_t_array,
Default_Terminator => 0);
subtype xcb_drawable_t_Pointer is C_xcb_drawable_t_Pointers.Pointer;
-- xcb_drawable_t_Pointer_Array
--
type xcb_drawable_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_drawable_t_Pointer;
-- xcb_fontable_t_Pointer
--
package C_xcb_fontable_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_fontable_t,
Element_Array => xcb.xcb_fontable_t_array,
Default_Terminator => 0);
subtype xcb_fontable_t_Pointer is C_xcb_fontable_t_Pointers.Pointer;
-- xcb_fontable_t_Pointer_Array
--
type xcb_fontable_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_fontable_t_Pointer;
-- xcb_bool32_t_Pointer
--
package C_xcb_bool32_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_bool32_t,
Element_Array => xcb.xcb_bool32_t_array,
Default_Terminator => 0);
subtype xcb_bool32_t_Pointer is C_xcb_bool32_t_Pointers.Pointer;
-- xcb_bool32_t_Pointer_Array
--
type xcb_bool32_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_bool32_t_Pointer;
-- xcb_visualid_t_Pointer
--
package C_xcb_visualid_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_visualid_t,
Element_Array => xcb.xcb_visualid_t_array,
Default_Terminator => 0);
subtype xcb_visualid_t_Pointer is C_xcb_visualid_t_Pointers.Pointer;
-- xcb_visualid_t_Pointer_Array
--
type xcb_visualid_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_visualid_t_Pointer;
-- xcb_timestamp_t_Pointer
--
package C_xcb_timestamp_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_timestamp_t,
Element_Array => xcb.xcb_timestamp_t_array,
Default_Terminator => 0);
subtype xcb_timestamp_t_Pointer is C_xcb_timestamp_t_Pointers.Pointer;
-- xcb_timestamp_t_Pointer_Array
--
type xcb_timestamp_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_timestamp_t_Pointer;
-- xcb_keysym_t_Pointer
--
package C_xcb_keysym_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_keysym_t,
Element_Array => xcb.xcb_keysym_t_array,
Default_Terminator => 0);
subtype xcb_keysym_t_Pointer is C_xcb_keysym_t_Pointers.Pointer;
-- xcb_keysym_t_Pointer_Array
--
type xcb_keysym_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_keysym_t_Pointer;
-- xcb_keycode_t_Pointer
--
package C_xcb_keycode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_keycode_t,
Element_Array => xcb.xcb_keycode_t_array,
Default_Terminator => 0);
subtype xcb_keycode_t_Pointer is C_xcb_keycode_t_Pointers.Pointer;
-- xcb_keycode_t_Pointer_Array
--
type xcb_keycode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_keycode_t_Pointer;
-- xcb_keycode32_t_Pointer
--
package C_xcb_keycode32_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_keycode32_t,
Element_Array => xcb.xcb_keycode32_t_array,
Default_Terminator => 0);
subtype xcb_keycode32_t_Pointer is C_xcb_keycode32_t_Pointers.Pointer;
-- xcb_keycode32_t_Pointer_Array
--
type xcb_keycode32_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_keycode32_t_Pointer;
-- xcb_button_t_Pointer
--
package C_xcb_button_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_button_t,
Element_Array => xcb.xcb_button_t_array,
Default_Terminator => 0);
subtype xcb_button_t_Pointer is C_xcb_button_t_Pointers.Pointer;
-- xcb_button_t_Pointer_Array
--
type xcb_button_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_button_t_Pointer;
-- xcb_visual_class_t_Pointer
--
package C_xcb_visual_class_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_visual_class_t,
Element_Array => xcb.xcb_visual_class_t_array,
Default_Terminator => xcb.xcb_visual_class_t'Val (0));
subtype xcb_visual_class_t_Pointer is C_xcb_visual_class_t_Pointers.Pointer;
-- xcb_visual_class_t_Pointer_Array
--
type xcb_visual_class_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_visual_class_t_Pointer;
-- xcb_event_mask_t_Pointer
--
package C_xcb_event_mask_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_event_mask_t,
Element_Array => xcb.xcb_event_mask_t_array,
Default_Terminator => xcb.xcb_event_mask_t'Val (0));
subtype xcb_event_mask_t_Pointer is C_xcb_event_mask_t_Pointers.Pointer;
-- xcb_event_mask_t_Pointer_Array
--
type xcb_event_mask_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_event_mask_t_Pointer;
-- xcb_backing_store_t_Pointer
--
package C_xcb_backing_store_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_backing_store_t,
Element_Array => xcb.xcb_backing_store_t_array,
Default_Terminator => xcb.xcb_backing_store_t'Val (0));
subtype xcb_backing_store_t_Pointer is
C_xcb_backing_store_t_Pointers.Pointer;
-- xcb_backing_store_t_Pointer_Array
--
type xcb_backing_store_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_backing_store_t_Pointer;
-- xcb_image_order_t_Pointer
--
package C_xcb_image_order_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_image_order_t,
Element_Array => xcb.xcb_image_order_t_array,
Default_Terminator => xcb.xcb_image_order_t'Val (0));
subtype xcb_image_order_t_Pointer is C_xcb_image_order_t_Pointers.Pointer;
-- xcb_image_order_t_Pointer_Array
--
type xcb_image_order_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_image_order_t_Pointer;
-- xcb_mod_mask_t_Pointer
--
package C_xcb_mod_mask_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_mod_mask_t,
Element_Array => xcb.xcb_mod_mask_t_array,
Default_Terminator => xcb.xcb_mod_mask_t'Val (0));
subtype xcb_mod_mask_t_Pointer is C_xcb_mod_mask_t_Pointers.Pointer;
-- xcb_mod_mask_t_Pointer_Array
--
type xcb_mod_mask_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_mod_mask_t_Pointer;
-- xcb_key_but_mask_t_Pointer
--
package C_xcb_key_but_mask_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_key_but_mask_t,
Element_Array => xcb.xcb_key_but_mask_t_array,
Default_Terminator => xcb.xcb_key_but_mask_t'Val (0));
subtype xcb_key_but_mask_t_Pointer is C_xcb_key_but_mask_t_Pointers.Pointer;
-- xcb_key_but_mask_t_Pointer_Array
--
type xcb_key_but_mask_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_key_but_mask_t_Pointer;
-- xcb_window_enum_t_Pointer
--
package C_xcb_window_enum_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_window_enum_t,
Element_Array => xcb.xcb_window_enum_t_array,
Default_Terminator => xcb.xcb_window_enum_t'Val (0));
subtype xcb_window_enum_t_Pointer is C_xcb_window_enum_t_Pointers.Pointer;
-- xcb_window_enum_t_Pointer_Array
--
type xcb_window_enum_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_window_enum_t_Pointer;
-- xcb_button_mask_t_Pointer
--
package C_xcb_button_mask_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_button_mask_t,
Element_Array => xcb.xcb_button_mask_t_array,
Default_Terminator => xcb.xcb_button_mask_t'Val (0));
subtype xcb_button_mask_t_Pointer is C_xcb_button_mask_t_Pointers.Pointer;
-- xcb_button_mask_t_Pointer_Array
--
type xcb_button_mask_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_button_mask_t_Pointer;
-- xcb_motion_t_Pointer
--
package C_xcb_motion_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_motion_t,
Element_Array => xcb.xcb_motion_t_array,
Default_Terminator => xcb.xcb_motion_t'Val (0));
subtype xcb_motion_t_Pointer is C_xcb_motion_t_Pointers.Pointer;
-- xcb_motion_t_Pointer_Array
--
type xcb_motion_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_motion_t_Pointer;
-- xcb_notify_detail_t_Pointer
--
package C_xcb_notify_detail_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_notify_detail_t,
Element_Array => xcb.xcb_notify_detail_t_array,
Default_Terminator => xcb.xcb_notify_detail_t'Val (0));
subtype xcb_notify_detail_t_Pointer is
C_xcb_notify_detail_t_Pointers.Pointer;
-- xcb_notify_detail_t_Pointer_Array
--
type xcb_notify_detail_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_notify_detail_t_Pointer;
-- xcb_notify_mode_t_Pointer
--
package C_xcb_notify_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_notify_mode_t,
Element_Array => xcb.xcb_notify_mode_t_array,
Default_Terminator => xcb.xcb_notify_mode_t'Val (0));
subtype xcb_notify_mode_t_Pointer is C_xcb_notify_mode_t_Pointers.Pointer;
-- xcb_notify_mode_t_Pointer_Array
--
type xcb_notify_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_notify_mode_t_Pointer;
-- xcb_visibility_t_Pointer
--
package C_xcb_visibility_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_visibility_t,
Element_Array => xcb.xcb_visibility_t_array,
Default_Terminator => xcb.xcb_visibility_t'Val (0));
subtype xcb_visibility_t_Pointer is C_xcb_visibility_t_Pointers.Pointer;
-- xcb_visibility_t_Pointer_Array
--
type xcb_visibility_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_visibility_t_Pointer;
-- xcb_place_t_Pointer
--
package C_xcb_place_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_place_t,
Element_Array => xcb.xcb_place_t_array,
Default_Terminator => xcb.xcb_place_t'Val (0));
subtype xcb_place_t_Pointer is C_xcb_place_t_Pointers.Pointer;
-- xcb_place_t_Pointer_Array
--
type xcb_place_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_place_t_Pointer;
-- xcb_property_t_Pointer
--
package C_xcb_property_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_property_t,
Element_Array => xcb.xcb_property_t_array,
Default_Terminator => xcb.xcb_property_t'Val (0));
subtype xcb_property_t_Pointer is C_xcb_property_t_Pointers.Pointer;
-- xcb_property_t_Pointer_Array
--
type xcb_property_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_property_t_Pointer;
-- xcb_time_t_Pointer
--
package C_xcb_time_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_time_t,
Element_Array => xcb.xcb_time_t_array,
Default_Terminator => xcb.xcb_time_t'Val (0));
subtype xcb_time_t_Pointer is C_xcb_time_t_Pointers.Pointer;
-- xcb_time_t_Pointer_Array
--
type xcb_time_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_time_t_Pointer;
-- xcb_atom_enum_t_Pointer
--
package C_xcb_atom_enum_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_atom_enum_t,
Element_Array => xcb.xcb_atom_enum_t_array,
Default_Terminator => xcb.xcb_atom_enum_t'Val (0));
subtype xcb_atom_enum_t_Pointer is C_xcb_atom_enum_t_Pointers.Pointer;
-- xcb_atom_enum_t_Pointer_Array
--
type xcb_atom_enum_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_atom_enum_t_Pointer;
-- xcb_colormap_state_t_Pointer
--
package C_xcb_colormap_state_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_colormap_state_t,
Element_Array => xcb.xcb_colormap_state_t_array,
Default_Terminator => xcb.xcb_colormap_state_t'Val (0));
subtype xcb_colormap_state_t_Pointer is
C_xcb_colormap_state_t_Pointers.Pointer;
-- xcb_colormap_state_t_Pointer_Array
--
type xcb_colormap_state_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_colormap_state_t_Pointer;
-- xcb_colormap_enum_t_Pointer
--
package C_xcb_colormap_enum_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_colormap_enum_t,
Element_Array => xcb.xcb_colormap_enum_t_array,
Default_Terminator => xcb.xcb_colormap_enum_t'Val (0));
subtype xcb_colormap_enum_t_Pointer is
C_xcb_colormap_enum_t_Pointers.Pointer;
-- xcb_colormap_enum_t_Pointer_Array
--
type xcb_colormap_enum_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_colormap_enum_t_Pointer;
-- xcb_mapping_t_Pointer
--
package C_xcb_mapping_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_mapping_t,
Element_Array => xcb.xcb_mapping_t_array,
Default_Terminator => xcb.xcb_mapping_t'Val (0));
subtype xcb_mapping_t_Pointer is C_xcb_mapping_t_Pointers.Pointer;
-- xcb_mapping_t_Pointer_Array
--
type xcb_mapping_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_mapping_t_Pointer;
-- xcb_window_class_t_Pointer
--
package C_xcb_window_class_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_window_class_t,
Element_Array => xcb.xcb_window_class_t_array,
Default_Terminator => xcb.xcb_window_class_t'Val (0));
subtype xcb_window_class_t_Pointer is C_xcb_window_class_t_Pointers.Pointer;
-- xcb_window_class_t_Pointer_Array
--
type xcb_window_class_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_window_class_t_Pointer;
-- xcb_cw_t_Pointer
--
package C_xcb_cw_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_cw_t,
Element_Array => xcb.xcb_cw_t_array,
Default_Terminator => xcb.xcb_cw_t'Val (0));
subtype xcb_cw_t_Pointer is C_xcb_cw_t_Pointers.Pointer;
-- xcb_cw_t_Pointer_Array
--
type xcb_cw_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers.xcb_cw_t_Pointer;
-- xcb_back_pixmap_t_Pointer
--
package C_xcb_back_pixmap_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_back_pixmap_t,
Element_Array => xcb.xcb_back_pixmap_t_array,
Default_Terminator => xcb.xcb_back_pixmap_t'Val (0));
subtype xcb_back_pixmap_t_Pointer is C_xcb_back_pixmap_t_Pointers.Pointer;
-- xcb_back_pixmap_t_Pointer_Array
--
type xcb_back_pixmap_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_back_pixmap_t_Pointer;
-- xcb_gravity_t_Pointer
--
package C_xcb_gravity_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_gravity_t,
Element_Array => xcb.xcb_gravity_t_array,
Default_Terminator => xcb.xcb_gravity_t'Val (0));
subtype xcb_gravity_t_Pointer is C_xcb_gravity_t_Pointers.Pointer;
-- xcb_gravity_t_Pointer_Array
--
type xcb_gravity_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_gravity_t_Pointer;
-- xcb_map_state_t_Pointer
--
package C_xcb_map_state_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_map_state_t,
Element_Array => xcb.xcb_map_state_t_array,
Default_Terminator => xcb.xcb_map_state_t'Val (0));
subtype xcb_map_state_t_Pointer is C_xcb_map_state_t_Pointers.Pointer;
-- xcb_map_state_t_Pointer_Array
--
type xcb_map_state_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_map_state_t_Pointer;
-- xcb_set_mode_t_Pointer
--
package C_xcb_set_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_set_mode_t,
Element_Array => xcb.xcb_set_mode_t_array,
Default_Terminator => xcb.xcb_set_mode_t'Val (0));
subtype xcb_set_mode_t_Pointer is C_xcb_set_mode_t_Pointers.Pointer;
-- xcb_set_mode_t_Pointer_Array
--
type xcb_set_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_set_mode_t_Pointer;
-- xcb_config_window_t_Pointer
--
package C_xcb_config_window_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_config_window_t,
Element_Array => xcb.xcb_config_window_t_array,
Default_Terminator => xcb.xcb_config_window_t'Val (0));
subtype xcb_config_window_t_Pointer is
C_xcb_config_window_t_Pointers.Pointer;
-- xcb_config_window_t_Pointer_Array
--
type xcb_config_window_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_config_window_t_Pointer;
-- xcb_stack_mode_t_Pointer
--
package C_xcb_stack_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_stack_mode_t,
Element_Array => xcb.xcb_stack_mode_t_array,
Default_Terminator => xcb.xcb_stack_mode_t'Val (0));
subtype xcb_stack_mode_t_Pointer is C_xcb_stack_mode_t_Pointers.Pointer;
-- xcb_stack_mode_t_Pointer_Array
--
type xcb_stack_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_stack_mode_t_Pointer;
-- xcb_circulate_t_Pointer
--
package C_xcb_circulate_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_circulate_t,
Element_Array => xcb.xcb_circulate_t_array,
Default_Terminator => xcb.xcb_circulate_t'Val (0));
subtype xcb_circulate_t_Pointer is C_xcb_circulate_t_Pointers.Pointer;
-- xcb_circulate_t_Pointer_Array
--
type xcb_circulate_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_circulate_t_Pointer;
-- xcb_prop_mode_t_Pointer
--
package C_xcb_prop_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_prop_mode_t,
Element_Array => xcb.xcb_prop_mode_t_array,
Default_Terminator => xcb.xcb_prop_mode_t'Val (0));
subtype xcb_prop_mode_t_Pointer is C_xcb_prop_mode_t_Pointers.Pointer;
-- xcb_prop_mode_t_Pointer_Array
--
type xcb_prop_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_prop_mode_t_Pointer;
-- xcb_get_property_type_t_Pointer
--
package C_xcb_get_property_type_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_property_type_t,
Element_Array => xcb.xcb_get_property_type_t_array,
Default_Terminator => xcb.xcb_get_property_type_t'Val (0));
subtype xcb_get_property_type_t_Pointer is
C_xcb_get_property_type_t_Pointers.Pointer;
-- xcb_get_property_type_t_Pointer_Array
--
type xcb_get_property_type_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_get_property_type_t_Pointer;
-- xcb_send_event_dest_t_Pointer
--
package C_xcb_send_event_dest_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_send_event_dest_t,
Element_Array => xcb.xcb_send_event_dest_t_array,
Default_Terminator => xcb.xcb_send_event_dest_t'Val (0));
subtype xcb_send_event_dest_t_Pointer is
C_xcb_send_event_dest_t_Pointers.Pointer;
-- xcb_send_event_dest_t_Pointer_Array
--
type xcb_send_event_dest_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_send_event_dest_t_Pointer;
-- xcb_grab_mode_t_Pointer
--
package C_xcb_grab_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_grab_mode_t,
Element_Array => xcb.xcb_grab_mode_t_array,
Default_Terminator => xcb.xcb_grab_mode_t'Val (0));
subtype xcb_grab_mode_t_Pointer is C_xcb_grab_mode_t_Pointers.Pointer;
-- xcb_grab_mode_t_Pointer_Array
--
type xcb_grab_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_grab_mode_t_Pointer;
-- xcb_grab_status_t_Pointer
--
package C_xcb_grab_status_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_grab_status_t,
Element_Array => xcb.xcb_grab_status_t_array,
Default_Terminator => xcb.xcb_grab_status_t'Val (0));
subtype xcb_grab_status_t_Pointer is C_xcb_grab_status_t_Pointers.Pointer;
-- xcb_grab_status_t_Pointer_Array
--
type xcb_grab_status_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_grab_status_t_Pointer;
-- xcb_cursor_enum_t_Pointer
--
package C_xcb_cursor_enum_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_cursor_enum_t,
Element_Array => xcb.xcb_cursor_enum_t_array,
Default_Terminator => xcb.xcb_cursor_enum_t'Val (0));
subtype xcb_cursor_enum_t_Pointer is C_xcb_cursor_enum_t_Pointers.Pointer;
-- xcb_cursor_enum_t_Pointer_Array
--
type xcb_cursor_enum_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_cursor_enum_t_Pointer;
-- xcb_button_index_t_Pointer
--
package C_xcb_button_index_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_button_index_t,
Element_Array => xcb.xcb_button_index_t_array,
Default_Terminator => xcb.xcb_button_index_t'Val (0));
subtype xcb_button_index_t_Pointer is C_xcb_button_index_t_Pointers.Pointer;
-- xcb_button_index_t_Pointer_Array
--
type xcb_button_index_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_button_index_t_Pointer;
-- xcb_grab_t_Pointer
--
package C_xcb_grab_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_grab_t,
Element_Array => xcb.xcb_grab_t_array,
Default_Terminator => xcb.xcb_grab_t'Val (0));
subtype xcb_grab_t_Pointer is C_xcb_grab_t_Pointers.Pointer;
-- xcb_grab_t_Pointer_Array
--
type xcb_grab_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_grab_t_Pointer;
-- xcb_allow_t_Pointer
--
package C_xcb_allow_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_allow_t,
Element_Array => xcb.xcb_allow_t_array,
Default_Terminator => xcb.xcb_allow_t'Val (0));
subtype xcb_allow_t_Pointer is C_xcb_allow_t_Pointers.Pointer;
-- xcb_allow_t_Pointer_Array
--
type xcb_allow_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_allow_t_Pointer;
-- xcb_input_focus_t_Pointer
--
package C_xcb_input_focus_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_input_focus_t,
Element_Array => xcb.xcb_input_focus_t_array,
Default_Terminator => xcb.xcb_input_focus_t'Val (0));
subtype xcb_input_focus_t_Pointer is C_xcb_input_focus_t_Pointers.Pointer;
-- xcb_input_focus_t_Pointer_Array
--
type xcb_input_focus_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_input_focus_t_Pointer;
-- xcb_font_draw_t_Pointer
--
package C_xcb_font_draw_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_font_draw_t,
Element_Array => xcb.xcb_font_draw_t_array,
Default_Terminator => xcb.xcb_font_draw_t'Val (0));
subtype xcb_font_draw_t_Pointer is C_xcb_font_draw_t_Pointers.Pointer;
-- xcb_font_draw_t_Pointer_Array
--
type xcb_font_draw_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_font_draw_t_Pointer;
-- xcb_gc_t_Pointer
--
package C_xcb_gc_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_gc_t,
Element_Array => xcb.xcb_gc_t_array,
Default_Terminator => xcb.xcb_gc_t'Val (0));
subtype xcb_gc_t_Pointer is C_xcb_gc_t_Pointers.Pointer;
-- xcb_gc_t_Pointer_Array
--
type xcb_gc_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers.xcb_gc_t_Pointer;
-- xcb_gx_t_Pointer
--
package C_xcb_gx_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_gx_t,
Element_Array => xcb.xcb_gx_t_array,
Default_Terminator => xcb.xcb_gx_t'Val (0));
subtype xcb_gx_t_Pointer is C_xcb_gx_t_Pointers.Pointer;
-- xcb_gx_t_Pointer_Array
--
type xcb_gx_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers.xcb_gx_t_Pointer;
-- xcb_line_style_t_Pointer
--
package C_xcb_line_style_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_line_style_t,
Element_Array => xcb.xcb_line_style_t_array,
Default_Terminator => xcb.xcb_line_style_t'Val (0));
subtype xcb_line_style_t_Pointer is C_xcb_line_style_t_Pointers.Pointer;
-- xcb_line_style_t_Pointer_Array
--
type xcb_line_style_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_line_style_t_Pointer;
-- xcb_cap_style_t_Pointer
--
package C_xcb_cap_style_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_cap_style_t,
Element_Array => xcb.xcb_cap_style_t_array,
Default_Terminator => xcb.xcb_cap_style_t'Val (0));
subtype xcb_cap_style_t_Pointer is C_xcb_cap_style_t_Pointers.Pointer;
-- xcb_cap_style_t_Pointer_Array
--
type xcb_cap_style_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_cap_style_t_Pointer;
-- xcb_join_style_t_Pointer
--
package C_xcb_join_style_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_join_style_t,
Element_Array => xcb.xcb_join_style_t_array,
Default_Terminator => xcb.xcb_join_style_t'Val (0));
subtype xcb_join_style_t_Pointer is C_xcb_join_style_t_Pointers.Pointer;
-- xcb_join_style_t_Pointer_Array
--
type xcb_join_style_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_join_style_t_Pointer;
-- xcb_fill_style_t_Pointer
--
package C_xcb_fill_style_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_fill_style_t,
Element_Array => xcb.xcb_fill_style_t_array,
Default_Terminator => xcb.xcb_fill_style_t'Val (0));
subtype xcb_fill_style_t_Pointer is C_xcb_fill_style_t_Pointers.Pointer;
-- xcb_fill_style_t_Pointer_Array
--
type xcb_fill_style_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_fill_style_t_Pointer;
-- xcb_fill_rule_t_Pointer
--
package C_xcb_fill_rule_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_fill_rule_t,
Element_Array => xcb.xcb_fill_rule_t_array,
Default_Terminator => xcb.xcb_fill_rule_t'Val (0));
subtype xcb_fill_rule_t_Pointer is C_xcb_fill_rule_t_Pointers.Pointer;
-- xcb_fill_rule_t_Pointer_Array
--
type xcb_fill_rule_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_fill_rule_t_Pointer;
-- xcb_subwindow_mode_t_Pointer
--
package C_xcb_subwindow_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_subwindow_mode_t,
Element_Array => xcb.xcb_subwindow_mode_t_array,
Default_Terminator => xcb.xcb_subwindow_mode_t'Val (0));
subtype xcb_subwindow_mode_t_Pointer is
C_xcb_subwindow_mode_t_Pointers.Pointer;
-- xcb_subwindow_mode_t_Pointer_Array
--
type xcb_subwindow_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_subwindow_mode_t_Pointer;
-- xcb_arc_mode_t_Pointer
--
package C_xcb_arc_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_arc_mode_t,
Element_Array => xcb.xcb_arc_mode_t_array,
Default_Terminator => xcb.xcb_arc_mode_t'Val (0));
subtype xcb_arc_mode_t_Pointer is C_xcb_arc_mode_t_Pointers.Pointer;
-- xcb_arc_mode_t_Pointer_Array
--
type xcb_arc_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_arc_mode_t_Pointer;
-- xcb_clip_ordering_t_Pointer
--
package C_xcb_clip_ordering_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_clip_ordering_t,
Element_Array => xcb.xcb_clip_ordering_t_array,
Default_Terminator => xcb.xcb_clip_ordering_t'Val (0));
subtype xcb_clip_ordering_t_Pointer is
C_xcb_clip_ordering_t_Pointers.Pointer;
-- xcb_clip_ordering_t_Pointer_Array
--
type xcb_clip_ordering_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_clip_ordering_t_Pointer;
-- xcb_coord_mode_t_Pointer
--
package C_xcb_coord_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_coord_mode_t,
Element_Array => xcb.xcb_coord_mode_t_array,
Default_Terminator => xcb.xcb_coord_mode_t'Val (0));
subtype xcb_coord_mode_t_Pointer is C_xcb_coord_mode_t_Pointers.Pointer;
-- xcb_coord_mode_t_Pointer_Array
--
type xcb_coord_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_coord_mode_t_Pointer;
-- xcb_poly_shape_t_Pointer
--
package C_xcb_poly_shape_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_poly_shape_t,
Element_Array => xcb.xcb_poly_shape_t_array,
Default_Terminator => xcb.xcb_poly_shape_t'Val (0));
subtype xcb_poly_shape_t_Pointer is C_xcb_poly_shape_t_Pointers.Pointer;
-- xcb_poly_shape_t_Pointer_Array
--
type xcb_poly_shape_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_poly_shape_t_Pointer;
-- xcb_image_format_t_Pointer
--
package C_xcb_image_format_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_image_format_t,
Element_Array => xcb.xcb_image_format_t_array,
Default_Terminator => xcb.xcb_image_format_t'Val (0));
subtype xcb_image_format_t_Pointer is C_xcb_image_format_t_Pointers.Pointer;
-- xcb_image_format_t_Pointer_Array
--
type xcb_image_format_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_image_format_t_Pointer;
-- xcb_colormap_alloc_t_Pointer
--
package C_xcb_colormap_alloc_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_colormap_alloc_t,
Element_Array => xcb.xcb_colormap_alloc_t_array,
Default_Terminator => xcb.xcb_colormap_alloc_t'Val (0));
subtype xcb_colormap_alloc_t_Pointer is
C_xcb_colormap_alloc_t_Pointers.Pointer;
-- xcb_colormap_alloc_t_Pointer_Array
--
type xcb_colormap_alloc_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_colormap_alloc_t_Pointer;
-- xcb_color_flag_t_Pointer
--
package C_xcb_color_flag_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_color_flag_t,
Element_Array => xcb.xcb_color_flag_t_array,
Default_Terminator => xcb.xcb_color_flag_t'Val (0));
subtype xcb_color_flag_t_Pointer is C_xcb_color_flag_t_Pointers.Pointer;
-- xcb_color_flag_t_Pointer_Array
--
type xcb_color_flag_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_color_flag_t_Pointer;
-- xcb_pixmap_enum_t_Pointer
--
package C_xcb_pixmap_enum_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_pixmap_enum_t,
Element_Array => xcb.xcb_pixmap_enum_t_array,
Default_Terminator => xcb.xcb_pixmap_enum_t'Val (0));
subtype xcb_pixmap_enum_t_Pointer is C_xcb_pixmap_enum_t_Pointers.Pointer;
-- xcb_pixmap_enum_t_Pointer_Array
--
type xcb_pixmap_enum_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_pixmap_enum_t_Pointer;
-- xcb_font_enum_t_Pointer
--
package C_xcb_font_enum_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_font_enum_t,
Element_Array => xcb.xcb_font_enum_t_array,
Default_Terminator => xcb.xcb_font_enum_t'Val (0));
subtype xcb_font_enum_t_Pointer is C_xcb_font_enum_t_Pointers.Pointer;
-- xcb_font_enum_t_Pointer_Array
--
type xcb_font_enum_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_font_enum_t_Pointer;
-- xcb_query_shape_of_t_Pointer
--
package C_xcb_query_shape_of_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_query_shape_of_t,
Element_Array => xcb.xcb_query_shape_of_t_array,
Default_Terminator => xcb.xcb_query_shape_of_t'Val (0));
subtype xcb_query_shape_of_t_Pointer is
C_xcb_query_shape_of_t_Pointers.Pointer;
-- xcb_query_shape_of_t_Pointer_Array
--
type xcb_query_shape_of_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_query_shape_of_t_Pointer;
-- xcb_kb_t_Pointer
--
package C_xcb_kb_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_kb_t,
Element_Array => xcb.xcb_kb_t_array,
Default_Terminator => xcb.xcb_kb_t'Val (0));
subtype xcb_kb_t_Pointer is C_xcb_kb_t_Pointers.Pointer;
-- xcb_kb_t_Pointer_Array
--
type xcb_kb_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers.xcb_kb_t_Pointer;
-- xcb_led_mode_t_Pointer
--
package C_xcb_led_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_led_mode_t,
Element_Array => xcb.xcb_led_mode_t_array,
Default_Terminator => xcb.xcb_led_mode_t'Val (0));
subtype xcb_led_mode_t_Pointer is C_xcb_led_mode_t_Pointers.Pointer;
-- xcb_led_mode_t_Pointer_Array
--
type xcb_led_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_led_mode_t_Pointer;
-- xcb_auto_repeat_mode_t_Pointer
--
package C_xcb_auto_repeat_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_auto_repeat_mode_t,
Element_Array => xcb.xcb_auto_repeat_mode_t_array,
Default_Terminator => xcb.xcb_auto_repeat_mode_t'Val (0));
subtype xcb_auto_repeat_mode_t_Pointer is
C_xcb_auto_repeat_mode_t_Pointers.Pointer;
-- xcb_auto_repeat_mode_t_Pointer_Array
--
type xcb_auto_repeat_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_auto_repeat_mode_t_Pointer;
-- xcb_blanking_t_Pointer
--
package C_xcb_blanking_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_blanking_t,
Element_Array => xcb.xcb_blanking_t_array,
Default_Terminator => xcb.xcb_blanking_t'Val (0));
subtype xcb_blanking_t_Pointer is C_xcb_blanking_t_Pointers.Pointer;
-- xcb_blanking_t_Pointer_Array
--
type xcb_blanking_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_blanking_t_Pointer;
-- xcb_exposures_t_Pointer
--
package C_xcb_exposures_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_exposures_t,
Element_Array => xcb.xcb_exposures_t_array,
Default_Terminator => xcb.xcb_exposures_t'Val (0));
subtype xcb_exposures_t_Pointer is C_xcb_exposures_t_Pointers.Pointer;
-- xcb_exposures_t_Pointer_Array
--
type xcb_exposures_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_exposures_t_Pointer;
-- xcb_host_mode_t_Pointer
--
package C_xcb_host_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_host_mode_t,
Element_Array => xcb.xcb_host_mode_t_array,
Default_Terminator => xcb.xcb_host_mode_t'Val (0));
subtype xcb_host_mode_t_Pointer is C_xcb_host_mode_t_Pointers.Pointer;
-- xcb_host_mode_t_Pointer_Array
--
type xcb_host_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_host_mode_t_Pointer;
-- xcb_family_t_Pointer
--
package C_xcb_family_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_family_t,
Element_Array => xcb.xcb_family_t_array,
Default_Terminator => xcb.xcb_family_t'Val (0));
subtype xcb_family_t_Pointer is C_xcb_family_t_Pointers.Pointer;
-- xcb_family_t_Pointer_Array
--
type xcb_family_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_family_t_Pointer;
-- xcb_access_control_t_Pointer
--
package C_xcb_access_control_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_access_control_t,
Element_Array => xcb.xcb_access_control_t_array,
Default_Terminator => xcb.xcb_access_control_t'Val (0));
subtype xcb_access_control_t_Pointer is
C_xcb_access_control_t_Pointers.Pointer;
-- xcb_access_control_t_Pointer_Array
--
type xcb_access_control_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_access_control_t_Pointer;
-- xcb_close_down_t_Pointer
--
package C_xcb_close_down_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_close_down_t,
Element_Array => xcb.xcb_close_down_t_array,
Default_Terminator => xcb.xcb_close_down_t'Val (0));
subtype xcb_close_down_t_Pointer is C_xcb_close_down_t_Pointers.Pointer;
-- xcb_close_down_t_Pointer_Array
--
type xcb_close_down_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_close_down_t_Pointer;
-- xcb_kill_t_Pointer
--
package C_xcb_kill_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_kill_t,
Element_Array => xcb.xcb_kill_t_array,
Default_Terminator => xcb.xcb_kill_t'Val (0));
subtype xcb_kill_t_Pointer is C_xcb_kill_t_Pointers.Pointer;
-- xcb_kill_t_Pointer_Array
--
type xcb_kill_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_kill_t_Pointer;
-- xcb_screen_saver_t_Pointer
--
package C_xcb_screen_saver_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_screen_saver_t,
Element_Array => xcb.xcb_screen_saver_t_array,
Default_Terminator => xcb.xcb_screen_saver_t'Val (0));
subtype xcb_screen_saver_t_Pointer is C_xcb_screen_saver_t_Pointers.Pointer;
-- xcb_screen_saver_t_Pointer_Array
--
type xcb_screen_saver_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_screen_saver_t_Pointer;
-- xcb_mapping_status_t_Pointer
--
package C_xcb_mapping_status_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_mapping_status_t,
Element_Array => xcb.xcb_mapping_status_t_array,
Default_Terminator => xcb.xcb_mapping_status_t'Val (0));
subtype xcb_mapping_status_t_Pointer is
C_xcb_mapping_status_t_Pointers.Pointer;
-- xcb_mapping_status_t_Pointer_Array
--
type xcb_mapping_status_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_mapping_status_t_Pointer;
-- xcb_map_index_t_Pointer
--
package C_xcb_map_index_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_map_index_t,
Element_Array => xcb.xcb_map_index_t_array,
Default_Terminator => xcb.xcb_map_index_t'Val (0));
subtype xcb_map_index_t_Pointer is C_xcb_map_index_t_Pointers.Pointer;
-- xcb_map_index_t_Pointer_Array
--
type xcb_map_index_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_map_index_t_Pointer;
-- xcb_render_pict_type_t_Pointer
--
package C_xcb_render_pict_type_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_pict_type_t,
Element_Array => xcb.xcb_render_pict_type_t_array,
Default_Terminator => xcb.xcb_render_pict_type_t'Val (0));
subtype xcb_render_pict_type_t_Pointer is
C_xcb_render_pict_type_t_Pointers.Pointer;
-- xcb_render_pict_type_t_Pointer_Array
--
type xcb_render_pict_type_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_pict_type_t_Pointer;
-- xcb_render_picture_enum_t_Pointer
--
package C_xcb_render_picture_enum_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_picture_enum_t,
Element_Array => xcb.xcb_render_picture_enum_t_array,
Default_Terminator => xcb.xcb_render_picture_enum_t'Val (0));
subtype xcb_render_picture_enum_t_Pointer is
C_xcb_render_picture_enum_t_Pointers.Pointer;
-- xcb_render_picture_enum_t_Pointer_Array
--
type xcb_render_picture_enum_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_picture_enum_t_Pointer;
-- xcb_render_pict_op_t_Pointer
--
package C_xcb_render_pict_op_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_pict_op_t,
Element_Array => xcb.xcb_render_pict_op_t_array,
Default_Terminator => xcb.xcb_render_pict_op_t'Val (0));
subtype xcb_render_pict_op_t_Pointer is
C_xcb_render_pict_op_t_Pointers.Pointer;
-- xcb_render_pict_op_t_Pointer_Array
--
type xcb_render_pict_op_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_pict_op_t_Pointer;
-- xcb_render_poly_edge_t_Pointer
--
package C_xcb_render_poly_edge_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_poly_edge_t,
Element_Array => xcb.xcb_render_poly_edge_t_array,
Default_Terminator => xcb.xcb_render_poly_edge_t'Val (0));
subtype xcb_render_poly_edge_t_Pointer is
C_xcb_render_poly_edge_t_Pointers.Pointer;
-- xcb_render_poly_edge_t_Pointer_Array
--
type xcb_render_poly_edge_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_poly_edge_t_Pointer;
-- xcb_render_poly_mode_t_Pointer
--
package C_xcb_render_poly_mode_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_poly_mode_t,
Element_Array => xcb.xcb_render_poly_mode_t_array,
Default_Terminator => xcb.xcb_render_poly_mode_t'Val (0));
subtype xcb_render_poly_mode_t_Pointer is
C_xcb_render_poly_mode_t_Pointers.Pointer;
-- xcb_render_poly_mode_t_Pointer_Array
--
type xcb_render_poly_mode_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_poly_mode_t_Pointer;
-- xcb_render_cp_t_Pointer
--
package C_xcb_render_cp_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_cp_t,
Element_Array => xcb.xcb_render_cp_t_array,
Default_Terminator => xcb.xcb_render_cp_t'Val (0));
subtype xcb_render_cp_t_Pointer is C_xcb_render_cp_t_Pointers.Pointer;
-- xcb_render_cp_t_Pointer_Array
--
type xcb_render_cp_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_cp_t_Pointer;
-- xcb_render_sub_pixel_t_Pointer
--
package C_xcb_render_sub_pixel_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_sub_pixel_t,
Element_Array => xcb.xcb_render_sub_pixel_t_array,
Default_Terminator => xcb.xcb_render_sub_pixel_t'Val (0));
subtype xcb_render_sub_pixel_t_Pointer is
C_xcb_render_sub_pixel_t_Pointers.Pointer;
-- xcb_render_sub_pixel_t_Pointer_Array
--
type xcb_render_sub_pixel_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_sub_pixel_t_Pointer;
-- xcb_render_repeat_t_Pointer
--
package C_xcb_render_repeat_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_repeat_t,
Element_Array => xcb.xcb_render_repeat_t_array,
Default_Terminator => xcb.xcb_render_repeat_t'Val (0));
subtype xcb_render_repeat_t_Pointer is
C_xcb_render_repeat_t_Pointers.Pointer;
-- xcb_render_repeat_t_Pointer_Array
--
type xcb_render_repeat_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_repeat_t_Pointer;
-- xcb_render_glyph_t_Pointer
--
package C_xcb_render_glyph_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_glyph_t,
Element_Array => xcb.xcb_render_glyph_t_array,
Default_Terminator => 0);
subtype xcb_render_glyph_t_Pointer is C_xcb_render_glyph_t_Pointers.Pointer;
-- xcb_render_glyph_t_Pointer_Array
--
type xcb_render_glyph_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_glyph_t_Pointer;
-- xcb_render_glyphset_t_Pointer
--
package C_xcb_render_glyphset_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_glyphset_t,
Element_Array => xcb.xcb_render_glyphset_t_array,
Default_Terminator => 0);
subtype xcb_render_glyphset_t_Pointer is
C_xcb_render_glyphset_t_Pointers.Pointer;
-- xcb_render_glyphset_t_Pointer_Array
--
type xcb_render_glyphset_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_glyphset_t_Pointer;
-- xcb_render_picture_t_Pointer
--
package C_xcb_render_picture_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_picture_t,
Element_Array => xcb.xcb_render_picture_t_array,
Default_Terminator => 0);
subtype xcb_render_picture_t_Pointer is
C_xcb_render_picture_t_Pointers.Pointer;
-- xcb_render_picture_t_Pointer_Array
--
type xcb_render_picture_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_picture_t_Pointer;
-- xcb_render_pictformat_t_Pointer
--
package C_xcb_render_pictformat_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_pictformat_t,
Element_Array => xcb.xcb_render_pictformat_t_array,
Default_Terminator => 0);
subtype xcb_render_pictformat_t_Pointer is
C_xcb_render_pictformat_t_Pointers.Pointer;
-- xcb_render_pictformat_t_Pointer_Array
--
type xcb_render_pictformat_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_pictformat_t_Pointer;
-- xcb_render_fixed_t_Pointer
--
package C_xcb_render_fixed_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_fixed_t,
Element_Array => xcb.xcb_render_fixed_t_array,
Default_Terminator => 0);
subtype xcb_render_fixed_t_Pointer is C_xcb_render_fixed_t_Pointers.Pointer;
-- xcb_render_fixed_t_Pointer_Array
--
type xcb_render_fixed_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_fixed_t_Pointer;
-- iovec_Pointer
--
package C_iovec_Pointers is new interfaces.c.Pointers
(Index => interfaces.c.size_t,
Element => xcb.iovec,
element_Array => xcb.iovec_Array,
default_Terminator => 0);
subtype iovec_Pointer is C_iovec_Pointers.Pointer;
-- iovec_Pointer_Array
--
type iovec_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers.iovec_Pointer;
-- xcb_send_request_flags_t_Pointer
--
package C_xcb_send_request_flags_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_send_request_flags_t,
Element_Array => xcb.xcb_send_request_flags_t_array,
Default_Terminator => xcb.xcb_send_request_flags_t'Val (0));
subtype xcb_send_request_flags_t_Pointer is
C_xcb_send_request_flags_t_Pointers.Pointer;
-- xcb_send_request_flags_t_Pointer_Array
--
type xcb_send_request_flags_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_send_request_flags_t_Pointer;
-- xcb_pict_format_t_Pointer
--
package C_xcb_pict_format_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_pict_format_t,
Element_Array => xcb.xcb_pict_format_t_array,
Default_Terminator => xcb.xcb_pict_format_t'Val (0));
subtype xcb_pict_format_t_Pointer is C_xcb_pict_format_t_Pointers.Pointer;
-- xcb_pict_format_t_Pointer_Array
--
type xcb_pict_format_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_pict_format_t_Pointer;
-- xcb_pict_standard_t_Pointer
--
package C_xcb_pict_standard_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_pict_standard_t,
Element_Array => xcb.xcb_pict_standard_t_array,
Default_Terminator => xcb.xcb_pict_standard_t'Val (0));
subtype xcb_pict_standard_t_Pointer is
C_xcb_pict_standard_t_Pointers.Pointer;
-- xcb_pict_standard_t_Pointer_Array
--
type xcb_pict_standard_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_pict_standard_t_Pointer;
-- xcb_render_util_composite_text_stream_t_Pointer
--
package C_xcb_render_util_composite_text_stream_t_Pointers is new interfaces
.c
.Pointers
(Index => interfaces.c.size_t,
Element => xcb.xcb_render_util_composite_text_stream_t,
element_Array => xcb.xcb_render_util_composite_text_stream_t_Array,
default_Terminator => 0);
subtype xcb_render_util_composite_text_stream_t_Pointer is
C_xcb_render_util_composite_text_stream_t_Pointers.Pointer;
-- xcb_render_util_composite_text_stream_t_Pointer_Array
--
type xcb_render_util_composite_text_stream_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_render_util_composite_text_stream_t_Pointer;
-- xcb_glx_pixmap_t_Pointer
--
package C_xcb_glx_pixmap_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_pixmap_t,
Element_Array => xcb.xcb_glx_pixmap_t_array,
Default_Terminator => 0);
subtype xcb_glx_pixmap_t_Pointer is C_xcb_glx_pixmap_t_Pointers.Pointer;
-- xcb_glx_pixmap_t_Pointer_Array
--
type xcb_glx_pixmap_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_pixmap_t_Pointer;
-- xcb_glx_context_t_Pointer
--
package C_xcb_glx_context_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_context_t,
Element_Array => xcb.xcb_glx_context_t_array,
Default_Terminator => 0);
subtype xcb_glx_context_t_Pointer is C_xcb_glx_context_t_Pointers.Pointer;
-- xcb_glx_context_t_Pointer_Array
--
type xcb_glx_context_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_context_t_Pointer;
-- xcb_glx_pbuffer_t_Pointer
--
package C_xcb_glx_pbuffer_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_pbuffer_t,
Element_Array => xcb.xcb_glx_pbuffer_t_array,
Default_Terminator => 0);
subtype xcb_glx_pbuffer_t_Pointer is C_xcb_glx_pbuffer_t_Pointers.Pointer;
-- xcb_glx_pbuffer_t_Pointer_Array
--
type xcb_glx_pbuffer_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_pbuffer_t_Pointer;
-- xcb_glx_window_t_Pointer
--
package C_xcb_glx_window_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_window_t,
Element_Array => xcb.xcb_glx_window_t_array,
Default_Terminator => 0);
subtype xcb_glx_window_t_Pointer is C_xcb_glx_window_t_Pointers.Pointer;
-- xcb_glx_window_t_Pointer_Array
--
type xcb_glx_window_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_window_t_Pointer;
-- xcb_glx_fbconfig_t_Pointer
--
package C_xcb_glx_fbconfig_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_fbconfig_t,
Element_Array => xcb.xcb_glx_fbconfig_t_array,
Default_Terminator => 0);
subtype xcb_glx_fbconfig_t_Pointer is C_xcb_glx_fbconfig_t_Pointers.Pointer;
-- xcb_glx_fbconfig_t_Pointer_Array
--
type xcb_glx_fbconfig_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_fbconfig_t_Pointer;
-- xcb_glx_drawable_t_Pointer
--
package C_xcb_glx_drawable_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_drawable_t,
Element_Array => xcb.xcb_glx_drawable_t_array,
Default_Terminator => 0);
subtype xcb_glx_drawable_t_Pointer is C_xcb_glx_drawable_t_Pointers.Pointer;
-- xcb_glx_drawable_t_Pointer_Array
--
type xcb_glx_drawable_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_drawable_t_Pointer;
-- xcb_glx_float32_t_Pointer
--
package C_xcb_glx_float32_t_Pointers is new interfaces.c.Pointers
(Index => interfaces.c.size_t,
Element => xcb.xcb_glx_float32_t,
element_Array => xcb.xcb_glx_float32_t_Array,
default_Terminator => 0.0);
subtype xcb_glx_float32_t_Pointer is C_xcb_glx_float32_t_Pointers.Pointer;
-- xcb_glx_float32_t_Pointer_Array
--
type xcb_glx_float32_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_float32_t_Pointer;
-- xcb_glx_float64_t_Pointer
--
package C_xcb_glx_float64_t_Pointers is new interfaces.c.Pointers
(Index => interfaces.c.size_t,
Element => xcb.xcb_glx_float64_t,
element_Array => xcb.xcb_glx_float64_t_Array,
default_Terminator => 0.0);
subtype xcb_glx_float64_t_Pointer is C_xcb_glx_float64_t_Pointers.Pointer;
-- xcb_glx_float64_t_Pointer_Array
--
type xcb_glx_float64_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_float64_t_Pointer;
-- xcb_glx_bool32_t_Pointer
--
package C_xcb_glx_bool32_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_bool32_t,
Element_Array => xcb.xcb_glx_bool32_t_array,
Default_Terminator => 0);
subtype xcb_glx_bool32_t_Pointer is C_xcb_glx_bool32_t_Pointers.Pointer;
-- xcb_glx_bool32_t_Pointer_Array
--
type xcb_glx_bool32_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_bool32_t_Pointer;
-- xcb_glx_context_tag_t_Pointer
--
package C_xcb_glx_context_tag_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_context_tag_t,
Element_Array => xcb.xcb_glx_context_tag_t_array,
Default_Terminator => 0);
subtype xcb_glx_context_tag_t_Pointer is
C_xcb_glx_context_tag_t_Pointers.Pointer;
-- xcb_glx_context_tag_t_Pointer_Array
--
type xcb_glx_context_tag_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_context_tag_t_Pointer;
-- xcb_glx_pbcet_t_Pointer
--
package C_xcb_glx_pbcet_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_pbcet_t,
Element_Array => xcb.xcb_glx_pbcet_t_array,
Default_Terminator => xcb.xcb_glx_pbcet_t'Val (0));
subtype xcb_glx_pbcet_t_Pointer is C_xcb_glx_pbcet_t_Pointers.Pointer;
-- xcb_glx_pbcet_t_Pointer_Array
--
type xcb_glx_pbcet_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_pbcet_t_Pointer;
-- xcb_glx_pbcdt_t_Pointer
--
package C_xcb_glx_pbcdt_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_pbcdt_t,
Element_Array => xcb.xcb_glx_pbcdt_t_array,
Default_Terminator => xcb.xcb_glx_pbcdt_t'Val (0));
subtype xcb_glx_pbcdt_t_Pointer is C_xcb_glx_pbcdt_t_Pointers.Pointer;
-- xcb_glx_pbcdt_t_Pointer_Array
--
type xcb_glx_pbcdt_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_pbcdt_t_Pointer;
-- xcb_glx_gc_t_Pointer
--
package C_xcb_glx_gc_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_gc_t,
Element_Array => xcb.xcb_glx_gc_t_array,
Default_Terminator => xcb.xcb_glx_gc_t'Val (0));
subtype xcb_glx_gc_t_Pointer is C_xcb_glx_gc_t_Pointers.Pointer;
-- xcb_glx_gc_t_Pointer_Array
--
type xcb_glx_gc_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_gc_t_Pointer;
-- xcb_glx_rm_t_Pointer
--
package C_xcb_glx_rm_t_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_rm_t,
Element_Array => xcb.xcb_glx_rm_t_array,
Default_Terminator => xcb.xcb_glx_rm_t'Val (0));
subtype xcb_glx_rm_t_Pointer is C_xcb_glx_rm_t_Pointers.Pointer;
-- xcb_glx_rm_t_Pointer_Array
--
type xcb_glx_rm_t_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.xcb_glx_rm_t_Pointer;
-- Display_Pointer
--
package C_Display_Pointers is new interfaces.c.Pointers
(Index => interfaces.c.size_t,
Element => xcb.Display,
element_Array => xcb.Display_Array,
default_Terminator => 0);
subtype Display_Pointer is C_Display_Pointers.Pointer;
-- Display_Pointer_Array
--
type Display_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers.Display_Pointer;
-- XEventQueueOwner_Pointer
--
package C_XEventQueueOwner_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.XEventQueueOwner,
Element_Array => xcb.XEventQueueOwner_array,
Default_Terminator => xcb.XEventQueueOwner'Val (0));
subtype XEventQueueOwner_Pointer is C_XEventQueueOwner_Pointers.Pointer;
-- XEventQueueOwner_Pointer_Array
--
type XEventQueueOwner_Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.Pointers
.XEventQueueOwner_Pointer;
end xcb.Pointers;
|
charlie5/cBound | Ada | 1,591 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_get_window_attributes_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
window : aliased xcb.xcb_window_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_window_attributes_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_window_attributes_request_t.Item,
Element_Array => xcb.xcb_get_window_attributes_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_window_attributes_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_window_attributes_request_t.Pointer,
Element_Array => xcb.xcb_get_window_attributes_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_get_window_attributes_request_t;
|
reznikmm/matreshka | Ada | 455 | ads |
package Types.Discretes.Enumerations is
pragma Preelaborate;
type Enumeration_Type is limited interface and Discrete_Type;
type Enumeration_Type_Access is access all Enumeration_Type'Class
with Storage_Size => 0;
not overriding function Is_Predefined_Character
(Self : Enumeration_Type) return Boolean is abstract;
-- One of predefined Character, Wide_Character, Wide_Wide_Character types.
end Types.Discretes.Enumerations;
|
stcarrez/ada-util | Ada | 4,565 | adb | -----------------------------------------------------------------------
-- util-concurrent-pools -- Concurrent Pools
-- Copyright (C) 2011, 2014, 2015, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Util.Concurrent.Pools is
-- ------------------------------
-- Get an element instance from the pool.
-- Wait until one instance gets available.
-- ------------------------------
procedure Get_Instance (From : in out Pool;
Item : out Element_Type;
Wait : in Duration := FOREVER) is
begin
if Wait < 0.0 then
From.List.Get_Instance (Item);
else
select
From.List.Get_Instance (Item);
or
delay Wait;
raise Timeout;
end select;
end if;
end Get_Instance;
-- ------------------------------
-- Put the element back to the pool.
-- ------------------------------
procedure Release (Into : in out Pool;
Item : in Element_Type) is
begin
Into.List.Release (Item);
end Release;
-- ------------------------------
-- Set the pool size.
-- ------------------------------
procedure Set_Size (Into : in out Pool;
Capacity : in Positive) is
begin
Into.List.Set_Size (Capacity);
end Set_Size;
-- ------------------------------
-- Get the number of available elements in the pool.
-- ------------------------------
procedure Get_Available (From : in out Pool;
Available : out Natural) is
begin
Available := From.List.Get_Available;
end Get_Available;
-- ------------------------------
-- Release the pool elements.
-- ------------------------------
overriding
procedure Finalize (Object : in out Pool) is
begin
Object.List.Set_Size (0);
end Finalize;
-- Pool of objects
protected body Protected_Pool is
-- ------------------------------
-- Get an element instance from the pool.
-- Wait until one instance gets available.
-- ------------------------------
entry Get_Instance (Item : out Element_Type) when Available > 0 is
begin
Item := Elements (Available);
Available := Available - 1;
end Get_Instance;
-- ------------------------------
-- Put the element back to the pool.
-- ------------------------------
procedure Release (Item : in Element_Type) is
begin
Available := Available + 1;
Elements (Available) := Item;
end Release;
-- ------------------------------
-- Set the pool size.
-- ------------------------------
procedure Set_Size (Capacity : in Natural) is
procedure Free is new Ada.Unchecked_Deallocation (Element_Array, Element_Array_Access);
begin
if Capacity = 0 then
Free (Elements);
elsif Elements = null then
Elements := new Element_Array (1 .. Capacity);
else
declare
New_Array : constant Element_Array_Access := new Element_Array (1 .. Capacity);
begin
if Capacity > Elements'Size then
New_Array (1 .. Elements'Last) := Elements (1 .. Elements'Last);
else
New_Array (1 .. Capacity) := Elements (1 .. Capacity);
end if;
Free (Elements);
Elements := New_Array;
end;
end if;
end Set_Size;
-- ------------------------------
-- Get the number of available elements.
-- ------------------------------
function Get_Available return Natural is
begin
return Available;
end Get_Available;
end Protected_Pool;
end Util.Concurrent.Pools;
|
faelys/natools | Ada | 1,759 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2013-2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.References.Tools is
function Is_Consistent (Left, Right : Reference) return Boolean is
begin
return (Left.Data = Right.Data) = (Left.Count = Right.Count);
end Is_Consistent;
function Is_Valid (Ref : Reference) return Boolean is
begin
return (Ref.Data = null) = (Ref.Count = null);
end Is_Valid;
function Count (Ref : Reference) return Natural is
begin
if Ref.Count /= null then
return Ref.Count.Get_Value;
else
return 0;
end if;
end Count;
end Natools.References.Tools;
|
reznikmm/matreshka | Ada | 7,120 | 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.Index_Entry_Page_Number_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Index_Entry_Page_Number_Element_Node is
begin
return Self : Text_Index_Entry_Page_Number_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_Index_Entry_Page_Number_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_Index_Entry_Page_Number
(ODF.DOM.Text_Index_Entry_Page_Number_Elements.ODF_Text_Index_Entry_Page_Number_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_Index_Entry_Page_Number_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Index_Entry_Page_Number_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Index_Entry_Page_Number_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_Index_Entry_Page_Number
(ODF.DOM.Text_Index_Entry_Page_Number_Elements.ODF_Text_Index_Entry_Page_Number_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_Index_Entry_Page_Number_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_Index_Entry_Page_Number
(Visitor,
ODF.DOM.Text_Index_Entry_Page_Number_Elements.ODF_Text_Index_Entry_Page_Number_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.Index_Entry_Page_Number_Element,
Text_Index_Entry_Page_Number_Element_Node'Tag);
end Matreshka.ODF_Text.Index_Entry_Page_Number_Elements;
|
AdaCore/langkit | Ada | 1,597 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libfoolang.Analysis; use Libfoolang.Analysis;
with Libfoolang.Common; use Libfoolang.Common;
procedure Main is
Ctx : constant Analysis_Context := Create_Context;
U : constant Analysis_Unit := Ctx.Get_From_Buffer
(Filename => "main.txt",
Buffer =>
"cons1 = 100" & ASCII.LF
& "cons2 = 200" & ASCII.LF
& "def foo(a=10 b=20 c=cons1)" & ASCII.LF
& "def bar(x=99 y=cons2)" & ASCII.LF
& "foo(1 2 3)" & ASCII.LF
& "bar(x y)" & ASCII.LF);
C : Call_Expr;
E : Expr;
begin
if U.Has_Diagnostics then
for D of U.Diagnostics loop
Put_Line (U.Format_GNU_Diagnostic (D));
end loop;
raise Program_Error;
end if;
for N of U.Root.Children loop
if N.Kind = Foo_Call_Expr then
C := N.As_Call_Expr;
Put_Line ("== " & C.Image & " ==");
for Id_Char of String'("abcdexyz") loop
declare
Id : constant String := (1 => Id_Char);
begin
Put_Line (Id & ":");
E := C.P_Get_Arg (To_Unbounded_Text (To_Text (Id)));
Put_Line (" (arg): "
& (if E.Is_Null then "None" else Image (E.Text)));
E := C.P_Get_Arg_Expr (To_Unbounded_Text (To_Text (Id)));
Put_Line (" (expr): "
& (if E.Is_Null then "None" else Image (E.Text)));
end;
end loop;
New_Line;
end if;
end loop;
end Main;
|
AdaCore/Ada_Drivers_Library | Ada | 2,829 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
separate (RISCV.CSR_Generic)
procedure Write_CSR_64 (Val : HAL.UInt64) is
procedure W_Low is new Write_CSR (Reg_Name, UInt32);
procedure W_High is new Write_CSR (Reg_Name & "h", UInt32);
begin
-- First write 0 to the low register to avoid overflow while we write the
-- high register.
W_Low (0);
W_High (UInt32 (Shift_Right (Val, 32) and 16#FFFF_FFFF#));
W_Low (UInt32 (Val and 16#FFFF_FFFF#));
end Write_CSR_64;
|
mhanuel26/ada-enet | Ada | 8,314 | ads | -----------------------------------------------------------------------
-- net-ntp -- NTP Network utilities
-- 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 Ada.Real_Time;
with Interfaces; use Interfaces;
with Net.Interfaces;
with Net.Buffers;
with Net.Sockets.Udp;
-- == NTP Client ==
-- The NTP client is used to retrieve the time by using the NTP protocol and keep the local
-- time synchronized with the NTP server. The NTP client does not maintain the date but allows
-- to retrieve the NTP reference information which together with the Ada monotonic time can
-- be used to get the current date.
--
-- An NTP client is associated with a particular NTP server. An application can use several
-- NTP client instance to synchronize with several NTP server and then choose the best
-- NTP reference for its date.
--
-- === Initialization ===
-- The NTP client is represented by the <tt>Client</tt> tagged type. An instance must be
-- declared for the management of the NTP state machine:
--
-- Client : Net.NTP.Client;
--
-- The NTP client is then initialized by giving the network interface and the NTP server to use:
--
-- Ntp_Server : Net.Ip_Addr := ...;
-- ...
-- Client.Initialize (Ifnet'Access, Ntp_Server);
--
-- === Processing ===
-- The NTP synchronisation is an asynchronous process that must be run continuously.
-- The <tt>Process</tt> procedure is responsible for sending the NTP client request to the
-- server on a regular basis. The <tt>Receive</tt> procedure will be called by the UDP stack
-- when the NTP server response is received. The NTP reference is computed when a correct
-- NTP server response is received. The state and NTP reference for the NTP synchronization
-- is maintained by a protected type held by the <tt>Client</tt> tagged type.
--
-- The <tt>Process</tt> procedure should be called to initiate the NTP request to the server
-- and then periodically synchronize with the server. The operation returns a time in the future
-- that indicates the deadline time for the next call. It is acceptable to call this operation
-- more often than necessary.
--
-- Ntp_Deadline : Ada.Real_Time.Time;
-- ..
-- Client.Process (Ntp_Deadline);
--
-- === NTP Date ===
-- The NTP reference information is retrieved by using the <tt>Get_Reference</tt> operation
-- which returns the NTP date together with the status and delay information between the client
-- and the server.
--
-- Ref : Net.NTP.NTP_Reference := Client.Get_Reference;
-- Now : Net.NTP.NTP_Timestamp;
--
-- Before using the NTP reference, it is necessary to check the status. The <tt>SYNCED</tt>
-- and <tt>RESYNC</tt> are the two possible states which indicate a successful synchronization.
-- The current date and time is obtained by the <tt>Get_Time</tt> function which uses the
-- NTP reference and the Ada monotonic time to return the current date (in NTP format).
--
-- if Ref.Status in Net.NTP.SYNCED | Net.NTP.RESYNC then
-- Now := Net.NTP.Get_Time (Ref);
-- end if;
--
-- The NTP date is a GMT time whose first epoch date is January 1st 1900.
package Net.NTP is
-- The NTP UDP port number.
NTP_PORT : constant Net.Uint16 := 123;
ONE_SEC : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Seconds (1);
ONE_USEC : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Microseconds (1);
-- The NTP client status.
type Status_Type is (NOSERVER, INIT, WAITING, SYNCED, RESYNC, TIMEOUT);
-- The NTP timestamp as defined by RFC 5905. The NTP epoch is Jan 1st 1900 and
-- NTP subseconds use the full 32-bit range. When bit 31 of the seconds is cleared,
-- we consider this as the second epoch which starts in 2036.
type NTP_Timestamp is record
Seconds : Net.Uint32 := 0;
Sub_Seconds : Net.Uint32 := 0;
end record;
-- Add a time span to the NTP timestamp.
function "+" (Left : in NTP_Timestamp;
Right : in Ada.Real_Time.Time_Span) return NTP_Timestamp;
-- The NTP reference indicates the NTP synchronisation with the NTP server.
-- The reference indicates the NTP time at a given point in the past when the NTP
-- synchronization is obtained. When several NTP servers are used, the NTP references
-- should be compared and the NTP server with the lowest <tt>Delta_Time</tt> should be
-- used.
--
-- The current date is obtained with the following forumla:
--
-- Date := Offset_Time + (Ada.Realtime.Clock - Offset_Ref)
type NTP_Reference is record
Status : Status_Type := NOSERVER;
Offset_Time : NTP_Timestamp;
Offset_Ref : Ada.Real_Time.Time;
Delta_Time : Ada.Real_Time.Time_Span;
end record;
-- Get the current date from the Ada monotonic time and the NTP reference.
function Get_Time (Ref : in NTP_Reference) return NTP_Timestamp;
type Client is new Net.Sockets.Udp.Socket with private;
-- Get the NTP client status.
function Get_Status (Request : in Client) return Status_Type;
-- Get the NTP time.
function Get_Time (Request : in out Client) return NTP_Timestamp;
-- Get the delta time between the NTP server and us.
function Get_Delta (Request : in out Client) return Integer_64;
-- Get the NTP reference information.
function Get_Reference (Request : in out Client) return NTP_Reference;
-- Initialize the NTP client to use the given NTP server.
procedure Initialize (Request : access Client;
Ifnet : access Net.Interfaces.Ifnet_Type'Class;
Server : in Net.Ip_Addr;
Port : in Net.Uint16 := NTP_PORT);
-- Process the NTP client.
-- Return in <tt>Next_Call</tt> the deadline time for the next call.
procedure Process (Request : in out Client;
Next_Call : out Ada.Real_Time.Time);
-- Receive the NTP response from the NTP server and update the NTP state machine.
overriding
procedure Receive (Request : in out Client;
From : in Net.Sockets.Sockaddr_In;
Packet : in out Net.Buffers.Buffer_Type);
private
protected type Machine is
-- Get the NTP status.
function Get_Status return Status_Type;
-- Get the delta time between the NTP server and us.
function Get_Delta return Integer_64;
-- Get the NTP reference information.
function Get_Reference return NTP_Reference;
-- Get the current NTP timestamp with the corresponding monitonic time.
procedure Get_Timestamp (Time : out NTP_Timestamp;
Now : out Ada.Real_Time.Time);
-- Set the status time.
procedure Set_Status (Value : in Status_Type);
-- Extract the timestamp from the NTP server response and update the reference time.
procedure Extract_Timestamp (Buf : in out Net.Buffers.Buffer_Type);
-- Insert in the packet the timestamp references for the NTP client packet.
procedure Put_Timestamp (Buf : in out Net.Buffers.Buffer_Type);
private
Status : Status_Type := NOSERVER;
Ref_Time : NTP_Timestamp;
Orig_Time : NTP_Timestamp;
Rec_Time : NTP_Timestamp;
Offset_Time : NTP_Timestamp;
Transmit_Time : NTP_Timestamp;
Offset_Ref : Ada.Real_Time.Time;
Delta_Time : Integer_64;
end Machine;
type Client is new Net.Sockets.Udp.Socket with record
Server : Net.Ip_Addr := (0, 0, 0, 0);
Deadline : Ada.Real_Time.Time;
State : Machine;
end record;
end Net.NTP;
|
reznikmm/matreshka | Ada | 7,040 | adb | ------------------------------------------------------------------------------
-- --
-- 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;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.UML.Behavioral_Features;
with AMF.Visitors.Standard_Profile_L2_Iterators;
with AMF.Visitors.Standard_Profile_L2_Visitors;
package body AMF.Internals.Standard_Profile_L2_Destroies is
---------------------------------
-- Get_Base_Behavioral_Feature --
---------------------------------
overriding function Get_Base_Behavioral_Feature
(Self : not null access constant Standard_Profile_L2_Destroy_Proxy)
return AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access is
begin
return
AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Behavioral_Feature
(Self.Element)));
end Get_Base_Behavioral_Feature;
---------------------------------
-- Set_Base_Behavioral_Feature --
---------------------------------
overriding procedure Set_Base_Behavioral_Feature
(Self : not null access Standard_Profile_L2_Destroy_Proxy;
To : AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Behavioral_Feature
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Base_Behavioral_Feature;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant Standard_Profile_L2_Destroy_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Enter_Destroy
(AMF.Standard_Profile_L2.Destroies.Standard_Profile_L2_Destroy_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant Standard_Profile_L2_Destroy_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Leave_Destroy
(AMF.Standard_Profile_L2.Destroies.Standard_Profile_L2_Destroy_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant Standard_Profile_L2_Destroy_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then
AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class
(Iterator).Visit_Destroy
(Visitor,
AMF.Standard_Profile_L2.Destroies.Standard_Profile_L2_Destroy_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.Standard_Profile_L2_Destroies;
|
stcarrez/ada-wiki | Ada | 2,958 | adb | -----------------------------------------------------------------------
-- wiki-helpers-parser -- Generic procedure for the wiki parser
-- Copyright (C) 2016, 2018, 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 Wiki.Helpers;
with Wiki.Streams;
procedure Wiki.Helpers.Parser (Engine : in out Engine_Type;
Content : in Element_Type;
Doc : in out Wiki.Documents.Document) is
type Wide_Input is new Wiki.Streams.Input_Stream with record
Pos : Positive;
Len : Natural;
end record;
-- Read the input stream and fill the `Into` buffer until either it is full or
-- we reach the end of line. Returns in `Last` the last valid position in the
-- `Into` buffer. When there is no character to read, return True in
-- the `Eof` indicator.
overriding
procedure Read (Input : in out Wide_Input;
Into : in out Wiki.Strings.WString;
Last : out Natural;
Eof : out Boolean);
overriding
procedure Read (Input : in out Wide_Input;
Into : in out Wiki.Strings.WString;
Last : out Natural;
Eof : out Boolean) is
Pos : Natural := Into'First;
Char : Wiki.Strings.WChar;
begin
Eof := False;
while Pos <= Into'Last loop
if Input.Pos <= Input.Len then
Element (Content, Input.Pos, Char);
else
Eof := True;
exit;
end if;
Into (Pos) := Char;
Pos := Pos + 1;
exit when Char = Helpers.LF;
if Char = Helpers.CR then
exit when Input.Pos > Input.Len;
-- Look for a possible LF and drop it.
declare
Read_Pos : constant Natural := Input.Pos;
begin
Element (Content, Input.Pos, Char);
if Char /= Helpers.LF then
Input.Pos := Read_Pos;
end if;
exit;
end;
end if;
end loop;
Last := Pos - 1;
end Read;
Buffer : aliased Wide_Input;
begin
Buffer.Pos := 1;
Buffer.Len := Length (Content);
Parse (Engine, Buffer'Unchecked_Access, Doc);
end Wiki.Helpers.Parser;
|
AdaCore/Ada_Drivers_Library | Ada | 8,669 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with STM32.Board; use STM32.Board;
with Bitmapped_Drawing;
with Bitmap_Color_Conversion; use Bitmap_Color_Conversion;
package body LCD_Std_Out is
-- We don't make the current font visible to clients because changing it
-- requires recomputation of the screen layout (eg the char height) and
-- issuance of commands to the LCD component driver (eg to refill).
Current_Font : BMP_Font := Default_Font;
Char_Width : Natural := BMP_Fonts.Char_Width (Current_Font);
Char_Height : Natural := BMP_Fonts.Char_Height (Current_Font);
Max_Width : Natural := LCD_Natural_Width - Char_Width;
-- The last place on the current "line" on the LCD where a char of the
-- current font size can be printed
Max_Height : Natural := LCD_Natural_Height - Char_Height;
-- The last "line" on the LCD where a char of this current font size can be
-- printed
Current_Y : Natural := 0;
-- The current "line" that the text will appear upon. Note this wraps
-- around to the top of the screen.
Char_Count : Natural := 0;
-- The number of characters currently printed on the current line
Initialized : Boolean := False;
procedure Draw_Char (X, Y : Natural; Msg : Character);
-- Convenience routine for call Drawing.Draw_Char
procedure Recompute_Screen_Dimensions (Font : BMP_Font);
-- Determins the max height and width for the specified font, given the
-- current LCD orientation
procedure Check_Initialized with Inline;
-- Ensures that the LCD display is initialized and DMA2D
-- is up and running
procedure Internal_Put (Msg : String);
-- Puts a new String in the frame buffer
procedure Internal_Put (Msg : Character);
-- Puts a new character in the frame buffer.
-----------------------
-- Check_Initialized --
-----------------------
procedure Check_Initialized is
begin
if Initialized then
return;
end if;
Initialized := True;
if Display.Initialized then
-- Ensure we use polling here: LCD_Std_Out may be called from the
-- Last chance handler, and we don't want unexpected tasks or
-- protected objects calling an entry not meant for that
Display.Set_Mode (HAL.Framebuffer.Polling);
else
Display.Initialize (Mode => HAL.Framebuffer.Polling);
Display.Initialize_Layer (1, HAL.Bitmap.RGB_565);
Clear_Screen;
end if;
end Check_Initialized;
---------------------------------
-- Recompute_Screen_Dimensions --
---------------------------------
procedure Recompute_Screen_Dimensions (Font : BMP_Font) is
begin
Check_Initialized;
Char_Width := BMP_Fonts.Char_Width (Font);
Char_Height := BMP_Fonts.Char_Height (Font);
Max_Width := Display.Width - Char_Width - 1;
Max_Height := Display.Height - Char_Height - 1;
end Recompute_Screen_Dimensions;
--------------
-- Set_Font --
--------------
procedure Set_Font (To : in BMP_Font) is
begin
Current_Font := To;
Recompute_Screen_Dimensions (Current_Font);
end Set_Font;
---------------------
-- Set_Orientation --
---------------------
procedure Set_Orientation (To : in HAL.Framebuffer.Display_Orientation) is
begin
Display.Set_Orientation (To);
Recompute_Screen_Dimensions (Current_Font);
Clear_Screen;
end Set_Orientation;
------------------
-- Clear_Screen --
------------------
procedure Clear_Screen is
begin
Check_Initialized;
Display.Hidden_Buffer (1).Set_Source (Current_Background_Color);
Display.Hidden_Buffer (1).Fill;
Current_Y := 0;
Char_Count := 0;
Display.Update_Layer (1, True);
end Clear_Screen;
------------------
-- Internal_Put --
------------------
procedure Internal_Put (Msg : String) is
begin
for C of Msg loop
if C = ASCII.LF then
New_Line;
else
Internal_Put (C);
end if;
end loop;
end Internal_Put;
---------
-- Put --
---------
procedure Put (Msg : String) is
begin
Internal_Put (Msg);
Display.Update_Layer (1, True);
end Put;
---------------
-- Draw_Char --
---------------
procedure Draw_Char (X, Y : Natural; Msg : Character) is
begin
Check_Initialized;
Bitmapped_Drawing.Draw_Char
(Display.Hidden_Buffer (1).all,
Start => (X, Y),
Char => Msg,
Font => Current_Font,
Foreground =>
Bitmap_Color_To_Word (Display.Color_Mode (1),
Current_Text_Color),
Background =>
Bitmap_Color_To_Word (Display.Color_Mode (1),
Current_Background_Color));
end Draw_Char;
---------
-- Put --
---------
procedure Internal_Put (Msg : Character) is
begin
if Char_Count * Char_Width > Max_Width then
New_Line;
end if;
Draw_Char (Char_Count * Char_Width, Current_Y, Msg);
Char_Count := Char_Count + 1;
end Internal_Put;
---------
-- Put --
---------
procedure Put (Msg : Character) is
begin
Internal_Put (Msg);
Display.Update_Layer (1, True);
end Put;
--------------
-- New_Line --
--------------
procedure New_Line is
begin
Char_Count := 0; -- next char printed will be at the start of a new line
if Current_Y + Char_Height > Max_Height then
Current_Y := 0;
else
Current_Y := Current_Y + Char_Height;
end if;
end New_Line;
--------------
-- Put_Line --
--------------
procedure Put_Line (Msg : String) is
begin
Put (Msg);
New_Line;
end Put_Line;
---------
-- Put --
---------
procedure Put (X, Y : Natural; Msg : Character) is
begin
Draw_Char (X, Y, Msg);
Display.Update_Layer (1, True);
end Put;
---------
-- Put --
---------
procedure Put (X, Y : Natural; Msg : String) is
Count : Natural := 0;
Next_X : Natural;
begin
for C of Msg loop
Next_X := X + Count * Char_Width;
Draw_Char (Next_X, Y, C);
Count := Count + 1;
end loop;
Display.Update_Layer (1, True);
end Put;
end LCD_Std_Out;
|
reznikmm/matreshka | Ada | 34,294 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Classifiers;
with AMF.String_Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Information_Items;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors;
package AMF.Internals.UML_Information_Items is
type UML_Information_Item_Proxy is
limited new AMF.Internals.UML_Classifiers.UML_Classifier_Proxy
and AMF.UML.Information_Items.UML_Information_Item with null record;
overriding function Get_Represented
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of InformationItem::represented.
--
-- Determines the classifiers that will specify the structure and nature
-- of the information. An information item represents all its represented
-- classifiers.
overriding function Get_Attribute
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
overriding function Get_Collaboration_Use
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
overriding function Get_Feature
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
overriding function Get_General
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
overriding function Get_Generalization
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
overriding function Get_Inherited_Member
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
overriding function Get_Is_Abstract
(Self : not null access constant UML_Information_Item_Proxy)
return Boolean;
-- Getter of Classifier::isAbstract.
--
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding function Get_Is_Final_Specialization
(Self : not null access constant UML_Information_Item_Proxy)
return Boolean;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding procedure Set_Is_Final_Specialization
(Self : not null access UML_Information_Item_Proxy;
To : Boolean);
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access);
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Owned_Use_Case
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
overriding function Get_Powertype_Extent
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
overriding function Get_Redefined_Classifier
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
overriding function Get_Representation
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding procedure Set_Representation
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access);
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding function Get_Substitution
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access);
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Use_Case
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
overriding function Get_Element_Import
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Package
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Packages.UML_Package_Access;
-- Getter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding procedure Set_Package
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.Packages.UML_Package_Access);
-- Setter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Information_Item_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access);
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Template_Binding
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Information_Item_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Information_Item_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function All_Features
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
overriding function Conforms_To
(Self : not null access constant UML_Information_Item_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::conformsTo.
--
-- The query conformsTo() gives true for a classifier that defines a type
-- that conforms to another. This is used, for example, in the
-- specification of signature conformance for operations.
overriding function General
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
overriding function Has_Visibility_Of
(Self : not null access constant UML_Information_Item_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
overriding function Inherit
(Self : not null access constant UML_Information_Item_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inherit.
--
-- The query inherit() defines how to inherit a set of elements. Here the
-- operation is defined to inherit them all. It is intended to be
-- redefined in circumstances where inheritance is affected by
-- redefinition.
-- The inherit operation is overridden to exclude redefined properties.
overriding function Inheritable_Members
(Self : not null access constant UML_Information_Item_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
overriding function Inherited_Member
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant UML_Information_Item_Proxy)
return Boolean;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
overriding function May_Specialize_Type
(Self : not null access constant UML_Information_Item_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
overriding function Exclude_Collisions
(Self : not null access constant UML_Information_Item_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant UML_Information_Item_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant UML_Information_Item_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Information_Item_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Information_Item_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Conforms_To
(Self : not null access constant UML_Information_Item_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean;
-- Operation Type::conformsTo.
--
-- The query conformsTo() gives true for a type that conforms to another.
-- By default, two types do not conform to each other. This query is
-- intended to be redefined for specific conformance situations.
overriding function Is_Compatible_With
(Self : not null access constant UML_Information_Item_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UML_Information_Item_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Parameterable_Elements
(Self : not null access constant UML_Information_Item_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
overriding function Is_Consistent_With
(Self : not null access constant UML_Information_Item_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Information_Item_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding procedure Enter_Element
(Self : not null access constant UML_Information_Item_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Information_Item_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Information_Item_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Information_Items;
|
tum-ei-rcs/StratoX | Ada | 8,799 | adb | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath ([email protected])
with STM32.GPIO; use STM32.GPIO;
with STM32.Device;
with STM32.Board;
-- @summary
-- target-specific mapping of HIL for GPIO in Pixracer v1 board
package body HIL.GPIO with
SPARK_Mode => Off
is
subtype Dev_GPIO is STM32.GPIO.GPIO_Point; -- abbreviate the long name
-- SPI1_SCK : constant Dev_GPIO := STM32.Device.PA5;
-- SPI1_MISO : constant Dev_GPIO := STM32.Device.PA6;
-- SPI1_MOSI : constant Dev_GPIO := STM32.Device.PA7;
-- SPI1_CS_MS5611 : constant Dev_GPIO := STM32.Device.PD7; -- Baro
-- -- SPI1_CS_MPU6000 : constant Dev_GPIO := STM32.Device.PC2; -- Acc/Gyro
-- -- SPI1_CS_LSM303D : constant Dev_GPIO := STM32.Device.PC15; -- Acc/Mag
-- -- SPI1_CS_L3GD20H : constant Dev_GPIO := STM32.Device.PC13; -- Gyro
--
---------------------------------------------------------------
-- PIN DEFINITIONS OF THINGS THAT ARE NOT VISIBLE TO HIL USER
---------------------------------------------------------------
-- SPI2: FRAM + BARO
SPI2_SCK : constant Dev_GPIO := STM32.Device.PB10; -- OK
SPI2_MISO : constant Dev_GPIO := STM32.Device.PB14; -- OK
SPI2_MOSI : constant Dev_GPIO := STM32.Device.PB15; -- OK
SPI2_CS_FRAM : constant Dev_GPIO := STM32.Device.PD10; -- OK
SPI2_CS_BARO : constant Dev_GPIO := STM32.Device.PD7; -- OK
I2C1_SCL : constant Dev_GPIO := STM32.Device.PB8; -- OK
I2C1_SDA : constant Dev_GPIO := STM32.Device.PB9; -- OK
UART1_RX : constant Dev_GPIO := STM32.Device.PB7; -- OK -> wifi ESP8266
UART1_TX : constant Dev_GPIO := STM32.Device.PB6; -- OK
UART2_RX : constant Dev_GPIO := STM32.Device.PD6; -- OK -> telem1
UART2_TX : constant Dev_GPIO := STM32.Device.PD5; -- OK
UART3_RX : constant Dev_GPIO := STM32.Device.PD9; -- OK -> telem2
UART3_TX : constant Dev_GPIO := STM32.Device.PD8; -- OK
UART4_RX : constant Dev_GPIO := STM32.Device.PA1; -- OK -> gps
UART4_TX : constant Dev_GPIO := STM32.Device.PA0; -- OK
UART7_RX : constant Dev_GPIO := STM32.Device.PE7; -- OK -> console
UART7_TX : constant Dev_GPIO := STM32.Device.PE8; -- OK
-- USART8: FrSky input (UART over specific inverter)
Config_SPI1 : constant GPIO_Port_Configuration := (Mode => Mode_AF,
Output_Type => Push_Pull,
Speed => Speed_50MHz,
Resistors => Floating );
Config_SPI2 : constant GPIO_Port_Configuration := (Mode => Mode_AF,
Output_Type => Push_Pull,
Speed => Speed_50MHz,
Resistors => Floating );
Config_I2C1 : constant GPIO_Port_Configuration := (Mode => Mode_AF,
Output_Type => Open_Drain,
Speed => Speed_25MHz,
Resistors => Floating );
Config_UART : constant GPIO_Port_Configuration := (Mode => Mode_AF,
Output_Type => Push_Pull,
Speed => Speed_50MHz,
Resistors => Floating );
Config_In : constant GPIO_Port_Configuration := (Mode => Mode_In,
Output_Type => Push_Pull,
Speed => Speed_50MHz,
Resistors => Floating );
function map(Point : GPIO_Point_Type) return GPIO_Point is
( case Point is
when RED_LED => STM32.Board.Red,
when BLU_LED => STM32.Board.Blue,
when GRN_LED => STM32.Board.Green,
when SPI_CS_BARO => SPI2_CS_BARO,
-- when SPI_CS_MPU6000 => SPI1_CS_MPU6000,
-- when SPI_CS_LSM303D => SPI1_CS_LSM303D,
-- when SPI_CS_L3GD20H => SPI1_CS_L3GD20H,
when SPI_CS_FRAM => SPI2_CS_FRAM
-- when SPI_CS_EXT => SPI4_CS
);
procedure write (Point : GPIO_Point_Type; Signal : GPIO_Signal_Type) is
stm32_point : GPIO_Point := map( Point );
begin
case (Signal) is
when LOW => STM32.GPIO.Clear( stm32_point );
when HIGH => STM32.GPIO.Set( stm32_point );
end case;
end write;
procedure read (Point : GPIO_Point_Type; Signal : out GPIO_Signal_Type) is
stm32_point : constant GPIO_Point := map( Point );
begin
if STM32.GPIO.Set(stm32_point) then
Signal := HIGH;
else
Signal := LOW;
end if;
end read;
procedure configure is
Config_Out : constant GPIO_Port_Configuration := (
Mode => Mode_Out,
Output_Type => Push_Pull,
Speed => Speed_2MHz,
Resistors => Floating );
Config_Out_Buz : constant GPIO_Port_Configuration := (
Mode => Mode_AF,
Output_Type => Push_Pull,
Speed => Speed_50MHz,
Resistors => Floating);
begin
-- configure LEDs
Configure_IO (Points => (1 => map(RED_LED), 2 => map (BLU_LED), 3 => map (GRN_LED)), Config => Config_Out);
-- FIXME: this doesn't belong here.
Configure_IO (Points => (1 => STM32.Device.PA15), Config => Config_Out_Buz);
Configure_Alternate_Function (Points => (1 => STM32.Device.PA15), AF => GPIO_AF_TIM2); -- allow timer 2 to control buzzer
--------------------------------
-- SPU & CHIP SELECT
--------------------------------
-- configure SPI 2
Configure_IO (Points => (SPI2_SCK, SPI2_MISO, SPI2_MOSI), Config => Config_SPI2);
Configure_Alternate_Function (Points => (1 => SPI2_SCK, 2 => SPI2_MOSI, 3 => SPI2_MISO),
AF => GPIO_AF_SPI2);
-- configure Baro ChipSelect
Configure_IO (Point => map(SPI_CS_BARO), Config => Config_Out);
STM32.GPIO.Set (This => map(SPI_CS_BARO));
--
-- -- -- configure MPU6000 ChipSelect
-- -- Configure_IO( Point => map(SPI_CS_MPU6000), Config => Config_Out );
-- -- Point := map(SPI_CS_MPU6000);
-- -- STM32.GPIO.Set( This => Point );
-- --
-- -- -- configure LSM303D ChipSelect
-- -- Configure_IO( Point => map(SPI_CS_LSM303D), Config => Config_Out );
-- -- Point := map(SPI_CS_LSM303D);
-- -- STM32.GPIO.Set( This => Point );
-- --
-- -- -- configure L3GD20H ChipSelect
-- -- Configure_IO( Point => map(SPI_CS_L3GD20H), Config => Config_Out );
-- -- Point := map(SPI_CS_L3GD20H);
-- -- STM32.GPIO.Set( This => Point );
-- configure FRAM ChipSelect
Configure_IO (Point => map(SPI_CS_FRAM), Config => Config_Out);
STM32.GPIO.Set (This => map(SPI_CS_FRAM));
--------------------------------
-- I2C
--------------------------------
-- Configure_Alternate_Function (Points => (I2C1_SDA, I2C1_SCL),
-- AF => GPIO_AF_I2C);
-- Configure_IO (Points => (I2C1_SDA, I2C1_SCL), Config => Config_I2C1);
--------------------------------
-- UARTS
--------------------------------
-- configure UART 2 (Tele 1)
Configure_IO (Points => (UART2_RX, UART2_TX), Config => Config_UART);
Configure_Alternate_Function (Points => (UART2_RX, UART2_TX),
AF => GPIO_AF_USART2);
-- configure UART 3 (Tele 2)
Configure_IO (Points => (UART3_RX, UART3_TX), Config => Config_UART);
Configure_Alternate_Function (Points => (UART3_RX, UART3_TX),
AF => GPIO_AF_USART3);
-- configure UART 4 (GPS)
Configure_IO (Points => (UART4_RX, UART4_TX), Config => Config_UART);
Configure_Alternate_Function (Points => (UART4_RX, UART4_TX),
AF => GPIO_AF_USART4);
end configure;
procedure All_LEDs_Off renames STM32.Board.All_LEDs_Off;
procedure All_LEDs_On renames STM32.Board.All_LEDs_Off;
end HIL.GPIO;
|
zhmu/ananas | Ada | 194 | ads | with Warn10_Pkg; use Warn10_Pkg;
package Warn10 is
type My_Driver is new Root with record
Extra : Natural;
end record;
procedure Do_Something(Driver : My_Driver);
end Warn10;
|
reznikmm/matreshka | Ada | 3,989 | 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.Db_Description_Attributes;
package Matreshka.ODF_Db.Description_Attributes is
type Db_Description_Attribute_Node is
new Matreshka.ODF_Db.Abstract_Db_Attribute_Node
and ODF.DOM.Db_Description_Attributes.ODF_Db_Description_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Db_Description_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Db_Description_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Db.Description_Attributes;
|
PThierry/ewok-kernel | Ada | 24 | ads | ../stm32f439/soc-pwr.ads |
Letractively/ada-el | Ada | 1,341 | ads | -----------------------------------------------------------------------
-- el -- Expression Language
-- Copyright (C) 2009, 2010, 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 EL.Expressions.Nodes;
private package EL.Expressions.Parser is
pragma Preelaborate;
procedure Parse (Expr : in String;
Context : in ELContext'Class;
Result : out EL.Expressions.Nodes.ELNode_Access);
procedure Parse (Expr : in Wide_Wide_String;
Context : in ELContext'Class;
Result : out EL.Expressions.Nodes.ELNode_Access);
end EL.Expressions.Parser;
|
reznikmm/matreshka | Ada | 3,734 | 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_Decimal_Places_Attributes is
pragma Preelaborate;
type ODF_Draw_Decimal_Places_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Decimal_Places_Attribute_Access is
access all ODF_Draw_Decimal_Places_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Decimal_Places_Attributes;
|
annexi-strayline/AURA | Ada | 4,583 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Unbounded_Synchronized_Queues;
package body Workers.Reporting is
------------------
-- Report_Queue --
------------------
package SQI is new Ada.Containers.Synchronized_Queue_Interfaces
(Element_Type => Work_Report);
package USQ is new Ada.Containers.Unbounded_Synchronized_Queues
(Queue_Interfaces => SQI);
Report_Queue: USQ.Queue;
-------------------
-- Submit_Report --
-------------------
procedure Submit_Report (Report: Work_Report) is
begin
Report_Queue.Enqueue (Report);
end Submit_Report;
-----------------------
-- Available_Reports --
-----------------------
function Available_Reports return Count_Type is
(Report_Queue.Current_Use);
---------------------
-- Retrieve_Report --
---------------------
function Retrieve_Report return Work_Report is
begin
return Report: Work_Report do
Report_Queue.Dequeue (Report);
end return;
end Retrieve_Report;
end Workers.Reporting;
|
reznikmm/matreshka | Ada | 6,740 | adb | ------------------------------------------------------------------------------
-- --
-- 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;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.UML.Usages;
with AMF.Visitors.Standard_Profile_L2_Iterators;
with AMF.Visitors.Standard_Profile_L2_Visitors;
package body AMF.Internals.Standard_Profile_L2_Sends is
--------------------
-- Get_Base_Usage --
--------------------
overriding function Get_Base_Usage
(Self : not null access constant Standard_Profile_L2_Send_Proxy)
return AMF.UML.Usages.UML_Usage_Access is
begin
return
AMF.UML.Usages.UML_Usage_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Usage
(Self.Element)));
end Get_Base_Usage;
--------------------
-- Set_Base_Usage --
--------------------
overriding procedure Set_Base_Usage
(Self : not null access Standard_Profile_L2_Send_Proxy;
To : AMF.UML.Usages.UML_Usage_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Usage
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Base_Usage;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant Standard_Profile_L2_Send_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Enter_Send
(AMF.Standard_Profile_L2.Sends.Standard_Profile_L2_Send_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant Standard_Profile_L2_Send_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Leave_Send
(AMF.Standard_Profile_L2.Sends.Standard_Profile_L2_Send_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant Standard_Profile_L2_Send_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then
AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class
(Iterator).Visit_Send
(Visitor,
AMF.Standard_Profile_L2.Sends.Standard_Profile_L2_Send_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.Standard_Profile_L2_Sends;
|
adamkruszewski/qweyboard | Ada | 5,503 | adb | package body Qweyboard is
Return_Combo : Key_Sets.Set;
Backspace_Combo : Key_Sets.Set;
task body Softboard is
Current_Timeout : Duration;
Pressed : Key_Sets.Set;
Released : Key_Sets.Set;
Last_Output : Output;
procedure Erase is
begin
Pressed.Clear;
Released.Clear;
case Last_Output.Variant is
when Syllable =>
if Last_Output.Continues_Word then
Last_Output := (Erase, Length (Last_Output.Text));
Output_Backend.Output.Erase (Last_Output.Amount);
else
Last_Output.Continues_Word := True;
Output_Backend.Output.Erase (1);
end if;
when others =>
Last_Output := (Erase, 1);
Output_Backend.Output.Erase (1);
end case;
end Erase;
procedure Commit is
Result : Unbounded_Wide_Wide_String;
use type Key_Sets.Set;
begin
Result := Languages.User_Language.Decode (Released);
Translate (Result, Character_Maps.Lower_Case_Map);
if Released = Return_Combo then
Log.Warning ("[Qweyboard] Return press not implemented");
elsif Released = Backspace_Combo then
Log.Chat ("[Qweyboard] Received backspace combination CR-RC; erasing");
Erase;
elsif Length (Result) > 0 then
Last_Output := (Syllable, Result, Released.Contains (NOSP));
Output_Backend.Output.Enter (From_Unbounded (Result), Released.Contains (NOSP));
end if;
Released.Clear;
end Commit;
begin
Log.Chat ("[Qweyboard] Initialised, waiting for go signal");
accept Ready_Wait;
loop
select
accept Configure (Settings : Configuration.Settings) do
Current_Timeout := Settings.Timeout;
Log.Chat ("[Qweyboard] Setting timeout to" & W (Duration'Image (Current_Timeout)));
end Configure;
or
accept Handle (Event : Key_Event) do
Log.Chat ("[Qweyboard] Handling key event");
if Event.Key = SUSP then
Last_Output := (Variant => Nothing);
Commit;
else
case Event.Key_Event_Variant is
when Key_Press =>
Pressed.Include (Event.Key);
when Key_Release =>
Pressed.Exclude (Event.Key);
-- If only this key was pressed, and no other key is in the chord
-- These are some hardcoded special cases – doesn't feel worth it
-- to make 'em dynamic at the moment
declare
Special_Used : Boolean := False;
begin
if Released.Is_Empty and Pressed.Is_Empty then
if Event.Key = NOSP then
Last_Output := (Syllable, To_Unbounded (" "), False);
Output_Backend.Output.Enter (From_Unbounded (Last_Output.Text), Last_Output.Continues_Word);
Special_Used := True;
elsif Event.Key = RO then
Last_Output := (Syllable, To_Unbounded ("."), True);
Output_Backend.Output.Enter (From_Unbounded (Last_Output.Text), Last_Output.Continues_Word);
Special_Used := True;
elsif Event.Key = RJ then
Last_Output := (Syllable, To_Unbounded (","), True);
Output_Backend.Output.Enter (From_Unbounded (Last_Output.Text), Last_Output.Continues_Word);
Special_Used := True;
end if;
end if;
if not Special_Used then
Released.Include (Event.Key);
end if;
end;
end case;
end if;
Log_Board (Pressed, Released);
end Handle;
or
accept Shut_Down;
Log.Info ("[Qweyboard] Received shut down command, committing and shutting down output backend");
Commit;
Output_Backend.Output.Shut_Down;
exit;
or
delay Current_Timeout;
if Pressed.Is_Empty then
Log.Chat ("[Qweyboard] Timed out and pressed is empty, committing");
Commit;
end if;
end select;
end loop;
end Softboard;
procedure Log_Board (Pressed : Key_Sets.Set; Released : Key_Sets.Set) is
begin
Log.Info ("[Qweyboard] Pressed: [", Suffix => ' ');
for Key of Pressed loop
Log.Info (W (Softkey'Image (Key)), Suffix => ' ');
end loop;
Log.Info ("]", Suffix => ' ');
Log.Info ("Released: [", Suffix => ' ');
for Key of Released loop
Log.Info (W (Softkey'Image (Key)), Suffix => ' ');
end loop;
Log.Info ("]");
end Log_Board;
begin
Return_Combo.Insert (LZ);
Return_Combo.Insert (RZ);
Backspace_Combo.Insert (LC);
Backspace_Combo.Insert (LR);
Backspace_Combo.Insert (RR);
Backspace_Combo.Insert (RC);
end Qweyboard;
|
reznikmm/matreshka | Ada | 6,820 | 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.Bookmark_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Bookmark_Element_Node is
begin
return Self : Text_Bookmark_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_Bookmark_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_Bookmark
(ODF.DOM.Text_Bookmark_Elements.ODF_Text_Bookmark_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_Bookmark_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Bookmark_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Bookmark_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_Bookmark
(ODF.DOM.Text_Bookmark_Elements.ODF_Text_Bookmark_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_Bookmark_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_Bookmark
(Visitor,
ODF.DOM.Text_Bookmark_Elements.ODF_Text_Bookmark_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.Bookmark_Element,
Text_Bookmark_Element_Node'Tag);
end Matreshka.ODF_Text.Bookmark_Elements;
|
francesco-bongiovanni/ewok-kernel | Ada | 3,466 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ada.unchecked_conversion;
with ewok.tasks; use ewok.tasks;
with ewok.tasks_shared; use ewok.tasks_shared;
with ewok.devices_shared; use ewok.devices_shared;
with ewok.sched;
with ewok.interrupts;
with soc.interrupts;
with m4.scb;
with debug;
package body ewok.mpu.handler
with spark_mode => off
is
function memory_fault_handler
(frame_a : t_stack_frame_access)
return t_stack_frame_access
is
current : ewok.tasks.t_task_access;
begin
if m4.scb.SCB.CFSR.MMFSR.MMARVALID then
debug.log (debug.WARNING, "MPU error: MMFAR.ADDRESS = " &
system_address'image (m4.scb.SCB.MMFAR.ADDRESS));
end if;
if m4.scb.SCB.CFSR.MMFSR.MLSPERR then
debug.log (debug.WARNING, "MPU error: a MemManage fault occurred during floating-point lazy state preservation");
end if;
if m4.scb.SCB.CFSR.MMFSR.MSTKERR then
debug.log (debug.WARNING, "MPU error: stacking for an exception entry has caused one or more access violation");
end if;
if m4.scb.SCB.CFSR.MMFSR.MUNSTKERR then
debug.log (debug.WARNING, "MPU error: unstack for an exception return has caused one or more access violation");
end if;
if m4.scb.SCB.CFSR.MMFSR.DACCVIOL then
debug.log (debug.WARNING, "MPU error: the processor attempted a load or store at a location that does not permit the operation");
end if;
if m4.scb.SCB.CFSR.MMFSR.IACCVIOL then
debug.log (debug.WARNING, "MPU error: the processor attempted an instruction fetch from a location that does not permit execution");
end if;
current := ewok.tasks.get_task(ewok.sched.get_current);
if current = NULL then
debug.panic ("MPU error: No current task.");
end if;
declare
begin
debug.log (debug.WARNING,
"MPU error: task: " & current.all.name &
", id:" & ewok.tasks_shared.t_task_id'image (current.all.id) &
", PC:" & system_address'image (frame_a.all.PC));
end;
-- On memory fault, the task is not scheduled anymore
ewok.tasks.set_state
(current.all.id, TASK_MODE_MAINTHREAD, ewok.tasks.TASK_STATE_FAULT);
-- Request schedule
m4.scb.SCB.ICSR.PENDSVSET := 1;
debug.panic("panic!");
return frame_a;
end memory_fault_handler;
procedure init
is
ok : boolean;
begin
ewok.interrupts.set_task_switching_handler
(soc.interrupts.INT_MEMMANAGE,
memory_fault_handler'access,
ID_UNUSED,
ID_DEV_UNUSED,
ok);
if not ok then raise program_error; end if;
end init;
end ewok.mpu.handler;
|
sungyeon/drake | Ada | 39,972 | adb | with Ada.Characters.Handling;
with Ada.Command_Line;
with Ada.Containers.Indefinite_Ordered_Sets;
with Ada.Containers.Indefinite_Ordered_Maps;
with Ada.Directories;
with Ada.Environment_Variables;
with Ada.Exceptions;
with Ada.Strings.Equal_Case_Insensitive;
with Ada.Strings.Fixed;
with Ada.Strings.Less_Case_Insensitive;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
procedure run_acats is
use type Ada.Containers.Count_Type;
use type Ada.Strings.Unbounded.Unbounded_String;
function "+" (Right : Ada.Strings.Unbounded.Unbounded_String) return String
renames Ada.Strings.Unbounded.To_String;
Command_Not_Found : exception;
Command_Failure : exception;
Configuration_Error : exception;
Unknown_Test : exception;
Compile_Failure : exception;
Test_Failure : exception;
Should_Be_Failure : exception;
-- child process
procedure Shell_Execute (Command : in String; Result : out Integer) is
function system (S : String) return Integer;
pragma Import (C, system);
Code : Integer;
type UI is mod 2 ** Integer'Size;
begin
Ada.Text_IO.Put_Line (Command);
Code := system (Command & ASCII.NUL);
if Code mod 256 /= 0 then
if (UI (Code) and 4) = 0 then -- WEXITED
raise Command_Not_Found with Command & Integer'Image (Code);
else
raise Command_Failure with Command & Integer'Image (Code);
end if;
end if;
Result := Code / 256;
end Shell_Execute;
procedure Shell_Execute (Command : in String) is
Result : Integer;
begin
Shell_Execute (Command, Result);
if Result /= 0 then
raise Command_Failure with Command;
end if;
end Shell_Execute;
procedure Symbolic_Link (Source, Destination : in String) is
begin
Shell_Execute ("ln -s " & Source & " " & Destination);
end Symbolic_Link;
procedure Sorted_Search (
Directory : in String;
Pattern : in String;
Filter : in Ada.Directories.Filter_Type;
Process : not null access procedure (
Directory_Entry : Ada.Directories.Directory_Entry_Type))
is
type Directory_Entry_Access is
access Ada.Directories.Directory_Entry_Type;
package Entry_Maps is
new Ada.Containers.Indefinite_Ordered_Maps (
String,
Directory_Entry_Access);
Entries : Entry_Maps.Map;
begin
declare -- make entries
Search : Ada.Directories.Search_Type;
begin
Ada.Directories.Start_Search (
Search,
Directory => Directory,
Pattern => Pattern,
Filter => Filter);
while Ada.Directories.More_Entries (Search) loop
declare
New_Entry : constant not null Directory_Entry_Access :=
new Ada.Directories.Directory_Entry_Type;
begin
Ada.Directories.Get_Next_Entry (Search, New_Entry.all);
Entry_Maps.Insert (
Entries,
Ada.Directories.Simple_Name (New_Entry.all),
New_Entry);
end;
end loop;
Ada.Directories.End_Search (Search);
end;
declare -- iterate sorted entries
procedure Do_Process (Position : in Entry_Maps.Cursor) is
begin
Process (Entry_Maps.Element (Position).all);
end Do_Process;
begin
Entry_Maps.Iterate (Entries, Process => Do_Process'Access);
end;
declare -- cleanup
procedure Cleanup (Position : in Entry_Maps.Cursor) is
procedure Update (
Unused_Key : in String;
Element : in out Directory_Entry_Access)
is
procedure Free is
new Ada.Unchecked_Deallocation (
Ada.Directories.Directory_Entry_Type,
Directory_Entry_Access);
begin
Free (Element);
end Update;
begin
Entry_Maps.Update_Element (Entries, Position,
Process => Update'Access);
end Cleanup;
begin
Entry_Maps.Iterate (Entries, Process => Cleanup'Access);
end;
end Sorted_Search;
-- getting environment
GCC_Prefix : constant String :=
Ada.Environment_Variables.Value ("GCCPREFIX", Default => "");
GCC_Suffix : constant String :=
Ada.Environment_Variables.Value ("GCCSUFFIX", Default => "");
Start_Dir : constant String := Ada.Directories.Current_Directory;
ACATS_Dir : constant String := Ada.Environment_Variables.Value ("ACATSDIR");
Support_Dir : constant String := Ada.Environment_Variables.Value ("SUPPORTDIR");
Test_Dir : constant String := Ada.Environment_Variables.Value ("TESTDIR");
RTS_Dir : constant String :=
Ada.Environment_Variables.Value ("RTSDIR", Default => "");
-- test result
type Test_Result is (
Passed, -- 0
Any_Exception, -- 1
Not_Applicative, -- 2
Tentatively, -- 3,
Failed, -- 4
Compile_Error,
Untested);
function Image (Item : Test_Result) return Character is
Table : constant array (Test_Result) of Character := "PANTFCU";
begin
return Table (Item);
end Image;
function Value (Item : Character) return Test_Result is
begin
case Item is
when 'P' => return Passed;
when 'A' => return Any_Exception;
when 'N' => return Not_Applicative;
when 'T' => return Tentatively;
when 'F' => return Failed;
when 'C' => return Compile_Error;
when 'U' => return Untested;
when others => raise Constraint_Error;
end case;
end Value;
-- test info
function Is_Only_Pragmas (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "cxh30030.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70010.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70030.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70040.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70050.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70060.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70070.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70080.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxd70090.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40010.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40021.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40030.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40041.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40051.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40060.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40071.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40082.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40090.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40101.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40111.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40121.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40130.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40140.a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "lxh40142.a");
end Is_Only_Pragmas;
function Clear_Screen_Before_Run (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "ee3412c");
end Clear_Screen_Before_Run;
-- test info (error class)
function Is_Error_Class (Name : String) return Boolean is
begin
-- bxxxxxxx, lxxxxxxx (excluding la1xxxxx)
return Name (Name'First) = 'B' or else Name (Name'First) = 'b'
or else (
(Name (Name'First) = 'L' or else Name (Name'First) = 'l')
and then not (
(Name (Name'First + 1) = 'A' or else Name (Name'First + 1) = 'a')
and then (Name (Name'First + 2) = '1')));
end Is_Error_Class;
function Is_No_Error (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "ba1020c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba15001");
end Is_No_Error;
function Is_Missing_Subunits (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "ba2001f")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001e")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007d")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007e")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007f")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007g")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008d")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008e")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008f")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008g");
end Is_Missing_Subunits;
function Is_Not_Found (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "ba11003")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba11013")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1101a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1101b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1101c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba1109a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba12007")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba12008")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba16001")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba16002")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ba3001f")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5007c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "la5008c");
end Is_Not_Found;
-- expected test results
function Expected_Result (Name : String) return Test_Result is
begin
if Is_Error_Class (Name) and then not Is_No_Error (Name) then
return Compile_Error;
elsif Ada.Strings.Equal_Case_Insensitive (Name, "cz1101a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "cz1103a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "e28002b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "e28005d")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3203a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3204a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3402b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3409f")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ee3412c")
then
return Tentatively;
elsif Ada.Strings.Equal_Case_Insensitive (Name, "eb4011a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "eb4012a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "eb4014a")
then
return Any_Exception; -- Tentatively
else
return Passed;
end if;
end Expected_Result;
-- test operations
procedure Setup_Test_Dir is
begin
if Ada.Directories.Exists (Test_Dir) then
declare
procedure Process (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is
Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry);
begin
if Simple_Name (Simple_Name'First) /= '.' then
declare
Full_Name : constant String :=
Ada.Directories.Full_Name (Dir_Entry);
begin
case Ada.Directories.Kind (Dir_Entry) is
when Ada.Directories.Ordinary_File
| Ada.Directories.Special_File =>
Ada.Directories.Delete_File (Full_Name);
when Ada.Directories.Directory =>
Ada.Directories.Delete_Tree (Full_Name);
end case;
end;
end if;
end Process;
begin
Ada.Directories.Search (
Directory => Test_Dir,
Pattern => "*",
Filter => (others => True),
Process => Process'Access);
end;
else
Ada.Directories.Create_Directory (Test_Dir);
end if;
end Setup_Test_Dir;
procedure Adjust_After_Extract (Name : in String) is
procedure Delete (Name : in String) is
begin
Ada.Text_IO.Put_Line ("remove " & Name);
Ada.Directories.Delete_File (Name);
end Delete;
procedure Copy (Source, Destination : in String) is
begin
Ada.Text_IO.Put_Line ("copy " & Source & " to " & Destination);
Ada.Directories.Copy_File (Source, Destination);
end Copy;
begin
if Ada.Strings.Equal_Case_Insensitive (Name, "ca1020e") then
Delete ("ca1020e_func1.adb");
Delete ("ca1020e_func2.adb");
Delete ("ca1020e_proc1.adb");
Delete ("ca1020e_proc2.adb");
elsif Ada.Strings.Equal_Case_Insensitive (Name, "ca14028") then
Delete ("ca14028_func2.adb");
Delete ("ca14028_func3.adb");
Delete ("ca14028_proc1.adb");
Delete ("ca14028_proc3.adb");
elsif Ada.Strings.Equal_Case_Insensitive (Name, "ce2108f") then
Copy ("../X2108E", "X2108E");
elsif Ada.Strings.Equal_Case_Insensitive (Name, "ce2108h") then
Copy ("../X2108G", "X2108G");
elsif Ada.Strings.Equal_Case_Insensitive (Name, "ce3112d") then
Copy ("../X3112C", "X3112C");
end if;
-- patch
declare
Patch_Name : constant String :=
Ada.Directories.Compose (
Containing_Directory => "..",
Name => Ada.Characters.Handling.To_Lower (Name),
Extension => "diff");
begin
if Ada.Directories.Exists (Patch_Name) then
Shell_Execute ("patch -bi " & Patch_Name);
end if;
end;
end Adjust_After_Extract;
procedure Invoke (
Executable : in String;
Expected : in Test_Result;
Result : not null access Test_Result)
is
C : Integer;
begin
Shell_Execute ("./" & Executable, C);
if C = 134 then -- SIGABORT in Linux
Result.all := Any_Exception;
else
Result.all := Test_Result'Val (C);
end if;
if Result.all /= Expected then
raise Test_Failure;
end if;
exception
when Command_Failure =>
Result.all := Any_Exception;
if Expected /= Any_Exception then
raise Test_Failure;
end if;
end Invoke;
-- compiler commands
procedure Chop (
Name : in String;
Destination_Directory : in String := "";
Accept_Error : in Boolean := False)
is
Command : Ada.Strings.Unbounded.Unbounded_String;
begin
Ada.Strings.Unbounded.Append (Command, "gnatchop -w");
if GCC_Prefix /= "" or else GCC_Suffix /= "" then
Ada.Strings.Unbounded.Append (Command, " --GCC=");
Ada.Strings.Unbounded.Append (Command, GCC_Prefix);
Ada.Strings.Unbounded.Append (Command, "gcc");
Ada.Strings.Unbounded.Append (Command, GCC_Suffix);
end if;
Ada.Strings.Unbounded.Append (Command, " ");
Ada.Strings.Unbounded.Append (Command, Name);
if Destination_Directory /= "" then
Ada.Strings.Unbounded.Append (Command, " ");
Ada.Strings.Unbounded.Append (Command, Destination_Directory);
end if;
begin
Shell_Execute (+Command);
exception
when Command_Failure =>
if not Accept_Error then
raise;
end if;
end;
end Chop;
procedure Compile_Only (Name : in String; Result : not null access Test_Result) is
Command : Ada.Strings.Unbounded.Unbounded_String;
begin
Ada.Strings.Unbounded.Append (Command, GCC_Prefix);
Ada.Strings.Unbounded.Append (Command, "gcc");
Ada.Strings.Unbounded.Append (Command, GCC_Suffix);
Ada.Strings.Unbounded.Append (Command, " -c ");
Ada.Strings.Unbounded.Append (Command, Name);
Shell_Execute (+Command);
exception
when Command_Failure =>
Result.all := Compile_Error;
raise Compile_Failure with +Command;
end Compile_Only;
procedure Compile (
Name : in String;
Stack_Check : in Boolean := False;
Overflow_Check : in Boolean := False;
Dynamic_Elaboration : in Boolean := False;
UTF_8 : in Boolean := False;
Link_With : in String := "";
RTS : in String := "";
Save_Log : in Boolean := False;
Result : not null access Test_Result)
is
Command : Ada.Strings.Unbounded.Unbounded_String;
begin
Ada.Strings.Unbounded.Append (Command, GCC_Prefix);
Ada.Strings.Unbounded.Append (Command, "gnatmake");
Ada.Strings.Unbounded.Append (Command, GCC_Suffix);
if Support_Dir /= "" then
Ada.Strings.Unbounded.Append (Command, " -I../"); -- relative path from Test_Dir
Ada.Strings.Unbounded.Append (Command, Support_Dir);
end if;
Ada.Strings.Unbounded.Append (Command, " -gnat05"); -- default version
Ada.Strings.Unbounded.Append (Command, " -gnata"); -- assertions
if Stack_Check then
Ada.Strings.Unbounded.Append (Command, " -fstack-check");
end if;
if Overflow_Check then
Ada.Strings.Unbounded.Append (Command, " -gnato");
end if;
if Dynamic_Elaboration then
Ada.Strings.Unbounded.Append (Command, " -gnatE -f");
end if;
Ada.Strings.Unbounded.Append (Command, " -gnatws"); -- suppress all warnings
if UTF_8 then
Ada.Strings.Unbounded.Append (Command, " -gnatW8");
end if;
Ada.Strings.Unbounded.Append (Command, " ");
Ada.Strings.Unbounded.Append (Command, Name);
if RTS /= "" then
Ada.Strings.Unbounded.Append (Command, " --RTS=");
Ada.Strings.Unbounded.Append (Command, RTS);
end if;
if Link_With /= "" then
Ada.Strings.Unbounded.Append (Command, " -largs ");
Ada.Strings.Unbounded.Append (Command, Link_With);
end if;
if Save_Log then
Ada.Strings.Unbounded.Append (Command, " 2>&1 | tee log.txt");
end if;
Shell_Execute (+Command);
exception
when Command_Failure =>
Result.all := Compile_Error;
raise Compile_Failure with +Command;
end Compile;
-- runtime info
type Runtime_Type is (GNAT, Drake);
function Get_Runtime return Runtime_Type is
begin
if RTS_Dir = "" then
return GNAT;
else
return Drake;
end if;
end Get_Runtime;
Runtime : constant Runtime_Type := Get_Runtime;
function Get_Expected_File_Name return String is
begin
case Runtime is
when GNAT => return "gnat-expected.txt";
when Drake => return "drake-expected.txt";
end case;
end Get_Expected_File_Name;
Expected_File_Name : constant String := Get_Expected_File_Name;
function Get_Report_File_Name return String is
begin
case Runtime is
when GNAT => return "gnat-result.txt";
when Drake => return "drake-result.txt";
end case;
end Get_Report_File_Name;
Report_File_Name : constant String := Get_Report_File_Name;
-- test info for compiler/runtime
function Stack_Check (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "c52103x")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c52104x")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c52104y")
or else Ada.Strings.Equal_Case_Insensitive (Name, "cb1010c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "cb1010d");
end Stack_Check;
function Overflow_Check (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "c43206a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45304a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45304b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45304c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45504a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45504b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45504c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45613a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45613b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45613c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45632a")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45632b")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c45632c")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c460008")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c460011")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c46014a")
or else (Runtime = Drake and then Ada.Strings.Equal_Case_Insensitive (Name, "c96005d"));
end Overflow_Check;
function Dynamic_Elaboration (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "c731001")
or else Ada.Strings.Equal_Case_Insensitive (Name, "c854002")
or else Ada.Strings.Equal_Case_Insensitive (Name, "ca5006a");
end Dynamic_Elaboration;
function Need_lm (Name : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (Name, "cxb5004"); -- for Linux
end Need_lm;
-- test operations for compiler/runtime (error class)
procedure Check_Log_In_Error_Class (Name : in String; Result : not null access Test_Result) is
File : Ada.Text_IO.File_Type;
Runtime_Configuration_Error : Boolean := False;
begin
Ada.Text_IO.Open (File, Ada.Text_IO.In_File, "log.txt");
while not Ada.Text_IO.End_Of_File (File) loop
declare
Line : constant String := Ada.Text_IO.Get_Line (File);
begin
if Ada.Strings.Fixed.Index (Line, "file can have only one compilation unit") >= 1
or else (Ada.Strings.Fixed.Index (Line, "cannot generate code") >= 1 and then not Is_Missing_Subunits (Name))
then
raise Configuration_Error;
elsif Ada.Strings.Fixed.Index (Line, "run-time library configuration error") >= 1 then
Runtime_Configuration_Error := True;
elsif Ada.Strings.Fixed.Index (Line, "not found") >= 1 then
if Runtime_Configuration_Error then
null; -- raise Should_Be_Failure
elsif Is_Not_Found (Name) then
Result.all := Compile_Error;
else
raise Configuration_Error;
end if;
elsif Ada.Strings.Fixed.Index (Line, "compilation error") >= 1
or else Ada.Strings.Fixed.Index (Line, "bind failed") >= 1
then
Result.all := Compile_Error;
end if;
end;
end loop;
Ada.Text_IO.Close (File);
if Is_No_Error (Name) then
if Result.all = Untested then
Result.all := Passed;
else
raise Compile_Failure;
end if;
elsif Result.all /= Compile_Error then
Result.all := Failed;
raise Should_Be_Failure;
end if;
end Check_Log_In_Error_Class;
-- expected test results for compiler/runtime
type Expected_Test_Result is record
Result : Test_Result;
Note : Ada.Strings.Unbounded.Unbounded_String;
end record;
package Expected_Tables is new Ada.Containers.Indefinite_Ordered_Maps (
String,
Expected_Test_Result,
"<" => Ada.Strings.Less_Case_Insensitive);
function Read_Expected_Table return Expected_Tables.Map is
begin
return Result : Expected_Tables.Map do
declare
File : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Name => Expected_File_Name);
Ada.Text_IO.Put ("reading " & Expected_File_Name & "...");
while not Ada.Text_IO.End_Of_File (File) loop
declare
Line : constant String := Ada.Text_IO.Get_Line (File);
Element : Expected_Test_Result;
begin
if Line (8) /= ' ' or else Line (10) /= ' ' then
raise Ada.Text_IO.Data_Error with Line;
end if;
begin
Element.Result := Value (Line (9));
exception
when Constraint_Error => raise Ada.Text_IO.Data_Error with Line;
end;
Element.Note := Ada.Strings.Unbounded.To_Unbounded_String (Line (11 .. Line'Last));
Expected_Tables.Include (Result, Line (1 .. 7), Element);
end;
end loop;
Ada.Text_IO.Close (File);
end;
end return;
end Read_Expected_Table;
Expected_Table : constant Expected_Tables.Map := Read_Expected_Table;
function Runtime_Expected_Result (Name : String) return Expected_Test_Result is
begin
if Expected_Table.Contains (Name) then
return Expected_Table.Element (Name);
else
return (Passed, Ada.Strings.Unbounded.Null_Unbounded_String);
end if;
end Runtime_Expected_Result;
function ACATS_And_Runtime_Expected_Result (Name : String) return Expected_Test_Result is
begin
return Result : Expected_Test_Result := Runtime_Expected_Result (Name) do
if Result.Result = Passed then
Result.Result := Expected_Result (Name);
Result.Note := Ada.Strings.Unbounded.To_Unbounded_String ("violate ACATS");
end if;
end return;
end ACATS_And_Runtime_Expected_Result;
-- test result records
type Test_Record is record
Result : Test_Result;
Is_Expected : Boolean;
end record;
package Test_Records is new Ada.Containers.Indefinite_Ordered_Maps (
String,
Test_Record,
"<" => Ada.Strings.Less_Case_Insensitive);
Records: Test_Records.Map;
-- executing test
package String_CI_Sets is new Ada.Containers.Indefinite_Ordered_Sets (
String,
"<" => Ada.Strings.Less_Case_Insensitive,
"=" => Ada.Strings.Equal_Case_Insensitive);
procedure Test (Directory : in String; Name : in String) is
In_Error_Class : constant Boolean := Is_Error_Class (Name);
Main : Ada.Strings.Unbounded.Unbounded_String;
Link_With : Ada.Strings.Unbounded.Unbounded_String;
UTF_8 : Boolean := False;
Result : aliased Test_Result := Untested;
procedure Process_Extract (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is
Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry);
begin
if Simple_Name (Simple_Name'First) /= '.' then
declare
Extension : constant String := Ada.Directories.Extension (Simple_Name);
begin
if Ada.Strings.Equal_Case_Insensitive (Extension, "ada")
or else Ada.Strings.Equal_Case_Insensitive (Extension, "dep")
or else Ada.Strings.Equal_Case_Insensitive (Extension, "a")
then
declare
Only_Pragmas : constant Boolean := Is_Only_Pragmas (Simple_Name);
begin
if Only_Pragmas then
Symbolic_Link (
Source => "../" & Ada.Directories.Compose (Directory, Simple_Name),
Destination => "gnat.adc;");
else
Chop (
"../" & Ada.Directories.Compose (Directory, Simple_Name),
Accept_Error => In_Error_Class);
end if;
end;
elsif Ada.Strings.Equal_Case_Insensitive (Extension, "am") then
Chop (
"../" & Ada.Directories.Compose (Directory, Simple_Name),
Accept_Error => In_Error_Class);
declare
Main_Name : constant String := Ada.Directories.Compose (
Name => Ada.Directories.Base_Name (Simple_Name),
Extension => "adb");
begin
if Ada.Directories.Exists (Main_Name) then
Main := Ada.Strings.Unbounded.To_Unbounded_String (Main_Name);
end if;
end;
elsif Ada.Strings.Equal_Case_Insensitive (Extension, "au") then
UTF_8 := True;
Chop (
"../" & Ada.Directories.Compose (Directory, Simple_Name),
Accept_Error => In_Error_Class);
elsif Ada.Strings.Equal_Case_Insensitive (Extension, "tst") then
declare
File : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Create (File, Name => "TSTTESTS.DAT");
Ada.Text_IO.Put_Line (File, Simple_Name);
Ada.Text_IO.Close (File);
Symbolic_Link (
Source => "../" & Ada.Directories.Compose (Directory, Simple_Name),
Destination => Simple_Name);
Symbolic_Link (
Source => "../support/MACRO.DFS",
Destination => "MACRO.DFS");
Shell_Execute (Ada.Directories.Compose (
Containing_Directory => Ada.Directories.Compose ("..", Support_Dir),
Name => "macrosub"));
end;
Chop (
Ada.Directories.Compose (Name => Ada.Directories.Base_Name (Simple_Name), Extension => "adt"),
Accept_Error => In_Error_Class);
elsif Ada.Strings.Equal_Case_Insensitive (Extension, "c")
or else Ada.Strings.Equal_Case_Insensitive (Extension, "cbl")
or else Ada.Strings.Equal_Case_Insensitive (Extension, "ftn")
then
Symbolic_Link (
Source => "../" & Ada.Directories.Compose (Directory, Simple_Name),
Destination => Simple_Name);
if not Ada.Strings.Equal_Case_Insensitive (Simple_Name, "cd300051.c") then -- use .o in support dir
Compile_Only (Simple_Name, Result'Access);
if Link_With /= "" then
Ada.Strings.Unbounded.Append (Link_With, " ");
end if;
Ada.Strings.Unbounded.Append (Link_With,
Ada.Directories.Compose (
Name => Ada.Directories.Base_Name (Simple_Name),
Extension => "o"));
end if;
else
raise Unknown_Test with "unknown extension """ & Extension & """ of " & Simple_Name;
end if;
end;
end if;
end Process_Extract;
Expected : constant Expected_Test_Result := ACATS_And_Runtime_Expected_Result (Name);
Is_Expected : Boolean := False;
begin
Ada.Text_IO.Put_Line ("**** " & Name & " ****");
begin
Setup_Test_Dir;
Ada.Directories.Set_Directory (Test_Dir);
Sorted_Search (
Directory => Start_Dir & "/" & Directory,
Pattern => Name & "*",
Filter => (others => True),
Process => Process_Extract'Access);
Adjust_After_Extract (Name);
if In_Error_Class then
declare
package Library_Unit_Sets renames String_CI_Sets;
Library_Units : Library_Unit_Sets.Set;
procedure Process_Collect (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is
Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry);
File : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Simple_Name);
while not Ada.Text_IO.End_Of_File (File) loop
declare
Separate_Word : constant String := "SEPARATE";
Line : constant String := Ada.Text_IO.Get_Line (File);
begin
if Line'Length >= Separate_Word'Length
and then Ada.Strings.Equal_Case_Insensitive (
Line (Line'First .. Line'First + Separate_Word'Length - 1),
Separate_Word)
then
return; -- separate unit is not a library unit
end if;
end;
end loop;
Ada.Text_IO.Close (File);
declare
Unit_Name : String := Ada.Directories.Base_Name (Simple_Name);
begin
for I in Unit_Name'Range loop
if Unit_Name (I) = '-' then
Unit_Name (I) := '.';
end if;
end loop;
Library_Unit_Sets.Include (Library_Units, Unit_Name);
end;
end Process_Collect;
File : Ada.Text_IO.File_Type;
procedure Process_With (Position : in Library_Unit_Sets.Cursor) is
begin
Ada.Text_IO.Put_Line (File, "with " & Library_Unit_Sets.Element (Position) & ";");
end Process_With;
begin
Ada.Directories.Search (
Directory => ".", -- Test_Dir
Pattern => "*.ad?",
Filter => (Ada.Directories.Ordinary_File => True, others => False),
Process => Process_Collect'Access);
Ada.Text_IO.Create (File, Name => "main.adb");
Library_Unit_Sets.Iterate (Library_Units, Process_With'Access);
Ada.Text_IO.Put_Line (File, "procedure main is");
Ada.Text_IO.Put_Line (File, "begin");
Ada.Text_IO.Put_Line (File, " null;");
Ada.Text_IO.Put_Line (File, "end main;");
Ada.Text_IO.Close (File);
begin
Compile ("main.adb",
UTF_8 => UTF_8,
RTS => RTS_Dir,
Save_Log => True,
Result => Result'Access);
-- no error caused by "tee" command when succeeded or failed to compile
exception
when Compile_Failure => null;
end;
Check_Log_In_Error_Class (Name, Result'Access);
Is_Expected := True;
end;
else
if Main = "" then
declare
procedure Process_Find_Main (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is
Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry);
Base_Name : constant String := Ada.Directories.Base_Name (Simple_Name);
begin
if Ada.Strings.Equal_Case_Insensitive (Name, Base_Name)
or else (Base_Name'Length > Name'Length
and then Ada.Strings.Equal_Case_Insensitive (Name, Base_Name (1 .. Name'Length))
and then (Base_Name (Base_Name'Last) = 'M' or else Base_Name (Base_Name'Last) = 'm'))
then
Main := Ada.Strings.Unbounded.To_Unbounded_String (Simple_Name);
end if;
end Process_Find_Main;
begin
Ada.Directories.Search (
Directory => ".", -- Test_Dir
Pattern => "*.adb",
Filter => (Ada.Directories.Ordinary_File => True, others => False),
Process => Process_Find_Main'Access);
end;
end if;
if Main = "" then
if Ada.Strings.Equal_Case_Insensitive (Name (Name'First .. Name'First + 2), "cxe") then
raise Compile_Failure; -- unimplemented test with GLADE
else
raise Configuration_Error with "main subprogram is not found.";
end if;
end if;
if Need_lm (Name) then
if Link_With /= "" then
Ada.Strings.Unbounded.Append (Link_With, " ");
end if;
Ada.Strings.Unbounded.Append (Link_With, "-lm");
end if;
Compile (
+Main,
Stack_Check => Stack_Check (Name),
Overflow_Check => Overflow_Check (Name),
Dynamic_Elaboration => Dynamic_Elaboration (Name),
Link_With => +Link_With,
RTS => RTS_Dir,
UTF_8 => UTF_8,
Result => Result'Access);
if Expected.Result = Untested then
raise Test_Failure;
else
if Clear_Screen_Before_Run (Name) then
Ada.Text_IO.New_Page;
end if;
Invoke (
Ada.Directories.Base_Name (+Main),
Expected => Expected.Result,
Result => Result'Access);
Is_Expected := True;
end if;
end if;
exception
when E : Compile_Failure | Test_Failure | Should_Be_Failure =>
Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
if Expected.Result /= Passed then
Is_Expected := Result = Expected.Result;
if Is_Expected then
Ada.Text_IO.Put_Line (
"expected: " & Test_Result'Image (Result) &
" " & Ada.Strings.Unbounded.To_String (Expected.Note));
else
Ada.Text_IO.Put_Line (
"unexpected: " & Test_Result'Image (Result) &
" (expected: " & Test_Result'Image (Expected.Result) & ")");
end if;
else
Is_Expected := False;
Ada.Text_IO.Put_Line ("unexpected: " & Test_Result'Image (Result));
end if;
end;
Test_Records.Include (Records, Name, Test_Record'(Result => Result, Is_Expected => Is_Expected));
Ada.Directories.Set_Directory (Start_Dir);
Ada.Text_IO.New_Line;
end Test;
package Test_Sets renames String_CI_Sets;
Executed_Tests : Test_Sets.Set;
type State_Type is (Skip, Run, Stop, Trial);
State : State_Type;
Continue_From : Ada.Strings.Unbounded.Unbounded_String;
Run_Until : Ada.Strings.Unbounded.Unbounded_String;
Report_File : Ada.Text_IO.File_Type;
procedure Process_File (
Directory : in String;
Dir_Entry : in Ada.Directories.Directory_Entry_Type)
is
Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry);
begin
if Simple_Name (Simple_Name'First) /= '.' then
declare
Base_Name : constant String := Ada.Directories.Base_Name (Simple_Name);
Test_Name : String renames Base_Name (1 .. 7);
Extension : constant String := Ada.Directories.Extension (Simple_Name);
function Eq_Test_Name (S : String) return Boolean is
begin
return Ada.Strings.Equal_Case_Insensitive (S, Simple_Name)
or else Ada.Strings.Equal_Case_Insensitive (S, Base_Name)
or else Ada.Strings.Equal_Case_Insensitive (S, Test_Name);
end Eq_Test_Name;
begin
if State = Skip and then Eq_Test_Name (+Continue_From) then
State := Run;
end if;
if not Executed_Tests.Contains (Test_Name) then
Test_Sets.Insert (Executed_Tests, Test_Name);
if State = Run
or else (State = Trial and then (
not Records.Contains (Test_Name)
or else not Records.Element (Test_Name).Is_Expected))
then
if Ada.Strings.Equal_Case_Insensitive (Extension, "ada")
or else Ada.Strings.Equal_Case_Insensitive (Extension, "dep") -- implementation depending
or else Ada.Strings.Equal_Case_Insensitive (Extension, "tst") -- macro
then
Test (Directory, Test_Name); -- legacy style test
elsif Ada.Strings.Equal_Case_Insensitive (Extension, "a")
or else Ada.Strings.Equal_Case_Insensitive (Extension, "am") -- main of multiple source
or else Ada.Strings.Equal_Case_Insensitive (Extension, "au") -- UTF-8
or else Ada.Strings.Equal_Case_Insensitive (Extension, "c") -- C source
or else Ada.Strings.Equal_Case_Insensitive (Extension, "cbl") -- COBOL source
or else Ada.Strings.Equal_Case_Insensitive (Extension, "ftn") -- Fortran source
then
Test (Directory, Test_Name); -- modern style test
else
raise Unknown_Test with "unknown extension """ & Extension & """ of " & Simple_Name;
end if;
if State = Trial and then not Records.Element (Test_Name).Is_Expected then
State := Stop;
end if;
else
if not Records.Contains (Test_Name) then
Test_Records.Include (
Records,
Test_Name,
Test_Record'(Result => Untested, Is_Expected => False));
end if;
end if;
declare
R : Test_Record renames Test_Records.Element (Records, Test_Name);
XO : constant array (Boolean) of Character := "XO";
begin
Ada.Text_IO.Put_Line (
Report_File,
Test_Name & ' ' & Image (R.Result) & ' ' & XO (R.Is_Expected));
end;
end if;
if State = Run and then Eq_Test_Name (+Run_Until) then
State := Stop;
end if;
end;
end if;
end Process_File;
procedure Process_Dir (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is
Simple_Name : constant String := Ada.Directories.Simple_Name (Dir_Entry);
begin
if Simple_Name (Simple_Name'First) /= '.'
and then not Ada.Strings.Equal_Case_Insensitive (Simple_Name, "docs")
and then not Ada.Strings.Equal_Case_Insensitive (Simple_Name, "support")
then
declare
Directory : constant String := Ada.Directories.Compose (
Containing_Directory => ACATS_Dir,
Name => Simple_Name);
procedure Process (Dir_Entry : in Ada.Directories.Directory_Entry_Type) is
begin
Process_File (Directory, Dir_Entry);
end Process;
begin
Sorted_Search (
Directory => Ada.Directories.Full_Name (Dir_Entry),
Pattern => "*",
Filter => (others => True),
Process => Process'Access);
end;
end if;
end Process_Dir;
begin
if Ada.Command_Line.Argument_Count < 1 then
State := Run;
elsif Ada.Command_Line.Argument (1) = "--trial" then
State := Trial;
else
State := Skip;
Continue_From := Ada.Strings.Unbounded.To_Unbounded_String (Ada.Command_Line.Argument (1));
if Ada.Command_Line.Argument_Count < 2 then
Run_Until := Continue_From;
elsif Ada.Command_Line.Argument (2) = ".." then
Run_Until := Ada.Strings.Unbounded.Null_Unbounded_String;
else
Run_Until := Ada.Strings.Unbounded.To_Unbounded_String (Ada.Command_Line.Argument (2));
end if;
end if;
begin
Ada.Text_IO.Open (Report_File, Ada.Text_IO.In_File, Name => Report_File_Name);
Ada.Text_IO.Put ("reading " & Report_File_Name & "...");
while not Ada.Text_IO.End_Of_File (Report_File) loop
declare
Line : constant String := Ada.Text_IO.Get_Line (Report_File);
Result : Test_Result;
Is_Expected : Boolean;
begin
if Line (8) /= ' ' or else Line (10) /= ' ' then
raise Ada.Text_IO.Data_Error with Line;
end if;
begin
Result := Value (Line (9));
exception
when Constraint_Error => raise Ada.Text_IO.Data_Error with Line;
end;
case Line (11) is
when 'X' => Is_Expected := False;
when 'O' => Is_Expected := True;
when others => raise Ada.Text_IO.Data_Error with Line;
end case;
Test_Records.Include (
Records,
Line (1 .. 7),
Test_Record'(Result => Result, Is_Expected => Is_Expected));
end;
end loop;
Ada.Text_IO.Close (Report_File);
Ada.Text_IO.Put_Line ("done.");
exception
when Ada.Text_IO.Name_Error => null;
end;
Ada.Text_IO.Create (Report_File, Name => Report_File_Name);
Sorted_Search (
Directory => ACATS_Dir,
Pattern => "*",
Filter => (Ada.Directories.Directory => True, others => False),
Process => Process_Dir'Access);
Ada.Text_IO.Close (Report_File);
case State is
when Run | Trial =>
Ada.Text_IO.Put_Line ("**** complete ****");
when others =>
null;
end case;
end run_acats;
|
zhmu/ananas | Ada | 5,382 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ I M G V --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-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. --
-- --
------------------------------------------------------------------------------
-- Expand routines for Image, Value and Width attributes. These are the
-- attributes that make use of enumeration type image tables.
with Types; use Types;
package Exp_Imgv is
procedure Build_Enumeration_Image_Tables (E : Entity_Id; N : Node_Id);
-- Build the enumeration image tables for E, which is an enumeration
-- base type. The node N is the point in the tree where the resulting
-- declarations are to be inserted.
--
-- The form of the tables generated is as follows:
--
-- xxxS : constant string (1 .. M) := "chars";
-- xxxN : constant array (0 .. N) of Index_Type := (i1, i2, .., iN, j);
--
-- Here xxxS is a string obtained by concatenating all the names of the
-- enumeration literals in sequence, representing any wide characters
-- according to the current wide character encoding method, and with all
-- letters forced to upper case.
--
-- The array xxxN is an array of indexes into xxxS pointing to the start
-- of each name, with one extra entry at the end, which is the index to
-- the character just past the end of the last literal, i.e. it is the
-- length of xxxS + 1. The element type is the shortest of the possible
-- types that will hold all the values.
--
-- For example, for the type
--
-- type x is (hello,'!',goodbye);
--
-- the generated tables would consist of
--
-- xxxS : constant string (1 .. 15) := "hello'!'goodbye";
-- xxxN : constant array (0 .. 3) of Integer_8 := (1, 6, 9, 16);
--
-- Here Integer_8 is used since 16 < 2**(8-1).
--
-- If the entity E needs the tables, the necessary declarations are built
-- and the fields Lit_Strings and Lit_Indexes of E are set to point to the
-- corresponding entities. If no tables are needed (E is not a user defined
-- enumeration root type, or pragma Discard_Names is in effect), then the
-- declarations are not constructed and the fields remain Empty.
--
-- If the number of enumeration literals is large enough, a (perfect) hash
-- function mapping the literals to their position number is also built and
-- requires additional tables. See the System.Perfect_Hash_Generators unit
-- for a complete description of this processing.
procedure Expand_Image_Attribute (N : Node_Id);
-- This procedure is called from Exp_Attr to expand an occurrence of the
-- attribute Image.
procedure Expand_Wide_Image_Attribute (N : Node_Id);
-- This procedure is called from Exp_Attr to expand an occurrence of the
-- attribute Wide_Image.
procedure Expand_Wide_Wide_Image_Attribute (N : Node_Id);
-- This procedure is called from Exp_Attr to expand an occurrence of the
-- attribute Wide_Wide_Image.
procedure Expand_Valid_Value_Attribute (N : Node_Id);
-- This procedure is called from Exp_Attr to expand an occurrence of the
-- attribute Valid_Value.
procedure Expand_Value_Attribute (N : Node_Id);
-- This procedure is called from Exp_Attr to expand an occurrence of the
-- attribute Value.
type Atype is (Normal, Wide, Wide_Wide);
-- Type of attribute in call to Expand_Width_Attribute
procedure Expand_Width_Attribute (N : Node_Id; Attr : Atype := Normal);
-- This procedure is called from Exp_Attr to expand an occurrence of the
-- attributes Width (Attr = Normal), or Wide_Width (Attr Wide), or
-- Wide_Wide_Width (Attr = Wide_Wide).
end Exp_Imgv;
|
zhmu/ananas | Ada | 718 | adb | -- { dg-do compile }
package body Prefetch1 is
procedure Prefetch_1 (Addr : System.Address);
pragma Import (Intrinsic, Prefetch_1, "__builtin_prefetch");
procedure Prefetch_2 (Addr : System.Address; RW : Integer);
pragma Import (Intrinsic, Prefetch_2, "__builtin_prefetch");
procedure Prefetch_3 (Addr : System.Address; RW : Integer; Locality : Integer);
pragma Import (Intrinsic, Prefetch_3, "__builtin_prefetch");
procedure My_Proc1 (Addr : System.Address) is
begin
Prefetch_1 (Addr);
end;
procedure My_Proc2 (Addr : System.Address) is
begin
Prefetch_2 (Addr, 1);
end;
procedure My_Proc3 (Addr : System.Address) is
begin
Prefetch_3 (Addr, 1, 1);
end;
end Prefetch1;
|
jwarwick/aoc_2020 | Ada | 2,590 | adb | -- AoC 2020, Day 6
with Ada.Text_IO;
with Ada.Containers; use Ada.Containers;
with Ada.Containers.Ordered_Sets;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
package body Day is
package TIO renames Ada.Text_IO;
package Char_Sets is new Ada.Containers.Ordered_Sets
(Element_Type => Character);
use Char_Sets;
function all_set return Char_Sets.Set is
a : Set;
alpha : constant String := "abcdefghijklmnopqrstuvwxyz";
begin
for c of alpha loop
a.insert(c);
end loop;
return a;
end all_set;
function anyone_sum(filename : in String) return Natural is
file : TIO.File_Type;
sum : Natural := 0;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
declare
group : Set;
begin
group_loop:
loop
declare
line : constant String := TIO.get_line(file);
begin
if index_non_blank(line) = 0 then
sum := sum + Natural(length(group));
exit group_loop;
else
for c of line loop
group.include(c);
end loop;
if TIO.end_of_file(file) then
sum := sum + Natural(length(group));
exit group_loop;
end if;
end if;
end;
end loop group_loop;
end;
end loop;
TIO.close(file);
return sum;
end anyone_sum;
function everyone_sum(filename : in String) return Natural is
file : TIO.File_Type;
sum : Natural := 0;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
declare
all_group : Set := all_set;
begin
group_loop:
loop
declare
line : constant String := TIO.get_line(file);
begin
if index_non_blank(line) = 0 then
sum := sum + Natural(length(all_group));
exit group_loop;
else
declare
person : Set;
begin
for c of line loop
person.include(c);
end loop;
all_group := all_group and person;
end;
if TIO.end_of_file(file) then
sum := sum + Natural(length(all_group));
exit group_loop;
end if;
end if;
end;
end loop group_loop;
end;
end loop;
TIO.close(file);
return sum;
end everyone_sum;
end Day;
|
zhmu/ananas | Ada | 9,821 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G E T _ T A R G --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Version for use with GCC
package body Get_Targ is
-- Functions returning individual run-time values. For the standard (GCC)
-- back end, these come from C interface functions (one for each value).
-----------------------
-- Get_Bits_Per_Unit --
-----------------------
function Get_Bits_Per_Unit return Pos is
function C_Get_Bits_Per_Unit return Pos;
pragma Import (C, C_Get_Bits_Per_Unit,
"get_target_bits_per_unit");
begin
return C_Get_Bits_Per_Unit;
end Get_Bits_Per_Unit;
-----------------------
-- Get_Bits_Per_Word --
-----------------------
function Get_Bits_Per_Word return Pos is
function C_Get_Bits_Per_Word return Pos;
pragma Import (C, C_Get_Bits_Per_Word,
"get_target_bits_per_word");
begin
return C_Get_Bits_Per_Word;
end Get_Bits_Per_Word;
-------------------
-- Get_Char_Size --
-------------------
function Get_Char_Size return Pos is
function C_Get_Char_Size return Pos;
pragma Import (C, C_Get_Char_Size,
"get_target_char_size");
begin
return C_Get_Char_Size;
end Get_Char_Size;
----------------------
-- Get_Wchar_T_Size --
----------------------
function Get_Wchar_T_Size return Pos is
function C_Get_Wchar_T_Size return Pos;
pragma Import (C, C_Get_Wchar_T_Size,
"get_target_wchar_t_size");
begin
return C_Get_Wchar_T_Size;
end Get_Wchar_T_Size;
--------------------
-- Get_Short_Size --
--------------------
function Get_Short_Size return Pos is
function C_Get_Short_Size return Pos;
pragma Import (C, C_Get_Short_Size,
"get_target_short_size");
begin
return C_Get_Short_Size;
end Get_Short_Size;
------------------
-- Get_Int_Size --
------------------
function Get_Int_Size return Pos is
function C_Get_Int_Size return Pos;
pragma Import (C, C_Get_Int_Size,
"get_target_int_size");
begin
return C_Get_Int_Size;
end Get_Int_Size;
-------------------
-- Get_Long_Size --
-------------------
function Get_Long_Size return Pos is
function C_Get_Long_Size return Pos;
pragma Import (C, C_Get_Long_Size,
"get_target_long_size");
begin
return C_Get_Long_Size;
end Get_Long_Size;
------------------------
-- Get_Long_Long_Size --
------------------------
function Get_Long_Long_Size return Pos is
function C_Get_Long_Long_Size return Pos;
pragma Import (C, C_Get_Long_Long_Size,
"get_target_long_long_size");
begin
return C_Get_Long_Long_Size;
end Get_Long_Long_Size;
-----------------------------
-- Get_Long_Long_Long_Size --
-----------------------------
function Get_Long_Long_Long_Size return Pos is
function C_Get_Long_Long_Long_Size return Pos;
pragma Import (C, C_Get_Long_Long_Long_Size,
"get_target_long_long_long_size");
begin
return C_Get_Long_Long_Long_Size;
end Get_Long_Long_Long_Size;
----------------------
-- Get_Pointer_Size --
----------------------
function Get_Pointer_Size return Pos is
function C_Get_Pointer_Size return Pos;
pragma Import (C, C_Get_Pointer_Size,
"get_target_pointer_size");
begin
return C_Get_Pointer_Size;
end Get_Pointer_Size;
---------------------------
-- Get_Maximum_Alignment --
---------------------------
function Get_Maximum_Alignment return Pos is
function C_Get_Maximum_Alignment return Pos;
pragma Import (C, C_Get_Maximum_Alignment,
"get_target_maximum_alignment");
begin
return C_Get_Maximum_Alignment;
end Get_Maximum_Alignment;
------------------------
-- Get_Float_Words_BE --
------------------------
function Get_Float_Words_BE return Nat is
function C_Get_Float_Words_BE return Nat;
pragma Import (C, C_Get_Float_Words_BE,
"get_target_float_words_be");
begin
return C_Get_Float_Words_BE;
end Get_Float_Words_BE;
------------------
-- Get_Words_BE --
------------------
function Get_Words_BE return Nat is
function C_Get_Words_BE return Nat;
pragma Import (C, C_Get_Words_BE,
"get_target_words_be");
begin
return C_Get_Words_BE;
end Get_Words_BE;
------------------
-- Get_Bytes_BE --
------------------
function Get_Bytes_BE return Nat is
function C_Get_Bytes_BE return Nat;
pragma Import (C, C_Get_Bytes_BE,
"get_target_bytes_be");
begin
return C_Get_Bytes_BE;
end Get_Bytes_BE;
-----------------
-- Get_Bits_BE --
-----------------
function Get_Bits_BE return Nat is
function C_Get_Bits_BE return Nat;
pragma Import (C, C_Get_Bits_BE,
"get_target_bits_be");
begin
return C_Get_Bits_BE;
end Get_Bits_BE;
---------------------
-- Get_Short_Enums --
---------------------
function Get_Short_Enums return Int is
flag_short_enums : Int;
pragma Import (C, flag_short_enums);
begin
return flag_short_enums;
end Get_Short_Enums;
--------------------------
-- Get_Strict_Alignment --
--------------------------
function Get_Strict_Alignment return Nat is
function C_Get_Strict_Alignment return Nat;
pragma Import (C, C_Get_Strict_Alignment,
"get_target_strict_alignment");
begin
return C_Get_Strict_Alignment;
end Get_Strict_Alignment;
------------------------------------
-- Get_System_Allocator_Alignment --
------------------------------------
function Get_System_Allocator_Alignment return Nat is
function C_Get_System_Allocator_Alignment return Nat;
pragma Import (C, C_Get_System_Allocator_Alignment,
"get_target_system_allocator_alignment");
begin
return C_Get_System_Allocator_Alignment;
end Get_System_Allocator_Alignment;
--------------------------------
-- Get_Double_Float_Alignment --
--------------------------------
function Get_Double_Float_Alignment return Nat is
function C_Get_Double_Float_Alignment return Nat;
pragma Import (C, C_Get_Double_Float_Alignment,
"get_target_double_float_alignment");
begin
return C_Get_Double_Float_Alignment;
end Get_Double_Float_Alignment;
---------------------------------
-- Get_Double_Scalar_Alignment --
---------------------------------
function Get_Double_Scalar_Alignment return Nat is
function C_Get_Double_Scalar_Alignment return Nat;
pragma Import (C, C_Get_Double_Scalar_Alignment,
"get_target_double_scalar_alignment");
begin
return C_Get_Double_Scalar_Alignment;
end Get_Double_Scalar_Alignment;
------------------------------
-- Get_Back_End_Config_File --
------------------------------
function Get_Back_End_Config_File return String_Ptr is
begin
return null;
end Get_Back_End_Config_File;
-----------------------------
-- Get_Max_Unaligned_Field --
-----------------------------
function Get_Max_Unaligned_Field return Pos is
begin
return 64; -- Can be different on some targets
end Get_Max_Unaligned_Field;
-----------------------------
-- Register_Back_End_Types --
-----------------------------
procedure Register_Back_End_Types (Call_Back : Register_Type_Proc) is
procedure Enumerate_Modes (Call_Back : Register_Type_Proc);
pragma Import (C, Enumerate_Modes, "enumerate_modes");
begin
Enumerate_Modes (Call_Back);
end Register_Back_End_Types;
end Get_Targ;
|
stcarrez/ada-el | Ada | 2,465 | ads | -----------------------------------------------------------------------
-- el-contexts-tls -- EL context and Thread Local Support
-- Copyright (C) 2015, 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 EL.Contexts.Default;
-- == EL TLS Context ==
-- The <tt>TLS_Context</tt> type defines an expression context that associates itself to
-- a per-thread context information. By declaring a variable with this type, the expression
-- context is associated with the current thread and it can be retrieved at any time by using the
-- <tt>Current</tt> function. As soon as the variable is finalized, the current thread context
-- is updated.
--
-- The expression context may be declared as follows:
--
-- Context : EL.Contexts.TLS.TLS_Context;
--
-- And at any time, a function or procedure that needs to evaluate an expression can use it:
--
-- Expr : EL.Expressions.Expression;
-- ...
-- Value : Util.Beans.Objects.Object := Expr.Get_Value (EL.Contexts.TLS.Current.all);
--
package EL.Contexts.TLS is
-- ------------------------------
-- TLS Context
-- ------------------------------
-- Context information for expression evaluation.
type TLS_Context is new EL.Contexts.Default.Default_Context with private;
-- Get the current EL context associated with the current thread.
function Current return EL.Contexts.ELContext_Access;
private
type TLS_Context is new EL.Contexts.Default.Default_Context with record
Previous : EL.Contexts.ELContext_Access;
end record;
-- Initialize and setup a new per-thread EL context.
overriding
procedure Initialize (Obj : in out TLS_Context);
-- Restore the previous per-thread EL context.
overriding
procedure Finalize (Obj : in out TLS_Context);
end EL.Contexts.TLS;
|
reznikmm/matreshka | Ada | 4,015 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Svg_V_Ideographic_Attributes;
package Matreshka.ODF_Svg.V_Ideographic_Attributes is
type Svg_V_Ideographic_Attribute_Node is
new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node
and ODF.DOM.Svg_V_Ideographic_Attributes.ODF_Svg_V_Ideographic_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_V_Ideographic_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Svg_V_Ideographic_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Svg.V_Ideographic_Attributes;
|
persan/A-gst | Ada | 6,690 | 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;
with System;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpreset_h is
-- unsupported macro: GST_TYPE_PRESET (gst_preset_get_type())
-- arg-macro: function GST_PRESET (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PRESET, GstPreset);
-- arg-macro: function GST_IS_PRESET (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PRESET);
-- arg-macro: function GST_PRESET_GET_INTERFACE (obj)
-- return G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_PRESET, GstPresetInterface);
-- GStreamer
-- * Copyright (C) 2006 Stefan Kost <[email protected]>
-- *
-- * gstpreset.h: helper interface header for element presets
-- *
-- * 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.
--
--*
-- * GstPreset:
-- *
-- * Opaque #GstPreset data structure.
--
-- dummy object
-- skipped empty struct u_GstPreset
-- skipped empty struct GstPreset
type GstPresetInterface;
type u_GstPresetInterface_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstPresetInterface is u_GstPresetInterface; -- gst/gstpreset.h:41
--*
-- * GstPresetInterface:
-- * @parent: parent interface type.
-- * @get_preset_names: virtual method to get list of presets
-- * @get_property_names: virtual methods to get properties that are persistent
-- * @load_preset: virtual methods to load a preset into properties
-- * @save_preset: virtual methods to save properties into a preset
-- * @rename_preset: virtual methods to rename a preset
-- * @delete_preset: virtual methods to remove a preset
-- * @set_meta: virtual methods to set textual meta data to a preset
-- * @get_meta: virtual methods to get textual meta data from a preset
-- *
-- * #GstPreset interface.
--
type GstPresetInterface is record
parent : aliased GStreamer.GST_Low_Level.glib_2_0_gobject_gtype_h.GTypeInterface; -- gst/gstpreset.h:59
get_preset_names : access function (arg1 : System.Address) return System.Address; -- gst/gstpreset.h:62
get_property_names : access function (arg1 : System.Address) return System.Address; -- gst/gstpreset.h:64
load_preset : access function (arg1 : System.Address; arg2 : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:66
save_preset : access function (arg1 : System.Address; arg2 : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:67
rename_preset : access function
(arg1 : System.Address;
arg2 : access GLIB.gchar;
arg3 : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:69
delete_preset : access function (arg1 : System.Address; arg2 : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:70
set_meta : access function
(arg1 : System.Address;
arg2 : access GLIB.gchar;
arg3 : access GLIB.gchar;
arg4 : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:73
get_meta : access function
(arg1 : System.Address;
arg2 : access GLIB.gchar;
arg3 : access GLIB.gchar;
arg4 : System.Address) return GLIB.gboolean; -- gst/gstpreset.h:75
u_gst_reserved : u_GstPresetInterface_u_gst_reserved_array; -- gst/gstpreset.h:77
end record;
pragma Convention (C_Pass_By_Copy, GstPresetInterface); -- gst/gstpreset.h:57
-- methods
--< private >
function gst_preset_get_type return GLIB.GType; -- gst/gstpreset.h:80
pragma Import (C, gst_preset_get_type, "gst_preset_get_type");
function gst_preset_get_preset_names (preset : System.Address) return System.Address; -- gst/gstpreset.h:82
pragma Import (C, gst_preset_get_preset_names, "gst_preset_get_preset_names");
function gst_preset_get_property_names (preset : System.Address) return System.Address; -- gst/gstpreset.h:84
pragma Import (C, gst_preset_get_property_names, "gst_preset_get_property_names");
function gst_preset_load_preset (preset : System.Address; name : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:86
pragma Import (C, gst_preset_load_preset, "gst_preset_load_preset");
function gst_preset_save_preset (preset : System.Address; name : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:87
pragma Import (C, gst_preset_save_preset, "gst_preset_save_preset");
function gst_preset_rename_preset
(preset : System.Address;
old_name : access GLIB.gchar;
new_name : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:88
pragma Import (C, gst_preset_rename_preset, "gst_preset_rename_preset");
function gst_preset_delete_preset (preset : System.Address; name : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:90
pragma Import (C, gst_preset_delete_preset, "gst_preset_delete_preset");
function gst_preset_set_meta
(preset : System.Address;
name : access GLIB.gchar;
tag : access GLIB.gchar;
value : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:92
pragma Import (C, gst_preset_set_meta, "gst_preset_set_meta");
function gst_preset_get_meta
(preset : System.Address;
name : access GLIB.gchar;
tag : access GLIB.gchar;
value : System.Address) return GLIB.gboolean; -- gst/gstpreset.h:94
pragma Import (C, gst_preset_get_meta, "gst_preset_get_meta");
function gst_preset_set_app_dir (app_dir : access GLIB.gchar) return GLIB.gboolean; -- gst/gstpreset.h:97
pragma Import (C, gst_preset_set_app_dir, "gst_preset_set_app_dir");
function gst_preset_get_app_dir return access GLIB.gchar; -- gst/gstpreset.h:98
pragma Import (C, gst_preset_get_app_dir, "gst_preset_get_app_dir");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpreset_h;
|
stcarrez/ada-awa | Ada | 31,490 | adb | -----------------------------------------------------------------------
-- AWA.Votes.Models -- AWA.Votes.Models
-----------------------------------------------------------------------
-- File generated by Dynamo DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0
-----------------------------------------------------------------------
-- Copyright (C) 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with Ada.Unchecked_Deallocation;
with ASF.Events.Faces.Actions;
pragma Warnings (On);
package body AWA.Votes.Models is
pragma Style_Checks ("-mrIu");
pragma Warnings (Off, "formal parameter * is not referenced");
pragma Warnings (Off, "use clause for type *");
pragma Warnings (Off, "use clause for private type *");
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
function Rating_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => RATING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Rating_Key;
function Rating_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => RATING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Rating_Key;
function "=" (Left, Right : Rating_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Rating_Ref'Class;
Impl : out Rating_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Rating_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Rating_Ref) is
Impl : Rating_Access;
begin
Impl := new Rating_Impl;
Impl.Rating := 0;
Impl.Vote_Count := 0;
Impl.For_Entity_Id := ADO.NO_IDENTIFIER;
Impl.For_Entity_Type := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Rating
-- ----------------------------------------
procedure Set_Id (Object : in out Rating_Ref;
Value : in ADO.Identifier) is
Impl : Rating_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Rating_Ref)
return ADO.Identifier is
Impl : constant Rating_Access
:= Rating_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Rating (Object : in out Rating_Ref;
Value : in Integer) is
Impl : Rating_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 2, Impl.Rating, Value);
end Set_Rating;
function Get_Rating (Object : in Rating_Ref)
return Integer is
Impl : constant Rating_Access
:= Rating_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Rating;
end Get_Rating;
procedure Set_Vote_Count (Object : in out Rating_Ref;
Value : in Integer) is
Impl : Rating_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 3, Impl.Vote_Count, Value);
end Set_Vote_Count;
function Get_Vote_Count (Object : in Rating_Ref)
return Integer is
Impl : constant Rating_Access
:= Rating_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Vote_Count;
end Get_Vote_Count;
procedure Set_For_Entity_Id (Object : in out Rating_Ref;
Value : in ADO.Identifier) is
Impl : Rating_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Identifier (Impl.all, 4, Impl.For_Entity_Id, Value);
end Set_For_Entity_Id;
function Get_For_Entity_Id (Object : in Rating_Ref)
return ADO.Identifier is
Impl : constant Rating_Access
:= Rating_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.For_Entity_Id;
end Get_For_Entity_Id;
procedure Set_For_Entity_Type (Object : in out Rating_Ref;
Value : in ADO.Entity_Type) is
Impl : Rating_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Entity_Type (Impl.all, 5, Impl.For_Entity_Type, Value);
end Set_For_Entity_Type;
function Get_For_Entity_Type (Object : in Rating_Ref)
return ADO.Entity_Type is
Impl : constant Rating_Access
:= Rating_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.For_Entity_Type;
end Get_For_Entity_Type;
-- Copy of the object.
procedure Copy (Object : in Rating_Ref;
Into : in out Rating_Ref) is
Result : Rating_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Rating_Access
:= Rating_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Rating_Access
:= new Rating_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Rating := Impl.Rating;
Copy.Vote_Count := Impl.Vote_Count;
Copy.For_Entity_Id := Impl.For_Entity_Id;
Copy.For_Entity_Type := Impl.For_Entity_Type;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Rating_Access := new Rating_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Rating_Access := new Rating_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Rating_Access := new Rating_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
overriding
procedure Save (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Rating_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Rating_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Rating_Impl) is
type Rating_Impl_Ptr is access all Rating_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Rating_Impl, Rating_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Rating_Impl_Ptr := Rating_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, RATING_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (RATING_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_1_NAME, -- rating
Value => Object.Rating);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_1_NAME, -- vote_count
Value => Object.Vote_Count);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- for_entity_id
Value => Object.For_Entity_Id);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_1_NAME, -- for_entity_type
Value => Object.For_Entity_Type);
Object.Clear_Modified (5);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (RATING_DEF'Access);
Result : Integer;
begin
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_1_NAME, -- rating
Value => Object.Rating);
Query.Save_Field (Name => COL_2_1_NAME, -- vote_count
Value => Object.Vote_Count);
Query.Save_Field (Name => COL_3_1_NAME, -- for_entity_id
Value => Object.For_Entity_Id);
Query.Save_Field (Name => COL_4_1_NAME, -- for_entity_type
Value => Object.For_Entity_Type);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Rating_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (RATING_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Rating_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Rating_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Rating_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Rating));
elsif Name = "vote_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Vote_Count));
elsif Name = "for_entity_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.For_Entity_Id));
elsif Name = "for_entity_type" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.For_Entity_Type));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Rating_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Rating := Stmt.Get_Integer (1);
Object.Vote_Count := Stmt.Get_Integer (2);
Object.For_Entity_Id := Stmt.Get_Identifier (3);
Object.For_Entity_Type := ADO.Entity_Type (Stmt.Get_Integer (4));
ADO.Objects.Set_Created (Object);
end Load;
function Vote_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => VOTE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Vote_Key;
function Vote_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => VOTE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Vote_Key;
function "=" (Left, Right : Vote_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Vote_Ref'Class;
Impl : out Vote_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Vote_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Vote_Ref) is
Impl : Vote_Access;
begin
Impl := new Vote_Impl;
Impl.Rating := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Vote
-- ----------------------------------------
procedure Set_Rating (Object : in out Vote_Ref;
Value : in Integer) is
Impl : Vote_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 1, Impl.Rating, Value);
end Set_Rating;
function Get_Rating (Object : in Vote_Ref)
return Integer is
Impl : constant Vote_Access
:= Vote_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Rating;
end Get_Rating;
procedure Set_Entity (Object : in out Vote_Ref;
Value : in Rating_Ref'Class) is
Impl : Vote_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 2, Impl.Entity, Value);
end Set_Entity;
function Get_Entity (Object : in Vote_Ref)
return Rating_Ref'Class is
Impl : constant Vote_Access
:= Vote_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Entity;
end Get_Entity;
procedure Set_User_Id (Object : in out Vote_Ref;
Value : in ADO.Identifier) is
Impl : Vote_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 3, Value);
end Set_User_Id;
function Get_User_Id (Object : in Vote_Ref)
return ADO.Identifier is
Impl : constant Vote_Access
:= Vote_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_User_Id;
-- Copy of the object.
procedure Copy (Object : in Vote_Ref;
Into : in out Vote_Ref) is
Result : Vote_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Vote_Access
:= Vote_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Vote_Access
:= new Vote_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Rating := Impl.Rating;
Copy.Entity := Impl.Entity;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Vote_Access := new Vote_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Vote_Access := new Vote_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("user_id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Vote_Access := new Vote_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("user_id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
overriding
procedure Save (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Vote_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Vote_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Vote_Impl) is
type Vote_Impl_Ptr is access all Vote_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Vote_Impl, Vote_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Vote_Impl_Ptr := Vote_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, VOTE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("user_id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (VOTE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- rating
Value => Object.Rating);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- entity_id
Value => Object.Entity);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- user_id
Value => Object.Get_Key);
Object.Clear_Modified (3);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "user_id = ? AND entity_id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Entity);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (VOTE_DEF'Access);
Result : Integer;
begin
Query.Save_Field (Name => COL_0_2_NAME, -- rating
Value => Object.Rating);
Query.Save_Field (Name => COL_1_2_NAME, -- entity_id
Value => Object.Entity);
Query.Save_Field (Name => COL_2_2_NAME, -- user_id
Value => Object.Get_Key);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Vote_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (VOTE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "user_id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Vote_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Vote_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Vote_Impl (Obj.all)'Access;
if Name = "rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Rating));
elsif Name = "user_id" then
return ADO.Objects.To_Object (Impl.Get_Key);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Vote_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Rating := Stmt.Get_Integer (0);
if not Stmt.Is_Null (1) then
Object.Entity.Set_Key_Value (Stmt.Get_Identifier (1), Session);
end if;
Object.Set_Key_Value (Stmt.Get_Identifier (2));
ADO.Objects.Set_Created (Object);
end Load;
procedure Op_Vote_Up (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Vote_Up (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Vote_Bean'Class (Bean).Vote_Up (Outcome);
end Op_Vote_Up;
package Binding_Vote_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Vote_Bean,
Method => Op_Vote_Up,
Name => "vote_up");
procedure Op_Vote_Down (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Vote_Down (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Vote_Bean'Class (Bean).Vote_Down (Outcome);
end Op_Vote_Down;
package Binding_Vote_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Vote_Bean,
Method => Op_Vote_Down,
Name => "vote_down");
procedure Op_Vote (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Vote (Bean : in out Vote_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Vote_Bean'Class (Bean).Vote (Outcome);
end Op_Vote;
package Binding_Vote_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Vote_Bean,
Method => Op_Vote,
Name => "vote");
Binding_Vote_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Vote_Bean_1.Proxy'Access,
2 => Binding_Vote_Bean_2.Proxy'Access,
3 => Binding_Vote_Bean_3.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Vote_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Vote_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Vote_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "permission" then
return Util.Beans.Objects.To_Object (From.Permission);
elsif Name = "entity_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Entity_Id));
elsif Name = "rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Rating));
elsif Name = "entity_type" then
return Util.Beans.Objects.To_Object (From.Entity_Type);
elsif Name = "total" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Total));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Vote_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "permission" then
Item.Permission := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "entity_id" then
Item.Entity_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "rating" then
Item.Rating := Util.Beans.Objects.To_Integer (Value);
elsif Name = "entity_type" then
Item.Entity_Type := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "total" then
Item.Total := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
end AWA.Votes.Models;
|
stcarrez/ada-awa | Ada | 14,045 | adb | -----------------------------------------------------------------------
-- awa-counters-modules -- Module counters
-- Copyright (C) 2015, 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 Ada.Unchecked_Deallocation;
with ADO.Queries;
with ADO.Statements;
with ADO.Parameters;
with ADO.Sessions.Entities;
with ADO.SQL;
with Util.Dates;
with Util.Log.Loggers;
with AWA.Modules.Beans;
with AWA.Applications;
with AWA.Counters.Models;
with AWA.Modules.Get;
with AWA.Counters.Beans;
with AWA.Counters.Components;
package body AWA.Counters.Modules is
use type ADO.Schemas.Class_Mapping_Access;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Awa.Counters.Module");
package Register is new AWA.Modules.Beans (Module => Counter_Module,
Module_Access => Counter_Module_Access);
procedure Load_Definition (DB : in out ADO.Sessions.Master_Session;
Def : in Counter_Def;
Result : out Natural);
procedure Flush (DB : in out ADO.Sessions.Master_Session;
Counter : in Counter_Def;
Def_Id : in Natural;
Counters : in Counter_Maps.Map;
Date : in Ada.Calendar.Time);
-- ------------------------------
-- Initialize the counters module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Counter_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the counters module");
Register.Register (Plugin => Plugin,
Name => "AWA.Counters.Beans.Stat_List_Bean",
Handler => AWA.Counters.Beans.Create_Counter_Stat_Bean'Access);
App.Add_Components (AWA.Counters.Components.Definition);
AWA.Modules.Module (Plugin).Initialize (App, Props);
-- Add here the creation of manager instances.
end Initialize;
-- ------------------------------
-- Configures the module after its initialization and after having read its XML configuration.
-- ------------------------------
overriding
procedure Configure (Plugin : in out Counter_Module;
Props : in ASF.Applications.Config) is
pragma Unreferenced (Props);
begin
Plugin.Counter_Limit := Plugin.Get_Config (PARAM_COUNTER_LIMIT, DEFAULT_COUNTER_LIMIT);
Plugin.Age_Limit := Duration (Plugin.Get_Config (PARAM_AGE_LIMIT, 300));
Log.Info ("Counter flush module limit is{0} counters with max age{1} seconds",
Natural'Image (Plugin.Counter_Limit), Duration'Image (Plugin.Age_Limit));
end Configure;
-- ------------------------------
-- Get the counters module.
-- ------------------------------
function Get_Counter_Module return Counter_Module_Access is
function Get is new AWA.Modules.Get (Counter_Module, Counter_Module_Access, NAME);
begin
return Get;
end Get_Counter_Module;
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt> and associated with the
-- database object <tt>Object</tt>.
-- ------------------------------
procedure Increment (Plugin : in out Counter_Module;
Counter : in Counter_Index_Type;
Object : in ADO.Objects.Object_Ref'Class) is
Key : constant ADO.Objects.Object_Key := Object.Get_Key;
begin
if Plugin.Counters.Need_Flush (Plugin.Counter_Limit, Plugin.Age_Limit) then
Plugin.Flush;
end if;
Plugin.Counters.Increment (Counter, Key);
end Increment;
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt> and associated with the
-- database object key <tt>Key</tt>.
-- ------------------------------
procedure Increment (Plugin : in out Counter_Module;
Counter : in Counter_Index_Type;
Key : in ADO.Objects.Object_Key) is
begin
if Plugin.Counters.Need_Flush (Plugin.Counter_Limit, Plugin.Age_Limit) then
Plugin.Flush;
end if;
Plugin.Counters.Increment (Counter, Key);
end Increment;
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt>.
-- ------------------------------
procedure Increment (Plugin : in out Counter_Module;
Counter : in Counter_Index_Type) is
Key : ADO.Objects.Object_Key (ADO.Objects.KEY_INTEGER, null);
begin
if Plugin.Counters.Need_Flush (Plugin.Counter_Limit, Plugin.Age_Limit) then
Plugin.Flush;
end if;
Plugin.Counters.Increment (Counter, Key);
end Increment;
-- ------------------------------
-- Get the current counter value.
-- ------------------------------
procedure Get_Counter (Plugin : in out Counter_Module;
Counter : in AWA.Counters.Counter_Index_Type;
Object : in ADO.Objects.Object_Ref'Class;
Result : out Natural) is
Id : constant ADO.Identifier := ADO.Objects.Get_Value (Object.Get_Key);
DB : ADO.Sessions.Master_Session := Plugin.Get_Master_Session;
Stmt : ADO.Statements.Query_Statement
:= DB.Create_Statement ("SELECT SUM(counter) FROM awa_counter WHERE "
& "object_id = :id AND definition_id = :definition_id");
Def_Id : Natural;
begin
Plugin.Counters.Get_Definition (DB, Counter, Def_Id);
Stmt.Bind_Param ("id", Id);
Stmt.Bind_Param ("definition_id", Def_Id);
Stmt.Execute;
Result := Stmt.Get_Result_Integer;
end Get_Counter;
protected body Counter_Table is
-- ------------------------------
-- Increment the counter identified by <tt>Counter</tt> and associated with the
-- database object <tt>Key</tt>.
-- ------------------------------
procedure Increment (Counter : in Counter_Index_Type;
Key : in ADO.Objects.Object_Key) is
procedure Increment (Key : in ADO.Objects.Object_Key;
Element : in out Positive);
procedure Increment (Key : in ADO.Objects.Object_Key;
Element : in out Positive) is
pragma Unreferenced (Key);
begin
Element := Element + 1;
end Increment;
Pos : Counter_Maps.Cursor;
begin
if Counters = null then
Counters := new Counter_Map_Array (1 .. Counter_Arrays.Get_Last);
Day := Ada.Calendar.Clock;
Day_End := Util.Dates.Get_Day_End (Day);
end if;
Pos := Counters (Counter).Find (Key);
if Counter_Maps.Has_Element (Pos) then
Counters (Counter).Update_Element (Pos, Increment'Access);
else
Counters (Counter).Insert (Key, 1);
Nb_Counters := Nb_Counters + 1;
end if;
end Increment;
-- ------------------------------
-- Get the counters that have been collected with the date and prepare to collect
-- new counters.
-- ------------------------------
procedure Steal_Counters (Result : out Counter_Map_Array_Access;
Date : out Ada.Calendar.Time) is
begin
Result := Counters;
Date := Day;
Counters := null;
Nb_Counters := 0;
end Steal_Counters;
-- ------------------------------
-- Check if we must flush the counters.
-- ------------------------------
function Need_Flush (Limit : in Natural;
Seconds : in Duration) return Boolean is
use type Ada.Calendar.Time;
begin
if Counters = null then
return False;
elsif Nb_Counters > Limit then
return True;
else
declare
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
begin
return Now > Day_End or else Now - Day >= Seconds;
end;
end if;
end Need_Flush;
-- ------------------------------
-- Get the definition ID associated with the counter.
-- ------------------------------
procedure Get_Definition (Session : in out ADO.Sessions.Master_Session;
Counter : in Counter_Index_Type;
Result : out Natural) is
begin
if Definitions = null then
Definitions := new Definition_Array_Type (1 .. Counter_Arrays.Get_Last);
Definitions.all := (others => 0);
end if;
if Definitions (Counter) = 0 then
Load_Definition (Session, Counter_Arrays.Get_Element (Counter).all,
Definitions (Counter));
end if;
Result := Definitions (Counter);
end Get_Definition;
end Counter_Table;
procedure Load_Definition (DB : in out ADO.Sessions.Master_Session;
Def : in Counter_Def;
Result : out Natural) is
Def_Db : AWA.Counters.Models.Counter_Definition_Ref;
Query : ADO.SQL.Query;
Found : Boolean;
Entity : ADO.Nullable_Entity_Type;
begin
if Def.Table = null then
Query.Set_Filter ("name = :name AND entity_type IS NULL");
else
Query.Set_Filter ("name = :name AND entity_type = :entity_type");
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "entity_type",
Table => Def.Table,
Session => DB);
end if;
Query.Bind_Param ("name", Def.Field.all);
Def_Db.Find (DB, Query, Found);
if not Found then
if Def.Table /= null then
Entity.Value := ADO.Sessions.Entities.Find_Entity_Type (DB, Def.Table);
Entity.Is_Null := False;
Def_Db.Set_Entity_Type (Entity);
end if;
Def_Db.Set_Name (Def.Field.all);
Def_Db.Save (DB);
end if;
Result := Natural (Def_Db.Get_Id);
end Load_Definition;
procedure Flush (DB : in out ADO.Sessions.Master_Session;
Counter : in Counter_Def;
Def_Id : in Natural;
Counters : in Counter_Maps.Map;
Date : in Ada.Calendar.Time) is
Query : ADO.Queries.Context;
Stmt : ADO.Statements.Query_Statement;
Update : ADO.Statements.Query_Statement;
Iter : Counter_Maps.Cursor := Counters.First;
Id : ADO.Identifier;
begin
Query.Set_Query (AWA.Counters.Models.Query_Counter_Update);
Stmt := DB.Create_Statement (Query);
if Counter.Table /= null and then Counter.Field'Length > 0 then
Query.Set_Query (AWA.Counters.Models.Query_Counter_Update_Field);
Update := DB.Create_Statement (Query);
end if;
while Counter_Maps.Has_Element (Iter) loop
Id := ADO.Objects.Get_Value (Counter_Maps.Key (Iter));
Stmt.Bind_Param ("date", Date);
Stmt.Bind_Param ("id", Id);
Stmt.Bind_Param ("counter", Counter_Maps.Element (Iter));
Stmt.Bind_Param ("definition", Integer (Def_Id));
Stmt.Execute;
if Counter.Table /= null and then Counter.Field'Length > 0 then
Update.Bind_Param ("id", Id);
Update.Bind_Param ("counter", Counter_Maps.Element (Iter));
Update.Bind_Param ("table", ADO.Parameters.Token (Counter.Table.Table.all));
Update.Bind_Param ("field", ADO.Parameters.Token (Counter.Field.all));
Update.Execute;
end if;
Counter_Maps.Next (Iter);
end loop;
end Flush;
-- ------------------------------
-- Flush the existing counters and update all the database records refered to them.
-- ------------------------------
procedure Flush (Plugin : in out Counter_Module) is
procedure Free is new
Ada.Unchecked_Deallocation (Object => Counter_Map_Array,
Name => Counter_Map_Array_Access);
Day : Ada.Calendar.Time;
Counters : Counter_Map_Array_Access;
begin
Plugin.Counters.Steal_Counters (Counters, Day);
if Counters = null then
return;
end if;
declare
DB : ADO.Sessions.Master_Session := Plugin.Get_Master_Session;
Date : constant Ada.Calendar.Time := Util.Dates.Get_Day_Start (Day);
Def_Id : Natural;
begin
DB.Begin_Transaction;
for I in Counters'Range loop
if not Counters (I).Is_Empty then
declare
Counter : constant Counter_Def := Counter_Arrays.Get_Element (I).all;
begin
Plugin.Counters.Get_Definition (DB, I, Def_Id);
Flush (DB, Counter, Def_Id, Counters (I), Date);
end;
end if;
end loop;
DB.Commit;
end;
Free (Counters);
end Flush;
end AWA.Counters.Modules;
|
zertovitch/excel-writer | Ada | 10,750 | adb | with Excel_Out;
with Ada.Calendar,
Ada.Characters.Handling,
Ada.Numerics.Float_Random,
Ada.Streams.Stream_IO,
Ada.Text_IO;
procedure Excel_Out_Demo is
use Excel_Out, Ada.Calendar;
procedure Small_Demo is
xl : Excel_Out.Excel_Out_File;
begin
xl.Create ("small.xls");
xl.Put_Line ("This is a small demo for Excel_Out");
for row in 3 .. 8 loop
for column in 1 .. 8 loop
xl.Write (row, column, row * 1000 + column);
end loop;
end loop;
xl.Close;
end Small_Demo;
procedure Big_Demo (ef : Excel_type) is
xl : Excel_Out_File;
font_1, font_2, font_3, font_for_title, font_5, font_6 : Font_type;
fmt_1, fmt_decimal_2, fmt_decimal_0, fmt_for_title, fmt_5, fmt_boxed, fmt_cust_num, fmt_8,
fmt_date_1, fmt_date_2, fmt_date_3, fmt_vertical : Format_type;
custom_num, custom_date_num : Number_format_type;
-- We test the output of some date (here: 2014-03-16 11:55:17)
some_time : constant Time := Time_Of (2014, 03, 16, Duration ((11.0 * 60.0 + 55.0) * 60.0 + 17.0));
damier : Natural;
use Ada.Characters.Handling;
begin
xl.Create ("big [" & To_Lower (ef'Image) & "].xls", ef, Windows_CP_1253);
xl.Zoom_level (85, 100); -- Zoom level 85% (Excel: Ctrl + one bump down with the mouse wheel)
-- Some page layout for printing...
xl.Header ("Big demo");
xl.Footer ("&D");
xl.Margins (1.2, 1.1, 0.9, 0.8);
xl.Print_Row_Column_Headers;
xl.Print_Gridlines;
xl.Page_Setup (fit_height_with_n_pages => 0, orientation => landscape, scale_or_fit => fit);
--
xl.Write_default_column_width (7);
xl.Write_column_width (1, 17); -- set to width of n times '0'
xl.Write_column_width (2, 11);
xl.Write_column_width (5, 11);
xl.Write_column_width (14, 0); -- hide this column
--
xl.Write_default_row_height (14);
xl.Write_row_height (1, 23); -- header row 1
xl.Write_row_height (2, 23); -- header row 2
xl.Write_row_height (9, 23);
xl.Write_row_height (11, 43);
xl.Write_row_height (13, 0); -- hide this row
--
xl.Define_Font ("Arial", 9, font_1, regular, blue);
xl.Define_Font ("Courier New", 11, font_2, bold & italic, red);
xl.Define_Font ("Times New Roman", 13, font_3, bold, teal);
xl.Define_Font ("Arial Narrow", 15, font_for_title, bold);
xl.Define_Font ("Calibri", 15, font_5, bold, dark_red);
xl.Define_Font ("Calibri", 9, font_6);
--
xl.Define_Number_Format (custom_num, "0.000000"); -- 6 decimals
xl.Define_Number_Format (custom_date_num, "yyyy\-mm\-dd\ hh:mm:ss"); -- ISO date
--
xl.Define_Format
(font => font_for_title,
number_format => general,
cell_format => fmt_for_title,
border => top & bottom,
vertical_align => centred);
--
xl.Define_Format (font_1, percent_0, fmt_1, centred, right);
xl.Define_Format (font_2, decimal_2, fmt_decimal_2);
xl.Define_Format (font_3, decimal_0_thousands_separator, fmt_decimal_0, centred);
xl.Define_Format (font_1, percent_2_plus, fmt_5, centred, right);
xl.Define_Format (font_5, general, fmt_boxed, border => box, vertical_align => centred);
xl.Define_Format (font_1, custom_num, fmt_cust_num, centred);
xl.Define_Format (font_6, general, fmt_8);
xl.Define_Format (font_6, dd_mm_yyyy, fmt_date_1, shaded => True, background_color => yellow);
xl.Define_Format (font_6, dd_mm_yyyy_hh_mm, fmt_date_2, background_color => yellow);
xl.Define_Format (font_6, hh_mm_ss, fmt_date_3, shaded => True); -- custom_date_num
xl.Define_Format (font_6, general, fmt_vertical, wrap_text => True, text_orient => rotated_90);
--
xl.Use_format (fmt_for_title);
xl.Put ("This is a big demo for Excel Writer / Excel_Out");
xl.Merge (6);
xl.Next;
xl.Put ("Excel format: " & ef'Image);
xl.Merge (1);
xl.New_Line;
xl.Freeze_Top_Row;
xl.Put ("Version: " & version);
xl.Merge (3);
xl.Next (4);
xl.Put ("Ref.: " & reference);
xl.Use_format (fmt_decimal_2);
for column in 1 .. 9 loop
xl.Write (3, column, Long_Float (column) + 0.5);
end loop;
xl.Use_format (fmt_8);
xl.Put (" <- = column + 0.5");
xl.Use_format (fmt_decimal_0);
for row in 4 .. 7 loop
for column in 1 .. 9 loop
damier := 10 + 990 * ((row + column) mod 2);
xl.Write (row, column, row * damier + column);
end loop;
end loop;
xl.Use_format (fmt_8);
xl.Put (" <- = row * (1000 or 10) + column");
xl.Use_format (fmt_for_title);
for column in 1 .. 20 loop
xl.Write (9, column, Character'Val (64 + column) & "");
end loop;
xl.Use_format (fmt_boxed);
xl.Write (11, 1, "Calibri font");
xl.Use_format (fmt_vertical);
xl.Put ("Wrapped text, rotated 90°");
xl.Use_format (fmt_8);
xl.Write (11, 4, "First number:");
xl.Write (11, 6, Long_Float'First);
xl.Write (11, 8, "Last number:");
xl.Write (11, 10, Long_Float'Last);
xl.Write (11, 12, "Smallest number:");
xl.Write (11, 15, (1.0 + Long_Float'Model_Epsilon) * Long_Float'Model_Small);
xl.Next;
-- Testing a specific code page (Windows_CP_1253), which was set upon the Create call above.
xl.Put_Line ("A few Greek letters (alpha, beta, gamma): " &
Character'Val (16#E1#) & ", " & Character'Val (16#E2#) & ", " & Character'Val (16#E3#)
);
-- Date: 2014-03-16 11:55:15
xl.Use_format (fmt_date_2);
xl.Put (some_time);
xl.Use_format (fmt_date_1);
xl.Put (some_time);
xl.Use_format (fmt_date_3);
xl.Put (some_time);
xl.Use_default_format;
xl.Put (0.0);
xl.Write_cell_comment_at_cursor ("This is a comment." & ASCII.LF & "Nice, isn't it ?");
xl.Put (" <- default fmt (general)");
xl.New_Line;
for row in 15 .. 300 loop
xl.Use_format (fmt_1);
xl.Write (row, 3, Long_Float (row) * 0.01);
xl.Use_format (fmt_5);
xl.Put (Long_Float (row - 100) * 0.001);
xl.Use_format (fmt_cust_num);
xl.Put (Long_Float (row - 15) + 0.123456);
end loop;
xl.Close;
end Big_Demo;
procedure Fancy is
xl : Excel_Out_File;
font_title, font_normal, font_normal_grey : Font_type;
fmt_title, fmt_subtitle, fmt_date, fmt_percent, fmt_amount : Format_type;
quotation_day : Time := Time_Of (2023, 03, 28, 9.0 * 3600.0);
price, last_price : Long_Float;
use Ada.Numerics.Float_Random;
gen : Generator;
begin
xl.Create ("fancy.xls");
-- Some page layout for printing...
xl.Header ("Fancy sheet");
xl.Footer ("&D");
xl.Margins (1.2, 1.1, 0.9, 0.8);
xl.Print_Gridlines;
xl.Page_Setup (fit_height_with_n_pages => 0, orientation => portrait, scale_or_fit => fit);
--
xl.Write_column_width (1, 15); -- set to width of n times '0'
xl.Write_column_width (3, 10); -- set to width of n times '0'
xl.Define_Font ("Calibri", 15, font_title, bold, white);
xl.Define_Font ("Calibri", 10, font_normal);
xl.Define_Font ("Calibri", 10, font_normal_grey, color => grey);
xl.Define_Format (font_title, general, fmt_title,
border => bottom, background_color => dark_blue,
vertical_align => centred
);
xl.Define_Format (font_normal, general, fmt_subtitle, border => bottom);
xl.Define_Format (font_normal, dd_mm_yyyy, fmt_date, background_color => silver);
xl.Define_Format (font_normal, decimal_0_thousands_separator, fmt_amount);
xl.Define_Format (font_normal_grey, percent_2_plus, fmt_percent);
xl.Use_format (fmt_title);
xl.Write_row_height (1, 25);
xl.Put ("Daily Excel Writer stock prices");
xl.Merge (3);
xl.New_Line;
xl.Use_format (fmt_subtitle);
xl.Put ("Date");
xl.Put ("Price");
xl.Put_Line ("Variation %");
xl.Freeze_Panes_at_cursor;
Reset (gen);
price := 950.0 + Long_Float (Random (gen)) * 200.0;
for i in 1 .. 3650 loop
xl.Use_format (fmt_date);
xl.Put (quotation_day);
quotation_day := quotation_day + Day_Duration'Last;
xl.Use_format (fmt_amount);
last_price := price;
-- Subtract 0.5 after Random for zero growth / inflation / ...
price := price * (1.0 + 0.1 * (Long_Float (Random (gen)) - 0.489));
xl.Put (price);
xl.Use_format (fmt_percent);
xl.Put_Line (price / last_price - 1.0);
end loop;
Close (xl);
end Fancy;
function My_nice_sheet (size : Positive) return String is
xl : Excel_Out_String;
begin
xl.Create;
xl.Put_Line ("This Excel file is fully created in memory.");
xl.Put_Line ("It can be stuffed directly into a zip stream,");
xl.Put_Line ("or sent from a server!");
xl.Put_Line ("- see ZipTest @ project Zip-Ada (search ""unzip-ada"" or ""zip-ada""");
for row in 1 .. size loop
for column in 1 .. size loop
xl.Write (row + 5, column, 0.01 + Long_Float (row * column));
end loop;
end loop;
xl.Close;
return xl.Contents;
end My_nice_sheet;
procedure String_Demo is
use Ada.Streams.Stream_IO;
f : File_Type;
begin
Create (f, Out_File, "from_string.xls");
String'Write (Stream (f), My_nice_sheet (200));
Close (f);
end String_Demo;
procedure Speed_Test is
xl : Excel_Out_File;
t0, t1 : Time;
iter : constant := 1000;
size : constant := 150;
secs : Long_Float;
dummy_int : Integer := 0;
begin
xl.Create ("speed_test.xls");
t0 := Clock;
for i in 1 .. iter loop
declare
dummy : constant String := My_nice_sheet (size);
begin
dummy_int := 0 * dummy_int + dummy'Length;
end;
end loop;
t1 := Clock;
secs := Long_Float (t1 - t0);
xl.Put_Line (
"Time (seconds) for creating" &
iter'Image & " sheets with" &
size'Image & " x" &
size'Image & " =" &
Integer'Image (size**2) & " cells"
);
xl.Put_Line (secs);
xl.Put_Line ("Sheets per second");
xl.Put_Line (Long_Float (iter) / secs);
xl.Close;
end Speed_Test;
use Ada.Text_IO;
begin
Put_Line ("Small demo -> small.xls");
Small_Demo;
Put_Line ("Big demo -> Big [...].xls");
for ef in BIFF3 .. BIFF4 loop
Big_Demo (ef);
end loop;
Put_Line ("Fancy sheet -> sancy.xls");
Fancy;
Put_Line ("Excel sheet in a string demo -> from_string.xls");
String_Demo;
Put_Line ("Speed test -> speed_test.xls");
Speed_Test;
end Excel_Out_Demo;
|
reznikmm/matreshka | Ada | 3,714 | 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.Form_Max_Length_Attributes is
pragma Preelaborate;
type ODF_Form_Max_Length_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Form_Max_Length_Attribute_Access is
access all ODF_Form_Max_Length_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Form_Max_Length_Attributes;
|
reznikmm/matreshka | Ada | 3,714 | 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_Frame_Name_Attributes is
pragma Preelaborate;
type ODF_Draw_Frame_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Frame_Name_Attribute_Access is
access all ODF_Draw_Frame_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Frame_Name_Attributes;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,492 | ads | -- This spec has been automatically generated from STM32F072x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.CRC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype IDR_IDR_Field is STM32_SVD.Byte;
-- Independent data register
type IDR_Register is record
-- General-purpose 8-bit data register bits
IDR : IDR_IDR_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IDR_Register use record
IDR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CR_RESET_Field is STM32_SVD.Bit;
subtype CR_REV_IN_Field is STM32_SVD.UInt2;
subtype CR_REV_OUT_Field is STM32_SVD.Bit;
-- Control register
type CR_Register is record
-- reset bit
RESET : CR_RESET_Field := 16#0#;
-- unspecified
Reserved_1_4 : STM32_SVD.UInt4 := 16#0#;
-- Reverse input data
REV_IN : CR_REV_IN_Field := 16#0#;
-- Reverse output data
REV_OUT : CR_REV_OUT_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
RESET at 0 range 0 .. 0;
Reserved_1_4 at 0 range 1 .. 4;
REV_IN at 0 range 5 .. 6;
REV_OUT at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- cyclic redundancy check calculation unit
type CRC_Peripheral is record
-- Data register
DR : aliased STM32_SVD.UInt32;
-- Independent data register
IDR : aliased IDR_Register;
-- Control register
CR : aliased CR_Register;
-- Initial CRC value
INIT : aliased STM32_SVD.UInt32;
end record
with Volatile;
for CRC_Peripheral use record
DR at 16#0# range 0 .. 31;
IDR at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
INIT at 16#C# range 0 .. 31;
end record;
-- cyclic redundancy check calculation unit
CRC_Periph : aliased CRC_Peripheral
with Import, Address => System'To_Address (16#40023000#);
end STM32_SVD.CRC;
|
faelys/natools | Ada | 2,792 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2014-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Cron.Tests provides a test suite for Natools.Cron. --
------------------------------------------------------------------------------
with Natools.Tests;
package Natools.Cron.Tests is
package NT renames Natools.Tests;
procedure All_Tests (Report : in out NT.Reporter'Class);
procedure Basic_Usage (Report : in out NT.Reporter'Class);
procedure Delete_While_Busy (Report : in out NT.Reporter'Class);
procedure Delete_While_Collision (Report : in out NT.Reporter'Class);
procedure Event_List_Extension (Report : in out NT.Reporter'Class);
procedure Event_List_Fusion (Report : in out NT.Reporter'Class);
procedure Insert_While_Busy (Report : in out NT.Reporter'Class);
procedure Time_Collision (Report : in out NT.Reporter'Class);
private
type Bounded_String (Max_Size : Natural) is record
Data : String (1 .. Max_Size);
Size : Natural := 0;
end record;
procedure Append (S : in out Bounded_String; C : Character);
function Get (S : Bounded_String) return String;
procedure Reset (S : in out Bounded_String);
type Test_Callback (Backend : access Bounded_String) is new Callback with
record
Symbol : Character;
end record;
overriding procedure Run (Self : in out Test_Callback);
type Long_Callback (Backend : access Bounded_String) is new Callback with
record
Open, Close : Character;
Wait : Duration;
end record;
overriding procedure Run (Self : in out Long_Callback);
end Natools.Cron.Tests;
|
stcarrez/server-faces-benchmark | Ada | 3,192 | adb | -----------------------------------------------------------------------
-- asfbench -- asfbench applications
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
package body Asfbench.Applications is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Asfbench");
-- ------------------------------
-- Initialize the application:
-- <ul>
-- <li>Register the servlets and filters.
-- <li>Register the application modules.
-- <li>Define the servlet and filter mappings.
-- </ul>
-- ------------------------------
procedure Initialize (App : in Application_Access;
Config : in ASF.Applications.Config) is
Fact : ASF.Applications.Main.Application_Factory;
begin
App.Self := App;
App.Initialize (Config, Fact);
App.Set_Global ("contextPath", CONTEXT_PATH);
end Initialize;
-- ------------------------------
-- Initialize the servlets provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the application servlets.
-- ------------------------------
overriding
procedure Initialize_Servlets (App : in out Application) is
begin
Log.Info ("Initializing application servlets...");
ASF.Applications.Main.Application (App).Initialize_Servlets;
App.Add_Servlet (Name => "faces", Server => App.Self.Faces'Access);
App.Add_Servlet (Name => "files", Server => App.Self.Files'Access);
App.Add_Servlet (Name => "ajax", Server => App.Self.Ajax'Access);
App.Add_Servlet (Name => "measures", Server => App.Self.Measures'Access);
App.Add_Servlet (Name => "auth", Server => App.Self.Auth'Access);
end Initialize_Servlets;
-- ------------------------------
-- Initialize the filters provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the application filters.
-- ------------------------------
overriding
procedure Initialize_Filters (App : in out Application) is
begin
Log.Info ("Initializing application filters...");
ASF.Applications.Main.Application (App).Initialize_Filters;
App.Add_Filter (Name => "dump", Filter => App.Self.Dump'Access);
App.Add_Filter (Name => "measures", Filter => App.Self.Measures'Access);
App.Add_Filter (Name => "no-cache", Filter => App.Self.No_Cache'Access);
end Initialize_Filters;
end Asfbench.Applications;
|
AdaCore/libadalang | Ada | 357 | adb | procedure Test is
package A is
type T is tagged null record;
procedure Foo (X : T) is null;
end A;
package B is
type T is new A.T with null record;
procedure Foo (X : T) is null;
end B;
package C is
type T is new B.T with null record;
procedure Foo (X : T) is null;
end C;
begin
null;
end Test;
|
sungyeon/drake | Ada | 3,613 | adb | with Ada.Containers.Array_Sorting;
with System.Long_Long_Integer_Types;
procedure Ada.Containers.Generic_Sort (First, Last : Index_Type'Base) 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
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean;
function LT (Left, Right : Word_Integer; Params : System.Address)
return Boolean
is
pragma Unreferenced (Params);
Left_Index : constant Index_Type := Index_Type'Val (Left);
Right_Index : constant Index_Type := Index_Type'Val (Right);
begin
return Before (Left_Index, Right_Index);
end LT;
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address);
procedure Swap (
Left, Right : Word_Integer;
Params : System.Address)
is
pragma Unreferenced (Params);
Left_Index : constant Index_Type := Index_Type'Val (Left);
Right_Index : constant Index_Type := Index_Type'Val (Right);
begin
Swap (Left_Index, Right_Index);
end Swap;
begin
Array_Sorting.In_Place_Merge_Sort (
Index_Type'Pos (First),
Index_Type'Pos (Last),
System.Null_Address,
LT => LT'Access,
Swap => Swap'Access);
end;
else
declare
type Context_Type is limited record
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 Before (Left_Index, 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);
begin
Swap (Left_Index, Right_Index);
end Swap;
Offset : constant Long_Long_Integer := Index_Type'Pos (First);
Context : aliased Context_Type := (Offset => Offset);
begin
Array_Sorting.In_Place_Merge_Sort (
0,
Word_Integer (Long_Long_Integer'(Index_Type'Pos (Last) - Offset)),
Context'Address,
LT => LT'Access,
Swap => Swap'Access);
end;
end if;
end Ada.Containers.Generic_Sort;
|
Yohann-Boniface-School/Ada-prime-calcutator | Ada | 2,652 | adb | ------------------------------------------------------------------------------
-- --
-- A SIGMANIFICIENT PROGRAM --
-- --
-- PRIME CALCULATOR --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO, Ada.Integer_Text_IO ;
use Ada.Text_IO, Ada.Integer_Text_IO ;
procedure Main is
count_prime : Integer ;
counter : Integer ;
wanted : Integer ;
iteration : Integer ;
testing : Integer ;
is_prime : Boolean ;
answer : Character ;
begin
loop
Put("Calculateur de nombre premiers") ;
New_line(2) ;
Put("Entrez 'p' pour calculer des premiers") ;
New_Line(1);
Put("Entrez 'q' pour quitter") ;
New_Line(2) ;
Put(">> ") ;
Get(answer) ;
Skip_line ;
if answer = 'p' then
Put("Entrez le nombre de premiers voulu : ");
Get(wanted) ;
Skip_line ;
iteration := 0 ;
count_prime := 0 ;
counter := 1 ;
if wanted > 0 then
Put("2");
New_Line(1);
if wanted > 1 then
Put("3");
New_Line(1);
end if ;
if wanted > 2 then
count_prime := 2;
loop
if counter = 1 then
counter := 0 ;
iteration := iteration + 1 ;
testing := ( 6 * iteration ) - 1 ;
else
counter := 1 ;
testing := ( 6 * iteration ) + 1 ;
end if ;
is_prime := True ;
for i in 2..(testing-1) loop
if (testing rem i = 0) then
is_prime := False ;
end if ;
end loop;
if is_prime = True then
Put(testing);
New_Line(1);
count_prime := count_prime + 1 ;
end if ;
exit when count_prime = wanted;
end loop ;
end if;
Put("Ended") ;
else
Put("Vous devez mettre un nombre positif ._.");
end if ;
end if ;
New_Line(3);
exit when answer = 'q' ;
end loop ;
end Main ;
-- Long life to prime ! --
|
Fabien-Chouteau/GESTE | Ada | 1,222 | adb | with Interfaces.C; use Interfaces.C;
with SDL_SDL_events_h; use SDL_SDL_events_h;
with SDL_SDL_keysym_h; use SDL_SDL_keysym_h;
package body Keyboard is
Is_Pressed : array (Key_Kind) of Boolean := (others => False);
------------
-- Update --
------------
procedure Update is
Evt : aliased SDL_Event;
begin
while SDL_PollEvent (Evt'Access) /= 0 loop
if Evt.c_type = SDL_KEYDOWN or else Evt.c_type = SDL_KEYUP then
case Evt.key.keysym.sym is
when SDLK_LEFT =>
Is_Pressed (Left) := Evt.c_type = SDL_KEYDOWN;
when SDLK_RIGHT =>
Is_Pressed (Right) := Evt.c_type = SDL_KEYDOWN;
when SDLK_DOWN =>
Is_Pressed (Down) := Evt.c_type = SDL_KEYDOWN;
when SDLK_UP =>
Is_Pressed (Up) := Evt.c_type = SDL_KEYDOWN;
when SDLK_ESCAPE =>
Is_Pressed (Esc) := Evt.c_type = SDL_KEYDOWN;
when others =>
null;
end case;
end if;
end loop;
end Update;
-------------
-- Pressed --
-------------
function Pressed (Key : Key_Kind) return Boolean
is (Is_Pressed (Key));
end Keyboard;
|
jwarwick/aoc_2020 | Ada | 2,957 | adb | -- AoC 2020, Day 5
with Ada.Text_IO;
package body Day is
package TIO renames Ada.Text_IO;
function parse_line(line : in String) return Boarding_Pass is
curr : Boarding_Pass;
begin
declare
low : Row_Type := Row_Type'first;
high : Row_Type := Row_Type'last;
tmp : Float;
begin
for idx in 0..6 loop
tmp := (Float(high)-Float(low))/2.0;
if line(line'first + idx) = 'B' then
low := low + Row_Type(Float'Floor(tmp)) + 1;
curr.Row := low;
elsif line(line'first + idx) = 'F' then
high := high - Row_Type(Float'Floor(tmp)) - 1;
curr.Row := high;
else
TIO.put_line("Don't know that value: " & line(line'first + idx));
return curr;
end if;
end loop;
end;
declare
low : Seat_Type := Seat_Type'first;
high : Seat_Type := Seat_Type'last;
tmp : Float;
begin
for idx in 7..9 loop
tmp := (Float(high)-Float(low))/2.0;
if line(line'first + idx) = 'R' then
low := low + Seat_Type(Float'Floor(tmp)) + 1;
curr.Seat := low;
elsif line(line'first + idx) = 'L' then
high := high - Seat_Type(Float'Floor(tmp)) - 1;
curr.Seat := high;
else
TIO.put_line("Don't know that value: " & line(line'first + idx));
return curr;
end if;
end loop;
end;
return curr;
end parse_line;
function load_batch(filename : in String) return Boarding_Pass_Vectors.Vector is
file : TIO.File_Type;
output : Boarding_Pass_Vectors.Vector;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
declare
curr : constant Boarding_Pass := parse_line(TIO.get_line(file));
begin
output.append(curr);
end;
end loop;
TIO.close(file);
return output;
end load_batch;
function seat_id(pass : in Boarding_Pass) return Natural is
begin
return (Natural(pass.row) * 8) + Natural(pass.seat);
end seat_id;
function highest_id(passes : in Boarding_Pass_Vectors.Vector) return Natural is
max : Natural := 0;
curr : Natural := 0;
begin
for p of passes loop
curr := seat_id(p);
if curr > max then
max := curr;
end if;
end loop;
return max;
end highest_id;
package ID_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Natural);
package ID_Sorter is new ID_Vectors.Generic_Sorting;
function missing_id(passes : in Boarding_Pass_Vectors.Vector) return Natural is
ids : ID_Vectors.Vector;
last : Natural;
begin
for p of passes loop
ids.append(seat_id(p));
end loop;
ID_Sorter.sort(ids);
last := ids(ids.first_index) - 1;
for id of ids loop
if id /= (last + 1) then
return id-1;
end if;
last := id;
end loop;
return 0;
end missing_id;
end Day;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 7,952 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Real_Time; use Ada.Real_Time;
with HAL.SDMMC; use HAL.SDMMC;
with STM32.Board; use STM32.Board;
with STM32.Device; use STM32.Device;
with STM32.DMA; use STM32.DMA;
with STM32.GPIO; use STM32.GPIO;
with STM32.SDMMC; use STM32.SDMMC;
with STM32.SDMMC_Interrupt; use STM32.SDMMC_Interrupt;
package body SDCard is
SD_Interrupt_Handler : aliased SDMMC_Interrupt_Handler (SD_Interrupt);
----------------
-- Initialize --
----------------
procedure Initialize
(This : in out SDCard_Controller)
is
begin
Set_Clock_Source (This.Device.all, Src_Sysclk);
-- Enable the GPIOs
Enable_Clock (SD_Pins & SD_Pins_2 & SD_Detect_Pin);
-- GPIO configuration for the SDIO pins
Configure_IO
(SD_Pins,
(Mode => Mode_AF,
AF => SD_Pins_AF,
AF_Output_Type => Push_Pull,
AF_Speed => Speed_High,
Resistors => Pull_Up));
Configure_IO
(SD_Pins_2,
(Mode => Mode_AF,
AF => SD_Pins_AF_2,
AF_Output_Type => Push_Pull,
AF_Speed => Speed_High,
Resistors => Pull_Up));
-- GPIO configuration for the SD-Detect pin
Configure_IO
(SD_Detect_Pin,
(Mode => Mode_In,
-- Output_Type => Open_Drain,
-- Speed => Speed_High,
Resistors => Pull_Up));
-- Enable the SDIO clock
STM32.Device.Enable_Clock (This.Device.all);
STM32.Device.Reset (This.Device.all);
-- Enable the DMA2 clock
Enable_Clock (SD_DMA);
Disable (SD_DMA, SD_DMA_Rx_Stream);
Configure
(SD_DMA,
SD_DMA_Rx_Stream,
(Channel => SD_DMA_Rx_Channel,
Direction => Peripheral_To_Memory,
Increment_Peripheral_Address => False,
Increment_Memory_Address => True,
Peripheral_Data_Format => Words,
Memory_Data_Format => Words,
Operation_Mode => Peripheral_Flow_Control_Mode,
Priority => Priority_Very_High,
FIFO_Enabled => True,
FIFO_Threshold => FIFO_Threshold_Full_Configuration,
Memory_Burst_Size => Memory_Burst_Inc4,
Peripheral_Burst_Size => Peripheral_Burst_Inc4));
Clear_All_Status (SD_DMA, SD_DMA_Rx_Stream);
Disable (SD_DMA, SD_DMA_Tx_Stream);
Configure
(SD_DMA,
SD_DMA_Tx_Stream,
(Channel => SD_DMA_Tx_Channel,
Direction => Memory_To_Peripheral,
Increment_Peripheral_Address => False,
Increment_Memory_Address => True,
Peripheral_Data_Format => Words,
Memory_Data_Format => Words,
Operation_Mode => Peripheral_Flow_Control_Mode,
Priority => Priority_Very_High,
FIFO_Enabled => True,
FIFO_Threshold => FIFO_Threshold_Full_Configuration,
Memory_Burst_Size => Memory_Burst_Inc4,
Peripheral_Burst_Size => Peripheral_Burst_Inc4));
Clear_All_Status (SD_DMA, SD_DMA_Tx_Stream);
This.Device.Enable_DMA_Transfers (RX_Int => SD_Rx_DMA_Int'Access,
TX_Int => SD_Tx_DMA_Int'Access,
SD_Int => SD_Interrupt_Handler'Access);
end Initialize;
------------------
-- Card_Present --
------------------
function Card_Present
(This : in out SDCard_Controller) return Boolean
is
begin
if STM32.GPIO.Set (SD_Detect_Pin) then
-- No card
This.Device.Clear_Card_Information;
This.Card_Detected := False;
else
-- Card detected. Just wait a bit to unbounce the signal from the
-- detect pin
if not This.Card_Detected then
delay until Clock + Milliseconds (50);
end if;
This.Card_Detected := not STM32.GPIO.Set (SD_Detect_Pin);
end if;
return This.Card_Detected;
end Card_Present;
--------------------------
-- Get_Card_information --
--------------------------
function Get_Card_Information
(This : in out SDCard_Controller)
return HAL.SDMMC.Card_Information
is
begin
This.Device.Ensure_Card_Informations;
if not This.Device.Has_Card_Information then
raise Device_Error;
end if;
return This.Device.Card_Information;
end Get_Card_Information;
----------------
-- Block_Size --
----------------
function Block_Size
(This : in out SDCard_Controller)
return UInt32
is
begin
return This.Get_Card_Information.Card_Block_Size;
end Block_Size;
-----------
-- Write --
-----------
overriding function Write
(This : in out SDCard_Controller;
Block_Number : UInt64;
Data : Block) return Boolean
is
begin
return This.Device.Write (Block_Number, Data);
end Write;
----------
-- Read --
----------
overriding function Read
(This : in out SDCard_Controller;
Block_Number : UInt64;
Data : out Block) return Boolean
is
begin
return This.Device.Read (Block_Number, Data);
end Read;
end SDCard;
|
reznikmm/matreshka | Ada | 4,632 | 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.Leader_Style_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Leader_Style_Attribute_Node is
begin
return Self : Style_Leader_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_Leader_Style_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Leader_Style_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Leader_Style_Attribute,
Style_Leader_Style_Attribute_Node'Tag);
end Matreshka.ODF_Style.Leader_Style_Attributes;
|
reznikmm/matreshka | Ada | 4,673 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Draw_Handle_Elements;
package Matreshka.ODF_Draw.Handle_Elements is
type Draw_Handle_Element_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Element_Node
and ODF.DOM.Draw_Handle_Elements.ODF_Draw_Handle
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Draw_Handle_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Handle_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Draw_Handle_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Draw_Handle_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Draw_Handle_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Draw.Handle_Elements;
|
AaronC98/PlaneSystem | Ada | 3,250 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2007-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;
package AWS.URL.Set is
function Parameters
(URL : not null access Object) return access AWS.Parameters.List
with Inline;
-- Returned the URL's parameters list object This is intended to pass
-- the internal parameters list component to routines in
-- AWS.Parameters.Set.
procedure Parameters (URL : in out Object; Set : AWS.Parameters.List)
with Inline;
-- Set the URL's parameters list to Set
procedure Connection_Data
(URL : in out Object;
Host : String;
Port : Positive;
Security : Boolean);
-- Update connection data, used by the server
procedure Security (URL : in out Object; Flag : Boolean);
-- Update protocol security flag of the URL.
-- Change port to default of new protocol if port was default on
-- previous protocol.
procedure Parse
(Item : in out Object;
URL : String;
Check_Validity : Boolean := True;
Normalize : Boolean := False);
end AWS.URL.Set;
|
tum-ei-rcs/StratoX | Ada | 25,748 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . L I B M _ D O U B L E --
-- --
-- B o d y --
-- --
-- Copyright (C) 2014-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Ada Cert Math specific version of s-libdou.adb
-- When Cody and Waite implementation is cited, it refers to the
-- Software Manual for the Elementary Functions by William J. Cody, Jr.
-- and William Waite, published by Prentice-Hall Series in Computational
-- Mathematics. Copyright 1980. ISBN 0-13-822064-6.
-- When Hart implementation is cited, it refers to
-- "Computer Approximations" by John F. Hart, published by Krieger.
-- Copyright 1968, Reprinted 1978 w/ corrections. ISBN 0-88275-642-7.
with Ada.Numerics; use Ada.Numerics;
with System.Libm; use System.Libm;
with System.Libm_Double.Squareroot;
package body System.Libm_Double is
subtype LF is Long_Float;
pragma Assert (LF'Machine_Radix = 2);
pragma Assert (LF'Machine_Mantissa = 53);
LF_HM : constant Integer := Long_Float'Machine_Mantissa / 2;
Sqrt_Epsilon_LF : constant Long_Float :=
Sqrt_2 ** (1 - Long_Float'Machine_Mantissa);
type Long_Float_Table is array (Positive range <>) of Long_Float;
-- A1 (i) = Float (2**((1-i)/16))
A1_Tab_LF : constant Long_Float_Table :=
(1.0,
Long_Float'Machine (Root16_Half),
Long_Float'Machine (Root16_Half**2),
Long_Float'Machine (Root16_Half**3),
Long_Float'Machine (Root16_Half**4),
Long_Float'Machine (Root16_Half**5),
Long_Float'Machine (Root16_Half**6),
Long_Float'Machine (Root16_Half**7),
Long_Float'Machine (Root16_Half**8),
Long_Float'Machine (Root16_Half**9),
Long_Float'Machine (Root16_Half**10),
Long_Float'Machine (Root16_Half**11),
Long_Float'Machine (Root16_Half**12),
Long_Float'Machine (Root16_Half**13),
Long_Float'Machine (Root16_Half**14),
Long_Float'Machine (Root16_Half**15),
0.5);
-- A2 (i) = 2**((1-2i)/16) - A1(2i)
A2_Tab_LF : constant Long_Float_Table :=
(Root16_Half - Long_Float'Machine (Root16_Half),
Root16_Half**3 - Long_Float'Machine (Root16_Half**3),
Root16_Half**5 - Long_Float'Machine (Root16_Half**5),
Root16_Half**7 - Long_Float'Machine (Root16_Half**7),
Root16_Half**9 - Long_Float'Machine (Root16_Half**9),
Root16_Half**11 - Long_Float'Machine (Root16_Half**11),
Root16_Half**13 - Long_Float'Machine (Root16_Half**13),
Root16_Half**15 - Long_Float'Machine (Root16_Half**15));
-- Intermediary functions
function Reconstruct_Pow
(Z : Long_Float;
P : Integer;
M : Integer) return Long_Float;
procedure Reduce_044
(X : Long_Float;
Reduced_X : out Long_Float;
P : out Integer)
with Post => abs (Reduced_X) < 0.044;
function Reduce_1_16 (X : Long_Float) return Long_Float
with Post => abs (X - Reduce_1_16'Result) <= 0.0625;
function Reduce_1_16 (X : Long_Float) return Long_Float is
(LF'Machine_Rounding (X * 16.0) * (1.0 / 16.0));
package Long_Float_Approximations is
new Generic_Approximations (Long_Float, Mantissa => 53);
use Long_Float_Approximations;
-- Local declarations
procedure Reduce_Half_Pi_Large (X : in out LF; N : LF; Q : out Quadrant);
procedure Split_Veltkamp (X : Long_Float; X_Hi, X_Lo : out Long_Float)
with Post => X = X_Hi + X_Lo;
function Multiply_Add (X, Y, Z : LF) return LF is (X * Y + Z);
-- The following functions reduce a positive X into the range
-- -ln (2) / 2 .. ln (2) / 2
-- It returns a reduced X and an integer N such that:
-- X'Old = X'New + N * Log (2)
-- It is used by Exp function
-- The result should be correctly rounded
procedure Reduce_Ln_2 (X : in out Long_Float; N : out Integer)
with Pre => abs (X) <= Long_Float'Ceiling
(Long_Float'Pred (709.78271_28337_79350_29149_8) * Inv_Ln_2);
-- @llr Reduce_Ln_2 Long_Float
-- The following is postcondition doesn't hold. Suspicious "=" ???
-- Post => abs (X) <= Ln_2 / 2.0 and
-- X'Old = X + Long_Float (N) * Ln_2;
-- The reduction is used by the Sin, Cos and Tan functions.
procedure Reduce_Half_Pi (X : in out Long_Float; Q : out Quadrant)
with Pre => X >= 0.0,
Post => abs (X) <= Max_Red_Trig_Arg;
-- @llr Reduce_Half_Pi Long_Float
-- The following functions reduce a positive X into the range
-- -(Pi/4 + E) .. Pi/4 + E, with E a small fraction of Pi.
--
-- The reason the normalization is not strict is that the computation of
-- the number of times to subtract half Pi is not exact. The rounding
-- error is worst for large arguments, where the number of bits behind
-- the radix point reduces to half the mantissa bits.
-- While it would be possible to correct for this, the polynomial
-- approximations work well for values slightly outside the -Pi/4 .. Pi/4
-- interval, so it is easier for both error analysis and implementation
-- to leave the reduction non-strict, and assume the reduced argument is
-- within -0.26 * Pi .. 0.26 * Pi rather than a quarter of pi.
-- The reduction is guaranteed to be correct to within 0.501 ulp for
-- values of X for which Ada's accuracy guarantees apply:
-- abs X <= 2.0**(T'Machine_Mantissa / 2)
-- For values outside this range, an attempt is made to have significance
-- decrease only proportionally with increase of magnitued. In any case,
-- for all finite arguments, the reduction will succeed, though the reduced
-- value may not agree with the mathematically correct value in even its
-- sign.
---------------------
-- Reconstruct_Pow --
---------------------
function Reconstruct_Pow
(Z : Long_Float;
P : Integer;
M : Integer) return Long_Float
is
-- Cody and Waite implementation (in "**" function page 84)
-- The following computation is carried out in two steps. First add 1 to
-- Z and multiply by 2**(-P/16). Then multiply the result by 2**M.
Result : Long_Float;
begin
Result := A1_Tab_LF (P + 1) * Z;
return Long_Float'Scaling (Result, M);
end Reconstruct_Pow;
----------------
-- Reduce_044 --
----------------
procedure Reduce_044
(X : Long_Float;
Reduced_X : out Long_Float;
P : out Integer)
is
-- Cody and Waite implementation (in "**" function page 84)
-- The output is:
-- P is the biggest odd Integer in range 1 .. 15 such that
-- 2^((1-P)/16) <= X.
-- Reduced_X equals 2 * (X-2^(-P/16)) / (X + 2^(-P/16)).
-- abs (Reduced_X) <= max (2^(2-P/16)-2^(1-P/16)) <= 0.443.
begin
P := 1;
if X <= A1_Tab_LF (9) then
P := 9;
end if;
if X <= A1_Tab_LF (P + 4) then
P := P + 4;
end if;
if X <= A1_Tab_LF (P + 2) then
P := P + 2;
end if;
Reduced_X := (X - A1_Tab_LF (P + 1)) - A2_Tab_LF ((P + 1) / 2);
Reduced_X := Reduced_X / (X + A1_Tab_LF (P + 1));
Reduced_X := Reduced_X + Reduced_X;
end Reduce_044;
--------------------
-- Instantiations --
--------------------
package Instantiations is
function Acos is new Generic_Acos (LF);
function Atan2 is new Generic_Atan2 (LF);
end Instantiations;
--------------------
-- Split_Veltkamp --
--------------------
procedure Split_Veltkamp (X : Long_Float; X_Hi, X_Lo : out Long_Float) is
M : constant LF := 0.5 + 2.0**(1 - LF'Machine_Mantissa / 2);
begin
X_Hi := X * M - (X * M - X);
X_Lo := X - X_Hi;
end Split_Veltkamp;
-----------------
-- Reduce_Ln_2 --
-----------------
procedure Reduce_Ln_2 (X : in out Long_Float; N : out Integer) is
L1 : constant := Long_Float'Leading_Part (Ln_2, LF_HM);
L2 : constant := Long_Float'Leading_Part (Ln_2 - L1, LF_HM);
L3 : constant := Ln_2 - L2 - L1;
XN : constant Long_Float := Long_Float'Rounding (X * Inv_Ln_2);
begin
-- The argument passed to the function is smaller than Ymax * 1/log(2)
-- No overflow is possible for N (Ymax is the largest machine number
-- less than Log (LF'Last)).
N := Integer (XN);
X := ((X - XN * L1) - XN * L2) - XN * L3;
if X < -Ln_2 / 2.0 then
X := X + Ln_2;
N := N - 1;
end if;
if X > Ln_2 / 2.0 then
X := X - Ln_2;
N := N + 1;
end if;
end Reduce_Ln_2;
--------------------
-- Reduce_Half_Pi --
--------------------
procedure Reduce_Half_Pi (X : in out Long_Float; Q : out Quadrant) is
K : constant := Pi / 2.0;
Bits_N : constant := 3;
Max_N : constant := 2.0**Bits_N - 1.0;
Max_X : constant LF := LF'Pred (K * Max_N); -- About 3.5 * Pi
Bits_C : constant := LF'Machine_Mantissa - Bits_N;
C1 : constant LF := LF'Leading_Part (K, Bits_C);
C2 : constant LF := K - C1;
N : constant LF := LF'Machine_Rounding (X * K**(-1));
begin
if not X'Valid then
X := X - X;
Q := 0;
elsif abs X > Max_X then
Reduce_Half_Pi_Large (X, N, Q);
else
pragma Assert (if X'Valid then abs N <= Max_N);
X := (X - N * C1) - N * C2;
Q := Integer (N) mod 4;
end if;
end Reduce_Half_Pi;
--------------------------
-- Reduce_Half_Pi_Large --
--------------------------
procedure Reduce_Half_Pi_Large (X : in out LF; N : LF; Q : out Quadrant) is
type Int_64 is range -2**63 .. 2**63 - 1; -- used for conversions
HM : constant Positive := LF'Machine_Mantissa / 2;
C1 : constant LF := LF'Leading_Part (Half_Pi, HM);
C2 : constant LF := LF'Leading_Part (Half_Pi - C1, HM);
C3 : constant LF := LF'Leading_Part (Half_Pi - C1 - C2, HM);
C4 : constant LF := Half_Pi - C1 - C2 - C3;
K : LF := N;
K_Hi : LF;
K_Lo : LF;
begin
Q := 0;
loop
Split_Veltkamp (X => K, X_Hi => K_Hi, X_Lo => K_Lo);
X := Multiply_Add (-K_Hi, C1, X);
X := Multiply_Add (-K_Hi, C2, Multiply_Add (-K_Lo, C1, X));
X := Multiply_Add (-K_Hi, C3, Multiply_Add (-K_Lo, C2, X));
X := Multiply_Add (-K_Hi, C4, Multiply_Add (-K_Lo, C3, X));
X := Multiply_Add (-K_Lo, C4, X);
if abs K < 2.0**62 then
Q := Quadrant ((Int_64 (Q) + Int_64 (N)) mod 4);
elsif abs K_Lo <= 2.0**62 then
Q := Quadrant ((Int_64 (Q) + Int_64 (N)) mod 4);
end if;
exit when X in -0.26 * Pi .. 0.26 * Pi;
K := LF'Machine_Rounding (X * Half_Pi**(-1));
end loop;
end Reduce_Half_Pi_Large;
----------
-- Acos --
----------
function Acos (X : LF) return LF is (Instantiations.Acos (X));
-----------
-- Acosh --
-----------
function Acosh (X : LF) return LF is
-- Math based implementation using Log1p: x-> Log (1+x)
T : constant LF := X - 1.0;
begin
if X > 1.0 / Sqrt_Epsilon_LF then
return Log (X) + Ln_2;
elsif X < 2.0 then
return Log1p (T + Sqrt (2.0 * T + T * T));
else
return Log (X + Sqrt ((X - 1.0) * (X + 1.0)));
end if;
end Acosh;
----------
-- Asin --
----------
function Asin (X : LF) return LF is (Long_Float_Approximations.Asin (X));
-----------
-- Asinh --
-----------
function Asinh (X : LF) return LF is
-- Math based implementation using Log1p: x-> Log (1+x)
Y : constant LF := abs X;
G : constant LF := X * X;
Res : LF;
begin
if Y < Sqrt_Epsilon_LF then
Res := Y;
elsif Y > 1.0 / Sqrt_Epsilon_LF then
Res := Log (Y) + Ln_2;
elsif Y < 2.0 then
Res := Log1p (Y + G / (1.0 + Sqrt (G + 1.0)));
else
Res := Log (Y + Sqrt (G + 1.0));
end if;
return LF'Copy_Sign (Res, X);
end Asinh;
----------
-- Atan --
----------
function Atan (X : LF) return LF is (Instantiations.Atan2 (X, 1.0));
-----------
-- Atan2 --
-----------
function Atan2 (Y, X : LF) return LF is (Instantiations.Atan2 (Y, X));
-----------
-- Atanh --
-----------
function Atanh (X : LF) return LF is
-- Math based implementation using Log1p: x-> Log (1+x)
(if X >= 0.0
then Log1p (2.0 * X / (1.0 - X)) / 2.0
else -Log1p (-2.0 * X / (1.0 + X)) / 2.0);
---------
-- Cos --
---------
function Cos (X : LF) return LF is
-- Math based implementation using Hart constants
Y : LF := abs (X);
Q : Quadrant;
Result : LF;
begin
Reduce_Half_Pi (Y, Q);
if Q mod 2 = 0 then
Result := Approx_Cos (Y);
else
Result := Approx_Sin (Y);
end if;
return (if Q = 1 or else Q = 2 then -Result else Result);
end Cos;
----------
-- Cosh --
----------
function Cosh (X : LF) return LF is
-- Cody and Waite implementation (page 217)
Y : constant LF := abs (X);
-- Because the overflow threshold for cosh(X) is beyond the overflow
-- threshold for exp(X), it appears natural to reformulate the
-- computation as:
-- Cosh (X) = Exp (X - Log (2))
-- But because Log (2) is not an exact machine number, the finite word
-- length of the machine implies that the absolute error in X - Log (2),
-- hence the transmitted error in Cosh (X) is proportional to the
-- magnitude of X even when X is error-free.
-- To avoid this problem, we revise the computation to
-- Cosh (X) = V/2 * exp(X - Log (V))
-- where Log (V) is an exact machine number slightly larger than Log (2)
-- with the last few digits of its significand zero.
Ln_V : constant := 8#0.542714#;
-- Machine value slightly above Ln_2
V_2 : constant := 0.24999_30850_04514_99336;
-- V**(-2)
V_2_1 : constant := 0.13830_27787_96019_02638E-4;
-- V / 2 - 1
Y_Bar : constant Long_Float := 709.78271_28933_83973_096;
-- Y_Bar is the last floating point for which exp (Y) does not overflow
-- and exp (-Y) does not underflow
W : LF;
Z : LF;
begin
if Y >= Y_Bar then
W := Y - Ln_V;
Z := Exp (W);
Z := Z + V_2 / Z;
return Z + V_2_1 * Z; -- rewriting of V/2 * Z
else
Z := Exp (Y);
return (Z + 1.0 / Z) / 2.0;
end if;
end Cosh;
---------
-- Exp --
---------
function Exp (X : LF) return LF is
-- Cody and Waite implementation (page 60)
N : Integer;
Y : LF := X;
R : LF;
Ymax : constant LF := LF'Pred (709.78271_28337_79350_29149_8);
-- The largest machine number less than Log (LF'Last)
begin
if abs (Y) < 2.0**(-LF'Machine_Mantissa - 1) then
return 1.0;
end if;
if abs Y > Ymax then
return (if Y > 0.0 then Infinity else 0.0);
end if;
Reduce_Ln_2 (Y, N);
R := Approx_Exp (Y);
return Long_Float'Scaling (R, N);
end Exp;
----------
-- Exp2 --
----------
function Exp2 (X : LF) return LF is
-- Implementation based on Cody and Waite Exp implementation (page 217)
-- but using Hart constants
N : Integer;
Y : LF := X;
R : LF;
Result : LF;
begin
if abs Y < 2.0**(-LF'Machine_Mantissa - 1) then
return 1.0;
end if;
if abs Y > LF'Pred (LF (LF'Machine_Emax)) then
return (if Y > 0.0 then Infinity else 0.0);
end if;
-- If X > Log(LF'Emax) ???
N := Integer (X);
Y := Y - Long_Float (N);
R := Approx_Exp2 (Y);
Result := Long_Float'Scaling (R, N + 1);
if Result /= Result then
Result := (if X < LF'First then 0.0 else Infinity);
end if;
return Result;
end Exp2;
---------
-- Log --
---------
function Log (X : LF) return LF is
-- Cody and Waite implementation (page 35)
Exponent_X : constant Integer := LF'Exponent (X);
XN : LF := LF (Exponent_X);
Mantissa_X : LF := LF'Scaling (X, -Exponent_X);
HM : constant Integer := LF'Machine_Mantissa / 2;
L1 : constant LF := LF'Leading_Part (Ln_2, HM);
L2 : constant LF := Ln_2 - L1;
Result : LF;
begin
if X <= 0.0 then
if X < 0.0 then
return NaN;
else
return -Infinity;
end if;
-- Making sure X is in Sqrt (0.5) .. Sqrt (2)
elsif X > Long_Float'Last then
return X;
elsif Mantissa_X <= Sqrt_Half then
XN := XN - 1.0;
Mantissa_X := Mantissa_X * 2.0;
end if;
Result := Approx_Log (Mantissa_X);
Result := (XN * L2 + Result) + XN * L1;
return Result;
end Log;
-----------
-- Log1p --
-----------
function Log1p (X : LF) return LF is
-- Quick implementation of Log1p not accurate to the Ada regular Log
-- requirements, but accurate enough to compute inverse hyperbolic
-- functions.
begin
if 1.0 + X = 1.0 then
return X;
elsif X > LF'Last then
return X;
else
return Log (1.0 + X) * (X / ((1.0 + X) - 1.0));
end if;
end Log1p;
----------
-- Log2 --
----------
function Log2 (X : LF) return LF is
-- Quick implementation of Log2 not accurate to the Ada regular Log
-- (base e) requirement on the whole definition interval but accurate
-- enough on 0 .. 2**(-1/16).
(Log (X) * (1.0 / Ln_2));
---------
-- Pow --
---------
function Pow (Left, Right : LF) return LF is
-- Cody and Waite implementation (page 84)
One_Over_Sixteen : constant := 0.0625;
M : constant Integer := LF'Exponent (Left);
G : constant LF := LF'Fraction (Left);
Y : constant LF := Right;
Z : LF;
P : Integer;
U2, U1, Y1, Y2, W1, W2, W : LF;
MM, PP, IW1, I : Integer;
Is_Special : Boolean;
Special_Result : LF;
procedure Pow_Special_Cases is new Generic_Pow_Special_Cases (LF);
begin
-- Special values
Pow_Special_Cases (Left, Right, Is_Special, Special_Result);
if Is_Special then
return Special_Result;
else
-- Left**Right is calculated using the formula
-- 2**(Right * Log2 (Left))
Reduce_044 (G, Z, P);
-- At this point, Z <= 0.044
U2 := Approx_Power_Log (Z);
U1 := LF (M * 16 - P) * 0.0625; -- U2 + U1 = Log2 (Left)
-- Forming the pseudo extended precision product of U * Right
Y1 := Reduce_1_16 (Y);
Y2 := Y - Y1;
W := U2 * Y + U1 * Y2;
W1 := Reduce_1_16 (W);
W2 := W - W1;
W := W1 + U1 * Y1;
W1 := Reduce_1_16 (W);
W2 := W2 + (W - W1);
W := Reduce_1_16 (W2);
IW1 := Integer (16.0 * (W1 + W));
W2 := W2 - W;
if W2 > 0.0 then
W2 := W2 - One_Over_Sixteen;
IW1 := 1 + IW1;
end if;
if IW1 < 0 then
I := 0;
else
I := 1;
end if;
MM := Integer (IW1 / 16) + I;
PP := 16 * MM - IW1;
Z := Approx_Exp2 (W2);
return Reconstruct_Pow (Z, PP, MM);
end if;
end Pow;
---------
-- Sin --
---------
function Sin (X : LF) return LF is
-- Math based implementation using Hart constants
Y : LF := abs X;
Q : Quadrant;
Result : LF;
begin
Reduce_Half_Pi (Y, Q);
if Q mod 2 = 0 then
Result := Approx_Sin (Y);
else
Result := Approx_Cos (Y);
end if;
return LF'Copy_Sign (1.0, X) * (if Q >= 2 then -Result else Result);
end Sin;
----------
-- Sinh --
----------
function Sinh (X : LF) return LF is
-- Cody and Waite implementation (page 217)
Sign : constant LF := LF'Copy_Sign (1.0, X);
Y : constant LF := abs X;
-- Because the overflow threshold for sinh(X) is beyond the overflow
-- threshold for exp(X), it appears natural to reformulate the
-- computation as:
-- Sinh (X) = Exp (X - Log (2))
-- But because Log (2) is not an exact machine number, the finite word
-- length of the machine implies that the absolute error in X - Log (2),
-- hence the transmitted error in Sinh (X) is proportional to the
-- magnitude of X even when X is error-free. To avoid this problem, we
-- revise the computation to:
-- Sinh (X) = V/2 * exp(X - Log (V))
-- where Log (V) is an exact machine number slightly larger than Log (2)
-- with the last few digits of its significand zero.
Ln_V : constant := 8#0.542714#;
-- Machine value slightly above Ln_2
V_2 : constant := 0.24999_30850_04514_99336;
-- V**(-2)
V_2_1 : constant := 0.13830_27787_96019_02638E-4;
-- V / 2 - 1
Y_Bar : constant Long_Float := 709.78271_28933_83973_096;
-- The last floating point for which exp (X) does not overflow and
-- exp (-x) does not underflow
W : LF;
Z : LF;
begin
if Y <= 1.0 then
return Approx_Sinh (X);
end if;
if Y >= Y_Bar then
W := Y - Ln_V;
Z := Exp (W);
Z := Z - V_2 / Z;
return Sign * (Z + V_2_1 * Z); -- rewriting of V/2 * Z
else
Z := Exp (Y);
return Sign * ((Z - 1.0 / Z) / 2.0);
end if;
end Sinh;
----------
-- Sqrt --
----------
function Sqrt (X : Long_Float) return Long_Float renames
System.Libm_Double.Squareroot.Sqrt;
---------
-- Tan --
---------
function Tan (X : LF) return LF is
-- Math based implementation using Hart constants
Y : LF := abs X;
N : Integer;
begin
if abs X < LF'Last then
Reduce_Half_Pi (Y, N);
else
return Infinity / Infinity;
end if;
-- The reconstruction is included in the algebraic fraction in
-- Approx_Tan function.
if N mod 2 = 0 then
return Approx_Tan (Y) * LF'Copy_Sign (1.0, X);
else
return Approx_Cot (Y) * LF'Copy_Sign (1.0, X);
end if;
end Tan;
----------
-- Tanh --
----------
function Tanh (X : LF) return LF is
-- Cody and Waite implementation (page 239)
F : constant LF := abs (X);
Xbig : constant := Ln_2 * LF (1 + LF'Machine_Mantissa);
LN_3_2 : constant := 0.54930_61443_34054_84570;
Result : LF;
begin
if F > Xbig then
Result := 1.0;
else
if F > LN_3_2 then
Result := 1.0 - 2.0 / (Exp (2.0 * F) + 1.0);
else
Result := Approx_Tanh (F);
end if;
end if;
return LF'Copy_Sign (Result, X);
end Tanh;
end System.Libm_Double;
|
stcarrez/swagger-ada | Ada | 10,707 | adb | -- REST API Validation
-- API to validate
--
-- The version of the OpenAPI document: 1.0.0
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.1-2023-08-27.
-- https://openapi-generator.tech
-- Do not edit the class manually.
pragma Warnings (Off, "*is not referenced");
with Swagger.Streams;
with Swagger.Servers.Operation;
package body TestBinary.Skeletons is
pragma Style_Checks ("-bmrIu");
pragma Warnings (Off, "*use clause for package*");
use Swagger.Streams;
Mime_1 : aliased constant String := "image/jpeg";
Mime_2 : aliased constant String := "image/png";
Media_List_1 : aliased constant Swagger.Mime_List :=
(1 => Mime_1'Access,
2 => Mime_2'Access);
Media_List_2 : aliased constant Swagger.Mime_List :=
(1 => Swagger.Mime_Json,
2 => Swagger.Mime_Xml);
package body Skeleton is
package API_Do_Get_Image is new Swagger.Servers.Operation
(Handler => Do_Get_Image,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/binary",
Mimes => Media_List_1'Access);
-- Get an image
procedure Do_Get_Image
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type)
is
Impl : Implementation_Type;
Status : Status_Type;
Owner : Swagger.Nullable_UString;
Result : Swagger.Blob_Ref;
begin
Status :=
To_Status_Type
(Swagger.Servers.Get_Query_Parameter (Req, "status"));
Swagger.Servers.Get_Query_Parameter (Req, "owner", Owner);
Impl.Do_Get_Image (Status, Owner, Result, Context);
if Context.Get_Status = 200 then
Context.Set_Description ("successful operation");
Swagger.Streams.Write (Stream, Result);
return;
end if;
if Context.Get_Status = 404 then
Context.Set_Description ("Invalid status value");
return;
end if;
end Do_Get_Image;
package API_Do_Get_Object is new Swagger.Servers.Operation
(Handler => Do_Get_Object,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/object",
Mimes => Media_List_2'Access);
-- Get an object
procedure Do_Get_Object
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type)
is
Impl : Implementation_Type;
Status : Status_Type;
Owner : Swagger.Nullable_UString;
Result : Swagger.Object;
begin
Status :=
To_Status_Type
(Swagger.Servers.Get_Query_Parameter (Req, "status"));
Swagger.Servers.Get_Query_Parameter (Req, "owner", Owner);
Impl.Do_Get_Object (Status, Owner, Result, Context);
if Context.Get_Status = 200 then
Context.Set_Description ("successful operation");
Stream.Start_Document;
if not Swagger.Is_Null (Result) then
Stream.Write_Entity ("", Result);
end if;
Stream.End_Document;
return;
end if;
if Context.Get_Status = 404 then
Context.Set_Description ("Invalid status value");
return;
end if;
end Do_Get_Object;
package API_Do_Get_Stats is new Swagger.Servers.Operation
(Handler => Do_Get_Stats,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/external/{status}",
Mimes => Media_List_2'Access);
-- Get some stat from external struct
procedure Do_Get_Stats
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type)
is
Impl : Implementation_Type;
Status : Status_Type;
Result : External.Stat_Vector;
begin
Status :=
To_Status_Type (Swagger.Servers.Get_Path_Parameter (Req, 1));
Impl.Do_Get_Stats (Status, Result, Context);
if Context.Get_Status = 200 then
Context.Set_Description ("successful operation");
Stream.Start_Document;
Serialize (Stream, "", Result);
Stream.End_Document;
return;
end if;
if Context.Get_Status = 404 then
Context.Set_Description ("Invalid status value");
return;
end if;
end Do_Get_Stats;
procedure Register
(Server : in out Swagger.Servers.Application_Type'Class)
is
begin
Swagger.Servers.Register (Server, API_Do_Get_Image.Definition);
Swagger.Servers.Register (Server, API_Do_Get_Object.Definition);
Swagger.Servers.Register (Server, API_Do_Get_Stats.Definition);
end Register;
end Skeleton;
package body Shared_Instance is
-- Get an image
procedure Do_Get_Image
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type)
is
Status : Status_Type;
Owner : Swagger.Nullable_UString;
Result : Swagger.Blob_Ref;
begin
Status :=
To_Status_Type
(Swagger.Servers.Get_Query_Parameter (Req, "status"));
Swagger.Servers.Get_Query_Parameter (Req, "owner", Owner);
Server.Do_Get_Image (Status, Owner, Result, Context);
if Context.Get_Status = 200 then
Context.Set_Description ("successful operation");
Swagger.Streams.Write (Stream, Result);
return;
end if;
if Context.Get_Status = 404 then
Context.Set_Description ("Invalid status value");
return;
end if;
end Do_Get_Image;
package API_Do_Get_Image is new Swagger.Servers.Operation
(Handler => Do_Get_Image,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/binary",
Mimes => Media_List_1'Access);
-- Get an object
procedure Do_Get_Object
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type)
is
Status : Status_Type;
Owner : Swagger.Nullable_UString;
Result : Swagger.Object;
begin
Status :=
To_Status_Type
(Swagger.Servers.Get_Query_Parameter (Req, "status"));
Swagger.Servers.Get_Query_Parameter (Req, "owner", Owner);
Server.Do_Get_Object (Status, Owner, Result, Context);
if Context.Get_Status = 200 then
Context.Set_Description ("successful operation");
Stream.Start_Document;
if not Swagger.Is_Null (Result) then
Stream.Write_Entity ("", Result);
end if;
Stream.End_Document;
return;
end if;
if Context.Get_Status = 404 then
Context.Set_Description ("Invalid status value");
return;
end if;
end Do_Get_Object;
package API_Do_Get_Object is new Swagger.Servers.Operation
(Handler => Do_Get_Object,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/object",
Mimes => Media_List_2'Access);
-- Get some stat from external struct
procedure Do_Get_Stats
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type)
is
Status : Status_Type;
Result : External.Stat_Vector;
begin
Status :=
To_Status_Type (Swagger.Servers.Get_Path_Parameter (Req, 1));
Server.Do_Get_Stats (Status, Result, Context);
if Context.Get_Status = 200 then
Context.Set_Description ("successful operation");
Stream.Start_Document;
Serialize (Stream, "", Result);
Stream.End_Document;
return;
end if;
if Context.Get_Status = 404 then
Context.Set_Description ("Invalid status value");
return;
end if;
end Do_Get_Stats;
package API_Do_Get_Stats is new Swagger.Servers.Operation
(Handler => Do_Get_Stats,
Method => Swagger.Servers.GET,
URI => URI_Prefix & "/external/{status}",
Mimes => Media_List_2'Access);
procedure Register
(Server : in out Swagger.Servers.Application_Type'Class)
is
begin
Swagger.Servers.Register (Server, API_Do_Get_Image.Definition);
Swagger.Servers.Register (Server, API_Do_Get_Object.Definition);
Swagger.Servers.Register (Server, API_Do_Get_Stats.Definition);
end Register;
protected body Server is
-- Get an image
procedure Do_Get_Image
(Status : in Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Blob_Ref;
Context : in out Swagger.Servers.Context_Type)
is
begin
Impl.Do_Get_Image (Status, Owner, Result, Context);
end Do_Get_Image;
-- Get an object
procedure Do_Get_Object
(Status : in Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Object;
Context : in out Swagger.Servers.Context_Type)
is
begin
Impl.Do_Get_Object (Status, Owner, Result, Context);
end Do_Get_Object;
-- Get some stat from external struct
procedure Do_Get_Stats
(Status : in Status_Type;
Result : out External.Stat_Vector;
Context : in out Swagger.Servers.Context_Type)
is
begin
Impl.Do_Get_Stats (Status, Result, Context);
end Do_Get_Stats;
end Server;
end Shared_Instance;
end TestBinary.Skeletons;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 20,047 | ads | pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32L0x3.svd
pragma Restrictions (No_Elaboration_Code);
with System;
package STM32_SVD.I2C is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR1_PE_Field is STM32_SVD.Bit;
subtype CR1_TXIE_Field is STM32_SVD.Bit;
subtype CR1_RXIE_Field is STM32_SVD.Bit;
subtype CR1_ADDRIE_Field is STM32_SVD.Bit;
subtype CR1_NACKIE_Field is STM32_SVD.Bit;
subtype CR1_STOPIE_Field is STM32_SVD.Bit;
subtype CR1_TCIE_Field is STM32_SVD.Bit;
subtype CR1_ERRIE_Field is STM32_SVD.Bit;
subtype CR1_DNF_Field is STM32_SVD.UInt4;
subtype CR1_ANFOFF_Field is STM32_SVD.Bit;
subtype CR1_TXDMAEN_Field is STM32_SVD.Bit;
subtype CR1_RXDMAEN_Field is STM32_SVD.Bit;
subtype CR1_SBC_Field is STM32_SVD.Bit;
subtype CR1_NOSTRETCH_Field is STM32_SVD.Bit;
subtype CR1_WUPEN_Field is STM32_SVD.Bit;
subtype CR1_GCEN_Field is STM32_SVD.Bit;
subtype CR1_SMBHEN_Field is STM32_SVD.Bit;
subtype CR1_SMBDEN_Field is STM32_SVD.Bit;
subtype CR1_ALERTEN_Field is STM32_SVD.Bit;
subtype CR1_PECEN_Field is STM32_SVD.Bit;
-- Control register 1
type CR1_Register is record
-- Peripheral enable
PE : CR1_PE_Field := 16#0#;
-- TX Interrupt enable
TXIE : CR1_TXIE_Field := 16#0#;
-- RX Interrupt enable
RXIE : CR1_RXIE_Field := 16#0#;
-- Address match interrupt enable (slave only)
ADDRIE : CR1_ADDRIE_Field := 16#0#;
-- Not acknowledge received interrupt enable
NACKIE : CR1_NACKIE_Field := 16#0#;
-- STOP detection Interrupt enable
STOPIE : CR1_STOPIE_Field := 16#0#;
-- Transfer Complete interrupt enable
TCIE : CR1_TCIE_Field := 16#0#;
-- Error interrupts enable
ERRIE : CR1_ERRIE_Field := 16#0#;
-- Digital noise filter
DNF : CR1_DNF_Field := 16#0#;
-- Analog noise filter OFF
ANFOFF : CR1_ANFOFF_Field := 16#0#;
-- unspecified
Reserved_13_13 : STM32_SVD.Bit := 16#0#;
-- DMA transmission requests enable
TXDMAEN : CR1_TXDMAEN_Field := 16#0#;
-- DMA reception requests enable
RXDMAEN : CR1_RXDMAEN_Field := 16#0#;
-- Slave byte control
SBC : CR1_SBC_Field := 16#0#;
-- Clock stretching disable
NOSTRETCH : CR1_NOSTRETCH_Field := 16#0#;
-- Wakeup from STOP enable
WUPEN : CR1_WUPEN_Field := 16#0#;
-- General call enable
GCEN : CR1_GCEN_Field := 16#0#;
-- SMBus Host address enable
SMBHEN : CR1_SMBHEN_Field := 16#0#;
-- SMBus Device Default address enable
SMBDEN : CR1_SMBDEN_Field := 16#0#;
-- SMBUS alert enable
ALERTEN : CR1_ALERTEN_Field := 16#0#;
-- PEC enable
PECEN : CR1_PECEN_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
PE at 0 range 0 .. 0;
TXIE at 0 range 1 .. 1;
RXIE at 0 range 2 .. 2;
ADDRIE at 0 range 3 .. 3;
NACKIE at 0 range 4 .. 4;
STOPIE at 0 range 5 .. 5;
TCIE at 0 range 6 .. 6;
ERRIE at 0 range 7 .. 7;
DNF at 0 range 8 .. 11;
ANFOFF at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
TXDMAEN at 0 range 14 .. 14;
RXDMAEN at 0 range 15 .. 15;
SBC at 0 range 16 .. 16;
NOSTRETCH at 0 range 17 .. 17;
WUPEN at 0 range 18 .. 18;
GCEN at 0 range 19 .. 19;
SMBHEN at 0 range 20 .. 20;
SMBDEN at 0 range 21 .. 21;
ALERTEN at 0 range 22 .. 22;
PECEN at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype CR2_SADD_Field is STM32_SVD.UInt10;
subtype CR2_RD_WRN_Field is STM32_SVD.Bit;
subtype CR2_ADD10_Field is STM32_SVD.Bit;
subtype CR2_HEAD10R_Field is STM32_SVD.Bit;
subtype CR2_START_Field is STM32_SVD.Bit;
subtype CR2_STOP_Field is STM32_SVD.Bit;
subtype CR2_NACK_Field is STM32_SVD.Bit;
subtype CR2_NBYTES_Field is STM32_SVD.Byte;
subtype CR2_RELOAD_Field is STM32_SVD.Bit;
subtype CR2_AUTOEND_Field is STM32_SVD.Bit;
subtype CR2_PECBYTE_Field is STM32_SVD.Bit;
-- Control register 2
type CR2_Register is record
-- Slave address bit (master mode)
SADD : CR2_SADD_Field := 16#0#;
-- Transfer direction (master mode)
RD_WRN : CR2_RD_WRN_Field := 16#0#;
-- 10-bit addressing mode (master mode)
ADD10 : CR2_ADD10_Field := 16#0#;
-- 10-bit address header only read direction (master receiver mode)
HEAD10R : CR2_HEAD10R_Field := 16#0#;
-- Start generation
START : CR2_START_Field := 16#0#;
-- Stop generation (master mode)
STOP : CR2_STOP_Field := 16#0#;
-- NACK generation (slave mode)
NACK : CR2_NACK_Field := 16#0#;
-- Number of bytes
NBYTES : CR2_NBYTES_Field := 16#0#;
-- NBYTES reload mode
RELOAD : CR2_RELOAD_Field := 16#0#;
-- Automatic end mode (master mode)
AUTOEND : CR2_AUTOEND_Field := 16#0#;
-- Packet error checking byte
PECBYTE : CR2_PECBYTE_Field := 16#0#;
-- unspecified
Reserved_27_31 : STM32_SVD.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
SADD at 0 range 0 .. 9;
RD_WRN at 0 range 10 .. 10;
ADD10 at 0 range 11 .. 11;
HEAD10R at 0 range 12 .. 12;
START at 0 range 13 .. 13;
STOP at 0 range 14 .. 14;
NACK at 0 range 15 .. 15;
NBYTES at 0 range 16 .. 23;
RELOAD at 0 range 24 .. 24;
AUTOEND at 0 range 25 .. 25;
PECBYTE at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype OAR1_OA1_Field is STM32_SVD.UInt10;
subtype OAR1_OA1MODE_Field is STM32_SVD.Bit;
subtype OAR1_OA1EN_Field is STM32_SVD.Bit;
-- Own address register 1
type OAR1_Register is record
-- Interface address
OA1 : OAR1_OA1_Field := 16#0#;
-- Own Address 1 10-bit mode
OA1MODE : OAR1_OA1MODE_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- Own Address 1 enable
OA1EN : OAR1_OA1EN_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OAR1_Register use record
OA1 at 0 range 0 .. 9;
OA1MODE at 0 range 10 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
OA1EN at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype OAR2_OA2_Field is STM32_SVD.UInt7;
subtype OAR2_OA2MSK_Field is STM32_SVD.UInt3;
subtype OAR2_OA2EN_Field is STM32_SVD.Bit;
-- Own address register 2
type OAR2_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit := 16#0#;
-- Interface address
OA2 : OAR2_OA2_Field := 16#0#;
-- Own Address 2 masks
OA2MSK : OAR2_OA2MSK_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- Own Address 2 enable
OA2EN : OAR2_OA2EN_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OAR2_Register use record
Reserved_0_0 at 0 range 0 .. 0;
OA2 at 0 range 1 .. 7;
OA2MSK at 0 range 8 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
OA2EN at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype TIMINGR_SCLL_Field is STM32_SVD.Byte;
subtype TIMINGR_SCLH_Field is STM32_SVD.Byte;
subtype TIMINGR_SDADEL_Field is STM32_SVD.UInt4;
subtype TIMINGR_SCLDEL_Field is STM32_SVD.UInt4;
subtype TIMINGR_PRESC_Field is STM32_SVD.UInt4;
-- Timing register
type TIMINGR_Register is record
-- SCL low period (master mode)
SCLL : TIMINGR_SCLL_Field := 16#0#;
-- SCL high period (master mode)
SCLH : TIMINGR_SCLH_Field := 16#0#;
-- Data hold time
SDADEL : TIMINGR_SDADEL_Field := 16#0#;
-- Data setup time
SCLDEL : TIMINGR_SCLDEL_Field := 16#0#;
-- unspecified
Reserved_24_27 : STM32_SVD.UInt4 := 16#0#;
-- Timing prescaler
PRESC : TIMINGR_PRESC_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIMINGR_Register use record
SCLL at 0 range 0 .. 7;
SCLH at 0 range 8 .. 15;
SDADEL at 0 range 16 .. 19;
SCLDEL at 0 range 20 .. 23;
Reserved_24_27 at 0 range 24 .. 27;
PRESC at 0 range 28 .. 31;
end record;
subtype TIMEOUTR_TIMEOUTA_Field is STM32_SVD.UInt12;
subtype TIMEOUTR_TIDLE_Field is STM32_SVD.Bit;
subtype TIMEOUTR_TIMOUTEN_Field is STM32_SVD.Bit;
subtype TIMEOUTR_TIMEOUTB_Field is STM32_SVD.UInt12;
subtype TIMEOUTR_TEXTEN_Field is STM32_SVD.Bit;
-- Status register 1
type TIMEOUTR_Register is record
-- Bus timeout A
TIMEOUTA : TIMEOUTR_TIMEOUTA_Field := 16#0#;
-- Idle clock timeout detection
TIDLE : TIMEOUTR_TIDLE_Field := 16#0#;
-- unspecified
Reserved_13_14 : STM32_SVD.UInt2 := 16#0#;
-- Clock timeout enable
TIMOUTEN : TIMEOUTR_TIMOUTEN_Field := 16#0#;
-- Bus timeout B
TIMEOUTB : TIMEOUTR_TIMEOUTB_Field := 16#0#;
-- unspecified
Reserved_28_30 : STM32_SVD.UInt3 := 16#0#;
-- Extended clock timeout enable
TEXTEN : TIMEOUTR_TEXTEN_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIMEOUTR_Register use record
TIMEOUTA at 0 range 0 .. 11;
TIDLE at 0 range 12 .. 12;
Reserved_13_14 at 0 range 13 .. 14;
TIMOUTEN at 0 range 15 .. 15;
TIMEOUTB at 0 range 16 .. 27;
Reserved_28_30 at 0 range 28 .. 30;
TEXTEN at 0 range 31 .. 31;
end record;
subtype ISR_TXE_Field is STM32_SVD.Bit;
subtype ISR_TXIS_Field is STM32_SVD.Bit;
subtype ISR_RXNE_Field is STM32_SVD.Bit;
subtype ISR_ADDR_Field is STM32_SVD.Bit;
subtype ISR_NACKF_Field is STM32_SVD.Bit;
subtype ISR_STOPF_Field is STM32_SVD.Bit;
subtype ISR_TC_Field is STM32_SVD.Bit;
subtype ISR_TCR_Field is STM32_SVD.Bit;
subtype ISR_BERR_Field is STM32_SVD.Bit;
subtype ISR_ARLO_Field is STM32_SVD.Bit;
subtype ISR_OVR_Field is STM32_SVD.Bit;
subtype ISR_PECERR_Field is STM32_SVD.Bit;
subtype ISR_TIMEOUT_Field is STM32_SVD.Bit;
subtype ISR_ALERT_Field is STM32_SVD.Bit;
subtype ISR_BUSY_Field is STM32_SVD.Bit;
subtype ISR_DIR_Field is STM32_SVD.Bit;
subtype ISR_ADDCODE_Field is STM32_SVD.UInt7;
-- Interrupt and Status register
type ISR_Register is record
-- Transmit data register empty (transmitters)
TXE : ISR_TXE_Field := 16#1#;
-- Transmit interrupt status (transmitters)
TXIS : ISR_TXIS_Field := 16#0#;
-- Read-only. Receive data register not empty (receivers)
RXNE : ISR_RXNE_Field := 16#0#;
-- Read-only. Address matched (slave mode)
ADDR : ISR_ADDR_Field := 16#0#;
-- Read-only. Not acknowledge received flag
NACKF : ISR_NACKF_Field := 16#0#;
-- Read-only. Stop detection flag
STOPF : ISR_STOPF_Field := 16#0#;
-- Read-only. Transfer Complete (master mode)
TC : ISR_TC_Field := 16#0#;
-- Read-only. Transfer Complete Reload
TCR : ISR_TCR_Field := 16#0#;
-- Read-only. Bus error
BERR : ISR_BERR_Field := 16#0#;
-- Read-only. Arbitration lost
ARLO : ISR_ARLO_Field := 16#0#;
-- Read-only. Overrun/Underrun (slave mode)
OVR : ISR_OVR_Field := 16#0#;
-- Read-only. PEC Error in reception
PECERR : ISR_PECERR_Field := 16#0#;
-- Read-only. Timeout or t_low detection flag
TIMEOUT : ISR_TIMEOUT_Field := 16#0#;
-- Read-only. SMBus alert
ALERT : ISR_ALERT_Field := 16#0#;
-- unspecified
Reserved_14_14 : STM32_SVD.Bit := 16#0#;
-- Read-only. Bus busy
BUSY : ISR_BUSY_Field := 16#0#;
-- Read-only. Transfer direction (Slave mode)
DIR : ISR_DIR_Field := 16#0#;
-- Read-only. Address match code (Slave mode)
ADDCODE : ISR_ADDCODE_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
TXE at 0 range 0 .. 0;
TXIS at 0 range 1 .. 1;
RXNE at 0 range 2 .. 2;
ADDR at 0 range 3 .. 3;
NACKF at 0 range 4 .. 4;
STOPF at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TCR at 0 range 7 .. 7;
BERR at 0 range 8 .. 8;
ARLO at 0 range 9 .. 9;
OVR at 0 range 10 .. 10;
PECERR at 0 range 11 .. 11;
TIMEOUT at 0 range 12 .. 12;
ALERT at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
BUSY at 0 range 15 .. 15;
DIR at 0 range 16 .. 16;
ADDCODE at 0 range 17 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype ICR_ADDRCF_Field is STM32_SVD.Bit;
subtype ICR_NACKCF_Field is STM32_SVD.Bit;
subtype ICR_STOPCF_Field is STM32_SVD.Bit;
subtype ICR_BERRCF_Field is STM32_SVD.Bit;
subtype ICR_ARLOCF_Field is STM32_SVD.Bit;
subtype ICR_OVRCF_Field is STM32_SVD.Bit;
subtype ICR_PECCF_Field is STM32_SVD.Bit;
subtype ICR_TIMOUTCF_Field is STM32_SVD.Bit;
subtype ICR_ALERTCF_Field is STM32_SVD.Bit;
-- Interrupt clear register
type ICR_Register is record
-- unspecified
Reserved_0_2 : STM32_SVD.UInt3 := 16#0#;
-- Write-only. Address Matched flag clear
ADDRCF : ICR_ADDRCF_Field := 16#0#;
-- Write-only. Not Acknowledge flag clear
NACKCF : ICR_NACKCF_Field := 16#0#;
-- Write-only. Stop detection flag clear
STOPCF : ICR_STOPCF_Field := 16#0#;
-- unspecified
Reserved_6_7 : STM32_SVD.UInt2 := 16#0#;
-- Write-only. Bus error flag clear
BERRCF : ICR_BERRCF_Field := 16#0#;
-- Write-only. Arbitration lost flag clear
ARLOCF : ICR_ARLOCF_Field := 16#0#;
-- Write-only. Overrun/Underrun flag clear
OVRCF : ICR_OVRCF_Field := 16#0#;
-- Write-only. PEC Error flag clear
PECCF : ICR_PECCF_Field := 16#0#;
-- Write-only. Timeout detection flag clear
TIMOUTCF : ICR_TIMOUTCF_Field := 16#0#;
-- Write-only. Alert flag clear
ALERTCF : ICR_ALERTCF_Field := 16#0#;
-- unspecified
Reserved_14_31 : STM32_SVD.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
ADDRCF at 0 range 3 .. 3;
NACKCF at 0 range 4 .. 4;
STOPCF at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
BERRCF at 0 range 8 .. 8;
ARLOCF at 0 range 9 .. 9;
OVRCF at 0 range 10 .. 10;
PECCF at 0 range 11 .. 11;
TIMOUTCF at 0 range 12 .. 12;
ALERTCF at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype PECR_PEC_Field is STM32_SVD.Byte;
-- PEC register
type PECR_Register is record
-- Read-only. Packet error checking register
PEC : PECR_PEC_Field;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PECR_Register use record
PEC at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype RXDR_RXDATA_Field is STM32_SVD.Byte;
-- Receive data register
type RXDR_Register is record
-- Read-only. 8-bit receive data
RXDATA : RXDR_RXDATA_Field;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RXDR_Register use record
RXDATA at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype TXDR_TXDATA_Field is STM32_SVD.Byte;
-- Transmit data register
type TXDR_Register is record
-- 8-bit transmit data
TXDATA : TXDR_TXDATA_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TXDR_Register use record
TXDATA at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Inter-integrated circuit
type I2C_Peripheral is record
-- Control register 1
CR1 : aliased CR1_Register;
-- Control register 2
CR2 : aliased CR2_Register;
-- Own address register 1
OAR1 : aliased OAR1_Register;
-- Own address register 2
OAR2 : aliased OAR2_Register;
-- Timing register
TIMINGR : aliased TIMINGR_Register;
-- Status register 1
TIMEOUTR : aliased TIMEOUTR_Register;
-- Interrupt and Status register
ISR : aliased ISR_Register;
-- Interrupt clear register
ICR : aliased ICR_Register;
-- PEC register
PECR : aliased PECR_Register;
-- Receive data register
RXDR : aliased RXDR_Register;
-- Transmit data register
TXDR : aliased TXDR_Register;
end record
with Volatile;
for I2C_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CR2 at 16#4# range 0 .. 31;
OAR1 at 16#8# range 0 .. 31;
OAR2 at 16#C# range 0 .. 31;
TIMINGR at 16#10# range 0 .. 31;
TIMEOUTR at 16#14# range 0 .. 31;
ISR at 16#18# range 0 .. 31;
ICR at 16#1C# range 0 .. 31;
PECR at 16#20# range 0 .. 31;
RXDR at 16#24# range 0 .. 31;
TXDR at 16#28# range 0 .. 31;
end record;
-- Inter-integrated circuit
I2C1_Periph : aliased I2C_Peripheral
with Import, Address => I2C1_Base;
-- Inter-integrated circuit
I2C2_Periph : aliased I2C_Peripheral
with Import, Address => I2C2_Base;
-- Inter-integrated circuit
I2C3_Periph : aliased I2C_Peripheral
with Import, Address => I2C3_Base;
end STM32_SVD.I2C;
|
io7m/coreland-opengl-ada | Ada | 9,415 | ads | with OpenGL.Thin;
package OpenGL.Texture is
type Index_t is new Thin.Unsigned_Integer_t;
type Index_Array_t is array (Natural range <>) of aliased Index_t;
type Border_Width_t is range 0 .. 1;
type Internal_Format_t is
(Alpha,
Alpha_4,
Alpha_8,
Alpha_12,
Alpha_16,
Compressed_Alpha,
Compressed_Luminance,
Compressed_Luminance_Alpha,
Compressed_Intensity,
Compressed_RGB,
Compressed_RGBA,
Luminance,
Luminance_4,
Luminance_8,
Luminance_12,
Luminance_16,
Luminance_Alpha,
Luminance_4_Alpha_4,
Luminance_6_Alpha_2,
Luminance_8_Alpha_8,
Luminance_12_Alpha_4,
Luminance_12_Alpha_12,
Luminance_16_Alpha_16,
Intensity,
Intensity_4,
Intensity_8,
Intensity_12,
Intensity_16,
R3_G3_B2,
RGB,
RGB_4,
RGB_5,
RGB_8,
RGB_10,
RGB_12,
RGB_16,
RGBA,
RGBA_2,
RGBA_4,
RGB5_A1,
RGBA_8,
RGB10_A2,
RGBA_12,
RGBA_16,
SLuminance,
SLuminance_8,
SLuminance_Alpha,
SLuminance_8_Alpha_8,
SRGB,
SRGB_8,
SRGB_Alpha,
SRGB_8_Alpha_8);
type Format_t is
(Color_Index,
Red,
Green,
Blue,
Alpha,
RGB,
BGR,
RGBA,
BGRA,
Luminance,
Luminance_Alpha);
type Data_Type_t is
(Unsigned_Byte,
Byte,
Bitmap,
Unsigned_Short,
Short,
Unsigned_Integer,
Integer,
Float,
Unsigned_Byte_3_3_2,
Unsigned_Byte_2_3_3_Rev,
Unsigned_Short_5_6_5,
Unsigned_Short_5_6_5_Rev,
Unsigned_Short_4_4_4_4,
Unsigned_Short_4_4_4_4_Rev,
Unsigned_Short_5_5_5_1,
Unsigned_Short_1_5_5_5_Rev,
Unsigned_Integer_8_8_8_8,
Unsigned_Integer_8_8_8_8_Rev,
Unsigned_Integer_10_10_10_2,
Unsigned_Integer_2_10_10_10_Rev);
type Storage_Parameter_t is
(Pack_Swap_Bytes,
Pack_LSB_First,
Pack_Row_Length,
Pack_Image_Height,
Pack_Skip_Pixels,
Pack_Skip_Rows,
Pack_Skip_Images,
Pack_Alignment,
Unpack_Swap_Bytes,
Unpack_LSB_First,
Unpack_Row_Length,
Unpack_Image_Height,
Unpack_Skip_Pixels,
Unpack_Skip_Rows,
Unpack_Skip_Images,
Unpack_Alignment);
--
-- Pixel_Store
--
-- proc_map : glPixelStorei
procedure Pixel_Store
(Parameter : in Storage_Parameter_t;
Value : in Standard.Integer);
-- proc_map : glPixelStoref
procedure Pixel_Store
(Parameter : in Storage_Parameter_t;
Value : in Standard.Float);
--
-- Parameter
--
type Target_t is
(Texture_1D,
Texture_2D,
Texture_3D,
Texture_Cube_Map,
Texture_Rectangle_ARB);
type Texture_Parameter_t is
(Texture_Min_Filter,
Texture_Mag_Filter,
Texture_Min_LOD,
Texture_Max_LOD,
Texture_Base_Level,
Texture_Max_Level,
Texture_Wrap_S,
Texture_Wrap_T,
Texture_Wrap_R,
Texture_Priority,
Texture_Compare_Mode,
Texture_Compare_Func,
Depth_Texture_Mode,
Generate_Mipmap);
Linear : constant := Thin.GL_LINEAR;
Linear_Mipmap_Linear : constant := Thin.GL_LINEAR_MIPMAP_LINEAR;
Linear_Mipmap_Nearest : constant := Thin.GL_LINEAR_MIPMAP_NEAREST;
Nearest : constant := Thin.GL_NEAREST;
Nearest_Mipmap_Linear : constant := Thin.GL_NEAREST_MIPMAP_LINEAR;
Nearest_Mipmap_Nearest : constant := Thin.GL_NEAREST_MIPMAP_NEAREST;
Clamp : constant := Thin.GL_CLAMP;
Clamp_To_Border : constant := Thin.GL_CLAMP_TO_BORDER;
Clamp_To_Edge : constant := Thin.GL_CLAMP_TO_EDGE;
Mirrored_Repeat : constant := Thin.GL_MIRRORED_REPEAT;
Repeat : constant := Thin.GL_REPEAT;
Always : constant := Thin.GL_ALWAYS;
Equal : constant := Thin.GL_EQUAL;
Greater_Than : constant := Thin.GL_GREATER;
Greater_Than_Or_Equal : constant := Thin.GL_GEQUAL;
Less_Than : constant := Thin.GL_LESS;
Less_Than_Or_Equal : constant := Thin.GL_LEQUAL;
Never : constant := Thin.GL_NEVER;
Not_Equal : constant := Thin.GL_NOTEQUAL;
-- proc_map : glTexParameteri
procedure Parameter
(Target : in Target_t;
Parameter : in Texture_Parameter_t;
Value : in Standard.Integer);
-- proc_map : glTexParameterf
procedure Parameter
(Target : in Target_t;
Parameter : in Texture_Parameter_t;
Value : in Standard.Float);
--
-- Environment
--
type Environment_Target_t is
(Texture_Environment,
Texture_Filter_Control,
Point_Sprite);
type Environment_Parameter_t is
(Texture_Env_Mode,
Texture_LOD_Bias,
Combine_RGB,
Combine_Alpha,
Source0_RGB,
Source1_RGB,
Source2_RGB,
Source0_Alpha,
Source1_Alpha,
Source2_Alpha,
Operand0_RGB,
Operand1_RGB,
Operand2_RGB,
Operand0_Alpha,
Operand1_Alpha,
Operand2_Alpha,
RGB_Scale,
Alpha_Scale,
Coord_Replace);
Add : constant := Thin.GL_ADD;
Add_Signed : constant := Thin.GL_ADD_SIGNED;
Interpolate : constant := Thin.GL_INTERPOLATE;
Modulate : constant := Thin.GL_MODULATE;
Decal : constant := Thin.GL_DECAL;
Blend : constant := Thin.GL_BLEND;
Replace : constant := Thin.GL_REPLACE;
Subtract : constant := Thin.GL_SUBTRACT;
Combine : constant := Thin.GL_COMBINE;
Texture : constant := Thin.GL_TEXTURE;
GL_Constant : constant := Thin.GL_CONSTANT;
Primary_Color : constant := Thin.GL_PRIMARY_COLOR;
Previous : constant := Thin.GL_PREVIOUS;
Source_Color : constant := Thin.GL_SRC_COLOR;
One_Minus_Source_Color : constant := Thin.GL_ONE_MINUS_SRC_COLOR;
Source_Alpha : constant := Thin.GL_SRC_ALPHA;
One_Minus_Source_Alpha : constant := Thin.GL_ONE_MINUS_SRC_ALPHA;
-- proc_map : glTexEnvi
procedure Environment
(Target : in Environment_Target_t;
Parameter : in Environment_Parameter_t;
Value : in Standard.Integer);
-- proc_map : glTexEnvf
procedure Environment
(Target : in Environment_Target_t;
Parameter : in Environment_Parameter_t;
Value : in Standard.Float);
--
-- Generate
--
-- proc_map : glGenTextures
procedure Generate
(Textures : in out Index_Array_t);
--
-- Image3D
--
type Target_3D_t is (Texture_3D, Proxy_Texture_3D, Texture_Rectangle_ARB);
generic
type Data_Element_t is private;
type Data_Index_t is range <>;
type Data_Array_t is array (Data_Index_t range <>) of aliased Data_Element_t;
-- proc_map : glTexImage3D
procedure Image_3D
(Target : in Target_3D_t;
Level : in Natural;
Internal_Format : in Internal_Format_t;
Width : in Positive;
Height : in Positive;
Depth : in Positive;
Border : in Border_Width_t;
Format : in Format_t;
Data : in Data_Array_t;
Data_Type : in Data_Type_t);
--
-- Image2D
--
type Target_2D_t is
(Texture_2D,
Proxy_Texture_2D,
Texture_Cube_Map_Positive_X,
Texture_Cube_Map_Negative_X,
Texture_Cube_Map_Positive_Y,
Texture_Cube_Map_Negative_Y,
Texture_Cube_Map_Positive_Z,
Texture_Cube_Map_Negative_Z,
Proxy_Texture_Cube_Map,
Texture_Rectangle_ARB);
generic
type Data_Element_t is private;
type Data_Index_t is range <>;
type Data_Array_t is array (Data_Index_t range <>) of aliased Data_Element_t;
-- proc_map : glTexImage2D
procedure Image_2D
(Target : in Target_2D_t;
Level : in Natural;
Internal_Format : in Internal_Format_t;
Width : in Positive;
Height : in Positive;
Border : in Border_Width_t;
Format : in Format_t;
Data : in Data_Array_t;
Data_Type : in Data_Type_t);
--
-- Image1D
--
type Target_1D_t is (Texture_1D, Proxy_Texture_1D, Texture_Rectangle_ARB);
generic
type Data_Element_t is private;
type Data_Index_t is range <>;
type Data_Array_t is array (Data_Index_t range <>) of aliased Data_Element_t;
-- proc_map : glTexImage1D
procedure Image_1D
(Target : in Target_1D_t;
Level : in Natural;
Internal_Format : in Internal_Format_t;
Width : in Positive;
Border : in Border_Width_t;
Format : in Format_t;
Data : in Data_Array_t;
Data_Type : in Data_Type_t);
--
-- Bind
--
-- proc_map : glBindTexture
procedure Bind
(Target : in Target_t;
Texture : in Index_t);
--
-- Blend_Function
--
type Blend_Factor_t is
(Blend_Constant_Alpha,
Blend_Constant_Color,
Blend_One,
Blend_One_Minus_Constant_Alpha,
Blend_One_Minus_Constant_Color,
Blend_One_Minus_Source_Alpha,
Blend_One_Minus_Source_Color,
Blend_One_Minus_Target_Alpha,
Blend_One_Minus_Target_Color,
Blend_Source_Alpha,
Blend_Source_Alpha_Saturate,
Blend_Source_Color,
Blend_Target_Alpha,
Blend_Target_Color,
Blend_Zero);
-- proc_map : glBlendFunc
procedure Blend_Function
(Source_Factor : in Blend_Factor_t;
Target_Factor : in Blend_Factor_t);
end OpenGL.Texture;
|
kylelk/ada-examples | Ada | 101 | adb | with Ada.Text_IO;
use Ada;
procedure hello is
begin
Text_IO.Put_Line("hello world");
end hello;
|
charlie5/cBound | Ada | 1,556 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_circulate_window_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
direction : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
window : aliased xcb.xcb_window_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_circulate_window_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_circulate_window_request_t.Item,
Element_Array => xcb.xcb_circulate_window_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_circulate_window_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_circulate_window_request_t.Pointer,
Element_Array => xcb.xcb_circulate_window_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_circulate_window_request_t;
|
reznikmm/matreshka | Ada | 3,694 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Print_Attributes is
pragma Preelaborate;
type ODF_Table_Print_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Print_Attribute_Access is
access all ODF_Table_Print_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Print_Attributes;
|
charlie5/cBound | Ada | 1,413 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_keymap_notify_event_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
keys : aliased swig.int8_t_Array (0 .. 30);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_keymap_notify_event_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_keymap_notify_event_t.Item,
Element_Array => xcb.xcb_keymap_notify_event_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_keymap_notify_event_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_keymap_notify_event_t.Pointer,
Element_Array => xcb.xcb_keymap_notify_event_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_keymap_notify_event_t;
|
charlie5/lace | Ada | 1,311 | ads | package collada.Library.animations
--
-- Models a collada 'animations' library, which is a collection of animations.
--
is
type Inputs_view is access all Library.Inputs;
type int_Array_view is access all int_Array;
-----------
--- Sampler
--
type Sampler is
record
Id : Text;
Inputs : Inputs_view;
end record;
-----------
--- Channel
--
type Channel is
record
Source : Text;
Target : Text;
end record;
--------------
--- Animation
--
type Animation is
record
Id : Text;
Name : Text;
Sources : library.Sources_view;
Sampler : animations.Sampler;
Channel : animations.Channel;
end record;
type Animation_array is array (Positive range <>) of Animation;
type Animation_array_view is access Animation_array;
function Inputs_of (Self : in Animation) return access float_Array;
function Outputs_of (Self : in Animation) return access float_Array;
function Interpolations_of (Self : in Animation) return access float_Array;
----------------
--- Library Item
--
type Item is
record
Contents : Animation_array_view;
end record;
end collada.Library.animations;
|
AdaCore/libadalang | Ada | 1,697 | ads | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
-- Helpers to create analysis contexts from GPR files
with GNATCOLL.Projects;
with GPR2.Project.Tree;
with GPR2.Project.View;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Implementation; use Libadalang.Implementation;
private package Libadalang.GPR_Impl is
procedure Initialize_Context_From_Project
(Context : Internal_Context;
Tree : GNATCOLL.Projects.Project_Tree_Access;
Project : GNATCOLL.Projects.Project_Type;
Env : GNATCOLL.Projects.Project_Environment_Access;
Is_Project_Owner : Boolean;
Event_Handler : Internal_Event_Handler_Access;
With_Trivia : Boolean;
Tab_Stop : Positive);
-- Initialize a freshly allocated analysis context from a GPR project.
--
-- The unit provider, file reader, config pragmas and default charset are
-- inferred from the designated project: see
-- ``Libadalang.Project_Provider.Create_Project_Unit_Provider`` for the
-- semantics of the ``Tree``, ``Project``, ``Env`` and ``Is_Project_Owner``
-- arguments.
--
-- See ``Libadalang.Implementation.Initialize_Context`` for the semantics
-- of the other arguments.
procedure Initialize_Context_From_Project
(Context : Internal_Context;
Tree : GPR2.Project.Tree.Object;
Project : GPR2.Project.View.Object := GPR2.Project.View.Undefined;
Event_Handler : Internal_Event_Handler_Access;
With_Trivia : Boolean;
Tab_Stop : Positive);
-- Likewise, but for GPR2
end Libadalang.GPR_Impl;
|
zhmu/ananas | Ada | 7,908 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- W I D E C H A R --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Note: this package uses the generic subprograms in System.WCh_Cnv, which
-- completely encapsulate the set of wide character encoding methods, so no
-- modifications are required when adding new encoding methods.
with Opt; use Opt;
with System.WCh_Cnv; use System.WCh_Cnv;
with System.WCh_Con; use System.WCh_Con;
package body Widechar is
---------------------------
-- Is_Start_Of_Wide_Char --
---------------------------
function Is_Start_Of_Wide_Char
(S : Source_Buffer_Ptr;
P : Source_Ptr) return Boolean
is
begin
case Wide_Character_Encoding_Method is
-- For Hex mode, just test for an ESC character. The ESC character
-- cannot appear in any other context in a legal Ada program.
when WCEM_Hex =>
return S (P) = ASCII.ESC;
-- For brackets, just test ["x where x is a hex character. This is
-- sufficient test, since this sequence cannot otherwise appear in a
-- legal Ada program.
when WCEM_Brackets =>
return P <= S'Last - 2
and then S (P) = '['
and then S (P + 1) = '"'
and then (S (P + 2) in '0' .. '9'
or else
S (P + 2) in 'a' .. 'f'
or else
S (P + 2) in 'A' .. 'F');
-- All other encoding methods use the upper bit set in the first
-- character to uniquely represent a wide character.
when WCEM_EUC
| WCEM_Shift_JIS
| WCEM_Upper
| WCEM_UTF8
=>
return S (P) >= Character'Val (16#80#);
end case;
end Is_Start_Of_Wide_Char;
-----------------
-- Length_Wide --
-----------------
function Length_Wide return Nat is
begin
return WC_Longest_Sequence;
end Length_Wide;
---------------
-- Scan_Wide --
---------------
procedure Scan_Wide
(S : Source_Buffer_Ptr;
P : in out Source_Ptr;
C : out Char_Code;
Err : out Boolean)
is
P_Init : constant Source_Ptr := P;
Chr : Character;
function In_Char return Character;
-- Function to obtain characters of wide character escape sequence
-------------
-- In_Char --
-------------
function In_Char return Character is
begin
P := P + 1;
return S (P - 1);
end In_Char;
function WC_In is new Char_Sequence_To_UTF_32 (In_Char);
-- Start of processing for Scan_Wide
begin
Chr := In_Char;
-- Scan out the wide character. If the first character is a bracket,
-- we allow brackets encoding regardless of the standard encoding
-- method being used, but otherwise we use this standard method.
if Chr = '[' then
C := Char_Code (WC_In (Chr, WCEM_Brackets));
else
C := Char_Code (WC_In (Chr, Wide_Character_Encoding_Method));
end if;
Err := False;
Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1);
exception
when Constraint_Error =>
C := Char_Code (0);
P := P - 1;
Err := True;
end Scan_Wide;
--------------
-- Set_Wide --
--------------
procedure Set_Wide
(C : Char_Code;
S : in out String;
P : in out Natural)
is
procedure Out_Char (C : Character);
-- Procedure to store one character of wide character sequence
--------------
-- Out_Char --
--------------
procedure Out_Char (C : Character) is
begin
P := P + 1;
S (P) := C;
end Out_Char;
procedure WC_Out is new UTF_32_To_Char_Sequence (Out_Char);
-- Start of processing for Set_Wide
begin
WC_Out (UTF_32_Code (C), Wide_Character_Encoding_Method);
end Set_Wide;
---------------
-- Skip_Wide --
---------------
procedure Skip_Wide (S : String; P : in out Natural) is
P_Init : constant Natural := P;
function Skip_Char return Character;
-- Function to skip one character of wide character escape sequence
---------------
-- Skip_Char --
---------------
function Skip_Char return Character is
begin
P := P + 1;
return S (P - 1);
end Skip_Char;
function WC_Skip is new Char_Sequence_To_UTF_32 (Skip_Char);
Discard : UTF_32_Code;
pragma Warnings (Off, Discard);
-- Start of processing for Skip_Wide
begin
-- Capture invalid wide characters errors since we are going to discard
-- the result anyway. We just want to move past it.
begin
Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
exception
when Constraint_Error =>
null;
end;
Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1);
end Skip_Wide;
---------------
-- Skip_Wide --
---------------
procedure Skip_Wide (S : Source_Buffer_Ptr; P : in out Source_Ptr) is
P_Init : constant Source_Ptr := P;
function Skip_Char return Character;
-- Function to skip one character of wide character escape sequence
---------------
-- Skip_Char --
---------------
function Skip_Char return Character is
begin
P := P + 1;
return S (P - 1);
end Skip_Char;
function WC_Skip is new Char_Sequence_To_UTF_32 (Skip_Char);
Discard : UTF_32_Code;
pragma Warnings (Off, Discard);
-- Start of processing for Skip_Wide
begin
-- Capture invalid wide characters errors since we are going to discard
-- the result anyway. We just want to move past it.
begin
Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
exception
when Constraint_Error =>
null;
end;
Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1);
end Skip_Wide;
end Widechar;
|
Subsets and Splits