repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 9,564 | 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$
------------------------------------------------------------------------------
with AMF.CMOF.Elements;
with AMF.DC;
with AMF.DI.Styles;
with AMF.DI.Diagram_Elements;
with AMF.Internals.UML_Elements;
with AMF.Internals.UMLDI_UML_Diagram_Elements;
with AMF.UML.Elements.Collections;
with AMF.UMLDI.UML_Diagram_Elements;
with AMF.UMLDI.UML_Edges;
with AMF.UMLDI.UML_Styles;
with AMF.Visitors;
package AMF.Internals.UMLDI_UML_Edges is
package Diagram_Elements is
new AMF.Internals.UMLDI_UML_Diagram_Elements
(AMF.Internals.UML_Elements.UML_Element_Base);
type UMLDI_UML_Edge_Proxy is
limited new Diagram_Elements.UMLDI_UML_Diagram_Element_Proxy
and AMF.UMLDI.UML_Edges.UMLDI_UML_Edge with null record;
overriding function Get_Source
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access;
-- Getter of UMLEdge::source.
--
-- Restricts the sources of UMLEdges to UMLDiagramElements.
overriding procedure Set_Source
(Self : not null access UMLDI_UML_Edge_Proxy;
To : AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access);
-- Setter of UMLEdge::source.
--
-- Restricts the sources of UMLEdges to UMLDiagramElements.
overriding function Get_Target
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access;
-- Getter of UMLEdge::target.
--
-- Restricts the targets of UMLEdges to UMLDiagramElements.
overriding procedure Set_Target
(Self : not null access UMLDI_UML_Edge_Proxy;
To : AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access);
-- Setter of UMLEdge::target.
--
-- Restricts the targets of UMLEdges to UMLDiagramElements.
overriding function Get_Is_Icon
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return Boolean;
-- Getter of UMLDiagramElement::isIcon.
--
-- For modelElements that have an option to be shown with shapes other
-- than rectangles, such as Actors, or with other identifying shapes
-- inside them, such as arrows distinguishing InputPins and OutputPins, or
-- edges that have an option to be shown with lines other than solid with
-- open arrow heads, such as Realization. A value of true for isIcon
-- indicates the alternative notation shall be shown.
overriding procedure Set_Is_Icon
(Self : not null access UMLDI_UML_Edge_Proxy;
To : Boolean);
-- Setter of UMLDiagramElement::isIcon.
--
-- For modelElements that have an option to be shown with shapes other
-- than rectangles, such as Actors, or with other identifying shapes
-- inside them, such as arrows distinguishing InputPins and OutputPins, or
-- edges that have an option to be shown with lines other than solid with
-- open arrow heads, such as Realization. A value of true for isIcon
-- indicates the alternative notation shall be shown.
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access;
-- Getter of UMLDiagramElement::localStyle.
--
-- Restricts owned styles to UMLStyles.
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Edge_Proxy;
To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access);
-- Setter of UMLDiagramElement::localStyle.
--
-- Restricts owned styles to UMLStyles.
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of UMLDiagramElement::modelElement.
--
-- Restricts UMLDiagramElements to show UML Elements, rather than other
-- language elements.
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.CMOF.Elements.CMOF_Element_Access;
-- Getter of DiagramElement::modelElement.
--
-- a reference to a depicted model element, which can be any MOF-based
-- element
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.DI.Styles.DI_Style_Access;
-- Getter of DiagramElement::localStyle.
--
-- a reference to an optional locally-owned style for this diagram element.
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Edge_Proxy;
To : AMF.DI.Styles.DI_Style_Access);
-- Setter of DiagramElement::localStyle.
--
-- a reference to an optional locally-owned style for this diagram element.
overriding function Get_Source
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.DI.Diagram_Elements.DI_Diagram_Element_Access;
-- Getter of Edge::source.
--
-- the edge's source diagram element, i.e. where the edge starts from.
overriding function Get_Target
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.DI.Diagram_Elements.DI_Diagram_Element_Access;
-- Getter of Edge::target.
--
-- the edge's target diagram element, i.e. where the edge ends at.
overriding function Get_Waypoint
(Self : not null access constant UMLDI_UML_Edge_Proxy)
return AMF.DC.Sequence_Of_DC_Point;
-- Getter of Edge::waypoint.
--
-- an optional list of points relative to the origin of the nesting
-- diagram that specifies the connected line segments of the edge
overriding procedure Enter_Element
(Self : not null access constant UMLDI_UML_Edge_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant UMLDI_UML_Edge_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant UMLDI_UML_Edge_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.UMLDI_UML_Edges;
|
AdaCore/training_material | Ada | 1,735 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_SDL_stdinc_h;
with System;
package SDL_SDL_timer_h is
SDL_TIMESLICE : constant := 10; -- ../include/SDL/SDL_timer.h:40
TIMER_RESOLUTION : constant := 10; -- ../include/SDL/SDL_timer.h:43
function SDL_GetTicks return SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_timer.h:49
pragma Import (C, SDL_GetTicks, "SDL_GetTicks");
procedure SDL_Delay (ms : SDL_SDL_stdinc_h.Uint32); -- ../include/SDL/SDL_timer.h:52
pragma Import (C, SDL_Delay, "SDL_Delay");
type SDL_TimerCallback is access function (arg1 : SDL_SDL_stdinc_h.Uint32) return SDL_SDL_stdinc_h.Uint32;
pragma Convention (C, SDL_TimerCallback); -- ../include/SDL/SDL_timer.h:55
function SDL_SetTimer (interval : SDL_SDL_stdinc_h.Uint32; callback : SDL_TimerCallback) return int; -- ../include/SDL/SDL_timer.h:86
pragma Import (C, SDL_SetTimer, "SDL_SetTimer");
type SDL_NewTimerCallback is access function (arg1 : SDL_SDL_stdinc_h.Uint32; arg2 : System.Address) return SDL_SDL_stdinc_h.Uint32;
pragma Convention (C, SDL_NewTimerCallback); -- ../include/SDL/SDL_timer.h:101
-- skipped empty struct u_SDL_TimerID
type SDL_TimerID is new System.Address; -- ../include/SDL/SDL_timer.h:104
function SDL_AddTimer
(interval : SDL_SDL_stdinc_h.Uint32;
callback : SDL_NewTimerCallback;
param : System.Address) return SDL_TimerID; -- ../include/SDL/SDL_timer.h:109
pragma Import (C, SDL_AddTimer, "SDL_AddTimer");
function SDL_RemoveTimer (t : SDL_TimerID) return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_timer.h:115
pragma Import (C, SDL_RemoveTimer, "SDL_RemoveTimer");
end SDL_SDL_timer_h;
|
shintakezou/drake | Ada | 15,540 | adb | with Ada.Calendar.Naked;
with Ada.Exception_Identification.From_Here;
with System.Zero_Terminated_WStrings;
with C.winbase;
with C.winnt;
package body Ada.Directories.Information is
use Exception_Identification.From_Here;
use type Exception_Identification.Exception_Id;
use type C.size_t;
use type C.windef.DWORD;
use type C.windef.WINBOOL;
use type C.winnt.HANDLE; -- C.void_ptr
subtype Directory_Entry_Information_Type is
System.Native_Directories.Directory_Entry_Information_Type;
function IO_Exception_Id (errno : C.windef.DWORD)
return Exception_Identification.Exception_Id
renames System.Native_Directories.IO_Exception_Id;
function Named_IO_Exception_Id (errno : C.windef.DWORD)
return Exception_Identification.Exception_Id
renames System.Native_Directories.Named_IO_Exception_Id;
function Is_Executable (Name : String) return Boolean;
function Is_Executable (Name : String) return Boolean is
-- Currently, check only that an extension is ".COM" or ".EXE".
-- It should check PATHEXT, or look PE header?
Ext_First : Positive;
Ext_Last : Natural;
Result : Boolean;
begin
Hierarchical_File_Names.Extension (Name,
First => Ext_First, Last => Ext_Last);
if Ext_Last - Ext_First + 1 = 3 then
declare
Ext : String (1 .. 3) := Name (Ext_First .. Ext_Last);
begin
for I in Ext'Range loop
if Ext (I) in 'a' .. 'z' then
Ext (I) := Character'Val (Character'Pos (Ext (I)) - 16#20#);
end if;
end loop;
Result := Ext = "COM" or else Ext = "EXE";
end;
else
Result := False;
end if;
return Result;
end Is_Executable;
-- implementation
function Creation_Time (Name : String) return Calendar.Time is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return Calendar.Naked.To_Time (Information.ftCreationTime);
end Creation_Time;
function Last_Access_Time (Name : String) return Calendar.Time is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return Calendar.Naked.To_Time (Information.ftLastAccessTime);
end Last_Access_Time;
function Is_Read_Only (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_SPARSE_FILE) /= 0;
end Is_Read_Only;
function Needs_Archiving (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_ARCHIVE) /= 0;
end Needs_Archiving;
function Is_Compressed (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_COMPRESSED) /= 0;
end Is_Compressed;
function Is_Encrypted (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_ENCRYPTED) /= 0;
end Is_Encrypted;
function Is_Hidden (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_HIDDEN) /= 0;
end Is_Hidden;
function Is_System (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_SYSTEM) /= 0;
end Is_System;
function Is_Offline (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_OFFLINE) /= 0;
end Is_Offline;
function Is_Temporary (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_TEMPORARY) /= 0;
end Is_Temporary;
function Is_Sparse (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_SPARSE_FILE) /= 0;
end Is_Sparse;
function Is_Not_Indexed (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) /= 0;
end Is_Not_Indexed;
function Creation_Time (
Directory_Entry : Directory_Entry_Type)
return Calendar.Time
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return Calendar.Naked.To_Time (
NC_Directory_Entry.Directory_Entry.ftLastWriteTime);
end Creation_Time;
function Last_Access_Time (
Directory_Entry : Directory_Entry_Type)
return Calendar.Time
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return Calendar.Naked.To_Time (
NC_Directory_Entry.Directory_Entry.ftLastAccessTime);
end Last_Access_Time;
function Is_Read_Only (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_READONLY) /= 0;
end Is_Read_Only;
function Needs_Archiving (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_ARCHIVE) /= 0;
end Needs_Archiving;
function Is_Compressed (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_COMPRESSED) /= 0;
end Is_Compressed;
function Is_Encrypted (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_ENCRYPTED) /= 0;
end Is_Encrypted;
function Is_Hidden (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_HIDDEN) /= 0;
end Is_Hidden;
function Is_System (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_SYSTEM) /= 0;
end Is_System;
function Is_Offline (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_OFFLINE) /= 0;
end Is_Offline;
function Is_Temporary (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_TEMPORARY) /= 0;
end Is_Temporary;
function Is_Sparse (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_SPARSE_FILE) /= 0;
end Is_Sparse;
function Is_Not_Indexed (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) /= 0;
end Is_Not_Indexed;
function Is_Symbolic_Link (Name : String) return Boolean is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return (Information.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_REPARSE_POINT) /= 0;
end Is_Symbolic_Link;
function Is_Symbolic_Link (
Directory_Entry : Directory_Entry_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return (NC_Directory_Entry.Directory_Entry.dwFileAttributes
and C.winnt.FILE_ATTRIBUTE_REPARSE_POINT) /= 0;
end Is_Symbolic_Link;
function User_Permission_Set (Name : String)
return User_Permission_Set_Type
is
Executable : constant Boolean := Is_Executable (Name);
Writable : constant Boolean := not Is_Read_Only (Name);
Readable : constant Boolean := True;
begin
return (
User_Execute => Executable,
User_Write => Writable,
User_Read => Readable);
end User_Permission_Set;
function User_Permission_Set (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return User_Permission_Set_Type
is
Executable : constant Boolean :=
Is_Executable (
Simple_Name (Directory_Entry)); -- checking the predicate
Writable : constant Boolean := not Is_Read_Only (Directory_Entry);
Readable : constant Boolean := True;
begin
return (
User_Execute => Executable,
User_Write => Writable,
User_Read => Readable);
end User_Permission_Set;
function Identity (Name : String) return File_Id is
Exception_Id : Exception_Identification.Exception_Id :=
Exception_Identification.Null_Id;
W_Name : aliased C.winnt.WCHAR_array (
0 ..
Name'Length * System.Zero_Terminated_WStrings.Expanding);
Handle : C.winnt.HANDLE;
Info : aliased C.winbase.BY_HANDLE_FILE_INFORMATION;
begin
System.Zero_Terminated_WStrings.To_C (Name, W_Name (0)'Access);
Handle := C.winbase.CreateFile (
W_Name (0)'Access,
dwDesiredAccess => 0,
dwShareMode =>
C.winnt.FILE_SHARE_READ or C.winnt.FILE_SHARE_WRITE
or C.winnt.FILE_SHARE_DELETE, -- only for query
lpSecurityAttributes => null,
dwCreationDisposition => C.winbase.OPEN_EXISTING,
dwFlagsAndAttributes =>
C.winbase.FILE_FLAG_BACKUP_SEMANTICS
or C.winbase.FILE_FLAG_OPEN_REPARSE_POINT,
hTemplateFile => C.windef.LPVOID (System.Null_Address));
if Handle = C.winbase.INVALID_HANDLE_VALUE then
Exception_Id := Named_IO_Exception_Id (C.winbase.GetLastError);
else
if C.winbase.GetFileInformationByHandle (Handle, Info'Access) =
C.windef.FALSE
then
Exception_Id := IO_Exception_Id (C.winbase.GetLastError);
end if;
if C.winbase.CloseHandle (Handle) = C.windef.FALSE then
if Exception_Id = Exception_Identification.Null_Id then
Exception_Id := IO_Exception_Id (C.winbase.GetLastError);
end if;
end if;
end if;
if Exception_Id /= Exception_Identification.Null_Id then
Raise_Exception (Exception_Id);
end if;
return (
FileIndexLow => Info.nFileIndexLow,
FileIndexHigh => Info.nFileIndexHigh,
VolumeSerialNumber => Info.dwVolumeSerialNumber);
end Identity;
function Identity (
Directory_Entry : Directory_Entry_Type)
return File_Id is
begin
-- WIN32_FILE_ATTRIBUTE_DATA does not contain the file index
return Identity (Full_Name (Directory_Entry)); -- checking the predicate
end Identity;
end Ada.Directories.Information;
|
jscparker/math_packages | Ada | 4,521 | ads |
--------------------------------------------------------------------------
-- package Jacobi_Eigen, Jacobi iterative eigen-decomposition
-- 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 Jacobi_Eigen
--
-- Jacobi's iterative algorithm for eigen-decomposition of
-- square real-valued symmetric matrices.
--
-- The Jacobi method converges quadratically and with high
-- reliability, but it is usually several times slower than the
-- standard Golub-Reinsch algorithm (unless the matrix is small).
-- Jacobi is usually best if accuracy and reliability are more
-- important than speed.
--
-- procedure Eigen_Decompose
--
-- Works on arbitrary diagonal blocks of input matrix. For other blocks just
-- copy the matrix to desired position; copy overhead is negligible compared
-- to the O(N^3) running time of the decomposition.
--
-- Procedure Eigen_Decompose is based on the Heinz Rutishauser ALGOL routine.
-- If you want to see the original program in its full glory, you should
-- be able to find it by googling "Rutishauser, Jacobi, Algol, ethistory".
-- It was written over half a century ago! Changes are few:
-- Slightly different calculation of the rotation angles.
-- Also a bit more care in avoiding overflows; the test suite
-- caught a few of them in the original routine.
--
generic
type Real is digits <>;
type Index is range <>;
type Matrix is array (Index, Index) of Real;
package Jacobi_Eigen is
type Col_Vector is array(Index) of Real;
-- procedure Eigen_Decompose
--
-- Standard Jacobi iterative eigendecomposition. The routine returns
-- eigenvectors and eigenvalues of any real-valued square symmetric matrix.
--
-- The orthonormal (unordered) eigenvectors are the Columns of Q.
-- The orthonormal (unordered) eigenvectors are returned as the Rows of Q'=Q_tr.
-- Eigenvals (returned in array Eigenvals) are ordered the same as Eigvecs in Q.
-- So A = QEQ'. The diagonal elements of diagonal matrix E are the eigvals.
-- The routine performs the eigen-decomposition on arbitrary square
-- diagonal blocks of matrix A.
-- It is assumed the blocks are symmetric.
-- The upper left corner of the square matrix is (Start_Col, Start_Col).
-- The lower rgt corner of the square matrix is (Final_Col, Final_Col).
-- Matrix A doesn't need to be positive definite, or semi-definite.
-- If Eigenvectors_Desired = False, then Q_tr is not calculated.
--
-- Routine only sees and operates on the upper triangle of matrix.
--
-- Input matrix A is destroyed. Save a copy of A if you need it.
--
-- Eigenvectors of A are returned as the ROWS of matrix: Q_tr
--
-- so Q_tr * A * Q = Diagonal_Eigs
--
procedure Eigen_Decompose
(A : in out Matrix; -- destroyed
Q_tr : out Matrix; -- rows of Q_tr are the eigvecs
Eigenvals : out Col_Vector;
No_of_Sweeps_Performed : out Natural;
Total_No_of_Rotations : out Natural;
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Eigenvectors_Desired : in Boolean := True);
procedure Sort_Eigs
(Eigenvals : in out Col_Vector;
Q_tr : in out Matrix; -- rows of Q_tr are the eigvecs
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Sort_Eigvecs_Also : in Boolean := True);
Standard_Threshold_Policy : constant Boolean := True;
-- True is faster.
-- False sometimes improves accuracy if the matrix is badly scaled.
end Jacobi_Eigen;
|
reznikmm/matreshka | Ada | 3,500 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Scanner_Utilities is
type Modes is (Regexp, XML);
function Mode return Modes;
-- Returns current generation mode.
end Scanner_Utilities;
|
charlie5/cBound | Ada | 1,723 | 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_glx_change_drawable_attributes_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
drawable : aliased xcb.xcb_glx_drawable_t;
num_attribs : aliased Interfaces.Unsigned_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_change_drawable_attributes_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_change_drawable_attributes_request_t.Item,
Element_Array =>
xcb.xcb_glx_change_drawable_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_glx_change_drawable_attributes_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_change_drawable_attributes_request_t.Pointer,
Element_Array =>
xcb.xcb_glx_change_drawable_attributes_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_change_drawable_attributes_request_t;
|
charlie5/cBound | Ada | 1,245 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with xcb.xcb_value_error_t;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_cursor_error_t is
-- Item
--
subtype Item is xcb.xcb_value_error_t.Item;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_cursor_error_t.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_cursor_error_t.Item,
Element_Array => xcb.xcb_cursor_error_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_cursor_error_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_cursor_error_t.Pointer,
Element_Array => xcb.xcb_cursor_error_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_cursor_error_t;
|
stcarrez/mat | Ada | 11,371 | ads | -----------------------------------------------------------------------
-- mat-memory-targets - Client info related to its memory
-- Copyright (C) 2014, 2015, 2019, 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.
-----------------------------------------------------------------------
with MAT.Events.Probes;
with MAT.Memory.Tools;
with MAT.Expressions;
package MAT.Memory.Targets is
Not_Found : exception;
-- Define some global statistics about the memory slots.
type Memory_Stat is record
Thread_Count : Natural := 0;
Total_Alloc : MAT.Types.Target_Size := 0;
Total_Free : MAT.Types.Target_Size := 0;
Malloc_Count : Natural := 0;
Free_Count : Natural := 0;
Realloc_Count : Natural := 0;
Used_Count : Natural := 0;
end record;
type Target_Memory is tagged limited private;
type Client_Memory_Ref is access all Target_Memory;
-- Initialize the target memory object to manage the memory slots, the stack frames
-- and setup the reader to analyze the memory events.
procedure Initialize (Memory : in out Target_Memory;
Manager : in out MAT.Events.Probes.Probe_Manager_Type'Class);
-- Add the memory region from the list of memory region managed by the program.
procedure Add_Region (Memory : in out Target_Memory;
Region : in Region_Info);
-- Find the memory region that intersect the given section described by <tt>From</tt>
-- and <tt>To</tt>. Each memory region that intersects is added to the <tt>Into</tt>
-- map.
procedure Find (Memory : in out Target_Memory;
From : in MAT.Types.Target_Addr;
To : in MAT.Types.Target_Addr;
Into : in out MAT.Memory.Region_Info_Map);
-- Find the region that matches the given name.
function Find_Region (Memory : in Target_Memory;
Name : in String) return Region_Info;
-- Take into account a malloc probe. The memory slot [Addr .. Slot.Size] is inserted
-- in the used slots map. The freed slots that intersect the malloc'ed region are
-- removed from the freed map.
procedure Probe_Malloc (Memory : in out Target_Memory;
Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
-- Take into account a free probe. Add the memory slot in the freed map and remove
-- the slot from the used slots map.
procedure Probe_Free (Memory : in out Target_Memory;
Addr : in MAT.Types.Target_Addr;
Slot : in Allocation;
Size : out MAT.Types.Target_Size;
By : out MAT.Events.Event_Id_Type);
-- Take into account a realloc probe. The old memory slot represented by Old_Addr is
-- removed from the used slots maps and the new memory slot [Addr .. Slot.Size] is
-- inserted in the used slots map.
procedure Probe_Realloc (Memory : in out Target_Memory;
Addr : in MAT.Types.Target_Addr;
Old_Addr : in MAT.Types.Target_Addr;
Slot : in Allocation;
Old_Size : out MAT.Types.Target_Size;
By : out MAT.Events.Event_Id_Type);
-- Take into account a secondary_stack mark. The address corresponds to
-- the `Mark_Id` structure that is recorded on the stack for the release.
procedure Probe_Secondary_Mark (Memory : in out Target_Memory;
Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
-- Take into account a secondary_stack allocate. The address corresponds to
-- the allocated block returned by secondary stack allocate.
procedure Probe_Secondary_Allocate (Memory : in out Target_Memory;
Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
-- Take into account a secondary_stack release. The address corresponds to
-- the `Mark_Id` structure that is recorded on the stack for the release.
-- It must match the first previous mark event with the same address and
-- the mark event is reported in `By`.
procedure Probe_Secondary_Release (Memory : in out Target_Memory;
Addr : in MAT.Types.Target_Addr;
Slot : in Allocation;
By : out MAT.Events.Event_Id_Type);
-- Collect the information about memory slot sizes allocated by the application.
procedure Size_Information (Memory : in out Target_Memory;
Sizes : in out MAT.Memory.Tools.Size_Info_Map);
-- Collect the information about threads and the memory allocations they've made.
procedure Thread_Information (Memory : in out Target_Memory;
Threads : in out Memory_Info_Map);
-- Collect the information about frames and the memory allocations they've made.
procedure Frame_Information (Memory : in out Target_Memory;
Level : in Natural;
Frames : in out Frame_Info_Map);
-- Get the global memory and allocation statistics.
procedure Stat_Information (Memory : in out Target_Memory;
Result : out Memory_Stat);
-- Find from the <tt>Memory</tt> map the memory slots whose address intersects
-- the region [From .. To] and which is selected by the given filter expression.
-- Add the memory slot in the <tt>Into</tt> list if it does not already contains
-- the memory slot.
procedure Find (Memory : in out Target_Memory;
From : in MAT.Types.Target_Addr;
To : in MAT.Types.Target_Addr;
Filter : in MAT.Expressions.Expression_Type;
Into : in out MAT.Memory.Allocation_Map);
private
protected type Memory_Allocator is
-- Add the memory region from the list of memory region managed by the program.
procedure Add_Region (Region : in Region_Info);
-- Find the region that matches the given name.
function Find_Region (Name : in String) return Region_Info;
-- Find the memory region that intersect the given section described by <tt>From</tt>
-- and <tt>To</tt>. Each memory region that intersects is added to the <tt>Into</tt>
-- map.
procedure Find (From : in MAT.Types.Target_Addr;
To : in MAT.Types.Target_Addr;
Into : in out MAT.Memory.Region_Info_Map);
-- Take into account a malloc probe. The memory slot [Addr .. Slot.Size] is inserted
-- in the used slots map. The freed slots that intersect the malloc'ed region are
-- removed from the freed map.
procedure Probe_Malloc (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
-- Take into account a free probe. Add the memory slot in the freed map and remove
-- the slot from the used slots map.
procedure Probe_Free (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation;
Size : out MAT.Types.Target_Size;
By : out MAT.Events.Event_Id_Type);
-- Take into account a realloc probe. The old memory slot represented by Old_Addr is
-- removed from the used slots maps and the new memory slot [Addr .. Slot.Size] is
-- inserted in the used slots map.
procedure Probe_Realloc (Addr : in MAT.Types.Target_Addr;
Old_Addr : in MAT.Types.Target_Addr;
Slot : in Allocation;
Old_Size : out MAT.Types.Target_Size;
By : out MAT.Events.Event_Id_Type);
-- Take into account a secondary_stack mark. The address corresponds to
-- the `Mark_Id` structure that is recorded on the stack for the release.
procedure Probe_Secondary_Mark (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
-- Take into account a secondary_stack allocate. The address corresponds to
-- the allocated block returned by secondary stack allocate.
procedure Probe_Secondary_Allocate (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
-- Take into account a secondary_stack release. The address corresponds to
-- the `Mark_Id` structure that is recorded on the stack for the release.
-- It must match the first previous mark event with the same address and
-- the mark event is reported in `By`.
procedure Probe_Secondary_Release (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation;
By : out MAT.Events.Event_Id_Type);
-- Collect the information about memory slot sizes allocated by the application.
procedure Size_Information (Sizes : in out MAT.Memory.Tools.Size_Info_Map);
-- Collect the information about threads and the memory allocations they've made.
procedure Thread_Information (Threads : in out Memory_Info_Map);
-- Collect the information about frames and the memory allocations they've made.
procedure Frame_Information (Level : in Natural;
Frames : in out Frame_Info_Map);
-- Find from the <tt>Memory</tt> map the memory slots whose address intersects
-- the region [From .. To] and which is selected by the given filter expression.
-- Add the memory slot in the <tt>Into</tt> list if it does not already contains
-- the memory slot.
procedure Find (From : in MAT.Types.Target_Addr;
To : in MAT.Types.Target_Addr;
Filter : in MAT.Expressions.Expression_Type;
Into : in out MAT.Memory.Allocation_Map);
-- Get the global memory and allocation statistics.
procedure Stat_Information (Result : out Memory_Stat);
private
Used_Slots : Allocation_Map;
Freed_Slots : Allocation_Map;
Regions : Region_Info_Map;
Stats : Memory_Stat;
end Memory_Allocator;
type Target_Memory is tagged limited record
Manager : MAT.Events.Probes.Probe_Manager_Type_Access;
Memory : Memory_Allocator;
end record;
end MAT.Memory.Targets;
|
AdaCore/Ada_Drivers_Library | Ada | 34,636 | ads | -- This spec has been automatically generated from cm4.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package Cortex_M_SVD.SCB is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Disables Interruption Folding
type ACTLR_DISFOLD_Field is
(
-- Interruption folding enabled
Normal,
-- Interruption folding disabled
Disable)
with Size => 1;
for ACTLR_DISFOLD_Field use
(Normal => 0,
Disable => 1);
-- Disabled FPU exception outputs
type ACTLR_PFEXCODIS_Field is
(
-- Normal operation.
Normal,
-- FPU exception outputs are disabled.
Disable)
with Size => 1;
for ACTLR_PFEXCODIS_Field use
(Normal => 0,
Disable => 1);
-- Disables dynamic read allocate mode for Write-Back Write-Allocate memory
-- regions:
type ACTLR_DISRAMODE_Field is
(
-- Normal operation.
Normal,
-- Dynamic disabled.
Disable)
with Size => 1;
for ACTLR_DISRAMODE_Field use
(Normal => 0,
Disable => 1);
-- Disables ITM and DWT ATB flush:
type ACTLR_DISITMATBFLUSH_Field is
(
-- Reset value for the field
Actlr_Disitmatbflush_Field_Reset,
-- ITM and DWT ATB flush disabled. AFVALID is ignored and AFREADY is
-- held HIGH.
Disable)
with Size => 1;
for ACTLR_DISITMATBFLUSH_Field use
(Actlr_Disitmatbflush_Field_Reset => 0,
Disable => 1);
-- Disables the Branch Target Address Cache (BTAC):
type ACTLR_DISBTACREAD_Field is
(
-- Normal operation.
Normal,
-- BTAC is not used and only static branch prediction can occur.
Disable)
with Size => 1;
for ACTLR_DISBTACREAD_Field use
(Normal => 0,
Disable => 1);
-- Disables the Branch Target Address Cache allocation:
type ACTLR_DISBTACALLOC_Field is
(
-- Normal operation.
Normal,
-- No new entries are allocated in BTAC, but existing entries can be
-- updated.
Disable)
with Size => 1;
for ACTLR_DISBTACALLOC_Field use
(Normal => 0,
Disable => 1);
-- Disables critical AXI Read-Under-Read:
type ACTLR_DISCRITAXIRUR_Field is
(
-- Normal operation.
Normal,
-- An AXI read to Strongly-ordered or device memory, or an LDREX to
-- shared memory, is not put on AXI if there are any outstanding reads
-- on AXI. Transactions on AXI cannot be interrupted. This bit might
-- reduce the time that these transactions are in progress and might
-- improve worst case interrupt latency. Performance is decreased when
-- this bit is set.
Disable)
with Size => 1;
for ACTLR_DISCRITAXIRUR_Field use
(Normal => 0,
Disable => 1);
-- Disables dual-issued direct branches:
type ACTLR_DISDI_DB_Field is
(
-- Normal operation.
Normal,
-- Direct branches instruction type cannot be dual-issued in channel 0
Disable)
with Size => 1;
for ACTLR_DISDI_DB_Field use
(Normal => 0,
Disable => 1);
-- Disables dual-issued indirect branches:
type ACTLR_DISDI_IB_Field is
(
-- Normal operation.
Normal,
-- Indirect branches, but not loads to PC instruction type cannot be
-- dual-issued in channel 0
Disable)
with Size => 1;
for ACTLR_DISDI_IB_Field use
(Normal => 0,
Disable => 1);
-- Disables dual-issued loads to PC:
type ACTLR_DISDI_LPC_Field is
(
-- Normal operation.
Normal,
-- Loads to PC instruction type cannot be dual-issued in channel 0
Disable)
with Size => 1;
for ACTLR_DISDI_LPC_Field use
(Normal => 0,
Disable => 1);
-- Disables integer MAC and MUL dual-issued instructions:
type ACTLR_DISDI_MAC_MUL_Field is
(
-- Normal operation.
Normal,
-- Integer MAC and MUL instruction type cannot be dual-issued in channel
-- 0
Disable)
with Size => 1;
for ACTLR_DISDI_MAC_MUL_Field use
(Normal => 0,
Disable => 1);
-- Disables VFP dual-issued instruction:
type ACTLR_DISDI_VFP_Field is
(
-- Normal operation.
Normal,
-- VFP instruction type cannot be dual-issued in channel 0
Disable)
with Size => 1;
for ACTLR_DISDI_VFP_Field use
(Normal => 0,
Disable => 1);
-- Disables direct branches instructions in channel 1:
type ACTLR_DISISSCH1_DB_Field is
(
-- Normal operation.
Normal,
-- Direct branches instruction type cannot be issued in channel 1
Disable)
with Size => 1;
for ACTLR_DISISSCH1_DB_Field use
(Normal => 0,
Disable => 1);
-- Disables indirect branches instructions in channel 1:
type ACTLR_DISISSCH1_IB_Field is
(
-- Normal operation.
Normal,
-- Indirect branches, but not loads to PC instruction type cannot be
-- issued in channel 1
Disable)
with Size => 1;
for ACTLR_DISISSCH1_IB_Field use
(Normal => 0,
Disable => 1);
-- Disables loads to PC instructions in channel 1:
type ACTLR_DISISSCH1_LPC_Field is
(
-- Normal operation.
Normal,
-- Loads to PC instruction type cannot be issued in channel 1
Disable)
with Size => 1;
for ACTLR_DISISSCH1_LPC_Field use
(Normal => 0,
Disable => 1);
-- Disables integer MAC and MUL instructions in channel 1:
type ACTLR_DISISSCH1_MAC_MUL_Field is
(
-- Normal operation.
Normal,
-- Integer MAC and MUL instruction type cannot be issued in channel 1
Disable)
with Size => 1;
for ACTLR_DISISSCH1_MAC_MUL_Field use
(Normal => 0,
Disable => 1);
-- Disables VFP instructions in channel 1:
type ACTLR_DISISSCH1_VFP_Field is
(
-- Normal operation.
Normal,
-- VFP instruction type cannot be issued in channel 1
Disable)
with Size => 1;
for ACTLR_DISISSCH1_VFP_Field use
(Normal => 0,
Disable => 1);
-- Disables dybnamic allocation of ADD ans SUB instructions:
type ACTLR_DISDYNADD_Field is
(
-- Normal operation. Some ADD and SUB instructions are resolved in EX1.
Normal,
-- All ADD and SUB instructions are resolved in EX2.
Disable)
with Size => 1;
for ACTLR_DISDYNADD_Field use
(Normal => 0,
Disable => 1);
-- Auxiliary Control Register. The ACTLR provides disable bits for the
-- following processor functions: FPU exception outputs, Dual-issue
-- functionality, Flushing of the trace output from the ITM and DWT,
-- Dynamic read allocate mode. By default this register is set to provide
-- optimum performance from the Cortex-M7 processor, and does not normally
-- require modification.
type ACTLR_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Disables Interruption Folding
DISFOLD : ACTLR_DISFOLD_Field := Cortex_M_SVD.SCB.Normal;
-- unspecified
Reserved_3_9 : HAL.UInt7 := 16#0#;
-- Disabled FPU exception outputs
PFEXCODIS : ACTLR_PFEXCODIS_Field := Cortex_M_SVD.SCB.Normal;
-- Disables dynamic read allocate mode for Write-Back Write-Allocate
-- memory regions:
DISRAMODE : ACTLR_DISRAMODE_Field := Cortex_M_SVD.SCB.Normal;
-- Read-only. Disables ITM and DWT ATB flush:
DISITMATBFLUSH : ACTLR_DISITMATBFLUSH_Field :=
Actlr_Disitmatbflush_Field_Reset;
-- Disables the Branch Target Address Cache (BTAC):
DISBTACREAD : ACTLR_DISBTACREAD_Field := Cortex_M_SVD.SCB.Normal;
-- Disables the Branch Target Address Cache allocation:
DISBTACALLOC : ACTLR_DISBTACALLOC_Field := Cortex_M_SVD.SCB.Normal;
-- Disables critical AXI Read-Under-Read:
DISCRITAXIRUR : ACTLR_DISCRITAXIRUR_Field :=
Cortex_M_SVD.SCB.Normal;
-- Disables dual-issued direct branches:
DISDI_DB : ACTLR_DISDI_DB_Field := Cortex_M_SVD.SCB.Normal;
-- Disables dual-issued indirect branches:
DISDI_IB : ACTLR_DISDI_IB_Field := Cortex_M_SVD.SCB.Normal;
-- Disables dual-issued loads to PC:
DISDI_LPC : ACTLR_DISDI_LPC_Field := Cortex_M_SVD.SCB.Normal;
-- Disables integer MAC and MUL dual-issued instructions:
DISDI_MAC_MUL : ACTLR_DISDI_MAC_MUL_Field :=
Cortex_M_SVD.SCB.Normal;
-- Disables VFP dual-issued instruction:
DISDI_VFP : ACTLR_DISDI_VFP_Field := Cortex_M_SVD.SCB.Normal;
-- Disables direct branches instructions in channel 1:
DISISSCH1_DB : ACTLR_DISISSCH1_DB_Field := Cortex_M_SVD.SCB.Normal;
-- Disables indirect branches instructions in channel 1:
DISISSCH1_IB : ACTLR_DISISSCH1_IB_Field := Cortex_M_SVD.SCB.Normal;
-- Disables loads to PC instructions in channel 1:
DISISSCH1_LPC : ACTLR_DISISSCH1_LPC_Field :=
Cortex_M_SVD.SCB.Normal;
-- Disables integer MAC and MUL instructions in channel 1:
DISISSCH1_MAC_MUL : ACTLR_DISISSCH1_MAC_MUL_Field :=
Cortex_M_SVD.SCB.Normal;
-- Disables VFP instructions in channel 1:
DISISSCH1_VFP : ACTLR_DISISSCH1_VFP_Field :=
Cortex_M_SVD.SCB.Normal;
-- Disables dybnamic allocation of ADD ans SUB instructions:
DISDYNADD : ACTLR_DISDYNADD_Field := Cortex_M_SVD.SCB.Normal;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ACTLR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
DISFOLD at 0 range 2 .. 2;
Reserved_3_9 at 0 range 3 .. 9;
PFEXCODIS at 0 range 10 .. 10;
DISRAMODE at 0 range 11 .. 11;
DISITMATBFLUSH at 0 range 12 .. 12;
DISBTACREAD at 0 range 13 .. 13;
DISBTACALLOC at 0 range 14 .. 14;
DISCRITAXIRUR at 0 range 15 .. 15;
DISDI_DB at 0 range 16 .. 16;
DISDI_IB at 0 range 17 .. 17;
DISDI_LPC at 0 range 18 .. 18;
DISDI_MAC_MUL at 0 range 19 .. 19;
DISDI_VFP at 0 range 20 .. 20;
DISISSCH1_DB at 0 range 21 .. 21;
DISISSCH1_IB at 0 range 22 .. 22;
DISISSCH1_LPC at 0 range 23 .. 23;
DISISSCH1_MAC_MUL at 0 range 24 .. 24;
DISISSCH1_VFP at 0 range 25 .. 25;
DISDYNADD at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-- Revision number, the p value in the rnpn product revision identifier.
type CPUID_Revision_Field is
(
-- Patch 0
P0,
-- Patch 1
P1,
-- Patch 2
P2)
with Size => 4;
for CPUID_Revision_Field use
(P0 => 0,
P1 => 1,
P2 => 2);
-- Part number of the processor.
type CPUID_PartNo_Field is
(
-- Cortes-M7
Cortex_M7)
with Size => 12;
for CPUID_PartNo_Field use
(Cortex_M7 => 3111);
subtype CPUID_Constant_Field is HAL.UInt4;
-- Variant number, the r value in the rnpn product revision identifier.
type CPUID_Variant_Field is
(
-- Revision 0
R0,
-- Revision 1
R1)
with Size => 4;
for CPUID_Variant_Field use
(R0 => 0,
R1 => 1);
-- Implementer code.
type CPUID_Implementer_Field is
(
-- ARM
Arm)
with Size => 8;
for CPUID_Implementer_Field use
(Arm => 65);
-- CPUID Base Register
type CPUID_Register is record
-- Read-only. Revision number, the p value in the rnpn product revision
-- identifier.
Revision : CPUID_Revision_Field;
-- Read-only. Part number of the processor.
PartNo : CPUID_PartNo_Field;
-- Read-only. Reads as 0xF.
Constant_k : CPUID_Constant_Field;
-- Read-only. Variant number, the r value in the rnpn product revision
-- identifier.
Variant : CPUID_Variant_Field;
-- Read-only. Implementer code.
Implementer : CPUID_Implementer_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CPUID_Register use record
Revision at 0 range 0 .. 3;
PartNo at 0 range 4 .. 15;
Constant_k at 0 range 16 .. 19;
Variant at 0 range 20 .. 23;
Implementer at 0 range 24 .. 31;
end record;
subtype ICSR_VECTACTIVE_Field is HAL.UInt9;
-- Indicates whether there are preempted active exceptions.
type ICSR_RETTOBASE_Field is
(
-- There are preempted active exceptions to execute.
Preempted,
-- There are no active exceptions, or the currently-executing exception
-- is the only active exception.
No_Preempted)
with Size => 1;
for ICSR_RETTOBASE_Field use
(Preempted => 0,
No_Preempted => 1);
subtype ICSR_VECTPENDING_Field is HAL.UInt9;
-- Interrupt Control and State Register
type ICSR_Register is record
-- Read-only. Contains the active exception number. Subtract 16 from
-- this value to obtain the CMSIS IRQ number required to index into the
-- Interrupt Clear-Enable, Set-Enable, Clear-Pending, Set-Pending or
-- Priority Registers.
VECTACTIVE : ICSR_VECTACTIVE_Field := 16#0#;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- Read-only. Indicates whether there are preempted active exceptions.
RETTOBASE : ICSR_RETTOBASE_Field := Cortex_M_SVD.SCB.Preempted;
-- Read-only. Indicates the exception number of the highest priority
-- pending enabled exception.
VECTPENDING : ICSR_VECTPENDING_Field := 16#0#;
-- unspecified
Reserved_21_21 : HAL.Bit := 16#0#;
-- Interrupt pending flag, excluding NMI and Faults
ISRPENDING : Boolean := False;
-- unspecified
Reserved_23_24 : HAL.UInt2 := 16#0#;
-- Write-only. SysTick exception clear-pending bit.
PENDSTCLR : Boolean := False;
-- SysTick exception set-pending bit.
PENDSTSET : Boolean := False;
-- Write-only. PendSV clear-pending bit.
PENDSVCLR : Boolean := False;
-- PendSV set-pending bit.
PENDSVSET : Boolean := False;
-- unspecified
Reserved_29_30 : HAL.UInt2 := 16#0#;
-- NMI set-pending bit.
NMIPENDSET : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICSR_Register use record
VECTACTIVE at 0 range 0 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
RETTOBASE at 0 range 11 .. 11;
VECTPENDING at 0 range 12 .. 20;
Reserved_21_21 at 0 range 21 .. 21;
ISRPENDING at 0 range 22 .. 22;
Reserved_23_24 at 0 range 23 .. 24;
PENDSTCLR at 0 range 25 .. 25;
PENDSTSET at 0 range 26 .. 26;
PENDSVCLR at 0 range 27 .. 27;
PENDSVSET at 0 range 28 .. 28;
Reserved_29_30 at 0 range 29 .. 30;
NMIPENDSET at 0 range 31 .. 31;
end record;
-- Interrupt priority grouping field. This field determines the split of
-- group priority from subpriority.
type AIRCR_PRIGROUP_Field is
(
-- Group priority bits: [7:1], subpriority bits [0]
Bxxxxxxx_Y,
-- Group priority bits: [7:2], subpriority bits [1:0]
Bxxxxxx_YY,
-- Group priority bits: [7:3], subpriority bits [2:0]
Bxxxxx_YYY,
-- Group priority bits: [7:4], subpriority bits [3:0]
Bxxxx_YYYY,
-- Group priority bits: [7:5], subpriority bits [4:0]
Bxxx_YYYYY,
-- Group priority bits: [7:6], subpriority bits [5:0]
Bxx_YYYYYY,
-- Group priority bits: [7], subpriority bits [6:0]
Bx_YYYYYYY,
-- Group priority bits: None, subpriority bits [7:0]
B_YYYYYYYY)
with Size => 3;
for AIRCR_PRIGROUP_Field use
(Bxxxxxxx_Y => 0,
Bxxxxxx_YY => 1,
Bxxxxx_YYY => 2,
Bxxxx_YYYY => 3,
Bxxx_YYYYY => 4,
Bxx_YYYYYY => 5,
Bx_YYYYYYY => 6,
B_YYYYYYYY => 7);
-- Data endianness bit setting is implementation defined.
type AIRCR_ENDIANNESS_Field is
(
-- Data is little endian
Little_Endian,
-- Data is big endian
Big_Endian)
with Size => 1;
for AIRCR_ENDIANNESS_Field use
(Little_Endian => 0,
Big_Endian => 1);
-- Register key. On write, write 0x5FA to VECTKEY, otherwise the write is
-- ignored. Reads as 0xFA05
type AIRCR_VECTKEY_Field is
(
-- The write key
Key,
-- The read key
Key_Read)
with Size => 16;
for AIRCR_VECTKEY_Field use
(Key => 1530,
Key_Read => 64005);
-- Application Interrupt and Reset Control Register
type AIRCR_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Write-only. System reset request bit setting is implementation
-- defined.
SYSRESETREQ : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- Interrupt priority grouping field. This field determines the split of
-- group priority from subpriority.
PRIGROUP : AIRCR_PRIGROUP_Field := Cortex_M_SVD.SCB.Bxxxxxxx_Y;
-- unspecified
Reserved_11_14 : HAL.UInt4 := 16#0#;
-- Read-only. Data endianness bit setting is implementation defined.
ENDIANNESS : AIRCR_ENDIANNESS_Field :=
Cortex_M_SVD.SCB.Little_Endian;
-- Register key. On write, write 0x5FA to VECTKEY, otherwise the write
-- is ignored. Reads as 0xFA05
VECTKEY : AIRCR_VECTKEY_Field := Cortex_M_SVD.SCB.Key_Read;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AIRCR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
SYSRESETREQ at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
PRIGROUP at 0 range 8 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
ENDIANNESS at 0 range 15 .. 15;
VECTKEY at 0 range 16 .. 31;
end record;
-- System Control Register
type SCR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Indicates sleep-on-exit when returning from Handler mode to Thread
-- mode
SLEEPONEXIT : Boolean := False;
-- Controls whether the processor uses sleep or deep sleep as its
-- low-power mode
SLEEPDEEP : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Send event on pending bit
SEVONPEND : Boolean := False;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SCR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
SLEEPONEXIT at 0 range 1 .. 1;
SLEEPDEEP at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
SEVONPEND at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Indicates how the processor enters Thread mode
type CCR_NONBASETHREADENA_Field is
(
-- Processor can enter Thread mode only when no exception is active
No_Active_Exception,
-- Processor can enter Thread mode from any level under the control of
-- an EXC_RETURN value
On_Exc_Return)
with Size => 1;
for CCR_NONBASETHREADENA_Field use
(No_Active_Exception => 0,
On_Exc_Return => 1);
-- Configuration and Control Register
type CCR_Register is record
-- Indicates how the processor enters Thread mode
NONBASETHREADENA : CCR_NONBASETHREADENA_Field :=
Cortex_M_SVD.SCB.No_Active_Exception;
-- Enables unprivileged software access to the STIR
USERSETMPEND : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Enables unalign access traps.
UNALIGNED_TRP : Boolean := False;
-- Enables faulting or halting when the processor executes an SDIF or
-- UDIV instruction with a divisor of 0.
DIV0_TRP : Boolean := False;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Enables handlers with priority -1 or -2 to ignore data BusFaults
-- caused by load and store instructions. This applies to the hard
-- fault, NMI, and FAULTMASK escalated handlers.
BFHFNMIGN : Boolean := False;
-- Read-only. Always reads-as-one. It indicates stack alignment on
-- exception entry is 8-byte aligned.
STKALIGN : Boolean := True;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
-- Enables L1 data cache.
DC : Boolean := False;
-- Enables L1 instruction cache.
IC : Boolean := False;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
NONBASETHREADENA at 0 range 0 .. 0;
USERSETMPEND at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
UNALIGNED_TRP at 0 range 3 .. 3;
DIV0_TRP at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
BFHFNMIGN at 0 range 8 .. 8;
STKALIGN at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
DC at 0 range 16 .. 16;
IC at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype SHPR1_PRI_4_Field is HAL.UInt8;
subtype SHPR1_PRI_5_Field is HAL.UInt8;
subtype SHPR1_PRI_6_Field is HAL.UInt8;
-- System Handler Priority Register 1
type SHPR1_Register is record
-- Priority of the system handler, MemManage
PRI_4 : SHPR1_PRI_4_Field := 16#0#;
-- Priority of the system handler, BusFault
PRI_5 : SHPR1_PRI_5_Field := 16#0#;
-- Priority of the system handler, UsageFault
PRI_6 : SHPR1_PRI_6_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SHPR1_Register use record
PRI_4 at 0 range 0 .. 7;
PRI_5 at 0 range 8 .. 15;
PRI_6 at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype SHPR2_PRI_11_Field is HAL.UInt8;
-- System Handler Priority Register 2
type SHPR2_Register is record
-- unspecified
Reserved_0_23 : HAL.UInt24 := 16#0#;
-- Priority of the system handler, SVCall
PRI_11 : SHPR2_PRI_11_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SHPR2_Register use record
Reserved_0_23 at 0 range 0 .. 23;
PRI_11 at 0 range 24 .. 31;
end record;
subtype SHPR3_PRI_14_Field is HAL.UInt8;
subtype SHPR3_PRI_15_Field is HAL.UInt8;
-- System Handler Priority Register 3
type SHPR3_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Priority of the system handler, PendSV
PRI_14 : SHPR3_PRI_14_Field := 16#0#;
-- Priority of the system handler, SysTick
PRI_15 : SHPR3_PRI_15_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SHPR3_Register use record
Reserved_0_15 at 0 range 0 .. 15;
PRI_14 at 0 range 16 .. 23;
PRI_15 at 0 range 24 .. 31;
end record;
-- System Handler Control and State Register
type SHPRS_Register is record
-- Read-only. MemManage exception active bit, reads as 1 if exception is
-- active.
MEMFAULTACT : Boolean := False;
-- Read-only. BusFault exception active bit, reads as 1 if exception is
-- active.
BUSFAULTACT : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Read-only. UsageFault exception active bit, reads as 1 if exception
-- is active.
USGFAULTACT : Boolean := False;
-- unspecified
Reserved_4_6 : HAL.UInt3 := 16#0#;
-- Read-only. SVCall active bit, reads as 1 if exception is active.
SVCALLACT : Boolean := False;
-- Read-only. Debug Monitor active bit, reads as 1 if exception is
-- active.
MONITORACT : Boolean := False;
-- unspecified
Reserved_9_9 : HAL.Bit := 16#0#;
-- Read-only. PendSV exception active bit, reads as 1 if exception is
-- active.
PENDSVACT : Boolean := False;
-- Read-only. Systick exception active bit, reads as 1 if exception is
-- active.
SYSTICKACT : Boolean := False;
-- Read-only. UsageFault exception pending bit, reads as 1 if exception
-- is pending
USGFAULTPENDED : Boolean := False;
-- Read-only. MemManage exception pending bit, reads as 1 if exception
-- is pending
MEMFAULTPENDED : Boolean := False;
-- Read-only. BusFault exception pending bit, reads as 1 if exception is
-- pending
BUSFAULTPENDED : Boolean := False;
-- Read-only. SVCall pending bit, reads as 1 if exception is pending
SVCALLPENDED : Boolean := False;
-- MemManage enable bit, set to 1 to enable
MEMFAULTENA : Boolean := False;
-- BusFault enable bit, set to 1 to enable
BUSFAULTENA : Boolean := False;
-- UsageFault enable bit, set to 1 to enable
USGFAULTENA : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SHPRS_Register use record
MEMFAULTACT at 0 range 0 .. 0;
BUSFAULTACT at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
USGFAULTACT at 0 range 3 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
SVCALLACT at 0 range 7 .. 7;
MONITORACT at 0 range 8 .. 8;
Reserved_9_9 at 0 range 9 .. 9;
PENDSVACT at 0 range 10 .. 10;
SYSTICKACT at 0 range 11 .. 11;
USGFAULTPENDED at 0 range 12 .. 12;
MEMFAULTPENDED at 0 range 13 .. 13;
BUSFAULTPENDED at 0 range 14 .. 14;
SVCALLPENDED at 0 range 15 .. 15;
MEMFAULTENA at 0 range 16 .. 16;
BUSFAULTENA at 0 range 17 .. 17;
USGFAULTENA at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- MemManage Fault Status Register
type MMSR_Register is record
-- Instruction access violation flag
IACCVIOL : Boolean := False;
-- Data access violation flag
DACCVIOL : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- MemManage fault on unstacking for a return from exception
MUNSTKERR : Boolean := False;
-- MemManage fault on stacking for exception entry
MSTKERR : Boolean := False;
-- MemManage fault during floating-point lazy state preservation.
MLSPERR : Boolean := False;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- MemManage fault address register valid flag.
MMARVALID : Boolean := False;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for MMSR_Register use record
IACCVIOL at 0 range 0 .. 0;
DACCVIOL at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
MUNSTKERR at 0 range 3 .. 3;
MSTKERR at 0 range 4 .. 4;
MLSPERR at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
MMARVALID at 0 range 7 .. 7;
end record;
-- BusFault Status Register
type BFSR_Register is record
-- Instruction bus error
IBUSERR : Boolean := False;
-- Precise data bus error
PRECISERR : Boolean := False;
-- Precise data bus error
IMPRECISERR : Boolean := False;
-- BusFault on unstacking for a return from exception.
UNSTKERR : Boolean := False;
-- BusFault on stacking for exception entry.
STKERR : Boolean := False;
-- BusFault on floating-point lazy state preservation.
LSPERR : Boolean := False;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- BusFault Address Register valid flag.
BFARVALID : Boolean := False;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for BFSR_Register use record
IBUSERR at 0 range 0 .. 0;
PRECISERR at 0 range 1 .. 1;
IMPRECISERR at 0 range 2 .. 2;
UNSTKERR at 0 range 3 .. 3;
STKERR at 0 range 4 .. 4;
LSPERR at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
BFARVALID at 0 range 7 .. 7;
end record;
-- UsageFault Status Register
type UFSR_Register is record
-- Undefined instruction UsageFault
UNDEFINSTR : Boolean := False;
-- Invalid State UsageFault
INVSTATE : Boolean := False;
-- Invalid PC load UsageFault, caused by an invalid PC load by
-- EXC_RETURN
INVPC : Boolean := False;
-- No coprocessor UsageFault
NOCP : Boolean := False;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- Unaligned access UsageFault
UNALIGNED : Boolean := False;
-- Divide by zero UsageFault.
DIVBYZERO : Boolean := False;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Size => 16,
Bit_Order => System.Low_Order_First;
for UFSR_Register use record
UNDEFINSTR at 0 range 0 .. 0;
INVSTATE at 0 range 1 .. 1;
INVPC at 0 range 2 .. 2;
NOCP at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
UNALIGNED at 0 range 8 .. 8;
DIVBYZERO at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-- HardFault Status Register
type HFSR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Indicates a BusFault on a vector table read during exception
-- processing.
VECTTBL : Boolean := False;
-- unspecified
Reserved_2_29 : HAL.UInt28 := 16#0#;
-- Indicates a forced hard fault, generated by escalation of a fault
-- with configurable priority that cannot be handled, either because of
-- priority or because it is disabled.
FORCED : Boolean := False;
-- Reserved for Debug use. When writing to the register, you must write
-- 1 to this bit, otherwise behavior is UNPREDICTABLE.
DEBUGEVT : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HFSR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
VECTTBL at 0 range 1 .. 1;
Reserved_2_29 at 0 range 2 .. 29;
FORCED at 0 range 30 .. 30;
DEBUGEVT at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- System control block
type SCB_Peripheral is record
-- Auxiliary Control Register. The ACTLR provides disable bits for the
-- following processor functions: FPU exception outputs, Dual-issue
-- functionality, Flushing of the trace output from the ITM and DWT,
-- Dynamic read allocate mode. By default this register is set to
-- provide optimum performance from the Cortex-M7 processor, and does
-- not normally require modification.
ACTLR : aliased ACTLR_Register;
-- CPUID Base Register
CPUID : aliased CPUID_Register;
-- Interrupt Control and State Register
ICSR : aliased ICSR_Register;
-- Vector Table Offset Register
VTOR : aliased HAL.UInt32;
-- Application Interrupt and Reset Control Register
AIRCR : aliased AIRCR_Register;
-- System Control Register
SCR : aliased SCR_Register;
-- Configuration and Control Register
CCR : aliased CCR_Register;
-- System Handler Priority Register 1
SHPR1 : aliased SHPR1_Register;
-- System Handler Priority Register 2
SHPR2 : aliased SHPR2_Register;
-- System Handler Priority Register 3
SHPR3 : aliased SHPR3_Register;
-- System Handler Control and State Register
SHPRS : aliased SHPRS_Register;
-- MemManage Fault Status Register
MMSR : aliased MMSR_Register;
-- BusFault Status Register
BFSR : aliased BFSR_Register;
-- UsageFault Status Register
UFSR : aliased UFSR_Register;
-- HardFault Status Register
HFSR : aliased HFSR_Register;
-- MemManage Fault Address Register
MMAR : aliased HAL.UInt32;
-- BusFault Address Register
BFAR : aliased HAL.UInt32;
end record
with Volatile;
for SCB_Peripheral use record
ACTLR at 16#8# range 0 .. 31;
CPUID at 16#D00# range 0 .. 31;
ICSR at 16#D04# range 0 .. 31;
VTOR at 16#D08# range 0 .. 31;
AIRCR at 16#D0C# range 0 .. 31;
SCR at 16#D10# range 0 .. 31;
CCR at 16#D14# range 0 .. 31;
SHPR1 at 16#D18# range 0 .. 31;
SHPR2 at 16#D1C# range 0 .. 31;
SHPR3 at 16#D20# range 0 .. 31;
SHPRS at 16#D24# range 0 .. 31;
MMSR at 16#D28# range 0 .. 7;
BFSR at 16#D29# range 0 .. 7;
UFSR at 16#D2A# range 0 .. 15;
HFSR at 16#D2C# range 0 .. 31;
MMAR at 16#D34# range 0 .. 31;
BFAR at 16#D38# range 0 .. 31;
end record;
-- System control block
SCB_Periph : aliased SCB_Peripheral
with Import, Address => System'To_Address (16#E000E000#);
end Cortex_M_SVD.SCB;
|
dbanetto/uni | Ada | 3,335 | ads | with Vehicle;
with common; use common;
with Reservoir;
package Pump with
Spark_Mode,
Abstract_State => (Unit, State),
Initializes => (Unit, State) is
procedure Initialize with
Global => (In_Out => (Unit, State)),
Depends => ((Unit, State) => (null), (null) => (Unit, State)),
Post => GetDebt = MoneyUnit (0.0) and not isNozzleOut;
procedure LiftNozzle (fuel : FuelType) with
Global => (In_Out => (State, Unit)),
Pre => not isNozzleOut and
( -- if there is a debt a different fuel type cannot be picked
(GetDebt > MoneyUnit (0.0) and fuel = GetCurrentFuelType) or
-- if there is no debt, does not matter which fuel nozzle is picked up
(GetDebt = MoneyUnit (0.0))
),
Post => isNozzleOut and fuel = GetCurrentFuelType and GetDebt = GetDebt'Old;
procedure ReturnNozzle with
Global => (In_Out => State, Input => Unit),
Depends => (State => (State, Unit)),
Pre => isNozzleOut,
Post => not isNozzleOut;
procedure PumpFuelFull (tank : in out Vehicle.Tank) with
Global => (In_Out => (Unit, Reservoir.Res), Input => State),
Depends =>
((Unit, tank, Reservoir.Res) => (tank, Unit, State, Reservoir.Res)),
Pre => isNozzleOut,
Post => GetCurrentFuelType = GetCurrentFuelType'Old and
-- there are two cases with pumping, if the tank is not full & reservior not empty
-- then there will be some pumping & an increase in debt
((not Vehicle.IsFull (tank'Old) and
not Reservoir.isEmpty (GetCurrentFuelType)'Old and
GetDebt > GetDebt'Old) or
-- the second case is when either the tank is full or reservior is empty
-- so no pumping will occur & thus no change in debt
((Vehicle.IsFull (tank'Old) or
Reservoir.isEmpty (GetCurrentFuelType)'Old) and
GetDebt = GetDebt'Old));
procedure PumpFuel (tank : in out Vehicle.Tank; amount : FuelUnit) with
Global => (In_Out => (Unit, Reservoir.Res), Input => State),
Depends =>
((Unit, tank, Reservoir.Res) =>
(tank, Unit, State, amount, Reservoir.Res)),
Pre => isNozzleOut and amount > FuelUnit (0),
-- GNAT cannot prove that GetDebt after is greater or equal to GetDebt before
Post => GetCurrentFuelType = GetCurrentFuelType'Old and
-- there are two cases with pumping, if the tank is not full & reservior not empty
-- then there will be some pumping & an increase in debt
((not Vehicle.IsFull (tank'Old) and
not Reservoir.isEmpty (GetCurrentFuelType)'Old and
GetDebt > GetDebt'Old) or
-- the second case is when either the tank is full or reservior is empty
-- so no pumping will occur & thus no change in debt
((Vehicle.IsFull (tank'Old) or
Reservoir.isEmpty (GetCurrentFuelType)'Old) and
GetDebt = GetDebt'Old));
procedure Pay (amount : MoneyUnit) with
Global => (In_Out => Unit),
Pre => GetDebt >= amount and amount >= MoneyUnit (0.00),
Post => GetDebt'Old - amount = GetDebt;
function isNozzleOut return Boolean with
Global => (Input => State);
function GetDebt return MoneyUnit with
Global => (Input => Unit);
function GetCurrentFuelType return FuelType with
Global => (Input => Unit);
end Pump;
|
tum-ei-rcs/StratoX | Ada | 7,741 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . N U M E R I C S . G E N E R I C _ C O M P L E X _ T Y P E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
generic
type Real is digits <>;
package Ada.Numerics.Generic_Complex_Types is
pragma Pure;
type Complex is record
Re, Im : Real'Base;
end record;
pragma Complex_Representation (Complex);
type Imaginary is private;
pragma Preelaborable_Initialization (Imaginary);
i : constant Imaginary;
j : constant Imaginary;
function Re (X : Complex) return Real'Base;
function Im (X : Complex) return Real'Base;
function Im (X : Imaginary) return Real'Base;
procedure Set_Re (X : in out Complex; Re : Real'Base);
procedure Set_Im (X : in out Complex; Im : Real'Base);
procedure Set_Im (X : out Imaginary; Im : Real'Base);
function Compose_From_Cartesian (Re, Im : Real'Base) return Complex;
function Compose_From_Cartesian (Re : Real'Base) return Complex;
function Compose_From_Cartesian (Im : Imaginary) return Complex;
function Modulus (X : Complex) return Real'Base;
function "abs" (Right : Complex) return Real'Base renames Modulus;
function Argument (X : Complex) return Real'Base;
function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
function Compose_From_Polar (
Modulus, Argument : Real'Base)
return Complex;
function Compose_From_Polar (
Modulus, Argument, Cycle : Real'Base)
return Complex;
function "+" (Right : Complex) return Complex;
function "-" (Right : Complex) return Complex;
function Conjugate (X : Complex) return Complex;
function "+" (Left, Right : Complex) return Complex;
function "-" (Left, Right : Complex) return Complex;
function "*" (Left, Right : Complex) return Complex;
function "/" (Left, Right : Complex) return Complex;
function "**" (Left : Complex; Right : Integer) return Complex;
function "+" (Right : Imaginary) return Imaginary;
function "-" (Right : Imaginary) return Imaginary;
function Conjugate (X : Imaginary) return Imaginary renames "-";
function "abs" (Right : Imaginary) return Real'Base;
function "+" (Left, Right : Imaginary) return Imaginary;
function "-" (Left, Right : Imaginary) return Imaginary;
function "*" (Left, Right : Imaginary) return Real'Base;
function "/" (Left, Right : Imaginary) return Real'Base;
function "**" (Left : Imaginary; Right : Integer) return Complex;
function "<" (Left, Right : Imaginary) return Boolean;
function "<=" (Left, Right : Imaginary) return Boolean;
function ">" (Left, Right : Imaginary) return Boolean;
function ">=" (Left, Right : Imaginary) return Boolean;
function "+" (Left : Complex; Right : Real'Base) return Complex;
function "+" (Left : Real'Base; Right : Complex) return Complex;
function "-" (Left : Complex; Right : Real'Base) return Complex;
function "-" (Left : Real'Base; Right : Complex) return Complex;
function "*" (Left : Complex; Right : Real'Base) return Complex;
function "*" (Left : Real'Base; Right : Complex) return Complex;
function "/" (Left : Complex; Right : Real'Base) return Complex;
function "/" (Left : Real'Base; Right : Complex) return Complex;
function "+" (Left : Complex; Right : Imaginary) return Complex;
function "+" (Left : Imaginary; Right : Complex) return Complex;
function "-" (Left : Complex; Right : Imaginary) return Complex;
function "-" (Left : Imaginary; Right : Complex) return Complex;
function "*" (Left : Complex; Right : Imaginary) return Complex;
function "*" (Left : Imaginary; Right : Complex) return Complex;
function "/" (Left : Complex; Right : Imaginary) return Complex;
function "/" (Left : Imaginary; Right : Complex) return Complex;
function "+" (Left : Imaginary; Right : Real'Base) return Complex;
function "+" (Left : Real'Base; Right : Imaginary) return Complex;
function "-" (Left : Imaginary; Right : Real'Base) return Complex;
function "-" (Left : Real'Base; Right : Imaginary) return Complex;
function "*" (Left : Imaginary; Right : Real'Base) return Imaginary;
function "*" (Left : Real'Base; Right : Imaginary) return Imaginary;
function "/" (Left : Imaginary; Right : Real'Base) return Imaginary;
function "/" (Left : Real'Base; Right : Imaginary) return Imaginary;
private
type Imaginary is new Real'Base;
i : constant Imaginary := 1.0;
j : constant Imaginary := 1.0;
pragma Inline ("+");
pragma Inline ("-");
pragma Inline ("*");
pragma Inline ("<");
pragma Inline ("<=");
pragma Inline (">");
pragma Inline (">=");
pragma Inline ("abs");
pragma Inline (Compose_From_Cartesian);
pragma Inline (Conjugate);
pragma Inline (Im);
pragma Inline (Re);
pragma Inline (Set_Im);
pragma Inline (Set_Re);
end Ada.Numerics.Generic_Complex_Types;
|
jrcarter/Ada_GUI | Ada | 3,612 | ads | -- --
-- package Copyright (c) Dmitry A. Kazakov --
-- Strings_Edit.Time_Conversions Luebeck --
-- Interface Summer, 2016 --
-- --
-- Last revision : 12:47 19 Jun 2016 --
-- --
-- This library 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 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 --
-- General Public License for more details. You should have --
-- received a copy of the GNU 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. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones; use Ada.Calendar.Time_Zones;
with Tables.Names;
package Strings_Edit.Time_Conversions is
--
-- To_String -- Convert time to text format
--
-- Date - The time to convert
--
-- Returns :
--
-- String representation of the parameter Date in the format:
-- Sun, 17 Feb 2013 21:02:43 +0100
--
function To_String (Date : Time) return String;
--
-- To_Time -- Time conversion
--
-- Date - To convert
--
-- Supported formats:
--
-- Fri, 31 Dec 1999 23:59:59 GMT
-- Friday, 31-Dec-99 23:59:59 GMT
-- Fri Dec 31 23:59:59 1999
--
-- Exceptions :
--
-- Time_Error - On error
--
function To_Time (Date : String) return Time;
--
-- Check_Spelling -- Of a month, day, zone name
--
procedure Check_Spelling (Name : String);
--
-- Check_Matched -- End of a month, day, zone name
--
function Check_Matched
( Source : String;
Pointer : Integer
) return Boolean;
private
package Day_Tables_Raw is new Tables (Day_Name);
package Day_Tables is new Day_Tables_Raw.Names;
use Day_Tables;
package Month_Tables_Raw is new Tables (Month_Number);
package Month_Tables is new Month_Tables_Raw.Names;
use Month_Tables;
package Zone_Tables_Raw is new Tables (Time_Zones.Time_Offset);
package Zone_Tables is new Zone_Tables_Raw.Names;
use Zone_Tables;
Months : Month_Tables.Dictionary;
Week_Days : Day_Tables.Dictionary;
Zones : Zone_Tables.Dictionary;
end Strings_Edit.Time_Conversions;
|
reznikmm/matreshka | Ada | 5,083 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Testsuite 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$
------------------------------------------------------------------------------
private with League.Strings;
private with XML.SAX.Attributes;
with XML.SAX.Content_Handlers;
with XML.SAX.Error_Handlers;
private with XML.SAX.Locators;
private with XML.SAX.Parse_Exceptions;
package XMLCatConf.Testsuite_Handlers is
type Testsuite_Handler is
limited new XML.SAX.Content_Handlers.SAX_Content_Handler
and XML.SAX.Error_Handlers.SAX_Error_Handler with private;
private
type Testsuite_Handler is
limited new XML.SAX.Content_Handlers.SAX_Content_Handler
and XML.SAX.Error_Handlers.SAX_Error_Handler with
record
Locator : XML.SAX.Locators.SAX_Locator;
end record;
overriding procedure Error
(Self : in out Testsuite_Handler;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception;
Success : in out Boolean);
overriding function Error_String
(Self : Testsuite_Handler) return League.Strings.Universal_String;
overriding procedure Fatal_Error
(Self : in out Testsuite_Handler;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception);
overriding procedure Set_Document_Locator
(Self : in out Testsuite_Handler;
Locator : XML.SAX.Locators.SAX_Locator);
overriding procedure Start_Element
(Self : in out Testsuite_Handler;
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 Warning
(Self : in out Testsuite_Handler;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception;
Success : in out Boolean);
end XMLCatConf.Testsuite_Handlers;
|
zhmu/ananas | Ada | 4,010 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . G L O B A L _ L O C K S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-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 implementation is specific to NT
with System.OS_Interface;
with System.Task_Lock;
with System.Win32;
with Interfaces.C.Strings;
package body System.Global_Locks is
package TSL renames System.Task_Lock;
package OSI renames System.OS_Interface;
package ICS renames Interfaces.C.Strings;
subtype Lock_File_Entry is Win32.HANDLE;
Last_Lock : Lock_Type := Null_Lock;
Lock_Table : array (Lock_Type range 1 .. 15) of Lock_File_Entry;
-----------------
-- Create_Lock --
-----------------
procedure Create_Lock (Lock : out Lock_Type; Name : String) is
L : Lock_Type;
begin
TSL.Lock;
Last_Lock := Last_Lock + 1;
L := Last_Lock;
TSL.Unlock;
if L > Lock_Table'Last then
raise Lock_Error;
end if;
Lock_Table (L) :=
OSI.CreateMutex (null, Win32.FALSE, ICS.New_String (Name));
Lock := L;
end Create_Lock;
------------------
-- Acquire_Lock --
------------------
procedure Acquire_Lock (Lock : in out Lock_Type) is
use type Win32.DWORD;
Res : Win32.DWORD;
begin
Res := OSI.WaitForSingleObject (Lock_Table (Lock), OSI.Wait_Infinite);
if Res = OSI.WAIT_FAILED then
raise Lock_Error;
end if;
end Acquire_Lock;
------------------
-- Release_Lock --
------------------
procedure Release_Lock (Lock : in out Lock_Type) is
use type Win32.BOOL;
Res : Win32.BOOL;
begin
Res := OSI.ReleaseMutex (Lock_Table (Lock));
if Res = Win32.FALSE then
raise Lock_Error;
end if;
end Release_Lock;
end System.Global_Locks;
|
AdaCore/libadalang | Ada | 72 | ads | generic
type T is private;
package Foo is
procedure Bar;
end Foo;
|
zhmu/ananas | Ada | 6,570 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- System.Atomic_Operations.Integer_Arithmetic --
-- --
-- B o d y --
-- --
-- Copyright (C) 2019-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Atomic_Primitives; use System.Atomic_Primitives;
with System.Atomic_Operations.Exchange;
with Interfaces.C;
package body System.Atomic_Operations.Integer_Arithmetic is
package Exchange is new System.Atomic_Operations.Exchange (Atomic_Type);
----------------
-- Atomic_Add --
----------------
procedure Atomic_Add
(Item : aliased in out Atomic_Type;
Value : Atomic_Type)
is
Ignore : constant Atomic_Type := Atomic_Fetch_And_Add (Item, Value);
begin
null;
end Atomic_Add;
---------------------
-- Atomic_Subtract --
---------------------
procedure Atomic_Subtract
(Item : aliased in out Atomic_Type;
Value : Atomic_Type)
is
Ignore : constant Atomic_Type := Atomic_Fetch_And_Subtract (Item, Value);
begin
null;
end Atomic_Subtract;
--------------------------
-- Atomic_Fetch_And_Add --
--------------------------
function Atomic_Fetch_And_Add
(Item : aliased in out Atomic_Type;
Value : Atomic_Type) return Atomic_Type
is
pragma Warnings (Off);
function Atomic_Fetch_Add
(Ptr : System.Address; Val : Atomic_Type; Model : Mem_Model := Seq_Cst)
return Atomic_Type;
pragma Import (Intrinsic, Atomic_Fetch_Add, "__atomic_fetch_add");
pragma Warnings (On);
begin
-- Use the direct intrinsics when possible, and fallback to
-- compare-and-exchange otherwise.
if Atomic_Type'Base'Last = Atomic_Type'Last
and then Atomic_Type'Base'First = Atomic_Type'First
and then Atomic_Type'Last = 2**(Atomic_Type'Object_Size - 1) - 1
then
if Atomic_Type'Object_Size in 8 | 16 | 32 | 64 then
return Atomic_Fetch_Add (Item'Address, Value);
else
raise Program_Error;
end if;
else
declare
Old_Value : aliased Atomic_Type := Item;
New_Value : Atomic_Type := Old_Value + Value;
begin
-- Keep iterating until the exchange succeeds
while not Exchange.Atomic_Compare_And_Exchange
(Item, Old_Value, New_Value)
loop
New_Value := Old_Value + Value;
end loop;
return Old_Value;
end;
end if;
end Atomic_Fetch_And_Add;
-------------------------------
-- Atomic_Fetch_And_Subtract --
-------------------------------
function Atomic_Fetch_And_Subtract
(Item : aliased in out Atomic_Type;
Value : Atomic_Type) return Atomic_Type
is
pragma Warnings (Off);
function Atomic_Fetch_Sub
(Ptr : System.Address; Val : Atomic_Type; Model : Mem_Model := Seq_Cst)
return Atomic_Type;
pragma Import (Intrinsic, Atomic_Fetch_Sub, "__atomic_fetch_sub");
pragma Warnings (On);
begin
-- Use the direct intrinsics when possible, and fallback to
-- compare-and-exchange otherwise.
if Atomic_Type'Base'Last = Atomic_Type'Last
and then Atomic_Type'Base'First = Atomic_Type'First
and then Atomic_Type'Last = 2**(Atomic_Type'Object_Size - 1) - 1
then
if Atomic_Type'Object_Size in 8 | 16 | 32 | 64 then
return Atomic_Fetch_Sub (Item'Address, Value);
else
raise Program_Error;
end if;
else
declare
Old_Value : aliased Atomic_Type := Item;
New_Value : Atomic_Type := Old_Value - Value;
begin
-- Keep iterating until the exchange succeeds
while not Exchange.Atomic_Compare_And_Exchange
(Item, Old_Value, New_Value)
loop
New_Value := Old_Value - Value;
end loop;
return Old_Value;
end;
end if;
end Atomic_Fetch_And_Subtract;
------------------
-- Is_Lock_Free --
------------------
function Is_Lock_Free (Item : aliased Atomic_Type) return Boolean is
pragma Unreferenced (Item);
use type Interfaces.C.size_t;
begin
return Atomic_Always_Lock_Free (Atomic_Type'Object_Size / 8);
end Is_Lock_Free;
end System.Atomic_Operations.Integer_Arithmetic;
|
jscparker/math_packages | Ada | 20,467 | adb |
with Orthogonal_Polys;
with text_io; use text_io;
with Ada.Numerics.Generic_Elementary_Functions;
procedure opolys_tst_1 is -- fit data with a nth order polynomial
type Real is digits 15;
package Math is new Ada.Numerics.Generic_Elementary_Functions (Real);
function Sin (X : Real) return Real renames Math.Sin;
function Cos (X : Real) return Real renames Math.Cos;
type Points_Index is range 0..81;
-- This determines the maximum storage size of the Data array.
-- the Data array will start at Points_Index'First and end
-- at Points_Index'Last.
-- Least squares fitting can be done on any sub interval of
-- this array by setting the obvious parameters in the procedure
-- below.
type Data is array (Points_Index) of Real;
package LS is new Orthogonal_Polys (Real, Points_Index, Data, 0.0, 1.0);
-- "*", "+", "-", "/", "<", "**", "-");
use LS;
X_axis : Data;
Y_Data : Data;
Weights : constant Data := (others => 1.0);
F : constant Points_Index := Data'First;
L : constant Points_Index := Data'Last;
Poly_A, Poly_0, Poly_1, Poly_2 : Poly_Data; -- already initialized.
Norm01, Norm12, Norm02 : Real;
NormA2 : Real;
Delta_X : Real;
Order_Of_Deriv : Coeff_Index;
Q1, Q2, Q3, Q4, Max1, Max2, Max3, d1, d2, d3 : Real;
-- Variables for IO:
Answer : character;
X, Y : Real;
X0, Y0: Real;
X1, Y1 : Real;
Integral_At_0 : Real := 0.0;
Factorial : Real := 1.0;
E : Real;
Order : Real;
Degree_Of_Poly : Coeff_Index;
Best_Fit : Poly_Data;
Poly_Set : Polynomials;
C : Poly_Sum_Coeffs;
Derivatives : Derivative_List;
Deg_Of_Test_Poly_Plus : Coeff_Index;
X_Coeffs, X_Coeffs_2 : Powers_Of_X_Coeffs;
First : constant Points_Index := Points_Index'First;
Last : constant Points_Index := Points_Index'Last;
X_Start : constant Real := -Real (2.0);
X_end : constant Real := 2.0;
Degree_Of_Test_Poly : constant Coeff_Index := Coeff_Index'(5);
package rio is new Text_IO.FLoat_IO(Real);
use rio;
---------
-- Sum --
---------
function Sum (X : Real;
Coeffs : Powers_Of_X_Coeffs) return Real is
Result : Real := 0.0;
begin
Result := Coeffs(Coeff_Index'Last);
for I in reverse Coeff_Index'First..Coeff_Index'Last-1 loop
Result := Result * X;
Result := Result + Coeffs(I);
end loop;
return Result;
end Sum;
-----------
-- Pause --
-----------
procedure Pause (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13 : string := "") is
Continue : Character := ' ';
begin
new_line;
if S0 /= "" then put_line (S0); end if;
if S1 /= "" then put_line (S1); end if;
if S2 /= "" then put_line (S2); end if;
if S3 /= "" then put_line (S3); end if;
if S4 /= "" then put_line (S4); end if;
if S5 /= "" then put_line (S5); end if;
if S6 /= "" then put_line (S6); end if;
if S7 /= "" then put_line (S7); end if;
if S8 /= "" then put_line (S8); end if;
if S9 /= "" then put_line (S9); end if;
if S10 /= "" then put_line (S10); end if;
if S11 /= "" then put_line (S11); end if;
if S12 /= "" then put_line (S12); end if;
if S13 /= "" then put_line (S13); end if;
new_line;
begin
Put ("Press a key to continue: ");
Get_Immediate (Continue); New_Line;
exception
when others => null;
end;
end pause;
--------------------
-- Make_True_Poly --
--------------------
-- Make a polynomial of order Poly_Order. All of the
-- the coefficients of powers of X are 1.0.
-- Y = 15.0 + 14.0*X + 13.0*X**2 + 12.0*X**3 + ...
-- Below we fit least-squares polynomials to this data
-- in order to test package Least_Squares_Poly.
procedure Make_True_Poly
(Poly_Order : in Coeff_Index;
Coeffs : in Powers_Of_X_Coeffs;
X_Axis, Data1 : out Data;
X_Start,X_end : in Real)
is
X, Y : Real;
Delta_X : constant Real :=
(X_end - X_Start) / Real(Points_Index'Last - Points_Index'First);
begin
for I in Points_Index loop
X := X_Start + Delta_X * Real (I - Points_Index'First);
Y := Coeffs (Poly_Order); -- highest order coefficient
if Poly_Order > 0 then
for Power_Of_X in reverse Coeff_Index range 1..Poly_Order loop
Y := Y * X;
Y := Y + Coeffs (Power_Of_X - 1);
end loop;
end if;
X_axis(I) := X;
Data1 (I) := Y;
end loop;
end Make_True_Poly;
begin
Delta_X := (X_end - X_Start) / Real (X_axis'Length - 1);
for I in Points_Index loop
X_axis(I) := X_Start + Real (I - Points_Index'First) * Delta_X;
end loop;
-------------
-- Test 1. --
-------------
Pause ("Test 1. Check orthogonality of each polynomial with the three",
"preceding polys. Print out inner product... should be about 0.");
begin
Start_Gram_Schmidt_Poly_Recursion
(X_axis, Weights, Data'First, Data'Last, Poly_0, Poly_1, Poly_Set);
Norm01 := Inner_Product (Poly_0.Points, Poly_1.Points, F, L, Weights);
new_line;
put (Norm01);
new_line;
for I in Coeff_Index range 2..Coeff_Index'Last loop
Get_Next_Poly (Poly_0, Poly_1, Weights, poly_2, Poly_Set);
NormA2 := Inner_Product (Poly_A.Points, Poly_2.Points, F, L, Weights);
Norm02 := Inner_Product (Poly_0.Points, Poly_2.Points, F, L, Weights);
Norm12 := Inner_Product (Poly_1.Points, Poly_2.Points, F, L, Weights);
new_line;
--put (Norm2 / Poly_2.Squared);
put (NormA2); put(" "); put (Norm12); put (" "); put (Norm02);
Poly_A := Poly_0;
Poly_0 := Poly_1;
Poly_1 := Poly_2;
end loop;
exception
when others =>
put_line ("Some error.");
end;
Pause ("");
-------------
-- Test 2. --
-------------
Pause ("Test 2 compares various calculations of poly values at the X-axis",
"grid points. Four different methods are used.",
"0: Use the original polynomial - the values stored in Poly_Data.",
"1: Calculate the 0th order derivative using the derivative function.",
"2: Call Poly_Value (which also uses the Clenshaw summation formula).",
"3: Calculate the coefficients of powers of X, and then sum the polynomial",
" using these coefficients. The differences will be printed below.",
" ",
"The first column will print the differences between method 0 and method",
"1 above. The second column prints differences between 0 and 2 above.",
" ",
"The 3rd column prints the differences between method 0 above, and the",
"value calculated by summing over coefficients of powers of X.",
"You'll notice that method 3 is a terrible way to evaluate polynomials.");
Start_Gram_Schmidt_Poly_Recursion
(X_axis, Weights, Data'First, Data'Last, Poly_0, Poly_1, Poly_Set);
for I in Coeff_Index range 2..Coeff_Index'Last loop
Get_Next_Poly (Poly_0, Poly_1, Weights, poly_2, Poly_Set);
Poly_0 := Poly_1;
Poly_1 := Poly_2;
-- In what follows look at poly value at each grid point X_axis(I)
C := (others => +0.0);
C(I) := +1.0;
Get_Coeffs_Of_Powers_Of_X (X_Coeffs, C, Poly_Set);
Max1 := 0.0; Max2 := 0.0; Max3 := 0.0;
for J in Points_Index loop
X := X_axis(J);
Order_Of_Deriv := 0;
Poly_Derivatives (Derivatives, X, Order_Of_Deriv, C, Poly_Set);
Q1 := Derivatives(0);
Q2 := Poly_Value (X, C, Poly_Set);
Q3 := Sum (X, X_Coeffs);
Q4 := Poly_2.Points(J);
d1 := Q4 - Q1; d2 := Q4 - Q2; d3 := Q4 - Q3;
if Abs(d1) > Max1 then Max1 := Abs(d1); end if;
if Abs(d2) > Max2 then Max2 := Abs(d2); end if;
if Abs(d3) > Max3 then Max3 := Abs(d3); end if;
--new_line;
--put(d1); put(" "); put(d2); put(" "); put(d3);
end loop;
new_line;
put(Max1); put(" "); put(Max2); put(" "); put(Max3);
end loop;
-------------
-- Test 1 --
-------------
New_Line;
Pause ("New series of tests: create a test polynomial, calculate",
"series of least squares polynomial fits to it, and print the comparison.");
Pause ("Test 1: we create a polynomial of order 14, with coefficients",
"equal to 16.0, 15.0, 14.0 etc.: Y = 16.0 + 15.0*X + 14.0*X**2 + ...",
"In what follows, the user fits a",
"least squares polynomial of some given order to the data. As the user",
"raises the order of the polynomial fit, the mean square error between",
"the least-squares polynomial fit and the data should fall. It",
"should suddenly fall by a factor 10**23 at order 5 and higher.");
loop
begin
put ("Input order of polynomial fit (try 6 first, and exit):");
New_Line; Get (Order);
Degree_Of_Poly := Coeff_Index (Order);
X_Coeffs_2 := (others => 0.0);
for I in Coeff_Index range 0..Degree_Of_Test_Poly loop
X_Coeffs_2 (I) := 16.0 - Real(I);
end loop;
Make_True_Poly
(Poly_Order => Degree_Of_Test_Poly,
Coeffs => X_Coeffs_2,
X_axis => X_axis,
Data1 => Y_Data,
X_Start => X_Start,
X_end => X_end);
Poly_Fit (Y_Data, X_axis, Weights, First, Last, Degree_Of_Poly,
Best_Fit, C, Poly_Set, E);
put("Mean square error = "); put(E); New_Line;
put_line ("Exit loop? if Yes, enter a 'y', else a 'n' ");
get (Answer);
if Answer = 'y' then
Exit;
end if;
exception
when others =>
put_line ("Some error. Try again: ");
end;
end loop;
-------------
-- Test 2 --
-------------
pause ("Test 2: print the differences between the LS fit and the data.",
"This test compares the original data with the least squares fit",
"polynomial returned by procedure Poly_Fit.");
-- Print differences:
for I in Points_Index loop
New_Line; Put (Best_Fit.Points(I) - Y_Data(I)); put (" ");
end loop;
-------------
-- Test 3 --
-------------
pause;
pause("Test 3: print the differences between the Poly and the Data.",
"This is a test of the function Poly_Value, which uses Clenshaw's",
"formula to sum the least-squares polynomial. This is calculated",
"in a different way from the polynomial test previously. Also,",
"we redo the least-squares fit to make sure that the order of the",
"least-squares poly is greater than the order of the polynomial",
"used to generate the test data.");
if Degree_Of_Test_Poly < Coeff_Index'Last then
Deg_Of_Test_Poly_Plus := Degree_Of_Test_Poly + 1;
else
Deg_Of_Test_Poly_Plus := Degree_Of_Test_Poly;
end if;
Poly_Fit (Y_Data, X_axis, Weights, First, Last, Deg_Of_Test_Poly_Plus,
Best_Fit, C, Poly_Set, E);
for I in Points_Index loop
X := X_axis(I);
Y := Poly_Value (X, C, Poly_Set);
New_Line; Put (Y - Y_Data(I)); put (" ");
end loop;
------------
-- Test 4 --
------------
pause;
pause("Test 4: attempt to get the coefficients of the powers of X",
"in the least-squares fit polynomial. This is a process that",
"can result in a large loss of precision, underflows, overflows",
"etc. if the degree of the polynomial is high. In the present",
"case, a 14th order poly, things work out OK if you sample the",
"poly over a sufficiently large interval in X.");
Get_Coeffs_Of_Powers_Of_X (X_Coeffs, C, Poly_Set);
New_Line;
for I in Coeff_Index loop
New_Line; put (X_Coeffs(I));
end loop;
-------------
-- Test 5 --
-------------
pause;
pause("Test 5: take the first derivative of the polynomial,",
"and compare with the predictions of the analytical",
"derivative.");
X_Coeffs_2 := (others => 0.0);
Y_Data := (others => 0.0);
if Degree_Of_Test_Poly > 0 then
for I in Coeff_Index range 0..Degree_Of_Test_Poly-1 loop
X_Coeffs_2 (I) := Real(I+1) * (16.0 - Real(I+1));
end loop;
Make_True_Poly (Poly_Order => Degree_Of_Test_Poly-1,
Coeffs => X_Coeffs_2,
X_axis => X_axis,
Data1 => Y_Data,
X_Start => X_Start,
X_end => X_end);
end if;
for I in Points_Index loop
X := X_axis(I);
Poly_Derivatives (Derivatives, X, 1, C, Poly_Set);
New_Line; Put (Derivatives(1) - Y_Data(I)); put (" ");
end loop;
-------------
-- Test 6 --
-------------
pause;
pause("Test 6: take the second derivative of the polynomial,",
"and compare with the predictions of the analytical",
"derivative.");
X_Coeffs_2 := (others => 0.0);
Y_Data := (others => 0.0);
if Degree_Of_Test_Poly > 1 then
for I in Coeff_Index range 0..Degree_Of_Test_Poly-2 loop
X_Coeffs_2 (I) := Real(I+2) * Real(I+1) * (16.0 - Real(I+2));
end loop;
Make_True_Poly
(Poly_Order => Degree_Of_Test_Poly-2,
Coeffs => X_Coeffs_2,
X_axis => X_axis,
Data1 => Y_Data,
X_Start => X_Start,
X_end => X_end);
end if;
for I in Points_Index loop
X := X_axis(I);
Poly_Derivatives (Derivatives, X, 2, C, Poly_Set);
New_Line; Put (Derivatives(2) - Y_Data(I)); put (" ");
end loop;
-------------
-- Test 7 --
-------------
pause;
pause("Test 7: take the third derivative of the polynomial,",
"and compare with the predictions of the analytical",
"derivative.");
X_Coeffs_2 := (others => 0.0);
Y_Data := (others => 0.0);
if Degree_Of_Test_Poly > 2 then
for I in Coeff_Index range 0..Degree_Of_Test_Poly-3 loop
X_Coeffs_2 (I) :=
Real(I+3) * Real(I+2) * Real(I+1) * (16.0 - Real(I+3));
end loop;
Make_True_Poly
(Poly_Order => Degree_Of_Test_Poly-3,
Coeffs => X_Coeffs_2,
X_axis => X_axis,
Data1 => Y_Data,
X_Start => X_Start,
X_end => X_end);
end if;
for I in Points_Index loop
X := X_axis(I);
Poly_Derivatives (Derivatives, X, 3, C, Poly_Set);
New_Line; Put (Derivatives(3) - Y_Data(I)); put (" ");
end loop;
-------------
-- Test 8 --
-------------
pause;
pause("Test 8: check that the Derivative routine also gets the",
"correct zeroth order derivative:",
"Below are the differences between the predictions of procedure",
"Poly_Derivatives, and the least-squares fit polynomial.");
for I in Points_Index loop
X := X_axis(I);
Poly_Derivatives (Derivatives, X, 2, C, Poly_Set);
New_Line; Put (Derivatives(0) - Best_Fit.Points(I)); put (" ");
end loop;
-------------
-- Test 9 --
-------------
pause;
pause("Test 9: check that the Derivative routine is able to correctly",
"calculate the coefficients of powers of X of the polynomial. We",
"use the fact that the coefficient of the m-th power of X equals",
"m-th derivative of the least squares fit polynomial evaluated at",
"X = 0, and divided by m!.");
Factorial := 1.0;
Poly_Derivatives (Derivatives, 0.0, Coeff_Index'Last, C, Poly_Set);
for m in Coeff_Index loop
if m > Coeff_Index'First then
Factorial := Factorial * Real(m);
end if;
New_Line; put (Derivatives(m) / Factorial);
end loop;
-------------
-- Test 10 --
-------------
pause;
pause("Test 10: take the indefinite Integral of the polynomial,",
"and compare with the predictions of the analytical",
"integral.");
X_Coeffs_2 := (others => 0.0);
Y_Data := (others => 0.0);
if Degree_Of_Test_Poly > 0 then
for I in reverse Coeff_Index range 0..Degree_Of_Test_Poly loop
X_Coeffs_2 (I+1) := (16.0 - Real(I)) / Real(I+1);
end loop;
X_Coeffs_2 (0) := (0.0);
Make_True_Poly (Poly_Order => Degree_Of_Test_Poly+1,
Coeffs => X_Coeffs_2,
X_axis => X_axis,
Data1 => Y_Data,
X_Start => X_Start,
X_end => X_end);
end if;
Integral_At_0 := Poly_Integral (0.0, C, Poly_Set);
for I in Points_Index loop
X := X_axis(I);
Y := Poly_Integral (X, C, Poly_Set) - Integral_At_0;
New_Line; Put (Y - Y_Data(I)); put (" ");
end loop;
-------------
-- Test 1 --
-------------
New_Line;
Pause ("New series of tests: the previous series was",
"designed to discover gross errors, but it didn't say much about",
"the numerical accuracy of the fits, because the error may have",
"been in the calculation of the original data. In the following",
"series of tests we generate data with Sin's and Cos's so that we",
"can reliably measure numerical error in the least squares fits");
Delta_X := 16.0 / Real (X_axis'Length - 1);
for I in Points_Index loop
X_axis(I) := Real (I - Points_Index'First) * Delta_X;
end loop;
for I in Points_Index loop
Y_Data(I) := Sin (X_axis(I));
end loop;
Poly_Fit (Y_Data, X_axis, Weights, First, Last, 36,
Best_Fit, C, Poly_Set, E);
pause("Test 1: Make sinusoidal data, fit a high order poly to it,",
"and print the difference between the fit and the original data:");
for I in Points_Index loop
X := X_axis(I);
Y := Poly_Value (X, C, Poly_Set);
new_line; Put (Y - Y_Data(I)); put (" ");
end loop;
pause;
pause("Test 2: Make sinusoidal data, fit a high order poly to it,",
"and print the difference between the 1st derivative of the fit",
"and the 1st derivative of the original data:");
for I in Points_Index loop
X := X_axis(I);
Poly_Derivatives (Derivatives, X, 1, C, Poly_Set);
new_line; Put (Derivatives(1) - Cos(X_axis(I))); put (" ");
end loop;
pause;
pause("Test 3: Make sinusoidal data, fit a high order poly to it,",
"and print the difference between the 2nd derivative of the fit",
"and the 2nd derivative of the original data:");
for I in Points_Index loop
X := X_axis(I);
Poly_Derivatives (Derivatives, X, 2, C, Poly_Set);
new_line; Put (Derivatives(2) + Sin(X_axis(I))); put (" ");
end loop;
pause;
pause("Test 4: Make sinusoidal data, fit a high order poly to it,",
"and print the difference between the 3rd derivative of the fit",
"and the 3rd derivative of the original data:");
for I in Points_Index loop
X := X_axis(I);
Poly_Derivatives (Derivatives, X, 3, C, Poly_Set);
new_line; Put (Derivatives(3) + Cos(X_axis(I))); put (" ");
end loop;
pause;
pause("Test 5: Make sinusoidal data, fit a high order poly to it,",
"and print the difference between the integral of the fit",
"and the integral of the original data:");
Integral_At_0 := Poly_Integral (0.0, C, Poly_Set);
for I in Points_Index'first+1 .. Points_Index'last loop
X0 := X_axis(I-1);
Y0 := Poly_Integral (X0, C, Poly_Set);
X1 := X_axis(I);
Y1 := Poly_Integral (X1, C, Poly_Set);
new_line; put (Y1 - Y0 - (-Cos (X1) + Cos (X0)) ); put (" ");
end loop;
end opolys_tst_1;
|
AdaCore/gpr | Ada | 49 | adb | with Pkg;
procedure Main is
begin
null;
end;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 18,799 | ads | -- This spec has been automatically generated from STM32F303xE.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.EXTI is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- IMR1_MR array element
subtype IMR1_MR_Element is STM32_SVD.Bit;
-- IMR1_MR array
type IMR1_MR_Field_Array is array (0 .. 31) of IMR1_MR_Element
with Component_Size => 1, Size => 32;
-- Interrupt mask register
type IMR1_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt32;
when True =>
-- MR as an array
Arr : IMR1_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for IMR1_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- EMR1_MR array element
subtype EMR1_MR_Element is STM32_SVD.Bit;
-- EMR1_MR array
type EMR1_MR_Field_Array is array (0 .. 31) of EMR1_MR_Element
with Component_Size => 1, Size => 32;
-- Event mask register
type EMR1_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt32;
when True =>
-- MR as an array
Arr : EMR1_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for EMR1_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- RTSR1_TR array element
subtype RTSR1_TR_Element is STM32_SVD.Bit;
-- RTSR1_TR array
type RTSR1_TR_Field_Array is array (0 .. 22) of RTSR1_TR_Element
with Component_Size => 1, Size => 23;
-- Type definition for RTSR1_TR
type RTSR1_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt23;
when True =>
-- TR as an array
Arr : RTSR1_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for RTSR1_TR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- RTSR1_TR array
type RTSR1_TR_Field_Array_1 is array (29 .. 31) of RTSR1_TR_Element
with Component_Size => 1, Size => 3;
-- Type definition for RTSR1_TR
type RTSR1_TR_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt3;
when True =>
-- TR as an array
Arr : RTSR1_TR_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for RTSR1_TR_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Rising Trigger selection register
type RTSR1_Register is record
-- Rising trigger event configuration of line 0
TR : RTSR1_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Rising trigger event configuration of line 29
TR_1 : RTSR1_TR_Field_1 := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTSR1_Register use record
TR at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
TR_1 at 0 range 29 .. 31;
end record;
-- FTSR1_TR array element
subtype FTSR1_TR_Element is STM32_SVD.Bit;
-- FTSR1_TR array
type FTSR1_TR_Field_Array is array (0 .. 22) of FTSR1_TR_Element
with Component_Size => 1, Size => 23;
-- Type definition for FTSR1_TR
type FTSR1_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt23;
when True =>
-- TR as an array
Arr : FTSR1_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for FTSR1_TR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- FTSR1_TR array
type FTSR1_TR_Field_Array_1 is array (29 .. 31) of FTSR1_TR_Element
with Component_Size => 1, Size => 3;
-- Type definition for FTSR1_TR
type FTSR1_TR_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt3;
when True =>
-- TR as an array
Arr : FTSR1_TR_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for FTSR1_TR_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Falling Trigger selection register
type FTSR1_Register is record
-- Falling trigger event configuration of line 0
TR : FTSR1_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Falling trigger event configuration of line 29
TR_1 : FTSR1_TR_Field_1 := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FTSR1_Register use record
TR at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
TR_1 at 0 range 29 .. 31;
end record;
-- SWIER1_SWIER array element
subtype SWIER1_SWIER_Element is STM32_SVD.Bit;
-- SWIER1_SWIER array
type SWIER1_SWIER_Field_Array is array (0 .. 22) of SWIER1_SWIER_Element
with Component_Size => 1, Size => 23;
-- Type definition for SWIER1_SWIER
type SWIER1_SWIER_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWIER as a value
Val : STM32_SVD.UInt23;
when True =>
-- SWIER as an array
Arr : SWIER1_SWIER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for SWIER1_SWIER_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- SWIER1_SWIER array
type SWIER1_SWIER_Field_Array_1 is array (29 .. 31)
of SWIER1_SWIER_Element
with Component_Size => 1, Size => 3;
-- Type definition for SWIER1_SWIER
type SWIER1_SWIER_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWIER as a value
Val : STM32_SVD.UInt3;
when True =>
-- SWIER as an array
Arr : SWIER1_SWIER_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for SWIER1_SWIER_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Software interrupt event register
type SWIER1_Register is record
-- Software Interrupt on line 0
SWIER : SWIER1_SWIER_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Software Interrupt on line 29
SWIER_1 : SWIER1_SWIER_Field_1 :=
(As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SWIER1_Register use record
SWIER at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
SWIER_1 at 0 range 29 .. 31;
end record;
-- PR1_PR array element
subtype PR1_PR_Element is STM32_SVD.Bit;
-- PR1_PR array
type PR1_PR_Field_Array is array (0 .. 22) of PR1_PR_Element
with Component_Size => 1, Size => 23;
-- Type definition for PR1_PR
type PR1_PR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PR as a value
Val : STM32_SVD.UInt23;
when True =>
-- PR as an array
Arr : PR1_PR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for PR1_PR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- PR1_PR array
type PR1_PR_Field_Array_1 is array (29 .. 31) of PR1_PR_Element
with Component_Size => 1, Size => 3;
-- Type definition for PR1_PR
type PR1_PR_Field_1
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PR as a value
Val : STM32_SVD.UInt3;
when True =>
-- PR as an array
Arr : PR1_PR_Field_Array_1;
end case;
end record
with Unchecked_Union, Size => 3;
for PR1_PR_Field_1 use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Pending register
type PR1_Register is record
-- Pending bit 0
PR : PR1_PR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_28 : STM32_SVD.UInt6 := 16#0#;
-- Pending bit 29
PR_1 : PR1_PR_Field_1 := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PR1_Register use record
PR at 0 range 0 .. 22;
Reserved_23_28 at 0 range 23 .. 28;
PR_1 at 0 range 29 .. 31;
end record;
-- IMR2_MR array element
subtype IMR2_MR_Element is STM32_SVD.Bit;
-- IMR2_MR array
type IMR2_MR_Field_Array is array (32 .. 35) of IMR2_MR_Element
with Component_Size => 1, Size => 4;
-- Type definition for IMR2_MR
type IMR2_MR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt4;
when True =>
-- MR as an array
Arr : IMR2_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for IMR2_MR_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- Interrupt mask register
type IMR2_Register is record
-- Interrupt Mask on external/internal line 32
MR : IMR2_MR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#FFFFFFF#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IMR2_Register use record
MR at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- EMR2_MR array element
subtype EMR2_MR_Element is STM32_SVD.Bit;
-- EMR2_MR array
type EMR2_MR_Field_Array is array (32 .. 35) of EMR2_MR_Element
with Component_Size => 1, Size => 4;
-- Type definition for EMR2_MR
type EMR2_MR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt4;
when True =>
-- MR as an array
Arr : EMR2_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for EMR2_MR_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- Event mask register
type EMR2_Register is record
-- Event mask on external/internal line 32
MR : EMR2_MR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EMR2_Register use record
MR at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- RTSR2_TR array element
subtype RTSR2_TR_Element is STM32_SVD.Bit;
-- RTSR2_TR array
type RTSR2_TR_Field_Array is array (32 .. 33) of RTSR2_TR_Element
with Component_Size => 1, Size => 2;
-- Type definition for RTSR2_TR
type RTSR2_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt2;
when True =>
-- TR as an array
Arr : RTSR2_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for RTSR2_TR_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Rising Trigger selection register
type RTSR2_Register is record
-- Rising trigger event configuration bit of line 32
TR : RTSR2_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTSR2_Register use record
TR at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- FTSR2_TR array element
subtype FTSR2_TR_Element is STM32_SVD.Bit;
-- FTSR2_TR array
type FTSR2_TR_Field_Array is array (32 .. 33) of FTSR2_TR_Element
with Component_Size => 1, Size => 2;
-- Type definition for FTSR2_TR
type FTSR2_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt2;
when True =>
-- TR as an array
Arr : FTSR2_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for FTSR2_TR_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Falling Trigger selection register
type FTSR2_Register is record
-- Falling trigger event configuration bit of line 32
TR : FTSR2_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FTSR2_Register use record
TR at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- SWIER2_SWIER array element
subtype SWIER2_SWIER_Element is STM32_SVD.Bit;
-- SWIER2_SWIER array
type SWIER2_SWIER_Field_Array is array (32 .. 33) of SWIER2_SWIER_Element
with Component_Size => 1, Size => 2;
-- Type definition for SWIER2_SWIER
type SWIER2_SWIER_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWIER as a value
Val : STM32_SVD.UInt2;
when True =>
-- SWIER as an array
Arr : SWIER2_SWIER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for SWIER2_SWIER_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Software interrupt event register
type SWIER2_Register is record
-- Software interrupt on line 32
SWIER : SWIER2_SWIER_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SWIER2_Register use record
SWIER at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- PR2_PR array element
subtype PR2_PR_Element is STM32_SVD.Bit;
-- PR2_PR array
type PR2_PR_Field_Array is array (32 .. 33) of PR2_PR_Element
with Component_Size => 1, Size => 2;
-- Type definition for PR2_PR
type PR2_PR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PR as a value
Val : STM32_SVD.UInt2;
when True =>
-- PR as an array
Arr : PR2_PR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for PR2_PR_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Pending register
type PR2_Register is record
-- Pending bit on line 32
PR : PR2_PR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PR2_Register use record
PR at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- External interrupt/event controller
type EXTI_Peripheral is record
-- Interrupt mask register
IMR1 : aliased IMR1_Register;
-- Event mask register
EMR1 : aliased EMR1_Register;
-- Rising Trigger selection register
RTSR1 : aliased RTSR1_Register;
-- Falling Trigger selection register
FTSR1 : aliased FTSR1_Register;
-- Software interrupt event register
SWIER1 : aliased SWIER1_Register;
-- Pending register
PR1 : aliased PR1_Register;
-- Interrupt mask register
IMR2 : aliased IMR2_Register;
-- Event mask register
EMR2 : aliased EMR2_Register;
-- Rising Trigger selection register
RTSR2 : aliased RTSR2_Register;
-- Falling Trigger selection register
FTSR2 : aliased FTSR2_Register;
-- Software interrupt event register
SWIER2 : aliased SWIER2_Register;
-- Pending register
PR2 : aliased PR2_Register;
end record
with Volatile;
for EXTI_Peripheral use record
IMR1 at 16#0# range 0 .. 31;
EMR1 at 16#4# range 0 .. 31;
RTSR1 at 16#8# range 0 .. 31;
FTSR1 at 16#C# range 0 .. 31;
SWIER1 at 16#10# range 0 .. 31;
PR1 at 16#14# range 0 .. 31;
IMR2 at 16#18# range 0 .. 31;
EMR2 at 16#1C# range 0 .. 31;
RTSR2 at 16#20# range 0 .. 31;
FTSR2 at 16#24# range 0 .. 31;
SWIER2 at 16#28# range 0 .. 31;
PR2 at 16#2C# range 0 .. 31;
end record;
-- External interrupt/event controller
EXTI_Periph : aliased EXTI_Peripheral
with Import, Address => System'To_Address (16#40010400#);
end STM32_SVD.EXTI;
|
reznikmm/matreshka | Ada | 3,649 | 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.Dc_Creator_Elements is
pragma Preelaborate;
type ODF_Dc_Creator is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Dc_Creator_Access is
access all ODF_Dc_Creator'Class
with Storage_Size => 0;
end ODF.DOM.Dc_Creator_Elements;
|
reznikmm/matreshka | Ada | 4,056 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A merge node is a control node that brings together multiple alternate
-- flows. It is not used to synchronize concurrent flows but to accept one
-- among several alternate flows.
------------------------------------------------------------------------------
with AMF.UML.Control_Nodes;
package AMF.UML.Merge_Nodes is
pragma Preelaborate;
type UML_Merge_Node is limited interface
and AMF.UML.Control_Nodes.UML_Control_Node;
type UML_Merge_Node_Access is
access all UML_Merge_Node'Class;
for UML_Merge_Node_Access'Storage_Size use 0;
end AMF.UML.Merge_Nodes;
|
reznikmm/matreshka | Ada | 3,448 | 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$
------------------------------------------------------------------------------
package AMF.DG.Path_Command_Collections is
pragma Preelaborate;
end AMF.DG.Path_Command_Collections;
|
AdaCore/gpr | Ada | 420 | adb | with Test_GPR;
with Test_Assert;
with GPR2.Project.Tree;
function Test return Integer is
package TGPR renames Test_GPR;
package A renames Test_Assert;
Tree : GPR2.Project.Tree.Object;
begin
TGPR.Load_With_No_Errors (Tree, "./data/main2.gpr");
TGPR.Assert_Variable
(View => Tree.Root_Project,
Variable => "Variable",
Value => "main2-shared2");
return A.Report;
end Test;
|
sparre/Command-Line-Parser-Generator | Ada | 134 | ads | with Subtype_Chains_2;
package Subtype_Chains_3 is
use Subtype_Chains_2;
procedure Run (Even : in Two);
end Subtype_Chains_3;
|
sungyeon/drake | Ada | 13,583 | adb | with Ada.Exception_Identification.From_Here;
with System.Debug; -- assertions
with C.winbase;
with C.windef;
with C.winerror;
package body System.Synchronous_Objects is
use Ada.Exception_Identification.From_Here;
use type C.windef.DWORD;
use type C.windef.WINBOOL;
function atomic_load (
ptr : not null access constant Counter;
memorder : Integer := C.ATOMIC_ACQUIRE)
return Counter
with Import, Convention => Intrinsic, External_Name => "__atomic_load_4";
procedure atomic_store (
ptr : not null access Counter;
val : Counter;
memorder : Integer := C.ATOMIC_RELEASE)
with Import,
Convention => Intrinsic, External_Name => "__atomic_store_4";
procedure atomic_add_fetch (
ptr : not null access Counter;
val : Counter;
memorder : Integer := C.ATOMIC_ACQ_REL)
with Import,
Convention => Intrinsic, External_Name => "__atomic_add_fetch_4";
function atomic_sub_fetch (
ptr : not null access Counter;
val : Counter;
memorder : Integer := C.ATOMIC_ACQ_REL)
return Counter
with Import,
Convention => Intrinsic, External_Name => "__atomic_sub_fetch_4";
function atomic_compare_exchange (
ptr : not null access Counter;
expected : not null access Counter;
desired : Counter;
weak : Boolean := False;
success_memorder : Integer := C.ATOMIC_ACQ_REL;
failure_memorder : Integer := C.ATOMIC_ACQUIRE)
return Boolean
with Import,
Convention => Intrinsic,
External_Name => "__atomic_compare_exchange_4";
-- mutex
procedure Initialize (Object : in out Mutex) is
begin
Object.Handle := C.winbase.CreateMutex (null, 0, null);
pragma Check (Debug,
Check =>
Address (Object.Handle) /= Null_Address
or else Debug.Runtime_Error ("CreateMutex failed"));
end Initialize;
procedure Finalize (Object : in out Mutex) is
Success : C.windef.WINBOOL;
begin
Success := C.winbase.CloseHandle (Object.Handle);
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("CloseHandle failed"));
end Finalize;
procedure Enter (Object : in out Mutex) is
begin
if C.winbase.WaitForSingleObject (Object.Handle, C.winbase.INFINITE) /=
C.winbase.WAIT_OBJECT_0
then
Raise_Exception (Tasking_Error'Identity);
end if;
end Enter;
procedure Leave (Object : in out Mutex) is
Success : C.windef.WINBOOL;
begin
Success := C.winbase.ReleaseMutex (Object.Handle);
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("ReleaseMutex failed"));
end Leave;
-- condition variable
procedure Initialize (Object : in out Condition_Variable) is
begin
atomic_store (Object.Waiters'Access, 0);
Initialize (Object.Event, Manual => True);
Initialize (Object.Reset_Barrier, Manual => True);
end Initialize;
procedure Finalize (Object : in out Condition_Variable) is
begin
Finalize (Object.Event);
Finalize (Object.Reset_Barrier);
end Finalize;
procedure Notify_All (Object : in out Condition_Variable) is
begin
Reset (Object.Reset_Barrier);
Set (Object.Event);
end Notify_All;
procedure Wait (
Object : in out Condition_Variable;
Mutex : in out Synchronous_Objects.Mutex)
is
Signaled : C.windef.DWORD;
begin
atomic_add_fetch (Object.Waiters'Access, 1);
Signaled :=
C.winbase.SignalObjectAndWait (
hObjectToSignal => Mutex.Handle,
hObjectToWaitOn => Object.Event.Handle,
dwMilliseconds => C.winbase.INFINITE,
bAlertable => 0);
pragma Check (Debug,
Check =>
Signaled = C.winbase.WAIT_OBJECT_0
or else Debug.Runtime_Error ("SignalObjectAndWait failed"));
if atomic_sub_fetch (Object.Waiters'Access, 1) = 0 then
Reset (Object.Event);
Set (Object.Reset_Barrier);
else
Wait (Object.Reset_Barrier);
end if;
Enter (Mutex);
end Wait;
-- queue
procedure Initialize (
Object : in out Queue;
Mutex : not null Mutex_Access) is
begin
Object.Mutex := Mutex;
Initialize (Object.Event, Manual => False);
Object.Head := null;
Object.Tail := null;
Object.Filter := null;
Object.Waiting := False;
Object.Canceled := False;
end Initialize;
procedure Finalize (Object : in out Queue) is
begin
Finalize (Object.Event);
end Finalize;
function Count (
Object : Queue;
Params : Address;
Filter : Queue_Filter)
return Natural
is
Result : Natural;
begin
Enter (Object.Mutex.all);
Result := Unsynchronized_Count (Object, Params, Filter);
Leave (Object.Mutex.all);
return Result;
end Count;
function Unsynchronized_Count (
Object : Queue;
Params : Address;
Filter : Queue_Filter)
return Natural
is
Result : Natural := 0;
I : Queue_Node_Access := Object.Head;
begin
while I /= null loop
if Filter = null or else Filter (I, Params) then
Result := Result + 1;
end if;
I := I.Next;
end loop;
return Result;
end Unsynchronized_Count;
function Canceled (Object : Queue) return Boolean is
begin
return Object.Canceled;
end Canceled;
procedure Cancel (
Object : in out Queue;
Cancel_Node : access procedure (X : in out Queue_Node_Access)) is
begin
Enter (Object.Mutex.all);
Object.Canceled := True;
if Cancel_Node /= null then
while Object.Head /= null loop
declare
Next : constant Queue_Node_Access := Object.Head.Next;
begin
Cancel_Node (Object.Head);
Object.Head := Next;
end;
end loop;
end if;
Leave (Object.Mutex.all);
end Cancel;
procedure Unsynchronized_Prepend (
Object : in out Queue;
Item : not null Queue_Node_Access;
Canceled : out Boolean) is
begin
Canceled := Object.Canceled;
if not Canceled then
Item.Next := Object.Head;
Object.Head := Item;
if Object.Tail = null then
Object.Tail := Item;
end if;
Notify_All (Object, Item);
end if;
end Unsynchronized_Prepend;
procedure Add (
Object : in out Queue;
Item : not null Queue_Node_Access;
Canceled : out Boolean) is
begin
Enter (Object.Mutex.all);
Canceled := Object.Canceled;
if not Canceled then
if Object.Head = null then
Object.Head := Item;
else
Object.Tail.Next := Item;
end if;
Object.Tail := Item;
Item.Next := null;
Notify_All (Object, Item);
end if;
Leave (Object.Mutex.all);
end Add;
procedure Take (
Object : in out Queue;
Item : out Queue_Node_Access;
Params : Address;
Filter : Queue_Filter) is
begin
Enter (Object.Mutex.all);
Unsynchronized_Take (Object, Item, Params, Filter);
Leave (Object.Mutex.all);
end Take;
procedure Unsynchronized_Take (
Object : in out Queue;
Item : out Queue_Node_Access;
Params : Address;
Filter : Queue_Filter)
is
Previous : Queue_Node_Access := null;
I : Queue_Node_Access := Object.Head;
begin
Take_No_Sync (Object, Item, Params, Filter, Previous, I);
end Unsynchronized_Take;
procedure Take_No_Sync (
Object : in out Queue;
Item : out Queue_Node_Access;
Params : Address;
Filter : Queue_Filter;
Previous : in out Queue_Node_Access;
Current : in out Queue_Node_Access) is
begin
Item := null;
Search : while Current /= null loop
if Filter = null or else Filter (Current, Params) then
if Previous /= null then
Previous.Next := Current.Next;
else
Object.Head := Current.Next;
end if;
if Current = Object.Tail then
Object.Tail := Previous;
end if;
Item := Current;
exit Search;
end if;
Previous := Current;
Current := Current.Next;
end loop Search;
end Take_No_Sync;
procedure Notify_All (
Object : in out Queue;
Item : not null Queue_Node_Access) is
begin
if Object.Waiting
and then (
Object.Filter = null or else Object.Filter (Item, Object.Params))
then
Set (Object.Event);
end if;
end Notify_All;
-- event
procedure Initialize (Object : in out Event; Manual : Boolean := True) is
begin
Object.Handle :=
C.winbase.CreateEvent (null, Boolean'Pos (Manual), 0, null);
end Initialize;
procedure Finalize (Object : in out Event) is
Success : C.windef.WINBOOL;
begin
Success := C.winbase.CloseHandle (Object.Handle);
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("CloseHandle failed"));
end Finalize;
function Get (Object : Event) return Boolean is
Signaled : C.windef.DWORD;
begin
Signaled := C.winbase.WaitForSingleObject (Object.Handle, 0);
pragma Check (Debug,
Check =>
Signaled = C.winbase.WAIT_OBJECT_0
or else Signaled = C.winerror.WAIT_TIMEOUT
or else Debug.Runtime_Error ("WaitForSingleObject failed"));
return Signaled = C.winbase.WAIT_OBJECT_0;
end Get;
procedure Set (Object : in out Event) is
Success : C.windef.WINBOOL;
begin
Success := C.winbase.SetEvent (Object.Handle);
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("SetEvent failed"));
end Set;
procedure Reset (Object : in out Event) is
Success : C.windef.WINBOOL;
begin
Success := C.winbase.ResetEvent (Object.Handle);
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("ResetEvent failed"));
end Reset;
procedure Wait (
Object : in out Event)
is
Signaled : C.windef.DWORD;
begin
Signaled :=
C.winbase.WaitForSingleObject (Object.Handle, C.winbase.INFINITE);
pragma Check (Debug,
Check =>
Signaled = C.winbase.WAIT_OBJECT_0
or else Debug.Runtime_Error ("WaitForSingleObject failed"));
end Wait;
procedure Wait (
Object : in out Event;
Timeout : Duration;
Value : out Boolean)
is
Milliseconds : constant C.windef.DWORD :=
C.windef.DWORD (Duration'Max (0.0, Timeout) * 1_000);
Signaled : C.windef.DWORD;
begin
Signaled := C.winbase.WaitForSingleObject (Object.Handle, Milliseconds);
pragma Check (Debug,
Check =>
Signaled = C.winbase.WAIT_OBJECT_0
or else Signaled = C.winerror.WAIT_TIMEOUT
or else Debug.Runtime_Error ("WaitForSingleObject failed"));
Value := Signaled = C.winbase.WAIT_OBJECT_0;
end Wait;
function Handle (Object : Event) return C.winnt.HANDLE is
begin
return Object.Handle;
end Handle;
-- multi-read/exclusive-write lock for protected
procedure Initialize (Object : in out RW_Lock) is
begin
atomic_store (Object.State'Access, 0);
Initialize (Object.Reader_Barrier, Manual => True);
Initialize (Object.Writer_Barrier, Manual => False);
end Initialize;
procedure Finalize (Object : in out RW_Lock) is
begin
Finalize (Object.Reader_Barrier);
Finalize (Object.Writer_Barrier);
end Finalize;
procedure Enter_Reading (Object : in out RW_Lock) is
begin
loop
declare
Current : constant Counter := atomic_load (Object.State'Access);
begin
if Current >= 0 then
declare
Expected : aliased Counter := Current;
begin
exit when atomic_compare_exchange (
Object.State'Access,
Expected'Access,
Current + 1);
end;
else
Wait (Object.Reader_Barrier);
end if;
end;
end loop;
end Enter_Reading;
procedure Enter_Writing (Object : in out RW_Lock) is
begin
loop
declare
Expected : aliased Counter := 0;
begin
exit when atomic_compare_exchange (
Object.State'Access,
Expected'Access,
-999);
end;
Wait (Object.Writer_Barrier);
end loop;
Reset (Object.Reader_Barrier);
end Enter_Writing;
procedure Leave (Object : in out RW_Lock) is
Expected : aliased Counter := -999;
begin
if atomic_compare_exchange (Object.State'Access, Expected'Access, 0) then
-- writer
Set (Object.Reader_Barrier);
Set (Object.Writer_Barrier);
else
-- reader
if atomic_sub_fetch (Object.State'Access, 1) = 0 then
Reset (Object.Reader_Barrier);
Set (Object.Writer_Barrier);
end if;
end if;
end Leave;
end System.Synchronous_Objects;
|
AdaCore/training_material | Ada | 3,104 | ads | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2009, AdaCore --
-- --
-- Labs 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 2 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, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Display; use Display;
with Display.Basic; use Display.Basic;
package Solar_System is
-- define type Bodies_Enum as an enumeration of Sun, Earth, Moon, Satellite
type Bodies_Enum is
(Sun, Earth, Moon, Satellite, Comet, Black_Hole, Asteroid_1, Asteroid_2);
procedure Init_Body
(B : Bodies_Enum;
Radius : Float;
Color : RGBA_T;
Distance : Float;
Speed : Float;
Turns_Around : Bodies_Enum;
Angle : Float := 0.0;
Tail : Boolean := False;
Visible : Boolean := True);
private
type Position is record
X : Float := 0.0;
Y : Float := 0.0;
end record;
type Tail_Length is new Integer range 1 .. 10;
type T_Tail is array (Tail_Length) of Position;
type Body_Type is record
Pos : Position;
Distance : Float;
Speed : Float;
Angle : Float;
Radius : Float;
Color : RGBA_T;
Visible : Boolean := True;
Turns_Around : Bodies_Enum;
With_Tail : Boolean := False;
Tail : T_Tail := (others => (0.0, 0.0));
end record;
protected Dispatch_Tasks is
procedure Get_Next_Body (B : out Bodies_Enum);
private
Current : Bodies_Enum := Bodies_Enum'First;
end Dispatch_Tasks;
task type T_Move_Body;
type Task_Array is array (Bodies_Enum) of T_Move_Body;
Tasks : Task_Array;
protected type P_Body is
function Get_Data return Body_Type;
procedure Set_Data (B : Body_Type);
private
Data : Body_Type;
end P_Body;
type Bodies_Array is array (Bodies_Enum) of P_Body;
Bodies : Bodies_Array;
procedure Move (Body_To_Move : in out Body_Type; Turns_Around : Body_Type);
end Solar_System;
|
ytomino/vampire | Ada | 1,982 | ads | -- The Village of Vampire by YT, このソースコードはNYSLです
with Serialization;
package Vampire.Villages.Village_IO is
Yaml_Type : constant String := "vampire-village";
procedure IO (
Serializer : not null access Serialization.Serializer;
Name : in String; People : in out Villages.People.Vector);
procedure IO (
Serializer : not null access Serialization.Serializer;
Village : in out Village_Type;
Info_Only : in Boolean := False);
package Requested_Role_IO is new Serialization.IO_Enumeration (Requested_Role);
package Person_Role_IO is new Serialization.IO_Enumeration (Person_Role);
package Person_State_IO is new Serialization.IO_Enumeration (Person_State);
package Message_Kind_IO is new Serialization.IO_Enumeration (Message_Kind);
package Village_Time_IO is new Serialization.IO_Enumeration (Village_Time);
package Role_Appearance_IO is
new Serialization.IO_Enumeration (Role_Appearance);
package Vote_IO is new Serialization.IO_Enumeration (Vote_Mode);
package Execution_IO is new Serialization.IO_Enumeration (Execution_Mode);
package Formation_IO is new Serialization.IO_Enumeration (Formation_Mode);
package Monster_Side_IO is
new Serialization.IO_Enumeration (Monster_Side_Mode);
package Attack_IO is new Serialization.IO_Enumeration (Attack_Mode);
package Vampire_Action_Set_IO is
new Serialization.IO_Enumeration (Vampire_Action_Set_Mode);
package Servant_Knowing_IO is
new Serialization.IO_Enumeration (Servant_Knowing_Mode);
package Daytime_Preview_IO is
new Serialization.IO_Enumeration (Daytime_Preview_Mode);
package Doctor_Infected_IO is
new Serialization.IO_Enumeration (Doctor_Infected_Mode);
package Hunter_Silver_Bullet_IO is
new Serialization.IO_Enumeration (Hunter_Silver_Bullet_Mode);
package Unfortunate_IO is new Serialization.IO_Enumeration (Unfortunate_Mode);
package Obsolete_Teaming_IO is
new Serialization.IO_Enumeration (Obsolete_Teaming_Mode);
end Vampire.Villages.Village_IO;
|
zhmu/ananas | Ada | 16,796 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . W I D E _ W I D E _ S U P E R B O U N D E D --
-- --
-- S p e c --
-- --
-- Copyright (C) 2003-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This non generic package contains most of the implementation of the
-- generic package Ada.Strings.Wide_Wide_Bounded.Generic_Bounded_Length.
-- It defines type Super_String as a discriminated record with the maximum
-- length as the discriminant. Individual instantiations of the package
-- Strings.Wide_Wide_Bounded.Generic_Bounded_Length use this type with
-- an appropriate discriminant value set.
with Ada.Strings.Wide_Wide_Maps;
package Ada.Strings.Wide_Wide_Superbounded is
pragma Preelaborate;
Wide_Wide_NUL : constant Wide_Wide_Character :=
Wide_Wide_Character'Val (0);
-- Wide_Wide_Bounded.Generic_Bounded_Length.Wide_Wide_Bounded_String is
-- derived from Super_String, with the constraint of the maximum length.
type Super_String (Max_Length : Positive) is record
Current_Length : Natural := 0;
Data : Wide_Wide_String (1 .. Max_Length);
-- A previous version had a default initial value for Data, which is
-- no longer necessary, because we now special-case this type in the
-- compiler, so "=" composes properly for descendants of this type.
-- Leaving it out is more efficient.
end record;
-- The subprograms defined for Super_String are similar to those defined
-- for Bounded_Wide_Wide_String, except that they have different names, so
-- that they can be renamed in Wide_Wide_Bounded.Generic_Bounded_Length.
function Super_Length (Source : Super_String) return Natural;
--------------------------------------------------------
-- Conversion, Concatenation, and Selection Functions --
--------------------------------------------------------
function To_Super_String
(Source : Wide_Wide_String;
Max_Length : Natural;
Drop : Truncation := Error) return Super_String;
-- Note the additional parameter Max_Length, which specifies the maximum
-- length setting of the resulting Super_String value.
-- The following procedures have declarations (and semantics) that are
-- exactly analogous to those declared in Ada.Strings.Wide_Wide_Bounded.
function Super_To_String (Source : Super_String) return Wide_Wide_String;
procedure Set_Super_String
(Target : out Super_String;
Source : Wide_Wide_String;
Drop : Truncation := Error);
function Super_Append
(Left : Super_String;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Super_String;
Right : Wide_Wide_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Wide_Wide_String;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Super_String;
Right : Wide_Wide_Character;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Wide_Wide_Character;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Append
(Source : in out Super_String;
New_Item : Super_String;
Drop : Truncation := Error);
procedure Super_Append
(Source : in out Super_String;
New_Item : Wide_Wide_String;
Drop : Truncation := Error);
procedure Super_Append
(Source : in out Super_String;
New_Item : Wide_Wide_Character;
Drop : Truncation := Error);
function Concat
(Left : Super_String;
Right : Super_String) return Super_String;
function Concat
(Left : Super_String;
Right : Wide_Wide_String) return Super_String;
function Concat
(Left : Wide_Wide_String;
Right : Super_String) return Super_String;
function Concat
(Left : Super_String;
Right : Wide_Wide_Character) return Super_String;
function Concat
(Left : Wide_Wide_Character;
Right : Super_String) return Super_String;
function Super_Element
(Source : Super_String;
Index : Positive) return Wide_Wide_Character;
procedure Super_Replace_Element
(Source : in out Super_String;
Index : Positive;
By : Wide_Wide_Character);
function Super_Slice
(Source : Super_String;
Low : Positive;
High : Natural) return Wide_Wide_String;
function Super_Slice
(Source : Super_String;
Low : Positive;
High : Natural) return Super_String;
procedure Super_Slice
(Source : Super_String;
Target : out Super_String;
Low : Positive;
High : Natural);
function "="
(Left : Super_String;
Right : Super_String) return Boolean;
function Equal
(Left : Super_String;
Right : Super_String) return Boolean renames "=";
function Equal
(Left : Super_String;
Right : Wide_Wide_String) return Boolean;
function Equal
(Left : Wide_Wide_String;
Right : Super_String) return Boolean;
function Less
(Left : Super_String;
Right : Super_String) return Boolean;
function Less
(Left : Super_String;
Right : Wide_Wide_String) return Boolean;
function Less
(Left : Wide_Wide_String;
Right : Super_String) return Boolean;
function Less_Or_Equal
(Left : Super_String;
Right : Super_String) return Boolean;
function Less_Or_Equal
(Left : Super_String;
Right : Wide_Wide_String) return Boolean;
function Less_Or_Equal
(Left : Wide_Wide_String;
Right : Super_String) return Boolean;
function Greater
(Left : Super_String;
Right : Super_String) return Boolean;
function Greater
(Left : Super_String;
Right : Wide_Wide_String) return Boolean;
function Greater
(Left : Wide_Wide_String;
Right : Super_String) return Boolean;
function Greater_Or_Equal
(Left : Super_String;
Right : Super_String) return Boolean;
function Greater_Or_Equal
(Left : Super_String;
Right : Wide_Wide_String) return Boolean;
function Greater_Or_Equal
(Left : Wide_Wide_String;
Right : Super_String) return Boolean;
----------------------
-- Search Functions --
----------------------
function Super_Index
(Source : Super_String;
Pattern : Wide_Wide_String;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
Wide_Wide_Maps.Identity)
return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_Wide_String;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural;
function Super_Index
(Source : Super_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
Wide_Wide_Maps.Identity)
return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural;
function Super_Index
(Source : Super_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
function Super_Index_Non_Blank
(Source : Super_String;
Going : Direction := Forward) return Natural;
function Super_Index_Non_Blank
(Source : Super_String;
From : Positive;
Going : Direction := Forward) return Natural;
function Super_Count
(Source : Super_String;
Pattern : Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
Wide_Wide_Maps.Identity)
return Natural;
function Super_Count
(Source : Super_String;
Pattern : Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural;
function Super_Count
(Source : Super_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural;
procedure Super_Find_Token
(Source : Super_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
From : Positive;
Test : Membership;
First : out Positive;
Last : out Natural);
procedure Super_Find_Token
(Source : Super_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
Test : Membership;
First : out Positive;
Last : out Natural);
------------------------------------
-- String Translation Subprograms --
------------------------------------
function Super_Translate
(Source : Super_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
return Super_String;
procedure Super_Translate
(Source : in out Super_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping);
function Super_Translate
(Source : Super_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Super_String;
procedure Super_Translate
(Source : in out Super_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function);
---------------------------------------
-- String Transformation Subprograms --
---------------------------------------
function Super_Replace_Slice
(Source : Super_String;
Low : Positive;
High : Natural;
By : Wide_Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Replace_Slice
(Source : in out Super_String;
Low : Positive;
High : Natural;
By : Wide_Wide_String;
Drop : Truncation := Error);
function Super_Insert
(Source : Super_String;
Before : Positive;
New_Item : Wide_Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Insert
(Source : in out Super_String;
Before : Positive;
New_Item : Wide_Wide_String;
Drop : Truncation := Error);
function Super_Overwrite
(Source : Super_String;
Position : Positive;
New_Item : Wide_Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Overwrite
(Source : in out Super_String;
Position : Positive;
New_Item : Wide_Wide_String;
Drop : Truncation := Error);
function Super_Delete
(Source : Super_String;
From : Positive;
Through : Natural) return Super_String;
procedure Super_Delete
(Source : in out Super_String;
From : Positive;
Through : Natural);
---------------------------------
-- String Selector Subprograms --
---------------------------------
function Super_Trim
(Source : Super_String;
Side : Trim_End) return Super_String;
procedure Super_Trim
(Source : in out Super_String;
Side : Trim_End);
function Super_Trim
(Source : Super_String;
Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
Right : Wide_Wide_Maps.Wide_Wide_Character_Set) return Super_String;
procedure Super_Trim
(Source : in out Super_String;
Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
Right : Wide_Wide_Maps.Wide_Wide_Character_Set);
function Super_Head
(Source : Super_String;
Count : Natural;
Pad : Wide_Wide_Character := Wide_Wide_Space;
Drop : Truncation := Error) return Super_String;
procedure Super_Head
(Source : in out Super_String;
Count : Natural;
Pad : Wide_Wide_Character := Wide_Wide_Space;
Drop : Truncation := Error);
function Super_Tail
(Source : Super_String;
Count : Natural;
Pad : Wide_Wide_Character := Wide_Wide_Space;
Drop : Truncation := Error) return Super_String;
procedure Super_Tail
(Source : in out Super_String;
Count : Natural;
Pad : Wide_Wide_Character := Wide_Wide_Space;
Drop : Truncation := Error);
------------------------------------
-- String Constructor Subprograms --
------------------------------------
-- Note: in some of the following routines, there is an extra parameter
-- Max_Length which specifies the value of the maximum length for the
-- resulting Super_String value.
function Times
(Left : Natural;
Right : Wide_Wide_Character;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Times
(Left : Natural;
Right : Wide_Wide_String;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Times
(Left : Natural;
Right : Super_String) return Super_String;
function Super_Replicate
(Count : Natural;
Item : Wide_Wide_Character;
Drop : Truncation := Error;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Super_Replicate
(Count : Natural;
Item : Wide_Wide_String;
Drop : Truncation := Error;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Super_Replicate
(Count : Natural;
Item : Super_String;
Drop : Truncation := Error) return Super_String;
private
-- Pragma Inline declarations
pragma Inline ("=");
pragma Inline (Less);
pragma Inline (Less_Or_Equal);
pragma Inline (Greater);
pragma Inline (Greater_Or_Equal);
pragma Inline (Concat);
pragma Inline (Super_Count);
pragma Inline (Super_Element);
pragma Inline (Super_Find_Token);
pragma Inline (Super_Index);
pragma Inline (Super_Index_Non_Blank);
pragma Inline (Super_Length);
pragma Inline (Super_Replace_Element);
pragma Inline (Super_Slice);
pragma Inline (Super_To_String);
end Ada.Strings.Wide_Wide_Superbounded;
|
AdaCore/Ada_Drivers_Library | Ada | 6,452 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This program demonstrates basic DAC use, using explicit calls to control
-- the output value and conversion starting/stopping.
-- The user increments the percentage of the DAC output (VRef+) voltage using
-- the blue User button on the board (e.g., a STM32F429 Discovery board).
-- The current percentage is displayed on the LCD. When incremented, the
-- new percentage is converted into an absolute value based on the selected
-- resolution. For example, a digital value of 2048 represents 50% in 12-bit
-- resolution.
-- Attach a voltmeter to PA4 (or PA5 if channel 2 is used) to see the voltage
-- change as a result of pushing the blue button.
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
with HAL; use HAL;
with STM32.Board; use STM32.Board;
with STM32.Device; use STM32.Device;
with STM32.DAC; use STM32.DAC;
with STM32.GPIO; use STM32.GPIO;
with LCD_Std_Out; use LCD_Std_Out;
procedure Demo_DAC_Basic is
Output_Channel : constant DAC_Channel := Channel_1; -- arbitrary
procedure Configure_DAC_GPIO (Output_Channel : DAC_Channel);
-- Once the channel is enabled, the corresponding GPIO pin is automatically
-- connected to the analog converter output. However, in order to avoid
-- parasitic consumption, the PA4 pin (Channel_1) or PA5 pin (Channel_2)
-- should first be configured to analog mode. See the note in the RM, page
-- 431.
procedure Print (Value : UInt32);
-- Prints the image of the arg at a fixed location
procedure Await_Button;
-- Wait for the user to press and then release the blue user button
-----------
-- Print --
-----------
procedure Print (Value : UInt32) is
Value_Image : constant String := Value'Img;
begin
LCD_Std_Out.Put (170, 52, Value_Image (2 .. Value_Image'Last) & " ");
end Print;
------------------
-- Await_Button --
------------------
procedure Await_Button is
begin
Await_Pressed : loop
exit Await_Pressed when Set (User_Button_Point);
end loop Await_Pressed;
Await_Released : loop
exit Await_Released when not Set (User_Button_Point);
end loop Await_Released;
end Await_Button;
------------------------
-- Configure_DAC_GPIO --
------------------------
procedure Configure_DAC_GPIO (Output_Channel : DAC_Channel) is
Output : constant GPIO_Point := (if Output_Channel = Channel_1
then DAC_Channel_1_IO
else DAC_Channel_2_IO);
begin
Enable_Clock (Output);
Configure_IO (Output, (Mode => Mode_Analog, Resistors => Floating));
end Configure_DAC_GPIO;
begin
Initialize_LEDs;
All_LEDs_Off;
LCD_Std_Out.Clear_Screen;
Configure_User_Button_GPIO;
Configure_DAC_GPIO (Output_Channel);
Enable_Clock (DAC_1);
Reset (DAC_1);
Select_Trigger (DAC_1, Output_Channel, Software_Trigger);
Enable_Trigger (DAC_1, Output_Channel);
Enable (DAC_1, Output_Channel);
declare
Value : UInt32 := 0;
Percent : UInt32;
Resolution : constant DAC_Resolution := DAC_Resolution_12_Bits;
-- Arbitrary, change as desired. Counts will automatically adjust.
Max_Counts : constant UInt32 := (if Resolution = DAC_Resolution_12_Bits
then Max_12bit_Resolution
else Max_8bit_Resolution);
begin
Put (0, 0, "VRef+ is 2.95V"); -- measured
Put (0, 25, "Button advances");
Put (0, 52, "Current %:");
loop
for K in UInt32 range 0 .. 10 loop
Percent := K * 10;
Print (Percent);
Value := (Percent * Max_Counts) / 100;
Set_Output
(DAC_1,
Output_Channel,
Value,
Resolution,
Right_Aligned);
Trigger_Conversion_By_Software (DAC_1, Output_Channel);
Await_Button;
end loop;
end loop;
end;
end Demo_DAC_Basic;
|
AdaCore/gpr | Ada | 955 | adb | with p7_0; use p7_0;
package body p7_3 is
function p7_3_0 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p7_0_0 (Item - 1)) + 730;
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p7_3_0;
function p7_3_1 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p7_0_1 (Item - 1)) + 731;
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p7_3_1;
function p7_3_2 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p7_0_2 (Item - 1)) + 732;
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p7_3_2;
end p7_3;
|
Falindir/AI | Ada | 114 | adb | with Ada.Text_IO;
use Ada.Text_IO;
procedure main is
begin -- Bonjour
Put("Hello Master Falindir");
end main; |
reznikmm/matreshka | Ada | 17,774 | 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_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Behaviors;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Data_Store_Nodes;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.States.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.UML.Types;
with AMF.UML.Value_Specifications;
with AMF.Visitors;
package AMF.Internals.UML_Data_Store_Nodes is
type UML_Data_Store_Node_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Data_Store_Nodes.UML_Data_Store_Node with null record;
overriding function Get_In_State
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.States.Collections.Set_Of_UML_State;
-- Getter of ObjectNode::inState.
--
-- The required states of the object available at this point in the
-- activity.
overriding function Get_Is_Control_Type
(Self : not null access constant UML_Data_Store_Node_Proxy)
return Boolean;
-- Getter of ObjectNode::isControlType.
--
-- Tells whether the type of the object node is to be treated as control.
overriding procedure Set_Is_Control_Type
(Self : not null access UML_Data_Store_Node_Proxy;
To : Boolean);
-- Setter of ObjectNode::isControlType.
--
-- Tells whether the type of the object node is to be treated as control.
overriding function Get_Ordering
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.UML_Object_Node_Ordering_Kind;
-- Getter of ObjectNode::ordering.
--
-- Tells whether and how the tokens in the object node are ordered for
-- selection to traverse edges outgoing from the object node.
overriding procedure Set_Ordering
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.UML_Object_Node_Ordering_Kind);
-- Setter of ObjectNode::ordering.
--
-- Tells whether and how the tokens in the object node are ordered for
-- selection to traverse edges outgoing from the object node.
overriding function Get_Selection
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of ObjectNode::selection.
--
-- Selects tokens for outgoing edges.
overriding procedure Set_Selection
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of ObjectNode::selection.
--
-- Selects tokens for outgoing edges.
overriding function Get_Upper_Bound
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access;
-- Getter of ObjectNode::upperBound.
--
-- The maximum number of tokens allowed in the node. Objects cannot flow
-- into the node if the upper bound is reached.
overriding procedure Set_Upper_Bound
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access);
-- Setter of ObjectNode::upperBound.
--
-- The maximum number of tokens allowed in the node. Objects cannot flow
-- into the node if the upper bound is reached.
overriding function Get_Activity
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityNode::activity.
--
-- Activity containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityNode::activity.
--
-- Activity containing the node.
overriding function Get_In_Group
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Node_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 Get_Client_Dependency
(Self : not null access constant UML_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Node_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_Type
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Types.UML_Type_Access;
-- Getter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding procedure Set_Type
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Types.UML_Type_Access);
-- Setter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding function Is_Consistent_With
(Self : not null access constant UML_Data_Store_Node_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_Data_Store_Node_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 function All_Owning_Packages
(Self : not null access constant UML_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Node_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_Data_Store_Nodes;
|
reznikmm/matreshka | Ada | 3,704 | 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.Chart_Error_Indicator_Elements is
pragma Preelaborate;
type ODF_Chart_Error_Indicator is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Chart_Error_Indicator_Access is
access all ODF_Chart_Error_Indicator'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Error_Indicator_Elements;
|
zhmu/ananas | Ada | 2,064 | adb | -- { dg-do run }
with Init5; use Init5;
with Text_IO; use Text_IO;
with Dump;
procedure P5 is
Local_R1 : R1;
Local_R2 : R2;
begin
Put ("My_R1 :");
Dump (My_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "My_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" }
Put ("My_R2 :");
Dump (My_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "My_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" }
Local_R1 := My_R1;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" }
Local_R2 := My_R2;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" }
Local_R1 := (I => 16#12345678#,
A => (16#AB0012#, 16#CD0034#, 16#EF0056#));
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" }
Local_R2 := (I => 16#12345678#,
A => (16#AB0012#, 16#CD0034#, 16#EF0056#));
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" }
Local_R1.I := Local_R2.I;
Local_R1.A(1) := Local_R2.A(1);
Local_R1.A(2) := Local_R2.A(2);
Local_R1.A(3) := Local_R2.A(3);
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" }
Local_R2.I := Local_R1.I;
Local_R2.A(1) := Local_R1.A(1);
Local_R2.A(2) := Local_R1.A(2);
Local_R2.A(3) := Local_R1.A(3);
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" }
end;
|
Irvise/Ada_SaxonSOC | Ada | 866 | ads | -- SaxonSOC GPIO mapping
-- The structure is mostly based on https://github.com/AdaCore/bb-runtimes/
-- blob/community-2020/riscv/sifive/fe310/svd/i-fe310-gpio.ads
with System;
-- TODO do more than just the LEDS
package Interfaces.SaxonSOC.GPIO is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
-- Auxiliary types
type GPIO_Control_Reg is new Unsigned_32;
type Mask_T is new Unsigned_32;
-- Addresses
GPIO_A_Base_Address : constant := 16#1000_0000#;
GPIO_A_Input : GPIO_Control_Reg
with Volatile_Full_Access,
Address => System'To_Address (GPIO_A_Base_Address);
GPIO_A_Output : GPIO_Control_Reg
with Address => System'To_Address (GPIO_A_Base_Address + 16#04#);
GPIO_A_Output_Enable : GPIO_Control_Reg
with Address => System'To_Address (GPIO_A_Base_Address + 16#08#);
end Interfaces.SaxonSOC.GPIO;
|
kontena/ruby-packer | Ada | 6,281 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Rain --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Laurent Pautet <[email protected]>
-- Modified by: Juergen Pfeifer, 1997
-- Version Control
-- $Revision: 1.8 $
-- $Date: 2008/08/30 21:38:07 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- --
with ncurses2.util; use ncurses2.util;
with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random;
with Status; use Status;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
procedure Rain is
Visibility : Cursor_Visibility;
subtype X_Position is Line_Position;
subtype Y_Position is Column_Position;
Xpos : array (1 .. 5) of X_Position;
Ypos : array (1 .. 5) of Y_Position;
done : Boolean;
c : Key_Code;
N : Integer;
G : Generator;
Max_X, X : X_Position;
Max_Y, Y : Y_Position;
procedure Next (J : in out Integer);
procedure Cursor (X : X_Position; Y : Y_Position);
procedure Next (J : in out Integer) is
begin
if J = 5 then
J := 1;
else
J := J + 1;
end if;
end Next;
procedure Cursor (X : X_Position; Y : Y_Position) is
begin
Move_Cursor (Line => X, Column => Y);
end Cursor;
pragma Inline (Cursor);
begin
Init_Screen;
Set_NL_Mode;
Set_Echo_Mode (False);
Visibility := Invisible;
Set_Cursor_Visibility (Visibility);
Set_Timeout_Mode (Standard_Window, Non_Blocking, 0);
Max_X := Lines - 5;
Max_Y := Columns - 5;
for I in Xpos'Range loop
Xpos (I) := X_Position (Float (Max_X) * Random (G)) + 2;
Ypos (I) := Y_Position (Float (Max_Y) * Random (G)) + 2;
end loop;
N := 1;
done := False;
while not done and Process.Continue loop
X := X_Position (Float (Max_X) * Random (G)) + 2;
Y := Y_Position (Float (Max_Y) * Random (G)) + 2;
Cursor (X, Y);
Add (Ch => '.');
Cursor (Xpos (N), Ypos (N));
Add (Ch => 'o');
--
Next (N);
Cursor (Xpos (N), Ypos (N));
Add (Ch => 'O');
--
Next (N);
Cursor (Xpos (N) - 1, Ypos (N));
Add (Ch => '-');
Cursor (Xpos (N), Ypos (N) - 1);
Add (Str => "|.|");
Cursor (Xpos (N) + 1, Ypos (N));
Add (Ch => '-');
--
Next (N);
Cursor (Xpos (N) - 2, Ypos (N));
Add (Ch => '-');
Cursor (Xpos (N) - 1, Ypos (N) - 1);
Add (Str => "/\\");
Cursor (Xpos (N), Ypos (N) - 2);
Add (Str => "| O |");
Cursor (Xpos (N) + 1, Ypos (N) - 1);
Add (Str => "\\/");
Cursor (Xpos (N) + 2, Ypos (N));
Add (Ch => '-');
--
Next (N);
Cursor (Xpos (N) - 2, Ypos (N));
Add (Ch => ' ');
Cursor (Xpos (N) - 1, Ypos (N) - 1);
Add (Str => " ");
Cursor (Xpos (N), Ypos (N) - 2);
Add (Str => " ");
Cursor (Xpos (N) + 1, Ypos (N) - 1);
Add (Str => " ");
Cursor (Xpos (N) + 2, Ypos (N));
Add (Ch => ' ');
Xpos (N) := X;
Ypos (N) := Y;
c := Getchar;
case c is
when Character'Pos ('q') => done := True;
when Character'Pos ('Q') => done := True;
when Character'Pos ('s') => Set_NoDelay_Mode (Standard_Window, False);
when Character'Pos (' ') => Set_NoDelay_Mode (Standard_Window, True);
when others => null;
end case;
Nap_Milli_Seconds (50);
end loop;
Visibility := Normal;
Set_Cursor_Visibility (Visibility);
End_Windows;
Curses_Free_All;
end Rain;
|
sungyeon/drake | Ada | 4,090 | adb | with System.Tasks;
with System.Debug; -- assertions
with C.winbase;
with C.windef;
with C.winerror;
package body System.Synchronous_Objects.Abortable is
use type C.windef.DWORD;
-- queue
procedure Take (
Object : in out Queue;
Item : out Queue_Node_Access;
Params : Address;
Filter : Queue_Filter;
Aborted : out Boolean) is
begin
Aborted := Tasks.Is_Aborted;
Enter (Object.Mutex.all);
declare
Previous : Queue_Node_Access := null;
I : Queue_Node_Access := Object.Head;
begin
Taking : loop
Take_No_Sync (Object, Item, Params, Filter, Previous, I);
exit Taking when Item /= null;
-- not found
declare
Tail_On_Waiting : constant Queue_Node_Access := Object.Tail;
begin
Object.Params := Params;
Object.Filter := Filter;
loop
Object.Waiting := True;
Leave (Object.Mutex.all);
Wait (Object.Event, Aborted => Aborted);
Enter (Object.Mutex.all);
Object.Waiting := False;
exit Taking when Aborted;
exit when Object.Tail /= Tail_On_Waiting;
end loop;
if Tail_On_Waiting /= null then
Previous := Tail_On_Waiting;
I := Tail_On_Waiting.Next;
else
Previous := null;
I := Object.Head;
end if;
end;
end loop Taking;
end;
Leave (Object.Mutex.all);
end Take;
-- event
procedure Wait (
Object : in out Event;
Aborted : out Boolean)
is
Abort_Event : constant access Event := Tasks.Abort_Event;
begin
if Abort_Event /= null then
declare
Handles : aliased array (0 .. 1) of aliased C.winnt.HANDLE :=
(Object.Handle, Abort_Event.Handle);
Signaled : C.windef.DWORD;
begin
Signaled :=
C.winbase.WaitForMultipleObjects (
2,
Handles (0)'Access,
0,
C.winbase.INFINITE);
pragma Check (Debug,
Check =>
Signaled = C.winbase.WAIT_OBJECT_0
or else Signaled = C.winbase.WAIT_OBJECT_0 + 1
or else Debug.Runtime_Error (
"WaitForMultipleObjects failed"));
Aborted := Signaled = C.winbase.WAIT_OBJECT_0 + 1;
end;
else
Wait (Object);
Aborted := Tasks.Is_Aborted;
end if;
end Wait;
procedure Wait (
Object : in out Event;
Timeout : Duration;
Value : out Boolean;
Aborted : out Boolean)
is
Abort_Event : constant access Event := Tasks.Abort_Event;
begin
if Abort_Event /= null then
declare
Handles : aliased array (0 .. 1) of aliased C.winnt.HANDLE :=
(Object.Handle, Abort_Event.Handle);
Milliseconds : constant C.windef.DWORD :=
C.windef.DWORD (Timeout * 1_000);
Signaled : C.windef.DWORD;
begin
Signaled :=
C.winbase.WaitForMultipleObjects (
2,
Handles (0)'Access,
0,
Milliseconds);
pragma Check (Debug,
Check =>
Signaled = C.winbase.WAIT_OBJECT_0
or else Signaled = C.winbase.WAIT_OBJECT_0 + 1
or else Signaled = C.winerror.WAIT_TIMEOUT
or else Debug.Runtime_Error (
"WaitForMultipleObjects failed"));
Value := Signaled = C.winbase.WAIT_OBJECT_0 or else Get (Object);
Aborted := Signaled = C.winbase.WAIT_OBJECT_0 + 1;
end;
else
Wait (Object, Timeout, Value);
Aborted := Tasks.Is_Aborted;
end if;
end Wait;
end System.Synchronous_Objects.Abortable;
|
AdaCore/Ada_Drivers_Library | Ada | 4,560 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2019, 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 Feather_STM32F405.I2C;
with AdaFruit.CharlieWing;
with HAL; use HAL;
procedure Main is
Matrix : AdaFruit.CharlieWing.Device (Feather_STM32F405.I2C.Controller, 0);
pragma Style_Checks (Off);
A : constant := 1;
Text : constant array (AdaFruit.CharlieWing.Y_Coord, 0 .. 74) of HAL.Bit :=
((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, A, 0, 0, 0, 0, 0, others => 0),
(A, 0, 0, 0, A, 0, 0, 0, 0, 0, 0, A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, A, 0, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, 0, 0, 0, 0, A, A, 0, 0, 0, 0, 0, A, 0, 0, 0, 0, 0, others => 0),
(A, A, 0, A, A, 0, 0, A, A, 0, 0, A, 0, 0, A, 0, 0, A, A, 0, 0, 0, A, 0, 0, 0, A, 0, 0, 0, 0, A, A, A, 0, A, 0, 0, 0, 0, 0, A, 0, 0, A, 0, 0, A, A, A, 0, 0, A, A, 0, others => 0),
(A, 0, A, 0, A, 0, 0, 0, 0, A, 0, A, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, 0, A, 0, A, A, 0, 0, A, 0, 0, A, A, A, 0, 0, 0, A, 0, 0, A, 0, A, 0, 0, A, 0, 0, 0, 0, A, others => 0),
(A, 0, 0, 0, A, 0, 0, A, A, A, 0, A, A, 0, 0, 0, A, A, A, A, 0, 0, A, 0, A, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, A, A, A, 0, A, 0, 0, A, 0, 0, A, A, A, others => 0),
(A, 0, 0, 0, A, 0, A, 0, 0, A, 0, A, 0, A, 0, 0, A, 0, 0, 0, 0, 0, A, A, 0, A, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, A, 0, 0, A, 0, A, 0, 0, A, others => 0),
(A, 0, 0, 0, A, 0, 0, A, A, A, 0, A, 0, 0, A, 0, 0, A, A, 0, 0, 0, A, 0, 0, 0, A, 0, A, A, A, 0, A, A, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, 0, 0, A, A, A, 0, 0, A, A, A, others => 0));
pragma Style_Checks (On);
begin
Feather_STM32F405.I2C.Initialize (400_000);
Matrix.Initialize;
Matrix.Fill (10);
loop
for Column in Text'Range (2) loop
for X in AdaFruit.CharlieWing.X_Coord loop
for Y in AdaFruit.CharlieWing.Y_Coord loop
if Text (Y, (X + Column) mod Text'Length (2)) = 1 then
Matrix.Enable (X, Y);
else
Matrix.Disable (X, Y);
end if;
end loop;
end loop;
delay 0.1;
end loop;
end loop;
end Main;
|
apple-oss-distributions/old_ncurses | Ada | 6,964 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Termcap --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control:
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
package body Terminal_Interface.Curses.Termcap is
function Get_Entry (Name : String) return Boolean
is
function tgetent (name : char_array; val : char_array)
return C_Int;
pragma Import (C, tgetent, "tgetent");
NameTxt : char_array (0 .. Name'Length);
Length : size_t;
ignored : char_array (0 .. 0) := (0 => nul);
result : C_Int;
begin
To_C (Name, NameTxt, Length);
result := tgetent (char_array (ignored), NameTxt);
if result = -1 then
raise Curses_Exception;
else
return Boolean'Val (result);
end if;
end Get_Entry;
------------------------------------------------------------------------------
function Get_Flag (Name : String) return Boolean
is
function tgetflag (id : char_array) return C_Int;
pragma Import (C, tgetflag, "tgetflag");
Txt : char_array (0 .. Name'Length);
Length : size_t;
begin
To_C (Name, Txt, Length);
if tgetflag (Txt) = 0 then
return False;
else
return True;
end if;
end Get_Flag;
------------------------------------------------------------------------------
procedure Get_Number (Name : in String;
Value : out Integer;
Result : out Boolean)
is
function tgetnum (id : char_array) return C_Int;
pragma Import (C, tgetnum, "tgetnum");
Txt : char_array (0 .. Name'Length);
Length : size_t;
begin
To_C (Name, Txt, Length);
Value := Integer (tgetnum (Txt));
if Value = -1 then
Result := False;
else
Result := True;
end if;
end Get_Number;
------------------------------------------------------------------------------
procedure Get_String (Name : String;
Value : out String;
Result : out Boolean)
is
function tgetstr (id : char_array;
buf : char_array) return chars_ptr;
pragma Import (C, tgetstr, "tgetstr");
Txt : char_array (0 .. Name'Length);
Length : size_t;
Txt2 : chars_ptr;
type t is new char_array (0 .. 1024); -- does it need to be 1024?
Return_Buffer : t := (0 => nul);
begin
To_C (Name, Txt, Length);
Txt2 := tgetstr (Txt, char_array (Return_Buffer));
if Txt2 = Null_Ptr then
Result := False;
else
Value := Fill_String (Txt2);
Result := True;
end if;
end Get_String;
function Get_String (Name : String) return Boolean
is
function tgetstr (Id : char_array;
buf : char_array) return chars_ptr;
pragma Import (C, tgetstr, "tgetstr");
Txt : char_array (0 .. Name'Length);
Length : size_t;
Txt2 : chars_ptr;
type t is new char_array (0 .. 1024); -- does it need to be 1024?
Phony_Txt : t := (0 => nul);
begin
To_C (Name, Txt, Length);
Txt2 := tgetstr (Txt, char_array (Phony_Txt));
if Txt2 = Null_Ptr then
return False;
else
return True;
end if;
end Get_String;
------------------------------------------------------------------------------
function TGoto (Cap : String;
Col : Column_Position;
Row : Line_Position) return Termcap_String is
function tgoto (cap : char_array;
col : C_Int;
row : C_Int) return chars_ptr;
pragma Import (C, tgoto);
Txt : char_array (0 .. Cap'Length);
Length : size_t;
begin
To_C (Cap, Txt, Length);
return Termcap_String (Fill_String
(tgoto (Txt, C_Int (Col), C_Int (Row))));
end TGoto;
end Terminal_Interface.Curses.Termcap;
|
AdaCore/libadalang | Ada | 644 | ads | package Foo is
type U is null record;
procedure Foo (Self : U);
--% node.p_subp_spec_or_null().p_primitive_subp_tagged_type()
type T is tagged null record;
procedure Bar (Self : T);
--% node.p_subp_spec_or_null().p_primitive_subp_tagged_type()
package Boo is
procedure Foo (Self : T);
--% node.p_subp_spec_or_null().p_primitive_subp_tagged_type()
end Boo;
generic
type U is private;
procedure Dummy (Self : T);
--% node.f_subp_decl.f_subp_spec.p_primitive_subp_tagged_type()
private
procedure Baz (Self : T);
--% node.p_subp_spec_or_null().p_primitive_subp_tagged_type()
end Foo;
|
jrcarter/Ada_GUI | Ada | 3,962 | ads | -- Ada_GUI implementation based on Gnoga. Adapted 2021
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . S E R V E R . T E M P L A T E _ P A R S E R . S I M P L E --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2014 David Botton --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are --
-- granted additional permissions described in the GCC Runtime Library --
-- Exception, version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
-- A simple find and replace template parser.
-- Templates are marked up as @@var_name.element@@
--
-- Info messages are available as @@gnoga_infos.row_number@@
-- Error messages are available as @@gnoga_errors.row_number@@
-- Note: The Simple parser is just a find and replace and so there is now
-- way to loop or otherwise determine in advance how many rows exist.
package Ada_GUI.Gnoga.Server.Template_Parser.Simple is
function Load_View (Name : String) return String;
-- Return named view with no passed data
function Load_View (Name : String;
Data_Map : Gnoga.Data_Map_Type;
Var_Name : String := "data")
return String;
-- Return named view with data map
function Load_View (Name : String; Data : View_Data)
return String;
-- Return named view with Data
function Load_View (Name : String;
Data_List : View_Data_Array)
return String;
-- Return named view with Data_List array of View_Data items
end Ada_GUI.Gnoga.Server.Template_Parser.Simple;
|
reznikmm/matreshka | Ada | 5,328 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Literal_Specifications.Collections is
pragma Preelaborate;
package UML_Literal_Specification_Collections is
new AMF.Generic_Collections
(UML_Literal_Specification,
UML_Literal_Specification_Access);
type Set_Of_UML_Literal_Specification is
new UML_Literal_Specification_Collections.Set with null record;
Empty_Set_Of_UML_Literal_Specification : constant Set_Of_UML_Literal_Specification;
type Ordered_Set_Of_UML_Literal_Specification is
new UML_Literal_Specification_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Literal_Specification : constant Ordered_Set_Of_UML_Literal_Specification;
type Bag_Of_UML_Literal_Specification is
new UML_Literal_Specification_Collections.Bag with null record;
Empty_Bag_Of_UML_Literal_Specification : constant Bag_Of_UML_Literal_Specification;
type Sequence_Of_UML_Literal_Specification is
new UML_Literal_Specification_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Literal_Specification : constant Sequence_Of_UML_Literal_Specification;
private
Empty_Set_Of_UML_Literal_Specification : constant Set_Of_UML_Literal_Specification
:= (UML_Literal_Specification_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Literal_Specification : constant Ordered_Set_Of_UML_Literal_Specification
:= (UML_Literal_Specification_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Literal_Specification : constant Bag_Of_UML_Literal_Specification
:= (UML_Literal_Specification_Collections.Bag with null record);
Empty_Sequence_Of_UML_Literal_Specification : constant Sequence_Of_UML_Literal_Specification
:= (UML_Literal_Specification_Collections.Sequence with null record);
end AMF.UML.Literal_Specifications.Collections;
|
AdaCore/libadalang | Ada | 44 | ads | generic
package D is
A : Integer;
end D;
|
AdaCore/Ada_Drivers_Library | Ada | 12,859 | ads | -- This spec has been automatically generated from STM32F40x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.GPIO is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- MODER array element
subtype MODER_Element is HAL.UInt2;
-- MODER array
type MODER_Field_Array is array (0 .. 15) of MODER_Element
with Component_Size => 2, Size => 32;
-- GPIO port mode register
type MODER_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MODER as a value
Val : HAL.UInt32;
when True =>
-- MODER as an array
Arr : MODER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for MODER_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- OTYPER_OT array
type OTYPER_OT_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for OTYPER_OT
type OTYPER_OT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- OT as a value
Val : HAL.UInt16;
when True =>
-- OT as an array
Arr : OTYPER_OT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for OTYPER_OT_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port output type register
type OTYPER_Register is record
-- Port x configuration bits (y = 0..15)
OT : OTYPER_OT_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OTYPER_Register use record
OT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- OSPEEDR array element
subtype OSPEEDR_Element is HAL.UInt2;
-- OSPEEDR array
type OSPEEDR_Field_Array is array (0 .. 15) of OSPEEDR_Element
with Component_Size => 2, Size => 32;
-- GPIO port output speed register
type OSPEEDR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- OSPEEDR as a value
Val : HAL.UInt32;
when True =>
-- OSPEEDR as an array
Arr : OSPEEDR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for OSPEEDR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- PUPDR array element
subtype PUPDR_Element is HAL.UInt2;
-- PUPDR array
type PUPDR_Field_Array is array (0 .. 15) of PUPDR_Element
with Component_Size => 2, Size => 32;
-- GPIO port pull-up/pull-down register
type PUPDR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PUPDR as a value
Val : HAL.UInt32;
when True =>
-- PUPDR as an array
Arr : PUPDR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for PUPDR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- IDR array
type IDR_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for IDR
type IDR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- IDR as a value
Val : HAL.UInt16;
when True =>
-- IDR as an array
Arr : IDR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for IDR_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port input data register
type IDR_Register is record
-- Read-only. Port input data (y = 0..15)
IDR : IDR_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IDR_Register use record
IDR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- ODR array
type ODR_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for ODR
type ODR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ODR as a value
Val : HAL.UInt16;
when True =>
-- ODR as an array
Arr : ODR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for ODR_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port output data register
type ODR_Register is record
-- Port output data (y = 0..15)
ODR : ODR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ODR_Register use record
ODR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- BSRR_BS array
type BSRR_BS_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for BSRR_BS
type BSRR_BS_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- BS as a value
Val : HAL.UInt16;
when True =>
-- BS as an array
Arr : BSRR_BS_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for BSRR_BS_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- BSRR_BR array
type BSRR_BR_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for BSRR_BR
type BSRR_BR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- BR as a value
Val : HAL.UInt16;
when True =>
-- BR as an array
Arr : BSRR_BR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for BSRR_BR_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port bit set/reset register
type BSRR_Register is record
-- Write-only. Port x set bit y (y= 0..15)
BS : BSRR_BS_Field := (As_Array => False, Val => 16#0#);
-- Write-only. Port x set bit y (y= 0..15)
BR : BSRR_BR_Field := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BSRR_Register use record
BS at 0 range 0 .. 15;
BR at 0 range 16 .. 31;
end record;
-- LCKR_LCK array
type LCKR_LCK_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for LCKR_LCK
type LCKR_LCK_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LCK as a value
Val : HAL.UInt16;
when True =>
-- LCK as an array
Arr : LCKR_LCK_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for LCKR_LCK_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- GPIO port configuration lock register
type LCKR_Register is record
-- Port x lock bit y (y= 0..15)
LCK : LCKR_LCK_Field := (As_Array => False, Val => 16#0#);
-- Port x lock bit y (y= 0..15)
LCKK : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LCKR_Register use record
LCK at 0 range 0 .. 15;
LCKK at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- AFRL array element
subtype AFRL_Element is HAL.UInt4;
-- AFRL array
type AFRL_Field_Array is array (0 .. 7) of AFRL_Element
with Component_Size => 4, Size => 32;
-- GPIO alternate function low register
type AFRL_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- AFRL as a value
Val : HAL.UInt32;
when True =>
-- AFRL as an array
Arr : AFRL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for AFRL_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- AFRH array element
subtype AFRH_Element is HAL.UInt4;
-- AFRH array
type AFRH_Field_Array is array (8 .. 15) of AFRH_Element
with Component_Size => 4, Size => 32;
-- GPIO alternate function high register
type AFRH_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- AFRH as a value
Val : HAL.UInt32;
when True =>
-- AFRH as an array
Arr : AFRH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for AFRH_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- General-purpose I/Os
type GPIO_Peripheral is record
-- GPIO port mode register
MODER : aliased MODER_Register;
-- GPIO port output type register
OTYPER : aliased OTYPER_Register;
-- GPIO port output speed register
OSPEEDR : aliased OSPEEDR_Register;
-- GPIO port pull-up/pull-down register
PUPDR : aliased PUPDR_Register;
-- GPIO port input data register
IDR : aliased IDR_Register;
-- GPIO port output data register
ODR : aliased ODR_Register;
-- GPIO port bit set/reset register
BSRR : aliased BSRR_Register;
-- GPIO port configuration lock register
LCKR : aliased LCKR_Register;
-- GPIO alternate function low register
AFRL : aliased AFRL_Register;
-- GPIO alternate function high register
AFRH : aliased AFRH_Register;
end record
with Volatile;
for GPIO_Peripheral use record
MODER at 16#0# range 0 .. 31;
OTYPER at 16#4# range 0 .. 31;
OSPEEDR at 16#8# range 0 .. 31;
PUPDR at 16#C# range 0 .. 31;
IDR at 16#10# range 0 .. 31;
ODR at 16#14# range 0 .. 31;
BSRR at 16#18# range 0 .. 31;
LCKR at 16#1C# range 0 .. 31;
AFRL at 16#20# range 0 .. 31;
AFRH at 16#24# range 0 .. 31;
end record;
-- General-purpose I/Os
GPIOA_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40020000#);
-- General-purpose I/Os
GPIOB_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40020400#);
-- General-purpose I/Os
GPIOC_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40020800#);
-- General-purpose I/Os
GPIOD_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40020C00#);
-- General-purpose I/Os
GPIOE_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40021000#);
-- General-purpose I/Os
GPIOF_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40021400#);
-- General-purpose I/Os
GPIOG_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40021800#);
-- General-purpose I/Os
GPIOH_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40021C00#);
-- General-purpose I/Os
GPIOI_Periph : aliased GPIO_Peripheral
with Import, Address => System'To_Address (16#40022000#);
end STM32_SVD.GPIO;
|
mirror/ncurses | Ada | 3,464 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.Alpha --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 1999-2003,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.13 $
-- Binding Version 01.00
------------------------------------------------------------------------------
package Terminal_Interface.Curses.Forms.Field_Types.Alpha is
pragma Preelaborate (Terminal_Interface.Curses.Forms.Field_Types.Alpha);
type Alpha_Field is new Field_Type
with record
Minimum_Field_Width : Natural := 0;
end record;
procedure Set_Field_Type (Fld : Field;
Typ : Alpha_Field);
pragma Inline (Set_Field_Type);
end Terminal_Interface.Curses.Forms.Field_Types.Alpha;
|
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.Office_Name_Attributes is
pragma Preelaborate;
type ODF_Office_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Office_Name_Attribute_Access is
access all ODF_Office_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Office_Name_Attributes;
|
stcarrez/dynamo | Ada | 15,246 | adb | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- --
-- A S I S . A D A _ E N V I R O N M E N T S . C O N T A I N E R S --
-- --
-- B o d y --
-- --
-- Copyright (c) 1995-2006, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adaccore.com). --
-- --
------------------------------------------------------------------------------
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Errors; use Asis.Errors;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.Contt; use A4G.Contt;
with A4G.Vcheck; use A4G.Vcheck;
package body Asis.Ada_Environments.Containers is
Package_Name : constant String := "Asis.Ada_Environments.Containers.";
-- At the moment, we implement the Container abstraction in a simplest
-- possible way pointed out in section 9.1: any Context is mapped to
-- a list of one Container
--
-- We think that the definition of the Container abstraction in ASIS
-- contains a hole. The Container remains valid only till the Context
-- from which it has been obtained remains opened (the same rule as for
-- other ASIS abstractions - Compilation_Unit, Element, Line,
-- Record_Component, Array_Component). We failed to find the corresponding
-- rule in the ASIS Standard.
-----------------------
-- Local subprograms --
-----------------------
-- We can not put the access and update routines for the components of the
-- Container type in Asis.Set_Get package where the access/update routines
-- for other ASIS abstractions are defined, because the Container
-- abstraction is defined not in Asis, but in
-- Asis.Ada_Environments.Containers. If we decide to implement Containers
-- in some non-trivial way, we may need to put low-level routines
-- operating on Containers in some separate package
function Set_Container
(Cntnr : Container_Id;
Cntxt : Context_Id)
return Container;
-- Creates the new value of the Container type, the Obtained field is set
-- equal to the current ASIS OS time
function Cntnr_Id (The_Container : Container) return Container_Id;
function Encl_Cont_Id (The_Container : Container) return Context_Id;
function Obtained (The_Container : Container) return ASIS_OS_Time;
-- These functions return components of the internal Contaier structure
procedure Check_Validity
(The_Container : Container;
Query : String);
-- Checks if the argument does not belong to the closed (and possibly then
-- reopened) Context. If this check fails, raises
-- ASIS_Inappropriate_Container with Value_Error error status and forms
-- the corresponding Diagnosis string
function Is_Nil (The_Container : Container) return Boolean;
-- Returns True if the container is a Nil_Container.
-- This is really strange that we do not have this function in the spec.
-- And the whole notion of Nil_Container seems to be ill-defined and
-- as a result - useless.
------------------------------
-- Local subprograms bodies --
------------------------------
--------------------
-- Check_Validity --
--------------------
procedure Check_Validity
(The_Container : Container;
Query : String)
is
begin
if not Is_Nil (The_Container) then
if not Is_Opened (Encl_Cont_Id (The_Container)) or else
not Later
(Opened_At (Encl_Cont_Id (The_Container)),
Obtained (The_Container))
then
Set_Error_Status
(Status => Value_Error,
Diagnosis => "Invalid Container value in " & Query);
raise ASIS_Inappropriate_Container;
end if;
end if;
end Check_Validity;
--------------
-- Cntnr_Id --
--------------
function Cntnr_Id (The_Container : Container) return Container_Id is
begin
return The_Container.Id;
end Cntnr_Id;
------------------
-- Encl_Cont_Id --
------------------
function Encl_Cont_Id (The_Container : Container) return Context_Id is
begin
return The_Container.Cont_Id;
end Encl_Cont_Id;
------------
-- Is_Nil --
------------
function Is_Nil (The_Container : Container) return Boolean is
begin
return Cntnr_Id (The_Container) = Nil_Container_Id;
end Is_Nil;
--------------
-- Obtained --
--------------
function Obtained (The_Container : Container) return ASIS_OS_Time is
begin
return The_Container.Obtained;
end Obtained;
-------------------
-- Set_Container --
-------------------
function Set_Container
(Cntnr : Container_Id;
Cntxt : Context_Id)
return Container
is
Result_Container : Container := Nil_Container;
begin
if Cntnr /= Nil_Container_Id then
Result_Container :=
(Id => Cntnr,
Cont_Id => Cntxt,
Obtained => A_OS_Time);
end if;
return Result_Container;
end Set_Container;
-----------------------------------------
-- End of the local subprograms bodies --
-----------------------------------------
-----------------------
-- Compilation_Units --
-----------------------
function Compilation_Units
(The_Container : Container)
return Asis.Compilation_Unit_List
is
begin
Check_Validity (The_Container, Package_Name & "Compilation_Units");
if Is_Nil (The_Container) then
return Nil_Compilation_Unit_List;
end if;
return Compilation_Units (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Compilation_Units");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Compilation_Units",
Ex => Ex);
end Compilation_Units;
-----------------------------
-- Compilation_Unit_Bodies --
-----------------------------
function Compilation_Unit_Bodies
(The_Container : Container)
return Asis.Compilation_Unit_List
is
begin
Check_Validity (The_Container, Package_Name & "Compilation_Unit_Bodies");
if Is_Nil (The_Container) then
return Nil_Compilation_Unit_List;
end if;
return Compilation_Unit_Bodies (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Compilation_Unit_Bodies");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Compilation_Unit_Bodies",
Ex => Ex);
end Compilation_Unit_Bodies;
-------------------------
-- Defining_Containers --
-------------------------
function Defining_Containers
(The_Context : Asis.Context)
return Container_List
is
begin
Check_Validity (The_Context, Package_Name & "Defining_Containers");
return
(1 => Set_Container (First_Container_Id, Get_Cont_Id (The_Context)));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Defining_Containers");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Defining_Containers",
Ex => Ex);
end Defining_Containers;
-----------------------
-- Enclosing_Context --
-----------------------
function Enclosing_Context
(The_Container : Container)
return Asis.Context
is
begin
Check_Validity (The_Container, Package_Name & "Enclosing_Context");
if Is_Nil (The_Container) then
Set_Error_Status (Status => Value_Error,
Diagnosis => "Nil_Contaier in " & Package_Name
& "Enclosing_Context");
raise ASIS_Inappropriate_Container;
end if;
return Get_Cont (Encl_Cont_Id (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Enclosing_Context");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Enclosing_Context",
Ex => Ex);
end Enclosing_Context;
--------------
-- Is_Equal --
--------------
function Is_Equal
(Left : Container;
Right : Container)
return Boolean
is
begin
Check_Validity (Left, Package_Name & "Is_Equal");
Check_Validity (Right, Package_Name & "Is_Equal");
return Is_Equal (Enclosing_Context (Left), Enclosing_Context (Right));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => Package_Name & "Is_Equal");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Equal",
Ex => Ex);
end Is_Equal;
------------------
-- Is_Identical --
------------------
function Is_Identical
(Left : Container;
Right : Container)
return Boolean
is
begin
Check_Validity (Left, Package_Name & "Is_Identical");
Check_Validity (Right, Package_Name & "Is_Identical");
return Is_Equal (Left, Right) and then
Is_Equal (Enclosing_Context (Left), Enclosing_Context (Right));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => Package_Name & "Is_Identical");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Is_Identical",
Ex => Ex);
end Is_Identical;
-------------------------------
-- Library_Unit_Declarations --
-------------------------------
function Library_Unit_Declarations
(The_Container : Container)
return Asis.Compilation_Unit_List
is
begin
Check_Validity
(The_Container, Package_Name & "Library_Unit_Declarations");
if Is_Nil (The_Container) then
return Nil_Compilation_Unit_List;
end if;
return Library_Unit_Declarations (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => Package_Name & "Library_Unit_Declarations");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Library_Unit_Declarations",
Ex => Ex);
end Library_Unit_Declarations;
----------
-- Name --
----------
function Name
(The_Container : Container)
return Wide_String
is
begin
Check_Validity (The_Container, Package_Name & "Name");
if Is_Nil (The_Container) then
return Nil_Asis_Wide_String;
end if;
return Name (Enclosing_Context (The_Container));
exception
when ASIS_Inappropriate_Container =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => Package_Name & "Name");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => Package_Name & "Name",
Ex => Ex);
end Name;
end Asis.Ada_Environments.Containers;
|
eivindhstray/Sanntid | Ada | 3,846 | 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;
procedure Signal_Abort;
entry Wait_Until_Aborted;
private
Finished_Gate_Open : Boolean := False;
Aborted : Boolean := False;
Should_Commit : Boolean := True;
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;
end if;
if Finished'Count = 0 then
Finished_Gate_Open := False;
end if;
end Finished;
procedure Signal_Abort is
begin
Aborted := True;
end Signal_Abort;
------------------------------------------
-- 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;
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
Manager.Wait_Until_Aborted;
Num := Prev + 5;
Put_Line (" Worker" & Integer'Image(Initial) &
" comitting" & Integer'Image(Num));
-- only showing the commit message,
Manager.Finished;
then abort
begin
Num := Unreliable_Slow_Add(Num);
Manager.Finished;
Put_Line (" Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num));
exception
when Count_Failed =>
begin
Put_Line( "Worker " &Integer'Image( Initial ) & " aborted, thus triggering" );
Manager.Signal_Abort;
Manager.Finished;
end;
end;
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;
|
gspu/synth | Ada | 59,658 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Replicant.Platform;
with Ada.Containers.Vectors;
with Ada.Exceptions;
with GNAT.OS_Lib;
package body Replicant is
package AC renames Ada.Containers;
package EX renames Ada.Exceptions;
package OSL renames GNAT.OS_Lib;
package PLT renames Replicant.Platform;
-------------------
-- mount_point --
-------------------
function location (mount_base : String; point : folder) return String is
begin
case point is
when bin => return mount_base & root_bin;
when sbin => return mount_base & root_sbin;
when usr_bin => return mount_base & root_usr_bin;
when usr_games => return mount_base & root_usr_games;
when usr_include => return mount_base & root_usr_include;
when usr_lib => return mount_base & root_usr_lib;
when usr_lib32 => return mount_base & root_usr_lib32;
when usr_libdata => return mount_base & root_usr_libdata;
when usr_libexec => return mount_base & root_usr_libexec;
when usr_local => return mount_base & root_localbase;
when usr_sbin => return mount_base & root_usr_sbin;
when usr_share => return mount_base & root_usr_share;
when usr_src => return mount_base & root_usr_src;
when usr_x11r7 => return mount_base & root_X11R7;
when lib => return mount_base & root_lib;
when dev => return mount_base & root_dev;
when etc => return mount_base & root_etc;
when etc_default => return mount_base & root_etc_default;
when etc_mtree => return mount_base & root_etc_mtree;
when etc_rcd => return mount_base & root_etc_rcd;
when tmp => return mount_base & root_tmp;
when var => return mount_base & root_var;
when home => return mount_base & root_home;
when proc => return mount_base & root_proc;
when linux => return mount_base & root_linux;
when boot => return mount_base & root_boot;
when root => return mount_base & root_root;
when xports => return mount_base & root_xports;
when options => return mount_base & root_options;
when libexec => return mount_base & root_libexec;
when packages => return mount_base & root_packages;
when distfiles => return mount_base & root_distfiles;
when wrkdirs => return mount_base & root_wrkdirs;
when ccache => return mount_base & root_ccache;
end case;
end location;
--------------------
-- mount_target --
--------------------
function mount_target (point : folder) return String is
begin
case point is
when xports => return JT.USS (PM.configuration.dir_portsdir);
when options => return JT.USS (PM.configuration.dir_options);
when packages => return JT.USS (PM.configuration.dir_packages);
when distfiles => return JT.USS (PM.configuration.dir_distfiles);
when ccache => return JT.USS (PM.configuration.dir_ccache);
when others => return "ERROR";
end case;
end mount_target;
------------------------
-- get_master_mount --
------------------------
function get_master_mount return String is
begin
return JT.USS (PM.configuration.dir_buildbase) & "/" & reference_base;
end get_master_mount;
-----------------------
-- get_slave_mount --
-----------------------
function get_slave_mount (id : builders) return String is
begin
return JT.USS (PM.configuration.dir_buildbase) & "/" & slave_name (id);
end get_slave_mount;
------------------------------
-- procedure set_platform --
------------------------------
procedure set_platform is
begin
if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then
platform_type := freebsd;
elsif JT.equivalent (PM.configuration.operating_sys, "NetBSD") then
platform_type := netbsd;
elsif JT.equivalent (PM.configuration.operating_sys, "Linux") then
platform_type := linux;
elsif JT.equivalent (PM.configuration.operating_sys, "SunOS") then
platform_type := solaris;
else
platform_type := dragonfly;
end if;
end set_platform;
------------------
-- initialize --
------------------
procedure initialize (testmode : Boolean; num_cores : cpu_range)
is
mm : constant String := get_master_mount;
etcmp : constant String := "/etc/master.passwd";
command : constant String := "/usr/sbin/pwd_mkdb -p -d ";
begin
smp_cores := num_cores;
developer_mode := testmode;
support_locks := testmode and then Unix.env_variable_defined ("LOCK");
start_abnormal_logging;
if AD.Exists (mm) then
annihilate_directory_tree (mm);
end if;
AD.Create_Path (mm & "/etc");
case platform_type is
when dragonfly |
netbsd |
freebsd => create_base_passwd (mm);
when linux => null; -- master.passwd not used
when solaris => null; -- master.passwd not used
when unknown => null;
end case;
create_base_group (mm);
case platform_type is
when dragonfly | freebsd =>
execute (command & mm & "/etc " & mm & etcmp);
when netbsd =>
execute (command & mm & " " & mm & etcmp);
when others => null;
end case;
PLT.cache_port_variables (mm);
create_mtree_exc_preinst (mm);
create_mtree_exc_preconfig (mm);
end initialize;
----------------
-- finalize --
----------------
procedure finalize
is
mm : constant String := get_master_mount;
begin
if AD.Exists (mm) then
annihilate_directory_tree (mm);
end if;
stop_abnormal_logging;
end finalize;
--------------------
-- mount_nullfs --
--------------------
procedure mount_nullfs (target, mount_point : String;
mode : mount_mode := readonly)
is
cmd_freebsd : constant String := "/sbin/mount_nullfs";
cmd_dragonfly : constant String := "/sbin/mount_null";
cmd_solaris : constant String := "/usr/sbin/mount -F lofs";
cmd_linux : constant String := "/usr/bin/mount --bind";
command : JT.Text;
begin
if not AD.Exists (mount_point) then
raise scenario_unexpected with
"mount point " & mount_point & " does not exist";
end if;
if not AD.Exists (target) then
raise scenario_unexpected with
"mount target " & target & " does not exist";
end if;
case platform_type is
when freebsd => command := JT.SUS (cmd_freebsd);
when dragonfly |
netbsd => command := JT.SUS (cmd_dragonfly);
when solaris => command := JT.SUS (cmd_solaris);
when linux => command := JT.SUS (cmd_linux);
when unknown =>
raise scenario_unexpected with
"Mounting on unknown operating system";
end case;
case mode is
when readonly => JT.SU.Append (command, " -o ro");
when readwrite => null;
end case;
JT.SU.Append (command, " " & target);
JT.SU.Append (command, " " & mount_point);
execute (JT.USS (command));
end mount_nullfs;
-----------------------
-- mount_linprocfs --
-----------------------
procedure mount_linprocfs (mount_point : String)
is
cmd_freebsd : constant String :=
"/sbin/mount -t linprocfs linproc " & mount_point;
cmd_netbsd : constant String :=
"/sbin/mount_procfs -o linux procfs " & mount_point;
begin
-- DragonFly has lost it's Linux Emulation capability.
-- FreeBSD has it for both amd64 and i386
-- We should return if FreeBSD arch is not amd64 or i386, but synth
-- will not run on any other arches at the moment, so we don't have
-- to check (and we don't have that information yet anyway)
case platform_type is
when freebsd => execute (cmd_freebsd);
when netbsd => execute (cmd_netbsd);
when dragonfly => null;
when solaris => null;
when linux => null;
when unknown => null;
end case;
end mount_linprocfs;
------------------------------
-- set_mount_as_read_only --
------------------------------
procedure set_mount_as_read_only (mount_point : String)
is
-- synth only supports BSD these days
command : constant String := "/sbin/umount -u -o ro " & mount_point;
begin
execute (command);
exception
when others =>
TIO.Put_Line (abnormal_log, "Failed to set mount to read-only mode: " & mount_point);
end set_mount_as_read_only;
---------------
-- unmount --
---------------
procedure unmount (device_or_node : String)
is
bsd_command : constant String := "/sbin/umount -f " & device_or_node;
sol_command : constant String := "/usr/sbin/umount " & device_or_node;
lin_command : constant String := "/usr/bin/umount " & device_or_node;
begin
-- failure to unmount causes stderr squawks which messes up curses display
-- Just log it and ignore for now (Add robustness later)
case platform_type is
when dragonfly |
freebsd |
netbsd => execute (bsd_command);
when linux => execute (lin_command);
when solaris => execute (sol_command);
when unknown => null;
end case;
exception
when others =>
TIO.Put_Line (abnormal_log, "Failed to umount " & device_or_node);
TIO.Put_Line (abnormal_log, "Resetting " & device_or_node & " to read-only mode");
set_mount_as_read_only (device_or_node);
end unmount;
-----------------------
-- forge_directory --
-----------------------
procedure forge_directory (target : String) is
begin
AD.Create_Path (New_Directory => target);
exception
when failed : others =>
TIO.Put_Line (EX.Exception_Information (failed));
raise scenario_unexpected with
"failed to create " & target & " directory";
end forge_directory;
-------------------
-- mount_tmpfs --
-------------------
procedure mount_tmpfs (mount_point : String; max_size_M : Natural := 0)
is
cmd_freebsd : constant String := "/sbin/mount -t tmpfs";
cmd_dragonfly : constant String := "/sbin/mount_tmpfs";
cmd_solaris : constant String := "/sbin/mount -F tmpfs";
command : JT.Text;
begin
case platform_type is
when freebsd |
netbsd |
linux => command := JT.SUS (cmd_freebsd);
when dragonfly => command := JT.SUS (cmd_dragonfly);
when solaris => command := JT.SUS (cmd_solaris);
when unknown =>
raise scenario_unexpected with
"Mounting on unknown operating system";
end case;
if max_size_M > 0 then
JT.SU.Append (command, " -o size=" & JT.trim (max_size_M'Img) & "M");
end if;
case platform_type is
when solaris => JT.SU.Append (command, " swap " & mount_point);
when freebsd |
dragonfly |
netbsd |
linux => JT.SU.Append (command, " tmpfs " & mount_point);
when unknown => null;
end case;
execute (JT.USS (command));
end mount_tmpfs;
---------------------
-- mount_devices --
---------------------
procedure mount_devices (path_to_dev : String)
is
bsd_command : constant String :=
"/sbin/mount -t devfs devfs " & path_to_dev;
lin_command : constant String :=
"/usr/bin/mount --bind /dev " & path_to_dev;
begin
case platform_type is
when dragonfly |
freebsd => execute (bsd_command);
when linux => execute (lin_command);
when netbsd => mount_nullfs (target => "/dev",
mount_point => path_to_dev);
when solaris => null;
when unknown => null;
end case;
end mount_devices;
-----------------------
-- unmount_devices --
-----------------------
procedure unmount_devices (path_to_dev : String) is
begin
case platform_type is
when dragonfly |
freebsd |
linux => unmount (path_to_dev);
when netbsd => unmount (path_to_dev);
when solaris => null;
when unknown => null;
end case;
end unmount_devices;
--------------------
-- mount_procfs --
--------------------
procedure mount_procfs (path_to_proc : String)
is
bsd_command : constant String :=
"/sbin/mount -t procfs proc " & path_to_proc;
net_command : constant String :=
"/sbin/mount_procfs /proc " & path_to_proc;
lin_command : constant String :=
"/usr/bin/mount --bind /proc " & path_to_proc;
begin
case platform_type is
when dragonfly |
freebsd => execute (bsd_command);
when netbsd => execute (net_command);
when linux => execute (lin_command);
when solaris => null;
when unknown => null;
end case;
end mount_procfs;
---------------------
-- umount_procfs --
---------------------
procedure unmount_procfs (path_to_proc : String) is
begin
case platform_type is
when dragonfly |
freebsd |
netbsd |
linux => unmount (path_to_proc);
when solaris => null;
when unknown => null;
end case;
end unmount_procfs;
------------------
-- get_suffix --
------------------
function slave_name (id : builders) return String
is
id_image : constant String := Integer (id)'Img;
suffix : String := "SL00";
begin
if id < 10 then
suffix (4) := id_image (2);
else
suffix (3 .. 4) := id_image (2 .. 3);
end if;
return suffix;
end slave_name;
---------------------
-- folder_access --
---------------------
procedure folder_access (path : String; operation : folder_operation)
is
cmd_fallback : constant String := "/bin/chmod";
fback_lock : constant String := " 555 ";
fback_unlock : constant String := " 755 ";
command : JT.Text := JT.SUS (cmd_fallback);
begin
if not AD.Exists (path) then
return;
end if;
case operation is
when lock => JT.SU.Append (command, fback_lock & path);
when unlock => JT.SU.Append (command, fback_unlock & path);
end case;
execute (JT.USS (command));
end folder_access;
----------------------
-- create_symlink --
----------------------
procedure create_symlink (destination, symbolic_link : String)
is
bsd_command : constant String := "/bin/ln -s ";
lin_command : constant String := "/usr/bin/ln -s ";
begin
case platform_type is
when dragonfly |
freebsd |
netbsd |
solaris => execute (bsd_command & destination & " " & symbolic_link);
when linux => execute (lin_command & destination & " " & symbolic_link);
when unknown =>
raise scenario_unexpected with
"Executing ln on unknown operating system";
end case;
end create_symlink;
---------------------------
-- populate_var_folder --
---------------------------
procedure populate_var_folder (path : String)
is
bsd_command : constant String := "/usr/sbin/mtree -p " & path &
" -f /etc/mtree/BSD.var.dist -deqU";
net_command : constant String := "/usr/sbin/mtree -p " & path &
" -f /etc/mtree/special -deqU";
begin
case platform_type is
when dragonfly |
freebsd => silent_exec (bsd_command);
when netbsd => silent_exec (net_command);
when linux => null;
when solaris => null;
when unknown => null;
end case;
end populate_var_folder;
---------------
-- execute --
---------------
procedure execute (command : String)
is
Exit_Status : Integer;
output : JT.Text := Unix.piped_command (command, Exit_Status);
begin
if abn_log_ready and then not JT.IsBlank (output) then
TIO.Put_Line (abnormal_log, JT.USS (output));
end if;
if Exit_Status /= 0 then
raise scenario_unexpected with
command & " => failed with code" & Exit_Status'Img;
end if;
end execute;
-------------------
-- silent_exec --
-------------------
procedure silent_exec (command : String)
is
cmd_output : JT.Text;
success : Boolean := Unix.piped_mute_command (command, cmd_output);
begin
if not success then
if abn_log_ready and then not JT.IsBlank (cmd_output) then
TIO.Put_Line (abnormal_log, "piped_mute_command failure:");
TIO.Put_Line (abnormal_log, JT.USS (cmd_output));
end if;
raise scenario_unexpected with
command & " => failed (exit code not 0)";
end if;
end silent_exec;
------------------------------
-- internal_system_command --
------------------------------
function internal_system_command (command : String) return JT.Text
is
content : JT.Text;
status : Integer;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise scenario_unexpected with "cmd: " & command &
" (return code =" & status'Img & ")";
end if;
return content;
end internal_system_command;
-------------------------
-- create_base_group --
-------------------------
procedure create_base_group (path_to_mm : String)
is
subtype sysgroup is String (1 .. 8);
type groupset is array (1 .. 52) of sysgroup;
users : constant groupset :=
("wheel ", "daemon ", "kmem ", "sys ",
"tty ", "operator", "mail ", "bin ",
"news ", "man ", "games ", "staff ",
"sshd ", "smmsp ", "mailnull", "guest ",
"bind ", "proxy ", "authpf ", "_pflogd ",
"unbound ", "ftp ", "video ", "hast ",
"uucp ", "xten ", "dialer ", "network ",
"_sdpd ", "_dhcp ", "www ", "vknet ",
"nogroup ", "nobody ",
-- Unique to NetBSD
"wsrc ", "maildrop", "postfix ", "named ",
"ntpd ", "_rwhod ", "_proxy ", "_timedc ",
"_httpd ", "_mdnsd ", "_tests ", "_tcpdump",
"_tss ", "_gpio ", "_rtadvd ", "_unbound",
"utmp ", "users ");
group : TIO.File_Type;
live_file : TIO.File_Type;
keepit : Boolean;
target : constant String := path_to_mm & "/group";
live_origin : constant String := "/etc/group";
begin
TIO.Open (File => live_file, Mode => TIO.In_File, Name => live_origin);
TIO.Create (File => group, Mode => TIO.Out_File, Name => target);
while not TIO.End_Of_File (live_file) loop
keepit := False;
declare
line : String := TIO.Get_Line (live_file);
begin
for grpindex in groupset'Range loop
declare
grpcolon : String := JT.trim (users (grpindex)) & ":";
begin
if grpcolon'Length <= line'Length then
if grpcolon = line (1 .. grpcolon'Last) then
keepit := True;
exit;
end if;
end if;
end;
end loop;
if keepit then
TIO.Put_Line (group, line);
end if;
end;
end loop;
TIO.Close (live_file);
TIO.Close (group);
end create_base_group;
--------------------------
-- create_base_passwd --
--------------------------
procedure create_base_passwd (path_to_mm : String)
is
subtype syspasswd is String (1 .. 10);
type passwdset is array (1 .. 41) of syspasswd;
users : constant passwdset :=
("root ", "toor ", "daemon ", "operator ",
"bin ", "tty ", "kmem ", "mail ",
"games ", "news ", "man ", "sshd ",
"smmsp ", "mailnull ", "bind ", "unbound ",
"proxy ", "_pflogd ", "_dhcp ", "uucp ",
"xten ", "pop ", "auditdistd", "_sdpd ",
"www ", "_ypldap ", "hast ", "nobody ",
-- Unique to NetBSD
"postfix ", "named ", "ntpd ", "_rwhod ",
"_proxy ", "_timedc ", "_httpd ", "_mdnsd ",
"_tests ", "_tcpdump ", "_tss ", "_rtadvd ",
"_unbound ");
masterpwd : TIO.File_Type;
live_file : TIO.File_Type;
keepit : Boolean;
live_origin : constant String := "/etc/master.passwd";
target : constant String := path_to_mm & live_origin;
begin
TIO.Open (File => live_file, Mode => TIO.In_File, Name => live_origin);
TIO.Create (File => masterpwd, Mode => TIO.Out_File, Name => target);
while not TIO.End_Of_File (live_file) loop
keepit := False;
declare
line : String := TIO.Get_Line (live_file);
begin
for pwdindex in passwdset'Range loop
declare
pwdcolon : String := JT.trim (users (pwdindex)) & ":";
begin
if pwdcolon'Length <= line'Length then
if pwdcolon = line (1 .. pwdcolon'Last) then
keepit := True;
exit;
end if;
end if;
end;
end loop;
if keepit then
TIO.Put_Line (masterpwd, line);
end if;
end;
end loop;
TIO.Close (live_file);
TIO.Close (masterpwd);
end create_base_passwd;
--------------------
-- create_group --
--------------------
procedure create_group (path_to_etc : String)
is
mm : constant String := get_master_mount;
group : constant String := "/group";
begin
AD.Copy_File (Source_Name => mm & group,
Target_Name => path_to_etc & group);
end create_group;
---------------------
-- create_passwd --
---------------------
procedure create_passwd (path_to_etc : String)
is
mmetc : constant String := get_master_mount & "/etc";
maspwd : constant String := "/master.passwd";
passwd : constant String := "/passwd";
spwd : constant String := "/spwd.db";
pwd : constant String := "/pwd.db";
begin
AD.Copy_File (Source_Name => mmetc & passwd,
Target_Name => path_to_etc & passwd);
AD.Copy_File (Source_Name => mmetc & maspwd,
Target_Name => path_to_etc & maspwd);
AD.Copy_File (Source_Name => mmetc & spwd,
Target_Name => path_to_etc & spwd);
AD.Copy_File (Source_Name => mmetc & pwd,
Target_Name => path_to_etc & pwd);
end create_passwd;
------------------------
-- copy_mtree_files --
------------------------
procedure copy_mtree_files (path_to_mtree : String)
is
mtree : constant String := "/etc/mtree";
root : constant String := "/BSD.root.dist";
usr : constant String := "/BSD.usr.dist";
var : constant String := "/BSD.var.dist";
spec : constant String := "/special";
begin
case platform_type is
when dragonfly | freebsd =>
AD.Copy_File (Source_Name => mtree & root,
Target_Name => path_to_mtree & root);
AD.Copy_File (Source_Name => mtree & usr,
Target_Name => path_to_mtree & usr);
AD.Copy_File (Source_Name => mtree & var,
Target_Name => path_to_mtree & var);
when netbsd =>
AD.Copy_File (Source_Name => mtree & spec,
Target_Name => path_to_mtree & spec);
when solaris => null;
when linux => null;
when unknown => null;
end case;
end copy_mtree_files;
------------------------
-- create_make_conf --
------------------------
procedure create_make_conf (path_to_etc : String; skip_cwrappers : Boolean)
is
makeconf : TIO.File_Type;
profilemc : constant String := PM.synth_confdir & "/" &
JT.USS (PM.configuration.profile) & "-make.conf";
varcache : constant String := get_master_mount & "/varcache.conf";
profile : constant String := JT.USS (PM.configuration.profile);
mjnum : constant Integer := Integer (PM.configuration.jobs_limit);
begin
case software_framework is
when ports_collection =>
TIO.Create (File => makeconf,
Mode => TIO.Out_File,
Name => path_to_etc & "/make.conf");
TIO.Put_Line
(makeconf,
"SYNTHPROFILE=" & profile & LAT.LF &
"USE_PACKAGE_DEPENDS_ONLY=yes" & LAT.LF &
"PACKAGE_BUILDING=yes" & LAT.LF &
"BATCH=yes" & LAT.LF &
"PKG_CREATE_VERBOSE=yes" & LAT.LF &
"PORTSDIR=/xports" & LAT.LF &
"DISTDIR=/distfiles" & LAT.LF &
"WRKDIRPREFIX=/construction" & LAT.LF &
"PORT_DBDIR=/options" & LAT.LF &
"PACKAGES=/packages" & LAT.LF &
"MAKE_JOBS_NUMBER_LIMIT=" & JT.int2str (mjnum));
if developer_mode then
TIO.Put_Line (makeconf, "DEVELOPER=1");
end if;
if AD.Exists (JT.USS (PM.configuration.dir_ccache)) then
TIO.Put_Line (makeconf, "WITH_CCACHE_BUILD=yes");
TIO.Put_Line (makeconf, "CCACHE_DIR=/ccache");
end if;
when pkgsrc =>
TIO.Create (File => makeconf,
Mode => TIO.Out_File,
Name => path_to_etc & "/mk.conf");
-- Note there is no equivalent for PORT_DBDIR
-- Custom options must be set in <profile>-make.conf
TIO.Put_Line
(makeconf,
"SYNTHPROFILE=" & profile & LAT.LF &
"USE_PACKAGE_DEPENDS_ONLY=yes" & LAT.LF &
"PACKAGE_BUILDING=yes" & LAT.LF &
"ALLOW_VULNERABLE_PACKAGES=yes" & LAT.LF &
"PKG_CREATE_VERBOSE=yes" & LAT.LF &
"PKG_FORMAT=pkgng" & LAT.LF &
"PKGSRCDIR=/xports" & LAT.LF &
"DISTDIR=/distfiles" & LAT.LF &
"WRKOBJDIR=/construction" & LAT.LF &
"PACKAGES=/packages" & LAT.LF &
"MAKE_JOBS=" & JT.int2str (mjnum));
if skip_cwrappers then
TIO.Put_Line (makeconf, "USE_CWRAPPERS=no");
end if;
if developer_mode then
TIO.Put_Line (makeconf, "PKG_DEVELOPER=yes");
end if;
if AD.Exists (JT.USS (PM.configuration.dir_ccache)) then
TIO.Put_Line (makeconf, "PKGSRC_COMPILER=ccache gcc");
TIO.Put_Line (makeconf, "CCACHE_DIR=/ccache");
end if;
end case;
concatenate_makeconf (makeconf, profilemc);
concatenate_makeconf (makeconf, varcache);
TIO.Close (makeconf);
end create_make_conf;
------------------------
-- copy_resolv_conf --
------------------------
procedure copy_resolv_conf (path_to_etc : String)
is
original : constant String := "/etc/resolv.conf";
begin
if not AD.Exists (original) then
return;
end if;
AD.Copy_File (Source_Name => original,
Target_Name => path_to_etc & "/resolv.conf");
end copy_resolv_conf;
-----------------------
-- copy_rc_default --
-----------------------
procedure copy_rc_default (path_to_etc : String)
is
rc_default : constant String := "/defaults/rc.conf";
etc_rcconf : constant String := "/etc" & rc_default;
begin
if not AD.Exists (etc_rcconf) then
return;
end if;
AD.Copy_File (Source_Name => etc_rcconf,
Target_Name => path_to_etc & rc_default);
end copy_rc_default;
-------------------
-- copy_etc_rc --
-------------------
procedure copy_etc_rcsubr (path_to_etc : String)
is
rcsubr : constant String := "/rc.subr";
etc_rcsubr : constant String := "/etc" & rcsubr;
begin
if not AD.Exists (etc_rcsubr) then
return;
end if;
AD.Copy_File (Source_Name => etc_rcsubr,
Target_Name => path_to_etc & rcsubr);
end copy_etc_rcsubr;
---------------------
-- copy_ldconfig --
---------------------
procedure copy_ldconfig (path_to_etc : String)
is
ldconfig : constant String := "/rc.d/ldconfig";
etc_ldconfig : constant String := "/etc" & ldconfig;
begin
if not AD.Exists (etc_ldconfig) then
return;
end if;
AD.Copy_File (Source_Name => etc_ldconfig,
Target_Name => path_to_etc & ldconfig,
Form => "mode=copy,preserve=all_attributes");
end copy_ldconfig;
---------------------------
-- create_etc_services --
---------------------------
procedure create_etc_services (path_to_etc : String)
is
svcfile : TIO.File_Type;
begin
TIO.Create (File => svcfile,
Mode => TIO.Out_File,
Name => path_to_etc & "/services");
TIO.Put_Line (svcfile,
"ftp 21/tcp" & LAT.LF &
"ftp 21/udp" & LAT.LF &
"ssh 22/tcp" & LAT.LF &
"ssh 22/udp" & LAT.LF &
"http 80/tcp" & LAT.LF &
"http 80/udp" & LAT.LF &
"https 443/tcp" & LAT.LF &
"https 443/udp" & LAT.LF);
TIO.Close (svcfile);
end create_etc_services;
------------------------
-- create_etc_fstab --
------------------------
procedure create_etc_fstab (path_to_etc : String)
is
fstab : TIO.File_Type;
begin
TIO.Create (File => fstab,
Mode => TIO.Out_File,
Name => path_to_etc & "/fstab");
case platform_type is
when dragonfly | freebsd =>
TIO.Put_Line (fstab, "linproc /usr/compat/proc linprocfs rw 0 0");
when netbsd =>
TIO.Put_Line (fstab, "procfs /emul/linux/proc procfs ro,linux 0 0");
when linux | solaris => null;
when unknown => null;
end case;
TIO.Close (fstab);
end create_etc_fstab;
-------------------------
-- create_etc_shells --
-------------------------
procedure create_etc_shells (path_to_etc : String)
is
shells : TIO.File_Type;
begin
TIO.Create (File => shells,
Mode => TIO.Out_File,
Name => path_to_etc & "/shells");
case platform_type is
when dragonfly | freebsd =>
TIO.Put_Line (shells,
"/bin/sh" & LAT.LF &
"/bin/csh" & LAT.LF &
"/bin/tcsh" & LAT.LF);
when netbsd =>
TIO.Put_Line (shells,
"/bin/sh" & LAT.LF &
"/bin/csh" & LAT.LF &
"/bin/ksh" & LAT.LF);
when linux =>
TIO.Put_Line (shells,
"/bin/sh" & LAT.LF &
"/bin/bash" & LAT.LF &
"/sbin/nologin" & LAT.LF &
"/usr/bin/sh" & LAT.LF &
"/usr/bin/bash" & LAT.LF &
"/usr/sbin/nologin" & LAT.LF);
when solaris =>
TIO.Put_Line (shells,
"/bin/bash" & LAT.LF &
"/bin/csh" & LAT.LF &
"/bin/ksh" & LAT.LF &
"/bin/ksh93" & LAT.LF &
"/bin/sh" & LAT.LF &
"/bin/tcsh" & LAT.LF &
"/bin/zsh" & LAT.LF &
"/sbin/sh" & LAT.LF &
"/usr/bin/bash" & LAT.LF &
"/usr/bin/csh" & LAT.LF &
"/usr/bin/ksh" & LAT.LF &
"/usr/bin/ksh93" & LAT.LF &
"/usr/bin/sh" & LAT.LF &
"/usr/bin/tcsh" & LAT.LF &
"/usr/bin/zsh");
when unknown => null;
end case;
TIO.Close (shells);
end create_etc_shells;
------------------------
-- execute_ldconfig --
------------------------
procedure execute_ldconfig (id : builders)
is
smount : constant String := get_slave_mount (id);
bsd_command : constant String := chroot & smount &
" /sbin/ldconfig -m /lib /usr/lib";
lin_command : constant String := chroot & smount &
" /usr/sbin/ldconfig /lib /usr/lib";
begin
case platform_type is
when dragonfly | freebsd => execute (bsd_command);
when linux => execute (lin_command);
when netbsd | solaris => null;
when unknown => null;
end case;
end execute_ldconfig;
-------------------------------
-- copy_directory_contents --
-------------------------------
function copy_directory_contents (src_directory : String;
tgt_directory : String;
pattern : String) return Boolean
is
Search : AD.Search_Type;
Dir_Ent : AD.Directory_Entry_Type;
Filter : constant AD.Filter_Type := (AD.Ordinary_File => True,
AD.Special_File => False,
AD.Directory => False);
begin
if not AD.Exists (src_directory) then
return False;
end if;
AD.Create_Path (tgt_directory);
AD.Start_Search (Search => Search,
Directory => src_directory,
Filter => Filter,
Pattern => pattern);
while AD.More_Entries (Search => Search) loop
AD.Get_Next_Entry (Search => Search, Directory_Entry => Dir_Ent);
AD.Copy_File
(Source_Name => src_directory & "/" & AD.Simple_Name (Dir_Ent),
Target_Name => tgt_directory & "/" & AD.Simple_Name (Dir_Ent));
end loop;
return True;
exception
when others => return False;
end copy_directory_contents;
------------------------
-- build_repository --
------------------------
function build_repository (id : builders; sign_command : String := "")
return Boolean
is
smount : constant String := get_slave_mount (id);
command : constant String := chroot & smount & " " &
root_localbase & "/sbin/pkg-static repo /packages";
sc_cmd : constant String := host_pkg8 & " repo " & smount &
"/packages signing_command: ";
key_loc : constant String := "/etc/repo.key";
use_key : constant Boolean := AD.Exists (smount & key_loc);
use_cmd : constant Boolean := not JT.IsBlank (sign_command);
begin
if not PLT.standalone_pkg8_install (id) then
TIO.Put_Line ("Failed to install pkg-static in builder" & id'Img);
return False;
end if;
if use_key then
silent_exec (command & " " & key_loc);
elsif use_cmd then
silent_exec (sc_cmd & sign_command);
else
silent_exec (command);
end if;
return True;
exception
when quepaso : others =>
TIO.Put_Line (EX.Exception_Message (quepaso));
return False;
end build_repository;
---------------------------------
-- annihilate_directory_tree --
---------------------------------
procedure annihilate_directory_tree (tree : String)
is
command : constant String := "/bin/rm -rf " & tree;
begin
silent_exec (command);
exception
when others => null;
end annihilate_directory_tree;
--------------------
-- launch_slave --
--------------------
procedure launch_slave (id : builders; opts : slave_options)
is
function clean_mount_point (point : folder) return String;
slave_base : constant String := get_slave_mount (id);
slave_work : constant String := slave_base & "_work";
slave_local : constant String := slave_base & "_localbase";
slave_linux : constant String := slave_base & "_linux";
dir_system : constant String := JT.USS (PM.configuration.dir_system);
live_system : constant Boolean := (dir_system = "/");
function clean_mount_point (point : folder) return String is
begin
if live_system then
return location ("", point);
else
return location (dir_system, point);
end if;
end clean_mount_point;
begin
forge_directory (slave_base);
mount_tmpfs (slave_base);
for mnt in folder'Range loop
forge_directory (location (slave_base, mnt));
end loop;
for mnt in subfolder'Range loop
mount_nullfs (target => clean_mount_point (mnt),
mount_point => location (slave_base, mnt));
end loop;
folder_access (location (slave_base, home), lock);
folder_access (location (slave_base, root), lock);
mount_nullfs (mount_target (xports), location (slave_base, xports));
mount_nullfs (mount_target (options), location (slave_base, options));
mount_nullfs (mount_target (packages), location (slave_base, packages),
mode => readwrite);
mount_nullfs (mount_target (distfiles), location (slave_base, distfiles),
mode => readwrite);
if PM.configuration.tmpfs_workdir then
-- The mount cap of 16Gb was removed; rust was the latest port to bust it
mount_tmpfs (location (slave_base, wrkdirs));
else
forge_directory (slave_work);
mount_nullfs (slave_work, location (slave_base, wrkdirs), readwrite);
end if;
if not support_locks and then PM.configuration.tmpfs_localbase then
mount_tmpfs (slave_base & root_localbase, 12 * 1024);
else
forge_directory (slave_local);
mount_nullfs (slave_local, slave_base & root_localbase, readwrite);
end if;
if opts.need_procfs then
mount_procfs (path_to_proc => location (slave_base, proc));
end if;
-- special platform handling
case platform_type is
when dragonfly =>
declare
bootdir : String := clean_mount_point (boot);
begin
if AD.Exists (bootdir) then
mount_nullfs (target => bootdir,
mount_point => location (slave_base, boot));
mount_tmpfs (slave_base & root_lmodules, 100);
end if;
end;
declare
games : String := clean_mount_point (usr_games);
begin
if AD.Exists (games) then
mount_nullfs
(target => games,
mount_point => location (slave_base, usr_games));
end if;
end;
when freebsd =>
if opts.need_linprocfs then
if PM.configuration.tmpfs_localbase then
mount_tmpfs (slave_base & root_linux, 12 * 1024);
else
forge_directory (slave_linux);
mount_nullfs (target => slave_linux,
mount_point => slave_base & root_linux,
mode => readwrite);
end if;
forge_directory (slave_base & root_linproc);
mount_linprocfs (mount_point => slave_base & root_linproc);
end if;
declare
lib32 : String := clean_mount_point (usr_lib32);
begin
if AD.Exists (lib32) then
mount_nullfs
(target => lib32,
mount_point => location (slave_base, usr_lib32));
end if;
end;
declare
bootdir : String := clean_mount_point (boot);
begin
if AD.Exists (bootdir) then
mount_nullfs (target => bootdir,
mount_point => location (slave_base, boot));
mount_tmpfs (slave_base & root_boot_fw, 100);
mount_tmpfs (slave_base & root_kmodules, 100);
end if;
end;
declare
games : String := clean_mount_point (usr_games);
begin
if AD.Exists (games) then
mount_nullfs
(target => games,
mount_point => location (slave_base, usr_games));
end if;
end;
when netbsd =>
declare
x11_dir : String := clean_mount_point (usr_x11r7);
begin
if AD.Exists (x11_dir) then
mount_nullfs
(target => x11_dir,
mount_point => location (slave_base, usr_x11r7));
end if;
end;
when linux => null; -- for now
when solaris => null; -- for now
when unknown => null;
end case;
declare
srcdir : String := clean_mount_point (usr_src);
begin
if AD.Exists (srcdir) then
mount_nullfs (srcdir, location (slave_base, usr_src));
if AD.Exists (srcdir & "/sys") then
create_symlink (destination => "usr/src/sys",
symbolic_link => slave_base & "/sys");
end if;
end if;
end;
if AD.Exists (mount_target (ccache)) then
mount_nullfs (mount_target (ccache), location (slave_base, ccache),
mode => readwrite);
end if;
mount_devices (location (slave_base, dev));
populate_var_folder (location (slave_base, var));
copy_mtree_files (location (slave_base, etc_mtree));
copy_rc_default (location (slave_base, etc));
copy_resolv_conf (location (slave_base, etc));
create_make_conf (location (slave_base, etc), opts.skip_cwrappers);
create_passwd (location (slave_base, etc));
create_group (location (slave_base, etc));
create_etc_services (location (slave_base, etc));
create_etc_shells (location (slave_base, etc));
create_etc_fstab (location (slave_base, etc));
copy_etc_rcsubr (location (slave_base, etc));
copy_ldconfig (location (slave_base, etc));
execute_ldconfig (id);
exception
when hiccup : others => EX.Reraise_Occurrence (hiccup);
end launch_slave;
---------------------
-- destroy_slave --
---------------------
procedure destroy_slave (id : builders; opts : slave_options)
is
slave_base : constant String := get_slave_mount (id);
slave_work : constant String := slave_base & "_work";
slave_local : constant String := slave_base & "_localbase";
slave_linux : constant String := slave_base & "_linux";
dir_system : constant String := JT.USS (PM.configuration.dir_system);
begin
unmount (slave_base & root_localbase);
if support_locks or else not PM.configuration.tmpfs_localbase then
-- We can't use AD.Delete_Tree because it skips directories
-- starting with "." (pretty useless then)
annihilate_directory_tree (slave_local);
end if;
unmount (location (slave_base, wrkdirs));
if not PM.configuration.tmpfs_workdir then
annihilate_directory_tree (slave_work);
end if;
if AD.Exists (location (dir_system, usr_src)) then
unmount (location (slave_base, usr_src));
end if;
if AD.Exists (mount_target (ccache)) then
unmount (location (slave_base, ccache));
end if;
case platform_type is
when dragonfly =>
if AD.Exists (location (dir_system, boot)) then
unmount (slave_base & root_lmodules);
unmount (location (slave_base, boot));
end if;
if AD.Exists (location (dir_system, usr_games)) then
unmount (location (slave_base, usr_games));
end if;
when freebsd =>
if opts.need_linprocfs then
unmount (slave_base & root_linproc);
unmount (slave_base & root_linux);
if not PM.configuration.tmpfs_localbase then
annihilate_directory_tree (slave_linux);
end if;
end if;
if AD.Exists (location (dir_system, usr_lib32)) then
unmount (location (slave_base, usr_lib32));
end if;
if AD.Exists (location (dir_system, boot)) then
unmount (slave_base & root_kmodules);
unmount (slave_base & root_boot_fw);
unmount (location (slave_base, boot));
end if;
if AD.Exists (location (dir_system, usr_games)) then
unmount (location (slave_base, usr_games));
end if;
when netbsd =>
if AD.Exists (location (dir_system, usr_x11r7)) then
unmount (location (slave_base, usr_x11r7));
end if;
when linux => null;
when solaris => null;
when unknown => null;
end case;
if opts.need_procfs then
unmount_procfs (location (slave_base, proc));
end if;
unmount_devices (location (slave_base, dev));
unmount (location (slave_base, xports));
unmount (location (slave_base, options));
unmount (location (slave_base, packages));
unmount (location (slave_base, distfiles));
for mnt in subfolder'Range loop
unmount (location (slave_base, mnt));
end loop;
unmount (slave_base);
annihilate_directory_tree (slave_base);
exception
when hiccup : others => EX.Reraise_Occurrence (hiccup);
end destroy_slave;
--------------------------
-- synth_mounts_exist --
--------------------------
function synth_mounts_exist return Boolean
is
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
begin
comres := internal_system_command (PLT.df_command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if JT.contains (topline, buildbase) then
return True;
end if;
end loop;
return False;
exception
when others =>
return True;
end synth_mounts_exist;
-----------------------------
-- clear_existing_mounts --
-----------------------------
function clear_existing_mounts return Boolean
is
package crate is new AC.Vectors (Index_Type => Positive,
Element_Type => JT.Text,
"=" => JT.SU."=");
procedure annihilate (cursor : crate.Cursor);
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
mindex : Natural;
mlength : Natural;
mpoints : crate.Vector;
procedure annihilate (cursor : crate.Cursor)
is
mountpoint : constant String := JT.USS (crate.Element (cursor));
begin
unmount (mountpoint);
if AD.Exists (mountpoint) then
AD.Delete_Directory (mountpoint);
end if;
exception
when others => null;
end annihilate;
begin
comres := internal_system_command (PLT.df_command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if JT.contains (topline, buildbase) then
mindex := JT.SU.Index (topline, buildbase);
mlength := JT.SU.Length (topline);
mpoints.Append (JT.SUS (JT.SU.Slice (topline, mindex, mlength)));
end if;
end loop;
mpoints.Reverse_Iterate (Process => annihilate'Access);
if synth_mounts_exist then
return False;
end if;
-- No need to remove empty dirs, the upcoming run will do that.
return True;
end clear_existing_mounts;
----------------------------
-- disk_workareas_exist --
----------------------------
function disk_workareas_exist return Boolean
is
Search : AD.Search_Type;
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
result : Boolean := False;
begin
if not AD.Exists (buildbase) then
return False;
end if;
AD.Start_Search (Search => Search,
Directory => buildbase,
Filter => (AD.Directory => True, others => False),
Pattern => "SL*_*");
result := AD.More_Entries (Search => Search);
return result;
end disk_workareas_exist;
--------------------------------
-- clear_existing_workareas --
--------------------------------
function clear_existing_workareas return Boolean
is
Search : AD.Search_Type;
Dir_Ent : AD.Directory_Entry_Type;
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
begin
AD.Start_Search (Search => Search,
Directory => buildbase,
Filter => (AD.Directory => True, others => False),
Pattern => "SL*_*");
while AD.More_Entries (Search => Search) loop
AD.Get_Next_Entry (Search => Search, Directory_Entry => Dir_Ent);
declare
target : constant String := buildbase & "/" &
AD.Simple_Name (Dir_Ent);
begin
annihilate_directory_tree (target);
end;
end loop;
return True;
exception
when others => return False;
end clear_existing_workareas;
----------------------------
-- concatenate_makeconf --
----------------------------
procedure concatenate_makeconf (makeconf_handle : TIO.File_Type;
target_name : String)
is
fragment : TIO.File_Type;
begin
if AD.Exists (target_name) then
TIO.Open (File => fragment, Mode => TIO.In_File, Name => target_name);
while not TIO.End_Of_File (fragment) loop
declare
Line : String := TIO.Get_Line (fragment);
begin
TIO.Put_Line (makeconf_handle, Line);
end;
end loop;
TIO.Close (fragment);
end if;
exception
when others => null;
end concatenate_makeconf;
---------------------------------------
-- write_common_mtree_exclude_base --
---------------------------------------
procedure write_common_mtree_exclude_base (mtreefile : TIO.File_Type) is
begin
TIO.Put_Line
(mtreefile,
"./bin" & LAT.LF
& "./boot" & LAT.LF
& "./ccache" & LAT.LF
& "./compat/linux/proc" & LAT.LF
& "./construction" & LAT.LF
& "./dev" & LAT.LF
& "./distfiles" & LAT.LF
& "./lib" & LAT.LF
& "./libexec" & LAT.LF
& "./home" & LAT.LF
& "./options" & LAT.LF
& "./packages" & LAT.LF
& "./proc" & LAT.LF
& "./root" & LAT.LF
& "./sbin" & LAT.LF
& "./tmp" & LAT.LF
& "./usr/bin" & LAT.LF
& "./usr/include" & LAT.LF
& "./usr/lib" & LAT.LF
& "./usr/lib32" & LAT.LF
& "./usr/libdata" & LAT.LF
& "./usr/libexec" & LAT.LF
& "./usr/sbin" & LAT.LF
& "./usr/share" & LAT.LF
& "./usr/src" & LAT.LF
& "./var/db/fontconfig" & LAT.LF
& "./var/run" & LAT.LF
& "./var/tmp" & LAT.LF
& "./xports"
);
end write_common_mtree_exclude_base;
--------------------------------
-- write_preinstall_section --
--------------------------------
procedure write_preinstall_section (mtreefile : TIO.File_Type) is
begin
case software_framework is
when ports_collection =>
TIO.Put_Line
(mtreefile,
"./etc/group" & LAT.LF
& "./etc/make.conf" & LAT.LF
& "./etc/make.conf.bak" & LAT.LF
& "./etc/make.nxb.conf" & LAT.LF
& "./etc/master.passwd" & LAT.LF
& "./etc/passwd" & LAT.LF
& "./etc/pwd.db" & LAT.LF
& "./etc/shells" & LAT.LF
& "./etc/spwd.db" & LAT.LF
& "./var/db" & LAT.LF
& "./var/log" & LAT.LF
& "./var/mail" & LAT.LF
& "./var/spool" & LAT.LF
& "./var/tmp" & LAT.LF
& "./usr/local/etc/gconf/gconf.xml.defaults/%gconf-tree*.xml" & LAT.LF
& "./usr/local/lib/gio/modules/giomodule.cache" & LAT.LF
& "./usr/local/info/dir" & LAT.LF
& "./usr/local/info" & LAT.LF
& "./usr/local/*/info/dir" & LAT.LF
& "./usr/local/*/info" & LAT.LF
& "./usr/local/*/ls-R" & LAT.LF
& "./usr/local/share/octave/octave_packages" & LAT.LF
& "./usr/local/share/xml/catalog.ports"
);
when pkgsrc =>
TIO.Put_Line
(mtreefile,
"./etc/group" & LAT.LF
& "./etc/mk.conf" & LAT.LF
& "./etc/master.passwd" & LAT.LF
& "./etc/passwd" & LAT.LF
& "./etc/pwd.db" & LAT.LF
& "./etc/shells" & LAT.LF
& "./etc/spwd.db" & LAT.LF
& "./var/db" & LAT.LF
& "./var/log" & LAT.LF
& "./var/mail" & LAT.LF
& "./var/spool" & LAT.LF
& "./var/tmp" & LAT.LF
& "./usr/pkg/etc/gconf/gconf.xml.defaults/%gconf-tree*.xml" & LAT.LF
& "./usr/pkg/lib/gio/modules/giomodule.cache" & LAT.LF
& "./usr/pkg/info/dir" & LAT.LF
& "./usr/pkg/info" & LAT.LF
& "./usr/pkg/*/info/dir" & LAT.LF
& "./usr/pkg/*/info" & LAT.LF
& "./usr/pkg/*/ls-R" & LAT.LF
& "./usr/pkg/share/xml/catalog.ports"
);
end case;
end write_preinstall_section;
--------------------------------
-- create_mtree_exc_preinst --
--------------------------------
procedure create_mtree_exc_preinst (path_to_mm : String)
is
mtreefile : TIO.File_Type;
filename : constant String := path_to_mm & "/mtree.prestage.exclude";
begin
TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename);
write_common_mtree_exclude_base (mtreefile);
write_preinstall_section (mtreefile);
TIO.Close (mtreefile);
end create_mtree_exc_preinst;
----------------------------------
-- create_mtree_exc_preconfig --
----------------------------------
procedure create_mtree_exc_preconfig (path_to_mm : String)
is
mtreefile : TIO.File_Type;
filename : constant String := path_to_mm & "/mtree.preconfig.exclude";
begin
TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename);
write_common_mtree_exclude_base (mtreefile);
TIO.Close (mtreefile);
end create_mtree_exc_preconfig;
------------------------
-- jail_environment --
------------------------
function jail_environment return JT.Text is
begin
return builder_env;
end jail_environment;
--------------------------------------
-- boot_modules_directory_missing --
--------------------------------------
function boot_modules_directory_missing return Boolean is
begin
if JT.equivalent (PM.configuration.operating_sys, "DragonFly") then
declare
sroot : constant String := JT.USS (PM.configuration.dir_system);
bootdir : constant String := sroot & root_boot;
modsdir : constant String := sroot & root_lmodules;
begin
if AD.Exists (bootdir) and then not AD.Exists (modsdir) then
return True;
end if;
end;
end if;
if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then
declare
sroot : constant String := JT.USS (PM.configuration.dir_system);
bootdir : constant String := sroot & root_boot;
modsdir : constant String := sroot & root_kmodules;
begin
if AD.Exists (bootdir) and then not AD.Exists (modsdir) then
return True;
end if;
end;
end if;
return False;
end boot_modules_directory_missing;
------------------------------
-- start_abnormal_logging --
------------------------------
procedure start_abnormal_logging
is
logpath : constant String := JT.USS (PM.configuration.dir_logs)
& "/" & abnormal_cmd_logname;
begin
if AD.Exists (logpath) then
AD.Delete_File (logpath);
end if;
TIO.Create (File => abnormal_log,
Mode => TIO.Out_File,
Name => logpath);
abn_log_ready := True;
exception
when others => abn_log_ready := False;
end start_abnormal_logging;
-----------------------------
-- stop_abnormal_logging --
-----------------------------
procedure stop_abnormal_logging is
begin
if abn_log_ready then
TIO.Close (abnormal_log);
end if;
end stop_abnormal_logging;
end Replicant;
|
annexi-strayline/AURA | Ada | 4,169 | ads | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This needs to be in its own package because we want to be able to initialize
-- constants in the Registrary.Last_Run with these functions, and the body
-- needs to be "seen" if we try to call a procedure that we define in the same
-- package.
with Registrar.Subsystems;
with Registrar.Library_Units;
package Registrar.Last_Run_Store is
function Load_Last_Run return Subsystems.Subsystem_Sets.Set;
function Load_Last_Run return Library_Units.Library_Unit_Sets.Set;
procedure Store_Current_Run;
-- Overwrites the backing store with the current Registry (All_Library_Units
-- and All_Subsystems). The Last_Run sets are not affected.
end Registrar.Last_Run_Store;
|
kjseefried/paraffin-examples | Ada | 1,048 | adb | pragma Profile (No_Implementation_Extensions);
with Parallel.Loops.Work_Seeking;
procedure Example is
N : constant Positive := 100_000;
type State_Type is null record;
type State_Vector_Type is array (1 .. N) of State_Type;
package Integer_Loops is new Parallel.Loops
(Iteration_Index_Type => Integer);
package Work_Seeking_Loops is
new Integer_Loops.Work_Seeking;
use Work_Seeking_Loops;
WM : Work_Seeking_Manager;
X0 : array (1 .. N) of State_Vector_Type;
X1 : array (1 .. N) of State_Vector_Type;
procedure Do_Partition (First, Last : Integer) is
-- normally this is much more complex
function F (I : Integer) return State_Vector_Type is
begin
return X0 (I);
end F;
begin
for I in First .. Last loop
X1 (I) := F (I);
end loop;
end Do_Partition;
begin
WM.Execute_Parallel_Loop
(From => X0'First,
To => X0'Last,
Process => Do_Partition'Access);
end Example;
|
charlie5/lace | Ada | 3,174 | adb | with
ada.unchecked_Deallocation;
package body gel.Keyboard.local
is
package body Forge
is
function to_Keyboard (of_Name : in String) return Item
is
begin
return Self : constant Item := (lace.Subject.local.Forge.to_Subject (of_Name)
with no_Modifiers)
do
null;
end return;
end to_Keyboard;
function new_Keyboard (of_Name : in String) return View
is
begin
return new Item' (to_Keyboard (of_Name));
end new_Keyboard;
end Forge;
procedure free (Self : in out View)
is
procedure deallocate is new ada.unchecked_Deallocation (Item'Class, View);
begin
Self.destroy;
deallocate (Self);
end free;
--------------
--- Attributes
--
overriding
function Modifiers (Self : in Item) return Modifier_Set
is
begin
return Self.Modifiers;
end Modifiers;
--------------
--- Operations
--
overriding
procedure emit_key_press_Event (Self : in out Item; Key : in keyboard.Key;
key_Code : in Integer)
is
the_key_press_Event : key_press_Event;
begin
case Key is
when LSHIFT => Self.Modifiers (LSHIFT) := True;
when RSHIFT => Self.Modifiers (RSHIFT) := True;
when LCTRL => Self.Modifiers (LCTRL) := True;
when RCTRL => Self.Modifiers (RCTRL) := True;
when LALT => Self.Modifiers (LALT) := True;
when RALT => Self.Modifiers (RALT) := True;
when LMETA => Self.Modifiers (LMETA) := True;
when RMETA => Self.Modifiers (RMETA) := True;
when NUMLOCK => Self.Modifiers (NUM) := True;
when CAPSLOCK => Self.Modifiers (CAPS) := True;
when MODE => Self.Modifiers (MODE) := True;
when others => null;
end case;
the_key_press_Event := ((Key, Self.Modifiers), key_Code);
Self.emit (the_key_press_Event);
end emit_key_press_Event;
overriding
procedure emit_key_release_Event (Self : in out Item; Key : in keyboard.Key)
is
the_key_release_Event : key_release_Event;
begin
case Key is
when LSHIFT => Self.Modifiers (LSHIFT) := False;
when RSHIFT => Self.Modifiers (RSHIFT) := False;
when LCTRL => Self.Modifiers (LCTRL) := False;
when RCTRL => Self.Modifiers (RCTRL) := False;
when LALT => Self.Modifiers (LALT) := False;
when RALT => Self.Modifiers (RALT) := False;
when LMETA => Self.Modifiers (LMETA) := False;
when RMETA => Self.Modifiers (RMETA) := False;
when NUMLOCK => Self.Modifiers (NUM) := False;
when CAPSLOCK => Self.Modifiers (CAPS) := False;
when MODE => Self.Modifiers (MODE) := False;
when others => null;
end case;
the_key_release_Event := (modified_Key => (Key, Self.Modifiers));
Self.emit (the_key_release_Event);
end emit_key_release_Event;
end gel.Keyboard.local;
|
AdaCore/Ada_Drivers_Library | Ada | 2,786 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, 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 MicroBit.IOs;
with MicroBit.Time;
procedure Main is
begin
-- Loop forever
loop
-- Turn on the LED connected to pin 0
MicroBit.IOs.Set (0, True);
-- Wait 500 milliseconds
MicroBit.Time.Delay_Ms (500);
-- Turn off the LED connected to pin 0
MicroBit.IOs.Set (0, False);
-- Wait 500 milliseconds
MicroBit.Time.Delay_Ms (500);
end loop;
end Main;
|
reznikmm/matreshka | Ada | 3,828 | 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_Attributes.FO.Margin_Right;
package ODF.DOM.Attributes.FO.Margin_Right.Internals is
function Create
(Node : Matreshka.ODF_Attributes.FO.Margin_Right.FO_Margin_Right_Access)
return ODF.DOM.Attributes.FO.Margin_Right.ODF_FO_Margin_Right;
function Wrap
(Node : Matreshka.ODF_Attributes.FO.Margin_Right.FO_Margin_Right_Access)
return ODF.DOM.Attributes.FO.Margin_Right.ODF_FO_Margin_Right;
end ODF.DOM.Attributes.FO.Margin_Right.Internals;
|
vasil-sd/ada-tlsf | Ada | 625 | ads | package TLSF.Config
with SPARK_Mode, Pure, Preelaborate is
Max_Block_Size_Log2 : constant := 29; -- max Block is about 512Mb
SL_Index_Count_Log2 : constant := 6;
Align_Size_Log2 : constant := 3; -- for 32bit system: 2
FL_Index_Max : constant := Max_Block_Size_Log2 - 1;
Align_Size : constant := 2 ** Align_Size_Log2;
SL_Index_Count : constant := 2 ** SL_Index_Count_Log2;
FL_Index_Shift : constant := SL_Index_Count_Log2;
FL_Index_Count : constant := FL_Index_Max - FL_Index_Shift + 1;
Small_Block_Size : constant := 2 ** FL_Index_Shift;
end TLSF.Config;
|
Hamster-Furtif/JeremyPlusPlus | Ada | 13,704 | adb | with ada.Characters.Handling, utils, ada.Text_IO, ada.Integer_Text_IO, Ada.Calendar, botIO, montecarlo;
use ada.Characters.Handling, utils, ada.Text_IO, ada.Integer_Text_IO, Ada.Calendar, botIO, montecarlo;
package body utils is
procedure addToSet(card : in T_card ; set : in out T_set) is
begin
set.set(set.size) := card;
set.size := set.size + 1;
end addToSet;
procedure emptySet(set :in out T_set)is
begin
set.size := 0;
end emptySet;
function getBestCombination(set : in T_set) return T_combination is
--Pour le full
brelan_trouve : Boolean := false;
index_brelan : Natural;
--Pour les paires
n_paires : Natural := 0;
--Pour la suite et la couleur
suite_trouvee : Boolean:= true;
combination : T_combination;
cards : T_set := set;
hauteur : Integer := 0;
quit : Boolean := false;
begin
sortSet(cards); --Trie du plus grand au plus petit
if cards.size >= 4 then
--Quinte flush (royale)
for i in 0..(cards.size-2) loop
if cards.set(i).colour /= cards.set(i+1).colour or cards.set(i).rank /= cards.set(i+1).rank + 1 then
suite_trouvee := false;
end if;
end loop;
if(suite_trouvee) then
if cards.set(0).rank = 12 then
combination.comb_type:=T_combination_type'Value("quinte_f_r");
combination.cards := cards;
return combination;
else
combination.comb_type:=T_combination_type'Value("quinte_f");
return combination;
end if;
else
suite_trouvee := true;
end if;
--Carre ?
for i in 0..(cards.size-3) loop
if cards.set(i).rank = cards.set(i+3).rank then
combination.comb_type:=T_combination_type'Value("carre");
for k in i..i+3 loop
addToSet(cards.set(k),combination.cards);
end loop;
for i in 1..cards.size loop
if not cardInSet(cards.set(i),combination.cards) then
addToSet(cards.set(i), combination.cards);
end if;
end loop;
return combination;
end if;
end loop;
--Full ?
for i in 0..cards.size loop
if cards.set(i).rank = cards.set(i+2).rank then
brelan_trouve := true;
index_brelan := i;
end if;
end loop;
if brelan_trouve then
if (index_brelan = 0 and cards.set(3).rank = cards.set(4).rank)
or (index_brelan = 2 and cards.set(0).rank = cards.set(1).rank)
then
combination.comb_type:= T_combination_type'Value("full");
return combination;
end if;
end if;
--Couleur (flush)
for i in 0..(cards.size-2) loop
if cards.set(i).colour /= cards.set(i+1).colour then
suite_trouvee := false;
end if;
end loop;
if(suite_trouvee) then
combination.comb_type:= T_combination_type'Value("couleur");
return combination;
else
suite_trouvee := true;
end if;
--Suite
for i in 0..(cards.size-2) loop
if cards.set(i).rank /= cards.set(i+1).rank + 1 then
suite_trouvee := false;
end if;
end loop;
if(suite_trouvee) then
combination.comb_type:= T_combination_type'Value("suite");
return combination;
else
suite_trouvee := true;
end if;
end if; --Fin de "au moins 4 cartes"
--Brelan
for i in 0..(cards.size-3) loop
if cards.set(i).rank = cards.set(i+2).rank then
combination.comb_type:= T_combination_type'Value("brelan");
addToSet(cards.set(i),combination.cards);
addToSet(cards.set(i+1),combination.cards);
addToSet(cards.set(i+2),combination.cards);
for i in 1..cards.size loop
if not cardInSet(cards.set(i),combination.cards) then
addToSet(cards.set(i), combination.cards);
end if;
end loop;
return combination;
end if;
end loop;
--Paire(s)
for i in 0..(cards.size-2) loop
if cards.set(i).rank = cards.set(i+1).rank then
n_paires := n_paires + 1;
addToSet(cards.set(i),combination.cards);
addToSet(cards.set(i+1),combination.cards);
end if;
end loop;
if(n_paires = 1) then
combination.comb_type:= T_combination_type'Value("paire");
for i in 1..cards.size loop
if not cardInSet(cards.set(i),combination.cards) then
addToSet(cards.set(i), combination.cards);
end if;
end loop;
return combination;
elsif(n_paires >= 2) then
combination.comb_type:= T_combination_type'Value("paire_2");
for i in 1..cards.size loop
if not cardInSet(cards.set(i),combination.cards) then
addToSet(cards.set(i), combination.cards);
end if;
end loop;
return combination;
end if;
combination.comb_type:= T_combination_type'Value("none");
combination.cards := cards;
return combination;
end getBestCombination;
procedure sortSet(set : in out T_set) is
step : Boolean := True;
temp : T_card;
index : Integer := set.size;
BEGIN
LOOP
step := True;
FOR I IN 0..index-2 LOOP
IF set.set(I).rank <set.set(I+1).rank THEN
temp := set.set(I);
set.set(I) := set.set(I+1);
set.set(I+1):=temp;
step := False;
END IF;
END LOOP;
exit when step;
End LOOP;
end sortSet;
function ">"(L : T_combination ; R : T_combination) return boolean is
begin
if(L.comb_type = R.comb_type) then
case L.comb_type is
when none =>
for i in 1..L.cards.size loop
if get_rank(L.cards.set(i))>get_rank(R.cards.set(i)) then return True;
elsif get_rank(L.cards.set(i))<get_rank(R.cards.set(i)) then return False;
end if;
end loop;
when paire =>
if L.cards.set(0).rank>R.cards.set(0).rank then return True;
elsif L.cards.set(0).rank<R.cards.set(0).rank then return False;
else
for i in 1..L.cards.size loop
if get_rank(L.cards.set(i))>get_rank(R.cards.set(i)) then return True;
elsif get_rank(L.cards.set(i))<get_rank(R.cards.set(i)) then return False;
end if;
end loop;
end if;
when others => return False;
--none, paire, paire_2, brelan, suite, couleur, full, carre, quinte_f, quinte_f_r
end case;
end if;
for k in T_combination_type loop
if L.comb_type = k then return False; end if;
if R.comb_type = k then return True; end if;
end loop;
return false;
end ">";
function "+"(L : T_set; R : T_set) return T_set is
total : T_set;
begin
emptySet(total);
for i in 0..L.size-1 loop
addToSet(L.set(i), total);
end loop;
for i in 0..R.size-1 loop
addToSet(R.set(i), total);
end loop;
return total;
end "+";
function "+"(L : T_card; R: T_card) return T_set is
s: T_set;
begin
addToSet(L,s);addToSet(R,s);
return s;
end "+";
function "+"(L : T_set; R: T_card) return T_set is
s: T_set :=L;
begin
addToSet(R,s);
return s;
end "+";
function "+"(L : T_card; R: T_set) return T_set is
s: T_set :=R;
begin
addToSet(L,s);
return s;
end "+";
procedure initGame(game : in out T_game) is
begin
--emptySet(game.history);
game.round := 0;
emptySet(game.table);
emptySet(game.hand);
end initGame;
function cardInSet(card : in T_card; set : in T_set) return Boolean is
begin
for i in 0..get_size(set)-1 loop
if get_card(set, i) = card then return True; end if;
end loop;
return false;
end cardInSet;
function get_settings (game : in T_game) return T_settings is
begin
return game.settings;
end get_settings;
function get_round(game : in T_game) return Integer is
begin
return game.round;
end get_round;
function get_pot(game : in T_game) return Integer is
begin
return game.pot;
end get_pot;
function get_table(game : in T_game) return T_set is
begin
return game.table;
end get_table;
function get_hand(game : in T_game) return T_set is
begin
return game.hand;
end get_hand;
function get_op_hand(game : in T_game) return T_set is
begin
return game.op_hand;
end get_op_hand;
function get_my_money(game : in T_game) return Integer is
begin
return game.my_money;
end get_my_money;
function get_op_money(game : in T_game) return Integer is
begin
return game.op_money;
end get_op_money;
function get_button_is_mine(game : in T_game) return Boolean is
begin
return game.button_is_mine;
end get_button_is_mine;
function get_small_blind(game : in T_game) return Integer is
begin
return game.small_blind;
end get_small_blind;
function get_big_blind(game : in T_game) return Integer is
begin
return game.big_blind;
end get_big_blind;
function get_amount_to_call(game : in T_game) return Integer is
begin
return game.amount_to_call;
end get_amount_to_call;
function get_min_bet(game : in T_game) return Integer is
begin
return game.min_bet;
end get_min_bet;
procedure set_settings(game : in out T_game; val : in T_settings) is
begin
game.settings := val;
end set_settings;
procedure set_round(game : in out T_game; val : in Integer) is
begin
game.round := val;
end set_round;
procedure set_pot(game : in out T_game; val : in Integer) is
begin
game.pot := val;
end set_pot;
procedure set_table(game : in out T_game; val : in T_set) is
begin
game.table := val;
end set_table;
procedure set_hand(game : in out T_game; val : in T_set) is
begin
game.hand := val;
end set_hand;
procedure set_op_hand(game : in out T_game; val : in T_set) is
begin
game.op_hand := val;
end set_op_hand;
procedure set_my_money(game : in out T_game; val : in Integer) is
begin
game.my_money := val;
end set_my_money;
procedure set_op_money(game : in out T_game; val : in Integer) is
begin
game.op_money := val;
end set_op_money;
procedure set_button_is_mine(game : in out T_game; val : in Boolean) is
begin
game.button_is_mine := val;
end set_button_is_mine;
procedure set_small_blind(game : in out T_game; val : in Integer) is
begin
game.small_blind := val;
end set_small_blind;
procedure set_big_blind(game : in out T_game; val : in Integer) is
begin
game.big_blind := val;
end set_big_blind;
procedure set_amount_to_call(game : in out T_game; val : in Integer) is
begin
game.amount_to_call := val;
end set_amount_to_call;
procedure set_min_bet(game : in out T_game; val : in Integer) is
begin
game.min_bet := val;
end set_min_bet;
function get_size (set : in T_set) return Natural is
begin
return set.size;
end get_size;
function get_card(set : in T_set; i : in Natural) return T_card is
begin
return set.set(i);
end get_card;
procedure set_card(set : in out T_set; i : in Natural; card : in T_card) is
begin
set.set(i) := card;
end set_card;
function get_rank(card : in T_card) return Integer is
begin
return card.rank;
end get_rank;
procedure set_rank(card : in out T_card; val : in Integer) is
begin
card.rank := val;
end set_rank;
function get_colour(card : in T_card) return T_colour is
begin
return card.colour;
end get_colour;
procedure set_colour(card : in out T_card; val : in T_colour) is
begin
card.colour := val;
end set_colour;
function get_timebank_max (settings : in T_settings) return Integer is
begin
return settings.timebank_max ;
end get_timebank_max ;
procedure set_timebank_max (settings : in out T_settings; val : in Integer) is
begin
settings.timebank_max := val;
end set_timebank_max ;
function get_timebank_sup (settings : in T_settings) return Integer is
begin
return settings.timebank_sup ;
end get_timebank_sup ;
procedure set_timebank_sup (settings : in out T_settings; val : in Integer) is
begin
settings.timebank_sup := val;
end set_timebank_sup ;
function get_hands_per_lvl(settings : in T_settings) return Integer is
begin
return settings.hands_per_lvl;
end get_hands_per_lvl;
procedure set_hands_per_lvl(settings : in out T_settings; val : in Integer) is
begin
settings.hands_per_lvl := val;
end set_hands_per_lvl;
end utils;
|
zhmu/ananas | Ada | 5,805 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C H 2 --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Einfo; use Einfo;
with Einfo.Utils; use Einfo.Utils;
with Namet; use Namet;
with Opt; use Opt;
with Restrict; use Restrict;
with Rident; use Rident;
with Sem_Ch8; use Sem_Ch8;
with Sem_Dim; use Sem_Dim;
with Sinfo; use Sinfo;
with Sinfo.Nodes; use Sinfo.Nodes;
with Stand; use Stand;
with Uintp; use Uintp;
package body Sem_Ch2 is
-------------------------------
-- Analyze_Character_Literal --
-------------------------------
procedure Analyze_Character_Literal (N : Node_Id) is
begin
-- The type is eventually inherited from the context. If expansion
-- has already established the proper type, do not modify it.
if No (Etype (N)) then
Set_Etype (N, Any_Character);
end if;
Set_Is_Static_Expression (N);
if Comes_From_Source (N)
and then not In_Character_Range (UI_To_CC (Char_Literal_Value (N)))
then
Check_Restriction (No_Wide_Characters, N);
end if;
end Analyze_Character_Literal;
------------------------
-- Analyze_Identifier --
------------------------
procedure Analyze_Identifier (N : Node_Id) is
begin
-- Ignore call if prior errors, and identifier has no name, since
-- this is the result of some kind of previous error generating a
-- junk identifier.
if not Is_Valid_Name (Chars (N)) and then Total_Errors_Detected /= 0 then
return;
else
Find_Direct_Name (N);
end if;
Analyze_Dimension (N);
end Analyze_Identifier;
-----------------------------
-- Analyze_Integer_Literal --
-----------------------------
procedure Analyze_Integer_Literal (N : Node_Id) is
begin
-- As a lexical element, an integer literal has type Universal_Integer,
-- i.e., is compatible with any integer type. This is semantically
-- consistent and simplifies type checking and subsequent constant
-- folding when needed. An exception is caused by 64-bit modular types,
-- whose upper bound is not representable in a nonstatic context that
-- will use 64-bit integers at run time. For such cases, we need to
-- preserve the information that the analyzed literal has that modular
-- type. For simplicity, we preserve the information for all integer
-- literals that result from a modular operation. This happens after
-- prior analysis (or construction) of the literal, and after type
-- checking and resolution.
if No (Etype (N)) or else not Is_Modular_Integer_Type (Etype (N)) then
Set_Etype (N, Universal_Integer);
end if;
Set_Is_Static_Expression (N);
end Analyze_Integer_Literal;
--------------------------
-- Analyze_Real_Literal --
--------------------------
procedure Analyze_Real_Literal (N : Node_Id) is
begin
Set_Etype (N, Universal_Real);
Set_Is_Static_Expression (N);
end Analyze_Real_Literal;
----------------------------
-- Analyze_String_Literal --
----------------------------
procedure Analyze_String_Literal (N : Node_Id) is
begin
-- The type is eventually inherited from the context. If expansion
-- has already established the proper type, do not modify it.
if No (Etype (N)) then
Set_Etype (N, Any_String);
end if;
-- String literals are static in Ada 95. Note that if the subtype
-- turns out to be non-static, then the Is_Static_Expression flag
-- will be reset in Eval_String_Literal.
if Ada_Version >= Ada_95 then
Set_Is_Static_Expression (N);
end if;
if Comes_From_Source (N) and then Has_Wide_Character (N) then
Check_Restriction (No_Wide_Characters, N);
end if;
end Analyze_String_Literal;
end Sem_Ch2;
|
VMika/DES_Ada | Ada | 17,240 | adb | pragma Warnings (Off);
pragma Ada_95;
pragma Source_File_Name (ada_main, Spec_File_Name => "b__mainparallel.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b__mainparallel.adb");
pragma Suppress (Overflow_Check);
with System.Restrictions;
with Ada.Exceptions;
package body ada_main is
E068 : Short_Integer; pragma Import (Ada, E068, "system__os_lib_E");
E011 : Short_Integer; pragma Import (Ada, E011, "system__soft_links_E");
E021 : Short_Integer; pragma Import (Ada, E021, "system__exception_table_E");
E064 : Short_Integer; pragma Import (Ada, E064, "ada__io_exceptions_E");
E048 : Short_Integer; pragma Import (Ada, E048, "ada__strings_E");
E036 : Short_Integer; pragma Import (Ada, E036, "ada__containers_E");
E023 : Short_Integer; pragma Import (Ada, E023, "system__exceptions_E");
E015 : Short_Integer; pragma Import (Ada, E015, "system__secondary_stack_E");
E074 : Short_Integer; pragma Import (Ada, E074, "interfaces__c_E");
E050 : Short_Integer; pragma Import (Ada, E050, "ada__strings__maps_E");
E054 : Short_Integer; pragma Import (Ada, E054, "ada__strings__maps__constants_E");
E076 : Short_Integer; pragma Import (Ada, E076, "system__object_reader_E");
E043 : Short_Integer; pragma Import (Ada, E043, "system__dwarf_lines_E");
E035 : Short_Integer; pragma Import (Ada, E035, "system__traceback__symbolic_E");
E139 : Short_Integer; pragma Import (Ada, E139, "interfaces__c__strings_E");
E199 : Short_Integer; pragma Import (Ada, E199, "interfaces__cobol_E");
E154 : Short_Integer; pragma Import (Ada, E154, "system__task_info_E");
E101 : Short_Integer; pragma Import (Ada, E101, "ada__tags_E");
E099 : Short_Integer; pragma Import (Ada, E099, "ada__streams_E");
E115 : Short_Integer; pragma Import (Ada, E115, "system__file_control_block_E");
E114 : Short_Integer; pragma Import (Ada, E114, "system__finalization_root_E");
E112 : Short_Integer; pragma Import (Ada, E112, "ada__finalization_E");
E111 : Short_Integer; pragma Import (Ada, E111, "system__file_io_E");
E214 : Short_Integer; pragma Import (Ada, E214, "ada__streams__stream_io_E");
E180 : Short_Integer; pragma Import (Ada, E180, "system__storage_pools_E");
E176 : Short_Integer; pragma Import (Ada, E176, "system__finalization_masters_E");
E174 : Short_Integer; pragma Import (Ada, E174, "system__storage_pools__subpools_E");
E166 : Short_Integer; pragma Import (Ada, E166, "ada__strings__unbounded_E");
E133 : Short_Integer; pragma Import (Ada, E133, "ada__real_time_E");
E097 : Short_Integer; pragma Import (Ada, E097, "ada__text_io_E");
E201 : Short_Integer; pragma Import (Ada, E201, "system__pool_global_E");
E210 : Short_Integer; pragma Import (Ada, E210, "system__sequential_io_E");
E232 : Short_Integer; pragma Import (Ada, E232, "system__tasking__initialization_E");
E240 : Short_Integer; pragma Import (Ada, E240, "system__tasking__protected_objects_E");
E244 : Short_Integer; pragma Import (Ada, E244, "system__tasking__protected_objects__entries_E");
E248 : Short_Integer; pragma Import (Ada, E248, "system__tasking__queuing_E");
E254 : Short_Integer; pragma Import (Ada, E254, "system__tasking__stages_E");
E193 : Short_Integer; pragma Import (Ada, E193, "p_structuraltypes_E");
E191 : Short_Integer; pragma Import (Ada, E191, "p_stephandler_E");
E205 : Short_Integer; pragma Import (Ada, E205, "p_stephandler__feistelhandler_E");
E207 : Short_Integer; pragma Import (Ada, E207, "p_stephandler__inputhandler_E");
E218 : Short_Integer; pragma Import (Ada, E218, "p_stephandler__iphandler_E");
E220 : Short_Integer; pragma Import (Ada, E220, "p_stephandler__keyhandler_E");
E222 : Short_Integer; pragma Import (Ada, E222, "p_stephandler__outputhandler_E");
E224 : Short_Integer; pragma Import (Ada, E224, "p_stephandler__reverseiphandler_E");
Local_Priority_Specific_Dispatching : constant String := "";
Local_Interrupt_States : constant String := "";
Is_Elaborated : Boolean := False;
procedure finalize_library is
begin
E224 := E224 - 1;
declare
procedure F1;
pragma Import (Ada, F1, "p_stephandler__reverseiphandler__finalize_spec");
begin
F1;
end;
E222 := E222 - 1;
declare
procedure F2;
pragma Import (Ada, F2, "p_stephandler__outputhandler__finalize_spec");
begin
F2;
end;
E220 := E220 - 1;
declare
procedure F3;
pragma Import (Ada, F3, "p_stephandler__keyhandler__finalize_spec");
begin
F3;
end;
E218 := E218 - 1;
declare
procedure F4;
pragma Import (Ada, F4, "p_stephandler__iphandler__finalize_spec");
begin
F4;
end;
E207 := E207 - 1;
declare
procedure F5;
pragma Import (Ada, F5, "p_stephandler__inputhandler__finalize_spec");
begin
F5;
end;
E205 := E205 - 1;
declare
procedure F6;
pragma Import (Ada, F6, "p_stephandler__feistelhandler__finalize_spec");
begin
F6;
end;
E191 := E191 - 1;
declare
procedure F7;
pragma Import (Ada, F7, "p_stephandler__finalize_spec");
begin
F7;
end;
E244 := E244 - 1;
declare
procedure F8;
pragma Import (Ada, F8, "system__tasking__protected_objects__entries__finalize_spec");
begin
F8;
end;
E210 := E210 - 1;
declare
procedure F9;
pragma Import (Ada, F9, "system__sequential_io__finalize_spec");
begin
F9;
end;
E201 := E201 - 1;
declare
procedure F10;
pragma Import (Ada, F10, "system__pool_global__finalize_spec");
begin
F10;
end;
E097 := E097 - 1;
declare
procedure F11;
pragma Import (Ada, F11, "ada__text_io__finalize_spec");
begin
F11;
end;
E166 := E166 - 1;
declare
procedure F12;
pragma Import (Ada, F12, "ada__strings__unbounded__finalize_spec");
begin
F12;
end;
E174 := E174 - 1;
declare
procedure F13;
pragma Import (Ada, F13, "system__storage_pools__subpools__finalize_spec");
begin
F13;
end;
E176 := E176 - 1;
declare
procedure F14;
pragma Import (Ada, F14, "system__finalization_masters__finalize_spec");
begin
F14;
end;
E214 := E214 - 1;
declare
procedure F15;
pragma Import (Ada, F15, "ada__streams__stream_io__finalize_spec");
begin
F15;
end;
declare
procedure F16;
pragma Import (Ada, F16, "system__file_io__finalize_body");
begin
E111 := E111 - 1;
F16;
end;
declare
procedure Reraise_Library_Exception_If_Any;
pragma Import (Ada, Reraise_Library_Exception_If_Any, "__gnat_reraise_library_exception_if_any");
begin
Reraise_Library_Exception_If_Any;
end;
end finalize_library;
procedure adafinal is
procedure s_stalib_adafinal;
pragma Import (C, s_stalib_adafinal, "system__standard_library__adafinal");
procedure Runtime_Finalize;
pragma Import (C, Runtime_Finalize, "__gnat_runtime_finalize");
begin
if not Is_Elaborated then
return;
end if;
Is_Elaborated := False;
Runtime_Finalize;
s_stalib_adafinal;
end adafinal;
type No_Param_Proc is access procedure;
procedure adainit is
Main_Priority : Integer;
pragma Import (C, Main_Priority, "__gl_main_priority");
Time_Slice_Value : Integer;
pragma Import (C, Time_Slice_Value, "__gl_time_slice_val");
WC_Encoding : Character;
pragma Import (C, WC_Encoding, "__gl_wc_encoding");
Locking_Policy : Character;
pragma Import (C, Locking_Policy, "__gl_locking_policy");
Queuing_Policy : Character;
pragma Import (C, Queuing_Policy, "__gl_queuing_policy");
Task_Dispatching_Policy : Character;
pragma Import (C, Task_Dispatching_Policy, "__gl_task_dispatching_policy");
Priority_Specific_Dispatching : System.Address;
pragma Import (C, Priority_Specific_Dispatching, "__gl_priority_specific_dispatching");
Num_Specific_Dispatching : Integer;
pragma Import (C, Num_Specific_Dispatching, "__gl_num_specific_dispatching");
Main_CPU : Integer;
pragma Import (C, Main_CPU, "__gl_main_cpu");
Interrupt_States : System.Address;
pragma Import (C, Interrupt_States, "__gl_interrupt_states");
Num_Interrupt_States : Integer;
pragma Import (C, Num_Interrupt_States, "__gl_num_interrupt_states");
Unreserve_All_Interrupts : Integer;
pragma Import (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
Detect_Blocking : Integer;
pragma Import (C, Detect_Blocking, "__gl_detect_blocking");
Default_Stack_Size : Integer;
pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
Leap_Seconds_Support : Integer;
pragma Import (C, Leap_Seconds_Support, "__gl_leap_seconds_support");
Bind_Env_Addr : System.Address;
pragma Import (C, Bind_Env_Addr, "__gl_bind_env_addr");
procedure Runtime_Initialize (Install_Handler : Integer);
pragma Import (C, Runtime_Initialize, "__gnat_runtime_initialize");
Finalize_Library_Objects : No_Param_Proc;
pragma Import (C, Finalize_Library_Objects, "__gnat_finalize_library_objects");
begin
if Is_Elaborated then
return;
end if;
Is_Elaborated := True;
Main_Priority := -1;
Time_Slice_Value := -1;
WC_Encoding := 'b';
Locking_Policy := ' ';
Queuing_Policy := ' ';
Task_Dispatching_Policy := ' ';
System.Restrictions.Run_Time_Restrictions :=
(Set =>
(False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, True, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False),
Value => (0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
Violated =>
(False, False, False, True, True, False, False, False,
False, False, False, True, True, True, False, False,
False, False, False, True, True, False, True, True,
False, True, True, True, True, False, False, False,
False, False, True, False, False, True, False, True,
False, False, True, False, False, False, True, True,
False, True, True, False, True, False, False, False,
True, False, True, True, True, True, True, False,
False, True, False, True, True, True, False, True,
True, False, True, True, True, True, False, False,
True, False, False, False, False, True, True, True,
False, False, False),
Count => (0, 0, 0, 0, 2, 2, 1, 0, 0, 0),
Unknown => (False, False, False, False, False, False, True, False, False, False));
Priority_Specific_Dispatching :=
Local_Priority_Specific_Dispatching'Address;
Num_Specific_Dispatching := 0;
Main_CPU := -1;
Interrupt_States := Local_Interrupt_States'Address;
Num_Interrupt_States := 0;
Unreserve_All_Interrupts := 0;
Detect_Blocking := 0;
Default_Stack_Size := -1;
Leap_Seconds_Support := 0;
Runtime_Initialize (1);
Finalize_Library_Objects := finalize_library'access;
System.Soft_Links'Elab_Spec;
System.Exception_Table'Elab_Body;
E021 := E021 + 1;
Ada.Io_Exceptions'Elab_Spec;
E064 := E064 + 1;
Ada.Strings'Elab_Spec;
E048 := E048 + 1;
Ada.Containers'Elab_Spec;
E036 := E036 + 1;
System.Exceptions'Elab_Spec;
E023 := E023 + 1;
System.Soft_Links'Elab_Body;
E011 := E011 + 1;
Interfaces.C'Elab_Spec;
System.Os_Lib'Elab_Body;
E068 := E068 + 1;
Ada.Strings.Maps'Elab_Spec;
Ada.Strings.Maps.Constants'Elab_Spec;
E054 := E054 + 1;
System.Secondary_Stack'Elab_Body;
E015 := E015 + 1;
System.Object_Reader'Elab_Spec;
System.Dwarf_Lines'Elab_Spec;
E043 := E043 + 1;
E074 := E074 + 1;
E050 := E050 + 1;
System.Traceback.Symbolic'Elab_Body;
E035 := E035 + 1;
E076 := E076 + 1;
Interfaces.C.Strings'Elab_Spec;
E139 := E139 + 1;
Interfaces.Cobol'Elab_Spec;
E199 := E199 + 1;
System.Task_Info'Elab_Spec;
E154 := E154 + 1;
Ada.Tags'Elab_Spec;
Ada.Tags'Elab_Body;
E101 := E101 + 1;
Ada.Streams'Elab_Spec;
E099 := E099 + 1;
System.File_Control_Block'Elab_Spec;
E115 := E115 + 1;
System.Finalization_Root'Elab_Spec;
E114 := E114 + 1;
Ada.Finalization'Elab_Spec;
E112 := E112 + 1;
System.File_Io'Elab_Body;
E111 := E111 + 1;
Ada.Streams.Stream_Io'Elab_Spec;
E214 := E214 + 1;
System.Storage_Pools'Elab_Spec;
E180 := E180 + 1;
System.Finalization_Masters'Elab_Spec;
System.Finalization_Masters'Elab_Body;
E176 := E176 + 1;
System.Storage_Pools.Subpools'Elab_Spec;
E174 := E174 + 1;
Ada.Strings.Unbounded'Elab_Spec;
E166 := E166 + 1;
Ada.Real_Time'Elab_Spec;
Ada.Real_Time'Elab_Body;
E133 := E133 + 1;
Ada.Text_Io'Elab_Spec;
Ada.Text_Io'Elab_Body;
E097 := E097 + 1;
System.Pool_Global'Elab_Spec;
E201 := E201 + 1;
System.Sequential_Io'Elab_Spec;
E210 := E210 + 1;
System.Tasking.Initialization'Elab_Body;
E232 := E232 + 1;
System.Tasking.Protected_Objects'Elab_Body;
E240 := E240 + 1;
System.Tasking.Protected_Objects.Entries'Elab_Spec;
E244 := E244 + 1;
System.Tasking.Queuing'Elab_Body;
E248 := E248 + 1;
System.Tasking.Stages'Elab_Body;
E254 := E254 + 1;
E193 := E193 + 1;
P_Stephandler'Elab_Spec;
P_Stephandler'Elab_Body;
E191 := E191 + 1;
P_Stephandler.Feistelhandler'Elab_Spec;
P_Stephandler.Feistelhandler'Elab_Body;
E205 := E205 + 1;
P_Stephandler.Inputhandler'Elab_Spec;
P_Stephandler.Inputhandler'Elab_Body;
E207 := E207 + 1;
P_Stephandler.Iphandler'Elab_Spec;
P_Stephandler.Iphandler'Elab_Body;
E218 := E218 + 1;
P_Stephandler.Keyhandler'Elab_Spec;
P_Stephandler.Keyhandler'Elab_Body;
E220 := E220 + 1;
P_Stephandler.Outputhandler'Elab_Spec;
P_Stephandler.Outputhandler'Elab_Body;
E222 := E222 + 1;
P_Stephandler.Reverseiphandler'Elab_Spec;
P_Stephandler.Reverseiphandler'Elab_Body;
E224 := E224 + 1;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_mainparallel");
function main
(argc : Integer;
argv : System.Address;
envp : System.Address)
return Integer
is
procedure Initialize (Addr : System.Address);
pragma Import (C, Initialize, "__gnat_initialize");
procedure Finalize;
pragma Import (C, Finalize, "__gnat_finalize");
SEH : aliased array (1 .. 2) of Integer;
Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
pragma Volatile (Ensure_Reference);
begin
gnat_argc := argc;
gnat_argv := argv;
gnat_envp := envp;
Initialize (SEH'Address);
adainit;
Ada_Main_Program;
adafinal;
Finalize;
return (gnat_exit_status);
end;
-- BEGIN Object file/option list
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_structuraltypes.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_stephandler.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_stephandler-feistelhandler.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_stephandler-inputhandler.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_stephandler-iphandler.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_stephandler-keyhandler.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_stephandler-outputhandler.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\p_stephandler-reverseiphandler.o
-- C:\Users\vadim\des-ada\Des_Ada\obj\mainParallel.o
-- -LC:\Users\vadim\des-ada\Des_Ada\obj\
-- -LC:\Users\vadim\des-ada\Des_Ada\obj\
-- -LC:/gnat/2017/lib/gcc/i686-pc-mingw32/6.3.1/adalib/
-- -static
-- -lgnarl
-- -lgnat
-- -Xlinker
-- --stack=0x200000,0x1000
-- -mthreads
-- -Wl,--stack=0x2000000
-- END Object file/option list
end ada_main;
|
charlie5/cBound | Ada | 1,402 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces.C;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_tex_geniv_cookie_t is
-- Item
--
type Item is record
sequence : aliased Interfaces.C.unsigned;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_get_tex_geniv_cookie_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_tex_geniv_cookie_t.Item,
Element_Array => xcb.xcb_glx_get_tex_geniv_cookie_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_glx_get_tex_geniv_cookie_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_tex_geniv_cookie_t.Pointer,
Element_Array => xcb.xcb_glx_get_tex_geniv_cookie_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_tex_geniv_cookie_t;
|
AdaCore/libadalang | Ada | 61 | ads | package Pkg_1.Child2 is
A, B : Integer;
end Pkg_1.Child2;
|
zhmu/ananas | Ada | 231 | ads | package Aggr9_Pkg is
type Byte is range 0 .. 255;
type R1 is
record
A,B : Byte;
end record;
type R2 is
record
F : R1;
end record;
procedure Send (M : R2);
end Aggr9_Pkg;
|
AdaDoom3/wayland_ada_binding | Ada | 7,025 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2016-2016, 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 MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- 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/>. --
-- --
------------------------------------------------------------------------------
-- This package describes the concept of property maps.
-- These are an abstract description that explain how to extract information
-- from a container, and possibly set information.
--
-- It is used almost everywhere in this library. Here are some examples:
--
-- * Retrieving stored elements from a container given a cursor.
-- A container of course provides such a capability directly (generally
-- via a function named Element or Get). But the generic algorithms also
-- need to know how to do this operation.
-- Some libraries chose to associate this capability directly with cursors
-- so that a cursor traits package also provides the Get command. But this
-- is slightly inflexible, since containers now need to provide different
-- traits package when they need to return different information (for
-- instance a map could chose to return either the element's key, its
-- value, or a pair of the two. And yet this is the same cursor in all
-- cases.
--
-- * Storing temporary information in the container
-- Graph algorithms typically need to mark vertices when they are visited
-- so that they are not processed again later on.
-- There are two approaches here:
--
-- - Either the container itself is able to store the information
-- directly (in the vertex, the edge, or in some other internal
-- field).
--
-- - Or an external data structure (provided just for the duration of
-- the algorithm) is used. For instance, a vector indexed by a unique
-- integer id associated with the vertices or edges. Or a map.
--
-- In both cases, the algorithm needs to perform the same Set and Get
-- operation. But in the first case, the map is the container itself (and
-- most likely the Clear operation will do nothing). These are called
-- "internal maps".
--
-- Such internal maps are exactly what is used to retrieve an element stored
-- in the container, as described in the first bullet above. But instead of
-- just relying on a primitive operation of the container (which would limit
-- the reusability of the algorithm to other data structures), or a Get
-- formal parameter that assumes the map is the container, the algorithms
-- generally let users decide where the map is stored.
-- This provides one level of indirection (with no performance cost in the
-- general case), which is sometimes useful to reuse algorithms.
--
-- In general, multiple versions of the algorithms will be provided, one for
-- each type of map (interior or exterior), and one that takes the map
-- explicitly in parameter so that the algorithm does not need to create the
-- map on its own, and the container can act as its own map.
pragma Ada_2012;
package Conts.Properties is
-----------------------------
-- Read-only property maps --
-----------------------------
generic
type Map_Type (<>) is limited private;
type Key_Type (<>) is limited private;
type Element_Type (<>) is private;
with function Get (M : Map_Type; K : Key_Type) return Element_Type is <>;
package Read_Only_Maps is
subtype Map is Map_Type;
subtype Key is Key_Type;
subtype Element is Element_Type;
function Value
(M : Map_Type; K : Key_Type) return Element_Type renames Get;
-- ??? Make visible to users of the package
end Read_Only_Maps;
-------------------
-- Property maps --
-------------------
generic
type Map_Type (<>) is limited private;
type Key_Type (<>) is limited private;
type Element_Type is private;
with procedure Set
(M : in out Map_Type; K : Key_Type; V : Element_Type) is <>;
with function Get (M : Map_Type; K : Key_Type) return Element_Type is <>;
with procedure Clear (M : in out Map_Type) is null;
package Maps is
subtype Map is Map_Type;
subtype Key is Key_Type;
subtype Element is Element_Type;
function Value
(M : Map_Type; K : Key_Type) return Element_Type renames Get;
-- ??? Make visible to users of the package
package As_Read_Only is new Read_Only_Maps (Map, Key, Element);
end Maps;
------------------------------
-- Property position models --
------------------------------
generic
type Map_Type (<>) is limited private;
type Key_Type (<>) is limited private;
type Model_Type is private;
type Index_Type is (<>);
with function Model (M : Map_Type) return Model_Type;
with function Get (M : Model_Type; K : Key_Type) return Index_Type;
package Position_Models is
subtype Map is Map_Type;
subtype Key is Key_Type;
function Value
(M : Model_Type; K : Key_Type) return Index_Type renames Get;
-- ??? Make visible to users of the package
end Position_Models;
-----------------------------
-- Property content models --
-----------------------------
generic
type Map_Type (<>) is limited private;
type Element_Type (<>) is private;
type Model_Type is private;
type Index_Type is (<>);
with function Model (M : Map_Type) return Model_Type;
with function Get (M : Model_Type; I : Index_Type) return Element_Type;
package Content_Models is
subtype Map is Map_Type;
subtype Element is Element_Type;
end Content_Models;
end Conts.Properties;
|
reznikmm/matreshka | Ada | 3,870 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 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$
------------------------------------------------------------------------------
with Asis.Expressions;
package body Properties.Expressions.Allocation is
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property)
return League.Strings.Universal_String
is
Item : constant Asis.Expression :=
Asis.Expressions.Allocator_Qualified_Expression (Element);
begin
return Engine.Text.Get_Property (Item, Name);
end Code;
end Properties.Expressions.Allocation;
|
zhmu/ananas | Ada | 1,286 | adb | -- { dg-do compile }
-- { dg-options "-O3" }
with Ada.Unchecked_Deallocation;
package body Opt68 is
procedure Free
is new Ada.Unchecked_Deallocation (Queue_Element, A_Queue_Element);
procedure Copy (dest : in out Queue; src : Queue) is
d, s, pd, ps, t : A_Queue_Element;
begin
if src.sz /= 0 then
d := dest.front;
s := src.front;
while d /= null and s /= null loop
d.value := s.value;
pd := d;
ps := s;
d := d.next;
s := s.next;
end loop;
if src.sz = dest.sz then
return;
elsif s = null then
while d /= null loop
t := d.next;
Free (d);
d := t;
end loop;
dest.back := pd;
dest.back.next := null;
else
if pd = null then
dest.front := new Queue_Element;
dest.front.value := s.value;
s := s.next;
pd := dest.front;
end if;
while s /= null loop
pd.next := new Queue_Element;
pd.next.value := s.value;
pd := pd.next;
s := s.next;
end loop;
dest.back := pd;
end if;
dest.sz := src.sz;
end if;
end;
end Opt68;
|
Fabien-Chouteau/lvgl-ada | Ada | 57 | adb | procedure Check_Pix32 is
begin
null;
end Check_Pix32;
|
nerilex/ada-util | Ada | 2,521 | ads | -----------------------------------------------------------------------
-- util-http-rest -- REST API support
-- Copyright (C) 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Serialize.IO;
with Util.Http.Clients;
with Util.Serialize.Mappers.Record_Mapper;
-- The <b>Util.Http.Rest</b> package defines a REST client type which helps in writing
-- REST client APIs. A REST client is similar to an HTTP client but it provides additional
-- operations that are useful in REST APIs.
package Util.Http.Rest is
-- -----------------------
-- REST client
-- -----------------------
type Client is new Util.Http.Clients.Client with private;
-- Execute an HTTP GET operation using the <b>Http</b> client on the given <b>URI</b>.
-- Upon successful reception of the response, parse the JSON result and populate the
-- serialization context associated with the parser.
procedure Get (Http : in out Client;
URI : in String;
Parser : in out Util.Serialize.IO.Parser'Class);
-- Execute an HTTP GET operation on the given <b>URI</b> and parse the JSON response
-- into the target object refered to by <b>Into</b> by using the mapping described
-- in <b>Mapping</b>.
generic
-- Package that maps the element into a record.
with package Element_Mapper is
new Util.Serialize.Mappers.Record_Mapper (<>);
procedure Rest_Get (URI : in String;
Mapping : in Util.Serialize.Mappers.Mapper_Access;
Path : in String := "";
Into : in Element_Mapper.Element_Type_Access);
private
type Client is new Util.Http.Clients.Client with record
Status : Natural := 0;
end record;
end Util.Http.Rest;
|
jhumphry/PRNG_Zoo | Ada | 3,485 | ads | --
-- PRNG Zoo
-- Copyright (c) 2014 - 2015, 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.
package PRNG_Zoo.MT is
-- Based on (Matsumoto and Nishimura, 1998)
type MT19937 is new PRNG_32Only and PRNG_Seed_From_Array with private;
function Strength(G: in MT19937) return PRNG_Strength is (Medium);
function Constructor(Params : not null access PRNG_Parameters'Class)
return MT19937;
procedure Reset(G: in out MT19937; S: in U64);
procedure Reset(G: in out MT19937; S: in U64_array);
function Generate(G: in out MT19937) return U32 with inline;
type MT19937_64 is new PRNG_64Only and PRNG_Seed_From_Array with private;
function Strength(G: in MT19937_64) return PRNG_Strength is (Medium);
function Constructor(Params : not null access PRNG_Parameters'Class)
return MT19937_64;
procedure Reset(G: in out MT19937_64; S: in U64);
procedure Reset(G: in out MT19937_64; S: in U64_array);
function Generate(G: in out MT19937_64) return U64 with inline;
-- Based on (Matsumoto and Nishimura, 2011)
type TinyMT_64 is new PRNG_64Only and PRNG_Seed_From_Array with private;
function Strength(G: in TinyMT_64) return PRNG_Strength is (Medium);
function Constructor(Params : not null access PRNG_Parameters'Class)
return TinyMT_64;
procedure Reset(G: in out TinyMT_64; S: in U64);
procedure Reset(G: in out TinyMT_64; S: in U64_array);
function Generate(G: in out TinyMT_64) return U64 with inline;
private
type MT_Index is mod 624;
type MT_State is array (MT_Index) of U32;
type MT19937 is new PRNG_32Only and PRNG_Seed_From_Array with
record
s : MT_State;
p : MT_Index;
end record;
function Constructor(Params : not null access PRNG_Parameters'Class)
return MT19937 is
(MT19937'(others => <>));
type MT_Index_64 is mod 312;
type MT_State_64 is array (MT_Index_64) of U64;
type MT19937_64 is new PRNG_64Only and PRNG_Seed_From_Array with
record
s : MT_State_64;
p : MT_Index_64;
end record;
function Constructor(Params : not null access PRNG_Parameters'Class)
return MT19937_64 is
(MT19937_64'(others => <>));
type TinyMT_64_State is array (U64 range 0..1) of U64;
type TinyMT_64 is new PRNG_64Only and PRNG_Seed_From_Array with
record
status : TinyMT_64_State;
mat1 : U32 := 16#fa051f40#;
mat2 : U32 := 16#ffd0fff4#;
tmat : U64 := 16#58d02ffeffbfffbc#;
end record;
function Constructor(Params : not null access PRNG_Parameters'Class)
return TinyMT_64 is
(TinyMT_64'(others => <>));
end PRNG_Zoo.MT;
|
ftigeot/ravensource | Ada | 1,676 | adb | --- src/gprlib.adb.orig 2018-05-25 06:23:18 UTC
+++ src/gprlib.adb
@@ -720,9 +720,6 @@ procedure Gprlib is
for Dir of Imported_Library_Directories loop
Library_Switches_Table.Append ("-L" & Dir);
- if Path_Option /= null then
- Add_Rpath (Dir);
- end if;
end loop;
for Libname of Imported_Library_Names loop
@@ -917,12 +914,6 @@ procedure Gprlib is
Shared_Lib_Suffix.all);
end if;
- if Path_Option /= null then
- for Path of Library_Rpath_Options_Table loop
- Add_Rpath (Path);
- end loop;
- end if;
-
if Path_Option /= null and then not Rpath.Is_Empty then
if Separate_Run_Path_Options then
for J in 1 .. Rpath.Last_Index loop
@@ -1468,9 +1459,7 @@ procedure Gprlib is
if Is_Regular_File (Object_Path) then
Object_Files.Append (Object_Path);
else
- Fail_Program
- (null,
- "unknown object file """ & Object_Path & """");
+ Put_Line ("WARNING: unknown object '" & Object_Path & "'");
end if;
end;
end loop;
@@ -2002,10 +1991,10 @@ procedure Gprlib is
Libgnat :=
new String'
- ("-lgnat-" & Line (6 .. Last));
+ ("-lgnat-" & Line (6));
Libgnarl :=
new String'
- ("-lgnarl-" & Line (6 .. Last));
+ ("-lgnarl-" & Line (6));
end if;
else
|
jhumphry/Ada_BinToAsc | Ada | 1,065 | adb | -- BinToAsc_Suite
-- Unit tests for BinToAsc
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
with BinToAsc_Suite.Misc_Tests;
with BinToAsc_Suite.Base16_Tests;
with BinToAsc_Suite.Base32_Tests;
with BinToAsc_Suite.Base64_Tests;
with BinToAsc_Suite.Base85_Tests;
package body BinToAsc_Suite is
use AUnit.Test_Suites;
Result : aliased Test_Suite;
Test_Misc : aliased Misc_Tests.Misc_Test;
Test_Base16 : aliased Base16_Tests.Base16_Test;
Test_Base32 : aliased Base32_Tests.Base32_Test;
Test_Base64 : aliased Base64_Tests.Base64_Test;
Test_Base85 : aliased Base85_Tests.Base85_Test;
-----------
-- Suite --
-----------
function Suite return AUnit.Test_Suites.Access_Test_Suite is
begin
Add_Test (Result'Access, Test_Misc'Access);
Add_Test (Result'Access, Test_Base16'Access);
Add_Test (Result'Access, Test_Base32'Access);
Add_Test (Result'Access, Test_Base64'Access);
Add_Test (Result'Access, Test_Base85'Access);
return Result'Access;
end Suite;
end BinToAsc_Suite;
|
reznikmm/matreshka | Ada | 3,784 | 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_Attributes.Style.Color;
package ODF.DOM.Attributes.Style.Color.Internals is
function Create
(Node : Matreshka.ODF_Attributes.Style.Color.Style_Color_Access)
return ODF.DOM.Attributes.Style.Color.ODF_Style_Color;
function Wrap
(Node : Matreshka.ODF_Attributes.Style.Color.Style_Color_Access)
return ODF.DOM.Attributes.Style.Color.ODF_Style_Color;
end ODF.DOM.Attributes.Style.Color.Internals;
|
stcarrez/ada-security | Ada | 3,449 | adb | -----------------------------------------------------------------------
-- auth_cb -- Authentication callback examples
-- Copyright (C) 2013, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Properties;
with Util.Log.Loggers;
with Util.Http.Clients.AWS;
with AWS.Config;
with AWS.Config.Set;
with AWS.Server;
with AWS.Services.Dispatchers.URI;
with AWS.Services.Page_Server;
with AWS.Services.Web_Block.Registry;
with AWS.Net.SSL;
with Auth_CB;
procedure Auth_Demo is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Auth_Demo");
Dispatcher : AWS.Services.Dispatchers.URI.Handler;
WS : AWS.Server.HTTP;
Config : AWS.Config.Object;
begin
if not AWS.Net.SSL.Is_Supported then
Log.Error ("SSL is not supported by AWS.");
Log.Error ("SSL is required for the OpenID connector to connect to OpenID providers.");
Log.Error ("Please, rebuild AWS with SSL support.");
return;
end if;
-- Get the authentication provider configuration. We use the Util.Properties and some
-- java like property file. Other configuration implementation are possible.
Auth_CB.Config.Load_Properties ("samples.properties");
Util.Log.Loggers.Initialize (Util.Properties.Manager (Auth_CB.Config));
-- Setup the HTTP client implementation to use AWS.
Util.Http.Clients.AWS.Register;
-- Setup AWS dispatchers.
AWS.Services.Dispatchers.URI.Register (Dispatcher, "/atlas/auth/auth",
Auth_CB.Get_Authorization'Access,
Prefix => True);
AWS.Services.Dispatchers.URI.Register (Dispatcher, "/verify",
Auth_CB.Verify_Authorization'Access);
AWS.Services.Dispatchers.URI.Register (Dispatcher, "/atlas",
AWS.Services.Page_Server.Callback'Access,
Prefix => True);
AWS.Services.Dispatchers.URI.Register (Dispatcher, "/success",
Auth_CB.User_Info'Access);
AWS.Services.Web_Block.Registry.Register ("success", "samples/web/success.thtml", null);
-- Configure AWS.
Config := AWS.Config.Get_Current;
AWS.Config.Set.Session (Config, True);
AWS.Config.Set.Session_Name (Config, "AUTH_DEMO");
AWS.Config.Set.Reuse_Address (Config, True);
AWS.Config.Set.WWW_Root (Config, "samples/web");
AWS.Server.Start (WS, Dispatcher => Dispatcher, Config => Config);
Log.Info ("Connect you browser to: http://localhost:8080/atlas/login.html");
Log.Info ("Press 'q' key to stop the server.");
AWS.Server.Wait (AWS.Server.Q_Key_Pressed);
Log.Info ("Shutting down server...");
AWS.Server.Shutdown (WS);
end Auth_Demo;
|
ytomino/xml-ada | Ada | 41,503 | adb | with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Address_To_Access_Conversions;
with C.string;
with C.libxml.globals;
with C.libxml.parser;
with C.libxml.tree;
with C.libxml.xmlIO;
with C.libxml.xmlmemory;
with C.libxml.xmlstring;
with C.libxml.xmlversion;
package body XML is
use type System.Address;
use type C.char_array;
use type C.signed_int;
use type C.size_t;
use type C.libxml.encoding.xmlCharEncodingHandlerPtr;
use type C.libxml.xmlstring.xmlChar_const_ptr;
use type C.libxml.tree.xmlOutputBufferPtr;
use type C.libxml.xmlreader.xmlTextReaderPtr;
use type C.libxml.xmlwriter.xmlTextWriterPtr;
procedure Free is new Ada.Unchecked_Deallocation (String, String_Access);
procedure memcpy (dst, src : System.Address; n : C.size_t)
with Import, Convention => Intrinsic, External_Name => "__builtin_memcpy";
procedure memset (
s : System.Address;
c : Standard.C.signed_int;
n : Standard.C.size_t)
with Import, Convention => Intrinsic, External_Name => "__builtin_memset";
type xmlChar_array is
array (C.size_t range <>) of aliased C.libxml.xmlstring.xmlChar
with Convention => C;
pragma Suppress_Initialization (xmlChar_array);
function To_char_const_ptr is
new Ada.Unchecked_Conversion (
C.libxml.xmlstring.xmlChar_const_ptr,
C.char_const_ptr);
function To_Address is
new Ada.Unchecked_Conversion (C.char_const_ptr, System.Address);
function Length (S : access constant C.char) return Natural is
begin
if S = null then
return 0;
else
return Natural (C.string.strlen (S));
end if;
end Length;
function To_String (S : access constant C.char; Length : Natural) return String is
Result : String (1 .. Length);
for Result'Address use To_Address (C.char_const_ptr (S));
begin
return Result;
end To_String;
function To_String (S : access constant C.char) return String is
begin
return To_String (S, Length (S));
end To_String;
function To_String_Without_LF (S : access constant C.char) return String is
L : Natural := Length (S);
Result : String (1 .. L);
for Result'Address use To_Address (C.char_const_ptr (S));
begin
if L >= 1 and then Result (L) = Character'Val (10) then
L := L - 1;
end if;
return To_String (S, L);
end To_String_Without_LF;
-- dirty trick
function Copy_String_Access (
S : not null String_Access;
Constraint : not null access String_Constraint)
return String_Access
is
type Fat_Type is record
Data : System.Address;
Constraints : System.Address;
end record;
Fat : Fat_Type;
Result : aliased String_Access;
for Fat'Address use Result'Address;
begin
Fat.Data := S.all'Address;
Fat.Constraints := Constraint.all'Address;
Constraint.First := S'First;
Constraint.Last := S'Last;
return Result;
end Copy_String_Access;
Version_Checked : Boolean := False;
-- implementation
function Version return String is
begin
Check_Version;
return To_String (C.libxml.globals.xmlParserVersion);
end Version;
procedure Check_Version is
begin
if not Version_Checked then
Version_Checked := True;
C.libxml.xmlversion.xmlCheckVersion (C.libxml.xmlversion.LIBXML_VERSION);
end if;
end Check_Version;
procedure Cleanup is
begin
C.libxml.parser.xmlCleanupParser;
C.libxml.xmlmemory.xmlMemoryDump;
end Cleanup;
function No_Encoding return Encoding_Type is
begin
return null;
end No_Encoding;
function Find (Name : String) return Encoding_Type is
Name_Length : constant C.size_t := Name'Length;
C_Name : C.char_array (0 .. Name_Length); -- NUL
Result : C.libxml.encoding.xmlCharEncodingHandlerPtr;
begin
memcpy (C_Name'Address, Name'Address, Name_Length);
C_Name (Name_Length) := C.char'Val (0);
Result :=
C.libxml.encoding.xmlFindCharEncodingHandler (C_Name (C_Name'First)'Access);
if Result = null then
raise Name_Error;
end if;
return Encoding_Type (Result);
end Find;
function Name (Encoding : Encoding_Type) return String is
begin
if Encoding = null then
raise Constraint_Error;
else
return To_String (Encoding.name);
end if;
end Name;
-- reader
function Read_Handler (
context : C.void_ptr;
buffer : access C.char;
len : C.signed_int)
return C.signed_int
with Convention => C;
function Read_Handler (
context : C.void_ptr;
buffer : access C.char;
len : C.signed_int)
return C.signed_int
is
type I is access procedure (Item : out String; Last : out Natural);
function To_Input is new Ada.Unchecked_Conversion (C.void_ptr, I);
Item : String (1 .. Natural (len));
for Item'Address use buffer.all'Address;
Last : Natural;
begin
To_Input (context) (Item, Last);
return C.signed_int (Last);
end Read_Handler;
procedure Reader_Error_Handler (
userData : C.void_ptr;
error : access C.libxml.xmlerror.xmlError)
with Convention => C;
procedure Reader_Error_Handler (
userData : C.void_ptr;
error : access C.libxml.xmlerror.xmlError)
is
package Conv is
new System.Address_To_Access_Conversions (Non_Controlled_Reader);
NC_Object : Non_Controlled_Reader
renames Conv.To_Pointer (System.Address (userData)).all;
begin
if NC_Object.Error then
C.libxml.xmlerror.xmlResetError (NC_Object.U.Last_Error'Access);
else
memset (NC_Object.U.Last_Error'Address, 0, C.libxml.xmlerror.xmlError'Size / Standard'Storage_Unit);
end if;
NC_Object.Error :=
not (
C.libxml.xmlerror.xmlCopyError (
from => error,
to => NC_Object.U.Last_Error'Access) < 0);
end Reader_Error_Handler;
procedure Next (NC_Object : in out Non_Controlled_Reader) is
begin
Reset_Last_Error (NC_Object);
if C.libxml.xmlreader.xmlTextReaderRead (NC_Object.Raw) < 0 then
Raise_Last_Error (NC_Object);
end if;
end Next;
procedure Read_Start (NC_Object : in out Non_Controlled_Reader) is
begin
if NC_Object.State = Start then
Next (NC_Object);
NC_Object.State := Next;
end if;
end Read_Start;
procedure Read (
NC_Object : in out Non_Controlled_Reader;
Parsed_Data : out Parsed_Data_Type) is
begin
case NC_Object.State is
when Next | Start | Remaining =>
if NC_Object.State /= Next then
Next (NC_Object);
end if;
declare
Node_Type : constant C.signed_int :=
C.libxml.xmlreader.xmlTextReaderNodeType (NC_Object.Raw);
begin
if Node_Type < 0 then
Raise_Last_Error (NC_Object);
else
case Node_Type is
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_NONE) =>
Parsed_Data.Event := (Event_Type => No_Event);
NC_Object.State := Remaining;
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_ATTRIBUTE) =>
declare
C_Name : constant C.libxml.xmlstring.xmlChar_const_ptr :=
C.libxml.xmlreader.xmlTextReaderConstName (NC_Object.Raw);
Name : String (1 .. Natural (C.string.strlen (To_char_const_ptr (C_Name))));
for Name'Address use C_Name.all'Address;
C_Value : constant C.libxml.xmlstring.xmlChar_const_ptr :=
C.libxml.xmlreader.xmlTextReaderConstValue (NC_Object.Raw);
Value : String (1 .. Natural (C.string.strlen (To_char_const_ptr (C_Value))));
for Value'Address use C_Value.all'Address;
begin
Parsed_Data.Event := (
Event_Type => Attribute,
Name =>
Copy_String_Access (
Name'Unrestricted_Access,
Parsed_Data.Name_Constraint'Access),
Value =>
Copy_String_Access (
Value'Unrestricted_Access,
Parsed_Data.Value_Constraint'Access));
end;
Reset_Last_Error (NC_Object);
declare
Moved : constant C.signed_int :=
C.libxml.xmlreader.xmlTextReaderMoveToNextAttribute (NC_Object.Raw);
begin
if Moved < 0 then
Raise_Last_Error (NC_Object);
elsif Moved > 0 then
NC_Object.State := Next; -- more attributes
else
-- end of attributes
Reset_Last_Error (NC_Object);
if C.libxml.xmlreader.xmlTextReaderMoveToElement (NC_Object.Raw) < 0 then
Raise_Last_Error (NC_Object);
end if;
if C.libxml.xmlreader.xmlTextReaderIsEmptyElement (NC_Object.Raw) > 0 then
NC_Object.State := Empty_Element;
else -- move to children
NC_Object.State := Remaining;
end if;
end if;
end;
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_ELEMENT) =>
declare
C_Name : constant C.libxml.xmlstring.xmlChar_const_ptr :=
C.libxml.xmlreader.xmlTextReaderConstName (NC_Object.Raw);
Name : String (1 .. Natural (C.string.strlen (To_char_const_ptr (C_Name))));
for Name'Address use C_Name.all'Address;
begin
Parsed_Data.Event := (
Event_Type => Element_Start,
Name =>
Copy_String_Access (
Name'Unrestricted_Access,
Parsed_Data.Name_Constraint'Access));
end;
if C.libxml.xmlreader.xmlTextReaderHasAttributes (NC_Object.Raw) > 0 then
NC_Object.State := Next;
Reset_Last_Error (NC_Object);
if C.libxml.xmlreader.xmlTextReaderMoveToFirstAttribute (
NC_Object.Raw) < 0
then
Raise_Last_Error (NC_Object);
end if;
elsif C.libxml.xmlreader.xmlTextReaderIsEmptyElement (NC_Object.Raw) > 0 then
NC_Object.State := Empty_Element;
else -- move to children
NC_Object.State := Remaining;
end if;
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_TEXT)
| C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_CDATA)
| C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_COMMENT)
| C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_WHITESPACE)
| C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_SIGNIFICANT_WHITESPACE) =>
declare
C_Content : constant C.libxml.xmlstring.xmlChar_const_ptr :=
C.libxml.xmlreader.xmlTextReaderConstValue (NC_Object.Raw);
Content :
String (1 .. Natural (C.string.strlen (To_char_const_ptr (C_Content))));
for Content'Address use C_Content.all'Address;
Content_Access : constant String_Access :=
Copy_String_Access (
Content'Unrestricted_Access,
Parsed_Data.Content_Constraint'Access);
begin
case Node_Type is
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_TEXT) =>
Parsed_Data.Event := (Event_Type => Text, Content => Content_Access);
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_CDATA) =>
Parsed_Data.Event := (Event_Type => CDATA, Content => Content_Access);
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_COMMENT) =>
Parsed_Data.Event := (Event_Type => Comment, Content => Content_Access);
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_WHITESPACE) =>
Parsed_Data.Event := (Event_Type => Whitespace, Content => Content_Access);
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_SIGNIFICANT_WHITESPACE) =>
Parsed_Data.Event :=
(Event_Type => Significant_Whitespace, Content => Content_Access);
when others =>
pragma Assert (False);
null;
end case;
end;
NC_Object.State := Remaining;
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_PROCESSING_INSTRUCTION) =>
declare
C_Name : constant C.libxml.xmlstring.xmlChar_const_ptr :=
C.libxml.xmlreader.xmlTextReaderConstName (NC_Object.Raw);
Name : String (1 .. Natural (C.string.strlen (To_char_const_ptr (C_Name))));
for Name'Address use C_Name.all'Address;
begin
Parsed_Data.Event := (
Event_Type => Processing_Instruction,
Name =>
Copy_String_Access (
Name'Unrestricted_Access,
Parsed_Data.Name_Constraint'Access));
-- it's not able to get attributes info with libxml2 (?)
pragma Assert (
C.libxml.xmlreader.xmlTextReaderHasAttributes (NC_Object.Raw) = 0);
end;
NC_Object.State := Remaining;
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_DOCUMENT_TYPE) =>
declare
C_Name : constant C.libxml.xmlstring.xmlChar_const_ptr :=
C.libxml.xmlreader.xmlTextReaderConstName (NC_Object.Raw);
Name : String (1 .. Natural (C.string.strlen (To_char_const_ptr (C_Name))));
for Name'Address use C_Name.all'Address;
begin
Parsed_Data.Event := (
Event_Type => Document_Type,
Name =>
Copy_String_Access (
Name'Unrestricted_Access,
Parsed_Data.Name_Constraint'Access),
Public_Id => null,
System_Id => null,
Subset => null);
-- it's not able to get extra DTD info with libxml2 (?)
pragma Assert (
C.libxml.xmlreader.xmlTextReaderHasAttributes (NC_Object.Raw) = 0);
end;
NC_Object.State := Remaining;
when C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_END_ELEMENT) =>
Parsed_Data.Event := (Event_Type => Element_End);
NC_Object.State := Remaining;
when others =>
raise Program_Error with "in XML.Read, unimplemented" & Node_Type'Img;
end case;
end if;
end;
when Empty_Element =>
Parsed_Data.Event := (Event_Type => Element_End);
NC_Object.State := Remaining;
end case;
end Read;
procedure Read (Object : in out Reader; Parsed_Data : out Parsed_Data_Type) is
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
Read (NC_Object, Parsed_Data);
end Process;
procedure Do_Read is new Controlled_Readers.Update (Process);
begin
Do_Read (Object);
end Read;
-- implementation of reader
function Is_Assigned (Parsing_Entry : Parsing_Entry_Type) return Boolean is
begin
return Parsing_Entry.Assigned;
end Is_Assigned;
function Value (Parsing_Entry : aliased Parsing_Entry_Type)
return Event_Reference_Type
is
pragma Check (Pre,
Check => Is_Assigned (Parsing_Entry) or else raise Status_Error);
begin
return (Element => Parsing_Entry.Data.Event'Access);
end Value;
function Create (
Input : not null access procedure (Item : out String; Last : out Natural);
Encoding : Encoding_Type := No_Encoding;
URI : String := "")
return Reader
is
type I is access procedure (Item : out String; Last : out Natural);
function To_void_ptr is new Ada.Unchecked_Conversion (I, C.void_ptr);
begin
Check_Version;
declare
P_Encoding : C.char_const_ptr := null;
P_URI : access constant C.char := null;
URI_Length : constant C.size_t := URI'Length;
C_URI : aliased C.char_array (0 .. URI_Length); -- NUL
begin
if Encoding /= null then
P_Encoding := C.char_const_ptr (Encoding.name);
end if;
if URI'Length > 0 then
memcpy (C_URI'Address, URI'Address, URI_Length);
C_URI (URI_Length) := C.char'Val (0);
P_URI := C_URI (C_URI'First)'Access;
end if;
return Result : aliased Reader do
declare
NC_Result : Non_Controlled_Reader
renames Controlled_Readers.Reference (Result).all;
begin
NC_Result.Raw :=
C.libxml.xmlreader.xmlReaderForIO (
Read_Handler'Access,
null,
To_void_ptr (Input),
P_URI,
P_Encoding,
0);
if NC_Result.Raw = null then
raise Use_Error;
end if;
Install_Error_Handler (NC_Result);
end;
end return;
end;
end Create;
procedure Set_DTD_Loading (Object : in out Reader; Value : in Boolean) is
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
if C.libxml.xmlreader.xmlTextReaderSetParserProp (
NC_Object.Raw,
C.libxml.xmlreader.xmlParserProperties'Enum_Rep (
C.libxml.xmlreader.XML_PARSER_LOADDTD),
Boolean'Pos (Value)) < 0
then
raise Use_Error;
end if;
end Process;
procedure Do_Set_DTD_Loading is new Controlled_Readers.Update (Process);
begin
Do_Set_DTD_Loading (Object);
end Set_DTD_Loading;
procedure Set_Default_Attributes (
Object : in out Reader;
Value : in Boolean)
is
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
if C.libxml.xmlreader.xmlTextReaderSetParserProp (
NC_Object.Raw,
C.libxml.xmlreader.xmlParserProperties'Enum_Rep (
C.libxml.xmlreader.XML_PARSER_DEFAULTATTRS),
Boolean'Pos (Value)) < 0
then
raise Use_Error;
end if;
end Process;
procedure Do_Set_Default_Attributes is new Controlled_Readers.Update (Process);
begin
Do_Set_Default_Attributes (Object);
end Set_Default_Attributes;
procedure Set_Validation (Object : in out Reader; Value : in Boolean) is
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
if C.libxml.xmlreader.xmlTextReaderSetParserProp (
NC_Object.Raw,
C.libxml.xmlreader.xmlParserProperties'Enum_Rep (
C.libxml.xmlreader.XML_PARSER_VALIDATE),
Boolean'Pos (Value)) < 0
then
raise Use_Error;
end if;
end Process;
procedure Do_Set_Validation is new Controlled_Readers.Update (Process);
begin
Do_Set_Validation (Object);
end Set_Validation;
procedure Set_Substitute_Entities (
Object : in out Reader;
Value : in Boolean)
is
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
if C.libxml.xmlreader.xmlTextReaderSetParserProp (
NC_Object.Raw,
C.libxml.xmlreader.xmlParserProperties'Enum_Rep (
C.libxml.xmlreader.XML_PARSER_SUBST_ENTITIES),
Boolean'Pos (Value)) < 0
then
raise Use_Error;
end if;
end Process;
procedure Do_Set_Substitute_Entities is
new Controlled_Readers.Update (Process);
begin
Do_Set_Substitute_Entities (Object);
end Set_Substitute_Entities;
function Version (Object : in out Reader) return access constant String is
Result : access constant String;
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
if NC_Object.Version = null then
Read_Start (NC_Object);
declare
C_Version : constant C.libxml.xmlstring.xmlChar_const_ptr :=
C.libxml.xmlreader.xmlTextReaderConstXmlVersion (NC_Object.Raw);
begin
if C_Version /= null then
declare
A_Version :
String (1 .. Natural (C.string.strlen (To_char_const_ptr (C_Version))));
for A_Version'Address use C_Version.all'Address;
begin
NC_Object.Version := new String'(A_Version);
end;
end if;
end;
end if;
Result := NC_Object.Version;
end Process;
procedure Do_Version is new Controlled_Readers.Update (Process);
begin
Do_Version (Object);
return Result;
end Version;
function Encoding (Object : in out Reader) return Encoding_Type is
Result : Encoding_Type;
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
Read_Start (NC_Object);
Result := Encoding_Type (
C.libxml.encoding.xmlFindCharEncodingHandler (
To_char_const_ptr (
C.libxml.xmlreader.xmlTextReaderConstEncoding (NC_Object.Raw))));
end Process;
procedure Do_Encoding is new Controlled_Readers.Update (Process);
begin
Do_Encoding (Object);
return Result;
end Encoding;
function Standalone (Object : in out Reader) return Standalone_Type is
Result : Standalone_Type;
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
Read_Start (NC_Object);
declare
Standalone_Value : constant C.signed_int :=
C.libxml.xmlreader.xmlTextReaderStandalone (NC_Object.Raw);
begin
if Standalone_Value < -1 then
Result := No_Specific; -- undocumented error
else
Result := Standalone_Type'Enum_Val (Standalone_Value);
end if;
end;
end Process;
procedure Do_Standalone is new Controlled_Readers.Update (Process);
begin
Do_Standalone (Object);
return Result;
end Standalone;
function Base_URI (Object : in out Reader) return String is
Result : C.libxml.xmlstring.xmlChar_const_ptr;
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
Read_Start (NC_Object);
Result := C.libxml.xmlreader.xmlTextReaderConstBaseUri (NC_Object.Raw);
end Process;
procedure Do_Base_URI is new Controlled_Readers.Update (Process);
begin
Do_Base_URI (Object);
return To_String (To_char_const_ptr (Result));
end Base_URI;
procedure Get (
Object : in out Reader;
Process : not null access procedure (Event : in XML.Event))
is
Parsed_Data : Parsed_Data_Type;
begin
Read (Object, Parsed_Data);
Process (Parsed_Data.Event);
end Get;
procedure Get (
Object : in out Reader;
Parsing_Entry : out Parsing_Entry_Type) is
begin
Read (Object, Parsing_Entry.Data);
Parsing_Entry.Assigned := True;
end Get;
procedure Get_Until_Element_End (Object : in out Reader) is
begin
loop
declare
T : Event_Type;
begin
declare
Parsed_Data : Parsed_Data_Type;
begin
Read (Object, Parsed_Data);
T := Parsed_Data.Event.Event_Type;
end;
case T is
when Element_Start =>
Get_Until_Element_End (Object);
when Element_End =>
exit;
when others =>
null;
end case;
end;
end loop;
end Get_Until_Element_End;
procedure Finish (Object : in out Reader) is
procedure Process (NC_Object : in out Non_Controlled_Reader) is
begin
case NC_Object.State is
when Next =>
null;
when Start | Remaining =>
Next (NC_Object);
when Empty_Element =>
raise Data_Error; -- Element_End
end case;
declare
Node_Type : constant C.signed_int :=
C.libxml.xmlreader.xmlTextReaderNodeType (NC_Object.Raw);
begin
if Node_Type /=
C.libxml.xmlreader.xmlReaderTypes'Enum_Rep (
C.libxml.xmlreader.XML_READER_TYPE_NONE)
then
raise Data_Error;
end if;
end;
end Process;
procedure Do_Finish is new Controlled_Readers.Update (Process);
begin
Do_Finish (Object);
end Finish;
function Last_Error_Line (Object : Reader) return Natural is
function Process (NC_Object : Non_Controlled_Reader) return Natural is
Line : Natural := 0;
begin
if NC_Object.Error then
Line := Integer (NC_Object.U.Last_Error.line - 1);
end if;
return Line;
end Process;
function Do_Last_Error_Line is new Controlled_Readers.Query (Natural, Process);
begin
return Do_Last_Error_Line (Object);
end Last_Error_Line;
function Last_Error_Message (Object : Reader) return String is
function Process (NC_Object : Non_Controlled_Reader) return String is
Message : C.char_const_ptr := null;
begin
if NC_Object.Error then
Message := C.char_const_ptr (NC_Object.U.Last_Error.message);
end if;
return To_String_Without_LF (Message);
end Process;
function Do_Last_Error_Message is
new Controlled_Readers.Query (String, Process);
begin
return Do_Last_Error_Message (Object);
end Last_Error_Message;
procedure Install_Error_Handler (
NC_Object : aliased in out Non_Controlled_Reader)
is
package Conv is
new System.Address_To_Access_Conversions (Non_Controlled_Reader);
begin
C.libxml.xmlreader.xmlTextReaderSetStructuredErrorHandler (
NC_Object.Raw,
Reader_Error_Handler'Access,
C.void_ptr (Conv.To_Address (NC_Object'Access)));
end Install_Error_Handler;
procedure Reset_Last_Error (NC_Object : in out Non_Controlled_Reader) is
begin
if NC_Object.Error then
NC_Object.Error := False;
C.libxml.xmlerror.xmlResetError (NC_Object.U.Last_Error'Access);
end if;
end Reset_Last_Error;
procedure Raise_Last_Error (NC_Object : in Non_Controlled_Reader) is
begin
if not NC_Object.Error then
raise Use_Error; -- API reported a failure, but did not callbacked
else
Raise_Error (NC_Object.U.Last_Error'Access);
end if;
end Raise_Last_Error;
package body Controlled_Readers is
function Reference (Object : aliased in out Reader)
return not null access Non_Controlled_Reader;
pragma Inline (Reference);
function Reference (Object : aliased in out Reader)
return not null access Non_Controlled_Reader is
begin
return Object.Data'Access;
end Reference;
-- implementation
function Reference (Object : aliased in out XML.Reader)
return not null access Non_Controlled_Reader is
begin
return Reference (Reader (Object));
end Reference;
function Query (Object : XML.Reader) return Result_Type is
function Query (Object : Reader) return Result_Type;
pragma Inline (Query);
function Query (Object : Reader) return Result_Type is
begin
return Process (Object.Data);
end Query;
begin
return Query (Reader (Object));
end Query;
procedure Update (Object : in out XML.Reader) is
procedure Update (Object : in out Reader);
pragma Inline (Update);
procedure Update (Object : in out Reader) is
begin
Process (Object.Data);
end Update;
begin
Update (Reader (Object));
end Update;
overriding procedure Finalize (Object : in out Reader) is
begin
C.libxml.xmlreader.xmlFreeTextReader (Object.Data.Raw);
Free (Object.Data.Version);
if Object.Data.Error then
C.libxml.xmlerror.xmlResetError (Object.Data.U.Last_Error'Access);
end if;
end Finalize;
end Controlled_Readers;
-- writer
function Write_Handler (
context : C.void_ptr;
buffer : access constant C.char;
len : C.signed_int)
return C.signed_int
with Convention => C;
function Write_Handler (
context : C.void_ptr;
buffer : access constant C.char;
len : C.signed_int)
return C.signed_int
is
type O is access procedure (Item : in String);
function To_Output is new Ada.Unchecked_Conversion (C.void_ptr, O);
Item : String (1 .. Natural (len));
for Item'Address use buffer.all'Address;
begin
To_Output (context) (Item);
return len;
end Write_Handler;
procedure Flush (NC_Object : in Non_Controlled_Writer) is
begin
if C.libxml.xmlwriter.xmlTextWriterFlush (NC_Object.Raw) < 0 then
raise Use_Error;
end if;
end Flush;
procedure Check_No_Zero (S : in String) is
begin
-- one of the design problems of libxml2,
-- it uses zero-terminated strings.
-- user's data may be lost if the data contains '\0', check it here.
if System.Address (
C.string.memchr (C.void_const_ptr (S'Address), 0, S'Length)) /=
System.Null_Address
then
raise Constraint_Error;
end if;
end Check_No_Zero;
-- for standalone
No_Image : constant C.char_array := "no" & C.char'Val (0);
Yes_Image : constant C.char_array := "yes" & C.char'Val (0);
Standalone_Image : constant array (Standalone_Type) of C.char_const_ptr := (
No_Specific => null,
No => No_Image (No_Image'First)'Access,
Yes => Yes_Image (Yes_Image'First)'Access);
-- implementation of writer
function Create (
Output : not null access procedure (Item : in String);
Encoding : Encoding_Type := No_Encoding)
return Writer
is
type O is access procedure (Item : in String);
function To_void_ptr is new Ada.Unchecked_Conversion (O, C.void_ptr);
begin
Check_Version;
declare
Buffer : constant C.libxml.tree.xmlOutputBufferPtr :=
C.libxml.xmlIO.xmlOutputBufferCreateIO (
Write_Handler'Access,
null,
To_void_ptr (Output),
Encoding);
begin
if Buffer = null then
raise Use_Error;
end if;
return Result : Writer do
declare
procedure Process (NC_Result : in out Non_Controlled_Writer) is
begin
NC_Result.Raw := C.libxml.xmlwriter.xmlNewTextWriter (Buffer);
if NC_Result.Raw = null then
declare
Dummy : C.signed_int;
begin
Dummy := C.libxml.xmlIO.xmlOutputBufferClose (Buffer);
end;
raise Use_Error;
end if;
end Process;
procedure Do_Create is new Controlled_Writers.Update (Process);
begin
Do_Create (Result);
end;
end return;
end;
end Create;
function Finished (Object : Writer) return Boolean is
function Process (NC_Object : Non_Controlled_Writer) return Boolean is
begin
return NC_Object.Finished;
end Process;
function Do_Finished is new Controlled_Writers.Query (Boolean, Process);
begin
return Do_Finished (Object);
end Finished;
procedure Flush (Object : in out Writer) is
procedure Process (NC_Object : in out Non_Controlled_Writer) is
begin
Flush (NC_Object);
end Process;
procedure Do_Flush is new Controlled_Writers.Update (Process);
begin
Do_Flush (Object);
end Flush;
procedure Set_Indent (Object : in out Writer; Indent : in Natural) is
procedure Process (NC_Object : in out Non_Controlled_Writer) is
begin
if C.libxml.xmlwriter.xmlTextWriterSetIndent (
NC_Object.Raw,
C.signed_int (Indent)) < 0
then
raise Use_Error;
end if;
end Process;
procedure Do_Set_Indent is new Controlled_Writers.Update (Process);
begin
Do_Set_Indent (Object);
end Set_Indent;
procedure Set_Indent (Object : in out Writer; Indent : in String) is
procedure Process (NC_Object : in out Non_Controlled_Writer) is
Indent_Length : constant C.size_t := Indent'Length;
C_Indent : xmlChar_array (0 .. Indent_Length); -- NUL
begin
memcpy (C_Indent'Address, Indent'Address, Indent_Length);
C_Indent (Indent_Length) := C.libxml.xmlstring.xmlChar'Val (0);
if C.libxml.xmlwriter.xmlTextWriterSetIndentString (
NC_Object.Raw,
C_Indent (C_Indent'First)'Access) < 0
then
raise Use_Error;
end if;
end Process;
procedure Do_Set_Indent is new Controlled_Writers.Update (Process);
begin
Do_Set_Indent (Object);
end Set_Indent;
procedure Put (Object : in out Writer; Event : in XML.Event) is
pragma Check (Pre, Check => not Finished (Object) or else raise Status_Error);
procedure Process (NC_Object : in out Non_Controlled_Writer) is
begin
case Event.Event_Type is
when No_Event =>
raise Data_Error;
when Element_Start =>
Check_No_Zero (Event.Name.all);
declare
Name : String renames Event.Name.all;
Name_Length : constant C.size_t := Name'Length;
C_Name : xmlChar_array (0 .. Name_Length); -- NUL
begin
memcpy (C_Name'Address, Name'Address, Name_Length);
C_Name (Name_Length) := C.libxml.xmlstring.xmlChar'Val (0);
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterStartElement (
NC_Object.Raw,
C_Name (C_Name'First)'Access) < 0
then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end;
when Attribute =>
Check_No_Zero (Event.Name.all);
Check_No_Zero (Event.Value.all);
declare
Name : String renames Event.Name.all;
Name_Length : constant C.size_t := Name'Length;
C_Name : xmlChar_array (0 .. Name_Length); -- NUL
Value : String renames Event.Value.all;
Value_Length : constant C.size_t := Value'Length;
C_Value : xmlChar_array (0 .. Value_Length); -- NUL
begin
memcpy (C_Name'Address, Name'Address, Name_Length);
C_Name (Name_Length) := C.libxml.xmlstring.xmlChar'Val (0);
memcpy (C_Value'Address, Value'Address, Value_Length);
C_Value (Value_Length) := C.libxml.xmlstring.xmlChar'Val (0);
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterWriteAttribute (
NC_Object.Raw,
C_Name (C_Name'First)'Access,
C_Value (C_Value'First)'Access) < 0
then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end;
when Text =>
Check_No_Zero (Event.Content.all);
declare
Content : String renames Event.Content.all;
Content_Length : constant C.size_t := Content'Length;
C_Content : xmlChar_array (0 .. Content_Length); -- NUL
begin
memcpy (C_Content'Address, Content'Address, Content_Length);
C_Content (Content_Length) := C.libxml.xmlstring.xmlChar'Val (0);
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterWriteString (
NC_Object.Raw,
C_Content (C_Content'First)'Access) < 0
then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end;
when CDATA =>
Check_No_Zero (Event.Content.all);
declare
Content : String renames Event.Content.all;
Content_Length : constant C.size_t := Content'Length;
C_Content : xmlChar_array (0 .. Content_Length); -- NUL
begin
memcpy (C_Content'Address, Content'Address, Content_Length);
C_Content (Content_Length) := C.libxml.xmlstring.xmlChar'Val (0);
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterWriteCDATA (
NC_Object.Raw,
C_Content (C_Content'First)'Access) < 0
then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end;
when Entity_Reference =>
raise Program_Error; -- unimplemented
when Entity_Start =>
raise Program_Error; -- unimplemented
when Processing_Instruction =>
raise Program_Error; -- unimplemented
when Comment =>
Check_No_Zero (Event.Content.all);
declare
Content : String renames Event.Content.all;
Content_Length : constant C.size_t := Content'Length;
C_Content : xmlChar_array (0 .. Content_Length); -- NUL
begin
memcpy (C_Content'Address, Content'Address, Content_Length);
C_Content (Content_Length) := C.libxml.xmlstring.xmlChar'Val (0);
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterWriteComment (
NC_Object.Raw,
C_Content (C_Content'First)'Access) < 0
then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end;
when Document =>
raise Program_Error; -- unimplemented
when Document_Type =>
declare
Public_Id_Length : C.size_t := 0;
System_Id_Length : C.size_t := 0;
Subset_Length : C.size_t := 0;
begin
Check_No_Zero (Event.Name.all);
if Event.Public_Id /= null then
Check_No_Zero (Event.Public_Id.all);
Public_Id_Length := Event.Public_Id'Length + 1;
end if;
if Event.System_Id /= null then
Check_No_Zero (Event.System_Id.all);
System_Id_Length := Event.System_Id'Length + 1;
end if;
if Event.Subset /= null then
Check_No_Zero (Event.Subset.all);
Subset_Length := Event.Subset'Length + 1;
end if;
declare
Name : String renames Event.Name.all;
Name_Length : constant C.size_t := Name'Length;
C_Name : xmlChar_array (0 .. Name_Length); -- NULL
C_Public_Id : xmlChar_array (0 .. Public_Id_Length); -- NUL
P_Public_Id : access constant C.libxml.xmlstring.xmlChar;
C_System_Id : xmlChar_array (0 .. System_Id_Length); -- NUL
P_System_Id : access constant C.libxml.xmlstring.xmlChar;
C_Subset : xmlChar_array (0 .. Subset_Length); -- NUL
P_Subset : access constant C.libxml.xmlstring.xmlChar;
begin
memcpy (C_Name'Address, Name'Address, Name_Length);
C_Name (Name_Length) := C.libxml.xmlstring.xmlChar'Val (0);
if Event.Public_Id /= null then
memcpy (C_Public_Id'Address, Event.Public_Id.all'Address, Public_Id_Length);
C_Public_Id (Public_Id_Length) := C.libxml.xmlstring.xmlChar'Val (0);
P_Public_Id := C_Public_Id (C_Public_Id'First)'Access;
end if;
if Event.System_Id /= null then
memcpy (C_System_Id'Address, Event.System_Id.all'Address, System_Id_Length);
C_System_Id (System_Id_Length) := C.libxml.xmlstring.xmlChar'Val (0);
P_System_Id := C_System_Id (C_System_Id'First)'Access;
end if;
if Event.Subset /= null then
memcpy (C_Subset'Address, Event.Subset.all'Address, Subset_Length);
C_Subset (Subset_Length) := C.libxml.xmlstring.xmlChar'Val (0);
P_Subset := C_Subset (C_Subset'First)'Access;
end if;
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterWriteDocType (
NC_Object.Raw,
C_Name (C_Name'First)'Access,
P_Public_Id,
P_System_Id,
P_Subset) < 0
then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end;
end;
when Document_Fragment =>
raise Program_Error; -- unimplemented
when Notation =>
raise Program_Error; -- unimplemented
when Whitespace =>
raise Program_Error; -- unimplemented
when Significant_Whitespace =>
raise Program_Error; -- unimplemented
when Element_End =>
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterEndElement (NC_Object.Raw) < 0 then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
when Entity_End =>
raise Program_Error; -- unimplemented
when XML_Declaration =>
raise Program_Error; -- unimplemented
end case;
end Process;
procedure Do_Put is new Controlled_Writers.Update (Process);
begin
Do_Put (Object);
end Put;
procedure Put_Document_Start (
Object : in out Writer;
Version : access constant String := null;
Encoding : Encoding_Type := No_Encoding;
Standalone : Standalone_Type := No_Specific)
is
pragma Check (Pre, Check => not Finished (Object) or else raise Status_Error);
procedure Process (NC_Object : in out Non_Controlled_Writer) is
Version_Length : C.size_t := 0;
begin
if Version /= null then
Check_No_Zero (Version.all);
Version_Length := Version'Length + 1;
end if;
declare
C_Version : C.char_array (0 .. Version_Length); -- NUL
P_Version : access constant C.char := null;
P_Encoding : access constant C.char := null;
begin
if Version /= null then
memcpy (C_Version'Address, Version.all'Address, Version_Length);
C_Version (Version_Length) := C.char'Val (0);
P_Version := C_Version (C_Version'First)'Access;
end if;
if Encoding /= null then
P_Encoding := Encoding.name;
end if;
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterStartDocument (
NC_Object.Raw,
P_Version,
P_Encoding,
Standalone_Image (Standalone)) < 0
then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end;
end Process;
procedure Do_Put_Document_Start is new Controlled_Writers.Update (Process);
begin
Do_Put_Document_Start (Object);
end Put_Document_Start;
procedure Put_Document_End (Object : in out Writer) is
pragma Check (Pre, Check => not Finished (Object) or else raise Status_Error);
procedure Process (NC_Object : in out Non_Controlled_Writer) is
begin
C.libxml.xmlerror.xmlResetLastError;
if C.libxml.xmlwriter.xmlTextWriterEndDocument (NC_Object.Raw) < 0 then
Raise_Error (C.libxml.xmlerror.xmlGetLastError);
end if;
end Process;
procedure Do_Put_Document_End is new Controlled_Writers.Update (Process);
begin
Do_Put_Document_End (Object);
end Put_Document_End;
procedure Finish (Object : in out Writer) is
pragma Check (Pre, Check => not Finished (Object) or else raise Status_Error);
procedure Process (NC_Object : in out Non_Controlled_Writer) is
begin
NC_Object.Finished := True;
Flush (NC_Object);
end Process;
procedure Do_Finish is new Controlled_Writers.Update (Process);
begin
Do_Finish (Object);
end Finish;
package body Controlled_Writers is
function Query (Object : XML.Writer) return Result_Type is
function Query (Object : Writer) return Result_Type;
pragma Inline (Query);
function Query (Object : Writer) return Result_Type is
begin
return Process (Object.Data);
end Query;
begin
return Query (Writer (Object));
end Query;
procedure Update (Object : in out XML.Writer) is
procedure Update (Object : in out Writer);
pragma Inline (Update);
procedure Update (Object : in out Writer) is
begin
Process (Object.Data);
end Update;
begin
Update (Writer (Object));
end Update;
overriding procedure Finalize (Object : in out Writer) is
begin
C.libxml.xmlwriter.xmlFreeTextWriter (Object.Data.Raw);
end Finalize;
end Controlled_Writers;
-- implementation of exceptions
procedure Raise_Error (Error : access constant C.libxml.xmlerror.xmlError) is
function Location return String is
begin
if Error.line = 0 then
return "";
else
return "line" & C.signed_int'Image (Error.line - 1) & ": ";
end if;
end Location;
begin
if Error = null then
raise Use_Error; -- ???
else
case Error.code is
when C.libxml.xmlerror.xmlParserErrors'Enum_Rep (
C.libxml.xmlerror.XML_ERR_OK) =>
raise Use_Error;
when C.libxml.xmlerror.xmlParserErrors'Enum_Rep (
C.libxml.xmlerror.XML_ERR_NO_MEMORY) =>
raise Storage_Error;
when others =>
raise Data_Error with Location & To_String_Without_LF (Error.message);
end case;
end if;
end Raise_Error;
end XML;
|
reznikmm/matreshka | Ada | 4,624 | 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_Chart.Logarithmic_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Logarithmic_Attribute_Node is
begin
return Self : Chart_Logarithmic_Attribute_Node do
Matreshka.ODF_Chart.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Chart_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Chart_Logarithmic_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Logarithmic_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Chart_URI,
Matreshka.ODF_String_Constants.Logarithmic_Attribute,
Chart_Logarithmic_Attribute_Node'Tag);
end Matreshka.ODF_Chart.Logarithmic_Attributes;
|
meowthsli/EVB1000 | Ada | 51,610 | ads | -- This spec has been automatically generated from STM32F105xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with System;
package STM32.TIM is
pragma Preelaborate;
---------------
-- Registers --
---------------
------------------
-- CR1_Register --
------------------
subtype CR1_CEN_Field is STM32.Bit;
subtype CR1_UDIS_Field is STM32.Bit;
subtype CR1_URS_Field is STM32.Bit;
subtype CR1_OPM_Field is STM32.Bit;
subtype CR1_DIR_Field is STM32.Bit;
subtype CR1_CMS_Field is STM32.UInt2;
subtype CR1_ARPE_Field is STM32.Bit;
subtype CR1_CKD_Field is STM32.UInt2;
-- control register 1
type CR1_Register is record
-- Counter enable
CEN : CR1_CEN_Field := 16#0#;
-- Update disable
UDIS : CR1_UDIS_Field := 16#0#;
-- Update request source
URS : CR1_URS_Field := 16#0#;
-- One-pulse mode
OPM : CR1_OPM_Field := 16#0#;
-- Direction
DIR : CR1_DIR_Field := 16#0#;
-- Center-aligned mode selection
CMS : CR1_CMS_Field := 16#0#;
-- Auto-reload preload enable
ARPE : CR1_ARPE_Field := 16#0#;
-- Clock division
CKD : CR1_CKD_Field := 16#0#;
-- unspecified
Reserved_10_31 : STM32.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
CEN at 0 range 0 .. 0;
UDIS at 0 range 1 .. 1;
URS at 0 range 2 .. 2;
OPM at 0 range 3 .. 3;
DIR at 0 range 4 .. 4;
CMS at 0 range 5 .. 6;
ARPE at 0 range 7 .. 7;
CKD at 0 range 8 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
------------------
-- CR2_Register --
------------------
subtype CR2_CCPC_Field is STM32.Bit;
subtype CR2_CCUS_Field is STM32.Bit;
subtype CR2_CCDS_Field is STM32.Bit;
subtype CR2_MMS_Field is STM32.UInt3;
subtype CR2_TI1S_Field is STM32.Bit;
subtype CR2_OIS1_Field is STM32.Bit;
subtype CR2_OIS1N_Field is STM32.Bit;
subtype CR2_OIS2_Field is STM32.Bit;
subtype CR2_OIS2N_Field is STM32.Bit;
subtype CR2_OIS3_Field is STM32.Bit;
subtype CR2_OIS3N_Field is STM32.Bit;
subtype CR2_OIS4_Field is STM32.Bit;
-- control register 2
type CR2_Register is record
-- Capture/compare preloaded control
CCPC : CR2_CCPC_Field := 16#0#;
-- unspecified
Reserved_1_1 : STM32.Bit := 16#0#;
-- Capture/compare control update selection
CCUS : CR2_CCUS_Field := 16#0#;
-- Capture/compare DMA selection
CCDS : CR2_CCDS_Field := 16#0#;
-- Master mode selection
MMS : CR2_MMS_Field := 16#0#;
-- TI1 selection
TI1S : CR2_TI1S_Field := 16#0#;
-- Output Idle state 1
OIS1 : CR2_OIS1_Field := 16#0#;
-- Output Idle state 1
OIS1N : CR2_OIS1N_Field := 16#0#;
-- Output Idle state 2
OIS2 : CR2_OIS2_Field := 16#0#;
-- Output Idle state 2
OIS2N : CR2_OIS2N_Field := 16#0#;
-- Output Idle state 3
OIS3 : CR2_OIS3_Field := 16#0#;
-- Output Idle state 3
OIS3N : CR2_OIS3N_Field := 16#0#;
-- Output Idle state 4
OIS4 : CR2_OIS4_Field := 16#0#;
-- unspecified
Reserved_15_31 : STM32.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
CCPC at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CCUS at 0 range 2 .. 2;
CCDS at 0 range 3 .. 3;
MMS at 0 range 4 .. 6;
TI1S at 0 range 7 .. 7;
OIS1 at 0 range 8 .. 8;
OIS1N at 0 range 9 .. 9;
OIS2 at 0 range 10 .. 10;
OIS2N at 0 range 11 .. 11;
OIS3 at 0 range 12 .. 12;
OIS3N at 0 range 13 .. 13;
OIS4 at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-------------------
-- SMCR_Register --
-------------------
subtype SMCR_SMS_Field is STM32.UInt3;
subtype SMCR_TS_Field is STM32.UInt3;
subtype SMCR_MSM_Field is STM32.Bit;
subtype SMCR_ETF_Field is STM32.UInt4;
subtype SMCR_ETPS_Field is STM32.UInt2;
subtype SMCR_ECE_Field is STM32.Bit;
subtype SMCR_ETP_Field is STM32.Bit;
-- slave mode control register
type SMCR_Register is record
-- Slave mode selection
SMS : SMCR_SMS_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32.Bit := 16#0#;
-- Trigger selection
TS : SMCR_TS_Field := 16#0#;
-- Master/Slave mode
MSM : SMCR_MSM_Field := 16#0#;
-- External trigger filter
ETF : SMCR_ETF_Field := 16#0#;
-- External trigger prescaler
ETPS : SMCR_ETPS_Field := 16#0#;
-- External clock enable
ECE : SMCR_ECE_Field := 16#0#;
-- External trigger polarity
ETP : SMCR_ETP_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMCR_Register use record
SMS at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
TS at 0 range 4 .. 6;
MSM at 0 range 7 .. 7;
ETF at 0 range 8 .. 11;
ETPS at 0 range 12 .. 13;
ECE at 0 range 14 .. 14;
ETP at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
subtype DIER_UIE_Field is STM32.Bit;
subtype DIER_CC1IE_Field is STM32.Bit;
subtype DIER_CC2IE_Field is STM32.Bit;
subtype DIER_CC3IE_Field is STM32.Bit;
subtype DIER_CC4IE_Field is STM32.Bit;
subtype DIER_COMIE_Field is STM32.Bit;
subtype DIER_TIE_Field is STM32.Bit;
subtype DIER_BIE_Field is STM32.Bit;
subtype DIER_UDE_Field is STM32.Bit;
subtype DIER_CC1DE_Field is STM32.Bit;
subtype DIER_CC2DE_Field is STM32.Bit;
subtype DIER_CC3DE_Field is STM32.Bit;
subtype DIER_CC4DE_Field is STM32.Bit;
subtype DIER_COMDE_Field is STM32.Bit;
subtype DIER_TDE_Field is STM32.Bit;
-- DMA/Interrupt enable register
type DIER_Register is record
-- Update interrupt enable
UIE : DIER_UIE_Field := 16#0#;
-- Capture/Compare 1 interrupt enable
CC1IE : DIER_CC1IE_Field := 16#0#;
-- Capture/Compare 2 interrupt enable
CC2IE : DIER_CC2IE_Field := 16#0#;
-- Capture/Compare 3 interrupt enable
CC3IE : DIER_CC3IE_Field := 16#0#;
-- Capture/Compare 4 interrupt enable
CC4IE : DIER_CC4IE_Field := 16#0#;
-- COM interrupt enable
COMIE : DIER_COMIE_Field := 16#0#;
-- Trigger interrupt enable
TIE : DIER_TIE_Field := 16#0#;
-- Break interrupt enable
BIE : DIER_BIE_Field := 16#0#;
-- Update DMA request enable
UDE : DIER_UDE_Field := 16#0#;
-- Capture/Compare 1 DMA request enable
CC1DE : DIER_CC1DE_Field := 16#0#;
-- Capture/Compare 2 DMA request enable
CC2DE : DIER_CC2DE_Field := 16#0#;
-- Capture/Compare 3 DMA request enable
CC3DE : DIER_CC3DE_Field := 16#0#;
-- Capture/Compare 4 DMA request enable
CC4DE : DIER_CC4DE_Field := 16#0#;
-- Reserved
COMDE : DIER_COMDE_Field := 16#0#;
-- Trigger DMA request enable
TDE : DIER_TDE_Field := 16#0#;
-- unspecified
Reserved_15_31 : STM32.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
CC2IE at 0 range 2 .. 2;
CC3IE at 0 range 3 .. 3;
CC4IE at 0 range 4 .. 4;
COMIE at 0 range 5 .. 5;
TIE at 0 range 6 .. 6;
BIE at 0 range 7 .. 7;
UDE at 0 range 8 .. 8;
CC1DE at 0 range 9 .. 9;
CC2DE at 0 range 10 .. 10;
CC3DE at 0 range 11 .. 11;
CC4DE at 0 range 12 .. 12;
COMDE at 0 range 13 .. 13;
TDE at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
subtype SR_UIF_Field is STM32.Bit;
subtype SR_CC1IF_Field is STM32.Bit;
subtype SR_CC2IF_Field is STM32.Bit;
subtype SR_CC3IF_Field is STM32.Bit;
subtype SR_CC4IF_Field is STM32.Bit;
subtype SR_COMIF_Field is STM32.Bit;
subtype SR_TIF_Field is STM32.Bit;
subtype SR_BIF_Field is STM32.Bit;
subtype SR_CC1OF_Field is STM32.Bit;
subtype SR_CC2OF_Field is STM32.Bit;
subtype SR_CC3OF_Field is STM32.Bit;
subtype SR_CC4OF_Field is STM32.Bit;
-- status register
type SR_Register is record
-- Update interrupt flag
UIF : SR_UIF_Field := 16#0#;
-- Capture/compare 1 interrupt flag
CC1IF : SR_CC1IF_Field := 16#0#;
-- Capture/Compare 2 interrupt flag
CC2IF : SR_CC2IF_Field := 16#0#;
-- Capture/Compare 3 interrupt flag
CC3IF : SR_CC3IF_Field := 16#0#;
-- Capture/Compare 4 interrupt flag
CC4IF : SR_CC4IF_Field := 16#0#;
-- COM interrupt flag
COMIF : SR_COMIF_Field := 16#0#;
-- Trigger interrupt flag
TIF : SR_TIF_Field := 16#0#;
-- Break interrupt flag
BIF : SR_BIF_Field := 16#0#;
-- unspecified
Reserved_8_8 : STM32.Bit := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : SR_CC1OF_Field := 16#0#;
-- Capture/compare 2 overcapture flag
CC2OF : SR_CC2OF_Field := 16#0#;
-- Capture/Compare 3 overcapture flag
CC3OF : SR_CC3OF_Field := 16#0#;
-- Capture/Compare 4 overcapture flag
CC4OF : SR_CC4OF_Field := 16#0#;
-- unspecified
Reserved_13_31 : STM32.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
CC2IF at 0 range 2 .. 2;
CC3IF at 0 range 3 .. 3;
CC4IF at 0 range 4 .. 4;
COMIF at 0 range 5 .. 5;
TIF at 0 range 6 .. 6;
BIF at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
CC1OF at 0 range 9 .. 9;
CC2OF at 0 range 10 .. 10;
CC3OF at 0 range 11 .. 11;
CC4OF at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
------------------
-- EGR_Register --
------------------
subtype EGR_UG_Field is STM32.Bit;
subtype EGR_CC1G_Field is STM32.Bit;
subtype EGR_CC2G_Field is STM32.Bit;
subtype EGR_CC3G_Field is STM32.Bit;
subtype EGR_CC4G_Field is STM32.Bit;
subtype EGR_COMG_Field is STM32.Bit;
subtype EGR_TG_Field is STM32.Bit;
subtype EGR_BG_Field is STM32.Bit;
-- event generation register
type EGR_Register is record
-- Write-only. Update generation
UG : EGR_UG_Field := 16#0#;
-- Write-only. Capture/compare 1 generation
CC1G : EGR_CC1G_Field := 16#0#;
-- Write-only. Capture/compare 2 generation
CC2G : EGR_CC2G_Field := 16#0#;
-- Write-only. Capture/compare 3 generation
CC3G : EGR_CC3G_Field := 16#0#;
-- Write-only. Capture/compare 4 generation
CC4G : EGR_CC4G_Field := 16#0#;
-- Write-only. Capture/Compare control update generation
COMG : EGR_COMG_Field := 16#0#;
-- Write-only. Trigger generation
TG : EGR_TG_Field := 16#0#;
-- Write-only. Break generation
BG : EGR_BG_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
CC2G at 0 range 2 .. 2;
CC3G at 0 range 3 .. 3;
CC4G at 0 range 4 .. 4;
COMG at 0 range 5 .. 5;
TG at 0 range 6 .. 6;
BG at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
---------------------------
-- CCMR1_Output_Register --
---------------------------
subtype CCMR1_Output_CC1S_Field is STM32.UInt2;
subtype CCMR1_Output_OC1FE_Field is STM32.Bit;
subtype CCMR1_Output_OC1PE_Field is STM32.Bit;
subtype CCMR1_Output_OC1M_Field is STM32.UInt3;
subtype CCMR1_Output_OC1CE_Field is STM32.Bit;
subtype CCMR1_Output_CC2S_Field is STM32.UInt2;
subtype CCMR1_Output_OC2FE_Field is STM32.Bit;
subtype CCMR1_Output_OC2PE_Field is STM32.Bit;
subtype CCMR1_Output_OC2M_Field is STM32.UInt3;
subtype CCMR1_Output_OC2CE_Field is STM32.Bit;
-- capture/compare mode register (output mode)
type CCMR1_Output_Register is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Output_CC1S_Field := 16#0#;
-- Output Compare 1 fast enable
OC1FE : CCMR1_Output_OC1FE_Field := 16#0#;
-- Output Compare 1 preload enable
OC1PE : CCMR1_Output_OC1PE_Field := 16#0#;
-- Output Compare 1 mode
OC1M : CCMR1_Output_OC1M_Field := 16#0#;
-- Output Compare 1 clear enable
OC1CE : CCMR1_Output_OC1CE_Field := 16#0#;
-- Capture/Compare 2 selection
CC2S : CCMR1_Output_CC2S_Field := 16#0#;
-- Output Compare 2 fast enable
OC2FE : CCMR1_Output_OC2FE_Field := 16#0#;
-- Output Compare 2 preload enable
OC2PE : CCMR1_Output_OC2PE_Field := 16#0#;
-- Output Compare 2 mode
OC2M : CCMR1_Output_OC2M_Field := 16#0#;
-- Output Compare 2 clear enable
OC2CE : CCMR1_Output_OC2CE_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Output_Register use record
CC1S at 0 range 0 .. 1;
OC1FE at 0 range 2 .. 2;
OC1PE at 0 range 3 .. 3;
OC1M at 0 range 4 .. 6;
OC1CE at 0 range 7 .. 7;
CC2S at 0 range 8 .. 9;
OC2FE at 0 range 10 .. 10;
OC2PE at 0 range 11 .. 11;
OC2M at 0 range 12 .. 14;
OC2CE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------------
-- CCMR1_Input_Register --
--------------------------
subtype CCMR1_Input_CC1S_Field is STM32.UInt2;
subtype CCMR1_Input_ICPCS_Field is STM32.UInt2;
subtype CCMR1_Input_IC1F_Field is STM32.UInt4;
subtype CCMR1_Input_CC2S_Field is STM32.UInt2;
subtype CCMR1_Input_IC2PCS_Field is STM32.UInt2;
subtype CCMR1_Input_IC2F_Field is STM32.UInt4;
-- capture/compare mode register 1 (input mode)
type CCMR1_Input_Register is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Input_CC1S_Field := 16#0#;
-- Input capture 1 prescaler
ICPCS : CCMR1_Input_ICPCS_Field := 16#0#;
-- Input capture 1 filter
IC1F : CCMR1_Input_IC1F_Field := 16#0#;
-- Capture/Compare 2 selection
CC2S : CCMR1_Input_CC2S_Field := 16#0#;
-- Input capture 2 prescaler
IC2PCS : CCMR1_Input_IC2PCS_Field := 16#0#;
-- Input capture 2 filter
IC2F : CCMR1_Input_IC2F_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Input_Register use record
CC1S at 0 range 0 .. 1;
ICPCS at 0 range 2 .. 3;
IC1F at 0 range 4 .. 7;
CC2S at 0 range 8 .. 9;
IC2PCS at 0 range 10 .. 11;
IC2F at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
---------------------------
-- CCMR2_Output_Register --
---------------------------
subtype CCMR2_Output_CC3S_Field is STM32.UInt2;
subtype CCMR2_Output_OC3FE_Field is STM32.Bit;
subtype CCMR2_Output_OC3PE_Field is STM32.Bit;
subtype CCMR2_Output_OC3M_Field is STM32.UInt3;
subtype CCMR2_Output_OC3CE_Field is STM32.Bit;
subtype CCMR2_Output_CC4S_Field is STM32.UInt2;
subtype CCMR2_Output_OC4FE_Field is STM32.Bit;
subtype CCMR2_Output_OC4PE_Field is STM32.Bit;
subtype CCMR2_Output_OC4M_Field is STM32.UInt3;
subtype CCMR2_Output_OC4CE_Field is STM32.Bit;
-- capture/compare mode register (output mode)
type CCMR2_Output_Register is record
-- Capture/Compare 3 selection
CC3S : CCMR2_Output_CC3S_Field := 16#0#;
-- Output compare 3 fast enable
OC3FE : CCMR2_Output_OC3FE_Field := 16#0#;
-- Output compare 3 preload enable
OC3PE : CCMR2_Output_OC3PE_Field := 16#0#;
-- Output compare 3 mode
OC3M : CCMR2_Output_OC3M_Field := 16#0#;
-- Output compare 3 clear enable
OC3CE : CCMR2_Output_OC3CE_Field := 16#0#;
-- Capture/Compare 4 selection
CC4S : CCMR2_Output_CC4S_Field := 16#0#;
-- Output compare 4 fast enable
OC4FE : CCMR2_Output_OC4FE_Field := 16#0#;
-- Output compare 4 preload enable
OC4PE : CCMR2_Output_OC4PE_Field := 16#0#;
-- Output compare 4 mode
OC4M : CCMR2_Output_OC4M_Field := 16#0#;
-- Output compare 4 clear enable
OC4CE : CCMR2_Output_OC4CE_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR2_Output_Register use record
CC3S at 0 range 0 .. 1;
OC3FE at 0 range 2 .. 2;
OC3PE at 0 range 3 .. 3;
OC3M at 0 range 4 .. 6;
OC3CE at 0 range 7 .. 7;
CC4S at 0 range 8 .. 9;
OC4FE at 0 range 10 .. 10;
OC4PE at 0 range 11 .. 11;
OC4M at 0 range 12 .. 14;
OC4CE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------------
-- CCMR2_Input_Register --
--------------------------
subtype CCMR2_Input_CC3S_Field is STM32.UInt2;
subtype CCMR2_Input_IC3PSC_Field is STM32.UInt2;
subtype CCMR2_Input_IC3F_Field is STM32.UInt4;
subtype CCMR2_Input_CC4S_Field is STM32.UInt2;
subtype CCMR2_Input_IC4PSC_Field is STM32.UInt2;
subtype CCMR2_Input_IC4F_Field is STM32.UInt4;
-- capture/compare mode register 2 (input mode)
type CCMR2_Input_Register is record
-- Capture/compare 3 selection
CC3S : CCMR2_Input_CC3S_Field := 16#0#;
-- Input capture 3 prescaler
IC3PSC : CCMR2_Input_IC3PSC_Field := 16#0#;
-- Input capture 3 filter
IC3F : CCMR2_Input_IC3F_Field := 16#0#;
-- Capture/Compare 4 selection
CC4S : CCMR2_Input_CC4S_Field := 16#0#;
-- Input capture 4 prescaler
IC4PSC : CCMR2_Input_IC4PSC_Field := 16#0#;
-- Input capture 4 filter
IC4F : CCMR2_Input_IC4F_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR2_Input_Register use record
CC3S at 0 range 0 .. 1;
IC3PSC at 0 range 2 .. 3;
IC3F at 0 range 4 .. 7;
CC4S at 0 range 8 .. 9;
IC4PSC at 0 range 10 .. 11;
IC4F at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCER_Register --
-------------------
subtype CCER_CC1E_Field is STM32.Bit;
subtype CCER_CC1P_Field is STM32.Bit;
subtype CCER_CC1NE_Field is STM32.Bit;
subtype CCER_CC1NP_Field is STM32.Bit;
subtype CCER_CC2E_Field is STM32.Bit;
subtype CCER_CC2P_Field is STM32.Bit;
subtype CCER_CC2NE_Field is STM32.Bit;
subtype CCER_CC2NP_Field is STM32.Bit;
subtype CCER_CC3E_Field is STM32.Bit;
subtype CCER_CC3P_Field is STM32.Bit;
subtype CCER_CC3NE_Field is STM32.Bit;
subtype CCER_CC3NP_Field is STM32.Bit;
subtype CCER_CC4E_Field is STM32.Bit;
subtype CCER_CC4P_Field is STM32.Bit;
-- capture/compare enable register
type CCER_Register is record
-- Capture/Compare 1 output enable
CC1E : CCER_CC1E_Field := 16#0#;
-- Capture/Compare 1 output Polarity
CC1P : CCER_CC1P_Field := 16#0#;
-- Capture/Compare 1 complementary output enable
CC1NE : CCER_CC1NE_Field := 16#0#;
-- Capture/Compare 1 output Polarity
CC1NP : CCER_CC1NP_Field := 16#0#;
-- Capture/Compare 2 output enable
CC2E : CCER_CC2E_Field := 16#0#;
-- Capture/Compare 2 output Polarity
CC2P : CCER_CC2P_Field := 16#0#;
-- Capture/Compare 2 complementary output enable
CC2NE : CCER_CC2NE_Field := 16#0#;
-- Capture/Compare 2 output Polarity
CC2NP : CCER_CC2NP_Field := 16#0#;
-- Capture/Compare 3 output enable
CC3E : CCER_CC3E_Field := 16#0#;
-- Capture/Compare 3 output Polarity
CC3P : CCER_CC3P_Field := 16#0#;
-- Capture/Compare 3 complementary output enable
CC3NE : CCER_CC3NE_Field := 16#0#;
-- Capture/Compare 3 output Polarity
CC3NP : CCER_CC3NP_Field := 16#0#;
-- Capture/Compare 4 output enable
CC4E : CCER_CC4E_Field := 16#0#;
-- Capture/Compare 3 output Polarity
CC4P : CCER_CC4P_Field := 16#0#;
-- unspecified
Reserved_14_31 : STM32.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCER_Register use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
CC1NE at 0 range 2 .. 2;
CC1NP at 0 range 3 .. 3;
CC2E at 0 range 4 .. 4;
CC2P at 0 range 5 .. 5;
CC2NE at 0 range 6 .. 6;
CC2NP at 0 range 7 .. 7;
CC3E at 0 range 8 .. 8;
CC3P at 0 range 9 .. 9;
CC3NE at 0 range 10 .. 10;
CC3NP at 0 range 11 .. 11;
CC4E at 0 range 12 .. 12;
CC4P at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
------------------
-- CNT_Register --
------------------
subtype CNT_CNT_Field is STM32.Short;
-- counter
type CNT_Register is record
-- counter value
CNT : CNT_CNT_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CNT_Register use record
CNT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- PSC_Register --
------------------
subtype PSC_PSC_Field is STM32.Short;
-- prescaler
type PSC_Register is record
-- Prescaler value
PSC : PSC_PSC_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PSC_Register use record
PSC at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- ARR_Register --
------------------
subtype ARR_ARR_Field is STM32.Short;
-- auto-reload register
type ARR_Register is record
-- Auto-reload value
ARR : ARR_ARR_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ARR_Register use record
ARR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- RCR_Register --
------------------
subtype RCR_REP_Field is STM32.Byte;
-- repetition counter register
type RCR_Register is record
-- Repetition counter value
REP : RCR_REP_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RCR_Register use record
REP at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- CCR1_Register --
-------------------
subtype CCR1_CCR1_Field is STM32.Short;
-- capture/compare register 1
type CCR1_Register is record
-- Capture/Compare 1 value
CCR1 : CCR1_CCR1_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR1_Register use record
CCR1 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCR2_Register --
-------------------
subtype CCR2_CCR2_Field is STM32.Short;
-- capture/compare register 2
type CCR2_Register is record
-- Capture/Compare 2 value
CCR2 : CCR2_CCR2_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR2_Register use record
CCR2 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCR3_Register --
-------------------
subtype CCR3_CCR3_Field is STM32.Short;
-- capture/compare register 3
type CCR3_Register is record
-- Capture/Compare value
CCR3 : CCR3_CCR3_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR3_Register use record
CCR3 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCR4_Register --
-------------------
subtype CCR4_CCR4_Field is STM32.Short;
-- capture/compare register 4
type CCR4_Register is record
-- Capture/Compare value
CCR4 : CCR4_CCR4_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR4_Register use record
CCR4 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- BDTR_Register --
-------------------
subtype BDTR_DTG_Field is STM32.Byte;
subtype BDTR_LOCK_Field is STM32.UInt2;
subtype BDTR_OSSI_Field is STM32.Bit;
subtype BDTR_OSSR_Field is STM32.Bit;
subtype BDTR_BKE_Field is STM32.Bit;
subtype BDTR_BKP_Field is STM32.Bit;
subtype BDTR_AOE_Field is STM32.Bit;
subtype BDTR_MOE_Field is STM32.Bit;
-- break and dead-time register
type BDTR_Register is record
-- Dead-time generator setup
DTG : BDTR_DTG_Field := 16#0#;
-- Lock configuration
LOCK : BDTR_LOCK_Field := 16#0#;
-- Off-state selection for Idle mode
OSSI : BDTR_OSSI_Field := 16#0#;
-- Off-state selection for Run mode
OSSR : BDTR_OSSR_Field := 16#0#;
-- Break enable
BKE : BDTR_BKE_Field := 16#0#;
-- Break polarity
BKP : BDTR_BKP_Field := 16#0#;
-- Automatic output enable
AOE : BDTR_AOE_Field := 16#0#;
-- Main output enable
MOE : BDTR_MOE_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BDTR_Register use record
DTG at 0 range 0 .. 7;
LOCK at 0 range 8 .. 9;
OSSI at 0 range 10 .. 10;
OSSR at 0 range 11 .. 11;
BKE at 0 range 12 .. 12;
BKP at 0 range 13 .. 13;
AOE at 0 range 14 .. 14;
MOE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DCR_Register --
------------------
subtype DCR_DBA_Field is STM32.UInt5;
subtype DCR_DBL_Field is STM32.UInt5;
-- DMA control register
type DCR_Register is record
-- DMA base address
DBA : DCR_DBA_Field := 16#0#;
-- unspecified
Reserved_5_7 : STM32.UInt3 := 16#0#;
-- DMA burst length
DBL : DCR_DBL_Field := 16#0#;
-- unspecified
Reserved_13_31 : STM32.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DCR_Register use record
DBA at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
DBL at 0 range 8 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
-------------------
-- DMAR_Register --
-------------------
subtype DMAR_DMAB_Field is STM32.Short;
-- DMA address for full transfer
type DMAR_Register is record
-- DMA register for burst accesses
DMAB : DMAR_DMAB_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAR_Register use record
DMAB at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- CR2_Register --
------------------
-- control register 2
type CR2_Register_1 is record
-- unspecified
Reserved_0_2 : STM32.UInt3 := 16#0#;
-- Capture/compare DMA selection
CCDS : CR2_CCDS_Field := 16#0#;
-- Master mode selection
MMS : CR2_MMS_Field := 16#0#;
-- TI1 selection
TI1S : CR2_TI1S_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register_1 use record
Reserved_0_2 at 0 range 0 .. 2;
CCDS at 0 range 3 .. 3;
MMS at 0 range 4 .. 6;
TI1S at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
-- DMA/Interrupt enable register
type DIER_Register_1 is record
-- Update interrupt enable
UIE : DIER_UIE_Field := 16#0#;
-- Capture/Compare 1 interrupt enable
CC1IE : DIER_CC1IE_Field := 16#0#;
-- Capture/Compare 2 interrupt enable
CC2IE : DIER_CC2IE_Field := 16#0#;
-- Capture/Compare 3 interrupt enable
CC3IE : DIER_CC3IE_Field := 16#0#;
-- Capture/Compare 4 interrupt enable
CC4IE : DIER_CC4IE_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32.Bit := 16#0#;
-- Trigger interrupt enable
TIE : DIER_TIE_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32.Bit := 16#0#;
-- Update DMA request enable
UDE : DIER_UDE_Field := 16#0#;
-- Capture/Compare 1 DMA request enable
CC1DE : DIER_CC1DE_Field := 16#0#;
-- Capture/Compare 2 DMA request enable
CC2DE : DIER_CC2DE_Field := 16#0#;
-- Capture/Compare 3 DMA request enable
CC3DE : DIER_CC3DE_Field := 16#0#;
-- Capture/Compare 4 DMA request enable
CC4DE : DIER_CC4DE_Field := 16#0#;
-- Reserved
COMDE : DIER_COMDE_Field := 16#0#;
-- Trigger DMA request enable
TDE : DIER_TDE_Field := 16#0#;
-- unspecified
Reserved_15_31 : STM32.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register_1 use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
CC2IE at 0 range 2 .. 2;
CC3IE at 0 range 3 .. 3;
CC4IE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TIE at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
UDE at 0 range 8 .. 8;
CC1DE at 0 range 9 .. 9;
CC2DE at 0 range 10 .. 10;
CC3DE at 0 range 11 .. 11;
CC4DE at 0 range 12 .. 12;
COMDE at 0 range 13 .. 13;
TDE at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- status register
type SR_Register_1 is record
-- Update interrupt flag
UIF : SR_UIF_Field := 16#0#;
-- Capture/compare 1 interrupt flag
CC1IF : SR_CC1IF_Field := 16#0#;
-- Capture/Compare 2 interrupt flag
CC2IF : SR_CC2IF_Field := 16#0#;
-- Capture/Compare 3 interrupt flag
CC3IF : SR_CC3IF_Field := 16#0#;
-- Capture/Compare 4 interrupt flag
CC4IF : SR_CC4IF_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32.Bit := 16#0#;
-- Trigger interrupt flag
TIF : SR_TIF_Field := 16#0#;
-- unspecified
Reserved_7_8 : STM32.UInt2 := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : SR_CC1OF_Field := 16#0#;
-- Capture/compare 2 overcapture flag
CC2OF : SR_CC2OF_Field := 16#0#;
-- Capture/Compare 3 overcapture flag
CC3OF : SR_CC3OF_Field := 16#0#;
-- Capture/Compare 4 overcapture flag
CC4OF : SR_CC4OF_Field := 16#0#;
-- unspecified
Reserved_13_31 : STM32.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_1 use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
CC2IF at 0 range 2 .. 2;
CC3IF at 0 range 3 .. 3;
CC4IF at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TIF at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
CC1OF at 0 range 9 .. 9;
CC2OF at 0 range 10 .. 10;
CC3OF at 0 range 11 .. 11;
CC4OF at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
------------------
-- EGR_Register --
------------------
-- event generation register
type EGR_Register_1 is record
-- Write-only. Update generation
UG : EGR_UG_Field := 16#0#;
-- Write-only. Capture/compare 1 generation
CC1G : EGR_CC1G_Field := 16#0#;
-- Write-only. Capture/compare 2 generation
CC2G : EGR_CC2G_Field := 16#0#;
-- Write-only. Capture/compare 3 generation
CC3G : EGR_CC3G_Field := 16#0#;
-- Write-only. Capture/compare 4 generation
CC4G : EGR_CC4G_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32.Bit := 16#0#;
-- Write-only. Trigger generation
TG : EGR_TG_Field := 16#0#;
-- unspecified
Reserved_7_31 : STM32.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register_1 use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
CC2G at 0 range 2 .. 2;
CC3G at 0 range 3 .. 3;
CC4G at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TG at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
--------------------------
-- CCMR1_Input_Register --
--------------------------
subtype CCMR1_Input_IC1PSC_Field is STM32.UInt2;
subtype CCMR1_Input_IC2PSC_Field is STM32.UInt2;
-- capture/compare mode register 1 (input mode)
type CCMR1_Input_Register_1 is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Input_CC1S_Field := 16#0#;
-- Input capture 1 prescaler
IC1PSC : CCMR1_Input_IC1PSC_Field := 16#0#;
-- Input capture 1 filter
IC1F : CCMR1_Input_IC1F_Field := 16#0#;
-- Capture/compare 2 selection
CC2S : CCMR1_Input_CC2S_Field := 16#0#;
-- Input capture 2 prescaler
IC2PSC : CCMR1_Input_IC2PSC_Field := 16#0#;
-- Input capture 2 filter
IC2F : CCMR1_Input_IC2F_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Input_Register_1 use record
CC1S at 0 range 0 .. 1;
IC1PSC at 0 range 2 .. 3;
IC1F at 0 range 4 .. 7;
CC2S at 0 range 8 .. 9;
IC2PSC at 0 range 10 .. 11;
IC2F at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCER_Register --
-------------------
-- capture/compare enable register
type CCER_Register_1 is record
-- Capture/Compare 1 output enable
CC1E : CCER_CC1E_Field := 16#0#;
-- Capture/Compare 1 output Polarity
CC1P : CCER_CC1P_Field := 16#0#;
-- unspecified
Reserved_2_3 : STM32.UInt2 := 16#0#;
-- Capture/Compare 2 output enable
CC2E : CCER_CC2E_Field := 16#0#;
-- Capture/Compare 2 output Polarity
CC2P : CCER_CC2P_Field := 16#0#;
-- unspecified
Reserved_6_7 : STM32.UInt2 := 16#0#;
-- Capture/Compare 3 output enable
CC3E : CCER_CC3E_Field := 16#0#;
-- Capture/Compare 3 output Polarity
CC3P : CCER_CC3P_Field := 16#0#;
-- unspecified
Reserved_10_11 : STM32.UInt2 := 16#0#;
-- Capture/Compare 4 output enable
CC4E : CCER_CC4E_Field := 16#0#;
-- Capture/Compare 3 output Polarity
CC4P : CCER_CC4P_Field := 16#0#;
-- unspecified
Reserved_14_31 : STM32.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCER_Register_1 use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
CC2E at 0 range 4 .. 4;
CC2P at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
CC3E at 0 range 8 .. 8;
CC3P at 0 range 9 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
CC4E at 0 range 12 .. 12;
CC4P at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
------------------
-- CR1_Register --
------------------
-- control register 1
type CR1_Register_1 is record
-- Counter enable
CEN : CR1_CEN_Field := 16#0#;
-- Update disable
UDIS : CR1_UDIS_Field := 16#0#;
-- Update request source
URS : CR1_URS_Field := 16#0#;
-- One-pulse mode
OPM : CR1_OPM_Field := 16#0#;
-- unspecified
Reserved_4_6 : STM32.UInt3 := 16#0#;
-- Auto-reload preload enable
ARPE : CR1_ARPE_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register_1 use record
CEN at 0 range 0 .. 0;
UDIS at 0 range 1 .. 1;
URS at 0 range 2 .. 2;
OPM at 0 range 3 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
ARPE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
------------------
-- CR2_Register --
------------------
-- control register 2
type CR2_Register_2 is record
-- unspecified
Reserved_0_3 : STM32.UInt4 := 16#0#;
-- Master mode selection
MMS : CR2_MMS_Field := 16#0#;
-- unspecified
Reserved_7_31 : STM32.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register_2 use record
Reserved_0_3 at 0 range 0 .. 3;
MMS at 0 range 4 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
-- DMA/Interrupt enable register
type DIER_Register_2 is record
-- Update interrupt enable
UIE : DIER_UIE_Field := 16#0#;
-- unspecified
Reserved_1_7 : STM32.UInt7 := 16#0#;
-- Update DMA request enable
UDE : DIER_UDE_Field := 16#0#;
-- unspecified
Reserved_9_31 : STM32.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register_2 use record
UIE at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
UDE at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- status register
type SR_Register_2 is record
-- Update interrupt flag
UIF : SR_UIF_Field := 16#0#;
-- unspecified
Reserved_1_31 : STM32.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_2 use record
UIF at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
------------------
-- EGR_Register --
------------------
-- event generation register
type EGR_Register_2 is record
-- Write-only. Update generation
UG : EGR_UG_Field := 16#0#;
-- unspecified
Reserved_1_31 : STM32.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register_2 use record
UG at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type TIM2_Disc is
(
Output,
Input);
-- General purpose timer
type TIM2_Peripheral
(Discriminent : TIM2_Disc := Output)
is record
-- control register 1
CR1 : CR1_Register;
-- control register 2
CR2 : CR2_Register_1;
-- slave mode control register
SMCR : SMCR_Register;
-- DMA/Interrupt enable register
DIER : DIER_Register_1;
-- status register
SR : SR_Register_1;
-- event generation register
EGR : EGR_Register_1;
-- capture/compare enable register
CCER : CCER_Register_1;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
-- capture/compare register 1
CCR1 : CCR1_Register;
-- capture/compare register 2
CCR2 : CCR2_Register;
-- capture/compare register 3
CCR3 : CCR3_Register;
-- capture/compare register 4
CCR4 : CCR4_Register;
-- DMA control register
DCR : DCR_Register;
-- DMA address for full transfer
DMAR : DMAR_Register;
case Discriminent is
when Output =>
-- capture/compare mode register 1 (output mode)
CCMR1_Output : CCMR1_Output_Register;
-- capture/compare mode register 2 (output mode)
CCMR2_Output : CCMR2_Output_Register;
when Input =>
-- capture/compare mode register 1 (input mode)
CCMR1_Input : CCMR1_Input_Register_1;
-- capture/compare mode register 2 (input mode)
CCMR2_Input : CCMR2_Input_Register;
end case;
end record
with Unchecked_Union, Volatile;
for TIM2_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
SMCR at 8 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
CCR2 at 56 range 0 .. 31;
CCR3 at 60 range 0 .. 31;
CCR4 at 64 range 0 .. 31;
DCR at 72 range 0 .. 31;
DMAR at 76 range 0 .. 31;
CCMR1_Output at 24 range 0 .. 31;
CCMR2_Output at 28 range 0 .. 31;
CCMR1_Input at 24 range 0 .. 31;
CCMR2_Input at 28 range 0 .. 31;
end record;
-- General purpose timer
TIM2_Periph : aliased TIM2_Peripheral
with Import, Address => TIM2_Base;
-- General purpose timer
TIM3_Periph : aliased TIM2_Peripheral
with Import, Address => TIM3_Base;
-- General purpose timer
TIM4_Periph : aliased TIM2_Peripheral
with Import, Address => TIM4_Base;
-- General purpose timer
TIM5_Periph : aliased TIM2_Peripheral
with Import, Address => TIM5_Base;
-- Basic timer
type TIM6_Peripheral is record
-- control register 1
CR1 : CR1_Register_1;
-- control register 2
CR2 : CR2_Register_2;
-- DMA/Interrupt enable register
DIER : DIER_Register_2;
-- status register
SR : SR_Register_2;
-- event generation register
EGR : EGR_Register_2;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
end record
with Volatile;
for TIM6_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
end record;
-- Basic timer
TIM6_Periph : aliased TIM6_Peripheral
with Import, Address => TIM6_Base;
-- Basic timer
TIM7_Periph : aliased TIM6_Peripheral
with Import, Address => TIM7_Base;
type TIM1_Disc is
(
Output,
Input);
-- Advanced timer
type TIM1_Peripheral
(Discriminent : TIM1_Disc := Output)
is record
-- control register 1
CR1 : CR1_Register;
-- control register 2
CR2 : CR2_Register;
-- slave mode control register
SMCR : SMCR_Register;
-- DMA/Interrupt enable register
DIER : DIER_Register;
-- status register
SR : SR_Register;
-- event generation register
EGR : EGR_Register;
-- capture/compare enable register
CCER : CCER_Register;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
-- repetition counter register
RCR : RCR_Register;
-- capture/compare register 1
CCR1 : CCR1_Register;
-- capture/compare register 2
CCR2 : CCR2_Register;
-- capture/compare register 3
CCR3 : CCR3_Register;
-- capture/compare register 4
CCR4 : CCR4_Register;
-- break and dead-time register
BDTR : BDTR_Register;
-- DMA control register
DCR : DCR_Register;
-- DMA address for full transfer
DMAR : DMAR_Register;
case Discriminent is
when Output =>
-- capture/compare mode register (output mode)
CCMR1_Output : CCMR1_Output_Register;
-- capture/compare mode register (output mode)
CCMR2_Output : CCMR2_Output_Register;
when Input =>
-- capture/compare mode register 1 (input mode)
CCMR1_Input : CCMR1_Input_Register;
-- capture/compare mode register 2 (input mode)
CCMR2_Input : CCMR2_Input_Register;
end case;
end record
with Unchecked_Union, Volatile;
for TIM1_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
SMCR at 8 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
RCR at 48 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
CCR2 at 56 range 0 .. 31;
CCR3 at 60 range 0 .. 31;
CCR4 at 64 range 0 .. 31;
BDTR at 68 range 0 .. 31;
DCR at 72 range 0 .. 31;
DMAR at 76 range 0 .. 31;
CCMR1_Output at 24 range 0 .. 31;
CCMR2_Output at 28 range 0 .. 31;
CCMR1_Input at 24 range 0 .. 31;
CCMR2_Input at 28 range 0 .. 31;
end record;
-- Advanced timer
TIM1_Periph : aliased TIM1_Peripheral
with Import, Address => TIM1_Base;
end STM32.TIM;
|
wookey-project/ewok-legacy | Ada | 2,362 | ads | --
-- 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;
package ewok.syscalls
with spark_mode => off
is
subtype t_syscall_ret is unsigned_32;
SYS_E_DONE : constant t_syscall_ret := 0; -- Syscall succesful
SYS_E_INVAL : constant t_syscall_ret := 1; -- Invalid input data
SYS_E_DENIED : constant t_syscall_ret := 2; -- Permission is denied
SYS_E_BUSY : constant t_syscall_ret := 3;
-- Target is busy OR not enough ressources OR ressource is already used
type t_svc_type is
(SVC_SYSCALL,
SVC_TASK_DONE,
SVC_ISR_DONE)
with size => 8;
function to_svc_type is new ada.unchecked_conversion
(unsigned_8, t_svc_type);
type t_syscall_type is
(SYS_YIELD,
SYS_INIT,
SYS_IPC,
SYS_CFG,
SYS_GETTICK,
SYS_RESET,
SYS_SLEEP,
SYS_LOCK,
SYS_GET_RANDOM,
SYS_LOG)
with size => 32;
type t_syscalls_init is
(INIT_DEVACCESS,
INIT_DMA,
INIT_DMA_SHM,
INIT_GETTASKID,
INIT_DONE);
type t_syscalls_ipc is
(IPC_RECV_SYNC,
IPC_SEND_SYNC,
IPC_RECV_ASYNC,
IPC_SEND_ASYNC);
type t_syscalls_cfg is
(CFG_GPIO_SET,
CFG_GPIO_GET,
CFG_GPIO_UNLOCK_EXTI,
CFG_DMA_RECONF,
CFG_DMA_RELOAD,
CFG_DMA_DISABLE,
CFG_DEV_MAP,
CFG_DEV_UNMAP,
CFG_DEV_RELEASE);
type t_syscalls_lock is
(LOCK_ENTER,
LOCK_EXIT);
type t_syscall_parameters is record
syscall_type : t_syscall_type;
args : aliased t_parameters;
end record
with pack;
end ewok.syscalls;
|
reznikmm/matreshka | Ada | 12,949 | 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.Utp.Coding_Rules;
with AMF.Utp.Data_Partitions;
with AMF.Utp.Data_Pools;
with AMF.Utp.Data_Selectors;
with AMF.Utp.Default_Applications;
with AMF.Utp.Defaults;
with AMF.Utp.Determ_Alts;
with AMF.Utp.Finish_Actions;
with AMF.Utp.Get_Timezone_Actions;
with AMF.Utp.Literal_Anies;
with AMF.Utp.Literal_Any_Or_Nulls;
with AMF.Utp.Log_Actions;
with AMF.Utp.Managed_Elements;
with AMF.Utp.Read_Timer_Actions;
with AMF.Utp.SUTs;
with AMF.Utp.Set_Timezone_Actions;
with AMF.Utp.Start_Timer_Actions;
with AMF.Utp.Stop_Timer_Actions;
with AMF.Utp.Test_Cases;
with AMF.Utp.Test_Components;
with AMF.Utp.Test_Contexts;
with AMF.Utp.Test_Log_Applications;
with AMF.Utp.Test_Logs;
with AMF.Utp.Test_Objectives;
with AMF.Utp.Test_Suites;
with AMF.Utp.Time_Out_Actions;
with AMF.Utp.Time_Out_Messages;
with AMF.Utp.Time_Outs;
with AMF.Utp.Timer_Running_Actions;
with AMF.Utp.Validation_Actions;
package AMF.Visitors.Utp_Iterators is
pragma Preelaborate;
type Utp_Iterator is limited interface and AMF.Visitors.Abstract_Iterator;
not overriding procedure Visit_Coding_Rule
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Coding_Rules.Utp_Coding_Rule_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Data_Partition
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Data_Partitions.Utp_Data_Partition_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Data_Pool
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Data_Pools.Utp_Data_Pool_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Data_Selector
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Data_Selectors.Utp_Data_Selector_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Default
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Defaults.Utp_Default_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Default_Application
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Default_Applications.Utp_Default_Application_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Determ_Alt
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Determ_Alts.Utp_Determ_Alt_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Finish_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Finish_Actions.Utp_Finish_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Get_Timezone_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Get_Timezone_Actions.Utp_Get_Timezone_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Literal_Any
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Literal_Anies.Utp_Literal_Any_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Literal_Any_Or_Null
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Literal_Any_Or_Nulls.Utp_Literal_Any_Or_Null_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Log_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Log_Actions.Utp_Log_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Managed_Element
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Managed_Elements.Utp_Managed_Element_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Read_Timer_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Read_Timer_Actions.Utp_Read_Timer_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_SUT
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.SUTs.Utp_SUT_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Set_Timezone_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Set_Timezone_Actions.Utp_Set_Timezone_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Start_Timer_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Start_Timer_Actions.Utp_Start_Timer_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Stop_Timer_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Stop_Timer_Actions.Utp_Stop_Timer_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Test_Case
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Test_Cases.Utp_Test_Case_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Test_Component
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Test_Components.Utp_Test_Component_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Test_Context
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Test_Contexts.Utp_Test_Context_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Test_Log
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Test_Logs.Utp_Test_Log_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Test_Log_Application
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Test_Log_Applications.Utp_Test_Log_Application_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Test_Objective
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Test_Objectives.Utp_Test_Objective_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Test_Suite
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Test_Suites.Utp_Test_Suite_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Time_Out
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Time_Outs.Utp_Time_Out_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Time_Out_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Time_Out_Actions.Utp_Time_Out_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Time_Out_Message
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Time_Out_Messages.Utp_Time_Out_Message_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Timer_Running_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Timer_Running_Actions.Utp_Timer_Running_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Validation_Action
(Self : in out Utp_Iterator;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Element : not null AMF.Utp.Validation_Actions.Utp_Validation_Action_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
end AMF.Visitors.Utp_Iterators;
|
stcarrez/ada-wiki | Ada | 7,495 | ads | -----------------------------------------------------------------------
-- wiki-documents -- Wiki document
-- Copyright (C) 2011, 2015, 2016, 2018, 2019, 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Wiki.Strings;
with Wiki.Attributes;
with Wiki.Nodes.Lists;
-- == Documents ==
-- The `Document` type is used to hold a Wiki document that was parsed by the parser
-- with one of the supported syntax. The `Document` holds two distinct parts:
--
-- * A main document body that represents the Wiki content that was parsed.
-- * A table of contents part that was built while Wiki sections are collected.
--
-- Most of the operations provided by the `Wiki.Documents` package are intended to
-- be used by the wiki parser and filters to build the document. The document is made of
-- nodes whose knowledge is required by the renderer.
--
-- A document instance must be declared before parsing a text:
--
-- Doc : Wiki.Documents.Document;
--
-- After parsing some HTML or Wiki text, it will contain a representation of the
-- HTML or Wiki text. It is possible to populate the document by using one of
-- the `Append`, `Add_Link`, `Add_Image` operation.
package Wiki.Documents is
pragma Preelaborate;
-- ------------------------------
-- A Wiki Document
-- ------------------------------
type Document is tagged private;
-- Append a simple node such as N_LINE_BREAK, N_HORIZONTAL_RULE or N_PARAGRAPH.
procedure Append (Into : in out Document;
Kind : in Wiki.Nodes.Simple_Node_Kind);
procedure Start_Block (Into : in out Document;
Kind : in Wiki.Nodes.Node_Kind;
Level : in Natural);
procedure End_Block (From : in out Document;
Kind : in Wiki.Nodes.Node_Kind);
-- Append a HTML tag start node to the document.
procedure Push_Node (Into : in out Document;
Tag : in Html_Tag;
Attributes : in Wiki.Attributes.Attribute_List);
-- Pop the HTML tag.
procedure Pop_Node (From : in out Document;
Tag : in Html_Tag);
-- Returns True if the current node is the root document node.
function Is_Root_Node (Doc : in Document) return Boolean;
-- Append the text with the given format at end of the document.
procedure Append (Into : in out Document;
Text : in Wiki.Strings.WString;
Format : in Format_Map);
-- Add a definition item at end of the document.
procedure Add_Definition (Into : in out Document;
Definition : in Wiki.Strings.WString);
-- Add a link.
procedure Add_Link (Into : in out Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List);
-- Add a link reference with the given label.
procedure Add_Link_Ref (Into : in out Document;
Label : in Wiki.Strings.WString);
-- Add an image.
procedure Add_Image (Into : in out Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List);
-- Add a quote.
procedure Add_Quote (Into : in out Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List);
-- Add a list (<ul> or <ol>) starting at the given number.
procedure Add_List (Into : in out Document;
Level : in Natural;
Ordered : in Boolean);
-- Add a blockquote (<blockquote>). The level indicates the blockquote nested level.
-- The blockquote must be closed at the next header.
procedure Add_Blockquote (Into : in out Document;
Level : in Natural);
-- Add a text block that is pre-formatted.
procedure Add_Preformatted (Into : in out Document;
Text : in Wiki.Strings.WString;
Format : in Wiki.Strings.WString);
-- Add a new row to the current table.
procedure Add_Row (Into : in out Document);
-- Add a column to the current table row. The column is configured with the
-- given attributes. The column content is provided through calls to Append.
procedure Add_Column (Into : in out Document;
Attributes : in out Wiki.Attributes.Attribute_List);
-- Finish the creation of the table.
procedure Finish_Table (Into : in out Document);
-- Iterate over the nodes of the list and call the <tt>Process</tt> procedure with
-- each node instance.
procedure Iterate (Doc : in Document;
Process : not null access procedure (Node : in Wiki.Nodes.Node_Type));
-- Returns True if the document is empty.
function Is_Empty (Doc : in Document) return Boolean;
-- Returns True if the document displays the table of contents by itself.
function Is_Using_TOC (Doc : in Document) return Boolean;
-- Returns True if the table of contents is visible and must be rendered.
function Is_Visible_TOC (Doc : in Document) return Boolean;
-- Hide the table of contents.
procedure Hide_TOC (Doc : in out Document);
-- Get the table of content node associated with the document.
procedure Get_TOC (Doc : in out Document;
TOC : out Wiki.Nodes.Lists.Node_List_Ref);
-- Get the table of content node associated with the document.
function Get_TOC (Doc : in Document) return Wiki.Nodes.Lists.Node_List_Ref;
-- Set a link definition.
procedure Set_Link (Doc : in out Document;
Name : in Wiki.Strings.WString;
Link : in Wiki.Strings.WString;
Title : in Wiki.Strings.WString);
-- Get a link definition.
function Get_Link (Doc : in Document;
Label : in Wiki.Strings.WString) return Wiki.Strings.WString;
function Get_Link_Title (Doc : in Document;
Label : in Wiki.Strings.WString) return Wiki.Strings.WString;
private
-- Append a node to the document.
procedure Append (Into : in out Document;
Node : in Wiki.Nodes.Node_Type_Access);
type Document is tagged record
Nodes : Wiki.Nodes.Lists.Node_List_Ref;
TOC : Wiki.Nodes.Lists.Node_List_Ref;
Links : Wiki.Strings.Maps.Map;
Titles : Wiki.Strings.Maps.Map;
Current : Wiki.Nodes.Node_Type_Access;
Using_TOC : Boolean := False;
Visible_TOC : Boolean := True;
end record;
end Wiki.Documents;
|
godunko/cga | Ada | 816 | ads | --
-- Copyright (C) 2023, Vadim Godunko <[email protected]>
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- Advanced algorithms to create Line_Segment_2D.
package CGK.Primitives.Line_Segments_2D.Builders is
pragma Pure;
type Line_Segment_2D_Builder is private;
procedure Build
(Self : in out Line_Segment_2D_Builder;
Point_1 : CGK.Primitives.Points_2D.Point_2D;
Point_2 : CGK.Primitives.Points_2D.Point_2D);
function Line_Segment
(Self : Line_Segment_2D_Builder)
return CGK.Primitives.Line_Segments_2D.Line_Segment_2D;
private
type Line_Segment_2D_Builder is record
State : CGK.Primitives.Builder_State_Kind := CGK.Primitives.Invalid;
Segment : Line_Segment_2D;
end record;
end CGK.Primitives.Line_Segments_2D.Builders;
|
twdroeger/ada-awa | Ada | 5,157 | adb | -----------------------------------------------------------------------
-- awa-events-queues-fifos -- Fifo event queues (memory based)
-- Copyright (C) 2012 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 Util.Log.Loggers;
package body AWA.Events.Queues.Fifos is
use Util.Log;
Log : constant Loggers.Logger := Loggers.Create ("AWA.Events.Queues.Fifos");
procedure Free is
new Ada.Unchecked_Deallocation (Object => AWA.Events.Module_Event'Class,
Name => AWA.Events.Module_Event_Access);
-- ------------------------------
-- Get the queue name.
-- ------------------------------
overriding
function Get_Name (From : in Fifo_Queue) return String is
begin
return From.Name;
end Get_Name;
-- ------------------------------
-- Get the model queue reference object.
-- Returns a null object if the queue is not persistent.
-- ------------------------------
overriding
function Get_Queue (From : in Fifo_Queue) return AWA.Events.Models.Queue_Ref is
pragma Unreferenced (From);
begin
return AWA.Events.Models.Null_Queue;
end Get_Queue;
-- ------------------------------
-- Queue the event.
-- ------------------------------
procedure Enqueue (Into : in out Fifo_Queue;
Event : in AWA.Events.Module_Event'Class) is
E : constant Module_Event_Access := Copy (Event);
begin
Log.Debug ("Enqueue event on queue {0}", Into.Name);
E.Set_Event_Kind (Event.Get_Event_Kind);
Into.Fifo.Enqueue (E);
end Enqueue;
-- ------------------------------
-- Dequeue an event and process it with the <b>Process</b> procedure.
-- ------------------------------
procedure Dequeue (From : in out Fifo_Queue;
Process : access procedure (Event : in Module_Event'Class)) is
E : Module_Event_Access;
begin
Log.Debug ("Dequeue event queue {0}", From.Name);
From.Fifo.Dequeue (E, 0.0);
begin
Process (E.all);
exception
when E : others =>
Log.Error ("Exception when processing event", E);
end;
Free (E);
exception
when Fifo_Protected_Queue.Timeout =>
null;
end Dequeue;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in Fifo_Queue;
Name : in String) return Util.Beans.Objects.Object is
pragma Unreferenced (From, Name);
begin
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
-- ------------------------------
overriding
procedure Set_Value (From : in out Fifo_Queue;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "size" then
From.Fifo.Set_Size (Util.Beans.Objects.To_Integer (Value));
end if;
end Set_Value;
-- ------------------------------
-- Release the queue storage.
-- ------------------------------
overriding
procedure Finalize (From : in out Fifo_Queue) is
begin
while From.Fifo.Get_Count > 0 loop
declare
E : Module_Event_Access;
begin
From.Fifo.Dequeue (E);
Free (E);
end;
end loop;
end Finalize;
-- ------------------------------
-- Create the queue associated with the given name and configure it by using
-- the configuration properties.
-- ------------------------------
function Create_Queue (Name : in String;
Props : in EL.Beans.Param_Vectors.Vector;
Context : in EL.Contexts.ELContext'Class) return Queue_Access is
Result : constant Fifo_Queue_Access := new Fifo_Queue '(Name_Length => Name'Length,
Name => Name,
others => <>);
begin
EL.Beans.Initialize (Result.all, Props, Context);
return Result.all'Access;
end Create_Queue;
end AWA.Events.Queues.Fifos;
|
Componolit/libsparkcrypto | Ada | 14,069 | adb | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2018 Componolit GmbH
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with AUnit.Assertions; use AUnit.Assertions;
with LSC.Internal.AES;
with OpenSSL;
pragma Style_Checks ("-s");
pragma Warnings (Off, "formal parameter ""T"" is not referenced");
package body LSC_Internal_Test_AES is
---------------------------------------------------------------------------
procedure Test_AES128_Decrypt (T : in out Test_Cases.Test_Case'Class)
is
subtype Message_Index is Natural range 1 .. 1000;
type Message_Type is array (Message_Index) of LSC.Internal.AES.Block_Type;
Plain1, Plain2, Cipher : Message_Type;
Key128 : LSC.Internal.AES.AES128_Key_Type;
Context1 : OpenSSL.AES_Dec_Context_Type;
Context2 : LSC.Internal.AES.AES_Dec_Context;
begin
Cipher := Message_Type'
(others => LSC.Internal.AES.Block_Type'(16#33221100#,
16#77665544#,
16#bbaa9988#,
16#ffeeddcc#));
Key128 := LSC.Internal.AES.AES128_Key_Type'(16#03020100#,
16#07060504#,
16#0b0a0908#,
16#1f1e1d1c#);
Context1 := OpenSSL.Create_AES128_Dec_Context (Key128);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Plain1 (I) := OpenSSL.Decrypt (Context1, Cipher (I));
end loop;
end loop;
Context2 := LSC.Internal.AES.Create_AES128_Dec_Context (Key128);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Plain2 (I) := LSC.Internal.AES.Decrypt (Context2, Cipher (I));
end loop;
end loop;
Assert (Plain1 = Plain2, "Plaintext differs");
end Test_AES128_Decrypt;
---------------------------------------------------------------------------
procedure Test_AES128_Encrypt (T : in out Test_Cases.Test_Case'Class)
is
subtype Message_Index is Natural range 1 .. 1000;
type Message_Type is array (Message_Index) of LSC.Internal.AES.Block_Type;
Plain, Cipher1, Cipher2 : Message_Type;
Key128 : LSC.Internal.AES.AES128_Key_Type;
Context1 : OpenSSL.AES_Enc_Context_Type;
Context2 : LSC.Internal.AES.AES_Enc_Context;
begin
Plain := Message_Type'
(others => LSC.Internal.AES.Block_Type'(16#33221100#,
16#77665544#,
16#bbaa9988#,
16#ffeeddcc#));
Key128 := LSC.Internal.AES.AES128_Key_Type'(16#03020100#,
16#07060504#,
16#0b0a0908#,
16#0f0e0d0c#);
Context1 := OpenSSL.Create_AES128_Enc_Context (Key128);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Cipher1 (I) := OpenSSL.Encrypt (Context1, Plain (I));
end loop;
end loop;
Context2 := LSC.Internal.AES.Create_AES128_Enc_Context (Key128);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Cipher2 (I) := LSC.Internal.AES.Encrypt (Context2, Plain (I));
end loop;
end loop;
Assert (Cipher1 = Cipher2, "Ciphertext differs");
end Test_AES128_Encrypt;
---------------------------------------------------------------------------
procedure Test_AES192_Decrypt (T : in out Test_Cases.Test_Case'Class)
is
subtype Message_Index is Natural range 1 .. 1000;
type Message_Type is array (Message_Index) of LSC.Internal.AES.Block_Type;
Plain1, Plain2, Cipher : Message_Type;
Key192 : LSC.Internal.AES.AES192_Key_Type;
Context1 : OpenSSL.AES_Dec_Context_Type;
Context2 : LSC.Internal.AES.AES_Dec_Context;
begin
Cipher := Message_Type'
(others => LSC.Internal.AES.Block_Type'(16#33221100#,
16#77665544#,
16#bbaa9988#,
16#ffeeddcc#));
Key192 := LSC.Internal.AES.AES192_Key_Type'(16#03020100#,
16#07060504#,
16#13121110#,
16#17161514#,
16#1b1a1918#,
16#1f1e1d1c#);
Context1 := OpenSSL.Create_AES192_Dec_Context (Key192);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Plain1 (I) := OpenSSL.Decrypt (Context1, Cipher (I));
end loop;
end loop;
Context2 := LSC.Internal.AES.Create_AES192_Dec_Context (Key192);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Plain2 (I) := LSC.Internal.AES.Decrypt (Context2, Cipher (I));
end loop;
end loop;
Assert (Plain1 = Plain2, "Plaintext differs");
end Test_AES192_Decrypt;
---------------------------------------------------------------------------
procedure Test_AES192_Encrypt (T : in out Test_Cases.Test_Case'Class)
is
subtype Message_Index is Natural range 1 .. 1000;
type Message_Type is array (Message_Index) of LSC.Internal.AES.Block_Type;
Plain, Cipher1, Cipher2 : Message_Type;
Key192 : LSC.Internal.AES.AES192_Key_Type;
Context1 : OpenSSL.AES_Enc_Context_Type;
Context2 : LSC.Internal.AES.AES_Enc_Context;
begin
Plain := Message_Type'
(others => LSC.Internal.AES.Block_Type'(16#33221100#,
16#77665544#,
16#bbaa9988#,
16#ffeeddcc#));
Key192 := LSC.Internal.AES.AES192_Key_Type'(16#03020100#,
16#07060504#,
16#07060504#,
16#0b0a0908#,
16#0b0a0908#,
16#0f0e0d0c#);
Context1 := OpenSSL.Create_AES192_Enc_Context (Key192);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Cipher1 (I) := OpenSSL.Encrypt (Context1, Plain (I));
end loop;
end loop;
Context2 := LSC.Internal.AES.Create_AES192_Enc_Context (Key192);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Cipher2 (I) := LSC.Internal.AES.Encrypt (Context2, Plain (I));
end loop;
end loop;
Assert (Cipher1 = Cipher2, "Ciphertext differs");
end Test_AES192_Encrypt;
---------------------------------------------------------------------------
procedure Test_AES256_Decrypt (T : in out Test_Cases.Test_Case'Class)
is
subtype Message_Index is Natural range 1 .. 1000;
type Message_Type is array (Message_Index) of LSC.Internal.AES.Block_Type;
Plain1, Plain2, Cipher : Message_Type;
Key256 : LSC.Internal.AES.AES256_Key_Type;
Context1 : OpenSSL.AES_Dec_Context_Type;
Context2 : LSC.Internal.AES.AES_Dec_Context;
begin
Cipher := Message_Type'
(others => LSC.Internal.AES.Block_Type'(16#33221100#,
16#77665544#,
16#bbaa9988#,
16#ffeeddcc#));
Key256 := LSC.Internal.AES.AES256_Key_Type'(16#03020100#,
16#07060504#,
16#0b0a0908#,
16#0f0e0d0c#,
16#13121110#,
16#17161514#,
16#1b1a1918#,
16#1f1e1d1c#);
Context1 := OpenSSL.Create_AES256_Dec_Context (Key256);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Plain1 (I) := OpenSSL.Decrypt (Context1, Cipher (I));
end loop;
end loop;
Context2 := LSC.Internal.AES.Create_AES256_Dec_Context (Key256);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Plain2 (I) := LSC.Internal.AES.Decrypt (Context2, Cipher (I));
end loop;
end loop;
Assert (Plain1 = Plain2, "Plaintext differs");
end Test_AES256_Decrypt;
---------------------------------------------------------------------------
procedure Test_AES256_Encrypt (T : in out Test_Cases.Test_Case'Class)
is
subtype Message_Index is Natural range 1 .. 1000;
type Message_Type is array (Message_Index) of LSC.Internal.AES.Block_Type;
Plain, Cipher1, Cipher2 : Message_Type;
Key256 : LSC.Internal.AES.AES256_Key_Type;
Context1 : OpenSSL.AES_Enc_Context_Type;
Context2 : LSC.Internal.AES.AES_Enc_Context;
begin
Plain := Message_Type'
(others => LSC.Internal.AES.Block_Type'(16#33221100#,
16#77665544#,
16#bbaa9988#,
16#ffeeddcc#));
Key256 := LSC.Internal.AES.AES256_Key_Type'(16#03020100#,
16#07060504#,
16#0b0a0908#,
16#0f0e0d0c#,
16#13121110#,
16#17161514#,
16#1b1a1918#,
16#1f1e1d1c#);
Context1 := OpenSSL.Create_AES256_Enc_Context (Key256);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Cipher1 (I) := OpenSSL.Encrypt (Context1, Plain (I));
end loop;
end loop;
Context2 := LSC.Internal.AES.Create_AES256_Enc_Context (Key256);
for k in Natural range 1 .. 20
loop
for I in Message_Index
loop
Cipher2 (I) := LSC.Internal.AES.Encrypt (Context2, Plain (I));
end loop;
end loop;
Assert (Cipher1 = Cipher2, "Plaintext differs");
end Test_AES256_Encrypt;
---------------------------------------------------------------------------
procedure Register_Tests (T : in out Test_Case) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_AES128_Decrypt'Access, "AES-128 decryption");
Register_Routine (T, Test_AES128_Encrypt'Access, "AES-128 encryption");
Register_Routine (T, Test_AES192_Decrypt'Access, "AES-192 decryption");
Register_Routine (T, Test_AES192_Encrypt'Access, "AES-192 encryption");
Register_Routine (T, Test_AES256_Decrypt'Access, "AES-256 decryption");
Register_Routine (T, Test_AES256_Encrypt'Access, "AES-256 encryption");
end Register_Tests;
---------------------------------------------------------------------------
function Name (T : Test_Case) return Test_String is
begin
return Format ("AES");
end Name;
end LSC_Internal_Test_AES;
|
sungyeon/drake | Ada | 253 | adb | with Ada.Strings.Wide_Hash;
function Ada.Strings.Wide_Bounded.Wide_Hash (
Key : Bounded.Bounded_Wide_String)
return Containers.Hash_Type is
begin
return Strings.Wide_Hash (Key.Element (1 .. Key.Length));
end Ada.Strings.Wide_Bounded.Wide_Hash;
|
KipodAfterFree/KAF-2019-FireHog | Ada | 4,652 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Form_Demo.Handler --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.5 $
-- Binding Version 00.93
------------------------------------------------------------------------------
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Sample.Form_Demo.Aux;
with Sample.Explanation; use Sample.Explanation;
package body Sample.Form_Demo.Handler is
package Aux renames Sample.Form_Demo.Aux;
procedure Drive_Me (F : in Form;
Title : in String := "")
is
L : Line_Count;
C : Column_Count;
Y : Line_Position;
X : Column_Position;
begin
Aux.Geometry (F, L, C, Y, X);
Drive_Me (F, Y, X, Title);
end Drive_Me;
procedure Drive_Me (F : in Form;
Lin : in Line_Position;
Col : in Column_Position;
Title : in String := "")
is
Pan : Panel := Aux.Create (F, Title, Lin, Col);
V : Cursor_Visibility := Normal;
Handle_CRLF : Boolean := True;
begin
Set_Cursor_Visibility (V);
if Aux.Count_Active (F) = 1 then
Handle_CRLF := False;
end if;
loop
declare
K : Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF);
R : Driver_Result;
begin
if (K = 13 or else K = 10) and then not Handle_CRLF then
R := Unknown_Request;
else
R := Driver (F, K);
end if;
case R is
when Form_Ok => null;
when Unknown_Request =>
if My_Driver (F, K, Pan) then
exit;
end if;
when others => Beep;
end case;
end;
end loop;
Set_Cursor_Visibility (V);
Aux.Destroy (F, Pan);
end Drive_Me;
end Sample.Form_Demo.Handler;
|
damaki/libkeccak | Ada | 7,012 | adb | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Interfaces; use Interfaces;
with Keccak.Types;
with Test_Vectors; use Test_Vectors;
package body Hash_Runner
is
procedure Free is new Ada.Unchecked_Deallocation
(Object => Keccak.Types.Byte_Array,
Name => Byte_Array_Access);
procedure Run_Tests (File_Name : in String;
Align_Bits : in Boolean;
Num_Passed : out Natural;
Num_Failed : out Natural)
is
use type Keccak.Types.Byte_Array;
package Integer_IO is new Ada.Text_IO.Integer_IO (Integer);
Len_Key : constant Unbounded_String := To_Unbounded_String ("Len");
Msg_Key : constant Unbounded_String := To_Unbounded_String ("Msg");
Repeat_Key : constant Unbounded_String := To_Unbounded_String ("Repeat");
Text_Key : constant Unbounded_String := To_Unbounded_String ("Text");
MD_Key : constant Unbounded_String := To_Unbounded_String ("MD");
Schema : Test_Vectors.Schema_Maps.Map;
Tests : Test_Vectors.Lists.List;
Ctx : Hash.Context;
Digest : Hash.Digest_Type;
Msg : Byte_Array_Access;
Len : Natural;
begin
Num_Passed := 0;
Num_Failed := 0;
-- Setup schema to support two types of test vector files:
-- Long or ShortMsgKAT containing: "Len", "Msg", and "MD" fields; and
-- ExtremelyLongMsgKAT containing: "Repeat", "Text", and "MD" fields.
Schema.Insert (Key => Len_Key,
New_Item => Schema_Entry'(VType => Integer_Type,
Required => False,
Is_List => False));
Schema.Insert (Key => Msg_Key,
New_Item => Schema_Entry'(VType => Hex_Array_Type,
Required => False,
Is_List => False));
Schema.Insert (Key => Repeat_Key,
New_Item => Schema_Entry'(VType => Integer_Type,
Required => False,
Is_List => False));
Schema.Insert (Key => Text_Key,
New_Item => Schema_Entry'(VType => String_Type,
Required => False,
Is_List => False));
Schema.Insert (Key => MD_Key,
New_Item => Schema_Entry'(VType => Hex_Array_Type,
Required => True,
Is_List => False));
-- Load the test file using the file name given on the command line
Ada.Text_IO.Put_Line ("Loading file: " & File_Name);
Test_Vectors.Load (File_Name => File_Name,
Schema => Schema,
Vectors_List => Tests);
Ada.Text_IO.Put ("Running ");
Integer_IO.Put (Integer (Tests.Length), Width => 0);
Ada.Text_IO.Put_Line (" tests ...");
-- Run each test.
for C of Tests loop
Hash.Init (Ctx);
if C.Contains (Len_Key) then
-- Test vector contains "Len", "Msg", and "MD" fields
Len := C.Element (Len_Key).First_Element.Int;
if Len > 0 then
Msg := new Keccak.Types.Byte_Array'(C.Element (Msg_Key).First_Element.Hex.all);
if Align_Bits and Len mod 8 /= 0 and Msg.all'Length > 0 then
-- Align last byte on the least significant bit
Msg.all (Msg.all'Last) := Shift_Right (Msg.all (Msg.all'Last), 8 - (Len mod 8));
end if;
Hash.Update (Ctx, Msg.all, Len);
Free (Msg);
end if;
else
-- Assume test vector defines "Repeat", "Text", and "MD" fields
Msg := String_To_Byte_Array (To_String (C.Element (Text_Key).First_Element.Str));
for I in 1 .. C.Element (Repeat_Key).First_Element.Int loop
Hash.Update (Ctx, Msg.all);
end loop;
Free (Msg);
end if;
Hash.Final (Ctx, Digest);
if Digest = C.Element (MD_Key).First_Element.Hex.all then
Num_Passed := Num_Passed + 1;
else
Num_Failed := Num_Failed + 1;
-- Display a message on failure to help with debugging.
if C.Contains (Len_Key) then
Ada.Text_IO.Put ("FAILURE (Msg bit-len: ");
Integer_IO.Put (C.Element (Len_Key).First_Element.Int, Width => 0);
Ada.Text_IO.Put_Line (")");
else
Ada.Text_IO.Put_Line ("FAILURE:");
end if;
Ada.Text_IO.Put (" Expected MD: ");
Ada.Text_IO.Put (Byte_Array_To_String (C.Element (MD_Key).First_Element.Hex.all));
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (" Actual MD: ");
Ada.Text_IO.Put (Byte_Array_To_String (Digest));
Ada.Text_IO.New_Line;
end if;
end loop;
end Run_Tests;
end Hash_Runner;
|
zhmu/ananas | Ada | 5,109 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C H 1 0 --
-- --
-- S p e c --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Types; use Types;
package Sem_Ch10 is
procedure Analyze_Compilation_Unit (N : Node_Id);
procedure Analyze_With_Clause (N : Node_Id);
procedure Analyze_Subprogram_Body_Stub (N : Node_Id);
procedure Analyze_Package_Body_Stub (N : Node_Id);
procedure Analyze_Task_Body_Stub (N : Node_Id);
procedure Analyze_Protected_Body_Stub (N : Node_Id);
procedure Analyze_Subunit (N : Node_Id);
procedure Install_Context (N : Node_Id; Chain : Boolean := True);
-- Installs the entities from the context clause of the given compilation
-- unit into the visibility chains. This is done before analyzing a unit.
-- For a child unit, install context of parents as well. The flag Chain is
-- used to control the "chaining" or linking of use-type and use-package
-- clauses to avoid circularities when reinstalling context clauses.
procedure Install_Private_With_Clauses (P : Entity_Id);
-- Install the private with_clauses of a compilation unit, when compiling
-- its private part, compiling a private child unit, or compiling the
-- private declarations of a public child unit.
function Is_Legal_Shadow_Entity_In_Body (T : Entity_Id) return Boolean;
-- Assuming that type T is an incomplete type coming from a limited with
-- view, determine whether the package where T resides is imported through
-- a regular with clause in the current package body.
function Is_Visible_Through_Renamings
(P : Entity_Id;
Error_Node : Node_Id := Empty) return Boolean;
-- Check if some package installed though normal with-clauses has a
-- renaming declaration of package P. AARM 10.1.2(21/2). Errors are
-- reported on Error_Node (if present); otherwise no error is reported.
procedure Load_Needed_Body
(N : Node_Id;
OK : out Boolean);
-- Load and analyze the body of a context unit that is generic, or that
-- contains generic units or inlined units. The body becomes part of the
-- semantic dependency set of the unit that needs it. The returned result
-- in OK is True if the load is successful, and False if the requested file
-- cannot be found.
procedure Remove_Context (N : Node_Id);
-- Removes the entities from the context clause of the given compilation
-- unit from the visibility chains. This is done on exit from a unit as
-- part of cleaning up the visibility chains for the caller. A special
-- case is that the call from the Main_Unit can be ignored, since at the
-- end of the main unit the visibility table won't be needed in any case.
-- For a child unit, remove parents and their context as well.
procedure Remove_Private_With_Clauses (Comp_Unit : Node_Id);
-- The private_with_clauses of a compilation unit are visible in the
-- private part of a nested package, even if this package appears in
-- the visible part of the enclosing compilation unit. This Ada 2005
-- rule imposes extra steps in order to install/remove the private_with
-- clauses of an enclosing unit.
end Sem_Ch10;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 5,143 | ads | -- This spec has been automatically generated from STM32F103.svd
-- Definition of the device's interrupts
package STM32_SVD.Interrupts is
pragma Preelaborate;
----------------
-- Interrupts --
----------------
-- Window Watchdog interrupt
WWDG : constant := 0;
-- PVD through EXTI line detection interrupt
PVD : constant := 1;
-- Tamper interrupt
TAMPER : constant := 2;
-- RTC global interrupt
RTC : constant := 3;
-- Flash global interrupt
FLASH : constant := 4;
-- RCC global interrupt
RCC : constant := 5;
-- EXTI Line0 interrupt
EXTI0 : constant := 6;
-- EXTI Line1 interrupt
EXTI1 : constant := 7;
-- EXTI Line2 interrupt
EXTI2 : constant := 8;
-- EXTI Line3 interrupt
EXTI3 : constant := 9;
-- EXTI Line4 interrupt
EXTI4 : constant := 10;
-- DMA1 Channel1 global interrupt
DMA1_Channel1 : constant := 11;
-- DMA1 Channel2 global interrupt
DMA1_Channel2 : constant := 12;
-- DMA1 Channel3 global interrupt
DMA1_Channel3 : constant := 13;
-- DMA1 Channel4 global interrupt
DMA1_Channel4 : constant := 14;
-- DMA1 Channel5 global interrupt
DMA1_Channel5 : constant := 15;
-- DMA1 Channel6 global interrupt
DMA1_Channel6 : constant := 16;
-- DMA1 Channel7 global interrupt
DMA1_Channel7 : constant := 17;
-- ADC1 and ADC2 global interrupt
ADC1_2 : constant := 18;
-- USB High Priority or CAN TX interrupts
USB_HP_CAN_TX : constant := 19;
-- USB Low Priority or CAN RX0 interrupts
USB_LP_CAN_RX0 : constant := 20;
-- CAN RX1 interrupt
CAN_RX1 : constant := 21;
-- CAN SCE interrupt
CAN_SCE : constant := 22;
-- EXTI Line[9:5] interrupts
EXTI9_5 : constant := 23;
-- TIM1 Break interrupt
TIM1_BRK : constant := 24;
-- TIM1 Update interrupt
TIM1_UP : constant := 25;
-- TIM1 Trigger and Commutation interrupts
TIM1_TRG_COM : constant := 26;
-- TIM1 Capture Compare interrupt
TIM1_CC : constant := 27;
-- TIM2 global interrupt
TIM2 : constant := 28;
-- TIM3 global interrupt
TIM3 : constant := 29;
-- TIM4 global interrupt
TIM4 : constant := 30;
-- I2C1 event interrupt
I2C1_EV : constant := 31;
-- I2C1 error interrupt
I2C1_ER : constant := 32;
-- I2C2 event interrupt
I2C2_EV : constant := 33;
-- I2C2 error interrupt
I2C2_ER : constant := 34;
-- SPI1 global interrupt
SPI1 : constant := 35;
-- SPI2 global interrupt
SPI2 : constant := 36;
-- USART1 global interrupt
USART1 : constant := 37;
-- USART2 global interrupt
USART2 : constant := 38;
-- USART3 global interrupt
USART3 : constant := 39;
-- EXTI Line[15:10] interrupts
EXTI15_10 : constant := 40;
-- RTC Alarms through EXTI line interrupt
RTCAlarm : constant := 41;
-- TIM8 Break interrupt
TIM8_BRK : constant := 43;
-- TIM8 Update interrupt
TIM8_UP : constant := 44;
-- TIM8 Trigger and Commutation interrupts
TIM8_TRG_COM : constant := 45;
-- TIM8 Capture Compare interrupt
TIM8_CC : constant := 46;
-- ADC3 global interrupt
ADC3 : constant := 47;
-- FSMC global interrupt
FSMC : constant := 48;
-- SDIO global interrupt
SDIO : constant := 49;
-- TIM5 global interrupt
TIM5 : constant := 50;
-- SPI3 global interrupt
SPI3 : constant := 51;
-- UART4 global interrupt
UART4 : constant := 52;
-- UART5 global interrupt
UART5 : constant := 53;
-- TIM6 global interrupt
TIM6 : constant := 54;
-- TIM7 global interrupt
TIM7 : constant := 55;
-- DMA2 Channel1 global interrupt
DMA2_Channel1 : constant := 56;
-- DMA2 Channel2 global interrupt
DMA2_Channel2 : constant := 57;
-- DMA2 Channel3 global interrupt
DMA2_Channel3 : constant := 58;
-- DMA2 Channel4 and DMA2 Channel5 global interrupt
DMA2_Channel4_5 : constant := 59;
Number_Of_Interrupts : constant := 59;
end STM32_SVD.Interrupts;
|
persan/A-gst | Ada | 13,155 | 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;
-- with GStreamer.GST_Low_Level.glib_2_0_gobject_gparam_h;
with Interfaces.C.Strings;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h is
-- unsupported macro: GST_TYPE_MINI_OBJECT (gst_mini_object_get_type())
-- arg-macro: function GST_IS_MINI_OBJECT (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MINI_OBJECT);
-- arg-macro: function GST_IS_MINI_OBJECT_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MINI_OBJECT);
-- arg-macro: function GST_MINI_OBJECT_GET_CLASS (obj)
-- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MINI_OBJECT, GstMiniObjectClass);
-- arg-macro: function GST_MINI_OBJECT (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MINI_OBJECT, GstMiniObject);
-- arg-macro: function GST_MINI_OBJECT_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MINI_OBJECT, GstMiniObjectClass);
-- arg-macro: function GST_MINI_OBJECT_CAST (obj)
-- return (GstMiniObject*)(obj);
-- arg-macro: function GST_MINI_OBJECT_CONST_CAST (obj)
-- return (const GstMiniObject*)(obj);
-- arg-macro: function GST_MINI_OBJECT_FLAGS (obj)
-- return GST_MINI_OBJECT_CAST(obj).flags;
-- arg-macro: procedure GST_MINI_OBJECT_FLAG_IS_SET (obj, flag)
-- notnot(GST_MINI_OBJECT_FLAGS (obj) and (flag))
-- arg-macro: function GST_MINI_OBJECT_FLAG_SET (obj, flag)
-- return GST_MINI_OBJECT_FLAGS (obj) |= (flag);
-- arg-macro: function GST_MINI_OBJECT_FLAG_UNSET (obj, flag)
-- return GST_MINI_OBJECT_FLAGS (obj) &= ~(flag);
-- arg-macro: function GST_VALUE_HOLDS_MINI_OBJECT (value)
-- return G_VALUE_HOLDS(value, GST_TYPE_MINI_OBJECT);
-- arg-macro: function GST_MINI_OBJECT_REFCOUNT (obj)
-- return (GST_MINI_OBJECT_CAST(obj)).refcount;
-- arg-macro: function GST_MINI_OBJECT_REFCOUNT_VALUE (obj)
-- return g_atomic_int_get (and(GST_MINI_OBJECT_CAST(obj)).refcount);
-- unsupported macro: GST_TYPE_PARAM_MINI_OBJECT (gst_param_spec_mini_object_get_type())
-- arg-macro: function GST_IS_PARAM_SPEC_MINI_OBJECT (pspec)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GST_TYPE_PARAM_MINI_OBJECT);
-- arg-macro: function GST_PARAM_SPEC_MINI_OBJECT (pspec)
-- return G_TYPE_CHECK_INSTANCE_CAST ((pspec), GST_TYPE_PARAM_MINI_OBJECT, GstParamSpecMiniObject);
-- GStreamer
-- * Copyright (C) 2005 David Schleef <[email protected]>
-- *
-- * gstminiobject.h: Header for GstMiniObject
-- *
-- * 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.
--
type GstMiniObject;
--subtype GstMiniObject is u_GstMiniObject; -- gst/gstminiobject.h:41
type GstMiniObjectClass;
--subtype GstMiniObjectClass is u_GstMiniObjectClass; -- gst/gstminiobject.h:42
--*
-- * GstMiniObjectCopyFunction:
-- * @obj: MiniObject to copy
-- *
-- * Virtual function prototype for methods to create copies of instances.
-- *
-- * Returns: reference to cloned instance.
--
type GstMiniObjectCopyFunction is access function (arg1 : access constant GstMiniObject) return access GstMiniObject;
pragma Convention (C, GstMiniObjectCopyFunction); -- gst/gstminiobject.h:52
--*
-- * GstMiniObjectFinalizeFunction:
-- * @obj: MiniObject to finalize
-- *
-- * Virtual function prototype for methods to free ressources used by
-- * mini-objects. Subclasses of the mini object are allowed to revive the
-- * passed object by doing a gst_mini_object_ref(). If the object is not
-- * revived after the finalize function, the memory associated with the
-- * object is freed.
--
type GstMiniObjectFinalizeFunction is access procedure (arg1 : access GstMiniObject);
pragma Convention (C, GstMiniObjectFinalizeFunction); -- gst/gstminiobject.h:63
--*
-- * GST_MINI_OBJECT_FLAGS:
-- * @obj: MiniObject to return flags for.
-- *
-- * This macro returns the entire set of flags for the mini-object.
--
--*
-- * GST_MINI_OBJECT_FLAG_IS_SET:
-- * @obj: MiniObject to check for flags.
-- * @flag: Flag to check for
-- *
-- * This macro checks to see if the given flag is set.
--
--*
-- * GST_MINI_OBJECT_FLAG_SET:
-- * @obj: MiniObject to set flag in.
-- * @flag: Flag to set, can by any number of bits in guint32.
-- *
-- * This macro sets the given bits.
--
--*
-- * GST_MINI_OBJECT_FLAG_UNSET:
-- * @obj: MiniObject to unset flag in.
-- * @flag: Flag to set, must be a single bit in guint32.
-- *
-- * This macro usets the given bits.
--
--*
-- * GST_VALUE_HOLDS_MINI_OBJECT:
-- * @value: the #GValue to check
-- *
-- * Checks if the given #GValue contains a #GST_TYPE_MINI_OBJECT value.
--
--*
-- * GstMiniObjectFlags:
-- * @GST_MINI_OBJECT_FLAG_READONLY: is the miniobject readonly or writable
-- * @GST_MINI_OBJECT_FLAG_RESERVED1: a flag reserved for internal use e.g. as
-- * GST_BUFFER_FLAG_MEDIA4. Since: 0.10.33.
-- * @GST_MINI_OBJECT_FLAG_LAST: first flag that can be used by subclasses.
-- *
-- * Flags for the mini object
--
-- padding
subtype GstMiniObjectFlags is unsigned;
GST_MINI_OBJECT_FLAG_READONLY : constant GstMiniObjectFlags := 1;
GST_MINI_OBJECT_FLAG_RESERVED1 : constant GstMiniObjectFlags := 2;
GST_MINI_OBJECT_FLAG_LAST : constant GstMiniObjectFlags := 16; -- gst/gstminiobject.h:121
--*
-- * GST_MINI_OBJECT_REFCOUNT:
-- * @obj: a #GstMiniObject
-- *
-- * Get access to the reference count field of the mini-object.
--
--*
-- * GST_MINI_OBJECT_REFCOUNT_VALUE:
-- * @obj: a #GstMiniObject
-- *
-- * Get the reference count value of the mini-object.
--
--*
-- * GstMiniObjectWeakNotify:
-- * @data: data that was provided when the weak reference was established
-- * @where_the_mini_object_was: the mini object being finalized
-- *
-- * A #GstMiniObjectWeakNotify function can be added to a mini object as a
-- * callback that gets triggered when the mini object is finalized. Since the
-- * mini object is already being finalized when the #GstMiniObjectWeakNotify is
-- * called, there's not much you could do with the object, apart from e.g. using
-- * its adress as hash-index or the like.
-- *
-- * Since: 0.10.35
-- *
--
type GstMiniObjectWeakNotify is access procedure (arg1 : System.Address; arg2 : access GstMiniObject);
pragma Convention (C, GstMiniObjectWeakNotify); -- gst/gstminiobject.h:152
-- skipped empty struct u_GstMiniObjectPrivate
-- skipped empty struct GstMiniObjectPrivate
--*
-- * GstMiniObject:
-- * @instance: type instance
-- * @refcount: atomic refcount
-- * @flags: extra flags.
-- *
-- * Base class for refcounted lightweight objects.
-- * Ref Func: gst_mini_object_ref
-- * Unref Func: gst_mini_object_unref
-- * Set Value Func: gst_value_set_mini_object
-- * Get Value Func: gst_value_get_mini_object
--
type GstMiniObject is record
instance : aliased GStreamer.GST_Low_Level.glib_2_0_gobject_gtype_h.GTypeInstance; -- gst/gstminiobject.h:170
refcount : aliased GLIB.gint; -- gst/gstminiobject.h:172
flags : aliased GLIB.guint; -- gst/gstminiobject.h:173
priv : System.Address; -- gst/gstminiobject.h:176
end record;
pragma Convention (C_Pass_By_Copy, GstMiniObject); -- gst/gstminiobject.h:169
--< public >
-- with COW
--< private >
type GstMiniObjectClass is record
type_class : aliased GStreamer.GST_Low_Level.glib_2_0_gobject_gtype_h.GTypeClass; -- gst/gstminiobject.h:180
copy : GstMiniObjectCopyFunction; -- gst/gstminiobject.h:182
finalize : GstMiniObjectFinalizeFunction; -- gst/gstminiobject.h:183
u_gst_reserved : System.Address; -- gst/gstminiobject.h:186
end record;
pragma Convention (C_Pass_By_Copy, GstMiniObjectClass); -- gst/gstminiobject.h:179
--< private >
function gst_mini_object_get_type return GLIB.GType; -- gst/gstminiobject.h:189
pragma Import (C, gst_mini_object_get_type, "gst_mini_object_get_type");
function gst_mini_object_new (c_type : GLIB.GType) return access GstMiniObject; -- gst/gstminiobject.h:191
pragma Import (C, gst_mini_object_new, "gst_mini_object_new");
function gst_mini_object_copy (mini_object : access constant GstMiniObject) return access GstMiniObject; -- gst/gstminiobject.h:192
pragma Import (C, gst_mini_object_copy, "gst_mini_object_copy");
function gst_mini_object_is_writable (mini_object : access constant GstMiniObject) return GLIB.gboolean; -- gst/gstminiobject.h:193
pragma Import (C, gst_mini_object_is_writable, "gst_mini_object_is_writable");
function gst_mini_object_make_writable (mini_object : access GstMiniObject) return access GstMiniObject; -- gst/gstminiobject.h:194
pragma Import (C, gst_mini_object_make_writable, "gst_mini_object_make_writable");
-- refcounting
function gst_mini_object_ref (mini_object : access GstMiniObject) return access GstMiniObject; -- gst/gstminiobject.h:197
pragma Import (C, gst_mini_object_ref, "gst_mini_object_ref");
procedure gst_mini_object_unref (mini_object : access GstMiniObject); -- gst/gstminiobject.h:198
pragma Import (C, gst_mini_object_unref, "gst_mini_object_unref");
procedure gst_mini_object_weak_ref
(object : access GstMiniObject;
notify : GstMiniObjectWeakNotify;
data : System.Address); -- gst/gstminiobject.h:199
pragma Import (C, gst_mini_object_weak_ref, "gst_mini_object_weak_ref");
procedure gst_mini_object_weak_unref
(object : access GstMiniObject;
notify : GstMiniObjectWeakNotify;
data : System.Address); -- gst/gstminiobject.h:202
pragma Import (C, gst_mini_object_weak_unref, "gst_mini_object_weak_unref");
procedure gst_mini_object_replace (olddata : System.Address; newdata : access GstMiniObject); -- gst/gstminiobject.h:205
pragma Import (C, gst_mini_object_replace, "gst_mini_object_replace");
-- GParamSpec
type GstParamSpecMiniObject;
--subtype GstParamSpecMiniObject is u_GstParamSpecMiniObject; -- gst/gstminiobject.h:216
--*
-- * GstParamSpecMiniObject:
-- * @parent_instance: private %GParamSpec portion
-- *
-- * A %GParamSpec derived structure that contains the meta data
-- * for %GstMiniObject properties.
--
type GstParamSpecMiniObject is record
parent_instance : aliased GStreamer.GST_Low_Level.glib_2_0_gobject_gparam_h.GParamSpec; -- gst/gstminiobject.h:227
end record;
pragma Convention (C_Pass_By_Copy, GstParamSpecMiniObject); -- gst/gstminiobject.h:225
function gst_param_spec_mini_object_get_type return GLIB.GType; -- gst/gstminiobject.h:231
pragma Import (C, gst_param_spec_mini_object_get_type, "gst_param_spec_mini_object_get_type");
function gst_param_spec_mini_object
(name : Interfaces.C.Strings.chars_ptr;
nick : Interfaces.C.Strings.chars_ptr;
blurb : Interfaces.C.Strings.chars_ptr;
object_type : GLIB.GType;
flags : GStreamer.GST_Low_Level.glib_2_0_gobject_gparam_h.GParamFlags) return access GStreamer.GST_Low_Level.glib_2_0_gobject_gparam_h.GParamSpec; -- gst/gstminiobject.h:233
pragma Import (C, gst_param_spec_mini_object, "gst_param_spec_mini_object");
-- GValue stuff
procedure gst_value_set_mini_object (value : access Glib.Values.GValue; mini_object : access GstMiniObject); -- gst/gstminiobject.h:239
pragma Import (C, gst_value_set_mini_object, "gst_value_set_mini_object");
procedure gst_value_take_mini_object (value : access Glib.Values.GValue; mini_object : access GstMiniObject); -- gst/gstminiobject.h:240
pragma Import (C, gst_value_take_mini_object, "gst_value_take_mini_object");
function gst_value_get_mini_object (value : access constant Glib.Values.GValue) return access GstMiniObject; -- gst/gstminiobject.h:241
pragma Import (C, gst_value_get_mini_object, "gst_value_get_mini_object");
function gst_value_dup_mini_object (value : access constant Glib.Values.GValue) return access GstMiniObject; -- gst/gstminiobject.h:242
pragma Import (C, gst_value_dup_mini_object, "gst_value_dup_mini_object");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h;
|
caqg/linux-home | Ada | 4,914 | ads | ------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2007-2016, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
-- This package provides a set of high-level subprograms for handling UTF8
-- encoding
with Basic_Types; use Basic_Types;
with GNAT.Strings; use GNAT.Strings;
with GNATCOLL.Iconv; use GNATCOLL.Iconv;
package UTF8_Utils is
function Unknown_To_UTF8
(Input : String;
Success : access Boolean) return UTF8_String;
-- Transform a string of unknown encoding to UTF-8.
-- The heuristics used is the following:
-- - if S already contains valid UTF-8, assume it is already encoded
-- in UTF8 (the statistical chances for this are very high)
-- - if S does not contain valid UTF-8, assume it is encoded using the
-- locale, and attempt to convert it from the locale to UTF-8.
-- Success is set to False if the conversion failed.
function Unknown_To_UTF8
(Input : String) return UTF8_String;
-- Same as above, but return "<could not convert to UTF8>" if the
-- conversion could not be done.
procedure Unknown_To_UTF8
(Input : String;
Output : out String_Access;
Success : out Boolean);
-- Same as above, but return Output as Unchecked_String_Access for
-- efficiency. Output is still in UTF8 format, and the caller is
-- responsible for freeing it.
-- In addition, if Input is already a valid UTF8 string, then Output
-- will be set to null: you should use Input in this case.
-- If Success is set to False, Output will also be set to null.
-- Warning: Never reference Output (Output'Range) or Output'Last,
-- use Output (1 .. Len) and Len instead.
function UTF8_To_Locale (Input : UTF8_String) return String;
-- Convert Input to the GPS locale (ie, the contents of the environment
-- variable CHARSET, defaulting to ISO-8859-1).
-- If Input could not be converted, Input is returned as-is.
function Locale_To_UTF8 (Input : String) return UTF8_String;
-- Convert Input from the GPS locale (ie, the contents of the environment
-- variable CHARSET, defaulting to ISO-8859-1).
-- If Input could not be converted, Input is returned as-is.
function UTF8_Next_Char
(Str : UTF8_String; Index : Positive) return Positive;
function UTF8_Next_Char
(Str : UTF8_Unbounded_String; Index : Positive) return Positive;
-- Find the start of the next UTF8 character after the Index-th byte.
-- Index has to be on the start of a character.
-- Index is set to a value greater than Str'Last if there is no more
-- character.
function UTF8_Prev_Char
(Str : UTF8_String; Index : Natural) return Natural;
-- Find the start of the previous UTF8 character before the Index-th byte.
-- Index has to be on the start of a character.
-- Index is set to 0 if there is no more character.
function UTF8_Get_Char (Input : UTF8_String) return Wide_Wide_Character;
-- Return first character of UTF8_String
function Latin_1_To_UTF8 (Input : String) return UTF8_String;
-- Convert Latin_1 string to UTF-8.
function Column_To_Index
(Buffer : UTF8_String; Column : Character_Offset_Type) return Natural;
-- Return index of first byte of UTF8 character in given Column
-- Return 0 in Column <= 0. Return Buffer'First when Column = 1
function UTF8_Length (Item : UTF8_String) return Natural;
-- Returns number of user visible characters in UTF8 encoded string.
function Validate (Object : Iconv_T; Input : Byte_Sequence) return Boolean;
-- Check if convertion of Text is possible using given Object
function Validate_UTF_8 (Input : Byte_Sequence) return Boolean;
-- Check whether Input is valid UTF-8
end UTF8_Utils;
|
HeisenbugLtd/msg_passing | Ada | 2,294 | adb | ------------------------------------------------------------------------
-- Copyright (C) 2010-2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under
-- the terms of the Do What The Fuck You Want To Public License,
-- Version 2, as published by Sam Hocevar. See the LICENSE file for
-- more details.
------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------
-- Msg_Passing.Blackboard
--
-- Implementation of message passing via blackboards.
--
------------------------------------------------------------------------
package body Msg_Passing.Blackboard is
---------------------------------------------------------------------
-- Object.Read
---------------------------------------------------------------------
procedure Read (Instance : in out Object;
Message : out Letter) is
begin
Instance.Locked.Get (Message);
end Read;
---------------------------------------------------------------------
-- Object.Write
---------------------------------------------------------------------
procedure Write (Instance : in out Object;
Message : in Letter) is
begin
Instance.Locked.Put (Message);
end Write;
---------------------------------------------------------------------
-- protected body Mutex
---------------------------------------------------------------------
protected body Mutex is
------------------------------------------------------------------
-- Blackboard.Get
------------------------------------------------------------------
entry Get (Message : out Letter) when Msg_Available is
begin
Message := The_Message;
Msg_Available := False;
end Get;
------------------------------------------------------------------
-- Blackboard.Put
------------------------------------------------------------------
entry Put (Message : in Letter) when not Msg_Available is
begin
The_Message := Message;
Msg_Available := True;
end Put;
end Mutex;
end Msg_Passing.Blackboard;
|
stcarrez/dynamo | Ada | 82,397 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . C O N F --
-- --
-- B o d y --
-- --
-- Copyright (C) 2006-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Makeutl; use Makeutl;
with MLib.Tgt;
with Opt; use Opt;
with Output; use Output;
with Prj.Env;
with Prj.Err;
with Prj.Part;
with Prj.PP;
with Prj.Proc; use Prj.Proc;
with Prj.Tree; use Prj.Tree;
with Prj.Util; use Prj.Util;
with Prj; use Prj;
with Snames; use Snames;
with Ada.Directories; use Ada.Directories;
with Ada.Exceptions; use Ada.Exceptions;
with GNAT.Case_Util; use GNAT.Case_Util;
with GNAT.HTable; use GNAT.HTable;
package body Prj.Conf is
Auto_Cgpr : constant String := "auto.cgpr";
Config_Project_Env_Var : constant String := "GPR_CONFIG";
-- Name of the environment variable that provides the name of the
-- configuration file to use.
Gprconfig_Name : constant String := "gprconfig";
Warn_For_RTS : Boolean := True;
-- Set to False when gprbuild parse again the project files, to avoid
-- an incorrect warning.
type Runtime_Root_Data;
type Runtime_Root_Ptr is access Runtime_Root_Data;
type Runtime_Root_Data is record
Root : String_Access;
Next : Runtime_Root_Ptr;
end record;
-- Data for a runtime root to be used when adding directories to the
-- project path.
type Compiler_Root_Data;
type Compiler_Root_Ptr is access Compiler_Root_Data;
type Compiler_Root_Data is record
Root : String_Access;
Runtimes : Runtime_Root_Ptr;
Next : Compiler_Root_Ptr;
end record;
-- Data for a compiler root to be used when adding directories to the
-- project path.
First_Compiler_Root : Compiler_Root_Ptr := null;
-- Head of the list of compiler roots
package RTS_Languages is new GNAT.HTable.Simple_HTable
(Header_Num => Prj.Header_Num,
Element => Name_Id,
No_Element => No_Name,
Key => Name_Id,
Hash => Prj.Hash,
Equal => "=");
-- Stores the runtime names for the various languages. This is in general
-- set from a --RTS command line option.
-----------------------
-- Local_Subprograms --
-----------------------
function Check_Target
(Config_File : Prj.Project_Id;
Autoconf_Specified : Boolean;
Project_Tree : Prj.Project_Tree_Ref;
Target : String := "") return Boolean;
-- Check that the config file's target matches Target.
-- Target should be set to the empty string when the user did not specify
-- a target. If the target in the configuration file is invalid, this
-- function will raise Invalid_Config with an appropriate message.
-- Autoconf_Specified should be set to True if the user has used
-- autoconf.
function Locate_Config_File (Name : String) return String_Access;
-- Search for Name in the config files directory. Return full path if
-- found, or null otherwise.
procedure Raise_Invalid_Config (Msg : String);
pragma No_Return (Raise_Invalid_Config);
-- Raises exception Invalid_Config with given message
procedure Apply_Config_File
(Config_File : Prj.Project_Id;
Project_Tree : Prj.Project_Tree_Ref);
-- Apply the configuration file settings to all the projects in the
-- project tree. The Project_Tree must have been parsed first, and
-- processed through the first phase so that all its projects are known.
--
-- Currently, this will add new attributes and packages in the various
-- projects, so that when the second phase of the processing is performed
-- these attributes are automatically taken into account.
type State is (No_State);
procedure Look_For_Project_Paths
(Project : Project_Id;
Tree : Project_Tree_Ref;
With_State : in out State);
-- Check the compilers in the Project and add record them in the list
-- rooted at First_Compiler_Root, with their runtimes, if they are not
-- already in the list.
procedure Update_Project_Path is new
For_Every_Project_Imported
(State => State,
Action => Look_For_Project_Paths);
------------------------------------
-- Add_Default_GNAT_Naming_Scheme --
------------------------------------
procedure Add_Default_GNAT_Naming_Scheme
(Config_File : in out Project_Node_Id;
Project_Tree : Project_Node_Tree_Ref)
is
procedure Create_Attribute
(Name : Name_Id;
Value : String;
Index : String := "";
Pkg : Project_Node_Id := Empty_Node);
----------------------
-- Create_Attribute --
----------------------
procedure Create_Attribute
(Name : Name_Id;
Value : String;
Index : String := "";
Pkg : Project_Node_Id := Empty_Node)
is
Attr : Project_Node_Id;
pragma Unreferenced (Attr);
Expr : Name_Id := No_Name;
Val : Name_Id := No_Name;
Parent : Project_Node_Id := Config_File;
begin
if Index /= "" then
Name_Len := Index'Length;
Name_Buffer (1 .. Name_Len) := Index;
Val := Name_Find;
end if;
if Pkg /= Empty_Node then
Parent := Pkg;
end if;
Name_Len := Value'Length;
Name_Buffer (1 .. Name_Len) := Value;
Expr := Name_Find;
Attr := Create_Attribute
(Tree => Project_Tree,
Prj_Or_Pkg => Parent,
Name => Name,
Index_Name => Val,
Kind => Prj.Single,
Value => Create_Literal_String (Expr, Project_Tree));
end Create_Attribute;
-- Local variables
Name : Name_Id;
Naming : Project_Node_Id;
Compiler : Project_Node_Id;
-- Start of processing for Add_Default_GNAT_Naming_Scheme
begin
if Config_File = Empty_Node then
-- Create a dummy config file if none was found
Name_Len := Auto_Cgpr'Length;
Name_Buffer (1 .. Name_Len) := Auto_Cgpr;
Name := Name_Find;
-- An invalid project name to avoid conflicts with user-created ones
Name_Len := 5;
Name_Buffer (1 .. Name_Len) := "_auto";
Config_File :=
Create_Project
(In_Tree => Project_Tree,
Name => Name_Find,
Full_Path => Path_Name_Type (Name),
Is_Config_File => True);
-- Setup library support
case MLib.Tgt.Support_For_Libraries is
when None =>
null;
when Static_Only =>
Create_Attribute (Name_Library_Support, "static_only");
when Full =>
Create_Attribute (Name_Library_Support, "full");
end case;
if MLib.Tgt.Standalone_Library_Auto_Init_Is_Supported then
Create_Attribute (Name_Library_Auto_Init_Supported, "true");
else
Create_Attribute (Name_Library_Auto_Init_Supported, "false");
end if;
-- Declare an empty target
Create_Attribute (Name_Target, "");
-- Setup Ada support (Ada is the default language here, since this
-- is only called when no config file existed initially, ie for
-- gnatmake).
Create_Attribute (Name_Default_Language, "ada");
Compiler := Create_Package (Project_Tree, Config_File, "compiler");
Create_Attribute
(Name_Driver, "gcc", "ada", Pkg => Compiler);
Create_Attribute
(Name_Language_Kind, "unit_based", "ada", Pkg => Compiler);
Create_Attribute
(Name_Dependency_Kind, "ALI_File", "ada", Pkg => Compiler);
Naming := Create_Package (Project_Tree, Config_File, "naming");
Create_Attribute (Name_Spec_Suffix, ".ads", "ada", Pkg => Naming);
Create_Attribute (Name_Separate_Suffix, ".adb", "ada", Pkg => Naming);
Create_Attribute (Name_Body_Suffix, ".adb", "ada", Pkg => Naming);
Create_Attribute (Name_Dot_Replacement, "-", Pkg => Naming);
Create_Attribute (Name_Casing, "lowercase", Pkg => Naming);
if Current_Verbosity = High then
Write_Line ("Automatically generated (in-memory) config file");
Prj.PP.Pretty_Print
(Project => Config_File,
In_Tree => Project_Tree,
Backward_Compatibility => False);
end if;
end if;
end Add_Default_GNAT_Naming_Scheme;
-----------------------
-- Apply_Config_File --
-----------------------
procedure Apply_Config_File
(Config_File : Prj.Project_Id;
Project_Tree : Prj.Project_Tree_Ref)
is
procedure Add_Attributes
(Project_Tree : Project_Tree_Ref;
Conf_Decl : Declarations;
User_Decl : in out Declarations);
-- Process the attributes in the config declarations. For
-- single string values, if the attribute is not declared in
-- the user declarations, declare it with the value in the
-- config declarations. For string list values, prepend the
-- value in the user declarations with the value in the config
-- declarations.
--------------------
-- Add_Attributes --
--------------------
procedure Add_Attributes
(Project_Tree : Project_Tree_Ref;
Conf_Decl : Declarations;
User_Decl : in out Declarations)
is
Shared : constant Shared_Project_Tree_Data_Access :=
Project_Tree.Shared;
Conf_Attr_Id : Variable_Id;
Conf_Attr : Variable;
Conf_Array_Id : Array_Id;
Conf_Array : Array_Data;
Conf_Array_Elem_Id : Array_Element_Id;
Conf_Array_Elem : Array_Element;
Conf_List : String_List_Id;
Conf_List_Elem : String_Element;
User_Attr_Id : Variable_Id;
User_Attr : Variable;
User_Array_Id : Array_Id;
User_Array : Array_Data;
User_Array_Elem_Id : Array_Element_Id;
User_Array_Elem : Array_Element;
begin
Conf_Attr_Id := Conf_Decl.Attributes;
User_Attr_Id := User_Decl.Attributes;
while Conf_Attr_Id /= No_Variable loop
Conf_Attr := Shared.Variable_Elements.Table (Conf_Attr_Id);
User_Attr := Shared.Variable_Elements.Table (User_Attr_Id);
if not Conf_Attr.Value.Default then
if User_Attr.Value.Default then
-- No attribute declared in user project file: just copy
-- the value of the configuration attribute.
User_Attr.Value := Conf_Attr.Value;
Shared.Variable_Elements.Table (User_Attr_Id) := User_Attr;
elsif User_Attr.Value.Kind = List
and then Conf_Attr.Value.Values /= Nil_String
then
-- List attribute declared in both the user project and the
-- configuration project: prepend the user list with the
-- configuration list.
declare
User_List : constant String_List_Id :=
User_Attr.Value.Values;
Conf_List : String_List_Id := Conf_Attr.Value.Values;
Conf_Elem : String_Element;
New_List : String_List_Id;
New_Elem : String_Element;
begin
-- Create new list
String_Element_Table.Increment_Last
(Shared.String_Elements);
New_List :=
String_Element_Table.Last (Shared.String_Elements);
-- Value of attribute is new list
User_Attr.Value.Values := New_List;
Shared.Variable_Elements.Table (User_Attr_Id) :=
User_Attr;
loop
-- Get each element of configuration list
Conf_Elem := Shared.String_Elements.Table (Conf_List);
New_Elem := Conf_Elem;
Conf_List := Conf_Elem.Next;
if Conf_List = Nil_String then
-- If it is the last element in the list, connect
-- to first element of user list, and we are done.
New_Elem.Next := User_List;
Shared.String_Elements.Table (New_List) := New_Elem;
exit;
else
-- If it is not the last element in the list, add
-- to new list.
String_Element_Table.Increment_Last
(Shared.String_Elements);
New_Elem.Next := String_Element_Table.Last
(Shared.String_Elements);
Shared.String_Elements.Table (New_List) := New_Elem;
New_List := New_Elem.Next;
end if;
end loop;
end;
end if;
end if;
Conf_Attr_Id := Conf_Attr.Next;
User_Attr_Id := User_Attr.Next;
end loop;
Conf_Array_Id := Conf_Decl.Arrays;
while Conf_Array_Id /= No_Array loop
Conf_Array := Shared.Arrays.Table (Conf_Array_Id);
User_Array_Id := User_Decl.Arrays;
while User_Array_Id /= No_Array loop
User_Array := Shared.Arrays.Table (User_Array_Id);
exit when User_Array.Name = Conf_Array.Name;
User_Array_Id := User_Array.Next;
end loop;
-- If this associative array does not exist in the user project
-- file, do a shallow copy of the full associative array.
if User_Array_Id = No_Array then
Array_Table.Increment_Last (Shared.Arrays);
User_Array := Conf_Array;
User_Array.Next := User_Decl.Arrays;
User_Decl.Arrays := Array_Table.Last (Shared.Arrays);
Shared.Arrays.Table (User_Decl.Arrays) := User_Array;
-- Otherwise, check each array element
else
Conf_Array_Elem_Id := Conf_Array.Value;
while Conf_Array_Elem_Id /= No_Array_Element loop
Conf_Array_Elem :=
Shared.Array_Elements.Table (Conf_Array_Elem_Id);
User_Array_Elem_Id := User_Array.Value;
while User_Array_Elem_Id /= No_Array_Element loop
User_Array_Elem :=
Shared.Array_Elements.Table (User_Array_Elem_Id);
exit when User_Array_Elem.Index = Conf_Array_Elem.Index;
User_Array_Elem_Id := User_Array_Elem.Next;
end loop;
-- If the array element doesn't exist in the user array,
-- insert a shallow copy of the conf array element in the
-- user array.
if User_Array_Elem_Id = No_Array_Element then
Array_Element_Table.Increment_Last
(Shared.Array_Elements);
User_Array_Elem := Conf_Array_Elem;
User_Array_Elem.Next := User_Array.Value;
User_Array.Value :=
Array_Element_Table.Last (Shared.Array_Elements);
Shared.Array_Elements.Table (User_Array.Value) :=
User_Array_Elem;
Shared.Arrays.Table (User_Array_Id) := User_Array;
-- Otherwise, if the value is a string list, prepend the
-- conf array element value to the array element.
elsif Conf_Array_Elem.Value.Kind = List then
Conf_List := Conf_Array_Elem.Value.Values;
if Conf_List /= Nil_String then
declare
Link : constant String_List_Id :=
User_Array_Elem.Value.Values;
Previous : String_List_Id := Nil_String;
Next : String_List_Id;
begin
loop
Conf_List_Elem :=
Shared.String_Elements.Table (Conf_List);
String_Element_Table.Increment_Last
(Shared.String_Elements);
Next :=
String_Element_Table.Last
(Shared.String_Elements);
Shared.String_Elements.Table (Next) :=
Conf_List_Elem;
if Previous = Nil_String then
User_Array_Elem.Value.Values := Next;
Shared.Array_Elements.Table
(User_Array_Elem_Id) := User_Array_Elem;
else
Shared.String_Elements.Table
(Previous).Next := Next;
end if;
Previous := Next;
Conf_List := Conf_List_Elem.Next;
if Conf_List = Nil_String then
Shared.String_Elements.Table
(Previous).Next := Link;
exit;
end if;
end loop;
end;
end if;
end if;
Conf_Array_Elem_Id := Conf_Array_Elem.Next;
end loop;
end if;
Conf_Array_Id := Conf_Array.Next;
end loop;
end Add_Attributes;
Shared : constant Shared_Project_Tree_Data_Access := Project_Tree.Shared;
Conf_Decl : constant Declarations := Config_File.Decl;
Conf_Pack_Id : Package_Id;
Conf_Pack : Package_Element;
User_Decl : Declarations;
User_Pack_Id : Package_Id;
User_Pack : Package_Element;
Proj : Project_List;
begin
Debug_Output ("Applying config file to a project tree");
Proj := Project_Tree.Projects;
while Proj /= null loop
if Proj.Project /= Config_File then
User_Decl := Proj.Project.Decl;
Add_Attributes
(Project_Tree => Project_Tree,
Conf_Decl => Conf_Decl,
User_Decl => User_Decl);
Conf_Pack_Id := Conf_Decl.Packages;
while Conf_Pack_Id /= No_Package loop
Conf_Pack := Shared.Packages.Table (Conf_Pack_Id);
User_Pack_Id := User_Decl.Packages;
while User_Pack_Id /= No_Package loop
User_Pack := Shared.Packages.Table (User_Pack_Id);
exit when User_Pack.Name = Conf_Pack.Name;
User_Pack_Id := User_Pack.Next;
end loop;
if User_Pack_Id = No_Package then
Package_Table.Increment_Last (Shared.Packages);
User_Pack := Conf_Pack;
User_Pack.Next := User_Decl.Packages;
User_Decl.Packages := Package_Table.Last (Shared.Packages);
Shared.Packages.Table (User_Decl.Packages) := User_Pack;
else
Add_Attributes
(Project_Tree => Project_Tree,
Conf_Decl => Conf_Pack.Decl,
User_Decl => Shared.Packages.Table
(User_Pack_Id).Decl);
end if;
Conf_Pack_Id := Conf_Pack.Next;
end loop;
Proj.Project.Decl := User_Decl;
-- For aggregate projects, we need to apply the config to all
-- their aggregated trees as well.
if Proj.Project.Qualifier in Aggregate_Project then
declare
List : Aggregated_Project_List;
begin
List := Proj.Project.Aggregated_Projects;
while List /= null loop
Debug_Output
("Recursively apply config to aggregated tree",
List.Project.Name);
Apply_Config_File
(Config_File, Project_Tree => List.Tree);
List := List.Next;
end loop;
end;
end if;
end if;
Proj := Proj.Next;
end loop;
end Apply_Config_File;
------------------
-- Check_Target --
------------------
function Check_Target
(Config_File : Project_Id;
Autoconf_Specified : Boolean;
Project_Tree : Prj.Project_Tree_Ref;
Target : String := "") return Boolean
is
Shared : constant Shared_Project_Tree_Data_Access :=
Project_Tree.Shared;
Variable : constant Variable_Value :=
Value_Of
(Name_Target, Config_File.Decl.Attributes, Shared);
Tgt_Name : Name_Id := No_Name;
OK : Boolean;
begin
if Variable /= Nil_Variable_Value and then not Variable.Default then
Tgt_Name := Variable.Value;
end if;
OK :=
Target = ""
or else
(Tgt_Name /= No_Name
and then (Length_Of_Name (Tgt_Name) = 0
or else Target = Get_Name_String (Tgt_Name)));
if not OK then
if Autoconf_Specified then
if Verbose_Mode then
Write_Line ("inconsistent targets, performing autoconf");
end if;
return False;
else
if Tgt_Name /= No_Name then
Raise_Invalid_Config
("mismatched targets: """
& Get_Name_String (Tgt_Name) & """ in configuration, """
& Target & """ specified");
else
Raise_Invalid_Config
("no target specified in configuration file");
end if;
end if;
end if;
return True;
end Check_Target;
--------------------------------------
-- Get_Or_Create_Configuration_File --
--------------------------------------
procedure Get_Or_Create_Configuration_File
(Project : Project_Id;
Conf_Project : Project_Id;
Project_Tree : Project_Tree_Ref;
Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment;
Allow_Automatic_Generation : Boolean;
Config_File_Name : String := "";
Autoconf_Specified : Boolean;
Target_Name : String := "";
Normalized_Hostname : String;
Packages_To_Check : String_List_Access := null;
Config : out Prj.Project_Id;
Config_File_Path : out String_Access;
Automatically_Generated : out Boolean;
On_Load_Config : Config_File_Hook := null)
is
Shared : constant Shared_Project_Tree_Data_Access := Project_Tree.Shared;
At_Least_One_Compiler_Command : Boolean := False;
-- Set to True if at least one attribute Ide'Compiler_Command is
-- specified for one language of the system.
Conf_File_Name : String_Access := new String'(Config_File_Name);
-- The configuration project file name. May be modified if there are
-- switches --config= in the Builder package of the main project.
Selected_Target : String_Access := new String'(Target_Name);
function Default_File_Name return String;
-- Return the name of the default config file that should be tested
procedure Do_Autoconf;
-- Generate a new config file through gprconfig. In case of error, this
-- raises the Invalid_Config exception with an appropriate message
procedure Check_Builder_Switches;
-- Check for switches --config and --RTS in package Builder
procedure Get_Project_Target;
-- If Target_Name is empty, get the specified target in the project
-- file, if any.
procedure Get_Project_Runtimes;
-- Get the various Runtime (<lang>) in the project file or any project
-- it extends, if any are specified.
function Get_Config_Switches return Argument_List_Access;
-- Return the --config switches to use for gprconfig
function Get_Db_Switches return Argument_List_Access;
-- Return the --db switches to use for gprconfig
function Might_Have_Sources (Project : Project_Id) return Boolean;
-- True if the specified project might have sources (ie the user has not
-- explicitly specified it. We haven't checked the file system, nor do
-- we need to at this stage.
----------------------------
-- Check_Builder_Switches --
----------------------------
procedure Check_Builder_Switches is
Get_RTS_Switches : constant Boolean :=
RTS_Languages.Get_First = No_Name;
-- If no switch --RTS have been specified on the command line, look
-- for --RTS switches in the Builder switches.
Builder : constant Package_Id :=
Value_Of (Name_Builder, Project.Decl.Packages, Shared);
Switch_Array_Id : Array_Element_Id;
-- The Switches to be checked
procedure Check_Switches;
-- Check the switches in Switch_Array_Id
--------------------
-- Check_Switches --
--------------------
procedure Check_Switches is
Switch_Array : Array_Element;
Switch_List : String_List_Id := Nil_String;
Switch : String_Element;
Lang : Name_Id;
Lang_Last : Positive;
begin
while Switch_Array_Id /= No_Array_Element loop
Switch_Array :=
Shared.Array_Elements.Table (Switch_Array_Id);
Switch_List := Switch_Array.Value.Values;
List_Loop : while Switch_List /= Nil_String loop
Switch := Shared.String_Elements.Table (Switch_List);
if Switch.Value /= No_Name then
Get_Name_String (Switch.Value);
if Conf_File_Name'Length = 0
and then Name_Len > 9
and then Name_Buffer (1 .. 9) = "--config="
then
Conf_File_Name :=
new String'(Name_Buffer (10 .. Name_Len));
elsif Get_RTS_Switches
and then Name_Len >= 7
and then Name_Buffer (1 .. 5) = "--RTS"
then
if Name_Buffer (6) = '=' then
if not Runtime_Name_Set_For (Name_Ada) then
Set_Runtime_For
(Name_Ada,
Name_Buffer (7 .. Name_Len));
end if;
elsif Name_Len > 7
and then Name_Buffer (6) = ':'
and then Name_Buffer (7) /= '='
then
Lang_Last := 7;
while Lang_Last < Name_Len
and then Name_Buffer (Lang_Last + 1) /= '='
loop
Lang_Last := Lang_Last + 1;
end loop;
if Name_Buffer (Lang_Last + 1) = '=' then
declare
RTS : constant String :=
Name_Buffer (Lang_Last + 2 .. Name_Len);
begin
Name_Buffer (1 .. Lang_Last - 6) :=
Name_Buffer (7 .. Lang_Last);
Name_Len := Lang_Last - 6;
To_Lower (Name_Buffer (1 .. Name_Len));
Lang := Name_Find;
if not Runtime_Name_Set_For (Lang) then
Set_Runtime_For (Lang, RTS);
end if;
end;
end if;
end if;
end if;
end if;
Switch_List := Switch.Next;
end loop List_Loop;
Switch_Array_Id := Switch_Array.Next;
end loop;
end Check_Switches;
-- Start of processing for Check_Builder_Switches
begin
if Builder /= No_Package then
Switch_Array_Id :=
Value_Of
(Name => Name_Switches,
In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
Shared => Shared);
Check_Switches;
Switch_Array_Id :=
Value_Of
(Name => Name_Default_Switches,
In_Arrays => Shared.Packages.Table (Builder).Decl.Arrays,
Shared => Shared);
Check_Switches;
end if;
end Check_Builder_Switches;
------------------------
-- Get_Project_Target --
------------------------
procedure Get_Project_Target is
begin
if Selected_Target'Length = 0 then
-- Check if attribute Target is specified in the main
-- project, or in a project it extends. If it is, use this
-- target to invoke gprconfig.
declare
Variable : Variable_Value;
Proj : Project_Id;
Tgt_Name : Name_Id := No_Name;
begin
Proj := Project;
Project_Loop :
while Proj /= No_Project loop
Variable :=
Value_Of (Name_Target, Proj.Decl.Attributes, Shared);
if Variable /= Nil_Variable_Value
and then not Variable.Default
and then Variable.Value /= No_Name
then
Tgt_Name := Variable.Value;
exit Project_Loop;
end if;
Proj := Proj.Extends;
end loop Project_Loop;
if Tgt_Name /= No_Name then
Selected_Target := new String'(Get_Name_String (Tgt_Name));
end if;
end;
end if;
end Get_Project_Target;
--------------------------
-- Get_Project_Runtimes --
--------------------------
procedure Get_Project_Runtimes is
Element : Array_Element;
Id : Array_Element_Id;
Lang : Name_Id;
Proj : Project_Id;
begin
Proj := Project;
while Proj /= No_Project loop
Id := Value_Of (Name_Runtime, Proj.Decl.Arrays, Shared);
while Id /= No_Array_Element loop
Element := Shared.Array_Elements.Table (Id);
Lang := Element.Index;
if not Runtime_Name_Set_For (Lang) then
Set_Runtime_For
(Lang, RTS_Name => Get_Name_String (Element.Value.Value));
end if;
Id := Element.Next;
end loop;
Proj := Proj.Extends;
end loop;
end Get_Project_Runtimes;
-----------------------
-- Default_File_Name --
-----------------------
function Default_File_Name return String is
Ada_RTS : constant String := Runtime_Name_For (Name_Ada);
Tmp : String_Access;
begin
if Selected_Target'Length /= 0 then
if Ada_RTS /= "" then
return
Selected_Target.all & '-' &
Ada_RTS & Config_Project_File_Extension;
else
return
Selected_Target.all & Config_Project_File_Extension;
end if;
elsif Ada_RTS /= "" then
return Ada_RTS & Config_Project_File_Extension;
else
Tmp := Getenv (Config_Project_Env_Var);
declare
T : constant String := Tmp.all;
begin
Free (Tmp);
if T'Length = 0 then
return Default_Config_Name;
else
return T;
end if;
end;
end if;
end Default_File_Name;
-----------------
-- Do_Autoconf --
-----------------
procedure Do_Autoconf is
Obj_Dir : constant Variable_Value :=
Value_Of
(Name_Object_Dir,
Conf_Project.Decl.Attributes,
Shared);
Gprconfig_Path : String_Access;
Success : Boolean;
begin
Gprconfig_Path := Locate_Exec_On_Path (Gprconfig_Name);
if Gprconfig_Path = null then
Raise_Invalid_Config
("could not locate gprconfig for auto-configuration");
end if;
-- First, find the object directory of the Conf_Project
if Obj_Dir = Nil_Variable_Value or else Obj_Dir.Default then
Get_Name_String (Conf_Project.Directory.Display_Name);
else
if Is_Absolute_Path (Get_Name_String (Obj_Dir.Value)) then
Get_Name_String (Obj_Dir.Value);
else
Name_Len := 0;
Add_Str_To_Name_Buffer
(Get_Name_String (Conf_Project.Directory.Display_Name));
Add_Str_To_Name_Buffer (Get_Name_String (Obj_Dir.Value));
end if;
end if;
if Subdirs /= null then
Add_Char_To_Name_Buffer (Directory_Separator);
Add_Str_To_Name_Buffer (Subdirs.all);
end if;
for J in 1 .. Name_Len loop
if Name_Buffer (J) = '/' then
Name_Buffer (J) := Directory_Separator;
end if;
end loop;
-- Make sure that Obj_Dir ends with a directory separator
if Name_Buffer (Name_Len) /= Directory_Separator then
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Directory_Separator;
end if;
declare
Obj_Dir : constant String := Name_Buffer (1 .. Name_Len);
Config_Switches : Argument_List_Access;
Db_Switches : Argument_List_Access;
Args : Argument_List (1 .. 5);
Arg_Last : Positive;
Obj_Dir_Exists : Boolean := True;
begin
-- Check if the object directory exists. If Setup_Projects is True
-- (-p) and directory does not exist, attempt to create it.
-- Otherwise, if directory does not exist, fail without calling
-- gprconfig.
if not Is_Directory (Obj_Dir)
and then (Setup_Projects or else Subdirs /= null)
then
begin
Create_Path (Obj_Dir);
if not Quiet_Output then
Write_Str ("object directory """);
Write_Str (Obj_Dir);
Write_Line (""" created");
end if;
exception
when others =>
Raise_Invalid_Config
("could not create object directory " & Obj_Dir);
end;
end if;
if not Is_Directory (Obj_Dir) then
case Env.Flags.Require_Obj_Dirs is
when Error =>
Raise_Invalid_Config
("object directory " & Obj_Dir & " does not exist");
when Warning =>
Prj.Err.Error_Msg
(Env.Flags,
"?object directory " & Obj_Dir & " does not exist");
Obj_Dir_Exists := False;
when Silent =>
null;
end case;
end if;
-- Get the config switches. This should be done only now, as some
-- runtimes may have been found in the Builder switches.
Config_Switches := Get_Config_Switches;
-- Get eventual --db switches
Db_Switches := Get_Db_Switches;
-- Invoke gprconfig
Args (1) := new String'("--batch");
Args (2) := new String'("-o");
-- If no config file was specified, set the auto.cgpr one
if Conf_File_Name'Length = 0 then
if Obj_Dir_Exists then
Args (3) := new String'(Obj_Dir & Auto_Cgpr);
else
declare
Path_FD : File_Descriptor;
Path_Name : Path_Name_Type;
begin
Prj.Env.Create_Temp_File
(Shared => Project_Tree.Shared,
Path_FD => Path_FD,
Path_Name => Path_Name,
File_Use => "configuration file");
if Path_FD /= Invalid_FD then
declare
Temp_Dir : constant String :=
Containing_Directory
(Get_Name_String (Path_Name));
begin
GNAT.OS_Lib.Close (Path_FD);
Args (3) :=
new String'(Temp_Dir &
Directory_Separator &
Auto_Cgpr);
Delete_File (Get_Name_String (Path_Name));
end;
else
-- We'll have an error message later on
Args (3) := new String'(Obj_Dir & Auto_Cgpr);
end if;
end;
end if;
else
Args (3) := Conf_File_Name;
end if;
Arg_Last := 3;
if Selected_Target /= null and then
Selected_Target.all /= ""
then
Args (4) :=
new String'("--target=" & Selected_Target.all);
Arg_Last := 4;
elsif Normalized_Hostname /= "" then
if At_Least_One_Compiler_Command then
Args (4) := new String'("--target=all");
else
Args (4) := new String'("--target=" & Normalized_Hostname);
end if;
Arg_Last := 4;
end if;
if not Verbose_Mode then
Arg_Last := Arg_Last + 1;
Args (Arg_Last) := new String'("-q");
end if;
if Verbose_Mode then
Write_Str (Gprconfig_Name);
for J in 1 .. Arg_Last loop
Write_Char (' ');
Write_Str (Args (J).all);
end loop;
for J in Config_Switches'Range loop
Write_Char (' ');
Write_Str (Config_Switches (J).all);
end loop;
for J in Db_Switches'Range loop
Write_Char (' ');
Write_Str (Db_Switches (J).all);
end loop;
Write_Eol;
elsif not Quiet_Output then
-- Display no message if we are creating auto.cgpr, unless in
-- verbose mode.
if Config_File_Name'Length > 0 or else Verbose_Mode then
Write_Str ("creating ");
Write_Str (Simple_Name (Args (3).all));
Write_Eol;
end if;
end if;
Spawn (Gprconfig_Path.all, Args (1 .. Arg_Last) &
Config_Switches.all & Db_Switches.all,
Success);
Free (Config_Switches);
Config_File_Path := Locate_Config_File (Args (3).all);
if Config_File_Path = null then
Raise_Invalid_Config
("could not create " & Args (3).all);
end if;
for F in Args'Range loop
Free (Args (F));
end loop;
end;
end Do_Autoconf;
---------------------
-- Get_Db_Switches --
---------------------
function Get_Db_Switches return Argument_List_Access is
Result : Argument_List_Access;
Nmb_Arg : Natural;
begin
Nmb_Arg :=
(2 * Db_Switch_Args.Last) + Boolean'Pos (not Load_Standard_Base);
Result := new Argument_List (1 .. Nmb_Arg);
if Nmb_Arg /= 0 then
for J in 1 .. Db_Switch_Args.Last loop
Result (2 * J - 1) :=
new String'("--db");
Result (2 * J) :=
new String'(Get_Name_String (Db_Switch_Args.Table (J)));
end loop;
if not Load_Standard_Base then
Result (Result'Last) := new String'("--db-");
end if;
end if;
return Result;
end Get_Db_Switches;
-------------------------
-- Get_Config_Switches --
-------------------------
function Get_Config_Switches return Argument_List_Access is
package Language_Htable is new GNAT.HTable.Simple_HTable
(Header_Num => Prj.Header_Num,
Element => Name_Id,
No_Element => No_Name,
Key => Name_Id,
Hash => Prj.Hash,
Equal => "=");
-- Hash table to keep the languages used in the project tree
IDE : constant Package_Id :=
Value_Of (Name_Ide, Project.Decl.Packages, Shared);
procedure Add_Config_Switches_For_Project
(Project : Project_Id;
Tree : Project_Tree_Ref;
With_State : in out Integer);
-- Add all --config switches for this project. This is also called
-- for aggregate projects.
-------------------------------------
-- Add_Config_Switches_For_Project --
-------------------------------------
procedure Add_Config_Switches_For_Project
(Project : Project_Id;
Tree : Project_Tree_Ref;
With_State : in out Integer)
is
pragma Unreferenced (With_State);
Shared : constant Shared_Project_Tree_Data_Access := Tree.Shared;
Variable : Variable_Value;
Check_Default : Boolean;
Lang : Name_Id;
List : String_List_Id;
Elem : String_Element;
begin
if Might_Have_Sources (Project) then
Variable :=
Value_Of (Name_Languages, Project.Decl.Attributes, Shared);
if Variable = Nil_Variable_Value or else Variable.Default then
-- Languages is not declared. If it is not an extending
-- project, or if it extends a project with no Languages,
-- check for Default_Language.
Check_Default := Project.Extends = No_Project;
if not Check_Default then
Variable :=
Value_Of
(Name_Languages,
Project.Extends.Decl.Attributes,
Shared);
Check_Default :=
Variable /= Nil_Variable_Value
and then Variable.Values = Nil_String;
end if;
if Check_Default then
Variable :=
Value_Of
(Name_Default_Language,
Project.Decl.Attributes,
Shared);
if Variable /= Nil_Variable_Value
and then not Variable.Default
then
Get_Name_String (Variable.Value);
To_Lower (Name_Buffer (1 .. Name_Len));
Lang := Name_Find;
Language_Htable.Set (Lang, Lang);
-- If no default language is declared, default to Ada
else
Language_Htable.Set (Name_Ada, Name_Ada);
end if;
end if;
elsif Variable.Values /= Nil_String then
-- Attribute Languages is declared with a non empty list:
-- put all the languages in Language_HTable.
List := Variable.Values;
while List /= Nil_String loop
Elem := Shared.String_Elements.Table (List);
Get_Name_String (Elem.Value);
To_Lower (Name_Buffer (1 .. Name_Len));
Lang := Name_Find;
Language_Htable.Set (Lang, Lang);
List := Elem.Next;
end loop;
end if;
end if;
end Add_Config_Switches_For_Project;
procedure For_Every_Imported_Project is new For_Every_Project_Imported
(State => Integer, Action => Add_Config_Switches_For_Project);
-- Document this procedure ???
-- Local variables
Name : Name_Id;
Count : Natural;
Result : Argument_List_Access;
Variable : Variable_Value;
Dummy : Integer := 0;
-- Start of processing for Get_Config_Switches
begin
For_Every_Imported_Project
(By => Project,
Tree => Project_Tree,
With_State => Dummy,
Include_Aggregated => True);
Name := Language_Htable.Get_First;
Count := 0;
while Name /= No_Name loop
Count := Count + 1;
Name := Language_Htable.Get_Next;
end loop;
Result := new String_List (1 .. Count);
Count := 1;
Name := Language_Htable.Get_First;
while Name /= No_Name loop
-- Check if IDE'Compiler_Command is declared for the language.
-- If it is, use its value to invoke gprconfig.
Variable :=
Value_Of
(Name,
Attribute_Or_Array_Name => Name_Compiler_Command,
In_Package => IDE,
Shared => Shared,
Force_Lower_Case_Index => True);
declare
Config_Command : constant String :=
"--config=" & Get_Name_String (Name);
Runtime_Name : constant String := Runtime_Name_For (Name);
begin
-- In CodePeer mode, we do not take into account any compiler
-- command from the package IDE.
if CodePeer_Mode
or else Variable = Nil_Variable_Value
or else Length_Of_Name (Variable.Value) = 0
then
Result (Count) :=
new String'(Config_Command & ",," & Runtime_Name);
else
At_Least_One_Compiler_Command := True;
declare
Compiler_Command : constant String :=
Get_Name_String (Variable.Value);
begin
if Is_Absolute_Path (Compiler_Command) then
Result (Count) :=
new String'
(Config_Command & ",," & Runtime_Name & ","
& Containing_Directory (Compiler_Command) & ","
& Simple_Name (Compiler_Command));
else
Result (Count) :=
new String'
(Config_Command & ",," & Runtime_Name & ",,"
& Compiler_Command);
end if;
end;
end if;
end;
Count := Count + 1;
Name := Language_Htable.Get_Next;
end loop;
return Result;
end Get_Config_Switches;
------------------------
-- Might_Have_Sources --
------------------------
function Might_Have_Sources (Project : Project_Id) return Boolean is
Variable : Variable_Value;
begin
Variable :=
Value_Of (Name_Source_Dirs, Project.Decl.Attributes, Shared);
if Variable = Nil_Variable_Value
or else Variable.Default
or else Variable.Values /= Nil_String
then
Variable :=
Value_Of (Name_Source_Files, Project.Decl.Attributes, Shared);
return Variable = Nil_Variable_Value
or else Variable.Default
or else Variable.Values /= Nil_String;
else
return False;
end if;
end Might_Have_Sources;
-- Local Variables
Success : Boolean;
Config_Project_Node : Project_Node_Id := Empty_Node;
-- Start of processing for Get_Or_Create_Configuration_File
begin
pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
Free (Config_File_Path);
Config := No_Project;
Get_Project_Target;
Get_Project_Runtimes;
Check_Builder_Switches;
-- Do not attempt to find a configuration project file when
-- Config_File_Name is No_Configuration_File.
if Config_File_Name = No_Configuration_File then
Config_File_Path := null;
else
if Conf_File_Name'Length > 0 then
Config_File_Path := Locate_Config_File (Conf_File_Name.all);
else
Config_File_Path := Locate_Config_File (Default_File_Name);
end if;
if Config_File_Path = null then
if not Allow_Automatic_Generation
and then Conf_File_Name'Length > 0
then
Raise_Invalid_Config
("could not locate main configuration project "
& Conf_File_Name.all);
end if;
end if;
end if;
Automatically_Generated :=
Allow_Automatic_Generation and then Config_File_Path = null;
<<Process_Config_File>>
if Automatically_Generated then
-- This might raise an Invalid_Config exception
Do_Autoconf;
-- If the config file is not auto-generated, warn if there is any --RTS
-- switch, but not when the config file is generated in memory.
elsif Warn_For_RTS
and then RTS_Languages.Get_First /= No_Name
and then Opt.Warning_Mode /= Opt.Suppress
and then On_Load_Config = null
then
Write_Line
("warning: " &
"runtimes are taken into account only in auto-configuration");
end if;
-- Parse the configuration file
if Verbose_Mode and then Config_File_Path /= null then
Write_Str ("Checking configuration ");
Write_Line (Config_File_Path.all);
end if;
if Config_File_Path /= null then
Prj.Part.Parse
(In_Tree => Project_Node_Tree,
Project => Config_Project_Node,
Project_File_Name => Config_File_Path.all,
Errout_Handling => Prj.Part.Finalize_If_Error,
Packages_To_Check => Packages_To_Check,
Current_Directory => Current_Directory,
Is_Config_File => True,
Env => Env);
else
Config_Project_Node := Empty_Node;
end if;
if On_Load_Config /= null then
On_Load_Config
(Config_File => Config_Project_Node,
Project_Node_Tree => Project_Node_Tree);
end if;
if Config_Project_Node /= Empty_Node then
Prj.Proc.Process_Project_Tree_Phase_1
(In_Tree => Project_Tree,
Project => Config,
Packages_To_Check => Packages_To_Check,
Success => Success,
From_Project_Node => Config_Project_Node,
From_Project_Node_Tree => Project_Node_Tree,
Env => Env,
Reset_Tree => False,
On_New_Tree_Loaded => null);
end if;
if Config_Project_Node = Empty_Node or else Config = No_Project then
Raise_Invalid_Config
("processing of configuration project """
& Config_File_Path.all & """ failed");
end if;
-- Check that the target of the configuration file is the one the user
-- specified on the command line. We do not need to check that when in
-- auto-conf mode, since the appropriate target was passed to gprconfig.
if not Automatically_Generated
and then not
Check_Target
(Config, Autoconf_Specified, Project_Tree, Selected_Target.all)
then
Automatically_Generated := True;
goto Process_Config_File;
end if;
end Get_Or_Create_Configuration_File;
------------------------
-- Locate_Config_File --
------------------------
function Locate_Config_File (Name : String) return String_Access is
Prefix_Path : constant String := Executable_Prefix_Path;
begin
if Prefix_Path'Length /= 0 then
return Locate_Regular_File
(Name,
"." & Path_Separator &
Prefix_Path & "share" & Directory_Separator & "gpr");
else
return Locate_Regular_File (Name, ".");
end if;
end Locate_Config_File;
------------------------------------
-- Parse_Project_And_Apply_Config --
------------------------------------
procedure Parse_Project_And_Apply_Config
(Main_Project : out Prj.Project_Id;
User_Project_Node : out Prj.Tree.Project_Node_Id;
Config_File_Name : String := "";
Autoconf_Specified : Boolean;
Project_File_Name : String;
Project_Tree : Prj.Project_Tree_Ref;
Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment;
Packages_To_Check : String_List_Access;
Allow_Automatic_Generation : Boolean := True;
Automatically_Generated : out Boolean;
Config_File_Path : out String_Access;
Target_Name : String := "";
Normalized_Hostname : String;
On_Load_Config : Config_File_Hook := null;
Implicit_Project : Boolean := False;
On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null)
is
Success : Boolean := False;
Target_Try_Again : Boolean := True;
Config_Try_Again : Boolean;
Finalization : Prj.Part.Errout_Mode := Prj.Part.Always_Finalize;
S : State := No_State;
Conf_File_Name : String_Access := new String'(Config_File_Name);
procedure Add_Directory (Dir : String);
-- Add a directory at the end of the Project Path
Auto_Generated : Boolean;
-------------------
-- Add_Directory --
-------------------
procedure Add_Directory (Dir : String) is
begin
if Opt.Verbose_Mode then
Write_Line (" Adding directory """ & Dir & """");
end if;
Prj.Env.Add_Directories (Env.Project_Path, Dir);
end Add_Directory;
begin
pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
-- Start with ignoring missing withed projects
Set_Ignore_Missing_With (Env.Flags, True);
-- Note: If in fact the config file is automatically generated, then
-- Automatically_Generated will be set to True after invocation of
-- Process_Project_And_Apply_Config.
Automatically_Generated := False;
-- Record Target_Value and Target_Origin
if Target_Name = "" then
Opt.Target_Value := new String'(Normalized_Hostname);
Opt.Target_Origin := Default;
else
Opt.Target_Value := new String'(Target_Name);
Opt.Target_Origin := Specified;
end if;
<<Parse_Again>>
-- Parse the user project tree
Project_Node_Tree.Incomplete_With := False;
Env.Flags.Incomplete_Withs := False;
Prj.Initialize (Project_Tree);
Main_Project := No_Project;
Prj.Part.Parse
(In_Tree => Project_Node_Tree,
Project => User_Project_Node,
Project_File_Name => Project_File_Name,
Errout_Handling => Finalization,
Packages_To_Check => Packages_To_Check,
Current_Directory => Current_Directory,
Is_Config_File => False,
Env => Env,
Implicit_Project => Implicit_Project);
Finalization := Prj.Part.Finalize_If_Error;
if User_Project_Node = Empty_Node then
return;
end if;
-- If --target was not specified on the command line, then do Phase 1 to
-- check if attribute Target is declared in the main project.
if Opt.Target_Origin /= Specified then
Main_Project := No_Project;
Process_Project_Tree_Phase_1
(In_Tree => Project_Tree,
Project => Main_Project,
Packages_To_Check => Packages_To_Check,
Success => Success,
From_Project_Node => User_Project_Node,
From_Project_Node_Tree => Project_Node_Tree,
Env => Env,
Reset_Tree => True,
On_New_Tree_Loaded => On_New_Tree_Loaded);
if not Success then
Main_Project := No_Project;
return;
end if;
declare
Variable : constant Variable_Value :=
Value_Of
(Name_Target,
Main_Project.Decl.Attributes,
Project_Tree.Shared);
begin
if Variable /= Nil_Variable_Value
and then not Variable.Default
and then
Get_Name_String (Variable.Value) /= Opt.Target_Value.all
then
if Target_Try_Again then
Opt.Target_Value :=
new String'(Get_Name_String (Variable.Value));
Target_Try_Again := False;
goto Parse_Again;
else
Fail_Program
(Project_Tree,
"inconsistent value of attribute Target");
end if;
end if;
end;
end if;
-- If there are missing withed projects, the projects will be parsed
-- again after the project path is extended with directories rooted
-- at the compiler roots.
Config_Try_Again := Project_Node_Tree.Incomplete_With;
Process_Project_And_Apply_Config
(Main_Project => Main_Project,
User_Project_Node => User_Project_Node,
Config_File_Name => Conf_File_Name.all,
Autoconf_Specified => Autoconf_Specified,
Project_Tree => Project_Tree,
Project_Node_Tree => Project_Node_Tree,
Env => Env,
Packages_To_Check => Packages_To_Check,
Allow_Automatic_Generation => Allow_Automatic_Generation,
Automatically_Generated => Auto_Generated,
Config_File_Path => Config_File_Path,
Target_Name => Target_Name,
Normalized_Hostname => Normalized_Hostname,
On_Load_Config => On_Load_Config,
On_New_Tree_Loaded => On_New_Tree_Loaded,
Do_Phase_1 => Opt.Target_Origin = Specified);
if Auto_Generated then
Automatically_Generated := True;
end if;
-- Exit if there was an error. Otherwise, if Config_Try_Again is True,
-- update the project path and try again.
if Main_Project /= No_Project and then Config_Try_Again then
Set_Ignore_Missing_With (Env.Flags, False);
if Config_File_Path /= null then
Conf_File_Name := new String'(Config_File_Path.all);
end if;
-- For the second time the project files are parsed, the warning for
-- --RTS= being only taken into account in auto-configuration are
-- suppressed, as we are no longer in auto-configuration.
Warn_For_RTS := False;
-- Add the default directories corresponding to the compilers
Update_Project_Path
(By => Main_Project,
Tree => Project_Tree,
With_State => S,
Include_Aggregated => True,
Imported_First => False);
declare
Compiler_Root : Compiler_Root_Ptr;
Prefix : String_Access;
Runtime_Root : Runtime_Root_Ptr;
Path_Value : constant String_Access := Getenv ("PATH");
begin
if Opt.Verbose_Mode then
Write_Line ("Setting the default project search directories");
if Prj.Current_Verbosity = High then
if Path_Value = null or else Path_Value'Length = 0 then
Write_Line ("No environment variable PATH");
else
Write_Line ("PATH =");
Write_Line (" " & Path_Value.all);
end if;
end if;
end if;
-- Reorder the compiler roots in the PATH order
if First_Compiler_Root /= null
and then First_Compiler_Root.Next /= null
then
declare
Pred : Compiler_Root_Ptr;
First_New_Comp : Compiler_Root_Ptr := null;
New_Comp : Compiler_Root_Ptr := null;
First : Positive := Path_Value'First;
Last : Positive;
Path_Last : Positive;
begin
while First <= Path_Value'Last loop
Last := First;
if Path_Value (First) /= Path_Separator then
while Last < Path_Value'Last
and then Path_Value (Last + 1) /= Path_Separator
loop
Last := Last + 1;
end loop;
Path_Last := Last;
while Path_Last > First
and then
Path_Value (Path_Last) = Directory_Separator
loop
Path_Last := Path_Last - 1;
end loop;
if Path_Last > First + 4
and then
Path_Value (Path_Last - 2 .. Path_Last) = "bin"
and then
Path_Value (Path_Last - 3) = Directory_Separator
then
Path_Last := Path_Last - 4;
Pred := null;
Compiler_Root := First_Compiler_Root;
while Compiler_Root /= null
and then Compiler_Root.Root.all /=
Path_Value (First .. Path_Last)
loop
Pred := Compiler_Root;
Compiler_Root := Compiler_Root.Next;
end loop;
if Compiler_Root /= null then
if Pred = null then
First_Compiler_Root :=
First_Compiler_Root.Next;
else
Pred.Next := Compiler_Root.Next;
end if;
if First_New_Comp = null then
First_New_Comp := Compiler_Root;
else
New_Comp.Next := Compiler_Root;
end if;
New_Comp := Compiler_Root;
New_Comp.Next := null;
end if;
end if;
end if;
First := Last + 1;
end loop;
if First_New_Comp /= null then
New_Comp.Next := First_Compiler_Root;
First_Compiler_Root := First_New_Comp;
end if;
end;
end if;
-- Now that the compiler roots are in a correct order, add the
-- directories corresponding to these compiler roots in the
-- project path.
Compiler_Root := First_Compiler_Root;
while Compiler_Root /= null loop
Prefix := Compiler_Root.Root;
Runtime_Root := Compiler_Root.Runtimes;
while Runtime_Root /= null loop
Add_Directory
(Runtime_Root.Root.all &
Directory_Separator &
"lib" &
Directory_Separator &
"gnat");
Add_Directory
(Runtime_Root.Root.all &
Directory_Separator &
"share" &
Directory_Separator &
"gpr");
Runtime_Root := Runtime_Root.Next;
end loop;
Add_Directory
(Prefix.all &
Directory_Separator &
Opt.Target_Value.all &
Directory_Separator &
"lib" &
Directory_Separator &
"gnat");
Add_Directory
(Prefix.all &
Directory_Separator &
Opt.Target_Value.all &
Directory_Separator &
"share" &
Directory_Separator &
"gpr");
Add_Directory
(Prefix.all &
Directory_Separator &
"share" &
Directory_Separator &
"gpr");
Add_Directory
(Prefix.all &
Directory_Separator &
"lib" &
Directory_Separator &
"gnat");
Compiler_Root := Compiler_Root.Next;
end loop;
end;
-- And parse again the project files. There will be no missing
-- withed projects, as Ignore_Missing_With is set to False in
-- the environment flags, so there is no risk of endless loop here.
goto Parse_Again;
end if;
end Parse_Project_And_Apply_Config;
--------------------------------------
-- Process_Project_And_Apply_Config --
--------------------------------------
procedure Process_Project_And_Apply_Config
(Main_Project : out Prj.Project_Id;
User_Project_Node : Prj.Tree.Project_Node_Id;
Config_File_Name : String := "";
Autoconf_Specified : Boolean;
Project_Tree : Prj.Project_Tree_Ref;
Project_Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment;
Packages_To_Check : String_List_Access;
Allow_Automatic_Generation : Boolean := True;
Automatically_Generated : out Boolean;
Config_File_Path : out String_Access;
Target_Name : String := "";
Normalized_Hostname : String;
On_Load_Config : Config_File_Hook := null;
Reset_Tree : Boolean := True;
On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null;
Do_Phase_1 : Boolean := True)
is
Shared : constant Shared_Project_Tree_Data_Access :=
Project_Tree.Shared;
Main_Config_Project : Project_Id;
Success : Boolean;
Conf_Project : Project_Id := No_Project;
-- The object directory of this project is used to store the config
-- project file in auto-configuration. Set by Check_Project below.
procedure Check_Project (Project : Project_Id);
-- Look for a non aggregate project. If one is found, put its project Id
-- in Conf_Project.
-------------------
-- Check_Project --
-------------------
procedure Check_Project (Project : Project_Id) is
begin
if Project.Qualifier = Aggregate
or else
Project.Qualifier = Aggregate_Library
then
declare
List : Aggregated_Project_List := Project.Aggregated_Projects;
begin
-- Look for a non aggregate project until one is found
while Conf_Project = No_Project and then List /= null loop
Check_Project (List.Project);
List := List.Next;
end loop;
end;
else
Conf_Project := Project;
end if;
end Check_Project;
-- Start of processing for Process_Project_And_Apply_Config
begin
Automatically_Generated := False;
if Do_Phase_1 then
Main_Project := No_Project;
Process_Project_Tree_Phase_1
(In_Tree => Project_Tree,
Project => Main_Project,
Packages_To_Check => Packages_To_Check,
Success => Success,
From_Project_Node => User_Project_Node,
From_Project_Node_Tree => Project_Node_Tree,
Env => Env,
Reset_Tree => Reset_Tree,
On_New_Tree_Loaded => On_New_Tree_Loaded);
if not Success then
Main_Project := No_Project;
return;
end if;
end if;
if Project_Tree.Source_Info_File_Name /= null then
if not Is_Absolute_Path (Project_Tree.Source_Info_File_Name.all) then
declare
Obj_Dir : constant Variable_Value :=
Value_Of
(Name_Object_Dir,
Main_Project.Decl.Attributes,
Shared);
begin
if Obj_Dir = Nil_Variable_Value or else Obj_Dir.Default then
Get_Name_String (Main_Project.Directory.Display_Name);
else
if Is_Absolute_Path (Get_Name_String (Obj_Dir.Value)) then
Get_Name_String (Obj_Dir.Value);
else
Name_Len := 0;
Add_Str_To_Name_Buffer
(Get_Name_String (Main_Project.Directory.Display_Name));
Add_Str_To_Name_Buffer (Get_Name_String (Obj_Dir.Value));
end if;
end if;
Add_Char_To_Name_Buffer (Directory_Separator);
Add_Str_To_Name_Buffer (Project_Tree.Source_Info_File_Name.all);
Free (Project_Tree.Source_Info_File_Name);
Project_Tree.Source_Info_File_Name :=
new String'(Name_Buffer (1 .. Name_Len));
end;
end if;
Read_Source_Info_File (Project_Tree);
end if;
-- Get the first project that is not an aggregate project or an
-- aggregate library project. The object directory of this project will
-- be used to store the config project file in auto-configuration.
Check_Project (Main_Project);
-- Fail if there is only aggregate projects and aggregate library
-- projects in the project tree.
if Conf_Project = No_Project then
Raise_Invalid_Config ("there are no non-aggregate projects");
end if;
-- Find configuration file
Get_Or_Create_Configuration_File
(Config => Main_Config_Project,
Project => Main_Project,
Conf_Project => Conf_Project,
Project_Tree => Project_Tree,
Project_Node_Tree => Project_Node_Tree,
Env => Env,
Allow_Automatic_Generation => Allow_Automatic_Generation,
Config_File_Name => Config_File_Name,
Autoconf_Specified => Autoconf_Specified,
Target_Name => Target_Name,
Normalized_Hostname => Normalized_Hostname,
Packages_To_Check => Packages_To_Check,
Config_File_Path => Config_File_Path,
Automatically_Generated => Automatically_Generated,
On_Load_Config => On_Load_Config);
Apply_Config_File (Main_Config_Project, Project_Tree);
-- Finish processing the user's project
Prj.Proc.Process_Project_Tree_Phase_2
(In_Tree => Project_Tree,
Project => Main_Project,
Success => Success,
From_Project_Node => User_Project_Node,
From_Project_Node_Tree => Project_Node_Tree,
Env => Env);
if Success then
if Project_Tree.Source_Info_File_Name /= null
and then not Project_Tree.Source_Info_File_Exists
then
Write_Source_Info_File (Project_Tree);
end if;
else
Main_Project := No_Project;
end if;
end Process_Project_And_Apply_Config;
--------------------------
-- Raise_Invalid_Config --
--------------------------
procedure Raise_Invalid_Config (Msg : String) is
begin
Raise_Exception (Invalid_Config'Identity, Msg);
end Raise_Invalid_Config;
----------------------
-- Runtime_Name_For --
----------------------
function Runtime_Name_For (Language : Name_Id) return String is
begin
if RTS_Languages.Get (Language) /= No_Name then
return Get_Name_String (RTS_Languages.Get (Language));
else
return "";
end if;
end Runtime_Name_For;
--------------------------
-- Runtime_Name_Set_For --
--------------------------
function Runtime_Name_Set_For (Language : Name_Id) return Boolean is
begin
return RTS_Languages.Get (Language) /= No_Name;
end Runtime_Name_Set_For;
---------------------
-- Set_Runtime_For --
---------------------
procedure Set_Runtime_For (Language : Name_Id; RTS_Name : String) is
begin
Name_Len := RTS_Name'Length;
Name_Buffer (1 .. Name_Len) := RTS_Name;
RTS_Languages.Set (Language, Name_Find);
end Set_Runtime_For;
----------------------------
-- Look_For_Project_Paths --
----------------------------
procedure Look_For_Project_Paths
(Project : Project_Id;
Tree : Project_Tree_Ref;
With_State : in out State)
is
Lang_Id : Language_Ptr;
Compiler_Root : Compiler_Root_Ptr;
Runtime_Root : Runtime_Root_Ptr;
Comp_Driver : String_Access;
Comp_Dir : String_Access;
Prefix : String_Access;
pragma Unreferenced (Tree);
begin
With_State := No_State;
Lang_Id := Project.Languages;
while Lang_Id /= No_Language_Index loop
if Lang_Id.Config.Compiler_Driver /= No_File then
Comp_Driver :=
new String'
(Get_Name_String (Lang_Id.Config.Compiler_Driver));
-- Get the absolute path of the compiler driver
if not Is_Absolute_Path (Comp_Driver.all) then
Comp_Driver := Locate_Exec_On_Path (Comp_Driver.all);
end if;
if Comp_Driver /= null and then Comp_Driver'Length > 0 then
Comp_Dir :=
new String'
(Containing_Directory (Comp_Driver.all));
-- Consider only the compiler drivers that are in "bin"
-- subdirectories.
if Simple_Name (Comp_Dir.all) = "bin" then
Prefix :=
new String'(Containing_Directory (Comp_Dir.all));
-- Check if the compiler root is already in the list. If it
-- is not, add it to the list.
Compiler_Root := First_Compiler_Root;
while Compiler_Root /= null loop
exit when Prefix.all = Compiler_Root.Root.all;
Compiler_Root := Compiler_Root.Next;
end loop;
if Compiler_Root = null then
First_Compiler_Root :=
new Compiler_Root_Data'
(Root => Prefix,
Runtimes => null,
Next => First_Compiler_Root);
Compiler_Root := First_Compiler_Root;
end if;
-- If there is a runtime for this compiler, check if it is
-- recorded with the compiler root. If it is not, record
-- the runtime.
declare
Runtime : constant String :=
Runtime_Name_For (Lang_Id.Name);
Root : String_Access;
begin
if Runtime'Length > 0 then
if Is_Absolute_Path (Runtime) then
Root := new String'(Runtime);
else
Root :=
new String'
(Prefix.all &
Directory_Separator &
Opt.Target_Value.all &
Directory_Separator &
Runtime);
end if;
Runtime_Root := Compiler_Root.Runtimes;
while Runtime_Root /= null loop
exit when Root.all = Runtime_Root.Root.all;
Runtime_Root := Runtime_Root.Next;
end loop;
if Runtime_Root = null then
Compiler_Root.Runtimes :=
new Runtime_Root_Data'
(Root => Root,
Next => Compiler_Root.Runtimes);
end if;
end if;
end;
end if;
end if;
end if;
Lang_Id := Lang_Id.Next;
end loop;
end Look_For_Project_Paths;
end Prj.Conf;
|
RREE/ada-util | Ada | 9,433 | adb | -----------------------------------------------------------------------
-- util-events-timers -- Timer list management
-- 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.Unchecked_Deallocation;
with Util.Log.Loggers;
package body Util.Events.Timers is
use type Ada.Real_Time.Time;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Events.Timers");
procedure Free is
new Ada.Unchecked_Deallocation (Object => Timer_Node,
Name => Timer_Node_Access);
-- -----------------------
-- Repeat the timer.
-- -----------------------
procedure Repeat (Event : in out Timer_Ref;
In_Time : in Ada.Real_Time.Time_Span) is
Timer : constant Timer_Node_Access := Event.Value;
begin
if Timer /= null and then Timer.List /= null then
Timer.List.Add (Timer, Timer.Deadline + In_Time);
end if;
end Repeat;
-- -----------------------
-- Cancel the timer.
-- -----------------------
procedure Cancel (Event : in out Timer_Ref) is
begin
if Event.Value /= null and then Event.Value.List /= null then
Event.Value.List.all.Cancel (Event.Value);
Event.Value.List := null;
end if;
end Cancel;
-- -----------------------
-- Check if the timer is ready to be executed.
-- -----------------------
function Is_Scheduled (Event : in Timer_Ref) return Boolean is
begin
return Event.Value /= null and then Event.Value.List /= null;
end Is_Scheduled;
-- -----------------------
-- Returns the deadline time for the timer execution.
-- Returns Time'Last if the timer is not scheduled.
-- -----------------------
function Time_Of_Event (Event : in Timer_Ref) return Ada.Real_Time.Time is
begin
return (if Event.Value /= null then Event.Value.Deadline else Ada.Real_Time.Time_Last);
end Time_Of_Event;
-- -----------------------
-- Set a timer to be called at the given time.
-- -----------------------
procedure Set_Timer (List : in out Timer_List;
Handler : in Timer_Access;
Event : in out Timer_Ref'Class;
At_Time : in Ada.Real_Time.Time) is
Timer : Timer_Node_Access := Event.Value;
begin
if Timer = null then
Event.Value := new Timer_Node;
Timer := Event.Value;
end if;
Timer.Handler := Handler;
-- Cancel the timer if it is part of another timer manager.
if Timer.List /= null and Timer.List /= List.Manager'Unchecked_Access then
Timer.List.Cancel (Timer);
end if;
-- Update the timer.
Timer.List := List.Manager'Unchecked_Access;
List.Manager.Add (Timer, At_Time);
end Set_Timer;
-- -----------------------
-- Set a timer to be called after the given time span.
-- -----------------------
procedure Set_Timer (List : in out Timer_List;
Handler : in Timer_Access;
Event : in out Timer_Ref'Class;
In_Time : in Ada.Real_Time.Time_Span) is
begin
List.Set_Timer (Handler, Event, Ada.Real_Time.Clock + In_Time);
end Set_Timer;
-- -----------------------
-- Process the timer handlers that have passed the deadline and return the next
-- deadline. The <tt>Max_Count</tt> parameter allows to limit the number of timer handlers
-- that are called by operation. The default is not limited.
-- -----------------------
procedure Process (List : in out Timer_List;
Timeout : out Ada.Real_Time.Time;
Max_Count : in Natural := Natural'Last) is
Timer : Timer_Ref;
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
for Count in 1 .. Max_Count loop
List.Manager.Find_Next (Now, Timeout, Timer);
exit when Timer.Value = null;
begin
Timer.Value.Handler.Time_Handler (Timer);
exception
when E : others =>
Timer_List'Class (List).Error (Timer.Value.Handler, E);
end;
Timer.Finalize;
end loop;
end Process;
-- -----------------------
-- Procedure called when a timer handler raises an exception.
-- The default operation reports an error in the logs. This procedure can be
-- overriden to implement specific error handling.
-- -----------------------
procedure Error (List : in out Timer_List;
Handler : in Timer_Access;
E : in Ada.Exceptions.Exception_Occurrence) is
pragma Unreferenced (List, Handler);
begin
Log.Error ("Timer handler raised an exception", E, True);
end Error;
overriding
procedure Adjust (Object : in out Timer_Ref) is
begin
if Object.Value /= null then
Util.Concurrent.Counters.Increment (Object.Value.Counter);
end if;
end Adjust;
overriding
procedure Finalize (Object : in out Timer_Ref) is
Is_Zero : Boolean;
begin
if Object.Value /= null then
Util.Concurrent.Counters.Decrement (Object.Value.Counter, Is_Zero);
if Is_Zero then
Free (Object.Value);
else
Object.Value := null;
end if;
end if;
end Finalize;
protected body Timer_Manager is
procedure Remove (Timer : in Timer_Node_Access) is
begin
if List = Timer then
List := Timer.Next;
Timer.Prev := null;
if List /= null then
List.Prev := null;
end if;
elsif Timer.Prev /= null then
Timer.Prev.Next := Timer.Next;
Timer.Next.Prev := Timer.Prev;
else
return;
end if;
Timer.Next := null;
Timer.Prev := null;
Timer.List := null;
end Remove;
-- -----------------------
-- Add a timer.
-- -----------------------
procedure Add (Timer : in Timer_Node_Access;
Deadline : in Ada.Real_Time.Time) is
Current : Timer_Node_Access := List;
Prev : Timer_Node_Access;
begin
Util.Concurrent.Counters.Increment (Timer.Counter);
if Timer.List /= null then
Remove (Timer);
end if;
Timer.Deadline := Deadline;
while Current /= null loop
if Current.Deadline > Deadline then
if Prev = null then
List := Timer;
else
Prev.Next := Timer;
end if;
Timer.Next := Current;
Current.Prev := Timer;
return;
end if;
Prev := Current;
Current := Current.Next;
end loop;
if Prev = null then
List := Timer;
Timer.Prev := null;
else
Prev.Next := Timer;
Timer.Prev := Prev;
end if;
Timer.Next := null;
end Add;
-- -----------------------
-- Cancel a timer.
-- -----------------------
procedure Cancel (Timer : in out Timer_Node_Access) is
Is_Zero : Boolean;
begin
if Timer.List = null then
return;
end if;
Remove (Timer);
Util.Concurrent.Counters.Decrement (Timer.Counter, Is_Zero);
if Is_Zero then
Free (Timer);
end if;
end Cancel;
-- -----------------------
-- Find the next timer to be executed before the given time or return the next deadline.
-- -----------------------
procedure Find_Next (Before : in Ada.Real_Time.Time;
Deadline : out Ada.Real_Time.Time;
Timer : in out Timer_Ref) is
begin
if List = null then
Deadline := Ada.Real_Time.Time_Last;
elsif List.Deadline < Before then
Timer.Value := List;
List := List.Next;
if List /= null then
List.Prev := null;
Deadline := List.Deadline;
else
Deadline := Ada.Real_Time.Time_Last;
end if;
else
Deadline := List.Deadline;
end if;
end Find_Next;
end Timer_Manager;
overriding
procedure Finalize (Object : in out Timer_List) is
Timer : Timer_Ref;
Timeout : Ada.Real_Time.Time;
begin
loop
Object.Manager.Find_Next (Ada.Real_Time.Time_Last, Timeout, Timer);
exit when Timer.Value = null;
Timer.Finalize;
end loop;
end Finalize;
end Util.Events.Timers;
|
zhmu/ananas | Ada | 3,971 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . B O U N D E D _ S T R I N G S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2016-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
package body System.Bounded_Strings is
------------
-- Append --
------------
procedure Append (X : in out Bounded_String; C : Character) is
begin
-- If we have too many characters to fit, simply drop them
if X.Length < X.Max_Length then
X.Length := X.Length + 1;
X.Chars (X.Length) := C;
end if;
end Append;
procedure Append (X : in out Bounded_String; S : String) is
begin
for C of S loop
Append (X, C);
end loop;
end Append;
--------------------
-- Append_Address --
--------------------
procedure Append_Address (X : in out Bounded_String; A : Address)
is
S : String (1 .. 18);
P : Natural;
use System.Storage_Elements;
N : Integer_Address;
H : constant array (Integer range 0 .. 15) of Character :=
"0123456789abcdef";
begin
P := S'Last;
N := To_Integer (A);
loop
S (P) := H (Integer (N mod 16));
P := P - 1;
N := N / 16;
exit when N = 0;
end loop;
S (P - 1) := '0';
S (P) := 'x';
Append (X, S (P - 1 .. S'Last));
end Append_Address;
-------------
-- Is_Full --
-------------
function Is_Full (X : Bounded_String) return Boolean is
begin
return X.Length >= X.Max_Length;
end Is_Full;
---------------
-- To_String --
---------------
function To_String (X : Bounded_String) return String is
begin
return X.Chars (1 .. X.Length);
end To_String;
end System.Bounded_Strings;
|
AdaCore/Ada_Drivers_Library | Ada | 3,232 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017-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. --
-- --
------------------------------------------------------------------------------
package NRF52_DK.Buttons is
type Button_State is (Pressed, Released);
type Button_Id is (Button_1, Button_2, Button_3, Button_4);
function State (Button : Button_Id) return Button_State;
-- Indicate the current state of the requested button
type Button_Callback is access procedure (Button : Button_Id;
State : Button_State);
function Subscribe (Callback : not null Button_Callback) return Boolean;
-- Add Callback to the list of subscribers. Return False if Callback cannot
-- be added.
--
-- Callback will be executed each time a button state changes.
function Unsubscribe (Callback : not null Button_Callback) return Boolean;
-- Remove Callback from the list of subscribers. Return False if Callback
-- is not in the list of sucbscribers.
end NRF52_DK.Buttons;
|
reznikmm/matreshka | Ada | 3,729 | 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.Db_Use_System_User_Attributes is
pragma Preelaborate;
type ODF_Db_Use_System_User_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Db_Use_System_User_Attribute_Access is
access all ODF_Db_Use_System_User_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Db_Use_System_User_Attributes;
|
francesco-bongiovanni/ewok-kernel | Ada | 2,808 | 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 soc.rcc;
package body soc.gpio
with spark_mode => off
is
function get_port_access
(port : t_gpio_port_index) return t_GPIO_port_access
is
begin
case port is
when GPIO_PA => return soc.gpio.GPIOA'access;
when GPIO_PB => return soc.gpio.GPIOB'access;
when GPIO_PC => return soc.gpio.GPIOC'access;
when GPIO_PD => return soc.gpio.GPIOD'access;
when GPIO_PE => return soc.gpio.GPIOE'access;
when GPIO_PF => return soc.gpio.GPIOF'access;
when GPIO_PG => return soc.gpio.GPIOG'access;
when GPIO_PH => return soc.gpio.GPIOH'access;
when GPIO_PI => return soc.gpio.GPIOI'access;
end case;
end get_port_access;
procedure config
(port : in t_gpio_port_index;
pin : in t_gpio_pin_index;
mode : in t_pin_mode;
otype : in t_pin_output_type;
ospeed : in t_pin_output_speed;
pupd : in t_pin_pupd;
af : in t_pin_alt_func)
is
gpio : soc.gpio.t_GPIO_port_access;
begin
-- Enable RCC
case port is
when GPIO_PA => soc.rcc.RCC.AHB1.GPIOAEN := true;
when GPIO_PB => soc.rcc.RCC.AHB1.GPIOBEN := true;
when GPIO_PC => soc.rcc.RCC.AHB1.GPIOCEN := true;
when GPIO_PD => soc.rcc.RCC.AHB1.GPIODEN := true;
when GPIO_PE => soc.rcc.RCC.AHB1.GPIOEEN := true;
when GPIO_PF => soc.rcc.RCC.AHB1.GPIOFEN := true;
when GPIO_PG => soc.rcc.RCC.AHB1.GPIOGEN := true;
when GPIO_PH => soc.rcc.RCC.AHB1.GPIOHEN := true;
when GPIO_PI => soc.rcc.RCC.AHB1.GPIOIEN := true;
end case;
gpio := soc.gpio.get_port_access (port);
gpio.all.MODER.pin(pin) := mode;
gpio.all.OTYPER.pin(pin) := otype;
gpio.all.OSPEEDR.pin(pin) := ospeed;
gpio.all.PUPDR.pin(pin) := pupd;
if pin < 8 then
gpio.all.AFRL.pin(pin) := af;
else
gpio.all.AFRH.pin(pin) := af;
end if;
end config;
end soc.gpio;
|
AdaCore/libadalang | Ada | 61 | ads | package Pkg.Child is
procedure P2 is null;
end Pkg.Child;
|
msrLi/portingSources | Ada | 830 | adb | -- Copyright 2011-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Dn is
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Dn;
|
landgraf/nanomsg-ada | Ada | 1,452 | ads | -- The MIT License (MIT)
-- Copyright (c) 2015 Pavel Zhukov <[email protected]>
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
package Nanomsg.Survey is
Nn_Proto_Survey : constant := 6;
Nn_Surveyor : constant Protocol_T := Nn_Proto_Survey * 16 + 2;
Nn_respondent : constant Protocol_T := Nn_Proto_Survey * 16 + 3;
Nn_Surveyor_Deadline : constant := 1;
end Nanomsg.Survey;
|
zhmu/ananas | Ada | 8,124 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ R E S --
-- --
-- S p e c --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Resolution processing for all subexpression nodes. Note that the separate
-- package Sem_Aggr contains the actual resolution routines for aggregates,
-- which are separated off since aggregate processing is complex.
with Types; use Types;
package Sem_Res is
-- As described in Sem_Type, the type resolution proceeds in two phases.
-- The first phase is a bottom up pass that is achieved during the
-- recursive traversal performed by the Analyze procedures. This phase
-- determines unambiguous types, and collects sets of possible types
-- where the interpretation is potentially ambiguous.
-- On completing this bottom up pass, which corresponds to a call to
-- Analyze on a complete context, the Resolve routine is called which
-- performs a top down resolution with recursive calls to itself to
-- resolve operands.
-- Since in practice a lot of semantic analysis has to be postponed until
-- types are known (e.g. static folding, setting of suppress flags), the
-- Resolve routines also complete the semantic analysis, and call the
-- expander for possible expansion of the completely type resolved node.
procedure Ambiguous_Character (C : Node_Id);
-- Give list of candidate interpretations when a character literal cannot
-- be resolved, for example in a (useless) comparison such as 'A' = 'B'.
-- In Ada 95 the literals in question can be of type Character or Wide_
-- Character. In Ada 2005 Wide_Wide_Character is also a candidate. The
-- node may also be overloaded with user-defined character types.
procedure Analyze_And_Resolve (N : Node_Id);
procedure Analyze_And_Resolve (N : Node_Id; Typ : Entity_Id);
procedure Analyze_And_Resolve
(N : Node_Id;
Typ : Entity_Id;
Suppress : Check_Id);
procedure Analyze_And_Resolve
(N : Node_Id;
Suppress : Check_Id);
-- These routines combine the effect of Analyze and Resolve. If a Suppress
-- argument is present, then the analysis is done with the specified check
-- suppressed (can be All_Checks to suppress all checks). These checks are
-- suppressed for both the analysis and resolution. If the type argument
-- is not present, then the Etype of the expression after the Analyze
-- call is used for the Resolve.
procedure Check_Parameterless_Call (N : Node_Id);
-- Several forms of names can denote calls to entities without parameters.
-- The context determines whether the name denotes the entity or a call to
-- it. When it is a call, the node must be rebuilt accordingly and
-- reanalyzed to obtain possible interpretations.
--
-- The name may be that of an overloadable construct, or it can be an
-- explicit dereference of a prefix that denotes an access to subprogram.
-- In that case, we want to convert the name into a call only if the
-- context requires the return type of the subprogram. Finally, a
-- parameterless protected subprogram appears as a selected component.
--
-- The parameter T is the Typ for the corresponding resolve call.
procedure Preanalyze_And_Resolve (N : Node_Id; T : Entity_Id);
-- Performs a preanalysis of expression node N. During preanalysis, N is
-- analyzed and then resolved against type T, but no expansion is carried
-- out for N or its children. For more info on preanalysis read the spec
-- of Sem.
procedure Preanalyze_And_Resolve (N : Node_Id);
-- Same, but use type of node because context does not impose a single type
procedure Preanalyze_With_Freezing_And_Resolve (N : Node_Id; T : Entity_Id);
-- Same, but perform freezing of static expressions of N or its children.
procedure Resolve (N : Node_Id; Typ : Entity_Id);
procedure Resolve (N : Node_Id; Typ : Entity_Id; Suppress : Check_Id);
-- Top-level type-checking procedure, called in a complete context. The
-- construct N, which is a subexpression, has already been analyzed, and
-- is required to be of type Typ given the analysis of the context (which
-- uses the information gathered on the bottom-up phase in Analyze). The
-- resolve routines do various other processing, e.g. static evaluation.
-- If a Suppress argument is present, then the resolution is done with the
-- specified check suppressed (can be All_Checks to suppress all checks).
procedure Resolve (N : Node_Id);
-- A version of Resolve where the type to be used for resolution is taken
-- from the Etype (N). This is commonly used in cases where the context
-- does not add anything and the first pass of analysis found the correct
-- expected type.
procedure Resolve_Discrete_Subtype_Indication
(N : Node_Id;
Typ : Entity_Id);
-- Resolve subtype indications in choices (case statements and aggregates)
-- and in index constraints. Note that the resulting Etype of the subtype_
-- indication node is set to the Etype of the contained range (i.e. an
-- Itype is not constructed for the actual subtype).
procedure Resolve_Entry (Entry_Name : Node_Id);
-- Find name of entry being called, and resolve prefix of name with its
-- own type. For now we assume that the prefix cannot be overloaded and
-- the name of the entry plays no role in the resolution.
function Valid_Conversion
(N : Node_Id;
Target : Entity_Id;
Operand : Node_Id;
Report_Errs : Boolean := True) return Boolean;
-- Verify legality rules given in 4.6 (8-23). Target is the target type
-- of the conversion, which may be an implicit conversion of an actual
-- parameter to an anonymous access type (in which case N denotes the
-- actual parameter and N = Operand). Returns a Boolean result indicating
-- whether the conversion is legal. Reports errors in the case of illegal
-- conversions, unless Report_Errs is False.
private
procedure Resolve_Implicit_Type (N : Node_Id) renames Resolve;
pragma Inline (Resolve_Implicit_Type);
-- We use this renaming to make the application of Inline very explicit to
-- this version, since other versions of Resolve are not inlined.
end Sem_Res;
|
reznikmm/matreshka | Ada | 4,615 | 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.Page_Number_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Page_Number_Attribute_Node is
begin
return Self : Draw_Page_Number_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_Page_Number_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Page_Number_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Page_Number_Attribute,
Draw_Page_Number_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Page_Number_Attributes;
|
msrLi/portingSources | Ada | 864 | adb | -- Copyright 2010-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
My_Shape : Circle := (X => 1, Y => 2, R => 3);
X : Integer;
begin
X := Position_X (My_Shape);
end Foo;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.