repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
zhmu/ananas | Ada | 12,516 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . S T A N D A R D _ L I B R A R Y --
-- --
-- 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package is included in all programs. It contains declarations that
-- are required to be part of every Ada program. A special mechanism is
-- required to ensure that these are loaded, since it may be the case in
-- some programs that the only references to these required packages are
-- from C code or from code generated directly by Gigi, and in both cases
-- the binder is not aware of such references.
-- System.Standard_Library also includes data that must be present in every
-- program, in particular data for all the standard exceptions, and also some
-- subprograms that must be present in every program.
-- The binder unconditionally includes s-stalib.ali, which ensures that this
-- package and the packages it references are included in all Ada programs,
-- together with the included data.
with Ada.Unchecked_Conversion;
package System.Standard_Library is
-- Historical note: pragma Preelaborate was surrounded by a pair of pragma
-- Warnings (Off/On) to circumvent a bootstrap issue.
pragma Preelaborate;
subtype Big_String is String (1 .. Positive'Last);
pragma Suppress_Initialization (Big_String);
-- Type used to obtain string access to given address. Initialization is
-- suppressed, since we never want to have variables of this type, and
-- we never want to attempt initialiazation of virtual variables of this
-- type (e.g. when pragma Normalize_Scalars is used).
type Big_String_Ptr is access all Big_String;
for Big_String_Ptr'Storage_Size use 0;
-- We use this access type to pass a pointer to an area of storage to be
-- accessed as a string. Of course when this pointer is used, it is the
-- responsibility of the accessor to ensure proper bounds. The storage
-- size clause ensures we do not allocate variables of this type.
function To_Ptr is
new Ada.Unchecked_Conversion (System.Address, Big_String_Ptr);
-------------------------------------
-- Exception Declarations and Data --
-------------------------------------
type Raise_Action is access procedure;
pragma Favor_Top_Level (Raise_Action);
-- A pointer to a procedure used in the Raise_Hook field
type Exception_Data;
type Exception_Data_Ptr is access all Exception_Data;
-- An equivalent of Exception_Id that is public
-- The following record defines the underlying representation of exceptions
-- WARNING: Any change to the record needs to be reflected in the following
-- locations in the compiler and runtime code:
-- 1. The construction of the exception type in Cstand
-- 2. Expand_N_Exception_Declaration in Exp_Ch11
-- 3. Expand_Pragma_Import_Or_Interface in Exp_Prag
-- 4. The processing in gigi that tests Not_Handled_By_Others
-- 5. The Internal_Exception routine in s-exctab.adb
-- 6. The declaration of the corresponding C type in raise.h
type Exception_Data is record
Not_Handled_By_Others : aliased Boolean;
-- Normally set False, indicating that the exception is handled in the
-- usual way by others (i.e. an others handler handles the exception).
-- Set True to indicate that this exception is not caught by others
-- handlers, but must be explicitly named in a handler. This latter
-- setting is currently used by the Abort_Signal.
Lang : aliased Character;
-- A character indicating the language raising the exception.
-- Set to "A" for exceptions defined by an Ada program.
-- Set to "C" for imported C++ exceptions.
Name_Length : aliased Natural;
-- Length of fully expanded name of exception
Full_Name : aliased System.Address;
-- Fully expanded name of exception, null terminated
-- You can use To_Ptr to convert this to a string.
HTable_Ptr : aliased Exception_Data_Ptr;
-- Hash table pointer used to link entries together in the hash table
-- built (by Register_Exception in s-exctab.adb) for converting between
-- identities and names.
Foreign_Data : aliased System.Address;
-- Data for imported exceptions. Not used in the Ada case. This
-- represents the address of the RTTI for the C++ case.
Raise_Hook : aliased Raise_Action;
-- This field can be used to place a "hook" on an exception. If the
-- value is non-null, then it points to a procedure which is called
-- whenever the exception is raised. This call occurs immediately,
-- before any other actions taken by the raise (and in particular
-- before any unwinding of the stack occurs).
end record;
-- Definitions for standard predefined exceptions defined in Standard,
-- Why are the NULs necessary here, seems like they should not be
-- required, since Gigi is supposed to add a Nul to each name ???
Constraint_Error_Name : constant String := "CONSTRAINT_ERROR" & ASCII.NUL;
Program_Error_Name : constant String := "PROGRAM_ERROR" & ASCII.NUL;
Storage_Error_Name : constant String := "STORAGE_ERROR" & ASCII.NUL;
Tasking_Error_Name : constant String := "TASKING_ERROR" & ASCII.NUL;
Abort_Signal_Name : constant String := "_ABORT_SIGNAL" & ASCII.NUL;
Numeric_Error_Name : constant String := "NUMERIC_ERROR" & ASCII.NUL;
-- This is used only in the Ada 83 case, but it is not worth having a
-- separate version of s-stalib.ads for use in Ada 83 mode.
Constraint_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Constraint_Error_Name'Length,
Full_Name => Constraint_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Numeric_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Numeric_Error_Name'Length,
Full_Name => Numeric_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Program_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Program_Error_Name'Length,
Full_Name => Program_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Storage_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Storage_Error_Name'Length,
Full_Name => Storage_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Tasking_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Tasking_Error_Name'Length,
Full_Name => Tasking_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Abort_Signal_Def : aliased Exception_Data :=
(Not_Handled_By_Others => True,
Lang => 'A',
Name_Length => Abort_Signal_Name'Length,
Full_Name => Abort_Signal_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
pragma Export (C, Constraint_Error_Def, "constraint_error");
pragma Export (C, Numeric_Error_Def, "numeric_error");
pragma Export (C, Program_Error_Def, "program_error");
pragma Export (C, Storage_Error_Def, "storage_error");
pragma Export (C, Tasking_Error_Def, "tasking_error");
pragma Export (C, Abort_Signal_Def, "_abort_signal");
Local_Partition_ID : Natural := 0;
-- This variable contains the local Partition_ID that will be used when
-- building exception occurrences. In distributed mode, it will be
-- set by each partition to the correct value during the elaboration.
type Exception_Trace_Kind is
(RM_Convention,
-- No particular trace is requested, only unhandled exceptions
-- in the environment task (following the RM) will be printed.
-- This is the default behavior.
Every_Raise,
-- Denotes the initial raise event for any exception occurrence, either
-- explicit or due to a specific language rule, within the context of a
-- task or not.
Unhandled_Raise,
-- Denotes the raise events corresponding to exceptions for which there
-- is no user defined handler. This includes unhandled exceptions in
-- task bodies.
Unhandled_Raise_In_Main
-- Same as Unhandled_Raise, except exceptions in task bodies are not
-- included. Same as RM_Convention, except (1) the message is printed as
-- soon as the environment task completes due to an unhandled exception
-- (before awaiting the termination of dependent tasks, and before
-- library-level finalization), and (2) a symbolic traceback is given
-- if possible. This is the default behavior if the binder switch -E is
-- used.
);
-- Provide a way to denote different kinds of automatic traces related
-- to exceptions that can be requested.
Exception_Trace : Exception_Trace_Kind := RM_Convention;
pragma Atomic (Exception_Trace);
-- By default, follow the RM convention
-----------------
-- Subprograms --
-----------------
procedure Abort_Undefer_Direct;
pragma Inline (Abort_Undefer_Direct);
-- A little procedure that just calls Abort_Undefer.all, for use in
-- clean up procedures, which only permit a simple subprogram name.
procedure Adafinal;
-- Performs the Ada Runtime finalization the first time it is invoked.
-- All subsequent calls are ignored.
end System.Standard_Library;
|
AdaCore/training_material | Ada | 3,707 | adb | with Ada.Containers.Vectors;
with Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package body Logs is
subtype Color is Style range Black .. None;
type Style_Content_T is record
Foreground, Background : Color := None;
end record;
type Styles_Array_T is array (Style) of Style_Content_T;
Styles_Colors : constant Styles_Array_T
:= (
Black => (Black, None),
Red => (Red, None),
Green => (Green, None),
Yellow => (Yellow, None),
Blue => (Blue, None),
Magenta => (Magenta, None),
Cyan => (Cyan, None),
White => (White, None),
Dummy => (None, None),
None => (None, None),
Black_On_Red => (Black, Red),
White_On_Red => (White, Red)
);
type Escaped_VT100 is new String;
function VT100_Esc (Content : String) return Escaped_VT100 is
begin
return Character'Val (8#33#) & "[" & Escaped_VT100 (Content) & "m";
end VT100_Esc;
function VT100_Esc (Colors : Style_Content_T) return Escaped_VT100 is
function To_VT100 (I : Integer) return String is
S : constant String := I'Image;
begin
return S (S'First + 1 .. S'Last);
end To_VT100;
begin
return VT100_Esc (To_VT100 (30 + Color'Pos (Colors.Foreground))
& ";"
& To_VT100 (40 + Color'Pos (Colors.Background)));
end VT100_Esc;
function VT100 (Escaped : Escaped_VT100; S : String) return String is
begin
return String (Escaped) & S & String (VT100_Esc ("0"));
end VT100;
function VT100 (Colors : Style_Content_T; S : String) return String is
begin
return VT100 (VT100_Esc (Colors), S);
end VT100;
function VT100 (Sty : Style; S : String) return String is
begin
return VT100 (Styles_Colors (Sty), S);
end VT100;
Buffered : Boolean := False;
package Log_Buffer_Pkg
is new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Unbounded_String);
B : Log_Buffer_Pkg.Vector := Log_Buffer_Pkg.Empty_Vector;
B_Current_Line : Unbounded_String := Null_Unbounded_String;
procedure Buffer is
begin
Buffered := True;
end Buffer;
procedure Unbuffer is
begin
Buffered := False;
Put_Buffer;
end Unbuffer;
procedure Put_Buffer is
Old_Buffered : constant Boolean := Buffered;
begin
Buffered := False;
for Line of B loop
Put_Line (To_String (Line));
end loop;
if B_Current_Line /= "" then
Put (To_String (B_Current_Line));
end if;
Log_Buffer_Pkg.Clear (B);
Set_Unbounded_String (B_Current_Line, "");
Buffered := Old_Buffered;
end Put_Buffer;
procedure Drop_Buffer is
begin
Log_Buffer_Pkg.Clear (B);
Set_Unbounded_String (B_Current_Line, "");
end Drop_Buffer;
procedure Put (Sty : Style; S : String) is
begin
Put (VT100 (Sty, S));
end Put;
procedure Put_Line (Sty : Style; S : String) is
begin
Put_Line (VT100 (Sty, S));
end Put_Line;
procedure Put (S : String) is
begin
if Buffered then
Append (B_Current_Line, S);
else
Ada.Text_IO.Put (S);
end if;
end Put;
procedure Put_Line (S : String) is
begin
Put (S);
New_Line;
end Put_Line;
procedure New_Line is
begin
if Buffered then
Log_Buffer_Pkg.Append (B, B_Current_Line);
B_Current_Line := Null_Unbounded_String;
else
Ada.Text_IO.New_Line;
end if;
end New_Line;
end Logs;
|
google-code/ada-security | Ada | 10,968 | adb | -----------------------------------------------------------------------
-- security-policies-roles -- Role based policies
-- Copyright (C) 2010, 2011, 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 Util.Log.Loggers;
with Util.Serialize.Mappers.Record_Mapper;
with Util.Strings.Tokenizers;
with Security.Controllers;
with Security.Controllers.Roles;
package body Security.Policies.Roles is
use Util.Log;
-- The logger
Log : constant Loggers.Logger := Loggers.Create ("Security.Policies.Roles");
-- ------------------------------
-- Set the roles which are assigned to the user in the security context.
-- The role policy will use these roles to verify a permission.
-- ------------------------------
procedure Set_Role_Context (Context : in out Security.Contexts.Security_Context'Class;
Roles : in Role_Map) is
Policy : constant Security.Policies.Policy_Access := Context.Get_Policy (NAME);
Data : Role_Policy_Context_Access;
begin
if Policy = null then
Log.Error ("There is no security policy: " & NAME);
end if;
Data := new Role_Policy_Context;
Data.Roles := Roles;
Context.Set_Policy_Context (Policy, Data.all'Access);
end Set_Role_Context;
-- ------------------------------
-- Set the roles which are assigned to the user in the security context.
-- The role policy will use these roles to verify a permission.
-- ------------------------------
procedure Set_Role_Context (Context : in out Security.Contexts.Security_Context'Class;
Roles : in String) is
Policy : constant Security.Policies.Policy_Access := Context.Get_Policy (NAME);
Data : Role_Policy_Context_Access;
Map : Role_Map;
begin
if Policy = null then
Log.Error ("There is no security policy: " & NAME);
end if;
Role_Policy'Class (Policy.all).Set_Roles (Roles, Map);
Data := new Role_Policy_Context;
Data.Roles := Map;
Context.Set_Policy_Context (Policy, Data.all'Access);
end Set_Role_Context;
-- ------------------------------
-- Get the policy name.
-- ------------------------------
overriding
function Get_Name (From : in Role_Policy) return String is
pragma Unreferenced (From);
begin
return NAME;
end Get_Name;
-- ------------------------------
-- Get the role name.
-- ------------------------------
function Get_Role_Name (Manager : in Role_Policy;
Role : in Role_Type) return String is
use type Ada.Strings.Unbounded.String_Access;
begin
if Manager.Names (Role) = null then
return "";
else
return Manager.Names (Role).all;
end if;
end Get_Role_Name;
-- ------------------------------
-- Find the role type associated with the role name identified by <b>Name</b>.
-- Raises <b>Invalid_Name</b> if there is no role type.
-- ------------------------------
function Find_Role (Manager : in Role_Policy;
Name : in String) return Role_Type is
use type Ada.Strings.Unbounded.String_Access;
begin
Log.Debug ("Searching role {0}", Name);
for I in Role_Type'First .. Manager.Next_Role loop
exit when Manager.Names (I) = null;
if Name = Manager.Names (I).all then
return I;
end if;
end loop;
Log.Debug ("Role {0} not found", Name);
raise Invalid_Name;
end Find_Role;
-- ------------------------------
-- Create a role
-- ------------------------------
procedure Create_Role (Manager : in out Role_Policy;
Name : in String;
Role : out Role_Type) is
begin
Role := Manager.Next_Role;
Log.Info ("Role {0} is {1}", Name, Role_Type'Image (Role));
if Manager.Next_Role = Role_Type'Last then
Log.Error ("Too many roles allocated. Number of roles is {0}",
Role_Type'Image (Role_Type'Last));
else
Manager.Next_Role := Manager.Next_Role + 1;
end if;
Manager.Names (Role) := new String '(Name);
end Create_Role;
-- ------------------------------
-- Get or build a permission type for the given name.
-- ------------------------------
procedure Add_Role_Type (Manager : in out Role_Policy;
Name : in String;
Result : out Role_Type) is
begin
Result := Manager.Find_Role (Name);
exception
when Invalid_Name =>
Manager.Create_Role (Name, Result);
end Add_Role_Type;
-- ------------------------------
-- Set the roles specified in the <tt>Roles</tt> parameter. Each role is represented by
-- its name and multiple roles are separated by ','.
-- Raises Invalid_Name if a role was not found.
-- ------------------------------
procedure Set_Roles (Manager : in Role_Policy;
Roles : in String;
Into : out Role_Map) is
procedure Process (Role : in String;
Done : out Boolean);
procedure Process (Role : in String;
Done : out Boolean) is
begin
Into (Manager.Find_Role (Role)) := True;
Done := False;
end Process;
begin
Into := (others => False);
Util.Strings.Tokenizers.Iterate_Tokens (Content => Roles,
Pattern => ",",
Process => Process'Access,
Going => Ada.Strings.Forward);
end Set_Roles;
type Config_Fields is (FIELD_NAME, FIELD_ROLE, FIELD_ROLE_PERMISSION, FIELD_ROLE_NAME);
procedure Set_Member (Into : in out Role_Policy'Class;
Field : in Config_Fields;
Value : in Util.Beans.Objects.Object);
-- ------------------------------
-- Called while parsing the XML policy file when the <name>, <role> and <role-permission>
-- XML entities are found. Create the new permission when the complete permission definition
-- has been parsed and save the permission in the security manager.
-- ------------------------------
procedure Set_Member (Into : in out Role_Policy'Class;
Field : in Config_Fields;
Value : in Util.Beans.Objects.Object) is
use Security.Controllers.Roles;
begin
case Field is
when FIELD_NAME =>
Into.Name := Value;
when FIELD_ROLE =>
declare
Role : constant String := Util.Beans.Objects.To_String (Value);
begin
Into.Roles (Into.Count + 1) := Into.Find_Role (Role);
Into.Count := Into.Count + 1;
exception
when Invalid_Name =>
raise Util.Serialize.Mappers.Field_Error with "Invalid role: " & Role;
end;
when FIELD_ROLE_PERMISSION =>
if Into.Count = 0 then
raise Util.Serialize.Mappers.Field_Error with "Missing at least one role";
end if;
declare
Name : constant String := Util.Beans.Objects.To_String (Into.Name);
Perm : constant Role_Controller_Access
:= new Role_Controller '(Count => Into.Count,
Roles => Into.Roles (1 .. Into.Count));
begin
Into.Manager.Add_Permission (Name, Perm.all'Access);
Into.Count := 0;
end;
when FIELD_ROLE_NAME =>
declare
Name : constant String := Util.Beans.Objects.To_String (Value);
Role : Role_Type;
begin
Into.Add_Role_Type (Name, Role);
end;
end case;
end Set_Member;
package Config_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Role_Policy'Class,
Element_Type_Access => Role_Policy_Access,
Fields => Config_Fields,
Set_Member => Set_Member);
Mapper : aliased Config_Mapper.Mapper;
-- ------------------------------
-- Setup the XML parser to read the <b>role-permission</b> description.
-- ------------------------------
procedure Prepare_Config (Policy : in out Role_Policy;
Reader : in out Util.Serialize.IO.XML.Parser) is
begin
Reader.Add_Mapping ("policy-rules", Mapper'Access);
Reader.Add_Mapping ("module", Mapper'Access);
Config_Mapper.Set_Context (Reader, Policy'Unchecked_Access);
end Prepare_Config;
-- ------------------------------
-- Finalize the policy manager.
-- ------------------------------
overriding
procedure Finalize (Policy : in out Role_Policy) is
use type Ada.Strings.Unbounded.String_Access;
begin
for I in Policy.Names'Range loop
exit when Policy.Names (I) = null;
Ada.Strings.Unbounded.Free (Policy.Names (I));
end loop;
end Finalize;
-- ------------------------------
-- Get the role policy associated with the given policy manager.
-- Returns the role policy instance or null if it was not registered in the policy manager.
-- ------------------------------
function Get_Role_Policy (Manager : in Security.Policies.Policy_Manager'Class)
return Role_Policy_Access is
Policy : constant Security.Policies.Policy_Access := Manager.Get_Policy (NAME);
begin
if Policy = null or else not (Policy.all in Role_Policy'Class) then
return null;
else
return Role_Policy'Class (Policy.all)'Access;
end if;
end Get_Role_Policy;
begin
Mapper.Add_Mapping ("role-permission", FIELD_ROLE_PERMISSION);
Mapper.Add_Mapping ("role-permission/name", FIELD_NAME);
Mapper.Add_Mapping ("role-permission/role", FIELD_ROLE);
Mapper.Add_Mapping ("security-role/role-name", FIELD_ROLE_NAME);
end Security.Policies.Roles;
|
AdaCore/libadalang | Ada | 120 | ads | package Pack is
package Inner is
I : Integer := 0;
function Fun return Integer;
end Inner;
end Pack;
|
HulinCedric/file-tree-website-generator | Ada | 124 | adb | with Ada.Text_IO;
use Ada.Text_IO;
procedure Bonjour is
begin -- Bonjour
Put("Hello world!");
end Bonjour;
|
charlie5/lace | Ada | 114 | ads | with
any_Math;
package short_Math is new any_Math (Real_t => short_Float);
pragma Pure (short_Math);
|
reznikmm/matreshka | Ada | 4,934 | 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.CMOF.Properties.Collections is
pragma Preelaborate;
package CMOF_Property_Collections is
new AMF.Generic_Collections
(CMOF_Property,
CMOF_Property_Access);
type Set_Of_CMOF_Property is
new CMOF_Property_Collections.Set with null record;
Empty_Set_Of_CMOF_Property : constant Set_Of_CMOF_Property;
type Ordered_Set_Of_CMOF_Property is
new CMOF_Property_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_CMOF_Property : constant Ordered_Set_Of_CMOF_Property;
type Bag_Of_CMOF_Property is
new CMOF_Property_Collections.Bag with null record;
Empty_Bag_Of_CMOF_Property : constant Bag_Of_CMOF_Property;
type Sequence_Of_CMOF_Property is
new CMOF_Property_Collections.Sequence with null record;
Empty_Sequence_Of_CMOF_Property : constant Sequence_Of_CMOF_Property;
private
Empty_Set_Of_CMOF_Property : constant Set_Of_CMOF_Property
:= (CMOF_Property_Collections.Set with null record);
Empty_Ordered_Set_Of_CMOF_Property : constant Ordered_Set_Of_CMOF_Property
:= (CMOF_Property_Collections.Ordered_Set with null record);
Empty_Bag_Of_CMOF_Property : constant Bag_Of_CMOF_Property
:= (CMOF_Property_Collections.Bag with null record);
Empty_Sequence_Of_CMOF_Property : constant Sequence_Of_CMOF_Property
:= (CMOF_Property_Collections.Sequence with null record);
end AMF.CMOF.Properties.Collections;
|
gitter-badger/libAnne | Ada | 854 | ads | generic
with function Image(Self : in Value_Type) return String is <>;
with function Wide_Image(Self : in Value_Type) return Wide_String is <>;
with function Wide_Wide_Image(Self : in Value_Type) return Wide_Wide_String is <>;
package Containers.Lists.Singly_Linked.IO is
----------
-- Node --
----------
function Image(Self : in Node) return String with Pure_Function;
function Wide_Image(Self : in Node) return Wide_String with Pure_Function;
function Wide_Wide_Image(Self : in Node) return Wide_Wide_String with Pure_Function;
----------
-- List --
----------
function Image(Self : in List) return String with Pure_Function;
function Wide_Image(Self : in List) return Wide_String with Pure_Function;
function Wide_Wide_Image(Self : in List) return Wide_Wide_String with Pure_Function;
end Containers.Lists.Singly_Linked.IO;
|
reznikmm/matreshka | Ada | 3,753 | 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.Internals.Generic_Element_Table;
with AMF.Internals.Tables.UML_Types;
package AMF.Internals.Tables.UML_Element_Table is
new AMF.Internals.Generic_Element_Table
(AMF.Internals.Tables.UML_Types.Element_Record);
pragma Preelaborate (AMF.Internals.Tables.UML_Element_Table);
|
reznikmm/matreshka | Ada | 20,538 | 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.
------------------------------------------------------------------------------
-- Property represents a declared state of one or more instances in terms of
-- a named relationship to a value or values. When a property is an attribute
-- of a classifier, the value or values are related to the instance of the
-- classifier by being held in slots of the instance. When a property is an
-- association end, the value or values are related to the instance or
-- instances at the other end(s) of the association. The range of valid
-- values represented by the property can be controlled by setting the
-- property's type.
--
-- A property has the capability of being a deployment target in a deployment
-- relationship. This enables modeling the deployment to hierarchical nodes
-- that have properties functioning as internal parts.
--
-- Property specializes ParameterableElement to specify that a property can
-- be exposed as a formal template parameter, and provided as an actual
-- parameter in a binding of a template.
--
-- A property represents a set of instances that are owned by a containing
-- classifier instance.
--
-- A property is a structural feature of a classifier that characterizes
-- instances of the classifier. A property related by ownedAttribute to a
-- classifier (other than an association) represents an attribute and might
-- also represent an association end. It relates an instance of the class to
-- a value or set of values of the type of the attribute. A property related
-- by memberEnd or its specializations to an association represents an end of
-- the association. The type of the property is the type of the end of the
-- association.
------------------------------------------------------------------------------
limited with AMF.UML.Associations;
limited with AMF.UML.Classes;
with AMF.UML.Connectable_Elements;
limited with AMF.UML.Data_Types;
with AMF.UML.Deployment_Targets;
limited with AMF.UML.Interfaces;
limited with AMF.UML.Parameterable_Elements;
limited with AMF.UML.Properties.Collections;
limited with AMF.UML.Redefinable_Elements;
with AMF.UML.Structural_Features;
limited with AMF.UML.Types.Collections;
limited with AMF.UML.Value_Specifications;
package AMF.UML.Properties is
pragma Preelaborate;
type UML_Property is limited interface
and AMF.UML.Connectable_Elements.UML_Connectable_Element
and AMF.UML.Deployment_Targets.UML_Deployment_Target
and AMF.UML.Structural_Features.UML_Structural_Feature;
type UML_Property_Access is
access all UML_Property'Class;
for UML_Property_Access'Storage_Size use 0;
not overriding function Get_Aggregation
(Self : not null access constant UML_Property)
return AMF.UML.UML_Aggregation_Kind is abstract;
-- Getter of Property::aggregation.
--
-- Specifies the kind of aggregation that applies to the Property.
not overriding procedure Set_Aggregation
(Self : not null access UML_Property;
To : AMF.UML.UML_Aggregation_Kind) is abstract;
-- Setter of Property::aggregation.
--
-- Specifies the kind of aggregation that applies to the Property.
not overriding function Get_Association
(Self : not null access constant UML_Property)
return AMF.UML.Associations.UML_Association_Access is abstract;
-- Getter of Property::association.
--
-- References the association of which this property is a member, if any.
not overriding procedure Set_Association
(Self : not null access UML_Property;
To : AMF.UML.Associations.UML_Association_Access) is abstract;
-- Setter of Property::association.
--
-- References the association of which this property is a member, if any.
not overriding function Get_Association_End
(Self : not null access constant UML_Property)
return AMF.UML.Properties.UML_Property_Access is abstract;
-- Getter of Property::associationEnd.
--
-- Designates the optional association end that owns a qualifier attribute.
not overriding procedure Set_Association_End
(Self : not null access UML_Property;
To : AMF.UML.Properties.UML_Property_Access) is abstract;
-- Setter of Property::associationEnd.
--
-- Designates the optional association end that owns a qualifier attribute.
not overriding function Get_Class
(Self : not null access constant UML_Property)
return AMF.UML.Classes.UML_Class_Access is abstract;
-- Getter of Property::class.
--
-- References the Class that owns the Property.
-- References the Class that owns the Property.
not overriding procedure Set_Class
(Self : not null access UML_Property;
To : AMF.UML.Classes.UML_Class_Access) is abstract;
-- Setter of Property::class.
--
-- References the Class that owns the Property.
-- References the Class that owns the Property.
not overriding function Get_Datatype
(Self : not null access constant UML_Property)
return AMF.UML.Data_Types.UML_Data_Type_Access is abstract;
-- Getter of Property::datatype.
--
-- The DataType that owns this Property.
not overriding procedure Set_Datatype
(Self : not null access UML_Property;
To : AMF.UML.Data_Types.UML_Data_Type_Access) is abstract;
-- Setter of Property::datatype.
--
-- The DataType that owns this Property.
not overriding function Get_Default
(Self : not null access constant UML_Property)
return AMF.Optional_String is abstract;
-- Getter of Property::default.
--
-- A String that is evaluated to give a default value for the Property
-- when an object of the owning Classifier is instantiated.
-- Specifies a String that represents a value to be used when no argument
-- is supplied for the Property.
not overriding procedure Set_Default
(Self : not null access UML_Property;
To : AMF.Optional_String) is abstract;
-- Setter of Property::default.
--
-- A String that is evaluated to give a default value for the Property
-- when an object of the owning Classifier is instantiated.
-- Specifies a String that represents a value to be used when no argument
-- is supplied for the Property.
not overriding function Get_Default_Value
(Self : not null access constant UML_Property)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access is abstract;
-- Getter of Property::defaultValue.
--
-- A ValueSpecification that is evaluated to give a default value for the
-- Property when an object of the owning Classifier is instantiated.
not overriding procedure Set_Default_Value
(Self : not null access UML_Property;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is abstract;
-- Setter of Property::defaultValue.
--
-- A ValueSpecification that is evaluated to give a default value for the
-- Property when an object of the owning Classifier is instantiated.
not overriding function Get_Interface
(Self : not null access constant UML_Property)
return AMF.UML.Interfaces.UML_Interface_Access is abstract;
-- Getter of Property::interface.
--
-- References the Interface that owns the Property
not overriding procedure Set_Interface
(Self : not null access UML_Property;
To : AMF.UML.Interfaces.UML_Interface_Access) is abstract;
-- Setter of Property::interface.
--
-- References the Interface that owns the Property
not overriding function Get_Is_Composite
(Self : not null access constant UML_Property)
return Boolean is abstract;
-- Getter of Property::isComposite.
--
-- If isComposite is true, the object containing the attribute is a
-- container for the object or value contained in the attribute.
-- This is a derived value, indicating whether the aggregation of the
-- Property is composite or not.
not overriding procedure Set_Is_Composite
(Self : not null access UML_Property;
To : Boolean) is abstract;
-- Setter of Property::isComposite.
--
-- If isComposite is true, the object containing the attribute is a
-- container for the object or value contained in the attribute.
-- This is a derived value, indicating whether the aggregation of the
-- Property is composite or not.
not overriding function Get_Is_Derived
(Self : not null access constant UML_Property)
return Boolean is abstract;
-- Getter of Property::isDerived.
--
-- Specifies whether the Property is derived, i.e., whether its value or
-- values can be computed from other information.
-- If isDerived is true, the value of the attribute is derived from
-- information elsewhere.
not overriding procedure Set_Is_Derived
(Self : not null access UML_Property;
To : Boolean) is abstract;
-- Setter of Property::isDerived.
--
-- Specifies whether the Property is derived, i.e., whether its value or
-- values can be computed from other information.
-- If isDerived is true, the value of the attribute is derived from
-- information elsewhere.
not overriding function Get_Is_Derived_Union
(Self : not null access constant UML_Property)
return Boolean is abstract;
-- Getter of Property::isDerivedUnion.
--
-- Specifies whether the property is derived as the union of all of the
-- properties that are constrained to subset it.
not overriding procedure Set_Is_Derived_Union
(Self : not null access UML_Property;
To : Boolean) is abstract;
-- Setter of Property::isDerivedUnion.
--
-- Specifies whether the property is derived as the union of all of the
-- properties that are constrained to subset it.
not overriding function Get_Is_ID
(Self : not null access constant UML_Property)
return Boolean is abstract;
-- Getter of Property::isID.
--
-- True indicates this property can be used to uniquely identify an
-- instance of the containing Class.
not overriding procedure Set_Is_ID
(Self : not null access UML_Property;
To : Boolean) is abstract;
-- Setter of Property::isID.
--
-- True indicates this property can be used to uniquely identify an
-- instance of the containing Class.
overriding function Get_Is_Read_Only
(Self : not null access constant UML_Property)
return Boolean is abstract;
-- Getter of Property::isReadOnly.
--
-- If isReadOnly is true, the attribute may not be written to after
-- initialization.
-- If true, the attribute may only be read, and not written.
overriding procedure Set_Is_Read_Only
(Self : not null access UML_Property;
To : Boolean) is abstract;
-- Setter of Property::isReadOnly.
--
-- If isReadOnly is true, the attribute may not be written to after
-- initialization.
-- If true, the attribute may only be read, and not written.
not overriding function Get_Opposite
(Self : not null access constant UML_Property)
return AMF.UML.Properties.UML_Property_Access is abstract;
-- Getter of Property::opposite.
--
-- In the case where the property is one navigable end of a binary
-- association with both ends navigable, this gives the other end.
not overriding procedure Set_Opposite
(Self : not null access UML_Property;
To : AMF.UML.Properties.UML_Property_Access) is abstract;
-- Setter of Property::opposite.
--
-- In the case where the property is one navigable end of a binary
-- association with both ends navigable, this gives the other end.
not overriding function Get_Owning_Association
(Self : not null access constant UML_Property)
return AMF.UML.Associations.UML_Association_Access is abstract;
-- Getter of Property::owningAssociation.
--
-- References the owning association of this property, if any.
not overriding procedure Set_Owning_Association
(Self : not null access UML_Property;
To : AMF.UML.Associations.UML_Association_Access) is abstract;
-- Setter of Property::owningAssociation.
--
-- References the owning association of this property, if any.
not overriding function Get_Qualifier
(Self : not null access constant UML_Property)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property is abstract;
-- Getter of Property::qualifier.
--
-- An optional list of ordered qualifier attributes for the end. If the
-- list is empty, then the Association is not qualified.
not overriding function Get_Redefined_Property
(Self : not null access constant UML_Property)
return AMF.UML.Properties.Collections.Set_Of_UML_Property is abstract;
-- Getter of Property::redefinedProperty.
--
-- References the properties that are redefined by this property.
not overriding function Get_Subsetted_Property
(Self : not null access constant UML_Property)
return AMF.UML.Properties.Collections.Set_Of_UML_Property is abstract;
-- Getter of Property::subsettedProperty.
--
-- References the properties of which this property is constrained to be a
-- subset.
not overriding function Default
(Self : not null access constant UML_Property)
return AMF.Optional_String is abstract;
-- Operation Property::default.
--
-- Missing derivation for Property::/default : String
not overriding function Is_Attribute
(Self : not null access constant UML_Property;
P : AMF.UML.Properties.UML_Property_Access)
return Boolean is abstract;
-- Operation Property::isAttribute.
--
-- The query isAttribute() is true if the Property is defined as an
-- attribute of some classifier.
overriding function Is_Compatible_With
(Self : not null access constant UML_Property;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is abstract;
-- Operation Property::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. In addition,
-- for properties, the type must be conformant with the type of the
-- specified parameterable element.
not overriding function Is_Composite
(Self : not null access constant UML_Property)
return Boolean is abstract;
-- Operation Property::isComposite.
--
-- The value of isComposite is true only if aggregation is composite.
overriding function Is_Consistent_With
(Self : not null access constant UML_Property;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is abstract;
-- Operation Property::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two Properties in a
-- context in which redefinition is possible, whether redefinition would
-- be logically consistent. A redefining property is consistent with a
-- redefined property if the type of the redefining property conforms to
-- the type of the redefined property, the multiplicity of the redefining
-- property (if specified) is contained in the multiplicity of the
-- redefined property.
-- The query isConsistentWith() specifies, for any two Properties in a
-- context in which redefinition is possible, whether redefinition would
-- be logically consistent. A redefining property is consistent with a
-- redefined property if the type of the redefining property conforms to
-- the type of the redefined property, and the multiplicity of the
-- redefining property (if specified) is contained in the multiplicity of
-- the redefined property.
not overriding function Is_Navigable
(Self : not null access constant UML_Property)
return Boolean is abstract;
-- Operation Property::isNavigable.
--
-- The query isNavigable() indicates whether it is possible to navigate
-- across the property.
not overriding function Opposite
(Self : not null access constant UML_Property)
return AMF.UML.Properties.UML_Property_Access is abstract;
-- Operation Property::opposite.
--
-- If this property is owned by a class, associated with a binary
-- association, and the other end of the association is also owned by a
-- class, then opposite gives the other end.
not overriding function Subsetting_Context
(Self : not null access constant UML_Property)
return AMF.UML.Types.Collections.Set_Of_UML_Type is abstract;
-- Operation Property::subsettingContext.
--
-- The query subsettingContext() gives the context for subsetting a
-- property. It consists, in the case of an attribute, of the
-- corresponding classifier, and in the case of an association end, all of
-- the classifiers at the other ends.
end AMF.UML.Properties;
|
AdaCore/Ada_Drivers_Library | Ada | 13,655 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.CCM is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Shortcut between ENDKSGEN event and CRYPT task.
type SHORTS_ENDKSGEN_CRYPT_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_ENDKSGEN_CRYPT_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcuts for the CCM.
type SHORTS_Register is record
-- Shortcut between ENDKSGEN event and CRYPT task.
ENDKSGEN_CRYPT : SHORTS_ENDKSGEN_CRYPT_Field := NRF_SVD.CCM.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
ENDKSGEN_CRYPT at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Enable interrupt on ENDKSGEN event.
type INTENSET_ENDKSGEN_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_ENDKSGEN_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on ENDKSGEN event.
type INTENSET_ENDKSGEN_Field_1 is
(-- Reset value for the field
Intenset_Endksgen_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_ENDKSGEN_Field_1 use
(Intenset_Endksgen_Field_Reset => 0,
Set => 1);
-- Enable interrupt on ENDCRYPT event.
type INTENSET_ENDCRYPT_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_ENDCRYPT_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on ENDCRYPT event.
type INTENSET_ENDCRYPT_Field_1 is
(-- Reset value for the field
Intenset_Endcrypt_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_ENDCRYPT_Field_1 use
(Intenset_Endcrypt_Field_Reset => 0,
Set => 1);
-- Enable interrupt on ERROR event.
type INTENSET_ERROR_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on ERROR event.
type INTENSET_ERROR_Field_1 is
(-- Reset value for the field
Intenset_Error_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_ERROR_Field_1 use
(Intenset_Error_Field_Reset => 0,
Set => 1);
-- Interrupt enable set register.
type INTENSET_Register is record
-- Enable interrupt on ENDKSGEN event.
ENDKSGEN : INTENSET_ENDKSGEN_Field_1 :=
Intenset_Endksgen_Field_Reset;
-- Enable interrupt on ENDCRYPT event.
ENDCRYPT : INTENSET_ENDCRYPT_Field_1 :=
Intenset_Endcrypt_Field_Reset;
-- Enable interrupt on ERROR event.
ERROR : INTENSET_ERROR_Field_1 := Intenset_Error_Field_Reset;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
ENDKSGEN at 0 range 0 .. 0;
ENDCRYPT at 0 range 1 .. 1;
ERROR at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Disable interrupt on ENDKSGEN event.
type INTENCLR_ENDKSGEN_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_ENDKSGEN_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on ENDKSGEN event.
type INTENCLR_ENDKSGEN_Field_1 is
(-- Reset value for the field
Intenclr_Endksgen_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_ENDKSGEN_Field_1 use
(Intenclr_Endksgen_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on ENDCRYPT event.
type INTENCLR_ENDCRYPT_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_ENDCRYPT_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on ENDCRYPT event.
type INTENCLR_ENDCRYPT_Field_1 is
(-- Reset value for the field
Intenclr_Endcrypt_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_ENDCRYPT_Field_1 use
(Intenclr_Endcrypt_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on ERROR event.
type INTENCLR_ERROR_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on ERROR event.
type INTENCLR_ERROR_Field_1 is
(-- Reset value for the field
Intenclr_Error_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_ERROR_Field_1 use
(Intenclr_Error_Field_Reset => 0,
Clear => 1);
-- Interrupt enable clear register.
type INTENCLR_Register is record
-- Disable interrupt on ENDKSGEN event.
ENDKSGEN : INTENCLR_ENDKSGEN_Field_1 :=
Intenclr_Endksgen_Field_Reset;
-- Disable interrupt on ENDCRYPT event.
ENDCRYPT : INTENCLR_ENDCRYPT_Field_1 :=
Intenclr_Endcrypt_Field_Reset;
-- Disable interrupt on ERROR event.
ERROR : INTENCLR_ERROR_Field_1 := Intenclr_Error_Field_Reset;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
ENDKSGEN at 0 range 0 .. 0;
ENDCRYPT at 0 range 1 .. 1;
ERROR at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Result of the MIC check performed during the previous CCM RX STARTCRYPT
type MICSTATUS_MICSTATUS_Field is
(-- MIC check failed.
Checkfailed,
-- MIC check passed.
Checkpassed)
with Size => 1;
for MICSTATUS_MICSTATUS_Field use
(Checkfailed => 0,
Checkpassed => 1);
-- CCM RX MIC check result.
type MICSTATUS_Register is record
-- Read-only. Result of the MIC check performed during the previous CCM
-- RX STARTCRYPT
MICSTATUS : MICSTATUS_MICSTATUS_Field;
-- unspecified
Reserved_1_31 : HAL.UInt31;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MICSTATUS_Register use record
MICSTATUS at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- CCM enable.
type ENABLE_ENABLE_Field is
(-- CCM is disabled.
Disabled,
-- CCM is enabled.
Enabled)
with Size => 2;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 2);
-- CCM enable.
type ENABLE_Register is record
-- CCM enable.
ENABLE : ENABLE_ENABLE_Field := NRF_SVD.CCM.Disabled;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- CCM mode operation.
type MODE_MODE_Field is
(-- CCM mode TX
Encryption,
-- CCM mode TX
Decryption)
with Size => 1;
for MODE_MODE_Field use
(Encryption => 0,
Decryption => 1);
-- Operation mode.
type MODE_Register is record
-- CCM mode operation.
MODE : MODE_MODE_Field := NRF_SVD.CCM.Decryption;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MODE_Register use record
MODE at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Peripheral power control.
type POWER_POWER_Field is
(-- Module power disabled.
Disabled,
-- Module power enabled.
Enabled)
with Size => 1;
for POWER_POWER_Field use
(Disabled => 0,
Enabled => 1);
-- Peripheral power control.
type POWER_Register is record
-- Peripheral power control.
POWER : POWER_POWER_Field := NRF_SVD.CCM.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
POWER at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- AES CCM Mode Encryption.
type CCM_Peripheral is record
-- Start generation of key-stream. This operation will stop by itself
-- when completed.
TASKS_KSGEN : aliased HAL.UInt32;
-- Start encrypt/decrypt. This operation will stop by itself when
-- completed.
TASKS_CRYPT : aliased HAL.UInt32;
-- Stop encrypt/decrypt.
TASKS_STOP : aliased HAL.UInt32;
-- Keystream generation completed.
EVENTS_ENDKSGEN : aliased HAL.UInt32;
-- Encrypt/decrypt completed.
EVENTS_ENDCRYPT : aliased HAL.UInt32;
-- Error happened.
EVENTS_ERROR : aliased HAL.UInt32;
-- Shortcuts for the CCM.
SHORTS : aliased SHORTS_Register;
-- Interrupt enable set register.
INTENSET : aliased INTENSET_Register;
-- Interrupt enable clear register.
INTENCLR : aliased INTENCLR_Register;
-- CCM RX MIC check result.
MICSTATUS : aliased MICSTATUS_Register;
-- CCM enable.
ENABLE : aliased ENABLE_Register;
-- Operation mode.
MODE : aliased MODE_Register;
-- Pointer to a data structure holding AES key and NONCE vector.
CNFPTR : aliased HAL.UInt32;
-- Pointer to the input packet.
INPTR : aliased HAL.UInt32;
-- Pointer to the output packet.
OUTPTR : aliased HAL.UInt32;
-- Pointer to a "scratch" data area used for temporary storage during
-- resolution. A minimum of 43 bytes must be reserved.
SCRATCHPTR : aliased HAL.UInt32;
-- Peripheral power control.
POWER : aliased POWER_Register;
end record
with Volatile;
for CCM_Peripheral use record
TASKS_KSGEN at 16#0# range 0 .. 31;
TASKS_CRYPT at 16#4# range 0 .. 31;
TASKS_STOP at 16#8# range 0 .. 31;
EVENTS_ENDKSGEN at 16#100# range 0 .. 31;
EVENTS_ENDCRYPT at 16#104# range 0 .. 31;
EVENTS_ERROR at 16#108# range 0 .. 31;
SHORTS at 16#200# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
MICSTATUS at 16#400# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
MODE at 16#504# range 0 .. 31;
CNFPTR at 16#508# range 0 .. 31;
INPTR at 16#50C# range 0 .. 31;
OUTPTR at 16#510# range 0 .. 31;
SCRATCHPTR at 16#514# range 0 .. 31;
POWER at 16#FFC# range 0 .. 31;
end record;
-- AES CCM Mode Encryption.
CCM_Periph : aliased CCM_Peripheral
with Import, Address => CCM_Base;
end NRF_SVD.CCM;
|
micahwelf/FLTK-Ada | Ada | 1,773 | ads |
package FLTK.Widgets.Valuators.Dials is
type Dial is new Valuator with private;
type Dial_Reference (Data : not null access Dial'Class) is limited null record
with Implicit_Dereference => Data;
type Dial_Kind is (Normal_Kind, Line_Kind, Fill_Kind);
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Dial;
end Forge;
function Get_Dial_Type
(This : in Dial)
return Dial_Kind;
function Get_First_Angle
(This : in Dial)
return Integer;
procedure Set_First_Angle
(This : in out Dial;
To : in Integer);
function Get_Second_Angle
(This : in Dial)
return Integer;
procedure Set_Second_Angle
(This : in out Dial;
To : in Integer);
procedure Set_Angles
(This : in out Dial;
One, Two : in Integer);
procedure Draw
(This : in out Dial);
function Handle
(This : in out Dial;
Event : in Event_Kind)
return Event_Outcome;
package Extra is
procedure Set_Dial_Type
(This : in out Dial;
To : in Dial_Kind);
end Extra;
private
type Dial is new Valuator with null record;
overriding procedure Finalize
(This : in out Dial);
pragma Inline (Get_Dial_Type);
pragma Inline (Get_First_Angle);
pragma Inline (Set_First_Angle);
pragma Inline (Get_Second_Angle);
pragma Inline (Set_Second_Angle);
pragma Inline (Set_Angles);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Valuators.Dials;
|
clairvoyant/anagram | Ada | 4,088 | adb | -- Copyright (c) 2010-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Anagram.Graphs is
function "+" (X : Boolean) return Unsigned;
pragma Inline ("+");
---------
-- "+" --
---------
function "+" (X : Boolean) return Unsigned is
Result : constant array (Boolean) of Unsigned := (0, -1);
begin
return Result (X);
end "+";
---------
-- Add --
---------
procedure Add
(Left : in out Graph;
Right : Graph;
Shift : Node_Count := 0) is
begin
if Right.Size + Shift > Left.Size then
raise Constraint_Error;
end if;
for J in 1 .. Right.Size loop
Left.X (J + Shift) := Left.X (J + Shift) or
Shift_Left (Right.X (J), Natural (Shift));
end loop;
end Add;
------------------
-- Add_Subgraph --
------------------
procedure Add_Subgraph
(Left : in out Graph;
Right : Graph)
is
Mask : constant Unsigned := Shift_Left (1, Natural (Left.Size)) - 1;
begin
if Left.Size > Right.Size then
raise Constraint_Error;
end if;
for J in 1 .. Left.Size loop
Left.X (J) := Left.X (J) or (Right.X (J) and Mask);
end loop;
end Add_Subgraph;
------------------
-- Add_Subgraph --
------------------
procedure Add_Subgraph
(Left : in out Graph;
Right : Graph;
Changed : in out Boolean;
Shift : Node_Count := 0)
is
Sum : Unsigned := 0;
Temp : Unsigned;
Mask : constant Unsigned := Shift_Left (1, Natural (Left.Size)) - 1;
begin
if Left.Size + Shift > Right.Size then
raise Constraint_Error;
end if;
for J in 1 .. Left.Size loop
Temp := Shift_Right (Right.X (J + Shift), Natural (Shift)) and Mask;
Sum := Sum or (Temp and not Left.X (J));
Left.X (J) := Left.X (J) or Temp;
end loop;
Changed := Changed or (Sum /= 0);
end Add_Subgraph;
----------
-- Edge --
----------
function Edge (Self : Graph; A, B : Node_Index) return Boolean is
begin
return (Self.X (A) and Shift_Left (1, Natural (B - 1))) /= 0;
end Edge;
-------------------------
-- Difference_Is_Empty --
-------------------------
function Difference_Is_Empty (X, Y : Graph) return Boolean is
begin
for J in 1 .. Node_Count'Min (X.Size, Y.Size) loop
if ((not X.X (J)) and Y.X (J)) /= 0 then
return False;
end if;
end loop;
return True;
end Difference_Is_Empty;
---------------------
-- Has_Self_Cycles --
---------------------
function Has_Self_Cycles (X : Graph) return Boolean is
Mask : Unsigned := 1;
begin
for J in 1 .. X.Size loop
if (X.X (J) and Mask) /= 0 then
return True;
end if;
Mask := Mask + Mask;
end loop;
return False;
end Has_Self_Cycles;
---------------
-- Intersect --
---------------
function Intersect (X, Y : Graph) return Boolean is
begin
for J in 1 .. Node_Count'Min (X.Size, Y.Size) loop
if (X.X (J) and Y.X (J)) /= 0 then
return True;
end if;
end loop;
return False;
end Intersect;
------------------
-- Path_Closure --
------------------
procedure Path_Closure (X : in out Graph) is
begin
for K in 1 .. X.Size loop
for I in 1 .. X.Size loop
X.X (I) := X.X (I) or (+Edge (X, I, K) and X.X (K));
end loop;
end loop;
end Path_Closure;
--------------
-- Set_Edge --
--------------
procedure Set_Edge
(Self : in out Graph;
A, B : Node_Index;
Value : Boolean := True)
is
begin
if Value then
Self.X (A) := Self.X (A) or Shift_Left (1, Natural (B - 1));
else
Self.X (A) := Self.X (A) and not Shift_Left (1, Natural (B - 1));
end if;
end Set_Edge;
end Anagram.Graphs;
|
ficorax/PortAudioAda | Ada | 1,006 | ads | with Ada.Numerics;
with Interfaces.C;
with PortAudioAda; use PortAudioAda;
package PaEx_Sine_Types is
Num_Seconds : constant := 5.0;
Sample_Rate : constant := 44_100.0;
Frames_Per_Buffer : constant := 64;
Pi : constant := Ada.Numerics.Pi;
Table_Size : constant := 200;
type Float_Array
is array (Integer range <>) of aliased Float;
pragma Convention (C, Float_Array);
type paTestData is
record
sine : aliased Float_Array (1 .. Table_Size);
left_phase : aliased Integer;
right_phase : aliased Integer;
message : aliased String (1 .. 20);
end record;
pragma Convention (C, paTestData);
type paTestData_Ptr is access all paTestData;
pragma Convention (C, paTestData_Ptr);
pragma No_Strict_Aliasing (paTestData_Ptr);
outputParameters : aliased PA_Stream_Parameters;
data : aliased paTestData;
pragma Convention (C, data);
end PaEx_Sine_Types;
|
annexi-strayline/AURA | Ada | 7,068 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Directories;
with Workers;
with Workers.Reporting;
package body Repositories.Cache is
-- Configuration
Cache_Root: constant String
:= Ada.Directories.Current_Directory & "/.aura/cache";
-- Useful things
New_Line: Character renames Workers.Reporting.New_Line;
--
-- Validate_Local_Or_System
--
-- Validate_Local_Or_System validates a Local or System repo.
--
-- The first step is to verify that Location is accessible, followed by
-- a collective hash of all non-hidden files contained therein (recursively)
--
-- For existing repos, the calculated hash is verified. If there is a hash
-- mismatch, the use is notified interactively, and is given the option
-- to accept the changes or abort the process.
--
-- Changes to System repositories imply potential global changes to all
-- subsystems already checked-out from that repository
--
-- If the user choses to accept changes on a repository, the repository
-- unit's Snapshot property is updated with the hash
--
-- If Snapshot of the dispatched repo is empty, the repo is assumed to be
-- new.
--
-- If Location is not accessible, validation fails
--
-- Finally, if the local repo is validated, it's path is used to set
-- Cache_Path
package Validate_Local_Or_System is
procedure Dispatch (Repo: in Repository; Index: in Repository_Index);
-- Dispatch submits a work order to validate a local repository
-- identified by Repo/Index. The process is attached to the
-- Caching_Progress tracker
end Validate_Local_Or_System;
package body Validate_Local_Or_System is separate;
--
-- Checkout_Git
--
-- Checkout_Git ensures that the cache for a given Git repo is both
-- present and valid.
--
-- If the cache is not present, an attempt is made to clone and checkout
-- the repo. If the cache is present, it is verified to be of the correct
-- snapshot (commit), and tracking branch. If these are not the expected
-- value, the existing cache is expunged, and a new cache is checked-out
package Checkout_Git is
procedure Dispatch (Repo: in Repository; Index: in Repository_Index);
-- Dispatch submits a work order to substantiate a git repository
-- identified by Repo/Index. The process is attached to the
-- Caching_Progress tracker
end Checkout_Git;
package body Checkout_Git is separate;
------------------------
-- Cache_Repositories --
------------------------
procedure Cache_Repositories is
use type Ada.Containers.Count_Type;
Repo_Map: Repository_Maps.Map := Extract_All_Repositories;
Index: Repository_Index := Root_Repository + 1;
begin
if Repo_Map.Length = 0 then return; end if;
-- The Root Repository is special, and should never be "cached". In fact,
-- it always has a cache state of "Available", So let's not waste time
-- iterating over it. We have an ordered map, so we really want to do
-- a regular iteration, instead of doing a find every time.
Repo_Map.Delete (Root_Repository);
for Repo of Repo_Map loop
if Repo.Cache_State = Requested then
Caching_Progress.Increment_Total_Items;
case Repo.Format is
when System | Local =>
Validate_Local_Or_System.Dispatch (Repo, Index);
when Git =>
Checkout_Git.Dispatch (Repo, Index);
end case;
end if;
Index := Index + 1;
end loop;
end Cache_Repositories;
end Repositories.Cache;
|
flyx/FreeTypeAda | Ada | 7,703 | ads | -- part of FreeTypeAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
package FT.Errors is
pragma Preelaborate;
type Error_Code is
(Ok, Cannot_Open_Resource, Unknown_File_Format, Invalid_File_Format,
Invalid_Version, Lower_Module_Version, Invalid_Argument,
Unimplemented_Feature, Invalid_Table, Invalid_Offset, Array_Too_Large,
Missing_Module, Missing_Property, Invalid_Glyph_Index,
Invalid_Character_Code, Invalid_Glyph_Format, Cannot_Render_Glyph,
Invalid_Outline, Invalid_Composite, Too_Many_Hints, Invalid_Pixel_Size,
Invalid_Handle, Invalid_Library_Handle, Invalid_Driver_Handle,
Invalid_Face_Handle, Invalid_Size_Handle, Invalid_Slot_Handle,
Invalid_CharMap_Handle, Invalid_Cache_Handle, Invalid_Stream_Handle,
Too_Many_Drivers, Too_Many_Extensions, Out_Of_Memory, Unlisted_Object,
Cannot_Open_Stream, Invalid_Stream_Seek, Invalid_Stream_Skip,
Invalid_Stream_Read, Invalid_Stream_Operation, Invalid_Frame_Operation,
Nested_Frame_Access, Invalid_Frame_Read, Raster_Uninitialized,
Raster_Corrupted, Raster_Overflow, Raster_Negative_Height,
Too_Many_Caches, Invalid_Opcode, Too_Few_Arguments, Stack_Overflow,
Code_Overflow, Bad_Argument, Divide_By_Zero, Invalid_Reference,
Debug_OpCode, ENDF_In_Exec_Stream, Nested_DEFS, Invalid_CodeRange,
Execution_Too_Long, Too_Many_Function_Defs, Too_Many_Instruction_Defs,
Table_Missing, Horiz_Header_Missing, Locations_Missing,
Name_Table_Missing, CMap_Table_Missing, Hmtx_Table_Missing,
Post_Table_Missing, Invalid_Horiz_Metrics, Invalid_CharMap_Format,
Invalid_PPem, Invalid_Vert_Metrics, Could_Not_Find_Context,
Invalid_Post_Table_Format, Invalid_Post_Table, DEF_In_Glyf_Bytecode,
Missing_Bitmap, Syntax_Error, Stack_Underflow, Ignore,
No_Unicode_Glyph_Name, Glyph_Too_Big, Missing_Startfont_Field,
Missing_Font_Field, Missing_Size_Field, Missing_Fontboundingbox_Field,
Missing_Chars_Field, Missing_Startchar_Field, Missing_Encoding_Field,
Missing_Bbx_Field, Bbx_Too_Big, Corrupted_Font_Header,
Corrupted_Font_Glyphs);
for Error_Code use
(Ok => 16#00#,
Cannot_Open_Resource => 16#01#,
Unknown_File_Format => 16#02#,
Invalid_File_Format => 16#03#,
Invalid_Version => 16#04#,
Lower_Module_Version => 16#05#,
Invalid_Argument => 16#06#,
Unimplemented_Feature => 16#07#,
Invalid_Table => 16#08#,
Invalid_Offset => 16#09#,
Array_Too_Large => 16#0A#,
Missing_Module => 16#0B#,
Missing_Property => 16#0C#,
Invalid_Glyph_Index => 16#10#,
Invalid_Character_Code => 16#11#,
Invalid_Glyph_Format => 16#12#,
Cannot_Render_Glyph => 16#13#,
Invalid_Outline => 16#14#,
Invalid_Composite => 16#15#,
Too_Many_Hints => 16#16#,
Invalid_Pixel_Size => 16#17#,
Invalid_Handle => 16#20#,
Invalid_Library_Handle => 16#21#,
Invalid_Driver_Handle => 16#22#,
Invalid_Face_Handle => 16#23#,
Invalid_Size_Handle => 16#24#,
Invalid_Slot_Handle => 16#25#,
Invalid_CharMap_Handle => 16#26#,
Invalid_Cache_Handle => 16#27#,
Invalid_Stream_Handle => 16#28#,
Too_Many_Drivers => 16#30#,
Too_Many_Extensions => 16#31#,
Out_Of_Memory => 16#40#,
Unlisted_Object => 16#41#,
Cannot_Open_Stream => 16#51#,
Invalid_Stream_Seek => 16#52#,
Invalid_Stream_Skip => 16#53#,
Invalid_Stream_Read => 16#54#,
Invalid_Stream_Operation => 16#55#,
Invalid_Frame_Operation => 16#56#,
Nested_Frame_Access => 16#57#,
Invalid_Frame_Read => 16#58#,
Raster_Uninitialized => 16#60#,
Raster_Corrupted => 16#61#,
Raster_Overflow => 16#62#,
Raster_Negative_Height => 16#63#,
Too_Many_Caches => 16#70#,
Invalid_Opcode => 16#80#,
Too_Few_Arguments => 16#81#,
Stack_Overflow => 16#82#,
Code_Overflow => 16#83#,
Bad_Argument => 16#84#,
Divide_By_Zero => 16#85#,
Invalid_Reference => 16#86#,
Debug_OpCode => 16#87#,
ENDF_In_Exec_Stream => 16#88#,
Nested_DEFS => 16#89#,
Invalid_CodeRange => 16#8A#,
Execution_Too_Long => 16#8B#,
Too_Many_Function_Defs => 16#8C#,
Too_Many_Instruction_Defs => 16#8D#,
Table_Missing => 16#8E#,
Horiz_Header_Missing => 16#8F#,
Locations_Missing => 16#90#,
Name_Table_Missing => 16#91#,
CMap_Table_Missing => 16#92#,
Hmtx_Table_Missing => 16#93#,
Post_Table_Missing => 16#94#,
Invalid_Horiz_Metrics => 16#95#,
Invalid_CharMap_Format => 16#96#,
Invalid_PPem => 16#97#,
Invalid_Vert_Metrics => 16#98#,
Could_Not_Find_Context => 16#99#,
Invalid_Post_Table_Format => 16#9A#,
Invalid_Post_Table => 16#9B#,
DEF_In_Glyf_Bytecode => 16#9C#,
Missing_Bitmap => 16#9D#,
Syntax_Error => 16#A0#,
Stack_Underflow => 16#A1#,
Ignore => 16#A2#,
No_Unicode_Glyph_Name => 16#A3#,
Glyph_Too_Big => 16#A4#,
Missing_Startfont_Field => 16#B0#,
Missing_Font_Field => 16#B1#,
Missing_Size_Field => 16#B2#,
Missing_Fontboundingbox_Field => 16#B3#,
Missing_Chars_Field => 16#B4#,
Missing_Startchar_Field => 16#B5#,
Missing_Encoding_Field => 16#B6#,
Missing_Bbx_Field => 16#B7#,
Bbx_Too_Big => 16#B8#,
Corrupted_Font_Header => 16#B9#,
Corrupted_Font_Glyphs => 16#BA#);
for Error_Code'Size use Interfaces.C.int'Size;
subtype Generic_Errors is Error_Code range Ok .. Missing_Property;
subtype Glyph_Character_Errors is Error_Code range
Invalid_Glyph_Index .. Invalid_Pixel_Size;
subtype Handle_Errors is Error_Code range
Invalid_Handle .. Invalid_Stream_Handle;
subtype Driver_Errors is Error_Code range
Too_Many_Drivers .. Too_Many_Extensions;
subtype Memory_Errors is Error_Code range Out_Of_Memory .. Unlisted_Object;
subtype Stream_Errors is Error_Code range
Cannot_Open_Stream .. Invalid_Frame_Read;
subtype Raster_Errors is Error_Code range
Raster_Uninitialized .. Raster_Negative_Height;
subtype Cache_Errors is Error_Code range Too_Many_Caches .. Too_Many_Caches;
subtype TrueType_And_SFNT_Errors is Error_Code range
Invalid_Opcode .. Missing_Bitmap;
subtype CFF_CID_And_Type_1_Errors is Error_Code range
Syntax_Error .. Glyph_Too_Big;
subtype BDF_Errors is Error_Code range
Missing_Startfont_Field .. Corrupted_Font_Glyphs;
function Description (Code : Error_Code) return String;
end FT.Errors;
|
charlie5/aIDE | Ada | 1,154 | ads | with
Ada.Containers.Vectors,
Ada.Streams;
package AdaM.Declaration.of_type
is
type Item is new Declaration.item with private;
-- View
--
type View is access all Item'Class;
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View);
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View);
for View'write use View_write;
for View'read use View_read;
-- Vector
--
package Vectors is new ada.Containers.Vectors (Positive, View);
subtype Vector is Vectors.Vector;
-- Forge
--
function new_Declaration return Declaration.of_type.view;
procedure free (Self : in out Declaration.of_type.view);
overriding
procedure destruct (Self : in out Declaration.of_type.item);
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id;
private
type Item is new Declaration.item with
record
null;
end record;
end AdaM.Declaration.of_type;
|
Lucretia/Cherry | Ada | 2,194 | ads | --
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Lime;
package Reports is
procedure Reprint_C (Lemp : access Lime.Lemon_Record);
procedure Reprint (Lemp : in Lime.Lemon_Record);
-- Duplicate the input file without comments and without actions
-- on rules
procedure Report_Output_C (Lemp : access Lime.Lemon_Record);
procedure Report_Output (Lemp : in Lime.Lemon_Record);
-- Generate the "*.out" log file
procedure Report_Table_C (Lemp : access Lime.Lemon_Record);
procedure Report_Table (Lemp : in out Lime.Lemon_Record;
User_Template_Name : in String);
-- Generate C source code for the parser
procedure Compress_Tables_C (Lemp : access Lime.Lemon_Record);
procedure Compress_Tables (Lemp : in Lime.Lemon_Record);
-- Reduce the size of the action tables, if possible, by making use
-- of defaults.
--
-- In this version, we take the most frequent REDUCE action and make
-- it the default. Except, there is no default if the wildcard token
-- is a possible look-ahead.
procedure Resort_States_C (Lemp : access Lime.Lemon_Record);
procedure Resort_States (Lemp : in Lime.Lemon_Record);
-- Renumber and resort states so that states with fewer choices
-- occur at the end. Except, keep state 0 as the first state.
procedure Dummy;
procedure Reprint_Of_Grammar
(Lemon_Lemp : in out Lime.Lemon_Record;
Base_Name : in String;
Token_Prefix : in String;
Terminal_Last : in Natural);
private
pragma Export (C, Reprint_C, "lemon_reprint");
pragma Export (C, Report_Output_C, "lemon_report_output");
pragma Export (C, Report_Table_C, "lemon_report_table");
pragma Export (C, Compress_Tables_C, "lemon_compress_tables");
pragma Export (C, Resort_States_C, "lemon_resort_states");
pragma Export (C, Dummy, "lemon_report_dummy");
end Reports;
|
faelys/natools | Ada | 1,813 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.S_Expressions.Printers.Tests provides a test suite for the --
-- canonical printer. --
------------------------------------------------------------------------------
with Natools.Tests;
package Natools.S_Expressions.Printers.Tests is
pragma Preelaborate (Tests);
package NT renames Natools.Tests;
procedure All_Tests (Report : in out NT.Reporter'Class);
procedure Canonical_Test (Report : in out NT.Reporter'Class);
end Natools.S_Expressions.Printers.Tests;
|
Rodeo-McCabe/orka | Ada | 3,620 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Numerics.Generic_Elementary_Functions;
package body Orka.Transforms.SIMD_Vectors is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Element_Type);
function Magnitude2 (Elements : Vector_Type) return Element_Type is
(Sum (Elements * Elements));
function "*" (Factor : Element_Type; Elements : Vector_Type) return Vector_Type is
begin
return (Factor, Factor, Factor, Factor) * Elements;
end "*";
function "*" (Elements : Vector_Type; Factor : Element_Type) return Vector_Type is
(Factor * Elements);
function Magnitude (Elements : Vector_Type) return Element_Type is
begin
return EF.Sqrt (Magnitude2 (Elements));
end Magnitude;
function Normalize (Elements : Vector_Type) return Vector_Type is
Length : constant Element_Type := Magnitude (Elements);
begin
return Divide_Or_Zero (Elements, (Length, Length, Length, Length));
end Normalize;
function Normalized (Elements : Vector_Type) return Boolean is
function Is_Equivalent (Expected, Result : Element_Type) return Boolean is
-- Because the square root is not computed, the bounds need
-- to be increased to +/- 2 * Epsilon + Epsilon ** 2. Since
-- Epsilon < 1, we can simply take +/- 3 * Epsilon
Epsilon : constant Element_Type := 3.0 * Element_Type'Model_Epsilon;
begin
return Result in Expected - Epsilon .. Expected + Epsilon;
end Is_Equivalent;
begin
return Is_Equivalent (1.0, Magnitude2 (Elements));
end Normalized;
function Distance (Left, Right : Vector_Type) return Element_Type is
(Magnitude (Left - Right));
function Projection (Elements, Direction : Vector_Type) return Vector_Type is
Unit_Direction : constant Vector_Type := Normalize (Direction);
begin
-- The dot product gives the magnitude of the projected vector:
-- |A_b| = |A| * cos(theta) = A . U_b
return Dot (Elements, Unit_Direction) * Unit_Direction;
end Projection;
function Perpendicular (Elements, Direction : Vector_Type) return Vector_Type is
(Elements - Projection (Elements, Direction));
function Angle (Left, Right : Vector_Type) return Element_Type is
begin
return EF.Arccos (Dot (Left, Right) / (Magnitude (Left) * Magnitude (Right)));
end Angle;
function Dot (Left, Right : Vector_Type) return Element_Type is
(Sum (Left * Right));
function Slerp
(Left, Right : Vector_Type;
Weight : Element_Type) return Vector_Type
is
Cos_Angle : constant Element_Type := Dot (Left, Right);
Angle : constant Element_Type := EF.Arccos (Cos_Angle);
SA : constant Element_Type := EF.Sin (Angle);
SL : constant Element_Type := EF.Sin ((1.0 - Weight) * Angle);
SR : constant Element_Type := EF.Sin (Weight * Angle);
begin
return (SL / SA) * Left + (SR / SA) * Right;
end Slerp;
end Orka.Transforms.SIMD_Vectors;
|
zhmu/ananas | Ada | 4,307 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . B U B B L E _ S O R T _ G --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-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. --
-- --
------------------------------------------------------------------------------
-- Bubblesort generic package using formal procedures
-- This package provides a generic bubble sort routine that can be used with
-- different types of data.
-- See also GNAT.Bubble_Sort, a version that works with subprogram access
-- parameters, allowing code sharing. The generic version is slightly more
-- efficient but does not allow code sharing and has an interface that is
-- more awkward to use.
-- There is also GNAT.Bubble_Sort_A, which is now considered obsolete, but
-- was an older version working with subprogram parameters. This version
-- is retained for backwards compatibility with old versions of GNAT.
generic
-- The data to be sorted is assumed to be indexed by integer values from
-- 1 to N, where N is the number of items to be sorted. In addition, the
-- index value zero is used for a temporary location used during the sort.
with procedure Move (From : Natural; To : Natural);
-- A procedure that moves the data item with index value From to the data
-- item with index value To (the old value in To being lost). An index
-- value of zero is used for moves from and to a single temporary location
-- used by the sort.
with function Lt (Op1, Op2 : Natural) return Boolean;
-- A function that compares two items and returns True if the item with
-- index Op1 is less than the item with Index Op2, and False if the Op2
-- item is greater than or equal to the Op1 item.
package GNAT.Bubble_Sort_G is
pragma Pure;
procedure Sort (N : Natural);
-- This procedures sorts items in the range from 1 to N into ascending
-- order making calls to Lt to do required comparisons, and Move to move
-- items around. Note that, as described above, both Move and Lt use a
-- single temporary location with index value zero. This sort is stable,
-- that is the order of equal elements in the input is preserved.
end GNAT.Bubble_Sort_G;
|
zrmyers/VulkanAda | Ada | 5,146 | adb | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- 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.
--------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Characters.Latin_1;
with Vulkan.Math.GenFMatrix;
with Vulkan.Math.Mat2x2;
with Vulkan.Math.Mat2x4;
with Vulkan.Math.GenFType;
with Vulkan.Math.Vec2;
with Vulkan.Math.Vec4;
with Vulkan.Math.Operators;
with Vulkan.Test.Framework;
use Ada.Text_IO;
use Ada.Characters.Latin_1;
use Vulkan.Math.Mat2x2;
use Vulkan.Math.Mat2x4;
use Vulkan.Math.GenFType;
use Vulkan.Math.Vec2;
use Vulkan.Math.Vec4;
use Vulkan.Test.Framework;
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides tests for single precision floating point mat2x4.
--------------------------------------------------------------------------------
package body Vulkan.Math.Mat2x4.Test is
-- Test Mat2x4
procedure Test_Mat2x4 is
vec1 : Vkm_Vec2 :=
Make_Vec2(1.0, 2.0);
vec2 : Vkm_Vec4 :=
Make_Vec4(1.0, 2.0, 3.0, 4.0);
mat1 : Vkm_Mat2x4 :=
Make_Mat2x4;
mat2 : Vkm_Mat2x4 :=
Make_Mat2x4(0.0, 1.0, 2.0, 3.0,
4.0, 5.0, 6.0, 7.0);
mat3 : Vkm_Mat2x4 :=
Make_Mat2x4(vec2, - vec2);
mat4 : Vkm_Mat2x4 :=
Make_Mat2x4(mat2);
mat5 : Vkm_Mat2x2 :=
Make_Mat2x2(5.0);
mat6 : Vkm_Mat2x4 :=
Make_Mat2x4(mat5);
begin
Put_Line(LF & "Testing Mat2x4 Constructors...");
Put_Line("mat1 " & mat1.Image);
Assert_Mat2x4_Equals(mat1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Put_Line("mat2 " & mat2.Image);
Assert_Mat2x4_Equals(mat2, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0);
Put_Line("mat3 " & mat3.Image);
Assert_Mat2x4_Equals(mat3, 1.0, 2.0, 3.0, 4.0, -1.0, -2.0, -3.0, -4.0);
Put_Line("mat4 " & mat4.Image);
Assert_Mat2x4_Equals(mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0);
Put_Line("mat6 " & mat6.Image);
Assert_Mat2x4_Equals(mat6, 5.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0);
Put_Line("Testing '=' operator...");
Put_Line(" mat2 != mat3");
Assert_Vkm_Bool_Equals(mat2 = mat3, False);
Put_Line(" mat4 != mat5");
Assert_Vkm_Bool_Equals(mat4 = mat5, False);
Put_Line(" mat4 = mat2");
Assert_Vkm_Bool_Equals(mat4 = mat2, True);
Put_Line(" Testing unary '+/-' operator");
Put_Line(" + mat4 = " & Image(+ mat4));
Assert_Mat2x4_Equals(+mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0);
Put_Line(" - mat4 = " & Image(- mat4));
Assert_Mat2x4_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0);
Put_Line("+(- mat4) = " & Image(+(- mat4)));
Assert_Mat2x4_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0);
Put_Line("Testing 'abs' operator...");
Put_Line(" abs(- mat4) = " & Image(abs(-mat4)));
Assert_Mat2x4_Equals(abs(-mat4), 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0);
Put_Line("Testing '+' operator...");
Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3));
Assert_Mat2x4_Equals(mat4 + mat3, 1.0, 3.0, 5.0, 7.0, 3.0, 3.0, 3.0, 3.0);
Put_Line("Testing '-' operator...");
Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3));
Assert_Mat2x4_Equals(mat4 - mat3, -1.0, -1.0, -1.0, -1.0, 5.0, 7.0, 9.0, 11.0);
Put_Line("Testing '*' operator...");
Put_Line(" mat5 * mat4 = " & Image(mat5 * mat4));
Assert_Mat2x4_Equals(mat5 * mat4, 0.0 , 5.0 , 10.0, 15.0,
20.0, 25.0, 30.0, 35.0);
Put_Line(" mat4 * vec2 = " & Image(mat4 * vec2));
Assert_Vec2_Equals(mat4 * vec2, 20.0, 60.0);
Put_Line(" vec1 * mat4 = " & Image(vec1 * mat4));
Assert_Vec4_Equals(vec1 * mat4, 8.0, 11.0, 14.0, 17.0);
end Test_Mat2x4;
end Vulkan.Math.Mat2x4.Test;
|
BrickBot/Bound-T-H8-300 | Ada | 4,041 | adb | -- Bound_T.Opt (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.3 $
-- $Date: 2015/10/24 20:05:45 $
--
-- $Log: bound_t-opt.adb,v $
-- Revision 1.3 2015/10/24 20:05:45 niklas
-- Moved to free licence.
--
-- Revision 1.2 2011-09-01 22:15:42 niklas
-- Added Show_Licence(_Opt), registered as "-licence" and "-license".
-- Added synonym "-synonyms" for "-synonym".
--
-- Revision 1.1 2011-08-31 04:17:12 niklas
-- Added for BT-CH-0222: Option registry. Option -dump. External help files.
--
with Options.Groups;
package body Bound_T.Opt is
function Time_Image (Item : Duration) return String
is
begin
if Item = Time_Unlimited then
return "unlimited";
else
return Duration'Image (Item);
end if;
end Time_Image;
HRT_Group : constant Options.Group_Name_T := Options.Group ("hrt");
--
-- The group of options related to Hard-Real-Time modelling.
begin
Options.Register (
Option => Show_Version_Opt'access,
Name => "version",
Group => Options.Groups.Outputs);
Options.Register (
Option => Show_Host_Version_Opt'access,
Name => "host_version",
Group => Options.Groups.Outputs);
Options.Register (
Option => Show_Licence_Opt'access,
Name => "licence",
Synonym => "license",
Group => Options.Groups.Outputs);
Options.Register (
Option => Dump_Program_Opt'access,
Name => "dump",
Group => Options.Groups.Outputs);
Options.Register (
Option => HRT_Opt'access,
Name => "hrt",
Groups => (Options.Groups.Inputs, HRT_Group));
Options.Register (
Option => Time_Analysis_Opt'access,
Name => "anatime",
Group => Options.Groups.Outputs);
Options.Register (
Option => Max_Analysis_Time_Opt'access,
Name => "max_anatime",
Group => Options.Groups.Resource_Limits);
Options.Register (
Option => List_Synonyms_Opt'access,
Name => "synonym",
Synonym => "synonyms",
Group => Options.Groups.Outputs);
Options.Register (
Option => Deallocate_Opt'access,
Name => Options.Imp_Item ("dealloc"),
Groups => (Options.Groups.Imp, Options.Groups.Host_Memory));
end Bound_T.Opt;
|
reznikmm/matreshka | Ada | 3,600 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Intervals.Hash is
new AMF.Elements.Generic_Hash (UML_Interval, UML_Interval_Access);
|
albinjal/ada_basic | Ada | 2,852 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Unchecked_Deallocation;
with Person_Handling; use Person_Handling;
package body Person_Sorted_List is
procedure Free is
new Ada.Unchecked_Deallocation(Post, List_Type);
function Empty(List: List_Type)
return Boolean is
begin
return List = null;
end Empty;
procedure Insert_First(List: in out List_Type; Data: in Person) is
Temp: List_Type;
begin
Temp := List;
List := new Post;
List.Data := Data;
List.Point := Temp;
end Insert_First;
procedure Insert(List: in out List_Type; Data: in Person) is
begin
if Empty(List) then
Insert_First(List, Data);
elsif Data < List.Data then
Insert_First(List, Data);
else
Insert(List.Point, Data);
end if;
end Insert;
procedure Put(List: List_Type) is
begin
if not Empty(List) then
Put(List.all.Data);
New_Line;
Put(List.all.Point);
end if;
end Put;
function Member(List: List_Type; Search: Person)
return Boolean is
begin
if Empty(List) then
return False;
end if;
if List.Data = Search then
return True;
else
return Member(List.all.Point, Search);
end if;
end Member;
procedure RemoveCurrent(List: in out List_Type) is
Temp: List_Type;
begin
Temp := List;
List := List.Point;
Free(Temp);
end RemoveCurrent;
procedure Remove(List: in out List_Type; Search: in Person) is
begin
if Empty(List) then
raise CANTFIND_ERROR;
end if;
if List.Data = Search then
RemoveCurrent(List);
else
if List.Point = null then
raise CANTFIND_ERROR;
end if;
Remove(List.Point, Search);
end if;
end Remove;
procedure Delete(List: in out List_Type) is
begin
if List.Point = null then
Free(List);
List := null;
else
RemoveCurrent(List);
Delete(List);
end if;
end Delete;
function Find(List: List_Type; Search: Person)
return Person is
begin
if Empty(List) then
raise CANTFIND_ERROR;
end if;
if List.Data = Search then
return List.Data;
end if;
if List.Point = null then
raise CANTFIND_ERROR;
end if;
return Find(List.Point, Search);
end Find;
procedure Find(List: in List_Type; Search: in Person; Data: out Person) is
begin
Data := Find(List, Search);
end Find;
function Length(List: List_Type)
return Integer is
begin
if List.Point /= null then
return 1 + Length(List.Point);
end if;
return 1;
end Length;
end Person_Sorted_List;
|
VitalijBondarenko/adagettext | Ada | 3,962 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (c) 2014-2015 Vitalij Bondarenko <[email protected]> --
-- --
------------------------------------------------------------------------------
-- --
-- The MIT License (MIT) --
-- --
-- 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. --
------------------------------------------------------------------------------
with Ada.Strings.Unbounded.Hash;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
package body L10n_Table is
---------------------
-- Get_L10n_String --
---------------------
function Get_L10n_String
(Pattern : Pattern_Matcher; Source_Line : String) return String
is
Bracket_Index : Natural;
Minus_Index : Natural;
First : Positive;
Last : Positive;
Found : Boolean;
Result : Match_Array (0 .. 0);
begin
Match (Pattern, Source_Line, Result);
Found := not (Result (0) = No_Match);
if Found then
First := Result (0).First;
Last := Result (0).Last;
Bracket_Index := Index (Source_Line (First .. Last), "(");
Minus_Index := Index (Source_Line (First .. Last), "-");
if Bracket_Index > 0 and (Bracket_Index - Minus_Index) in 2 .. 3 then
First := Bracket_Index + 1;
elsif Minus_Index > 0 then
First := Minus_Index + 1;
end if;
return Source_Line (First .. Last);
end if;
return "";
end Get_L10n_String;
function Get_L10n_String
(Pattern : Pattern_Matcher;
Source_Line : String) return Unbounded_String is
begin
return To_Unbounded_String (Get_L10n_String (Pattern, Source_Line));
end Get_L10n_String;
function Get_L10n_String
(Pattern : Pattern_Matcher;
Source_Line : Unbounded_String) return Unbounded_String is
begin
return To_Unbounded_String
(Get_L10n_String (Pattern, To_String (Source_Line)));
end Get_L10n_String;
function Get_L10n_String
(Pattern : String;
Source_Line : String) return String is
begin
return Get_L10n_String (Compile (Pattern), Source_Line);
end Get_L10n_String;
end L10n_Table;
|
usnistgov/rcslib | Ada | 3,934 | adb | --
-- New Ada Body File starts here.
-- This file should be named nml_ex1_n_ada.adb
-- Automatically generated by NML CodeGen Java Applet.
with Nml_Msg; use Nml_Msg;
with Posemath_N_Ada; use Posemath_N_Ada;
with Cms;
-- Some standard Ada Packages we always need.
with Unchecked_Deallocation;
with Unchecked_Conversion;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
package body nml_ex1_n_ada is
-- Create some common variables and functions needed for updating Enumeration types.
-- Every NMLmsg type needs an update and an initialize function.
procedure Initialize(Msg : in out EXAMPLE_MSG) is
begin
Msg.NmlType := EXAMPLE_MSG_TYPE;
Msg.Size := EXAMPLE_MSG'Size/8;
end Initialize;
procedure Update_EXAMPLE_MSG(Cms_Ptr : in Cms.Cms_Access; Msg : in EXAMPLE_MSG_Access) is
begin
Cms.Begin_Class(Cms_Ptr,"EXAMPLE_MSG","");
Msg.NmlType := EXAMPLE_MSG_TYPE;
Msg.Size := EXAMPLE_MSG'Size/8;
Cms.Update_Double(Cms_Ptr, "d", Msg.d);
Cms.Update_C_Float(Cms_Ptr, "f", Msg.f);
Cms.Update_Char(Cms_Ptr, "c", Msg.c);
Cms.Update_Short(Cms_Ptr, "s", Msg.s);
Cms.Update_Int(Cms_Ptr, "i", Msg.i);
Cms.Update_Long(Cms_Ptr, "l", Msg.l);
Cms.Update_Unsigned_Char(Cms_Ptr, "uc", Msg.uc);
Cms.Update_Unsigned_Short(Cms_Ptr, "us", Msg.us);
Cms.Update_Unsigned(Cms_Ptr, "ui", Msg.ui);
Cms.Update_Unsigned_Long(Cms_Ptr, "ul", Msg.ul);
Cms.Update_Dla_Length(Cms_Ptr,"da_length", Msg.da_Length);
Cms.Update_Double_Dla(Cms_Ptr, "da", Msg.da,Msg.da_length,20);
Cms.End_Class(Cms_Ptr,"EXAMPLE_MSG","");
end Update_EXAMPLE_MSG;
procedure Update_Internal_EXAMPLE_MSG(Cms_Ptr : in Cms.Cms_Access; Msg : in out EXAMPLE_MSG) is
begin
Cms.Begin_Class(Cms_Ptr,"EXAMPLE_MSG","");
Msg.NmlType := EXAMPLE_MSG_TYPE;
Msg.Size := EXAMPLE_MSG'Size/8;
Cms.Update_Double(Cms_Ptr, "d", Msg.d);
Cms.Update_C_Float(Cms_Ptr, "f", Msg.f);
Cms.Update_Char(Cms_Ptr, "c", Msg.c);
Cms.Update_Short(Cms_Ptr, "s", Msg.s);
Cms.Update_Int(Cms_Ptr, "i", Msg.i);
Cms.Update_Long(Cms_Ptr, "l", Msg.l);
Cms.Update_Unsigned_Char(Cms_Ptr, "uc", Msg.uc);
Cms.Update_Unsigned_Short(Cms_Ptr, "us", Msg.us);
Cms.Update_Unsigned(Cms_Ptr, "ui", Msg.ui);
Cms.Update_Unsigned_Long(Cms_Ptr, "ul", Msg.ul);
Cms.Update_Dla_Length(Cms_Ptr,"da_length", Msg.da_Length);
Cms.Update_Double_Dla(Cms_Ptr, "da", Msg.da,Msg.da_length,20);
Cms.End_Class(Cms_Ptr,"EXAMPLE_MSG","");
end Update_Internal_EXAMPLE_MSG;
NameList : constant Char_Array(1..24) := (
'E','X','A','M','P','L','E','_','M','S','G',nul,
nul,nul,nul,nul,nul,nul,nul,nul,nul,nul,nul,nul
);
IdList : constant Cms.Long_Array(1..2) := (
EXAMPLE_MSG_TYPE, -- 101, 0
-1);
SizeList : constant Cms.Size_T_Array(1..2) := (
EXAMPLE_MSG'Size/8,
0);
Symbol_Lookup_EXAMPLE_MSG_Name : constant Interfaces.C.Strings.Chars_Ptr := Interfaces.C.Strings.New_String("EXAMPLE_MSG");
function Symbol_Lookup(Nml_Type : in long) return Interfaces.C.Strings.Chars_Ptr;
pragma Export(C,Symbol_Lookup,"ada_nml_ex1_n_ada_symbol_lookup");
function Symbol_Lookup(Nml_Type : in long) return Interfaces.C.Strings.Chars_Ptr is
begin
case Nml_Type is
when EXAMPLE_MSG_TYPE => return Symbol_Lookup_EXAMPLE_MSG_Name;
when others => return Null_Ptr;
end case;
end Symbol_Lookup;
function Format(Nml_Type : in long;
Msg : in NmlMsg_Access;
Cms_Ptr : in Cms.Cms_Access)
return int is
Checked_Nml_Type : long;
begin
Checked_Nml_Type := Cms.Check_Type_Info(Cms_Ptr,Nml_Type,
NmlMsg_Access_To_Limited_Controlled_Access(Msg),
"nml_ex1_n_ada",
Symbol_Lookup'Access,
NameList,IdList,SizeList,2,12);
if Msg = Null then
return 0;
end if;
case Checked_Nml_Type is
when EXAMPLE_MSG_TYPE => Update_EXAMPLE_MSG(Cms_Ptr, NmlMsg_to_EXAMPLE_MSG(Msg));
when others => return 0;
end case;
return 1;
end Format;
end nml_ex1_n_ada;
-- End of Ada Body file nml_ex1_n_ada.adb
|
reznikmm/matreshka | Ada | 3,684 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Unit_Attributes is
pragma Preelaborate;
type ODF_Draw_Unit_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Unit_Attribute_Access is
access all ODF_Draw_Unit_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Unit_Attributes;
|
cborao/Ada-P4-chat | Ada | 1,573 | ads |
-- Práctica 4: César Borao Moratinos (Hash_Maps_G_Open.ads)
generic
type Key_Type is private;
type Value_Type is private;
with function "=" (K1, K2: Key_Type) return Boolean;
type Hash_Range is mod <>;
with function Hash (K: Key_Type) return Hash_Range;
Max: in Natural;
package Hash_Maps_G is
type Map is limited private;
Full_Map : exception;
procedure Get (M: Map;
Key: in Key_Type;
Value: out Value_Type;
Success: out Boolean);
procedure Put (M: in out Map;
Key: Key_Type;
Value: Value_Type);
procedure Delete (M: in out Map;
Key: in Key_Type;
Success: out Boolean);
function Map_Length (M : Map) return Natural;
--
-- Cursor Interface for iterating over Map elements
--
type Cursor is limited private;
function First (M: Map) return Cursor;
procedure Next (C: in out Cursor);
function Has_Element (C: Cursor) return Boolean;
type Element_Type is record
Key: Key_Type;
Value: Value_Type;
end record;
No_Element: exception;
--Raises No_Element if Has_Element(C) = False;
function Element (C: Cursor) return Element_Type;
private
type Cell is record
Key : Key_Type;
Value : Value_Type;
Full : Boolean := False;
Deleted: Boolean := False;
end record;
type Cell_Array is array (Hash_Range) of Cell;
type Cell_Array_A is access Cell_Array;
type Map is record
P_Array: Cell_Array_A;
Length : Natural := 0;
end record;
type Cursor is record
M: Map;
Position: Hash_Range;
End_Found: Boolean:= False;
end record;
end Hash_Maps_G;
|
AdaCore/training_material | Ada | 38 | ads | protected Object
with Lock_Free is
|
dbanetto/uni | Ada | 3,264 | ads | package Exercise with
Spark_Mode is
type IntArray is array (Integer range <>) of Integer with
Predicate => IntArray'Length >= 0;
-- util function for spec
function Contains
(values : IntArray;
value : Integer) return Boolean is
(for some v of values => v = value) with
Post => Contains'Result = (for some v of values => value = v);
-- Ordered (acending) array of integers
subtype OrderedIntArray is IntArray with
Predicate =>
(for all i in OrderedIntArray'First .. OrderedIntArray'Last - 1 =>
OrderedIntArray (i) <= OrderedIntArray (i + 1));
function InArray (value : Integer; input : IntArray) return Boolean with
Post => InArray'Result =
(for some k in input'Range => value = input (k));
function FirstIndexOf
(value : Integer;
input : IntArray) return Integer with
Pre => InArray (value, input),
Post =>
(for some i in input'Range =>
-- ensure that the input has the value
value = input (i) and
-- ensure that the
i = FirstIndexOf'Result and
-- ensure that all values before the found index does not include the value
-- thus it is the first instance of the value
(for all k in 0 .. i => input (k) /= value));
function countValue
(value : Integer;
input : IntArray) return Integer is
-- use stack to store state, yippes
-- for each element we find in the list we add 1 and then add the rest
-- by recursively to the rest of the list
(if
(for some i in input'Range => i = value)
then
-- we make a sub array from the found element plus one to the end of the array
1 + (countValue(value, input (FirstIndexOf (value, input) + 1 .. input'Last)))
-- for the case of the sub array does not contain the value return 0
else 0) with
Post =>
(countValue'Result =
(if
(for some i in input'Range => i = value)
then
1 + (countValue(value, input (FirstIndexOf (value, input) + 1 .. input'Last)))
else 0));
function DeleteValue
(value : Integer;
input : in IntArray) return IntArray with
Post =>
-- check if result is a permutation of input
(for all i of DeleteValue'Result =>
countValue (i, DeleteValue'Result) = countValue (i, input)) and
-- the length of result array plus number of occurance of value in input is equal
-- to the size of the input array
DeleteValue'Result'Length + countValue(value, input) = input'Length and
-- the result does not include value
(for all i of DeleteValue'Result => i /= value);
function ContcatArray
(a : OrderedIntArray;
b : OrderedIntArray) return OrderedIntArray with
-- ensure that a is lees than b so a ordered con
Pre => (a (a'Last) <= b (b'First)),
Post => ContcatArray'Result = a & b;
function MergeArray
(a : OrderedIntArray;
b : OrderedIntArray) return OrderedIntArray with
-- check if result is a permutation of a and b
Post =>
(for all i of MergeArray'Result =>
countValue (i, MergeArray'Result) =
countValue (i, a) + countValue (i, b));
end Exercise;
|
Fabien-Chouteau/AGATE | Ada | 3,340 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, Fabien Chouteau --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with AGATE.Console; use AGATE.Console;
package body AGATE.Traces_Output is
Init_Done : Boolean := False;
----------------
-- Initialize --
----------------
procedure Initialize
(Filename : String)
is
pragma Unreferenced (Filename);
begin
Init_Done := True;
end Initialize;
--------------
-- Finalize --
--------------
procedure Finalize is null;
-----------------
-- Initialized --
-----------------
function Initialized return Boolean is
begin
return Init_Done;
end Initialized;
-----------
-- Write --
-----------
function Write
(Buffer_Address : System.Address;
Buffer_Size : Natural)
return Natural
is
Str : array (1 .. Buffer_Size) of Character
with Address => Buffer_Address;
begin
for C of Str loop
AGATE.Console.Print (C);
end loop;
return Buffer_Size;
end Write;
end AGATE.Traces_Output;
|
zhmu/ananas | Ada | 41,772 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . F I L E _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Finalization; use Ada.Finalization;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Ada.Unchecked_Deallocation;
with Interfaces.C_Streams; use Interfaces.C_Streams;
with System.Case_Util; use System.Case_Util;
with System.CRTL;
with System.OS_Lib;
with System.Soft_Links;
package body System.File_IO is
use System.File_Control_Block;
package SSL renames System.Soft_Links;
use type CRTL.size_t;
----------------------
-- Global Variables --
----------------------
Open_Files : AFCB_Ptr;
-- This points to a list of AFCB's for all open files. This is a doubly
-- linked list, with the Prev pointer of the first entry, and the Next
-- pointer of the last entry containing null. Note that this global
-- variable must be properly protected to provide thread safety.
type Temp_File_Record;
type Temp_File_Record_Ptr is access all Temp_File_Record;
type Temp_File_Record is record
File : AFCB_Ptr;
Next : aliased Temp_File_Record_Ptr;
Name : String (1 .. max_path_len + 1);
end record;
-- One of these is allocated for each temporary file created
Temp_Files : aliased Temp_File_Record_Ptr;
-- Points to list of names of temporary files. Note that this global
-- variable must be properly protected to provide thread safety.
procedure Free is new Ada.Unchecked_Deallocation
(Temp_File_Record, Temp_File_Record_Ptr);
type File_IO_Clean_Up_Type is new Limited_Controlled with null record;
-- The closing of all open files and deletion of temporary files is an
-- action that takes place at the end of execution of the main program.
-- This action is implemented using a library level object that gets
-- finalized at the end of program execution. Note that the type is
-- limited, in order to stop the compiler optimizing away the declaration
-- which would be allowed in the non-limited case.
procedure Finalize (V : in out File_IO_Clean_Up_Type);
-- This is the finalize operation that is used to do the cleanup
File_IO_Clean_Up_Object : File_IO_Clean_Up_Type;
pragma Warnings (Off, File_IO_Clean_Up_Object);
-- This is the single object of the type that triggers the finalization
-- call. Since it is at the library level, this happens just before the
-- environment task is finalized.
text_translation_required : Boolean;
for text_translation_required'Size use Character'Size;
pragma Import
(C, text_translation_required, "__gnat_text_translation_required");
-- If true, add appropriate suffix to control string for Open
-----------------------
-- Local Subprograms --
-----------------------
procedure Free_String is new Ada.Unchecked_Deallocation (String, Pstring);
subtype Fopen_String is String (1 .. 4);
-- Holds open string (longest is "w+b" & nul)
procedure Fopen_Mode
(Namestr : String;
Mode : File_Mode;
Text : Boolean;
Creat : Boolean;
Amethod : Character;
Fopstr : out Fopen_String);
-- Determines proper open mode for a file to be opened in the given Ada
-- mode. Namestr is the NUL-terminated file name. Text is true for a text
-- file and false otherwise, and Creat is true for a create call, and False
-- for an open call. The value stored in Fopstr is a nul-terminated string
-- suitable for a call to fopen or freopen. Amethod is the character
-- designating the access method from the Access_Method field of the FCB.
function Errno_Message
(Name : String;
Errno : Integer := OS_Lib.Errno) return String;
-- Return Errno_Message for Errno, with file name prepended
procedure Raise_Device_Error
(File : AFCB_Ptr;
Errno : Integer := OS_Lib.Errno);
pragma No_Return (Raise_Device_Error);
-- Clear error indication on File and raise Device_Error with an exception
-- message providing errno information.
----------------
-- Append_Set --
----------------
procedure Append_Set (File : AFCB_Ptr) is
begin
if File.Mode = Append_File then
if fseek (File.Stream, 0, SEEK_END) /= 0 then
Raise_Device_Error (File);
end if;
end if;
end Append_Set;
----------------
-- Chain_File --
----------------
procedure Chain_File (File : AFCB_Ptr) is
begin
-- Take a task lock, to protect the global data value Open_Files
SSL.Lock_Task.all;
-- Do the chaining operation locked
File.Next := Open_Files;
File.Prev := null;
Open_Files := File;
if File.Next /= null then
File.Next.Prev := File;
end if;
SSL.Unlock_Task.all;
exception
when others =>
SSL.Unlock_Task.all;
raise;
end Chain_File;
---------------------
-- Check_File_Open --
---------------------
procedure Check_File_Open (File : AFCB_Ptr) is
begin
if File = null then
raise Status_Error with "file not open";
end if;
end Check_File_Open;
-----------------------
-- Check_Read_Status --
-----------------------
procedure Check_Read_Status (File : AFCB_Ptr) is
begin
if File = null then
raise Status_Error with "file not open";
elsif File.Mode not in Read_File_Mode then
raise Mode_Error with "file not readable";
end if;
end Check_Read_Status;
------------------------
-- Check_Write_Status --
------------------------
procedure Check_Write_Status (File : AFCB_Ptr) is
begin
if File = null then
raise Status_Error with "file not open";
elsif File.Mode = In_File then
raise Mode_Error with "file not writable";
end if;
end Check_Write_Status;
-----------
-- Close --
-----------
procedure Close (File_Ptr : access AFCB_Ptr) is
Close_Status : int := 0;
Dup_Strm : Boolean := False;
Errno : Integer := 0;
File : AFCB_Ptr renames File_Ptr.all;
begin
-- Take a task lock, to protect the global variables Open_Files and
-- Temp_Files, and the chains they point to.
SSL.Lock_Task.all;
Check_File_Open (File);
AFCB_Close (File);
-- Sever the association between the given file and its associated
-- external file. The given file is left closed. Do not perform system
-- closes on the standard input, output and error files and also do not
-- attempt to close a stream that does not exist (signalled by a null
-- stream value -- happens in some error situations).
if not File.Is_System_File and then File.Stream /= NULL_Stream then
-- Do not do an fclose if this is a shared file and there is at least
-- one other instance of the stream that is open.
if File.Shared_Status = Yes then
declare
P : AFCB_Ptr;
begin
P := Open_Files;
while P /= null loop
if P /= File and then File.Stream = P.Stream then
Dup_Strm := True;
exit;
end if;
P := P.Next;
end loop;
end;
end if;
-- Do the fclose unless this was a duplicate in the shared case
if not Dup_Strm then
Close_Status := fclose (File.Stream);
if Close_Status /= 0 then
Errno := OS_Lib.Errno;
end if;
end if;
end if;
-- Dechain file from list of open files and then free the storage
if File.Prev = null then
Open_Files := File.Next;
else
File.Prev.Next := File.Next;
end if;
if File.Next /= null then
File.Next.Prev := File.Prev;
end if;
-- If it's a temp file, remove the corresponding record from Temp_Files,
-- and delete the file. There are unlikely to be large numbers of temp
-- files open, so a linear search is sufficiently efficient. Note that
-- we don't need to check for end of list, because the file must be
-- somewhere on the list. Note that as for Finalize, we ignore any
-- errors while attempting the unlink operation.
if File.Is_Temporary_File then
declare
Temp : access Temp_File_Record_Ptr := Temp_Files'Access;
-- Note the double indirection here
Discard : int;
New_Temp : Temp_File_Record_Ptr;
begin
while Temp.all.all.File /= File loop
Temp := Temp.all.all.Next'Access;
end loop;
Discard := unlink (Temp.all.all.Name'Address);
New_Temp := Temp.all.all.Next;
Free (Temp.all);
Temp.all := New_Temp;
end;
end if;
-- Deallocate some parts of the file structure that were kept in heap
-- storage with the exception of system files (standard input, output
-- and error) since they had some information allocated in the stack.
if not File.Is_System_File then
Free_String (File.Name);
Free_String (File.Form);
AFCB_Free (File);
end if;
File := null;
if Close_Status /= 0 then
Raise_Device_Error (null, Errno);
end if;
SSL.Unlock_Task.all;
exception
when others =>
SSL.Unlock_Task.all;
raise;
end Close;
------------
-- Delete --
------------
procedure Delete (File_Ptr : access AFCB_Ptr) is
File : AFCB_Ptr renames File_Ptr.all;
begin
Check_File_Open (File);
if not File.Is_Regular_File then
raise Use_Error with "cannot delete non-regular file";
end if;
declare
Filename : aliased constant String := File.Name.all;
Is_Temporary_File : constant Boolean := File.Is_Temporary_File;
begin
Close (File_Ptr);
-- Now unlink the external file. Note that we use the full name in
-- this unlink, because the working directory may have changed since
-- we did the open, and we want to unlink the right file. However, if
-- it's a temporary file, then closing it already unlinked it.
if not Is_Temporary_File then
if unlink (Filename'Address) = -1 then
raise Use_Error with OS_Lib.Errno_Message;
end if;
end if;
end;
end Delete;
-----------------
-- End_Of_File --
-----------------
function End_Of_File (File : AFCB_Ptr) return Boolean is
begin
Check_File_Open (File);
if feof (File.Stream) /= 0 then
return True;
else
Check_Read_Status (File);
if ungetc (fgetc (File.Stream), File.Stream) = EOF then
clearerr (File.Stream);
return True;
else
return False;
end if;
end if;
end End_Of_File;
-------------------
-- Errno_Message --
-------------------
function Errno_Message
(Name : String;
Errno : Integer := OS_Lib.Errno) return String
is
begin
return Name & ": " & OS_Lib.Errno_Message (Err => Errno);
end Errno_Message;
--------------
-- Finalize --
--------------
procedure Finalize (V : in out File_IO_Clean_Up_Type) is
pragma Warnings (Off, V);
Fptr1 : aliased AFCB_Ptr;
Fptr2 : AFCB_Ptr;
Discard : int;
begin
-- Take a lock to protect global Open_Files data structure
SSL.Lock_Task.all;
-- First close all open files (the slightly complex form of this loop is
-- required because Close nulls out its argument).
Fptr1 := Open_Files;
while Fptr1 /= null loop
Fptr2 := Fptr1.Next;
Close (Fptr1'Access);
Fptr1 := Fptr2;
end loop;
-- Now unlink all temporary files. We do not bother to free the blocks
-- because we are just about to terminate the program. We also ignore
-- any errors while attempting these unlink operations.
while Temp_Files /= null loop
Discard := unlink (Temp_Files.Name'Address);
Temp_Files := Temp_Files.Next;
end loop;
SSL.Unlock_Task.all;
exception
when others =>
SSL.Unlock_Task.all;
raise;
end Finalize;
-----------
-- Flush --
-----------
procedure Flush (File : AFCB_Ptr) is
begin
Check_Write_Status (File);
if fflush (File.Stream) /= 0 then
Raise_Device_Error (File);
end if;
end Flush;
----------------
-- Fopen_Mode --
----------------
-- The fopen mode to be used is shown by the following table:
-- OPEN CREATE
-- Append_File "r+" "w+"
-- In_File "r" "w+"
-- Out_File (Direct_IO, Stream_IO) "r+" [*] "w"
-- Out_File (others) "w" "w"
-- Inout_File "r+" "w+"
-- [*] Except that for Out_File, if the file exists and is a fifo (i.e. a
-- named pipe), we use "w" instead of "r+". This is necessary to make a
-- write to the fifo block until a reader is ready.
-- Note: we do not use "a" or "a+" for Append_File, since this would not
-- work in the case of stream files, where even if in append file mode,
-- you can reset to earlier points in the file. The caller must use the
-- Append_Set routine to deal with the necessary positioning.
-- Note: in several cases, the fopen mode used allows reading and writing,
-- but the setting of the Ada mode is more restrictive. For instance,
-- Create in In_File mode uses "w+" which allows writing, but the Ada mode
-- In_File will cause any write operations to be rejected with Mode_Error
-- in any case.
-- Note: for the Out_File/Open cases for other than the Direct_IO case, an
-- initial call will be made by the caller to first open the file in "r"
-- mode to be sure that it exists. The real open, in "w" mode, will then
-- destroy this file. This is peculiar, but that's what Ada semantics
-- require and the ACATS tests insist on.
-- If text file translation is required, then either "b" or "t" is appended
-- to the mode, depending on the setting of Text.
procedure Fopen_Mode
(Namestr : String;
Mode : File_Mode;
Text : Boolean;
Creat : Boolean;
Amethod : Character;
Fopstr : out Fopen_String)
is
Fptr : Positive;
function is_fifo (Path : Address) return Integer;
pragma Import (C, is_fifo, "__gnat_is_fifo");
begin
case Mode is
when In_File =>
if Creat then
Fopstr (1) := 'w';
Fopstr (2) := '+';
Fptr := 3;
else
Fopstr (1) := 'r';
Fptr := 2;
end if;
when Out_File =>
if Amethod in 'D' | 'S'
and then not Creat
and then is_fifo (Namestr'Address) = 0
then
Fopstr (1) := 'r';
Fopstr (2) := '+';
Fptr := 3;
else
Fopstr (1) := 'w';
Fptr := 2;
end if;
when Append_File
| Inout_File
=>
Fopstr (1) := (if Creat then 'w' else 'r');
Fopstr (2) := '+';
Fptr := 3;
end case;
-- If text_translation_required is true then we need to append either a
-- "t" or "b" to the string to get the right mode.
if text_translation_required then
Fopstr (Fptr) := (if Text then 't' else 'b');
Fptr := Fptr + 1;
end if;
Fopstr (Fptr) := ASCII.NUL;
end Fopen_Mode;
----------
-- Form --
----------
function Form (File : AFCB_Ptr) return String is
begin
if File = null then
raise Status_Error with "Form: file not open";
else
return File.Form.all (1 .. File.Form'Length - 1);
end if;
end Form;
------------------
-- Form_Boolean --
------------------
function Form_Boolean
(Form : String;
Keyword : String;
Default : Boolean) return Boolean
is
V1, V2 : Natural;
begin
Form_Parameter (Form, Keyword, V1, V2);
if V1 = 0 then
return Default;
elsif Form (V1) = 'y' then
return True;
elsif Form (V1) = 'n' then
return False;
else
raise Use_Error with "invalid Form";
end if;
end Form_Boolean;
------------------
-- Form_Integer --
------------------
function Form_Integer
(Form : String;
Keyword : String;
Default : Integer) return Integer
is
V1, V2 : Natural;
V : Integer;
begin
Form_Parameter (Form, Keyword, V1, V2);
if V1 = 0 then
return Default;
else
V := 0;
for J in V1 .. V2 loop
if Form (J) not in '0' .. '9' then
raise Use_Error with "invalid Form";
else
V := V * 10 + Character'Pos (Form (J)) - Character'Pos ('0');
end if;
if V > 999_999 then
raise Use_Error with "invalid Form";
end if;
end loop;
return V;
end if;
end Form_Integer;
--------------------
-- Form_Parameter --
--------------------
procedure Form_Parameter
(Form : String;
Keyword : String;
Start : out Natural;
Stop : out Natural)
is
Klen : constant Integer := Keyword'Length;
begin
for J in Form'First + Klen .. Form'Last - 1 loop
if Form (J) = '='
and then Form (J - Klen .. J - 1) = Keyword
then
Start := J + 1;
Stop := Start - 1;
while Form (Stop + 1) /= ASCII.NUL
and then Form (Stop + 1) /= ','
loop
Stop := Stop + 1;
end loop;
return;
end if;
end loop;
Start := 0;
Stop := 0;
end Form_Parameter;
-------------
-- Is_Open --
-------------
function Is_Open (File : AFCB_Ptr) return Boolean is
begin
-- We return True if the file is open, and the underlying file stream is
-- usable. In particular on Windows an application linked with -mwindows
-- option set does not have a console attached. In this case standard
-- files (Current_Output, Current_Error, Current_Input) are not created.
-- We want Is_Open (Current_Output) to return False in this case.
return File /= null and then fileno (File.Stream) /= -1;
end Is_Open;
-------------------
-- Make_Buffered --
-------------------
procedure Make_Buffered
(File : AFCB_Ptr;
Buf_Siz : Interfaces.C_Streams.size_t)
is
status : Integer;
pragma Unreferenced (status);
begin
status := setvbuf (File.Stream, Null_Address, IOFBF, Buf_Siz);
end Make_Buffered;
------------------------
-- Make_Line_Buffered --
------------------------
procedure Make_Line_Buffered
(File : AFCB_Ptr;
Line_Siz : Interfaces.C_Streams.size_t)
is
status : Integer;
pragma Unreferenced (status);
begin
status := setvbuf (File.Stream, Null_Address, IOLBF, Line_Siz);
-- No error checking???
end Make_Line_Buffered;
---------------------
-- Make_Unbuffered --
---------------------
procedure Make_Unbuffered (File : AFCB_Ptr) is
status : Integer;
pragma Unreferenced (status);
begin
status := setvbuf (File.Stream, Null_Address, IONBF, 0);
-- No error checking???
end Make_Unbuffered;
----------
-- Mode --
----------
function Mode (File : AFCB_Ptr) return File_Mode is
begin
if File = null then
raise Status_Error with "Mode: file not open";
else
return File.Mode;
end if;
end Mode;
----------
-- Name --
----------
function Name (File : AFCB_Ptr) return String is
begin
if File = null then
raise Status_Error with "Name: file not open";
else
return File.Name.all (1 .. File.Name'Length - 1);
end if;
end Name;
----------
-- Open --
----------
procedure Open
(File_Ptr : in out AFCB_Ptr;
Dummy_FCB : AFCB'Class;
Mode : File_Mode;
Name : String;
Form : String;
Amethod : Character;
Creat : Boolean;
Text : Boolean;
C_Stream : FILEs := NULL_Stream)
is
pragma Warnings (Off, Dummy_FCB);
-- Yes we know this is never assigned a value. That's intended, since
-- all we ever use of this value is the tag for dispatching purposes.
procedure Tmp_Name (Buffer : Address);
pragma Import (C, Tmp_Name, "__gnat_tmp_name");
-- Set buffer (a String address) with a temporary filename
function Get_Case_Sensitive return Integer;
pragma Import (C, Get_Case_Sensitive,
"__gnat_get_file_names_case_sensitive");
procedure Record_AFCB;
-- Create and record new AFCB into the runtime, note that the
-- implementation uses the variables below which corresponds to the
-- status of the opened file.
File_Names_Case_Sensitive : constant Boolean := Get_Case_Sensitive /= 0;
-- Set to indicate whether the operating system convention is for file
-- names to be case sensitive (e.g., in Unix, set True), or not case
-- sensitive (e.g., in Windows, set False). Declared locally to avoid
-- breaking the Preelaborate rule that disallows function calls at the
-- library level.
Stream : FILEs := C_Stream;
-- Stream which we open in response to this request
Shared : Shared_Status_Type;
-- Setting of Shared_Status field for file
Fopstr : aliased Fopen_String;
-- Mode string used in fopen call
Formstr : aliased String (1 .. Form'Length + 1);
-- Form string with ASCII.NUL appended, folded to lower case
Text_Encoding : Content_Encoding;
Tempfile : constant Boolean := Name = "" and Stream = NULL_Stream;
-- Indicates temporary file case, which is indicated by an empty file
-- name and no specified Stream.
Namelen : constant Integer := max_path_len;
-- Length required for file name, not including final ASCII.NUL.
-- Note that we used to reference L_tmpnam here, which is not reliable
-- since __gnat_tmp_name does not always use tmpnam.
Namestr : aliased String (1 .. Namelen + 1);
-- Name as given or temporary file name with ASCII.NUL appended
Fullname : aliased String (1 .. max_path_len + 1);
-- Full name (as required for Name function, and as stored in the
-- control block in the Name field) with ASCII.NUL appended.
Full_Name_Len : Integer;
-- Length of name actually stored in Fullname
Encoding : CRTL.Filename_Encoding;
-- Filename encoding specified into the form parameter
-----------------
-- Record_AFCB --
-----------------
procedure Record_AFCB is
begin
File_Ptr := AFCB_Allocate (Dummy_FCB);
-- Note that we cannot use an aggregate here as File_Ptr is a
-- class-wide access to a limited type (Root_Stream_Type).
File_Ptr.Is_Regular_File := is_regular_file (fileno (Stream)) /= 0;
File_Ptr.Is_System_File := False;
File_Ptr.Text_Encoding := Text_Encoding;
File_Ptr.Shared_Status := Shared;
File_Ptr.Access_Method := Amethod;
File_Ptr.Stream := Stream;
File_Ptr.Form := new String'(Formstr);
File_Ptr.Name := new String'(Fullname
(1 .. Full_Name_Len));
File_Ptr.Mode := Mode;
File_Ptr.Is_Temporary_File := Tempfile;
File_Ptr.Encoding := Encoding;
Chain_File (File_Ptr);
Append_Set (File_Ptr);
end Record_AFCB;
-- Start of processing for Open
begin
if File_Ptr /= null then
raise Status_Error with "file already open";
end if;
-- Acquire form string, setting required NUL terminator
Formstr (1 .. Form'Length) := Form;
Formstr (Formstr'Last) := ASCII.NUL;
-- Convert form string to lower case
for J in Formstr'Range loop
if Formstr (J) in 'A' .. 'Z' then
Formstr (J) := Character'Val (Character'Pos (Formstr (J)) + 32);
end if;
end loop;
-- Acquire setting of shared parameter
declare
V1, V2 : Natural;
begin
Form_Parameter (Formstr, "shared", V1, V2);
if V1 = 0 then
Shared := None;
elsif Formstr (V1 .. V2) = "yes" then
Shared := Yes;
elsif Formstr (V1 .. V2) = "no" then
Shared := No;
else
raise Use_Error with "invalid Form";
end if;
end;
-- Acquire setting of encoding parameter
declare
V1, V2 : Natural;
begin
Form_Parameter (Formstr, "encoding", V1, V2);
if V1 = 0 then
Encoding := CRTL.Unspecified;
elsif Formstr (V1 .. V2) = "utf8" then
Encoding := CRTL.UTF8;
elsif Formstr (V1 .. V2) = "8bits" then
Encoding := CRTL.ASCII_8bits;
else
raise Use_Error with "invalid Form";
end if;
end;
-- Acquire setting of text_translation parameter. Only needed if this is
-- a [Wide_[Wide_]]Text_IO file, in which case we default to True, but
-- if the Form says Text_Translation=No, we use binary mode, so new-line
-- will be just LF, even on Windows.
if Text then
Text_Encoding := Default_Text;
else
Text_Encoding := None;
end if;
if Text_Encoding in Text_Content_Encoding then
declare
V1, V2 : Natural;
begin
Form_Parameter (Formstr, "text_translation", V1, V2);
if V1 = 0 then
null;
elsif Formstr (V1 .. V2) = "no" then
Text_Encoding := None;
elsif Formstr (V1 .. V2) = "text"
or else Formstr (V1 .. V2) = "yes"
then
Text_Encoding := Interfaces.C_Streams.Text;
elsif Formstr (V1 .. V2) = "wtext" then
Text_Encoding := Wtext;
elsif Formstr (V1 .. V2) = "u8text" then
Text_Encoding := U8text;
elsif Formstr (V1 .. V2) = "u16text" then
Text_Encoding := U16text;
else
raise Use_Error with "invalid Form";
end if;
end;
end if;
-- If we were given a stream (call from xxx.C_Streams.Open), then set
-- the full name to the given one, and skip to end of processing.
if Stream /= NULL_Stream then
Full_Name_Len := Name'Length + 1;
Fullname (1 .. Full_Name_Len - 1) := Name;
Fullname (Full_Name_Len) := ASCII.NUL;
-- Normal case of Open or Create
else
-- If temporary file case, get temporary file name and add to the
-- list of temporary files to be deleted on exit.
if Tempfile then
if not Creat then
raise Name_Error with "opening temp file without creating it";
end if;
Tmp_Name (Namestr'Address);
if Namestr (1) = ASCII.NUL then
raise Use_Error with "invalid temp file name";
end if;
-- Normal case of non-empty name given (i.e. not a temp file)
else
if Name'Length > Namelen then
raise Name_Error with "file name too long";
end if;
Namestr (1 .. Name'Length) := Name;
Namestr (Name'Length + 1) := ASCII.NUL;
end if;
-- Get full name in accordance with the advice of RM A.8.2(22)
full_name (Namestr'Address, Fullname'Address);
if Fullname (1) = ASCII.NUL then
raise Use_Error with Errno_Message (Name);
end if;
Full_Name_Len := 1;
while Full_Name_Len < Fullname'Last
and then Fullname (Full_Name_Len) /= ASCII.NUL
loop
Full_Name_Len := Full_Name_Len + 1;
end loop;
-- Fullname is generated by calling system's full_name. The problem
-- is, full_name does nothing about the casing, so a file name
-- comparison may generally speaking not be valid on non-case-
-- sensitive systems, and in particular we get unexpected failures
-- on Windows/Vista because of this. So we use s-casuti to force
-- the name to lower case.
if not File_Names_Case_Sensitive then
To_Lower (Fullname (1 .. Full_Name_Len));
end if;
-- If Shared=None or Shared=Yes, then check for the existence of
-- another file with exactly the same full name.
if Shared /= No then
declare
P : AFCB_Ptr;
begin
-- Take a task lock to protect Open_Files
SSL.Lock_Task.all;
-- Search list of open files
P := Open_Files;
while P /= null loop
if Fullname (1 .. Full_Name_Len) = P.Name.all then
-- If we get a match, and either file has Shared=None,
-- then raise Use_Error, since we don't allow two files
-- of the same name to be opened unless they specify the
-- required sharing mode.
if Shared = None
or else P.Shared_Status = None
then
raise Use_Error with "reopening shared file";
-- If both files have Shared=Yes, then we acquire the
-- stream from the located file to use as our stream.
elsif Shared = Yes
and then P.Shared_Status = Yes
then
Stream := P.Stream;
Record_AFCB;
pragma Assert (not Tempfile);
exit;
-- Otherwise one of the files has Shared=Yes and one has
-- Shared=No. If the current file has Shared=No then all
-- is well but we don't want to share any other file's
-- stream. If the current file has Shared=Yes, we would
-- like to share a stream, but not from a file that has
-- Shared=No, so either way, we just continue the search.
else
null;
end if;
end if;
P := P.Next;
end loop;
SSL.Unlock_Task.all;
exception
when others =>
SSL.Unlock_Task.all;
raise;
end;
end if;
-- Open specified file if we did not find an existing stream,
-- otherwise we just return as there is nothing more to be done.
if Stream /= NULL_Stream then
return;
else
Fopen_Mode
(Namestr => Namestr,
Mode => Mode,
Text => Text_Encoding in Text_Content_Encoding,
Creat => Creat,
Amethod => Amethod,
Fopstr => Fopstr);
-- A special case, if we are opening (OPEN case) a file and the
-- mode returned by Fopen_Mode is not "r" or "r+", then we first
-- make sure that the file exists as required by Ada semantics.
if not Creat and then Fopstr (1) /= 'r' then
if file_exists (Namestr'Address) = 0 then
raise Name_Error with Errno_Message (Name);
end if;
end if;
-- Now open the file. Note that we use the name as given in the
-- original Open call for this purpose, since that seems the
-- clearest implementation of the intent. It would presumably
-- work to use the full name here, but if there is any difference,
-- then we should use the name used in the call.
-- Note: for a corresponding delete, we will use the full name,
-- since by the time of the delete, the current working directory
-- may have changed and we do not want to delete a different file.
Stream :=
fopen (Namestr'Address, Fopstr'Address, Encoding);
if Stream = NULL_Stream then
-- Raise Name_Error if trying to open a non-existent file.
-- Otherwise raise Use_Error.
-- Should we raise Device_Error for ENOSPC???
declare
function Is_File_Not_Found_Error
(Errno_Value : Integer) return Integer;
pragma Import
(C, Is_File_Not_Found_Error,
"__gnat_is_file_not_found_error");
-- Non-zero when the given errno value indicates a non-
-- existing file.
Errno : constant Integer := OS_Lib.Errno;
Message : constant String := Errno_Message (Name, Errno);
begin
if Is_File_Not_Found_Error (Errno) /= 0 then
raise Name_Error with Message;
else
raise Use_Error with Message;
end if;
end;
end if;
end if;
end if;
-- Stream has been successfully located or opened, so now we are
-- committed to completing the opening of the file. Allocate block on
-- heap and fill in its fields.
Record_AFCB;
if Tempfile then
-- Chain to temp file list, ensuring thread safety with a lock
begin
SSL.Lock_Task.all;
Temp_Files :=
new Temp_File_Record'
(File => File_Ptr, Name => Namestr, Next => Temp_Files);
SSL.Unlock_Task.all;
exception
when others =>
SSL.Unlock_Task.all;
raise;
end;
end if;
end Open;
------------------------
-- Raise_Device_Error --
------------------------
procedure Raise_Device_Error
(File : AFCB_Ptr;
Errno : Integer := OS_Lib.Errno)
is
begin
-- Clear error status so that the same error is not reported twice
if File /= null then
clearerr (File.Stream);
end if;
raise Device_Error with OS_Lib.Errno_Message (Err => Errno);
end Raise_Device_Error;
--------------
-- Read_Buf --
--------------
procedure Read_Buf (File : AFCB_Ptr; Buf : Address; Siz : size_t) is
Nread : size_t;
begin
Nread := fread (Buf, 1, Siz, File.Stream);
if Nread = Siz then
return;
elsif ferror (File.Stream) /= 0 then
Raise_Device_Error (File);
elsif Nread = 0 then
raise End_Error;
else -- 0 < Nread < Siz
raise Data_Error with "not enough data read";
end if;
end Read_Buf;
procedure Read_Buf
(File : AFCB_Ptr;
Buf : Address;
Siz : Interfaces.C_Streams.size_t;
Count : out Interfaces.C_Streams.size_t)
is
begin
Count := fread (Buf, 1, Siz, File.Stream);
if Count = 0 and then ferror (File.Stream) /= 0 then
Raise_Device_Error (File);
end if;
end Read_Buf;
-----------
-- Reset --
-----------
-- The reset which does not change the mode simply does a rewind
procedure Reset (File_Ptr : access AFCB_Ptr) is
File : AFCB_Ptr renames File_Ptr.all;
begin
Check_File_Open (File);
Reset (File_Ptr, File.Mode);
end Reset;
-- The reset with a change in mode is done using freopen, and is not
-- permitted except for regular files (since otherwise there is no name for
-- the freopen, and in any case it seems meaningless).
procedure Reset (File_Ptr : access AFCB_Ptr; Mode : File_Mode) is
File : AFCB_Ptr renames File_Ptr.all;
Fopstr : aliased Fopen_String;
begin
Check_File_Open (File);
-- Change of mode not allowed for shared file or file with no name or
-- file that is not a regular file, or for a system file. Note that we
-- allow the "change" of mode if it is not in fact doing a change.
if Mode /= File.Mode then
if File.Shared_Status = Yes then
raise Use_Error with "cannot change mode of shared file";
elsif File.Name'Length <= 1 then
raise Use_Error with "cannot change mode of temp file";
elsif File.Is_System_File then
raise Use_Error with "cannot change mode of system file";
elsif not File.Is_Regular_File then
raise Use_Error with "cannot change mode of non-regular file";
end if;
end if;
-- For In_File or Inout_File for a regular file, we can just do a rewind
-- if the mode is unchanged, which is more efficient than doing a full
-- reopen.
if Mode = File.Mode
and then Mode in Read_File_Mode
then
rewind (File.Stream);
-- Here the change of mode is permitted, we do it by reopening the file
-- in the new mode and replacing the stream with a new stream.
else
Fopen_Mode
(Namestr => File.Name.all,
Mode => Mode,
Text => File.Text_Encoding in Text_Content_Encoding,
Creat => False,
Amethod => File.Access_Method,
Fopstr => Fopstr);
File.Stream := freopen
(File.Name.all'Address, Fopstr'Address, File.Stream,
File.Encoding);
if File.Stream = NULL_Stream then
Close (File_Ptr);
raise Use_Error;
else
File.Mode := Mode;
Append_Set (File);
end if;
end if;
end Reset;
---------------
-- Write_Buf --
---------------
procedure Write_Buf (File : AFCB_Ptr; Buf : Address; Siz : size_t) is
begin
-- Note: for most purposes, the Siz and 1 parameters in the fwrite call
-- could be reversed, but we have encountered systems where this is a
-- better choice, since for some file formats, reversing the parameters
-- results in records of one byte each.
SSL.Abort_Defer.all;
if fwrite (Buf, Siz, 1, File.Stream) /= 1 then
if Siz /= 0 then
SSL.Abort_Undefer.all;
Raise_Device_Error (File);
end if;
end if;
SSL.Abort_Undefer.all;
end Write_Buf;
end System.File_IO;
|
reznikmm/matreshka | Ada | 3,600 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.Utp.Test_Logs.Hash is
new AMF.Elements.Generic_Hash (Utp_Test_Log, Utp_Test_Log_Access);
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 514 | adb | with STM32_SVD; use STM32_SVD;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32GD.Startup;
package body STM32GD.Board is
procedure Init is
begin
CLOCKS.Init;
RCC_Periph.APB2ENR.AFIOEN := 1;
RCC_Periph.APB2ENR.IOPAEN := 1;
RCC_Periph.APB2ENR.IOPBEN := 1;
RCC_Periph.APB2ENR.IOPCEN := 1;
RCC_Periph.APB1ENR.USART2EN := 1;
BUTTON.Init;
LED.Init;
LED2.Init;
TX.Init;
RX.Init;
USART.Init;
RTC.Init;
end Init;
end STM32GD.Board;
|
reznikmm/matreshka | Ada | 3,793 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.Constants;
package body Matreshka.ODF_Attributes.Style.Print_Orientation is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Print_Orientation_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Print_Orientation_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.Style.Print_Orientation;
|
AaronC98/PlaneSystem | Ada | 7,580 | adb | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2002-2012, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
with AWS.Resources.Streams.ZLib;
with ZLib;
package body AWS.Resources.Embedded is
type Node is record
File_Buffer : Buffer_Access;
File_Time : Calendar.Time;
end record;
package Res_Files is new Ada.Containers.Indefinite_Hashed_Maps
(String, Node, Ada.Strings.Hash, "=", "=");
Files_Table : Res_Files.Map;
procedure Append
(Stream : Streams.Stream_Access;
Data : Buffer_Access);
------------
-- Append --
------------
procedure Append
(Stream : Streams.Stream_Access;
Data : Buffer_Access) is
begin
Streams.Memory.Append
(Streams.Memory.Stream_Type (Stream.all), Data);
end Append;
------------
-- Create --
------------
procedure Create
(File : out File_Type;
Buffer : Buffer_Access)
is
Stream : Streams.Stream_Access;
begin
Stream := new Streams.Memory.Stream_Type;
Append (Stream, Buffer);
Streams.Create (File, Stream);
end Create;
-----------
-- Exist --
-----------
function Exist (Name : String) return File_Instance is
VP, VG : Boolean := False;
begin
if Is_GZip (Name) then
VG := Res_Files.Contains (Files_Table, Name);
VP := Res_Files.Contains
(Files_Table,
(Name (Name'First .. Name'Last - GZip_Ext'Length)));
else
VP := Res_Files.Contains (Files_Table, Name);
VG := Res_Files.Contains (Files_Table, Name & GZip_Ext);
end if;
if VG and then VP then
return Both;
elsif VG then
return GZip;
elsif VP then
return Plain;
else
return None;
end if;
end Exist;
---------------
-- File_Size --
---------------
function File_Size (Name : String) return Utils.File_Size_Type is
Cursor : Res_Files.Cursor;
begin
Cursor := Res_Files.Find (Files_Table, Name);
if Res_Files.Has_Element (Cursor) then
return Res_Files.Element (Cursor).File_Buffer'Length;
elsif Is_GZip (Name) then
-- Don't look for resource Name & ".gz.gz"
raise Resource_Error;
end if;
Cursor := Res_Files.Find (Files_Table, Name & GZip_Ext);
if Res_Files.Has_Element (Cursor) then
return Res_Files.Element (Cursor).File_Buffer'Length;
else
raise Resource_Error;
end if;
end File_Size;
--------------------
-- File_Timestamp --
--------------------
function File_Timestamp (Name : String) return Ada.Calendar.Time is
Cursor : Res_Files.Cursor;
begin
Cursor := Res_Files.Find (Files_Table, Name);
if Res_Files.Has_Element (Cursor) then
return Res_Files.Element (Cursor).File_Time;
elsif Is_GZip (Name) then
-- Don't look for resource Name & ".gz.gz";
raise Resource_Error;
end if;
Cursor := Res_Files.Find (Files_Table, Name & GZip_Ext);
if Res_Files.Has_Element (Cursor) then
return Res_Files.Element (Cursor).File_Time;
else
raise Resource_Error;
end if;
end File_Timestamp;
---------------------
-- Is_Regular_File --
---------------------
function Is_Regular_File (Name : String) return Boolean is
begin
return Res_Files.Contains (Files_Table, Name)
or else (not Is_GZip (Name)
and then Res_Files.Contains (Files_Table, Name & GZip_Ext));
end Is_Regular_File;
----------
-- Open --
----------
procedure Open
(File : out File_Type;
Name : String;
Form : String := "";
GZip : in out Boolean)
is
pragma Unreferenced (Form);
Stream : Streams.Stream_Access;
Found : Boolean;
procedure Open_File (Name : String);
---------------
-- Open_File --
---------------
procedure Open_File (Name : String) is
Cursor : Res_Files.Cursor;
begin
Cursor := Res_Files.Find (Files_Table, Name);
if Res_Files.Has_Element (Cursor) then
Found := True;
Stream := new Streams.Memory.Stream_Type;
Append (Stream, Res_Files.Element (Cursor).File_Buffer);
else
Found := False;
end if;
end Open_File;
begin
if Is_GZip (Name) then
-- Don't try to open file Name & ".gz.gz"
GZip := False;
Open_File (Name);
elsif GZip then
Open_File (Name & GZip_Ext);
if not Found then
Open_File (Name);
if Found then
GZip := False;
end if;
end if;
else
Open_File (Name);
if not Found then
Open_File (Name & GZip_Ext);
if Found then
Stream
:= Streams.ZLib.Inflate_Create (Stream, Header => ZLib.GZip);
end if;
end if;
end if;
Streams.Create (File, Stream);
end Open;
--------------
-- Register --
--------------
procedure Register
(Name : String;
Content : Buffer_Access;
File_Time : Calendar.Time)
is
N : constant Node := (Content, File_Time);
begin
Res_Files.Include (Files_Table, Name, N);
end Register;
end AWS.Resources.Embedded;
|
kqr/qweyboard | Ada | 906 | ads | with Configuration;
with Ada.Real_Time;
private with Unicode_Strings;
private with Qweyboard.Languages;
private with Logging;
private with Output_Backend;
package Qweyboard.Emulation is
package RT renames Ada.Real_Time;
use type RT.Time, RT.Time_Span;
task type Timer_Task;
protected Softboard is
procedure Configure (Settings : Configuration.Settings);
procedure Handle (Event : Key_Event);
entry Get_Deadline (Time : out RT.Time);
procedure Timeout;
private
Deadline : RT.Time := RT.Time_First;
Current_Timeout : RT.Time_Span;
Timer : Timer_Task;
Pressed : Key_Sets.Set;
Released : Key_Sets.Set;
Last_Output : Output;
procedure Commit;
procedure Erase;
end Softboard;
private
use Unbounded;
use Logging;
procedure Log_Board (Pressed : Key_Sets.Set; Released : Key_Sets.Set);
end Qweyboard.Emulation;
|
onox/orka | Ada | 4,332 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.glTF.Scenes is
function Create_Nodes (Nodes : Types.JSON_Value) return Natural_Vectors.Vector is
Result : Natural_Vectors.Vector;
begin
for Node of Nodes loop
Result.Append (Natural (Long_Integer'(Node.Value)));
end loop;
return Result;
end Create_Nodes;
function Get_Matrix (Matrix : Types.JSON_Value) return Transforms.Matrix4
with Pre => Matrix.Length = 16;
function Get_Matrix (Matrix : Types.JSON_Value) return Transforms.Matrix4 is
Result : Transforms.Matrix4;
begin
for I in Index_4D loop
for J in Index_4D loop
declare
Column : constant Natural := Index_4D'Pos (I) * 4;
Row : constant Natural := Index_4D'Pos (J);
begin
Result (I) (J) := Matrix.Get (Column + Row + 1).Value;
end;
end loop;
end loop;
return Result;
end Get_Matrix;
function Get_Vector3 (Vector : Types.JSON_Value) return Transforms.Vector4
with Pre => Vector.Length = 3;
function Get_Vector4 (Vector : Types.JSON_Value) return Transforms.Vector4
with Pre => Vector.Length = 4;
function Get_Vector3 (Vector : Types.JSON_Value) return Transforms.Vector4 is
((Vector.Get (1).Value, Vector.Get (2).Value, Vector.Get (3).Value, 0.0));
function Get_Vector4 (Vector : Types.JSON_Value) return Transforms.Vector4 is
((Vector.Get (1).Value, Vector.Get (2).Value, Vector.Get (3).Value, Vector.Get (4).Value));
function Create_Node (Object : Types.JSON_Value) return Node is
Transform : constant Transform_Kind
:= (if Object.Contains ("matrix") then Matrix else TRS);
begin
return Result : Node (Transform) do
Result.Name := Name_Strings.To_Bounded_String (Object.Get ("name").Value);
Result.Children.Append (Create_Nodes (Object.Get_Array_Or_Empty ("children")));
Result.Mesh := Natural_Optional (Long_Integer'(Object.Get ("mesh", Undefined).Value));
case Transform is
when Matrix =>
Result.Matrix := Get_Matrix (Object.Get ("matrix"));
when TRS =>
if Object.Contains ("translation") then
Result.Translation := Get_Vector3 (Object.Get ("translation"));
end if;
if Object.Contains ("rotation") then
Result.Rotation := Get_Vector4 (Object.Get ("rotation"));
pragma Assert (for all E of Result.Rotation => E in -1.0 .. 1.0);
end if;
if Object.Contains ("scale") then
Result.Scale := Get_Vector3 (Object.Get ("scale"));
end if;
end case;
end return;
end Create_Node;
function Get_Nodes
(Nodes : Types.JSON_Value) return Node_Vectors.Vector
is
Result : Node_Vectors.Vector (Capacity => Nodes.Length);
begin
for Node of Nodes loop
Result.Append (Create_Node (Node));
end loop;
return Result;
end Get_Nodes;
function Create_Scene
(Object : Types.JSON_Value) return Scene is
begin
return Result : Scene do
Result.Name := Name_Strings.To_Bounded_String (Object.Get ("name").Value);
Result.Nodes.Append (Create_Nodes (Object.Get ("nodes")));
end return;
end Create_Scene;
function Get_Scenes
(Scenes : Types.JSON_Value) return Scene_Vectors.Vector
is
Result : Scene_Vectors.Vector (Capacity => Scenes.Length);
begin
for Scene of Scenes loop
Result.Append (Create_Scene (Scene));
end loop;
return Result;
end Get_Scenes;
end Orka.glTF.Scenes;
|
rveenker/sdlada | Ada | 10,710 | adb | with SDL;
with SDL.Error;
with SDL.Events.Events;
with SDL.Events.Keyboards;
with SDL.Events.Joysticks;
with SDL.Events.Windows;
with SDL.Inputs.Joysticks.Makers;
with SDL.Inputs.Joysticks.Game_Controllers;
with SDL.Events.Mice;
with SDL.Log;
with SDL.Video.Displays;
with SDL.Video.Windows;
with SDL.Video.Windows.Makers;
with SDL.Video.Windows.Manager;
with SDL.Versions;
with System;
procedure Test is
W : SDL.Video.Windows.Window;
Total_Drivers : Positive := SDL.Video.Total_Drivers;
Linked_Version : SDL.Versions.Version;
begin
SDL.Log.Set (Category => SDL.Log.Application, Priority => SDL.Log.Debug);
SDL.Versions.Linked_With (Info => Linked_Version);
SDL.Log.Put_Debug ("System.Word_Size: " & Integer'Image (System.Word_Size));
SDL.Log.Put_Debug ("Revision : " & SDL.Versions.Revision);
SDL.Log.Put_Debug ("Linked with : " & SDL.Versions.Version_Level'Image (Linked_Version.Major) &
"." & SDL.Versions.Version_Level'Image (Linked_Version.Minor) &
"." & SDL.Versions.Version_Level'Image (Linked_Version.Patch));
SDL.Log.Put_Debug ("Compiled with : " & SDL.Versions.Version_Level'Image (SDL.Versions.Compiled_Major) &
"." & SDL.Versions.Version_Level'Image (SDL.Versions.Compiled_Minor) &
"." & SDL.Versions.Version_Level'Image (SDL.Versions.Compiled_Patch));
SDL.Log.Put_Debug ("Bit Order : " & System.Bit_Order'Image (SDL.Video.Windows.Window'Bit_Order));
SDL.Log.Put_Debug ("Total drivers : " & Positive'Image (Total_Drivers));
for Index in Positive'First .. Total_Drivers loop
SDL.Log.Put_Debug ("Driver (" & Positive'Image (Index) & ") : " & SDL.Video.Driver_Name (Natural (Index)));
end loop;
if SDL.Initialise = True then
SDL.Log.Put_Debug ("Current driver : " & SDL.Video.Current_Driver_Name);
SDL.Log.Put_Debug ("Total displays : " & SDL.Video.Displays.Display_Indices'Image (SDL.Video.Displays.Total));
SDL.Error.Clear;
SDL.Log.Put_Debug ("Error : " & SDL.Error.Get);
SDL.Video.Windows.Makers.Create (Win => W,
Title => "Test SDLAda 2.0 - हिन्दी समाचार",
Position => SDL.Natural_Coordinates'(X => 100, Y => 100),
Size => SDL.Positive_Sizes'(800, 640));
SDL.Log.Put_Debug ("Window Grabbed : " & Boolean'Image (W.Is_Grabbed));
-- W.Set_Grabbed;
SDL.Log.Put_Debug ("Window Grabbed : " & Boolean'Image (W.Is_Grabbed));
SDL.Log.Put_Debug ("Window ID : " & SDL.Video.Windows.ID'Image (W.Get_ID));
SDL.Log.Put_Debug ("Window Title : " & W.Get_Title);
SDL.Log.Put_Debug ("Window on display : " & SDL.Video.Displays.Display_Indices'Image (W.Display_Index));
-- W.Set_Mode (SDL.Video.Windows.Full_Screen);
declare
ID : SDL.Video.Windows.ID := SDL.Video.Windows.Get_ID (W);
W2 : SDL.Video.Windows.Window := SDL.Video.Windows.From_ID (ID);
begin
SDL.Video.Windows.Set_Title (W2, "Grabbed second window!");
end;
-- Joysticks.
declare
Total_Sticks : SDL.Inputs.Joysticks.All_Devices := SDL.Inputs.Joysticks.Total;
Stick : SDL.Inputs.Joysticks.Joystick;
GUID_1 : SDL.Inputs.Joysticks.GUIDs;
GUID_2 : SDL.Inputs.Joysticks.GUIDs;
use type SDL.Inputs.Joysticks.Devices;
use type SDL.Inputs.Joysticks.Joystick;
use type SDL.Inputs.Joysticks.GUIDs;
begin
if Total_Sticks = 0 then
SDL.Log.Put_Debug ("No Joysticks : ");
else
SDL.Log.Put_Debug ("Joystick polling: " & Boolean'Image (SDL.Events.Joysticks.Is_Polling_Enabled));
SDL.Log.Put_Debug ("Total Joysticks : " & SDL.Inputs.Joysticks.Devices'Image (Total_Sticks));
for Joystick in SDL.Inputs.Joysticks.Devices'First .. Total_Sticks loop
GUID_1 := SDL.Inputs.Joysticks.GUID (Joystick);
GUID_2 := SDL.Inputs.Joysticks.Value (SDL.Inputs.Joysticks.Image (GUID_1));
if GUID_1 = GUID_2 then
SDL.Log.Put_Debug ("GUID Image<->Value works");
end if;
SDL.Log.Put_Debug ("Joystick : (" & SDL.Inputs.Joysticks.Devices'Image (Joystick) & ") - " &
SDL.Inputs.Joysticks.Name (Joystick) & " - " &
Integer'Image (SDL.Inputs.Joysticks.GUIDs'Size) & " - GUID: " & ' ' &
SDL.Inputs.Joysticks.Image (GUID_1));
SDL.Inputs.Joysticks.Makers.Create (Device => Joystick, Actual_Stick => Stick);
if Stick /= SDL.Inputs.Joysticks.Null_Joystick then
SDL.Log.Put_Debug (" Name : " & Stick.Name);
SDL.Log.Put_Debug (" Axes : " & SDL.Events.Joysticks.Axes'Image (Stick.Axes));
SDL.Log.Put_Debug (" Balls : " & SDL.Events.Joysticks.Balls'Image (Stick.Balls));
SDL.Log.Put_Debug (" Buttons : " & SDL.Events.Joysticks.Buttons'Image (Stick.Buttons));
SDL.Log.Put_Debug (" Hats : " & SDL.Events.Joysticks.Hats'Image (Stick.Hats));
SDL.Log.Put_Debug (" Haptic : " & Boolean'Image (Stick.Is_Haptic));
SDL.Log.Put_Debug (" Attached : " & Boolean'Image (Stick.Is_Attached));
SDL.Log.Put_Debug (" GUID : " & SDL.Inputs.Joysticks.Image (Stick.GUID));
SDL.Log.Put_Debug (" Instance : " & SDL.Inputs.Joysticks.Instances'Image (Stick.Instance));
Stick.Close;
end if;
if SDL.Inputs.Joysticks.Game_Controllers.Is_Game_Controller (Joystick) = True then
SDL.Log.Put_Debug (" Is game controller : Yes");
else
SDL.Log.Put_Debug (" Is game controller : No");
end if;
end loop;
end if;
end;
-- Window manager.
declare
Info : SDL.Video.Windows.Manager.WM_Info;
begin
Info.Version := SDL.Versions.Compiled;
if SDL.Video.Windows.Manager.Get_WM_Info (W, Info) = True then
SDL.Log.Put_Debug ("Window manager in use: " & SDL.Video.Windows.Manager.WM_Types'Image (Info.Sub_System));
else
SDL.Log.Put_Debug ("Cannot get window manager info.");
SDL.Log.Put_Debug ("Error : " & SDL.Error.Get);
end if;
end;
-- Main loop.
declare
Event : SDL.Events.Events.Events;
Finished : Boolean := False;
use type SDL.Events.Event_Types;
use type SDL.Events.Keyboards.Key_Codes;
use type SDL.Events.Windows.Window_Event_ID;
begin
loop
while SDL.Events.Events.Poll (Event) loop
case Event.Common.Event_Type is
when SDL.Events.Quit =>
Finished := True;
when SDL.Events.Keyboards.Key_Up =>
SDL.Log.Put_Debug ("Key up event : " &
SDL.Events.Keyboards.Key_Codes'Image (Event.Keyboard.Key_Sym.Key_Code) &
" Scan code: " &
SDL.Events.Keyboards.Scan_Codes'Image (Event.Keyboard.Key_Sym.Scan_Code));
if Event.Keyboard.Key_Sym.Key_Code = SDL.Events.Keyboards.Code_Escape then
Finished := True;
end if;
when SDL.Events.Joysticks.Axis_Motion =>
SDL.Log.Put_Debug
("Joystick axis event (ID = " & SDL.Events.Joysticks.IDs'Image (Event.Joystick_Axis.Which) &
"): Axis: " & SDL.Events.Joysticks.Axes'Image (Event.Joystick_Axis.Axis) &
" Value: " & SDL.Events.Joysticks.Axes_Values'Image (Event.Joystick_Axis.Value));
when SDL.Events.Mice.Motion =>
SDL.Log.Put_Debug
("Mouse motion event (ID = " & SDL.Events.Mice.IDs'Image (Event.Mouse_Motion.Which) &
"): (X => " & SDL.Coordinate'Image (Event.Mouse_Motion.X) &
"): (Y => " & SDL.Coordinate'Image (Event.Mouse_Motion.Y) &
"): (X Rel => " & SDL.Events.Mice.Movement_Values'Image (Event.Mouse_Motion.X_Relative) &
", Y Rel => " & SDL.Events.Mice.Movement_Values'Image (Event.Mouse_Motion.Y_Relative) &
")");
when SDL.Events.Mice.Button_Up | SDL.Events.Mice.Button_Down =>
SDL.Log.Put_Debug
("Mouse button event (ID = " & SDL.Events.Mice.IDs'Image (Event.Mouse_Motion.Which) &
"): Button = " & SDL.Events.Mice.Buttons'Image (Event.Mouse_Button.Button) &
" State: " & SDL.Events.Button_State'Image (Event.Mouse_Button.State) &
" Clicks: " & SDL.Events.Mice.Button_Clicks'Image (Event.Mouse_Button.Clicks) &
" (X => " & SDL.Coordinate'Image (Event.Mouse_Button.X) &
", Y => " & SDL.Coordinate'Image (Event.Mouse_Button.Y) &
")");
when SDL.Events.Mice.Wheel =>
SDL.Log.Put_Debug
("Mouse wheel event (ID = " & SDL.Events.Mice.IDs'Image (Event.Mouse_Wheel.Which) &
"): (X => " & SDL.Events.Mice.Wheel_Values'Image (Event.Mouse_Wheel.X) &
"): (Y => " & SDL.Events.Mice.Wheel_Values'Image (Event.Mouse_Wheel.Y) &
"): (Direction => " & SDL.Events.Mice.Wheel_Directions'Image (Event.Mouse_Wheel.Direction) &
")");
when SDL.Events.Windows.Window =>
if Event.Window.Event_ID = SDL.Events.Windows.Moved then
SDL.Log.Put_Debug ("Window on display : " &
SDL.Video.Displays.Display_Indices'Image (W.Display_Index));
end if;
when others =>
null;
end case;
end loop;
exit when Finished;
end loop;
end;
W.Finalize;
SDL.Finalise;
end if;
end Test;
|
AdaCore/libadalang | Ada | 199 | adb | procedure Testloop is
type My_Int is range Integer'First .. Integer'Last;
B : My_Int;
begin
for J in My_Int'Range loop
B := J;
pragma Test_Statement;
end loop;
end Testloop;
|
reznikmm/matreshka | Ada | 3,416 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017, 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 WUI.Slots is
pragma Preelaborate (WUI.Slots);
end WUI.Slots;
|
reznikmm/matreshka | Ada | 5,295 | 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.Standard_Profile_L2.Files.Collections is
pragma Preelaborate;
package Standard_Profile_L2_File_Collections is
new AMF.Generic_Collections
(Standard_Profile_L2_File,
Standard_Profile_L2_File_Access);
type Set_Of_Standard_Profile_L2_File is
new Standard_Profile_L2_File_Collections.Set with null record;
Empty_Set_Of_Standard_Profile_L2_File : constant Set_Of_Standard_Profile_L2_File;
type Ordered_Set_Of_Standard_Profile_L2_File is
new Standard_Profile_L2_File_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Standard_Profile_L2_File : constant Ordered_Set_Of_Standard_Profile_L2_File;
type Bag_Of_Standard_Profile_L2_File is
new Standard_Profile_L2_File_Collections.Bag with null record;
Empty_Bag_Of_Standard_Profile_L2_File : constant Bag_Of_Standard_Profile_L2_File;
type Sequence_Of_Standard_Profile_L2_File is
new Standard_Profile_L2_File_Collections.Sequence with null record;
Empty_Sequence_Of_Standard_Profile_L2_File : constant Sequence_Of_Standard_Profile_L2_File;
private
Empty_Set_Of_Standard_Profile_L2_File : constant Set_Of_Standard_Profile_L2_File
:= (Standard_Profile_L2_File_Collections.Set with null record);
Empty_Ordered_Set_Of_Standard_Profile_L2_File : constant Ordered_Set_Of_Standard_Profile_L2_File
:= (Standard_Profile_L2_File_Collections.Ordered_Set with null record);
Empty_Bag_Of_Standard_Profile_L2_File : constant Bag_Of_Standard_Profile_L2_File
:= (Standard_Profile_L2_File_Collections.Bag with null record);
Empty_Sequence_Of_Standard_Profile_L2_File : constant Sequence_Of_Standard_Profile_L2_File
:= (Standard_Profile_L2_File_Collections.Sequence with null record);
end AMF.Standard_Profile_L2.Files.Collections;
|
optikos/oasis | Ada | 4,219 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Unknown_Discriminant_Parts;
with Program.Element_Visitors;
package Program.Nodes.Unknown_Discriminant_Parts is
pragma Preelaborate;
type Unknown_Discriminant_Part is
new Program.Nodes.Node
and Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part
and Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part_Text
with private;
function Create
(Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Box_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Unknown_Discriminant_Part;
type Implicit_Unknown_Discriminant_Part is
new Program.Nodes.Node
and Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part
with private;
function Create
(Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Unknown_Discriminant_Part
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Unknown_Discriminant_Part is
abstract new Program.Nodes.Node
and Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part
with null record;
procedure Initialize
(Self : aliased in out Base_Unknown_Discriminant_Part'Class);
overriding procedure Visit
(Self : not null access Base_Unknown_Discriminant_Part;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Is_Unknown_Discriminant_Part_Element
(Self : Base_Unknown_Discriminant_Part)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Unknown_Discriminant_Part)
return Boolean;
type Unknown_Discriminant_Part is
new Base_Unknown_Discriminant_Part
and Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part_Text
with record
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Box_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Unknown_Discriminant_Part_Text
(Self : aliased in out Unknown_Discriminant_Part)
return Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part_Text_Access;
overriding function Left_Bracket_Token
(Self : Unknown_Discriminant_Part)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Box_Token
(Self : Unknown_Discriminant_Part)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Right_Bracket_Token
(Self : Unknown_Discriminant_Part)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Unknown_Discriminant_Part is
new Base_Unknown_Discriminant_Part
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Unknown_Discriminant_Part_Text
(Self : aliased in out Implicit_Unknown_Discriminant_Part)
return Program.Elements.Unknown_Discriminant_Parts
.Unknown_Discriminant_Part_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Unknown_Discriminant_Part)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Unknown_Discriminant_Part)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Unknown_Discriminant_Part)
return Boolean;
end Program.Nodes.Unknown_Discriminant_Parts;
|
charlie5/lace | Ada | 2,274 | adb | with
gel.Window.sdl,
gel.Applet.gui_world,
gel.Forge,
gel.Sprite,
openGL.Palette,
openGL.Model.text.lit_colored,
Physics;
pragma unreferenced (gel.Window.sdl);
procedure launch_text_sprite_Demo
--
-- Shows a few text sprites.
--
is
use gel.Math,
openGL.Palette;
the_Applet : constant gel.Applet.gui_World.view := gel.forge.new_gui_Applet ("text sprite Demo",
space_Kind => physics.Bullet);
the_Text_1 : constant gel.Sprite.view := gel.forge.new_text_Sprite (the_Applet.gui_World,
Origin_3D,
"Howdy",
the_Applet.Font,
Green);
the_Text_2 : constant gel.Sprite.view := gel.forge.new_text_Sprite (the_Applet.gui_World,
Origin_3D,
"Doody",
the_Applet.Font,
Green);
text_1_Model : constant openGL.Model.text.lit_colored.view
:= openGL.Model.text.lit_colored.view (the_Text_1.graphics_Model);
begin
the_Applet.gui_Camera.Site_is ([0.0, 0.0, 50.0]); -- Position the camera.
the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboards.
the_Applet.gui_World.add (the_Text_1);
the_Applet.gui_World.add (the_Text_2);
the_Text_2.Site_is ([0.0, 10.0, 0.0]);
while the_Applet.is_open
loop
if text_1_Model.Text = "Yay"
then
text_1_Model.Text_is ("Howdy");
else
text_1_Model.Text_is ("Yay");
end if;
the_Applet.gui_World.evolve;
the_Applet.freshen; -- Handle any new events and update the screen.
delay 0.5;
end loop;
the_Applet.destroy;
end launch_text_sprite_Demo;
|
osannolik/ada-canopen | Ada | 2,906 | ads | with Interfaces;
private with Interfaces.C;
private with System;
package SocketCAN is
-- Ada binding for the SocketCAN driver included in Linux Kernel > 2.6.25.
-- https://www.kernel.org/doc/Documentation/networking/can.txt
--
-- Note: This binding is incomplete!
-- Interfaces CAN_RAW socket with CAN 2.0A standard frame format.
-- The other protocols (and FD) should be easy to add though.
--
-- Adding e.g. a virtual CAN interface (vcan):
-- $ sudo modprobe vcan
-- $ sudo ip link add dev vcan0 type vcan
-- $ sudo ip link set up vcan0
type Socket_Type is private;
type Protocol_Type is
(RAW, -- RAW sockets
BCM, -- Broadcast Manager
TP16, -- VAG Transport Protocol v1.6
TP20, -- VAG Transport Protocol v2.0
MCNET, -- Bosch MCNet
ISOTP, -- ISO 15765-2 Transport Protocol
J1939, -- SAE J1939
NPROTO);
Is_Implemented : constant array (Protocol_Type) of Boolean :=
(RAW => True,
BCM | TP16 | TP20 | MCNET | ISOTP | J1939 | NPROTO => False);
type Frame_Id_Type is mod 2**11;
subtype Dlc_Type is Natural range 0 .. 8;
subtype Frame_Data_Type is Interfaces.Unsigned_8;
type Frame_Data is array (0 .. 7) of Frame_Data_Type;
type Can_Frame is record
Can_Id : Frame_Id_Type;
Rtr : Boolean;
Dlc : Dlc_Type;
Data : Frame_Data;
end record;
SocketCAN_Error : exception;
function Create_Socket (Protocol : Protocol_Type := RAW) return Socket_Type
with Pre => Is_Implemented (Protocol);
procedure Bind_Socket
(Socket : in Socket_Type;
Name : in String := "can0");
procedure Close_Socket
(Socket : in Socket_Type);
procedure Send_Socket
(Socket : in Socket_Type;
Frame : in Can_Frame);
procedure Receive_Socket_Blocking
(Socket : in Socket_Type;
Frame : out Can_Frame);
function Is_Frame_Pending
(Socket : Socket_Type)
return Boolean;
private
type Socket_Type is new Integer;
package C renames Interfaces.C;
function C_Name_To_Index (Name : C.char_array) return C.int;
pragma Import (C, C_Name_To_Index, "if_nametoindex");
function C_Write
(S : C.int;
Msg : System.Address;
Len : C.int) return C.int;
pragma Import (C, C_Write, "write");
function C_Read
(S : C.int;
Msg : System.Address;
Len : C.int) return C.int;
pragma Import (C, C_Read, "read");
type Poll_Fd is record
Fd : C.int;
Events : C.short;
Revents : C.short;
end record;
pragma Convention (C, Poll_Fd);
subtype Nfds is C.unsigned_long;
function C_Poll
(Fds : System.Address;
N_Fds : Nfds;
Timeout : C.int) return C.int;
pragma Import (C, C_Poll, "poll");
end SocketCAN;
|
reznikmm/matreshka | Ada | 6,740 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Note_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Note_Element_Node is
begin
return Self : Text_Note_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Note_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Note
(ODF.DOM.Text_Note_Elements.ODF_Text_Note_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Note_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Note_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Note_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Note
(ODF.DOM.Text_Note_Elements.ODF_Text_Note_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Note_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Note
(Visitor,
ODF.DOM.Text_Note_Elements.ODF_Text_Note_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Note_Element,
Text_Note_Element_Node'Tag);
end Matreshka.ODF_Text.Note_Elements;
|
silky/synth | Ada | 4,258 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with JohnnyText;
with Display;
with Unix;
package PortScan.Buildcycle is
cycle_log_error : exception;
cycle_cmd_error : exception;
procedure initialize (test_mode : Boolean; jail_env : JT.Text);
-- Expose for overall build log
function log_duration (start, stop : CAL.Time) return String;
function elapsed_now return String;
function elapsed_build (id : builders) return String;
-- Was private, but expose so Pilot can use it.
function generic_system_command (command : String) return JT.Text;
-- Simple time calculation
function get_packages_per_hour (packages_done : Natural;
from_when : CAL.Time)
return Natural;
-- records the current length of the build log.
procedure set_log_lines (id : builders);
-- Returns "True" when afterphase string matches a legal phase name.
-- Allowed phases: extract/patch/configure/build/stage/install/deinstall
function valid_test_phase (afterphase : String) return Boolean;
private
type execution_limit is range 1 .. 720;
type trackrec is
record
seq_id : port_id;
head_time : CAL.Time;
tail_time : CAL.Time;
log_handle : aliased TIO.File_Type;
dynlink : string_crate.Vector;
loglines : Natural := 0;
end record;
type dim_trackers is array (builders) of trackrec;
trackers : dim_trackers;
uname_mrv : JT.Text;
customenv : JT.Text;
slave_env : JT.Text;
testing : Boolean;
lock_localbase : Boolean;
uselog : constant Boolean := True;
discerr : constant String := "Discovery error";
selftest : constant String := "SELFTEST";
function initialize_log (id : builders) return Boolean;
procedure finalize_log (id : builders);
function get_environment (id : builders) return String;
function get_root (id : builders) return String;
function get_options_configuration (id : builders) return String;
procedure set_uname_mrv;
function split_collection (line : JT.Text; title : String) return String;
function get_port_variables (id : builders) return JT.Text;
procedure dump_port_variables (id : builders; content : JT.Text);
function log_name (sid : port_id) return String;
function dump_file (filename : String) return String;
function dump_make_conf (id : builders; conf_file : String) return String;
function log_section (title : String; header : Boolean) return String;
procedure log_phase_end (id : builders);
procedure log_phase_begin (phase : String; id : builders);
function generic_execute (id : builders; command : String;
dogbite : out Boolean;
time_limit : execution_limit) return Boolean;
procedure stack_linked_libraries (id : builders; base, filename : String);
procedure log_linked_libraries (id : builders);
procedure mark_file_system (id : builders; action : String);
procedure interact_with_builder (id : builders);
procedure obtain_custom_environment;
function elapsed_HH_MM_SS (start, stop : CAL.Time) return String;
function environment_override (enable_tty : Boolean := False) return String;
function format_loglines (numlines : Natural) return String;
function timeout_multiplier_x10 return Positive;
function detect_leftovers_and_MIA (id : builders; action : String;
description : String) return Boolean;
-- This is designed to be used twice; once with lock=True and again
-- with lock=False. It's a diagnostic mechanism and effectively sets
-- /usr/local inside a slave as read-only
procedure set_localbase_protection (id : builders; lock : Boolean);
-- Compile status of builder for the curses display (guts)
function builder_status_core (id : builders;
shutdown : Boolean := False;
idle : Boolean := False;
phasestr : String)
return Display.builder_rec;
end PortScan.Buildcycle;
|
stcarrez/ada-security | Ada | 13,412 | adb | -----------------------------------------------------------------------
-- security-policies-roles -- Role based policies
-- Copyright (C) 2010, 2011, 2012, 2017, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with Util.Serialize.Mappers.Record_Mapper;
with Util.Strings.Tokenizers;
with Util.Strings.Builders;
with Security.Controllers;
with Security.Controllers.Roles;
package body Security.Policies.Roles is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.Policies.Roles");
-- ------------------------------
-- Set the roles which are assigned to the user in the security context.
-- The role policy will use these roles to verify a permission.
-- ------------------------------
procedure Set_Role_Context (Context : in out Security.Contexts.Security_Context'Class;
Roles : in Role_Map) is
Policy : constant Security.Policies.Policy_Access := Context.Get_Policy (NAME);
Data : Role_Policy_Context_Access;
begin
if Policy = null then
Log.Error ("There is no security policy: " & NAME);
end if;
Data := new Role_Policy_Context;
Data.Roles := Roles;
Context.Set_Policy_Context (Policy, Data.all'Access);
end Set_Role_Context;
-- ------------------------------
-- Set the roles which are assigned to the user in the security context.
-- The role policy will use these roles to verify a permission.
-- ------------------------------
procedure Set_Role_Context (Context : in out Security.Contexts.Security_Context'Class;
Roles : in String) is
Policy : constant Security.Policies.Policy_Access := Context.Get_Policy (NAME);
Data : Role_Policy_Context_Access;
Map : Role_Map;
begin
if Policy = null then
Log.Error ("There is no security policy: " & NAME);
end if;
Role_Policy'Class (Policy.all).Set_Roles (Roles, Map);
Data := new Role_Policy_Context;
Data.Roles := Map;
Context.Set_Policy_Context (Policy, Data.all'Access);
end Set_Role_Context;
-- ------------------------------
-- Get the policy name.
-- ------------------------------
overriding
function Get_Name (From : in Role_Policy) return String is
pragma Unreferenced (From);
begin
return NAME;
end Get_Name;
-- ------------------------------
-- Get the role name.
-- ------------------------------
function Get_Role_Name (Manager : in Role_Policy;
Role : in Role_Type) return String is
use type Ada.Strings.Unbounded.String_Access;
begin
if Manager.Names (Role) = null then
return "";
else
return Manager.Names (Role).all;
end if;
end Get_Role_Name;
-- ------------------------------
-- Get the roles that grant the given permission.
-- ------------------------------
function Get_Grants (Manager : in Role_Policy;
Permission : in Permissions.Permission_Index) return Role_Map is
begin
return Manager.Grants (Permission);
end Get_Grants;
-- ------------------------------
-- Get the number of roles set in the map.
-- ------------------------------
function Get_Count (Map : in Role_Map) return Natural is
Count : Natural := 0;
begin
for R of Map loop
if R then
Count := Count + 1;
end if;
end loop;
return Count;
end Get_Count;
-- ------------------------------
-- Return the list of role names separated by ','.
-- ------------------------------
function To_String (List : in Role_Name_Array) return String is
use type Ada.Strings.Unbounded.String_Access;
Buf : Util.Strings.Builders.Builder (Len => 256);
Need_Colon : Boolean := False;
begin
for Name of List loop
if Name /= null then
if Need_Colon then
Util.Strings.Builders.Append (Buf, ",");
end if;
Util.Strings.Builders.Append (Buf, Name.all);
Need_Colon := True;
end if;
end loop;
return Util.Strings.Builders.To_Array (Buf);
end To_String;
-- ------------------------------
-- Get the list of role names that are defined by the role map.
-- ------------------------------
function Get_Role_Names (Manager : in Role_Policy;
Map : in Role_Map) return Role_Name_Array is
Result : Role_Name_Array (1 .. Get_Count (Map));
Pos : Positive := 1;
begin
for Role in Map'Range loop
if Map (Role) then
Result (Pos) := Manager.Names (Role);
Pos := Pos + 1;
end if;
end loop;
return Result;
end Get_Role_Names;
-- ------------------------------
-- Find the role type associated with the role name identified by <b>Name</b>.
-- Raises <b>Invalid_Name</b> if there is no role type.
-- ------------------------------
function Find_Role (Manager : in Role_Policy;
Name : in String) return Role_Type is
use type Ada.Strings.Unbounded.String_Access;
begin
Log.Debug ("Searching role {0}", Name);
for I in Role_Type'First .. Manager.Next_Role loop
exit when Manager.Names (I) = null;
if Name = Manager.Names (I).all then
return I;
end if;
end loop;
Log.Debug ("Role {0} not found", Name);
raise Invalid_Name;
end Find_Role;
-- ------------------------------
-- Create a role
-- ------------------------------
procedure Create_Role (Manager : in out Role_Policy;
Name : in String;
Role : out Role_Type) is
begin
Role := Manager.Next_Role;
Log.Info ("Role {0} is {1}", Name, Role_Type'Image (Role));
if Manager.Next_Role = Role_Type'Last then
Log.Error ("Too many roles allocated. Number of roles is {0}",
Role_Type'Image (Role_Type'Last));
else
Manager.Next_Role := Manager.Next_Role + 1;
end if;
Manager.Names (Role) := new String '(Name);
end Create_Role;
-- ------------------------------
-- Get or build a permission type for the given name.
-- ------------------------------
procedure Add_Role_Type (Manager : in out Role_Policy;
Name : in String;
Result : out Role_Type) is
begin
Result := Manager.Find_Role (Name);
exception
when Invalid_Name =>
Manager.Create_Role (Name, Result);
end Add_Role_Type;
-- ------------------------------
-- Set the roles specified in the <tt>Roles</tt> parameter. Each role is represented by
-- its name and multiple roles are separated by ','.
-- Raises Invalid_Name if a role was not found.
-- ------------------------------
procedure Set_Roles (Manager : in Role_Policy;
Roles : in String;
Into : out Role_Map) is
procedure Process (Role : in String;
Done : out Boolean);
procedure Process (Role : in String;
Done : out Boolean) is
begin
Into (Manager.Find_Role (Role)) := True;
Done := False;
end Process;
begin
Into := (others => False);
Util.Strings.Tokenizers.Iterate_Tokens (Content => Roles,
Pattern => ",",
Process => Process'Access,
Going => Ada.Strings.Forward);
end Set_Roles;
type Config_Fields is (FIELD_NAME, FIELD_ROLE, FIELD_ROLE_PERMISSION, FIELD_ROLE_NAME);
procedure Set_Member (Into : in out Role_Policy'Class;
Field : in Config_Fields;
Value : in Util.Beans.Objects.Object);
-- ------------------------------
-- Called while parsing the XML policy file when the <name>, <role> and <role-permission>
-- XML entities are found. Create the new permission when the complete permission definition
-- has been parsed and save the permission in the security manager.
-- ------------------------------
procedure Set_Member (Into : in out Role_Policy'Class;
Field : in Config_Fields;
Value : in Util.Beans.Objects.Object) is
use Security.Controllers.Roles;
begin
case Field is
when FIELD_NAME =>
Into.Name := Value;
when FIELD_ROLE =>
declare
Role : constant String := Util.Beans.Objects.To_String (Value);
begin
Into.Roles (Into.Count + 1) := Into.Find_Role (Role);
Into.Count := Into.Count + 1;
exception
when Invalid_Name =>
raise Util.Serialize.Mappers.Field_Error with "Invalid role: " & Role;
end;
when FIELD_ROLE_PERMISSION =>
if Into.Count = 0 then
raise Util.Serialize.Mappers.Field_Error with "Missing at least one role";
end if;
declare
Name : constant String := Util.Beans.Objects.To_String (Into.Name);
Perm : Role_Controller_Access;
Index : Permission_Index;
begin
Security.Permissions.Add_Permission (Name, Index);
for I in 1 .. Into.Count loop
Into.Grants (Index) (Into.Roles (I)) := True;
end loop;
if not Into.Manager.Has_Controller (Index) then
Perm := new Role_Controller '(Count => Into.Count,
Roles => Into.Roles (1 .. Into.Count));
Into.Manager.Add_Permission (Name, Perm.all'Access);
end if;
Into.Count := 0;
end;
when FIELD_ROLE_NAME =>
declare
Name : constant String := Util.Beans.Objects.To_String (Value);
Role : Role_Type;
begin
Into.Add_Role_Type (Name, Role);
end;
end case;
end Set_Member;
package Config_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Role_Policy'Class,
Element_Type_Access => Role_Policy_Access,
Fields => Config_Fields,
Set_Member => Set_Member);
Role_Mapper : aliased Config_Mapper.Mapper;
-- ------------------------------
-- Setup the XML parser to read the <b>role-permission</b> description.
-- ------------------------------
overriding
procedure Prepare_Config (Policy : in out Role_Policy;
Mapper : in out Util.Serialize.Mappers.Processing) is
begin
Mapper.Add_Mapping ("policy-rules", Role_Mapper'Access);
Mapper.Add_Mapping ("module", Role_Mapper'Access);
Config_Mapper.Set_Context (Mapper, Policy'Unchecked_Access);
end Prepare_Config;
-- ------------------------------
-- Finalize the policy manager.
-- ------------------------------
overriding
procedure Finalize (Policy : in out Role_Policy) is
use type Ada.Strings.Unbounded.String_Access;
begin
for I in Policy.Names'Range loop
exit when Policy.Names (I) = null;
Ada.Strings.Unbounded.Free (Policy.Names (I));
end loop;
end Finalize;
-- ------------------------------
-- Get the role policy associated with the given policy manager.
-- Returns the role policy instance or null if it was not registered in the policy manager.
-- ------------------------------
function Get_Role_Policy (Manager : in Security.Policies.Policy_Manager'Class)
return Role_Policy_Access is
Policy : constant Security.Policies.Policy_Access := Manager.Get_Policy (NAME);
begin
if Policy = null or else not (Policy.all in Role_Policy'Class) then
return null;
else
return Role_Policy'Class (Policy.all)'Access;
end if;
end Get_Role_Policy;
begin
Role_Mapper.Add_Mapping ("role-permission", FIELD_ROLE_PERMISSION);
Role_Mapper.Add_Mapping ("role-permission/name", FIELD_NAME);
Role_Mapper.Add_Mapping ("role-permission/role", FIELD_ROLE);
Role_Mapper.Add_Mapping ("security-role/role-name", FIELD_ROLE_NAME);
end Security.Policies.Roles;
|
reznikmm/matreshka | Ada | 4,011 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Chart_Style_Name_Attributes;
package Matreshka.ODF_Chart.Style_Name_Attributes is
type Chart_Style_Name_Attribute_Node is
new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node
and ODF.DOM.Chart_Style_Name_Attributes.ODF_Chart_Style_Name_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Style_Name_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Chart_Style_Name_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Chart.Style_Name_Attributes;
|
persan/advent-of-code-2020 | Ada | 57 | ads | package Adventofcode.Day_14 is
end Adventofcode.Day_14;
|
zhmu/ananas | Ada | 3,906 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . A T O M I C _ C O U N T E R S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2011-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 is version of the package, for use on platforms where this capability
-- is not supported. All Atomic_Counter operations raises Program_Error,
-- Atomic_Unsigned operations processed in non-atomic manner.
package body System.Atomic_Counters is
---------------
-- Decrement --
---------------
function Decrement (Item : in out Atomic_Counter) return Boolean is
begin
raise Program_Error;
return False;
end Decrement;
function Decrement (Item : aliased in out Atomic_Unsigned) return Boolean is
begin
-- Could not use Item := Item - 1; because it is disabled in spec.
Item := Atomic_Unsigned'Pred (Item);
return Item = 0;
end Decrement;
procedure Decrement (Item : aliased in out Atomic_Unsigned) is
begin
Item := Atomic_Unsigned'Pred (Item);
end Decrement;
---------------
-- Increment --
---------------
procedure Increment (Item : in out Atomic_Counter) is
begin
raise Program_Error;
end Increment;
procedure Increment (Item : aliased in out Atomic_Unsigned) is
begin
Item := Atomic_Unsigned'Succ (Item);
end Increment;
----------------
-- Initialize --
----------------
procedure Initialize (Item : out Atomic_Counter) is
begin
raise Program_Error;
end Initialize;
------------
-- Is_One --
------------
function Is_One (Item : Atomic_Counter) return Boolean is
begin
raise Program_Error;
return False;
end Is_One;
end System.Atomic_Counters;
|
jwarwick/aoc_2020 | Ada | 169 | ads | -- AOC 2020, Day 22
package Day is
function combat(filename : in String) return Natural;
function recursive_combat(filename : in String) return Natural;
end Day;
|
reznikmm/matreshka | Ada | 4,535 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.C_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_C_Attribute_Node is
begin
return Self : Text_C_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_C_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.C_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.C_Attribute,
Text_C_Attribute_Node'Tag);
end Matreshka.ODF_Text.C_Attributes;
|
AdaCore/langkit | Ada | 916 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libfoolang.Analysis; use Libfoolang.Analysis;
with Libfoolang.Rewriting; use Libfoolang.Rewriting;
procedure Main is
Buffer : constant String := "(a, )";
Ctx : constant Analysis_Context := Create_Context;
U : constant Analysis_Unit := Get_From_Buffer
(Ctx, "main.txt", Buffer => Buffer);
begin
Put_Line ("main.adb: starting...");
if Has_Diagnostics (U) then
raise Program_Error;
end if;
declare
RH : Rewriting_Handle := Start_Rewriting (Ctx);
Dummy_URH : constant Unit_Rewriting_Handle := Handle (U);
R : constant Apply_Result := Apply (RH);
begin
if not R.Success then
Abort_Rewriting (RH);
raise Program_Error;
end if;
end;
Put_Line (Image (U.Text));
New_Line;
Put_Line ("main.adb: done.");
end Main;
|
reznikmm/matreshka | Ada | 3,699 | 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.Svg_Panose_1_Attributes is
pragma Preelaborate;
type ODF_Svg_Panose_1_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_Panose_1_Attribute_Access is
access all ODF_Svg_Panose_1_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_Panose_1_Attributes;
|
faelys/natools | Ada | 1,296 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with HMAC.Main;
with Natools.GNAT_HMAC.SHA1;
procedure HMAC.SHA1 is new HMAC.Main (Natools.GNAT_HMAC.SHA1);
|
reznikmm/matreshka | Ada | 4,788 | adb |
with Command_Line_Interface; use Command_Line_Interface;
with String_Pkg; use String_Pkg;
--VAX with Vms_Lib;
separate (Ayacc.Initialize)
procedure Get_Arguments (File : out String_Type;
C_Lex : out Switch;
Debug : out Switch;
Summary : out Switch;
Verbose : out Switch;
-- UMASS CODES :
Error_Recovery : out Switch;
-- END OF UMASS CODES.
Extension : out String_Type) is
C_Lex_Argument : String_Type;
Debug_Argument : String_Type;
Summary_Argument : String_Type;
Verbose_Argument : String_Type;
-- UMASS CODES :
Error_Recovery_Argument : String_Type;
-- END OF UMASS CODES.
Positional : Natural := 0;
-- Number of positional parameters
Total : Natural := 0;
-- Total number of parameters
Max_Parameters : constant := 6;
Incorrect_Call : exception;
function Convert_Switch is new
Convert (Parameter_Type => Switch,
Type_Name => "Switch");
procedure Put_Help_Message is
begin
New_Line;
Put_Line (" -- Ayacc: An Ada Parser Generator.");
New_Line;
Put_Line (" type Switch is (On, Off);");
New_Line;
Put_Line (" procedure Ayacc (File : in String;");
Put_Line (" C_Lex : in Switch := Off;");
Put_Line (" Debug : in Switch := Off;");
Put_Line (" Summary : in Switch := On;");
Put_Line (" Verbose : in Switch := Off;");
-- UMASS CODES :
Put_Line (" Error_Recovery : in Switch := Off);");
-- END OF UMASS CODES.
New_Line;
Put_Line (" -- File Specifies the Ayacc Input Source File.");
Put_Line (" -- C_Lex Specifies the Generation of a 'C' Lex Interface.");
Put_Line (" -- Debug Specifies the Production of Debugging Output");
Put_Line (" -- By the Generated Parser.");
Put_Line (" -- Summary Specifies the Printing of Statistics About the");
Put_Line (" -- Generated Parser.");
Put_Line (" -- Verbose Specifies the Production of a Human Readable");
Put_Line (" -- Report of States in the Generated Parser.");
-- UMASS CODES :
Put_Line (" -- Error_Recovery Specifies the Generation of extension of");
Put_Line (" -- error recovery.");
-- END OF UMASS CODES.
New_Line;
end Put_Help_Message;
begin
--VAX Vms_Lib.Set_Error;
Command_Line_Interface.Initialize (Tool_Name => "Ayacc");
Positional := Positional_Arg_Count;
Total := Named_Arg_Count + Positional;
if Total = 0 then
raise Incorrect_Call;
elsif Total > Max_Parameters then
Put_Line ("Ayacc: Too many parameters.");
raise Incorrect_Call;
end if;
-- Get named values
File := Named_Arg_Value ("File", "");
C_Lex_Argument := Named_Arg_Value ("C_Lex", "Off");
Debug_Argument := Named_Arg_Value ("Debug", "Off");
Summary_Argument := Named_Arg_Value ("Summary", "On");
Verbose_Argument := Named_Arg_Value ("Verbose", "Off");
-- UMASS CODES :
Error_Recovery_Argument := Named_Arg_Value ("Error_Recovery", "Off");
-- END OF UMASS CODES.
Extension := Named_Arg_Value ("Extension", ".a");
-- Get any positional associations
if Positional >= 1 then
File := Positional_Arg_Value (1);
if Positional >= 2 then
C_Lex_Argument := Positional_Arg_Value (2);
if Positional >= 3 then
Debug_Argument := Positional_Arg_Value (3);
if Positional >= 4 then
Summary_Argument := Positional_Arg_Value (4);
if Positional >= 5 then
Verbose_Argument := Positional_Arg_Value (5);
-- UMASS CODES :
if Positional = Max_Parameters then
Error_Recovery_Argument := Positional_Arg_Value (5);
end if;
-- END OF UMASS CODES.
end if;
end if;
end if;
end if;
end if;
Command_Line_Interface.Finalize;
C_Lex := Convert_Switch (Value (C_Lex_Argument));
Debug := Convert_Switch (Value (Debug_Argument));
Summary := Convert_Switch (Value (Summary_Argument));
Verbose := Convert_Switch (Value (Verbose_Argument));
-- UMASS CODES :
Error_Recovery := Convert_Switch (Value (Error_Recovery_Argument));
-- END OF UMASS CODES.
exception
when Incorrect_Call | Invalid_Parameter |
Invalid_Parameter_Order | Missing_Positional_Arg |
Unreferenced_Named_Arg | Invalid_Named_Association |
Unbalanced_Parentheses =>
Put_Help_Message ;
raise Invalid_Command_Line ;
end Get_Arguments;
|
reznikmm/matreshka | Ada | 3,595 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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 Matreshka.XML_Schema.Named_Maps;
package XML.Schema.Named_Maps.Internals is
pragma Preelaborate;
function Create
(Node : Matreshka.XML_Schema.Named_Maps.Named_Map_Access)
return XS_Named_Map;
end XML.Schema.Named_Maps.Internals;
|
stcarrez/atlas | Ada | 3,432 | ads | -----------------------------------------------------------------------
-- atlas-reviews-beans -- Beans for module reviews
-- Copyright (C) 2014 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Beans.Basic;
with Util.Beans.Objects;
with Atlas.Reviews.Modules;
with Atlas.Reviews.Models;
package Atlas.Reviews.Beans is
type Review_Bean is new Atlas.Reviews.Models.Review_Bean with record
Module : Atlas.Reviews.Modules.Review_Module_Access := null;
end record;
type Review_Bean_Access is access all Review_Bean'Class;
-- Get the value identified by the name.
overriding
function Get_Value (From : in Review_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
overriding
procedure Set_Value (From : in out Review_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
overriding
procedure Save (Bean : in out Review_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
overriding
procedure Delete (Bean : in out Review_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
overriding
procedure Load (Bean : in out Review_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- Create the Reviews_Bean bean instance.
function Create_Review_Bean (Module : in Atlas.Reviews.Modules.Review_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access;
type Review_List_Bean is new Atlas.Reviews.Models.Review_List_Bean with record
Module : Atlas.Reviews.Modules.Review_Module_Access := null;
Reviews : aliased Atlas.Reviews.Models.List_Info_List_Bean;
Reviews_Bean : Atlas.Reviews.Models.List_Info_List_Bean_Access;
end record;
type Review_List_Bean_Access is access all Review_List_Bean'Class;
-- Get the value identified by the name.
overriding
function Get_Value (From : in Review_List_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
overriding
procedure Set_Value (From : in out Review_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
overriding
procedure Load (Into : in out Review_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- Create the Review_List_Bean bean instance.
function Create_Review_List_Bean (Module : in Atlas.Reviews.Modules.Review_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access;
end Atlas.Reviews.Beans;
|
apple-oss-distributions/old_ncurses | Ada | 3,011 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- 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
------------------------------------------------------------------------------
procedure ncurses2.acs_and_scroll;
|
AdaCore/libadalang | Ada | 36,298 | adb | ------------------------------------------------------------------------------
-- --
-- POLYORB COMPONENTS --
-- --
-- B A C K E N D . B E _ C O R B A _ A D A . A L I G N E D --
-- --
-- B o d y --
-- --
-- Copyright (C) 2005-2013, Free Software Foundation, Inc. --
-- --
-- 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 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/>. --
-- --
-- PolyORB is maintained by AdaCore --
-- (email: [email protected]) --
-- --
------------------------------------------------------------------------------
with Namet; use Namet;
with Frontend.Nodes; use Frontend.Nodes;
with Frontend.Nutils;
with Backend.BE_CORBA_Ada.Nodes; use Backend.BE_CORBA_Ada.Nodes;
with Backend.BE_CORBA_Ada.Nutils; use Backend.BE_CORBA_Ada.Nutils;
with Backend.BE_CORBA_Ada.IDL_To_Ada; use Backend.BE_CORBA_Ada.IDL_To_Ada;
with Backend.BE_CORBA_Ada.Runtime; use Backend.BE_CORBA_Ada.Runtime;
with Backend.BE_CORBA_Ada.Common; use Backend.BE_CORBA_Ada.Common;
package body Backend.BE_CORBA_Ada.Aligned is
package FEN renames Frontend.Nodes;
package FEU renames Frontend.Nutils;
package BEN renames Backend.BE_CORBA_Ada.Nodes;
package body Package_Spec is
-- The Args_Type_Out is unusable for the moment, it will be
-- used just for bounded type
function Args_Type_Record_In (E : Node_Id) return Node_Id;
function Args_Type_Record_Out (E : Node_Id) return Node_Id;
function Args_Type_Access_Out (E : Node_Id) return Node_Id;
procedure Visit_Specification (E : Node_Id);
procedure Visit_Module (E : Node_Id);
procedure Visit_Operation_Declaration (E : Node_Id);
procedure Visit_Interface_Declaration (E : Node_Id);
procedure Visit_Structure_Type (E : Node_Id);
procedure Visit_Union_Type (E : Node_Id);
procedure Visit_Type_Declaration (E : Node_Id);
function Make_Variable_Type
(N : Node_Id;
Type_Spec : Node_Id;
Desc : List_Id)
return Node_Id;
function Is_Unbounded_Type (N : Node_Id) return Boolean;
-- Return true if N (type spec) contains an unbounded type
procedure Get_Discriminants
(N : Node_Id;
L : List_Id;
Ret : Boolean := False;
Struct : Boolean := False);
-- Fill 'L' with all discriminants of the type 'N'. Ret
-- indicate if the type is used for return argument in this
-- case the argument name is 'Return'. Struct indicate if the
-- type is a structure member.
-------------------------
-- Args_Type_Record_In --
-------------------------
function Args_Type_Record_In (E : Node_Id) return Node_Id is
pragma Assert (FEN.Kind (E) = K_Operation_Declaration);
Spec : constant Node_Id := Stub_Node
(BE_Node (Identifier (E)));
Param : constant List_Id := Parameters (E);
Discr : constant List_Id := New_List;
Components : constant List_Id := New_List;
L : List_Id := No_List;
Args_Type : Node_Id := No_Node;
Component : Node_Id;
Par_Type : Node_Id;
N : Node_Id;
Par : Node_Id;
begin
-- For each subprogram we generate a record containing the
-- In parameters with the aligned type.
if not FEU.Is_Empty (Param) then
Par := First_Entity (Param);
while Present (Par) loop
if Is_In (FEN.Parameter_Mode (Par)) then
-- If the parameter type is a class-wide type, we
-- remove the "'Class" attribute from the type
-- name.
Par_Type := Type_Spec (Par);
if BEN.Kind (Par_Type) = K_Attribute_Reference then
Par_Type := Prefix (Par_Type);
end if;
Par_Type := Make_Type_Designator (Par_Type);
if Is_Unbounded_Type (Type_Spec (Par)) then
L := New_List;
Get_Discriminants (Par, L);
end if;
Par_Type := Make_Variable_Type
(Par_Type, Type_Spec (Par), L);
-- Add the discriminants of Par to Discr
if not Is_Empty (L) then
N := First_Node (L);
Append_To (Discr, N);
L := No_List;
end if;
Component := Make_Component_Declaration
(Defining_Identifier => Make_Defining_Identifier
(IDL_Name (Identifier (Declarator (Par)))),
Subtype_Indication => Par_Type);
Append_To (Components, Component);
end if;
Par := Next_Entity (Par);
end loop;
end if;
-- Record name
Get_Name_String (BEN.Name (Defining_Identifier (Spec)));
Add_Str_To_Name_Buffer ("_Args_Type_In");
N := Make_Selected_Component
(Defining_Identifier (Aligned_Package (Current_Entity)),
Make_Defining_Identifier (Name_Find));
-- record type Declaration
Args_Type := Make_Full_Type_Declaration
(Defining_Identifier => N,
Type_Definition => Make_Record_Definition (Components),
Discriminant_Spec => Discr);
return Args_Type;
end Args_Type_Record_In;
--------------------------
-- Args_Type_Record_Out --
--------------------------
function Args_Type_Record_Out (E : Node_Id) return Node_Id is
pragma Assert (FEN.Kind (E) = K_Operation_Declaration);
Spec : constant Node_Id := Stub_Node
(BE_Node (Identifier (E)));
T : constant Node_Id := Type_Spec (E);
Param : constant List_Id := Parameters (E);
Discr : constant List_Id := New_List;
Components : constant List_Id := New_List;
L : List_Id := No_List;
Args_Type : Node_Id := No_Node;
Component : Node_Id;
Par_Type : Node_Id;
N : Node_Id;
Par : Node_Id;
begin
-- For each subprogram we generate a record containing the
-- Out parameters with the aligned type.
if not FEU.Is_Empty (Param) then
Par := First_Entity (Param);
while Present (Par) loop
if Is_Out (FEN.Parameter_Mode (Par)) then
-- If the parameter type is a class-wide type, we
-- remove the "'Class" attribute from the type
-- name.
Par_Type := Type_Spec (Par);
if BEN.Kind (Par_Type) = K_Attribute_Reference then
Par_Type := Prefix (Par_Type);
end if;
Par_Type := Make_Type_Designator (Par_Type);
if Is_Unbounded_Type (Type_Spec (Par)) then
L := New_List;
Get_Discriminants (Par_Type, L);
end if;
Par_Type := Make_Variable_Type
(Par_Type, Type_Spec (Par), L);
if not Is_Empty (L) then
N := First_Node (L);
Append_To (Discr, N);
L := No_List;
end if;
Component := Make_Component_Declaration
(Defining_Identifier => Make_Defining_Identifier
(IDL_Name (Identifier (Declarator (Par)))),
Subtype_Indication => Par_Type);
Append_To (Components, Component);
end if;
Par := Next_Entity (Par);
end loop;
end if;
-- If the subprogram is a function, we add an additional
-- member corresponding to the result of the function.
if Present (T) and then
FEN.Kind (T) /= K_Void
then
-- If the return type is a class-wide type, we remove the
-- "'Class" attribute from the type name.
Par_Type := T;
if BEN.Kind (Par_Type) = K_Attribute_Reference then
Par_Type := Prefix (Par_Type);
end if;
Par_Type := Make_Type_Designator (Par_Type);
if Is_Unbounded_Type (T) then
L := New_List;
Get_Discriminants (T, L, True, False);
end if;
Par_Type := Make_Variable_Type (Par_Type, T, L);
if not Is_Empty (L) then
N := First_Node (L);
Append_To (Discr, N);
L := No_List;
end if;
Component := Make_Component_Declaration
(Defining_Identifier => Make_Defining_Identifier
(PN (P_Returns)),
Subtype_Indication => Par_Type);
Append_To (Components, Component);
end if;
-- The record name
Get_Name_String (BEN.Name (Defining_Identifier (Spec)));
Add_Str_To_Name_Buffer ("_Args_Type_Out");
N := Make_Selected_Component
(Defining_Identifier (Aligned_Package (Current_Entity)),
Make_Defining_Identifier (Name_Find));
-- Record type Declaration
Args_Type := Make_Full_Type_Declaration
(Defining_Identifier => N,
Type_Definition => Make_Record_Definition (Components),
Discriminant_Spec => Discr);
return Args_Type;
end Args_Type_Record_Out;
--------------------------
-- Args_Type_Access_Out --
--------------------------
function Args_Type_Access_Out (E : Node_Id) return Node_Id
is
pragma Assert (FEN.Kind (E) = K_Operation_Declaration);
Spec : constant Node_Id := Stub_Node
(BE_Node (Identifier (E)));
N : Node_Id;
M : Node_Id;
begin
Get_Name_String (BEN.Name (Defining_Identifier (Spec)));
Add_Str_To_Name_Buffer ("_Args_Type_Out");
N := Make_Defining_Identifier (Name_Find);
Get_Name_String (BEN.Name (Defining_Identifier (Spec)));
Add_Str_To_Name_Buffer ("_Args_Type_Access_Out");
M := Make_Selected_Component
(Defining_Identifier (Aligned_Package (Current_Entity)),
Make_Defining_Identifier (Name_Find));
M := Make_Full_Type_Declaration
(Defining_Identifier => M,
Type_Definition => Make_Access_Type_Definition (N));
return M;
end Args_Type_Access_Out;
-----------
-- Visit --
-----------
procedure Visit (E : Node_Id) is
begin
case FEN.Kind (E) is
when K_Module =>
Visit_Module (E);
when K_Operation_Declaration =>
Visit_Operation_Declaration (E);
when K_Interface_Declaration =>
Visit_Interface_Declaration (E);
when K_Structure_Type =>
Visit_Structure_Type (E);
when K_Union_Type =>
Visit_Union_Type (E);
when K_Type_Declaration =>
Visit_Type_Declaration (E);
when K_Specification =>
Visit_Specification (E);
when others =>
null;
end case;
end Visit;
----------------------------
-- Visit_Type_Declaration --
----------------------------
procedure Visit_Type_Declaration (E : Node_Id) is
D : Node_Id;
Id : Node_Id;
T : Node_Id;
N : Node_Id;
Type_Spec_Node : Node_Id;
Is_Subtype : Boolean := FEN.Marked_As_Subtype (E);
begin
Set_Aligned_Spec;
Type_Spec_Node := Type_Spec (E);
-- * The fixed type shall be mapped to an equivalent Ada
-- decimal type.
-- * For each declarator, a type definition shall be
-- generated.
if FEN.Kind (Type_Spec_Node) = K_Fixed_Point_Type then
declare
Fixed_Type_Node : Node_Id;
Fixed_Name : constant Name_Id
:= Map_Fixed_Type_Name (Type_Spec_Node);
begin
-- XXX it is certainly false.
-- TODO: make a package instantiation at the marshalling time
T := Make_Selected_Component
(Defining_Identifier (Aligned_Package (Current_Entity)),
Make_Defining_Identifier (Fixed_Name));
Fixed_Type_Node := Make_Full_Type_Declaration
(Defining_Identifier => T,
Type_Definition => Make_Decimal_Type_Definition
(Type_Spec_Node),
Is_Subtype => Is_Subtype);
Append_To (Visible_Part (Current_Package), Fixed_Type_Node);
end;
elsif FEN.Kind (Type_Spec_Node) = K_String_Type or else
FEN.Kind (Type_Spec_Node) = K_Wide_String_Type
then
declare
Str_Package_Inst : Node_Id;
Pkg_Name : Name_Id;
Pkg_Node : Node_Id;
String_Pkg : Node_Id;
begin
-- We create an instantiation of the generic package
-- PolyORB.Aligned_Types.Bounded_Strings (or
-- PolyORB.Aligned_Types.Bounded_Wide_Strings). Then,
-- the string type is derived from the
-- 'Bounded_String' type (or the 'Bounded_Wide_String'
-- type of the instantiated package.
Pkg_Name := Map_String_Pkg_Name (Type_Spec_Node);
if FEN.Kind (Type_Spec_Node) = K_Wide_String_Type then
String_Pkg :=
RU (RU_PolyORB_Aligned_Types_Bounded_Wide_Strings,
False);
T := Make_Defining_Identifier (TN (T_Bounded_Wide_String));
else
String_Pkg :=
RU (RU_PolyORB_Aligned_Types_Bounded_Strings,
False);
T := Make_Defining_Identifier (TN (T_Bounded_String));
end if;
-- Building the string package node
Pkg_Node := Make_Selected_Component
(Defining_Identifier (Aligned_Package (Current_Entity)),
Make_Defining_Identifier (Pkg_Name));
Str_Package_Inst := Make_Package_Instantiation
(Defining_Identifier => Pkg_Node,
Generic_Package => String_Pkg,
Parameter_List => New_List
(Make_Literal (FEU.Expr_Value (Max_Size (Type_Spec_Node)))));
Append_To (Visible_Part (Current_Package), Str_Package_Inst);
T := Make_Selected_Component (Pkg_Node, T);
end;
elsif FEN.Kind (Type_Spec_Node) /= K_Sequence_Type then
-- General case
T := Make_Type_Designator (Type_Spec_Node);
end if;
Is_Subtype := Is_Subtype or Is_Object_Type (Type_Spec (E));
D := First_Entity (Declarators (E));
while Present (D) loop
Id := Make_Selected_Component
(Defining_Identifier (Aligned_Package (Current_Entity)),
Map_Defining_Identifier (D));
if Kind (D) = K_Complex_Declarator then
N := Make_Full_Type_Declaration
(Defining_Identifier => Id,
Type_Definition =>
Make_Array_Type_Definition
(Map_Range_Constraints
(FEN.Array_Sizes (D))
, T));
elsif FEN.Kind (Type_Spec_Node) = K_Sequence_Type then
declare
M : Node_Id;
K : Node_Id;
Rang : Node_Id;
L : constant List_Id := New_List;
Disc : constant List_Id := New_List;
begin
-- Declaration of array of element type
M := Make_Type_Designator (Type_Spec (Type_Spec_Node));
K := RE (RE_Unsigned_Long_10);
M := Make_Array_Type_Definition (No_List, M, K);
K := Map_Defining_Identifier (D);
Set_Str_To_Name_Buffer
(Get_Name_String (BEN.Name (K)) & "_Content");
K := Make_Defining_Identifier (Name_Find);
M := Make_Full_Type_Declaration (K, M);
Append_To (Visible_Part (Current_Package), M);
-- Declration of the sequence type
if Present (Max_Size (Type_Spec_Node)) then
K := Make_Literal
(FEU.Expr_Value (Max_Size (Type_Spec_Node)));
else
M := Map_Defining_Identifier (D);
Set_Str_To_Name_Buffer
(Get_Name_String (BEN.Name (M)) & "_Length");
K := Make_Defining_Identifier (Name_Find);
end if;
Rang := Make_Range_Constraint (Make_Literal (Int1_Val), K);
M := Map_Defining_Identifier (D);
Set_Str_To_Name_Buffer
(Get_Name_String (BEN.Name (M)) & "_Content");
M := Make_Defining_Identifier (Name_Find);
K := Make_String_Type_Definition (M, Rang);
M := Make_Component_Declaration
(Make_Defining_Identifier (PN (P_Content)), K);
Append_To (L, M);
-- Discriminant
if not Present (Max_Size (Type_Spec_Node)) then
K := Map_Defining_Identifier (D);
Set_Str_To_Name_Buffer
(Get_Name_String (BEN.Name (K)) & "_Length");
M := Make_Defining_Identifier (Name_Find);
M := Make_Component_Declaration
(M, RE (RE_Unsigned_Long_10));
Append_To (Disc, M);
end if;
-- Type declaration
N := Make_Full_Type_Declaration
(Defining_Identifier => Id,
Type_Definition => Make_Record_Definition (L),
Discriminant_Spec => Disc);
end;
else
N := Make_Full_Type_Declaration
(Defining_Identifier => Id,
Type_Definition => Make_Derived_Type_Definition
(Subtype_Indication => T,
Record_Extension_Part => No_Node,
Is_Subtype => Is_Subtype,
Opt_Range => Optional_Range (E)),
Is_Subtype => Is_Subtype);
end if;
Append_To (Visible_Part (Current_Package), N);
D := Next_Entity (D);
end loop;
end Visit_Type_Declaration;
---------------------------------
-- Visit_Interface_Declaration --
---------------------------------
procedure Visit_Interface_Declaration (E : Node_Id) is
N : Node_Id;
begin
-- If local interface, nothing to do.
if FEN.Is_Local_Interface (E) then
return;
end if;
N := BEN.Parent (Type_Def_Node (BE_Node (Identifier (E))));
Push_Entity (BEN.IDL_Unit (Package_Declaration (N)));
Set_Aligned_Spec;
N := First_Entity (Interface_Body (E));
while Present (N) loop
Visit (N);
N := Next_Entity (N);
end loop;
Pop_Entity;
end Visit_Interface_Declaration;
--------------------------
-- Visit_Structure_Type --
--------------------------
procedure Visit_Structure_Type (E : Node_Id) is
Components : constant List_Id := New_List;
Discr : constant List_Id := New_List;
L : List_Id := New_List;
N : Node_Id;
M : Node_Id;
C : Node_Id;
Member : Node_Id;
Unbounded : Boolean;
begin
Set_Aligned_Spec;
Member := First_Entity (Members (E));
while Present (Member) loop
N := Map_Defining_Identifier
(Identifier (First_Entity (Declarators (Member))));
M := Make_Type_Designator (Type_Spec (Member),
First_Entity (Declarators (Member)));
Unbounded := Is_Unbounded_Type (Type_Spec (Member));
if Unbounded then
Get_Discriminants (Member, L, False, True);
M := Make_Variable_Type (M, Type_Spec (Member), L);
C := First_Node (L);
Append_To (Discr, C);
L := New_List;
end if;
N := Make_Component_Declaration
(Defining_Identifier => N,
Subtype_Indication => M);
Append_To (Components, N);
Member := Next_Entity (Member);
end loop;
N := Make_Selected_Component
(Defining_Identifier (Aligned_Package (Current_Entity)),
Make_Defining_Identifier (FEN.IDL_Name (FEN.Identifier (E))));
N := Make_Full_Type_Declaration
(Defining_Identifier => N,
Type_Definition => Make_Record_Definition (Components),
Discriminant_Spec => Discr);
Append_To (Visible_Part (Current_Package), N);
end Visit_Structure_Type;
----------------------
-- Visit_Union_Type --
----------------------
procedure Visit_Union_Type (E : Node_Id) is
N : Node_Id;
S : Node_Id := Switch_Type_Spec (E);
Orig_Type : constant Node_Id :=
FEU.Get_Original_Type_Specifier (S);
L : List_Id;
Discr : List_Id;
Components : List_Id;
Choices : List_Id;
Variants : List_Id;
Literal_Parent : Node_Id := No_Node;
T : Node_Id;
Switch_Case : Node_Id;
M : Node_Id;
Variant : Node_Id;
Label : Node_Id;
Choice : Node_Id;
begin
Set_Aligned_Spec;
T := Make_Type_Designator (S);
-- If the discriminator is an enumeration type, we must put
-- the full names of the literal.
if FEN.Kind (Orig_Type) = K_Enumeration_Type then
Literal_Parent := Map_Expanded_Name
(Scope_Entity
(Identifier
(Orig_Type)));
else
S := No_Node;
end if;
L := New_List;
Discr := New_List;
Components := New_List;
Variants := New_List;
Switch_Case := First_Entity (Switch_Type_Body (E));
while Present (Switch_Case) loop
Variant := New_Node (K_Variant);
Choices := New_List;
Set_Discrete_Choices (Variant, Choices);
-- Make the switchs
-- Expansion guarantees that the "default:" case is
-- isolated in a standalone alternative.
Label := First_Entity (Labels (Switch_Case));
while Present (Label) loop
Choice := Make_Literal_With_Parent
(Value => FEU.Expr_Value (Label),
Parent => Literal_Parent);
if S /= No_Node then
Choice := Cast_Variable_To_PolyORB_Aligned_Type (Choice, S);
end if;
Append_To (Choices, Choice);
Label := Next_Entity (Label);
end loop;
N := Map_Defining_Identifier
(Identifier (Declarator (Element (Switch_Case))));
M := Make_Type_Designator
(Type_Spec (Element (Switch_Case)),
Declarator (Element (Switch_Case)));
if Is_Unbounded_Type (Type_Spec (Element (Switch_Case))) then
Get_Discriminants (Element (Switch_Case), L);
M := Make_Variable_Type
(M, Type_Spec (Element (Switch_Case)), L);
Append_To (Discr, First_Node (L));
L := New_List;
end if;
Set_Component (Variant, Make_Component_Declaration (N, M));
Append_To (Variants, Variant);
Switch_Case := Next_Entity (Switch_Case);
end loop;
Append_To (Discr,
Make_Component_Declaration
(Make_Defining_Identifier (CN (C_Switch)), T,
Make_Attribute_Reference (T, A_First)));
Append_To (Components,
Make_Variant_Part
(Make_Defining_Identifier (CN (C_Switch)),
Variants));
-- Type declaration
N := Make_Full_Type_Declaration
(Make_Defining_Identifier (FEN.IDL_Name (FEN.Identifier (E))),
Make_Record_Type_Definition
(Make_Record_Definition (Components)),
Discr);
Append_To (Visible_Part (Current_Package), N);
end Visit_Union_Type;
------------------
-- Visit_Module --
------------------
procedure Visit_Module (E : Node_Id) is
D : Node_Id;
begin
if not Map_Particular_CORBA_Parts (E, PK_Aligned_Spec) then
Push_Entity (Stub_Node (BE_Node (Identifier (E))));
D := First_Entity (Definitions (E));
while Present (D) loop
Visit (D);
D := Next_Entity (D);
end loop;
Pop_Entity;
end if;
end Visit_Module;
---------------------------------
-- Visit_Operation_Declaration --
---------------------------------
procedure Visit_Operation_Declaration (E : Node_Id) is
N : Node_Id;
begin
Set_Aligned_Spec;
Set_Str_To_Name_Buffer ("Operation : ");
Get_Name_String_And_Append (IDL_Name (Identifier (E)));
N := Make_Ada_Comment (Name_Find);
Append_To (Visible_Part (Current_Package), N);
-- Generating the 'Operation_Name'_Args_Type_In/Out
-- declarations.
N := Args_Type_Record_In (E);
Append_To (Visible_Part (Current_Package), N);
Bind_FE_To_BE (Identifier (E), N, B_Args_In);
N := Args_Type_Record_Out (E);
Append_To (Visible_Part (Current_Package), N);
Bind_FE_To_BE (Identifier (E), N, B_Args_Out);
N := Args_Type_Access_Out (E);
Append_To (Visible_Part (Current_Package), N);
Bind_FE_To_BE (Identifier (E), N, B_Access_Args_Out);
end Visit_Operation_Declaration;
-------------------------
-- Visit_Specification --
-------------------------
procedure Visit_Specification (E : Node_Id) is
Definition : Node_Id;
begin
Push_Entity (Stub_Node (BE_Node (Identifier (E))));
Definition := First_Entity (Definitions (E));
while Present (Definition) loop
Visit (Definition);
Definition := Next_Entity (Definition);
end loop;
Pop_Entity;
end Visit_Specification;
------------------------
-- Make_Variable_Type --
------------------------
function Make_Variable_Type
(N : Node_Id;
Type_Spec : Node_Id;
Desc : List_Id)
return Node_Id
is
Rewinded_Type : Node_Id;
M : Node_Id;
begin
if Is_Empty (Desc) then
return N;
end if;
Rewinded_Type := FEU.Get_Original_Type_Specifier (Type_Spec);
Set_Aligned_Spec;
case FEN.Kind (Rewinded_Type) is
when K_String
| K_Wide_String =>
M := Make_Subprogram_Call
(N,
New_List (Defining_Identifier (First_Node (Desc))));
return M;
when K_Sequence_Type =>
if not Present (Max_Size (Rewinded_Type)) then
M := Make_Subprogram_Call
(N,
New_List (Defining_Identifier (First_Node (Desc))));
return M;
else
return N;
end if;
when others =>
declare
K : Node_Id;
L : List_Id;
begin
-- Make Union_Type (Switch, Discriminant1, ...,
-- DiscriminantsN);
L := New_List;
K := First_Node (Desc);
while Present (K) loop
M := Make_Identifier
(Fully_Qualified_Name (Defining_Identifier (K)));
Append_To (L, M);
K := Next_Node (K);
end loop;
M := Make_Subprogram_Call (N, L);
return M;
end;
end case;
end Make_Variable_Type;
-----------------------
-- Is_Unbounded_Type --
-----------------------
function Is_Unbounded_Type (N : Node_Id) return Boolean is
Rewinded_Type : Node_Id;
begin
Rewinded_Type := FEU.Get_Original_Type_Specifier (N);
case FEN.Kind (Rewinded_Type) is
when K_Long
| K_Unsigned_Short
| K_Unsigned_Long
| K_Long_Long
| K_Unsigned_Long_Long
| K_Short
| K_Float
| K_Double
| K_Long_Double
| K_Boolean
| K_Char
| K_Wide_Char
| K_Octet
| K_String_Type
| K_Wide_String_Type =>
return False;
when K_String
| K_Wide_String
| K_Sequence_Type
| K_Union_Type =>
return True;
when K_Structure_Type =>
declare
Ret : Boolean := False;
Member : Node_Id;
begin
-- We test if there is an unbounded member
Member := First_Entity (Members (Rewinded_Type));
while Present (Member) loop
Ret := Is_Unbounded_Type (Type_Spec (Member));
exit when Ret;
Member := Next_Entity (Member);
end loop;
return Ret;
end;
when others =>
return False;
end case;
end Is_Unbounded_Type;
-----------------------
-- Get_Discriminants --
-----------------------
procedure Get_Discriminants
(N : Node_Id;
L : List_Id;
Ret : Boolean := False;
Struct : Boolean := False)
is
Rewinded_Type : Node_Id;
M : Node_Id;
begin
-- If we are processing the return value we have directly
-- the type.
if Ret then
Rewinded_Type := FEU.Get_Original_Type_Specifier (N);
else
Rewinded_Type := FEU.Get_Original_Type_Specifier (Type_Spec (N));
end if;
case FEN.Kind (Rewinded_Type) is
when K_Union_Type =>
declare
Member : Node_Id;
begin
Member := First_Entity (Switch_Type_Body (Rewinded_Type));
while Present (Member) loop
if Is_Unbounded_Type (Type_Spec (Element (Member))) then
Get_Discriminants (Element (Member), L);
end if;
Member := Next_Entity (Member);
end loop;
M := Make_Type_Designator (Switch_Type_Spec (Rewinded_Type));
M := Make_Component_Declaration
(Make_Defining_Identifier (CN (C_Switch)), M,
Make_Attribute_Reference (M, A_First));
Append_To (L, M);
end;
when K_Structure_Type =>
declare
Member : Node_Id;
begin
Member := First_Entity (Members (Rewinded_Type));
while Present (Member) loop
if Is_Unbounded_Type (Type_Spec (Member)) then
Get_Discriminants (Member, L, False, True);
end if;
Member := Next_Entity (Member);
end loop;
end;
when K_String
| K_Wide_String =>
if Struct then
Get_Name_String
(IDL_Name (Identifier (First_Entity (Declarators (N)))));
elsif Ret then
Set_Str_To_Name_Buffer ("Returns");
else
Get_Name_String
(IDL_Name (Identifier (Declarator (N))));
end if;
Add_Str_To_Name_Buffer ("_Size");
M := Make_Defining_Identifier (Name_Find);
M := Make_Component_Declaration
(M, RE (RE_Natural),
Make_Attribute_Reference (RE (RE_Natural), A_First));
Append_To (L, M);
when K_Sequence_Type =>
if Present (Max_Size (Rewinded_Type)) then
return;
end if;
if Struct then
Get_Name_String
(IDL_Name (Identifier (First_Entity (Declarators (N)))));
elsif Ret then
Set_Str_To_Name_Buffer ("Returns");
else
Get_Name_String
(IDL_Name (Identifier (Declarator (N))));
end if;
Add_Str_To_Name_Buffer ("_Size");
M := Make_Defining_Identifier (Name_Find);
Append_To (L,
Make_Component_Declaration (M, RE (RE_Unsigned_Long_10)));
when others =>
null;
end case;
end Get_Discriminants;
end Package_Spec;
end Backend.BE_CORBA_Ada.Aligned;
|
charlie5/cBound | Ada | 1,324 | 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_query_tree_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_query_tree_cookie_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_query_tree_cookie_t.Item,
Element_Array => xcb.xcb_query_tree_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_query_tree_cookie_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_query_tree_cookie_t.Pointer,
Element_Array => xcb.xcb_query_tree_cookie_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_query_tree_cookie_t;
|
tum-ei-rcs/StratoX | Ada | 2,798 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . E X E C U T I O N _ T I M E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-2013, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- 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/>. --
-- --
------------------------------------------------------------------------------
with Ada.Task_Identification;
with System.BB.Threads;
with System.BB.Time;
with System.BB.Interrupts;
package System.BB.Execution_Time
with SPARK_Mode => On is
function Global_Interrupt_Clock return System.BB.Time.Time;
-- Sum of the interrupt clocks
function Interrupt_Clock
(Interrupt : System.BB.Interrupts.Interrupt_ID)
return System.BB.Time.Time;
pragma Inline (Interrupt_Clock);
-- CPU Time spent to handle the given interrupt
function Thread_Clock
(Th : System.BB.Threads.Thread_Id) return System.BB.Time.Time;
pragma Inline (Thread_Clock);
-- CPU Time spent in the given thread
end System.BB.Execution_Time;
|
jwarwick/aoc_2019_ada | Ada | 666 | ads | -- AOC, Day 6
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Day is
type Orbit_Entry is record
Left : Unbounded_String := Null_Unbounded_String;
Right : Unbounded_String := Null_Unbounded_String;
end record;
package Orbit_List is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Orbit_Entry);
type Orbit_Checksum is new Natural;
function load_orbits(filename : in String) return Orbit_List.Vector;
-- function load_orbits_from_string(str : in String) return Orbit_List.Vector;
function orbit_count_checksum(ol : in Orbit_List.Vector) return Orbit_Checksum;
end Day;
|
micahwelf/FLTK-Ada | Ada | 1,293 | ads |
package FLTK.Widgets.Menus.Choices is
type Choice is new Menu with private;
type Choice_Reference (Data : not null access Choice'Class) is limited null record
with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Choice;
end Forge;
function Chosen
(This : in Choice)
return FLTK.Menu_Items.Menu_Item_Reference;
function Chosen_Index
(This : in Choice)
return Extended_Index;
procedure Set_Chosen
(This : in out Choice;
Place : in Index);
procedure Set_Chosen
(This : in out Choice;
Item : in FLTK.Menu_Items.Menu_Item);
procedure Draw
(This : in out Choice);
function Handle
(This : in out Choice;
Event : in Event_Kind)
return Event_Outcome;
private
type Choice is new Menu with null record;
overriding procedure Finalize
(This : in out Choice);
pragma Inline (Chosen);
pragma Inline (Chosen_Index);
pragma Inline (Set_Chosen);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Menus.Choices;
|
Intelligente-sanntidssystemer/Ada-prosjekt | Ada | 14,933 | adb | ------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
with nRF.ADC; use nRF.ADC;
with nRF.PPI; use nRF.PPI;
with nRF.Timers; use nRF.Timers;
with nRF.GPIO.Tasks_And_Events; use nRF.GPIO.Tasks_And_Events;
with nRF.Events; use nRF.Events;
with nRF.Interrupts; use nRF.Interrupts;
package body NRF52_DK.IOs is
-- The analog out feature is implemented as PWM signal. To generate the PWM
-- signals we use a timer with the configuration described bellow.
--
-- Because of the limited number of timer comparators and GPIOTE channels,
-- we can only have 3 PWMs on the system at the same time. However there
-- are 5 pins allowed to use PWM, so we need to dynamicaly allocate the
-- PWM based on user requests.
--
-- Timer configuration:
--
-- Comparator 0, 1, 2 are used to control the pulse width of the 3 PWMs.
-- Each of those comparator is associated with a PWM and a pin. When the
-- timer counter reaches the value of a comparator, the associated pin
-- toggles.
--
-- Comparator 3 is use to control the period. When the timer counter reaches
-- its value, all pins toggle.
--
-- Comparator 3 also trigger an interrupt. In the handler for this
-- interrupt, we update all the comparator values and start the timer again.
--
--
-- Int handler and timer start Cmp 0 Cmp 1 Cmp 2 Cmp3, Timer stop and interrupt
-- v v v v v
-- _______________________________ ____
-- |_______________________|
-- ______________________________________ ____
-- |________________|
-- _____________________________________________ ____
-- |_________|
--
-- ^------------------ Timer loop sequence -------------------^
--
-- Since all the timer events trigger a toggle of the pin, we have to make
-- sure that the pin is at a good state (high) when starting the timer,
-- otherwise the waveform could be inverted. This is why the GPIO channels
-- are always configured when the timer is reconfigured.
--
-- PPI and GPIOTE:
--
-- To trigger a pin toggle from the timer compare events we use the
-- following configuation.
--
-- Two PPI channels are used for each PWM pin. For a PWM X, one PPI channel
-- is used to trigger a GPIOTE task on comparator X event, a second PPI
-- channel is used to trigger a GPIOTE event on comparator 3 event. So
-- the comparator 3 event is used by all PWMs.
--
-- For a PWM X, GPIOTE channel X is configure to do a pin toggle when its
-- task is activated by one of the two PPI channels described above.
-- We keep track of the current mode of the pin to be able to detect when a
-- change of configuration is needed.
type Pin_Mode is (None, Digital_In, Digital_Out, Analog_In, Analog_Out);
Current_Mode : array (Pin_Id) of Pin_Mode := (others => None);
-- PWM --
Number_Of_PWMs : constant := 3;
type PWM_Allocated is range 0 .. Number_Of_PWMs;
subtype PWM_Id is PWM_Allocated range 0 .. Number_Of_PWMs - 1;
No_PWM : constant PWM_Allocated := Number_Of_PWMs;
PWM_Alloc : array (Pin_Id) of PWM_Allocated := (others => No_PWM);
PWM_Timer : Timer renames Timer_0;
PWM_Interrupt : constant Interrupt_Name := TIMER0_Interrupt;
PWM_Global_Compare : constant Timer_Channel := 3;
PWM_Precision : constant := 4;
PWM_Period : UInt32 := 2_000 / PWM_Precision;
type PWM_Status is record
Taken : Boolean := False;
Pulse_Width : Analog_Value;
Cmp : UInt32 := 10;
Pin : Pin_Id;
end record;
PWMs : array (PWM_Id) of PWM_Status;
function Has_PWM (Pin : Pin_Id) return Boolean
is (PWM_Alloc (Pin) /= No_PWM);
procedure Allocate_PWM (Pin : Pin_Id;
Success : out Boolean)
with Pre => not Has_PWM (Pin);
procedure Deallocate_PWM (Pin : Pin_Id)
with Pre => Has_PWM (Pin),
Post => not Has_PWM (Pin);
procedure Configure_PPI (Id : PWM_Id);
procedure Configure_GPIOTE (Id : PWM_Id);
procedure Init_PWM_Timer;
function To_Compare_Value (V : Analog_Value) return UInt32;
procedure PWM_Timer_Handler;
----------------------
-- To_Compare_Value --
----------------------
function To_Compare_Value (V : Analog_Value) return UInt32
is
Cmp : constant UInt32 :=
(PWM_Period * UInt32 (V)) / UInt32 (Analog_Value'Last);
begin
if Cmp = 0 then
return 1;
elsif Cmp >= PWM_Period then
return PWM_Period - 1;
else
return Cmp;
end if;
end To_Compare_Value;
------------------
-- Allocate_PWM --
------------------
procedure Allocate_PWM (Pin : Pin_Id;
Success : out Boolean)
is
begin
for Id in PWM_Id loop
if not PWMs (Id).Taken then
PWMs (Id).Taken := True;
PWMs (Id).Pin := Pin;
PWM_Alloc (Pin) := Id;
Configure_PPI (Id);
Success := True;
return;
end if;
end loop;
Success := False;
end Allocate_PWM;
--------------------
-- Deallocate_PWM --
--------------------
procedure Deallocate_PWM (Pin : Pin_Id) is
begin
if PWM_Alloc (Pin) /= No_PWM then
nRF.GPIO.Tasks_And_Events.Disable (GPIOTE_Channel (PWM_Alloc (Pin)));
PWMs (PWM_Alloc (Pin)).Taken := False;
PWM_Alloc (Pin) := No_PWM;
end if;
end Deallocate_PWM;
-------------------
-- Configure_PPI --
-------------------
procedure Configure_PPI (Id : PWM_Id) is
Chan1 : constant Channel_ID := Channel_ID (Id) * 2;
Chan2 : constant Channel_ID := Chan1 + 1;
begin
-- Use one PPI channel to triggerd GPTIOTE OUT task on the compare event
-- associated with this PWM_Id;
nRF.PPI.Configure
(Chan => Chan1,
Evt_EP => PWM_Timer.Compare_Event (Timer_Channel (Id)),
Task_EP => Out_Task (GPIOTE_Channel (Id)));
-- Use another PPI channel to triggerd GPTIOTE OUT task on compare 3 event
nRF.PPI.Configure
(Chan => Chan2,
Evt_EP => PWM_Timer.Compare_Event (PWM_Global_Compare),
Task_EP => Out_Task (GPIOTE_Channel (Id)));
nRF.PPI.Enable_Channel (Chan1);
nRF.PPI.Enable_Channel (Chan2);
end Configure_PPI;
----------------------
-- Configure_GPIOTE --
----------------------
procedure Configure_GPIOTE (Id : PWM_Id) is
begin
-- Configure the GPIOTE OUT task to toggle the pin
nRF.GPIO.Tasks_And_Events.Enable_Task
(Chan => GPIOTE_Channel (Id),
GPIO_Pin => Points (PWMs (Id).Pin).Pin,
Action => Toggle_Pin,
Initial_Value => Init_Set);
end Configure_GPIOTE;
-----------------------
-- PWM_Timer_Handler --
-----------------------
procedure PWM_Timer_Handler is
begin
Clear (PWM_Timer.Compare_Event (PWM_Global_Compare));
PWM_Timer.Set_Compare (PWM_Global_Compare, PWM_Period);
PWM_Timer.Set_Compare (0, PWMs (0).Cmp);
PWM_Timer.Set_Compare (1, PWMs (1).Cmp);
PWM_Timer.Set_Compare (2, PWMs (2).Cmp);
PWM_Timer.Start;
end PWM_Timer_Handler;
--------------------
-- Init_PWM_Timer --
--------------------
procedure Init_PWM_Timer is
begin
PWM_Timer.Set_Mode (Mode_Timer);
PWM_Timer.Set_Prescaler (6);
PWM_Timer.Set_Bitmode (Bitmode_32bit);
-- Clear counter internal register and stop when timer reaches compare
-- value 3.
PWM_Timer.Compare_Shortcut (Chan => PWM_Global_Compare,
Stop => True,
Clear => True);
PWM_Timer.Set_Compare (PWM_Global_Compare, PWM_Period);
for Id in PWM_Id loop PWM_Timer.Set_Compare (Timer_Channel (Id),
To_Compare_Value (PWMs (Id).Pulse_Width));
if PWMs (Id).Taken then
Configure_GPIOTE (Id);
end if;
end loop;
Enable_Interrupt (PWM_Timer.Compare_Event (PWM_Global_Compare));
nRF.Interrupts.Register (PWM_Interrupt,
PWM_Timer_Handler'Access);
nRF.Interrupts.Enable (PWM_Interrupt);
end Init_PWM_Timer;
---------
-- Set --
---------
procedure Set
(Pin : Pin_Id;
Value : Boolean)
is
Pt : GPIO_Point renames Points (Pin);
Conf : GPIO_Configuration;
begin
if Current_Mode (Pin) /= Digital_Out then
if Has_PWM (Pin) then
Deallocate_PWM (Pin);
end if;
Conf.Mode := Mode_Out;
Conf.Resistors := No_Pull;
Conf.Input_Buffer := Input_Buffer_Connect;
Conf.Sense := Sense_Disabled;
Pt.Configure_IO (Conf);
Current_Mode (Pin) := Digital_Out;
end if;
if Value then
Pt.Set;
else
Pt.Clear;
end if;
end Set;
---------
-- Set --
---------
function Set
(Pin : Pin_Id)
return Boolean
is
Pt : GPIO_Point renames Points (Pin);
Conf : GPIO_Configuration;
begin
if Current_Mode (Pin) /= Digital_In then
if Has_PWM (Pin) then
Deallocate_PWM (Pin);
end if;
Conf.Mode := Mode_In;
Conf.Resistors := No_Pull;
Conf.Input_Buffer := Input_Buffer_Connect;
Conf.Sense := Sense_Disabled;
Pt.Configure_IO (Conf);
Current_Mode (Pin) := Digital_In;
end if;
return Pt.Set;
end Set;
--------------------------
-- Set_Analog_Period_Us --
--------------------------
procedure Set_Analog_Period_Us (Period : Natural) is
begin
PWM_Period := UInt32 (Period) / PWM_Precision;
-- Update the comparator values for ech PWM
for PWM of PWMs loop
PWM.Cmp := To_Compare_Value (PWM.Pulse_Width);
end loop;
end Set_Analog_Period_Us;
-----------
-- Write --
-----------
procedure Write
(Pin : Pin_Id;
Value : Analog_Value)
is
Success : Boolean;
Pt : GPIO_Point renames Points (Pin);
Conf : GPIO_Configuration;
begin
if not Has_PWM (Pin) then
-- Stop the timer while we configure a new pin
PWM_Timer.Stop;
PWM_Timer.Clear;
Allocate_PWM (Pin, Success);
if not Success then
raise Program_Error with "No PWM available";
end if;
-- Set the pin as output
Conf.Mode := Mode_Out;
Conf.Resistors := No_Pull;
Conf.Input_Buffer := Input_Buffer_Connect;
Conf.Sense := Sense_Disabled;
Pt.Configure_IO (Conf);
Pt.Clear;
Current_Mode (Pin) := Analog_Out;
Init_PWM_Timer;
PWM_Timer.Start;
end if;
PWMs (PWM_Alloc (Pin)).Pulse_Width := Value;
PWMs (PWM_Alloc (Pin)).Cmp := To_Compare_Value (Value);
end Write;
------------
-- Analog --
------------
function Analog
(Pin : Pin_Id)
return Analog_Value
is
Result : UInt16;
begin
if Current_Mode (Pin) /= Analog_In then
if Has_PWM (Pin) then
Deallocate_PWM (Pin);
end if;
Current_Mode (Pin) := Analog_In;
end if;
Result := Do_Pin_Conversion (Pin => (case Pin is
when 3 => 1, --AIN 1 pin 3
when 4 => 2, --AIN 2 pin 4
when 5 => 3, --AIN 7 pin 5 (unused as it is assigned digital)
when 28 => 4, --AIN 4 pin 28
when 29 => 5, --AIN 5 pin 29
when 30 => 6, --AIN 6 pin 30
when 31 => 7, --AIN 7 pint31
when others => 0),--NC 0
Input => Pin_One_Forth,
Ref => VDD_One_Forth,
Res => Res_10bit);
return Analog_Value (Result);
end Analog;
end NRF52_DK.IOs;
|
AdaCore/training_material | Ada | 481 | adb | -- Which of the following declaration(s) is(are) legal?
procedure Main is
--$ begin question
type T is limited record
I : Integer;
end record;
--$ end question
--$ line cut
function "+" (A : T) return T is (A);
--$ line cut
function "-" (A : T) return T is (I => -A.I);
--$ line cut
function "=" (A, B : T) return Boolean is (True);
--$ line cut
function "=" (A, B : T) return Boolean is (A.I = T'(I => B.I).I);
begin
null;
end Main;
|
twdroeger/ada-awa | Ada | 1,875 | adb | -----------------------------------------------------------------------
-- awa_command - Tests for AWA command
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Commands;
with Util.Tests;
with AWA.Tests;
with AWA.Commands.Drivers;
with AWA.Commands.List;
with AWA.Commands.Start;
with AWA.Commands.Stop;
with Servlet.Server;
with AWA.Tests;
with ADO.Drivers;
with AWA.Testsuite;
procedure AWA_Command is
package Server_Commands is
new AWA.Commands.Drivers (Driver_Name => "awa",
Container_Type => Servlet.Server.Container);
package List_Command is
new AWA.Commands.List (Server_Commands);
package Start_Command is
new AWA.Commands.Start (Server_Commands);
package Stop_Command is
new AWA.Commands.Stop (Server_Commands);
App : aliased AWA.Tests.Test_Application;
Context : AWA.Commands.Context_Type;
Arguments : Util.Commands.Dynamic_Argument_List;
Suite : Util.Tests.Access_Test_Suite := AWA.Testsuite.Suite;
begin
ADO.Drivers.Initialize;
Server_Commands.WS.Register_Application ("/test", App'Unchecked_Access);
Server_Commands.Run (Context, Arguments);
end AWA_Command;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 24,957 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF51_SVD.UART is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Shortcut between CTS event and STARTRX task.
type SHORTS_CTS_STARTRX_Field is
(
-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_CTS_STARTRX_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between NCTS event and STOPRX task.
type SHORTS_NCTS_STOPRX_Field is
(
-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_NCTS_STOPRX_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcuts for UART.
type SHORTS_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Shortcut between CTS event and STARTRX task.
CTS_STARTRX : SHORTS_CTS_STARTRX_Field := NRF51_SVD.UART.Disabled;
-- Shortcut between NCTS event and STOPRX task.
NCTS_STOPRX : SHORTS_NCTS_STOPRX_Field := NRF51_SVD.UART.Disabled;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
Reserved_0_2 at 0 range 0 .. 2;
CTS_STARTRX at 0 range 3 .. 3;
NCTS_STOPRX at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Enable interrupt on CTS event.
type INTENSET_CTS_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_CTS_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on CTS event.
type INTENSET_CTS_Field_1 is
(
-- Reset value for the field
Intenset_Cts_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_CTS_Field_1 use
(Intenset_Cts_Field_Reset => 0,
Set => 1);
-- Enable interrupt on NCTS event.
type INTENSET_NCTS_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_NCTS_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on NCTS event.
type INTENSET_NCTS_Field_1 is
(
-- Reset value for the field
Intenset_Ncts_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_NCTS_Field_1 use
(Intenset_Ncts_Field_Reset => 0,
Set => 1);
-- Enable interrupt on RXRDY event.
type INTENSET_RXDRDY_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_RXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on RXRDY event.
type INTENSET_RXDRDY_Field_1 is
(
-- Reset value for the field
Intenset_Rxdrdy_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_RXDRDY_Field_1 use
(Intenset_Rxdrdy_Field_Reset => 0,
Set => 1);
-- Enable interrupt on TXRDY event.
type INTENSET_TXDRDY_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_TXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on TXRDY event.
type INTENSET_TXDRDY_Field_1 is
(
-- Reset value for the field
Intenset_Txdrdy_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_TXDRDY_Field_1 use
(Intenset_Txdrdy_Field_Reset => 0,
Set => 1);
-- Enable interrupt on ERROR event.
type INTENSET_ERROR_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on ERROR event.
type INTENSET_ERROR_Field_1 is
(
-- Reset value for the field
Intenset_Error_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_ERROR_Field_1 use
(Intenset_Error_Field_Reset => 0,
Set => 1);
-- Enable interrupt on RXTO event.
type INTENSET_RXTO_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_RXTO_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on RXTO event.
type INTENSET_RXTO_Field_1 is
(
-- Reset value for the field
Intenset_Rxto_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_RXTO_Field_1 use
(Intenset_Rxto_Field_Reset => 0,
Set => 1);
-- Interrupt enable set register.
type INTENSET_Register is record
-- Enable interrupt on CTS event.
CTS : INTENSET_CTS_Field_1 := Intenset_Cts_Field_Reset;
-- Enable interrupt on NCTS event.
NCTS : INTENSET_NCTS_Field_1 := Intenset_Ncts_Field_Reset;
-- Enable interrupt on RXRDY event.
RXDRDY : INTENSET_RXDRDY_Field_1 := Intenset_Rxdrdy_Field_Reset;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Enable interrupt on TXRDY event.
TXDRDY : INTENSET_TXDRDY_Field_1 := Intenset_Txdrdy_Field_Reset;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- Enable interrupt on ERROR event.
ERROR : INTENSET_ERROR_Field_1 := Intenset_Error_Field_Reset;
-- unspecified
Reserved_10_16 : HAL.UInt7 := 16#0#;
-- Enable interrupt on RXTO event.
RXTO : INTENSET_RXTO_Field_1 := Intenset_Rxto_Field_Reset;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
CTS at 0 range 0 .. 0;
NCTS at 0 range 1 .. 1;
RXDRDY at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
TXDRDY at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
ERROR at 0 range 9 .. 9;
Reserved_10_16 at 0 range 10 .. 16;
RXTO at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Disable interrupt on CTS event.
type INTENCLR_CTS_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_CTS_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on CTS event.
type INTENCLR_CTS_Field_1 is
(
-- Reset value for the field
Intenclr_Cts_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_CTS_Field_1 use
(Intenclr_Cts_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on NCTS event.
type INTENCLR_NCTS_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_NCTS_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on NCTS event.
type INTENCLR_NCTS_Field_1 is
(
-- Reset value for the field
Intenclr_Ncts_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_NCTS_Field_1 use
(Intenclr_Ncts_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on RXRDY event.
type INTENCLR_RXDRDY_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_RXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on RXRDY event.
type INTENCLR_RXDRDY_Field_1 is
(
-- Reset value for the field
Intenclr_Rxdrdy_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_RXDRDY_Field_1 use
(Intenclr_Rxdrdy_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on TXRDY event.
type INTENCLR_TXDRDY_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_TXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on TXRDY event.
type INTENCLR_TXDRDY_Field_1 is
(
-- Reset value for the field
Intenclr_Txdrdy_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_TXDRDY_Field_1 use
(Intenclr_Txdrdy_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on ERROR event.
type INTENCLR_ERROR_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on ERROR event.
type INTENCLR_ERROR_Field_1 is
(
-- Reset value for the field
Intenclr_Error_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_ERROR_Field_1 use
(Intenclr_Error_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on RXTO event.
type INTENCLR_RXTO_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_RXTO_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on RXTO event.
type INTENCLR_RXTO_Field_1 is
(
-- Reset value for the field
Intenclr_Rxto_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_RXTO_Field_1 use
(Intenclr_Rxto_Field_Reset => 0,
Clear => 1);
-- Interrupt enable clear register.
type INTENCLR_Register is record
-- Disable interrupt on CTS event.
CTS : INTENCLR_CTS_Field_1 := Intenclr_Cts_Field_Reset;
-- Disable interrupt on NCTS event.
NCTS : INTENCLR_NCTS_Field_1 := Intenclr_Ncts_Field_Reset;
-- Disable interrupt on RXRDY event.
RXDRDY : INTENCLR_RXDRDY_Field_1 := Intenclr_Rxdrdy_Field_Reset;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Disable interrupt on TXRDY event.
TXDRDY : INTENCLR_TXDRDY_Field_1 := Intenclr_Txdrdy_Field_Reset;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- Disable interrupt on ERROR event.
ERROR : INTENCLR_ERROR_Field_1 := Intenclr_Error_Field_Reset;
-- unspecified
Reserved_10_16 : HAL.UInt7 := 16#0#;
-- Disable interrupt on RXTO event.
RXTO : INTENCLR_RXTO_Field_1 := Intenclr_Rxto_Field_Reset;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
CTS at 0 range 0 .. 0;
NCTS at 0 range 1 .. 1;
RXDRDY at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
TXDRDY at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
ERROR at 0 range 9 .. 9;
Reserved_10_16 at 0 range 10 .. 16;
RXTO at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- A start bit is received while the previous data still lies in RXD. (Data
-- loss).
type ERRORSRC_OVERRUN_Field is
(
-- Error not present.
Notpresent,
-- Error present.
Present)
with Size => 1;
for ERRORSRC_OVERRUN_Field use
(Notpresent => 0,
Present => 1);
-- A start bit is received while the previous data still lies in RXD. (Data
-- loss).
type ERRORSRC_OVERRUN_Field_1 is
(
-- Reset value for the field
Errorsrc_Overrun_Field_Reset,
-- Clear error on write.
Clear)
with Size => 1;
for ERRORSRC_OVERRUN_Field_1 use
(Errorsrc_Overrun_Field_Reset => 0,
Clear => 1);
-- A character with bad parity is received. Only checked if HW parity
-- control is enabled.
type ERRORSRC_PARITY_Field is
(
-- Error not present.
Notpresent,
-- Error present.
Present)
with Size => 1;
for ERRORSRC_PARITY_Field use
(Notpresent => 0,
Present => 1);
-- A character with bad parity is received. Only checked if HW parity
-- control is enabled.
type ERRORSRC_PARITY_Field_1 is
(
-- Reset value for the field
Errorsrc_Parity_Field_Reset,
-- Clear error on write.
Clear)
with Size => 1;
for ERRORSRC_PARITY_Field_1 use
(Errorsrc_Parity_Field_Reset => 0,
Clear => 1);
-- A valid stop bit is not detected on the serial data input after all bits
-- in a character have been received.
type ERRORSRC_FRAMING_Field is
(
-- Error not present.
Notpresent,
-- Error present.
Present)
with Size => 1;
for ERRORSRC_FRAMING_Field use
(Notpresent => 0,
Present => 1);
-- A valid stop bit is not detected on the serial data input after all bits
-- in a character have been received.
type ERRORSRC_FRAMING_Field_1 is
(
-- Reset value for the field
Errorsrc_Framing_Field_Reset,
-- Clear error on write.
Clear)
with Size => 1;
for ERRORSRC_FRAMING_Field_1 use
(Errorsrc_Framing_Field_Reset => 0,
Clear => 1);
-- The serial data input is '0' for longer than the length of a data frame.
type ERRORSRC_BREAK_Field is
(
-- Error not present.
Notpresent,
-- Error present.
Present)
with Size => 1;
for ERRORSRC_BREAK_Field use
(Notpresent => 0,
Present => 1);
-- The serial data input is '0' for longer than the length of a data frame.
type ERRORSRC_BREAK_Field_1 is
(
-- Reset value for the field
Errorsrc_Break_Field_Reset,
-- Clear error on write.
Clear)
with Size => 1;
for ERRORSRC_BREAK_Field_1 use
(Errorsrc_Break_Field_Reset => 0,
Clear => 1);
-- Error source. Write error field to 1 to clear error.
type ERRORSRC_Register is record
-- A start bit is received while the previous data still lies in RXD.
-- (Data loss).
OVERRUN : ERRORSRC_OVERRUN_Field_1 :=
Errorsrc_Overrun_Field_Reset;
-- A character with bad parity is received. Only checked if HW parity
-- control is enabled.
PARITY : ERRORSRC_PARITY_Field_1 := Errorsrc_Parity_Field_Reset;
-- A valid stop bit is not detected on the serial data input after all
-- bits in a character have been received.
FRAMING : ERRORSRC_FRAMING_Field_1 :=
Errorsrc_Framing_Field_Reset;
-- The serial data input is '0' for longer than the length of a data
-- frame.
BREAK : ERRORSRC_BREAK_Field_1 := Errorsrc_Break_Field_Reset;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ERRORSRC_Register use record
OVERRUN at 0 range 0 .. 0;
PARITY at 0 range 1 .. 1;
FRAMING at 0 range 2 .. 2;
BREAK at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Enable or disable UART and acquire IOs.
type ENABLE_ENABLE_Field is
(
-- UART disabled.
Disabled,
-- UART enabled.
Enabled)
with Size => 3;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 4);
-- Enable UART and acquire IOs.
type ENABLE_Register is record
-- Enable or disable UART and acquire IOs.
ENABLE : ENABLE_ENABLE_Field := NRF51_SVD.UART.Disabled;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype RXD_RXD_Field is HAL.UInt8;
-- RXD register. On read action the buffer pointer is displaced. Once read
-- the character is consumed. If read when no character available, the UART
-- will stop working.
type RXD_Register is record
-- Read-only. *** Reading this field has side effects on other resources
-- ***. RX data from previous transfer. Double buffered.
RXD : RXD_RXD_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RXD_Register use record
RXD at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype TXD_TXD_Field is HAL.UInt8;
-- TXD register.
type TXD_Register is record
-- Write-only. TX data for transfer.
TXD : TXD_TXD_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TXD_Register use record
TXD at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Hardware flow control.
type CONFIG_HWFC_Field is
(
-- Hardware flow control disabled.
Disabled,
-- Hardware flow control enabled.
Enabled)
with Size => 1;
for CONFIG_HWFC_Field use
(Disabled => 0,
Enabled => 1);
-- Include parity bit.
type CONFIG_PARITY_Field is
(
-- Parity bit excluded.
Excluded,
-- Parity bit included.
Included)
with Size => 3;
for CONFIG_PARITY_Field use
(Excluded => 0,
Included => 7);
-- Configuration of parity and hardware flow control register.
type CONFIG_Register is record
-- Hardware flow control.
HWFC : CONFIG_HWFC_Field := NRF51_SVD.UART.Disabled;
-- Include parity bit.
PARITY : CONFIG_PARITY_Field := NRF51_SVD.UART.Excluded;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CONFIG_Register use record
HWFC at 0 range 0 .. 0;
PARITY at 0 range 1 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Peripheral power control.
type POWER_POWER_Field is
(
-- Module power disabled.
Disabled,
-- Module power enabled.
Enabled)
with Size => 1;
for POWER_POWER_Field use
(Disabled => 0,
Enabled => 1);
-- Peripheral power control.
type POWER_Register is record
-- Peripheral power control.
POWER : POWER_POWER_Field := NRF51_SVD.UART.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
POWER at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Universal Asynchronous Receiver/Transmitter.
type UART_Peripheral is record
-- Start UART receiver.
TASKS_STARTRX : aliased HAL.UInt32;
-- Stop UART receiver.
TASKS_STOPRX : aliased HAL.UInt32;
-- Start UART transmitter.
TASKS_STARTTX : aliased HAL.UInt32;
-- Stop UART transmitter.
TASKS_STOPTX : aliased HAL.UInt32;
-- Suspend UART.
TASKS_SUSPEND : aliased HAL.UInt32;
-- CTS activated.
EVENTS_CTS : aliased HAL.UInt32;
-- CTS deactivated.
EVENTS_NCTS : aliased HAL.UInt32;
-- Data received in RXD.
EVENTS_RXDRDY : aliased HAL.UInt32;
-- Data sent from TXD.
EVENTS_TXDRDY : aliased HAL.UInt32;
-- Error detected.
EVENTS_ERROR : aliased HAL.UInt32;
-- Receiver timeout.
EVENTS_RXTO : aliased HAL.UInt32;
-- Shortcuts for UART.
SHORTS : aliased SHORTS_Register;
-- Interrupt enable set register.
INTENSET : aliased INTENSET_Register;
-- Interrupt enable clear register.
INTENCLR : aliased INTENCLR_Register;
-- Error source. Write error field to 1 to clear error.
ERRORSRC : aliased ERRORSRC_Register;
-- Enable UART and acquire IOs.
ENABLE : aliased ENABLE_Register;
-- Pin select for RTS.
PSELRTS : aliased HAL.UInt32;
-- Pin select for TXD.
PSELTXD : aliased HAL.UInt32;
-- Pin select for CTS.
PSELCTS : aliased HAL.UInt32;
-- Pin select for RXD.
PSELRXD : aliased HAL.UInt32;
-- RXD register. On read action the buffer pointer is displaced. Once
-- read the character is consumed. If read when no character available,
-- the UART will stop working.
RXD : aliased RXD_Register;
-- TXD register.
TXD : aliased TXD_Register;
-- UART Baudrate.
BAUDRATE : aliased HAL.UInt32;
-- Configuration of parity and hardware flow control register.
CONFIG : aliased CONFIG_Register;
-- Peripheral power control.
POWER : aliased POWER_Register;
end record
with Volatile;
for UART_Peripheral use record
TASKS_STARTRX at 16#0# range 0 .. 31;
TASKS_STOPRX at 16#4# range 0 .. 31;
TASKS_STARTTX at 16#8# range 0 .. 31;
TASKS_STOPTX at 16#C# range 0 .. 31;
TASKS_SUSPEND at 16#1C# range 0 .. 31;
EVENTS_CTS at 16#100# range 0 .. 31;
EVENTS_NCTS at 16#104# range 0 .. 31;
EVENTS_RXDRDY at 16#108# range 0 .. 31;
EVENTS_TXDRDY at 16#11C# range 0 .. 31;
EVENTS_ERROR at 16#124# range 0 .. 31;
EVENTS_RXTO at 16#144# range 0 .. 31;
SHORTS at 16#200# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
ERRORSRC at 16#480# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
PSELRTS at 16#508# range 0 .. 31;
PSELTXD at 16#50C# range 0 .. 31;
PSELCTS at 16#510# range 0 .. 31;
PSELRXD at 16#514# range 0 .. 31;
RXD at 16#518# range 0 .. 31;
TXD at 16#51C# range 0 .. 31;
BAUDRATE at 16#524# range 0 .. 31;
CONFIG at 16#56C# range 0 .. 31;
POWER at 16#FFC# range 0 .. 31;
end record;
-- Universal Asynchronous Receiver/Transmitter.
UART0_Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (16#40002000#);
end NRF51_SVD.UART;
|
MinimSecure/unum-sdk | Ada | 777 | ads | -- Copyright 2013-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Const is
Aint_Global_GDB_E : exception;
end Const;
|
AdaCore/libadalang | Ada | 2,661 | adb | -- Enumerate all tagged types that are derived and count how many derivations
-- they have.
with Ada.Containers.Hashed_Maps;
with Ada.Text_IO;
with Libadalang.Analysis;
with Libadalang.Common;
with Helpers;
procedure Derivation_Count is
package TIO renames Ada.Text_IO;
package LAL renames Libadalang.Analysis;
package LALCO renames Libadalang.Common;
use type LALCO.Ada_Node_Kind_Type;
function Hash (TD : LAL.Base_Type_Decl) return Ada.Containers.Hash_Type is
(LAL.Ada_Node'Class (TD).Hash);
package Derivation_Histogram_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => LAL.Base_Type_Decl,
Element_Type => Positive,
Hash => Hash,
Equivalent_Keys => LAL."=");
Histogram : Derivation_Histogram_Maps.Map;
-- Mapping of tagged type declarations to the number of times this type
-- declaration is derived.
function Process_Node (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status;
------------------
-- Process_Node --
------------------
function Process_Node (Node : LAL.Ada_Node'Class) return LALCO.Visit_Status
is
use Derivation_Histogram_Maps;
Base : LAL.Base_Type_Decl;
Derived : LAL.Derived_Type_Def;
Cur : Cursor;
Inserted : Boolean;
begin
-- Skip all nodes that are not the derivation of a tagged type, or that
-- are "with private".
if Node.Kind /= LALCO.Ada_Derived_Type_Def then
return LALCO.Into;
end if;
Derived := Node.As_Derived_Type_Def;
if Derived.F_Has_With_Private.P_As_Bool
or else not Derived.Parent.As_Type_Decl.P_Is_Tagged_Type
then
return LALCO.Into;
end if;
-- Get the canonical view for the type from which Derived is derived
Base :=
Derived.F_Subtype_Indication.P_Designated_Type_Decl.P_Canonical_Type;
-- Increment its derivation count
Histogram.Insert (Base, 1, Cur, Inserted);
if not Inserted then
Histogram.Replace_Element (Cur, Element (Cur) + 1);
end if;
return LALCO.Into;
end Process_Node;
Units : Helpers.Unit_Vectors.Vector;
Ctx : constant LAL.Analysis_Context :=
Helpers.Initialize ("material.gpr", Units);
pragma Unreferenced (Ctx);
begin
for Unit of Units loop
LAL.Root (Unit).Traverse (Process_Node'Access);
end loop;
for Cur in Histogram.Iterate loop
declare
use Derivation_Histogram_Maps;
begin
TIO.Put_Line (Key (Cur).Image & " is derived"
& Positive'Image (Element (Cur)) & " times");
end;
end loop;
end Derivation_Count;
|
onox/orka | Ada | 737 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.SIMD.FMA.Singles is
pragma Pure;
end Orka.SIMD.FMA.Singles;
|
RREE/ada-util | Ada | 12,655 | ads | -----------------------------------------------------------------------
-- util-encoders-base64 -- Encode/Decode a stream in Base64
-- Copyright (C) 2009, 2010, 2011, 2012, 2016, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Interfaces;
-- The <b>Util.Encodes.Base64</b> packages encodes and decodes streams
-- in Base64 (See rfc4648: The Base16, Base32, and Base64 Data Encodings).
package Util.Encoders.Base64 is
pragma Preelaborate;
-- Encode the 64-bit value to LEB128 and then base64url.
function Encode (Value : in Interfaces.Unsigned_64) return String;
-- Decode the base64url string and then the LEB128 integer.
-- Raise the Encoding_Error if the string is invalid and cannot be decoded.
function Decode (Value : in String) return Interfaces.Unsigned_64;
-- ------------------------------
-- Base64 encoder
-- ------------------------------
-- This <b>Encoder</b> translates the (binary) input stream into
-- a Base64 ascii stream.
type Encoder is new Util.Encoders.Transformer with private;
-- Encodes the binary input stream represented by <b>Data</b> into
-- the a base64 output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in out Encoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset);
-- Finish encoding the input array.
overriding
procedure Finish (E : in out Encoder;
Into : in out Ada.Streams.Stream_Element_Array;
Last : in out Ada.Streams.Stream_Element_Offset);
-- Set the encoder to use the base64 URL alphabet when <b>Mode</b> is True.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
procedure Set_URL_Mode (E : in out Encoder;
Mode : in Boolean);
-- Create a base64 encoder using the URL alphabet.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
function Create_URL_Encoder return Transformer_Access;
-- ------------------------------
-- Base64 decoder
-- ------------------------------
-- The <b>Decoder</b> decodes a Base64 ascii stream into a binary stream.
type Decoder is new Util.Encoders.Transformer with private;
-- Decodes the base64 input stream represented by <b>Data</b> into
-- the binary output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in out Decoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset);
-- Set the decoder to use the base64 URL alphabet when <b>Mode</b> is True.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
procedure Set_URL_Mode (E : in out Decoder;
Mode : in Boolean);
-- Create a base64 decoder using the URL alphabet.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
function Create_URL_Decoder return Transformer_Access;
private
type Alphabet is
array (Interfaces.Unsigned_8 range 0 .. 63) of Ada.Streams.Stream_Element;
type Alphabet_Access is not null access constant Alphabet;
BASE64_ALPHABET : aliased constant Alphabet :=
(Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'),
Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'),
Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'),
Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'),
Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'),
Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'),
Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'),
Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'),
Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'),
Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'),
Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'),
Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'),
Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'),
Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'),
Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'),
Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('+'), Character'Pos ('/'));
BASE64_URL_ALPHABET : aliased constant Alphabet :=
(Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'),
Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'),
Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'),
Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'),
Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'),
Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'),
Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'),
Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'),
Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'),
Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'),
Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'),
Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'),
Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'),
Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'),
Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'),
Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('-'), Character'Pos ('_'));
type Encoder is new Util.Encoders.Transformer with record
Alphabet : Alphabet_Access := BASE64_ALPHABET'Access;
Column : Natural := 0;
Count : Natural := 0;
Value : Interfaces.Unsigned_8;
end record;
type Alphabet_Values is array (Ada.Streams.Stream_Element) of Interfaces.Unsigned_8;
type Alphabet_Values_Access is not null access constant Alphabet_Values;
BASE64_VALUES : aliased constant Alphabet_Values :=
(Character'Pos ('A') => 0, Character'Pos ('B') => 1,
Character'Pos ('C') => 2, Character'Pos ('D') => 3,
Character'Pos ('E') => 4, Character'Pos ('F') => 5,
Character'Pos ('G') => 6, Character'Pos ('H') => 7,
Character'Pos ('I') => 8, Character'Pos ('J') => 9,
Character'Pos ('K') => 10, Character'Pos ('L') => 11,
Character'Pos ('M') => 12, Character'Pos ('N') => 13,
Character'Pos ('O') => 14, Character'Pos ('P') => 15,
Character'Pos ('Q') => 16, Character'Pos ('R') => 17,
Character'Pos ('S') => 18, Character'Pos ('T') => 19,
Character'Pos ('U') => 20, Character'Pos ('V') => 21,
Character'Pos ('W') => 22, Character'Pos ('X') => 23,
Character'Pos ('Y') => 24, Character'Pos ('Z') => 25,
Character'Pos ('a') => 26, Character'Pos ('b') => 27,
Character'Pos ('c') => 28, Character'Pos ('d') => 29,
Character'Pos ('e') => 30, Character'Pos ('f') => 31,
Character'Pos ('g') => 32, Character'Pos ('h') => 33,
Character'Pos ('i') => 34, Character'Pos ('j') => 35,
Character'Pos ('k') => 36, Character'Pos ('l') => 37,
Character'Pos ('m') => 38, Character'Pos ('n') => 39,
Character'Pos ('o') => 40, Character'Pos ('p') => 41,
Character'Pos ('q') => 42, Character'Pos ('r') => 43,
Character'Pos ('s') => 44, Character'Pos ('t') => 45,
Character'Pos ('u') => 46, Character'Pos ('v') => 47,
Character'Pos ('w') => 48, Character'Pos ('x') => 49,
Character'Pos ('y') => 50, Character'Pos ('z') => 51,
Character'Pos ('0') => 52, Character'Pos ('1') => 53,
Character'Pos ('2') => 54, Character'Pos ('3') => 55,
Character'Pos ('4') => 56, Character'Pos ('5') => 57,
Character'Pos ('6') => 58, Character'Pos ('7') => 59,
Character'Pos ('8') => 60, Character'Pos ('9') => 61,
Character'Pos ('+') => 62, Character'Pos ('/') => 63,
others => 16#FF#);
BASE64_URL_VALUES : aliased constant Alphabet_Values :=
(Character'Pos ('A') => 0, Character'Pos ('B') => 1,
Character'Pos ('C') => 2, Character'Pos ('D') => 3,
Character'Pos ('E') => 4, Character'Pos ('F') => 5,
Character'Pos ('G') => 6, Character'Pos ('H') => 7,
Character'Pos ('I') => 8, Character'Pos ('J') => 9,
Character'Pos ('K') => 10, Character'Pos ('L') => 11,
Character'Pos ('M') => 12, Character'Pos ('N') => 13,
Character'Pos ('O') => 14, Character'Pos ('P') => 15,
Character'Pos ('Q') => 16, Character'Pos ('R') => 17,
Character'Pos ('S') => 18, Character'Pos ('T') => 19,
Character'Pos ('U') => 20, Character'Pos ('V') => 21,
Character'Pos ('W') => 22, Character'Pos ('X') => 23,
Character'Pos ('Y') => 24, Character'Pos ('Z') => 25,
Character'Pos ('a') => 26, Character'Pos ('b') => 27,
Character'Pos ('c') => 28, Character'Pos ('d') => 29,
Character'Pos ('e') => 30, Character'Pos ('f') => 31,
Character'Pos ('g') => 32, Character'Pos ('h') => 33,
Character'Pos ('i') => 34, Character'Pos ('j') => 35,
Character'Pos ('k') => 36, Character'Pos ('l') => 37,
Character'Pos ('m') => 38, Character'Pos ('n') => 39,
Character'Pos ('o') => 40, Character'Pos ('p') => 41,
Character'Pos ('q') => 42, Character'Pos ('r') => 43,
Character'Pos ('s') => 44, Character'Pos ('t') => 45,
Character'Pos ('u') => 46, Character'Pos ('v') => 47,
Character'Pos ('w') => 48, Character'Pos ('x') => 49,
Character'Pos ('y') => 50, Character'Pos ('z') => 51,
Character'Pos ('0') => 52, Character'Pos ('1') => 53,
Character'Pos ('2') => 54, Character'Pos ('3') => 55,
Character'Pos ('4') => 56, Character'Pos ('5') => 57,
Character'Pos ('6') => 58, Character'Pos ('7') => 59,
Character'Pos ('8') => 60, Character'Pos ('9') => 61,
Character'Pos ('-') => 62, Character'Pos ('_') => 63,
others => 16#FF#);
type Decoder is new Util.Encoders.Transformer with record
Values : Alphabet_Values_Access := BASE64_VALUES'Access;
end record;
end Util.Encoders.Base64;
|
BrickBot/Bound-T-H8-300 | Ada | 4,548 | ads | -- Bounded_Set_Pool (decl)
--
-- Finite-set structures, generic in the element type, and using
-- a common storage pool, with generic size.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.2 $
-- $Date: 2015/10/24 19:36:47 $
--
-- $Log: bounded_set_pool.ads,v $
-- Revision 1.2 2015/10/24 19:36:47 niklas
-- Moved to free licence.
--
-- Revision 1.1 2001-01-07 21:54:16 holsti
-- First version.
--
generic
type Element_Type is private;
--
-- The type of elements in the sets.
Max_Elements : Natural;
--
-- The maximum total number of elements in the sets.
package Bounded_Set_Pool is
type Set_Type is limited private;
--
-- A set of elements of type Value_Type, empty by default.
-- All sets created from one instance of Bounded_Set_Pool use
-- a shared pool holding a total of at most Max_Elements elements.
-- Any single set can contain up to Max_Elements elements, but
-- this maximum value can be realized only if all other sets
-- in the same pool (same instance of Bounded_Set_Pool) are
-- empty.
--
-- Since sets are handled as linear lists, this package is intended
-- chiefly for use with small sets.
Overflow : exception;
--
-- Raised by an attempt to add an element into a set when
-- the pool is full (Max_Elements already present, in total,
-- from all sets in the pool).
Underflow : exception;
--
-- Raised by an attempt to take an element from an empty set.
function Empty (Item : Set_Type) return Boolean;
--
-- Whether the set is currently empty.
procedure Add (
Element : in Element_Type;
To : in out Set_Type);
--
-- Adds the element into the set. No effect if the element is
-- already a member of the set.
-- Raises Overflow if the pool was full, and the element is not
-- already a member.
procedure Take (
From : in out Set_Type;
Element : out Element_Type);
--
-- Takes one (arbitrary) element from the set, and removes it
-- from the set.
-- Raises Underflow if the set was empty.
private
type Link_Type is new Natural range 0 .. Max_Elements;
--
-- A reference to an element (item) in the pool.
-- The value zero means "none".
None : constant Link_Type := 0;
subtype Index_Type is Link_Type range 1 .. Link_Type'Last;
--
-- A reference to an element (item) in the pool, excluding
-- the case "none".
type Set_Type is record
Head : Link_Type := None;
end record;
--
-- The elements in the set are stored as a list of pool
-- locations. The Set_Type points to the head of the list,
-- and each element points to the next element, except the
-- last element where the pointer is None.
end Bounded_Set_Pool;
|
reznikmm/matreshka | Ada | 4,772 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_Tracked_Changes_Elements;
package Matreshka.ODF_Text.Tracked_Changes_Elements is
type Text_Tracked_Changes_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Tracked_Changes_Elements.ODF_Text_Tracked_Changes
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Tracked_Changes_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Tracked_Changes_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Tracked_Changes_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Tracked_Changes_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Tracked_Changes_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Tracked_Changes_Elements;
|
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.Presentation_Speed_Attributes is
pragma Preelaborate;
type ODF_Presentation_Speed_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Presentation_Speed_Attribute_Access is
access all ODF_Presentation_Speed_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Presentation_Speed_Attributes;
|
zhmu/ananas | Ada | 7,164 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . S T R E A M _ A T T R I B U T E S . X D R --
-- --
-- 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains alternate implementations of the stream attributes
-- for elementary types based on the XDR standard. These are the subprograms
-- that are directly accessed by occurrences of the stream attributes where
-- the type is elementary.
-- It is especially useful for exchanging streams between two different
-- systems with different basic type representations and endianness.
-- We only provide the subprograms for the standard base types. For user
-- defined types, the subprogram for the corresponding root type is called
-- with an appropriate conversion.
package System.Stream_Attributes.XDR is
pragma Preelaborate;
pragma Suppress (Accessibility_Check, XDR);
-- No need to check accessibility on arguments of subprograms
---------------------
-- Input Functions --
---------------------
-- Functions for S'Input attribute. These functions are also used for
-- S'Read, with the obvious transformation, since the input operation
-- is the same for all elementary types (no bounds or discriminants
-- are involved).
function I_AD (Stream : not null access RST) return Fat_Pointer;
function I_AS (Stream : not null access RST) return Thin_Pointer;
function I_B (Stream : not null access RST) return Boolean;
function I_C (Stream : not null access RST) return Character;
function I_F (Stream : not null access RST) return Float;
function I_I (Stream : not null access RST) return Integer;
function I_I24 (Stream : not null access RST) return Integer_24;
function I_LF (Stream : not null access RST) return Long_Float;
function I_LI (Stream : not null access RST) return Long_Integer;
function I_LLF (Stream : not null access RST) return Long_Long_Float;
function I_LLI (Stream : not null access RST) return Long_Long_Integer;
function I_LLU (Stream : not null access RST) return UST.Long_Long_Unsigned;
function I_LU (Stream : not null access RST) return UST.Long_Unsigned;
function I_SF (Stream : not null access RST) return Short_Float;
function I_SI (Stream : not null access RST) return Short_Integer;
function I_SSI (Stream : not null access RST) return Short_Short_Integer;
function I_SSU (Stream : not null access RST) return
UST.Short_Short_Unsigned;
function I_SU (Stream : not null access RST) return UST.Short_Unsigned;
function I_U (Stream : not null access RST) return UST.Unsigned;
function I_U24 (Stream : not null access RST) return Unsigned_24;
function I_WC (Stream : not null access RST) return Wide_Character;
function I_WWC (Stream : not null access RST) return Wide_Wide_Character;
-----------------------
-- Output Procedures --
-----------------------
-- Procedures for S'Write attribute. These procedures are also used for
-- 'Output, since for elementary types there is no difference between
-- 'Write and 'Output because there are no discriminants or bounds to
-- be written.
procedure W_AD (Stream : not null access RST; Item : Fat_Pointer);
procedure W_AS (Stream : not null access RST; Item : Thin_Pointer);
procedure W_B (Stream : not null access RST; Item : Boolean);
procedure W_C (Stream : not null access RST; Item : Character);
procedure W_F (Stream : not null access RST; Item : Float);
procedure W_I (Stream : not null access RST; Item : Integer);
procedure W_I24 (Stream : not null access RST; Item : Integer_24);
procedure W_LF (Stream : not null access RST; Item : Long_Float);
procedure W_LI (Stream : not null access RST; Item : Long_Integer);
procedure W_LLF (Stream : not null access RST; Item : Long_Long_Float);
procedure W_LLI (Stream : not null access RST; Item : Long_Long_Integer);
procedure W_LLU (Stream : not null access RST; Item :
UST.Long_Long_Unsigned);
procedure W_LU (Stream : not null access RST; Item : UST.Long_Unsigned);
procedure W_SF (Stream : not null access RST; Item : Short_Float);
procedure W_SI (Stream : not null access RST; Item : Short_Integer);
procedure W_SSI (Stream : not null access RST; Item : Short_Short_Integer);
procedure W_SSU (Stream : not null access RST; Item :
UST.Short_Short_Unsigned);
procedure W_SU (Stream : not null access RST; Item : UST.Short_Unsigned);
procedure W_U (Stream : not null access RST; Item : UST.Unsigned);
procedure W_U24 (Stream : not null access RST; Item : Unsigned_24);
procedure W_WC (Stream : not null access RST; Item : Wide_Character);
procedure W_WWC (Stream : not null access RST; Item : Wide_Wide_Character);
end System.Stream_Attributes.XDR;
|
reznikmm/matreshka | Ada | 4,025 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Form_Allow_Inserts_Attributes;
package Matreshka.ODF_Form.Allow_Inserts_Attributes is
type Form_Allow_Inserts_Attribute_Node is
new Matreshka.ODF_Form.Abstract_Form_Attribute_Node
and ODF.DOM.Form_Allow_Inserts_Attributes.ODF_Form_Allow_Inserts_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_Allow_Inserts_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Form_Allow_Inserts_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Form.Allow_Inserts_Attributes;
|
twdroeger/ada-awa | Ada | 10,300 | adb | -----------------------------------------------------------------------
-- awa-events-dispatchers-actions -- Event dispatcher to Ada bean actions
-- Copyright (C) 2012, 2015, 2017, 2018 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.Strings.Unbounded;
with Ada.Exceptions;
with Util.Beans.Objects;
with Util.Beans.Basic;
with Util.Log.Loggers;
with EL.Contexts;
with EL.Contexts.TLS;
with EL.Variables;
with EL.Variables.Default;
with ASF.Beans;
with ASF.Requests;
with ASF.Sessions;
with AWA.Events.Action_Method;
package body AWA.Events.Dispatchers.Actions is
use Ada.Strings.Unbounded;
use Util.Log;
Log : constant Loggers.Logger := Loggers.Create ("AWA.Events.Dispatchers.Actions");
-- ------------------------------
-- Dispatch the event identified by <b>Event</b>.
-- The event actions which are associated with the event are executed synchronously.
-- ------------------------------
overriding
procedure Dispatch (Manager : in Action_Dispatcher;
Event : in Module_Event'Class) is
use Util.Beans.Objects;
-- Dispatch the event to the event action identified by <b>Action</b>.
procedure Dispatch_One (Action : in Event_Action);
type Event_Bean is new Util.Beans.Basic.Readonly_Bean with null record;
overriding
function Get_Value (From : in Event_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- ------------------------------
-- 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 Event_Bean;
Name : in String) return Util.Beans.Objects.Object is
pragma Unreferenced (From);
begin
return Event.Get_Value (Name);
end Get_Value;
Variables : aliased EL.Variables.Default.Default_Variable_Mapper;
-- ------------------------------
-- Default Resolver
-- ------------------------------
type Event_ELResolver is limited new EL.Contexts.ELResolver with record
Request : ASF.Requests.Request_Access;
Application : AWA.Applications.Application_Access;
end record;
overriding
function Get_Value (Resolver : Event_ELResolver;
Context : EL.Contexts.ELContext'Class;
Base : access Util.Beans.Basic.Readonly_Bean'Class;
Name : Unbounded_String) return Util.Beans.Objects.Object;
overriding
procedure Set_Value (Resolver : in out Event_ELResolver;
Context : in EL.Contexts.ELContext'Class;
Base : access Util.Beans.Basic.Bean'Class;
Name : in Unbounded_String;
Value : in Util.Beans.Objects.Object);
-- ------------------------------
-- Get the value associated with a base object and a given property.
-- ------------------------------
overriding
function Get_Value (Resolver : Event_ELResolver;
Context : EL.Contexts.ELContext'Class;
Base : access Util.Beans.Basic.Readonly_Bean'Class;
Name : Unbounded_String) return Util.Beans.Objects.Object is
use Util.Beans.Basic;
use type ASF.Requests.Request_Access;
Result : Object;
Bean : Util.Beans.Basic.Readonly_Bean_Access;
Scope : ASF.Beans.Scope_Type;
Key : constant String := To_String (Name);
begin
if Base /= null then
return Base.Get_Value (Key);
end if;
if Resolver.Request /= null then
Result := Resolver.Request.Get_Attribute (Key);
if not Util.Beans.Objects.Is_Null (Result) then
return Result;
end if;
-- If there is a session, look if the attribute is defined there.
declare
Session : constant ASF.Sessions.Session := Resolver.Request.Get_Session;
begin
if Session.Is_Valid then
Result := Session.Get_Attribute (Key);
if not Util.Beans.Objects.Is_Null (Result) then
return Result;
end if;
end if;
end;
end if;
Resolver.Application.Create (Name, Context, Bean, Scope);
if Bean = null then
return Resolver.Application.Get_Global (Name, Context);
end if;
Result := To_Object (Bean);
if Resolver.Request /= null then
Resolver.Request.Set_Attribute (Key, Result);
else
Variables.Bind (Key, Result);
end if;
return Result;
end Get_Value;
-- ------------------------------
-- Set the value associated with a base object and a given property.
-- ------------------------------
overriding
procedure Set_Value (Resolver : in out Event_ELResolver;
Context : in EL.Contexts.ELContext'Class;
Base : access Util.Beans.Basic.Bean'Class;
Name : in Unbounded_String;
Value : in Util.Beans.Objects.Object) is
pragma Unreferenced (Context);
use type ASF.Requests.Request_Access;
Key : constant String := To_String (Name);
begin
if Base /= null then
Base.Set_Value (Name => Key, Value => Value);
elsif Resolver.Request /= null then
Resolver.Request.Set_Attribute (Name => Key, Value => Value);
else
Variables.Bind (To_String (Name), Value);
end if;
end Set_Value;
Local_Event : aliased Event_Bean;
Resolver : aliased Event_ELResolver;
ELContext : aliased EL.Contexts.TLS.TLS_Context;
-- ------------------------------
-- Dispatch the event to the event action identified by <b>Action</b>.
-- ------------------------------
procedure Dispatch_One (Action : in Event_Action) is
use Ada.Exceptions;
Method : EL.Expressions.Method_Info;
begin
Method := Action.Action.Get_Method_Info (Context => ELContext);
if Method.Object.all in Util.Beans.Basic.Bean'Class then
-- If we have a prepare method and the bean provides a Set_Value method,
-- call the preparation method to fill the bean with some values.
EL.Beans.Initialize (Util.Beans.Basic.Bean'Class (Method.Object.all),
Action.Properties,
ELContext);
end if;
-- Execute the specified method on the bean and give it the event object.
AWA.Events.Action_Method.Execute (Method => Method,
Param => Event);
-- If an exception is raised by the action, do not propagate it:
-- o We have to dispatch the event to other actions.
-- o The event may be dispatched asynchronously and there is no handler
-- that could handle such exception
exception
when E : others =>
Log.Error ("Error when executing event action {0}: {1}: {2}",
Action.Action.Get_Expression, Exception_Name (E), Exception_Message (E));
end Dispatch_One;
Pos : Event_Action_Lists.Cursor := Manager.Actions.First;
begin
Resolver.Application := Manager.Application;
ELContext.Set_Resolver (Resolver'Unchecked_Access);
ELContext.Set_Variable_Mapper (Variables'Unchecked_Access);
Variables.Bind (Name => "event",
Value => To_Object (Local_Event'Unchecked_Access, STATIC));
while Event_Action_Lists.Has_Element (Pos) loop
Event_Action_Lists.Query_Element (Pos, Dispatch_One'Access);
Event_Action_Lists.Next (Pos);
end loop;
end Dispatch;
-- ------------------------------
-- Add an action invoked when an event is dispatched through this dispatcher.
-- When the event queue dispatches the event, the Ada bean identified by the method action
-- represented by <b>Action</b> is created and initialized by evaluating and setting the
-- parameters defined in <b>Params</b>. The action method is then invoked.
-- ------------------------------
overriding
procedure Add_Action (Manager : in out Action_Dispatcher;
Action : in EL.Expressions.Method_Expression;
Params : in EL.Beans.Param_Vectors.Vector) is
Item : Event_Action;
begin
Item.Action := Action;
Item.Properties := Params;
Manager.Actions.Append (Item);
end Add_Action;
-- ------------------------------
-- Create a new dispatcher associated with the application.
-- ------------------------------
function Create_Dispatcher (Application : in AWA.Applications.Application_Access)
return Dispatcher_Access is
Result : constant Dispatcher_Access := new Action_Dispatcher '(Dispatcher with
Application => Application,
others => <>);
begin
return Result.all'Access;
end Create_Dispatcher;
end AWA.Events.Dispatchers.Actions;
|
reznikmm/matreshka | Ada | 3,641 | 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 XML.DOM.Elements;
package ODF.DOM.Elements.Table.Table_Column is
type ODF_Table_Table_Column is
new XML.DOM.Elements.DOM_Element with private;
private
type ODF_Table_Table_Column is
new XML.DOM.Elements.DOM_Element with null record;
end ODF.DOM.Elements.Table.Table_Column;
|
oresat/oresat-c3-rf | Ada | 32,452 | adb | M:main
F:Fmain$pwrmgmt_irq$0$0({2}DF,SV:S),C,0,0,1,6,0
F:Fmain$transmit_packet$0$0({2}DF,SV:S),C,0,0,0,0,0
F:Fmain$display_transmit_packet$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$axradio_statuschange$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$enable_radio_interrupt_in_mcu_pin$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$disable_radio_interrupt_in_mcu_pin$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:Fmain$wakeup_callback$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$_sdcc_external_startup$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$main$0$0({2}DF,SI:S),C,0,0,0,0,0
F:G$main$0$0({2}DF,SI:S),C,0,0,0,0,0
T:Fmain$wtimer_callback[({0}S:S$next$0$0({2}DX,STwtimer_callback:S),Z,0,0)({2}S:S$handler$0$0({2}DC,DF,SV:S),Z,0,0)]
T:Fmain$axradio_status_receive[({0}S:S$phy$0$0({10}STaxradio_status_receive_phy:S),Z,0,0)({10}S:S$mac$0$0({12}STaxradio_status_receive_mac:S),Z,0,0)({22}S:S$pktdata$0$0({2}DX,SC:U),Z,0,0)({24}S:S$pktlen$0$0({2}SI:U),Z,0,0)]
T:Fmain$axradio_address[({0}S:S$addr$0$0({5}DA5d,SC:U),Z,0,0)]
T:Fmain$axradio_address_mask[({0}S:S$addr$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$mask$0$0({5}DA5d,SC:U),Z,0,0)]
T:Fmain$__00000000[({0}S:S$rx$0$0({26}STaxradio_status_receive:S),Z,0,0)({0}S:S$cs$0$0({3}STaxradio_status_channelstate:S),Z,0,0)]
T:Fmain$axradio_status_channelstate[({0}S:S$rssi$0$0({2}SI:S),Z,0,0)({2}S:S$busy$0$0({1}SC:U),Z,0,0)]
T:Fmain$u32endian[({0}S:S$b0$0$0({1}SC:U),Z,0,0)({1}S:S$b1$0$0({1}SC:U),Z,0,0)({2}S:S$b2$0$0({1}SC:U),Z,0,0)({3}S:S$b3$0$0({1}SC:U),Z,0,0)]
T:Fmain$u16endian[({0}S:S$b0$0$0({1}SC:U),Z,0,0)({1}S:S$b1$0$0({1}SC:U),Z,0,0)]
T:Fmain$wtimer_desc[({0}S:S$next$0$0({2}DX,STwtimer_desc:S),Z,0,0)({2}S:S$handler$0$0({2}DC,DF,SV:S),Z,0,0)({4}S:S$time$0$0({4}SL:U),Z,0,0)]
T:Fmain$axradio_status_receive_mac[({0}S:S$remoteaddr$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$localaddr$0$0({5}DA5d,SC:U),Z,0,0)({10}S:S$raw$0$0({2}DX,SC:U),Z,0,0)]
T:Fmain$calsector[({0}S:S$id$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$len$0$0({1}SC:U),Z,0,0)({6}S:S$devid$0$0({6}DA6d,SC:U),Z,0,0)({12}S:S$calg00gain$0$0({2}DA2d,SC:U),Z,0,0)({14}S:S$calg01gain$0$0({2}DA2d,SC:U),Z,0,0)({16}S:S$calg10gain$0$0({2}DA2d,SC:U),Z,0,0)({18}S:S$caltempgain$0$0({2}DA2d,SC:U),Z,0,0)({20}S:S$caltempoffs$0$0({2}DA2d,SC:U),Z,0,0)({22}S:S$frcoscfreq$0$0({2}DA2d,SC:U),Z,0,0)({24}S:S$lposcfreq$0$0({2}DA2d,SC:U),Z,0,0)({26}S:S$lposcfreq_fast$0$0({2}DA2d,SC:U),Z,0,0)({28}S:S$powctrl0$0$0({1}SC:U),Z,0,0)({29}S:S$powctrl1$0$0({1}SC:U),Z,0,0)({30}S:S$ref$0$0({1}SC:U),Z,0,0)]
T:Fmain$axradio_status_receive_phy[({0}S:S$rssi$0$0({2}SI:S),Z,0,0)({2}S:S$offset$0$0({4}SL:S),Z,0,0)({6}S:S$timeoffset$0$0({2}SI:S),Z,0,0)({8}S:S$period$0$0({2}SI:S),Z,0,0)]
T:Fmain$axradio_status[({0}S:S$status$0$0({1}SC:U),Z,0,0)({1}S:S$error$0$0({1}SC:U),Z,0,0)({2}S:S$time$0$0({4}SL:U),Z,0,0)({6}S:S$u$0$0({26}ST__00000000:S),Z,0,0)]
S:G$random_seed$0$0({2}SI:U),E,0,0
S:G$wtimer0_clksrc$0$0({1}SC:U),E,0,0
S:G$wtimer1_clksrc$0$0({1}SC:U),E,0,0
S:G$wtimer1_prescaler$0$0({1}SC:U),E,0,0
S:G$_start__stack$0$0({0}DA0d,SC:U),E,0,0
S:G$pkt_counter$0$0({2}SI:U),E,0,0
S:G$coldstart$0$0({1}SC:U),E,0,0
S:Lmain.enter_critical$crit$1$29({1}SC:U),E,0,0
S:Lmain.exit_critical$crit$1$30({1}SC:U),E,0,0
S:Lmain.pwrmgmt_irq$pc$1$364({1}SC:U),R,0,0,[r7]
S:Lmain.wakeup_callback$desc$1$398({2}DX,STwtimer_desc:S),R,0,0,[]
S:Lmain._sdcc_external_startup$c$2$402({1}SC:U),R,0,0,[]
S:Lmain._sdcc_external_startup$p$2$402({1}SC:U),R,0,0,[]
S:Lmain._sdcc_external_startup$c$2$403({1}SC:U),R,0,0,[]
S:Lmain._sdcc_external_startup$p$2$403({1}SC:U),R,0,0,[]
S:Lmain.main$saved_button_state$1$405({1}SC:U),E,0,0
S:Lmain.main$i$1$405({1}SC:U),R,0,0,[r7]
S:Lmain.main$x$3$417({1}SC:U),R,0,0,[r6]
S:Lmain.main$flg$3$421({1}SC:U),R,0,0,[r6]
S:Lmain.main$flg$3$423({1}SC:U),R,0,0,[r7]
S:Lmain._sdcc_external_startup$sloc0$1$0({1}SB0$0:S),H,0,0
S:G$ADCCH0VAL0$0$0({1}SC:U),F,0,0
S:G$ADCCH0VAL1$0$0({1}SC:U),F,0,0
S:G$ADCCH0VAL$0$0({2}SI:U),F,0,0
S:G$ADCCH1VAL0$0$0({1}SC:U),F,0,0
S:G$ADCCH1VAL1$0$0({1}SC:U),F,0,0
S:G$ADCCH1VAL$0$0({2}SI:U),F,0,0
S:G$ADCCH2VAL0$0$0({1}SC:U),F,0,0
S:G$ADCCH2VAL1$0$0({1}SC:U),F,0,0
S:G$ADCCH2VAL$0$0({2}SI:U),F,0,0
S:G$ADCCH3VAL0$0$0({1}SC:U),F,0,0
S:G$ADCCH3VAL1$0$0({1}SC:U),F,0,0
S:G$ADCCH3VAL$0$0({2}SI:U),F,0,0
S:G$ADCTUNE0$0$0({1}SC:U),F,0,0
S:G$ADCTUNE1$0$0({1}SC:U),F,0,0
S:G$ADCTUNE2$0$0({1}SC:U),F,0,0
S:G$DMA0ADDR0$0$0({1}SC:U),F,0,0
S:G$DMA0ADDR1$0$0({1}SC:U),F,0,0
S:G$DMA0ADDR$0$0({2}SI:U),F,0,0
S:G$DMA0CONFIG$0$0({1}SC:U),F,0,0
S:G$DMA1ADDR0$0$0({1}SC:U),F,0,0
S:G$DMA1ADDR1$0$0({1}SC:U),F,0,0
S:G$DMA1ADDR$0$0({2}SI:U),F,0,0
S:G$DMA1CONFIG$0$0({1}SC:U),F,0,0
S:G$FRCOSCCONFIG$0$0({1}SC:U),F,0,0
S:G$FRCOSCCTRL$0$0({1}SC:U),F,0,0
S:G$FRCOSCFREQ0$0$0({1}SC:U),F,0,0
S:G$FRCOSCFREQ1$0$0({1}SC:U),F,0,0
S:G$FRCOSCFREQ$0$0({2}SI:U),F,0,0
S:G$FRCOSCKFILT0$0$0({1}SC:U),F,0,0
S:G$FRCOSCKFILT1$0$0({1}SC:U),F,0,0
S:G$FRCOSCKFILT$0$0({2}SI:U),F,0,0
S:G$FRCOSCPER0$0$0({1}SC:U),F,0,0
S:G$FRCOSCPER1$0$0({1}SC:U),F,0,0
S:G$FRCOSCPER$0$0({2}SI:U),F,0,0
S:G$FRCOSCREF0$0$0({1}SC:U),F,0,0
S:G$FRCOSCREF1$0$0({1}SC:U),F,0,0
S:G$FRCOSCREF$0$0({2}SI:U),F,0,0
S:G$ANALOGA$0$0({1}SC:U),F,0,0
S:G$GPIOENABLE$0$0({1}SC:U),F,0,0
S:G$EXTIRQ$0$0({1}SC:U),F,0,0
S:G$INTCHGA$0$0({1}SC:U),F,0,0
S:G$INTCHGB$0$0({1}SC:U),F,0,0
S:G$INTCHGC$0$0({1}SC:U),F,0,0
S:G$PALTA$0$0({1}SC:U),F,0,0
S:G$PALTB$0$0({1}SC:U),F,0,0
S:G$PALTC$0$0({1}SC:U),F,0,0
S:G$PALTRADIO$0$0({1}SC:U),F,0,0
S:G$PINCHGA$0$0({1}SC:U),F,0,0
S:G$PINCHGB$0$0({1}SC:U),F,0,0
S:G$PINCHGC$0$0({1}SC:U),F,0,0
S:G$PINSEL$0$0({1}SC:U),F,0,0
S:G$LPOSCCONFIG$0$0({1}SC:U),F,0,0
S:G$LPOSCFREQ0$0$0({1}SC:U),F,0,0
S:G$LPOSCFREQ1$0$0({1}SC:U),F,0,0
S:G$LPOSCFREQ$0$0({2}SI:U),F,0,0
S:G$LPOSCKFILT0$0$0({1}SC:U),F,0,0
S:G$LPOSCKFILT1$0$0({1}SC:U),F,0,0
S:G$LPOSCKFILT$0$0({2}SI:U),F,0,0
S:G$LPOSCPER0$0$0({1}SC:U),F,0,0
S:G$LPOSCPER1$0$0({1}SC:U),F,0,0
S:G$LPOSCPER$0$0({2}SI:U),F,0,0
S:G$LPOSCREF0$0$0({1}SC:U),F,0,0
S:G$LPOSCREF1$0$0({1}SC:U),F,0,0
S:G$LPOSCREF$0$0({2}SI:U),F,0,0
S:G$LPXOSCGM$0$0({1}SC:U),F,0,0
S:G$MISCCTRL$0$0({1}SC:U),F,0,0
S:G$OSCCALIB$0$0({1}SC:U),F,0,0
S:G$OSCFORCERUN$0$0({1}SC:U),F,0,0
S:G$OSCREADY$0$0({1}SC:U),F,0,0
S:G$OSCRUN$0$0({1}SC:U),F,0,0
S:G$RADIOFDATAADDR0$0$0({1}SC:U),F,0,0
S:G$RADIOFDATAADDR1$0$0({1}SC:U),F,0,0
S:G$RADIOFDATAADDR$0$0({2}SI:U),F,0,0
S:G$RADIOFSTATADDR0$0$0({1}SC:U),F,0,0
S:G$RADIOFSTATADDR1$0$0({1}SC:U),F,0,0
S:G$RADIOFSTATADDR$0$0({2}SI:U),F,0,0
S:G$RADIOMUX$0$0({1}SC:U),F,0,0
S:G$SCRATCH0$0$0({1}SC:U),F,0,0
S:G$SCRATCH1$0$0({1}SC:U),F,0,0
S:G$SCRATCH2$0$0({1}SC:U),F,0,0
S:G$SCRATCH3$0$0({1}SC:U),F,0,0
S:G$SILICONREV$0$0({1}SC:U),F,0,0
S:G$XTALAMPL$0$0({1}SC:U),F,0,0
S:G$XTALOSC$0$0({1}SC:U),F,0,0
S:G$XTALREADY$0$0({1}SC:U),F,0,0
S:Fmain$flash_deviceid$0$0({6}DA6d,SC:U),F,0,0
S:Fmain$flash_calsector$0$0({31}STcalsector:S),F,0,0
S:G$radio_lcd_display$0$0({0}DA0d,SC:U),F,0,0
S:G$radio_not_found_lcd_display$0$0({0}DA0d,SC:U),F,0,0
S:G$wakeup_desc$0$0({8}STwtimer_desc:S),F,0,0
S:Lmain.transmit_packet$demo_packet_$1$366({6}DA6d,SC:U),F,0,0
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$DPH1$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$DPL1$0$0({1}SC:U),I,0,0
S:G$DPTR0$0$0({2}SI:U),I,0,0
S:G$DPTR1$0$0({2}SI:U),I,0,0
S:G$DPS$0$0({1}SC:U),I,0,0
S:G$E2IE$0$0({1}SC:U),I,0,0
S:G$E2IP$0$0({1}SC:U),I,0,0
S:G$EIE$0$0({1}SC:U),I,0,0
S:G$EIP$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$PCON$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$XPAGE$0$0({1}SC:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$ADCCH0CONFIG$0$0({1}SC:U),I,0,0
S:G$ADCCH1CONFIG$0$0({1}SC:U),I,0,0
S:G$ADCCH2CONFIG$0$0({1}SC:U),I,0,0
S:G$ADCCH3CONFIG$0$0({1}SC:U),I,0,0
S:G$ADCCLKSRC$0$0({1}SC:U),I,0,0
S:G$ADCCONV$0$0({1}SC:U),I,0,0
S:G$ANALOGCOMP$0$0({1}SC:U),I,0,0
S:G$CLKCON$0$0({1}SC:U),I,0,0
S:G$CLKSTAT$0$0({1}SC:U),I,0,0
S:G$CODECONFIG$0$0({1}SC:U),I,0,0
S:G$DBGLNKBUF$0$0({1}SC:U),I,0,0
S:G$DBGLNKSTAT$0$0({1}SC:U),I,0,0
S:G$DIRA$0$0({1}SC:U),I,0,0
S:G$DIRB$0$0({1}SC:U),I,0,0
S:G$DIRC$0$0({1}SC:U),I,0,0
S:G$DIRR$0$0({1}SC:U),I,0,0
S:G$PINA$0$0({1}SC:U),I,0,0
S:G$PINB$0$0({1}SC:U),I,0,0
S:G$PINC$0$0({1}SC:U),I,0,0
S:G$PINR$0$0({1}SC:U),I,0,0
S:G$PORTA$0$0({1}SC:U),I,0,0
S:G$PORTB$0$0({1}SC:U),I,0,0
S:G$PORTC$0$0({1}SC:U),I,0,0
S:G$PORTR$0$0({1}SC:U),I,0,0
S:G$IC0CAPT0$0$0({1}SC:U),I,0,0
S:G$IC0CAPT1$0$0({1}SC:U),I,0,0
S:G$IC0CAPT$0$0({2}SI:U),I,0,0
S:G$IC0MODE$0$0({1}SC:U),I,0,0
S:G$IC0STATUS$0$0({1}SC:U),I,0,0
S:G$IC1CAPT0$0$0({1}SC:U),I,0,0
S:G$IC1CAPT1$0$0({1}SC:U),I,0,0
S:G$IC1CAPT$0$0({2}SI:U),I,0,0
S:G$IC1MODE$0$0({1}SC:U),I,0,0
S:G$IC1STATUS$0$0({1}SC:U),I,0,0
S:G$NVADDR0$0$0({1}SC:U),I,0,0
S:G$NVADDR1$0$0({1}SC:U),I,0,0
S:G$NVADDR$0$0({2}SI:U),I,0,0
S:G$NVDATA0$0$0({1}SC:U),I,0,0
S:G$NVDATA1$0$0({1}SC:U),I,0,0
S:G$NVDATA$0$0({2}SI:U),I,0,0
S:G$NVKEY$0$0({1}SC:U),I,0,0
S:G$NVSTATUS$0$0({1}SC:U),I,0,0
S:G$OC0COMP0$0$0({1}SC:U),I,0,0
S:G$OC0COMP1$0$0({1}SC:U),I,0,0
S:G$OC0COMP$0$0({2}SI:U),I,0,0
S:G$OC0MODE$0$0({1}SC:U),I,0,0
S:G$OC0PIN$0$0({1}SC:U),I,0,0
S:G$OC0STATUS$0$0({1}SC:U),I,0,0
S:G$OC1COMP0$0$0({1}SC:U),I,0,0
S:G$OC1COMP1$0$0({1}SC:U),I,0,0
S:G$OC1COMP$0$0({2}SI:U),I,0,0
S:G$OC1MODE$0$0({1}SC:U),I,0,0
S:G$OC1PIN$0$0({1}SC:U),I,0,0
S:G$OC1STATUS$0$0({1}SC:U),I,0,0
S:G$RADIOACC$0$0({1}SC:U),I,0,0
S:G$RADIOADDR0$0$0({1}SC:U),I,0,0
S:G$RADIOADDR1$0$0({1}SC:U),I,0,0
S:G$RADIOADDR$0$0({2}SI:U),I,0,0
S:G$RADIODATA0$0$0({1}SC:U),I,0,0
S:G$RADIODATA1$0$0({1}SC:U),I,0,0
S:G$RADIODATA2$0$0({1}SC:U),I,0,0
S:G$RADIODATA3$0$0({1}SC:U),I,0,0
S:G$RADIODATA$0$0({4}SL:U),I,0,0
S:G$RADIOSTAT0$0$0({1}SC:U),I,0,0
S:G$RADIOSTAT1$0$0({1}SC:U),I,0,0
S:G$RADIOSTAT$0$0({2}SI:U),I,0,0
S:G$SPCLKSRC$0$0({1}SC:U),I,0,0
S:G$SPMODE$0$0({1}SC:U),I,0,0
S:G$SPSHREG$0$0({1}SC:U),I,0,0
S:G$SPSTATUS$0$0({1}SC:U),I,0,0
S:G$T0CLKSRC$0$0({1}SC:U),I,0,0
S:G$T0CNT0$0$0({1}SC:U),I,0,0
S:G$T0CNT1$0$0({1}SC:U),I,0,0
S:G$T0CNT$0$0({2}SI:U),I,0,0
S:G$T0MODE$0$0({1}SC:U),I,0,0
S:G$T0PERIOD0$0$0({1}SC:U),I,0,0
S:G$T0PERIOD1$0$0({1}SC:U),I,0,0
S:G$T0PERIOD$0$0({2}SI:U),I,0,0
S:G$T0STATUS$0$0({1}SC:U),I,0,0
S:G$T1CLKSRC$0$0({1}SC:U),I,0,0
S:G$T1CNT0$0$0({1}SC:U),I,0,0
S:G$T1CNT1$0$0({1}SC:U),I,0,0
S:G$T1CNT$0$0({2}SI:U),I,0,0
S:G$T1MODE$0$0({1}SC:U),I,0,0
S:G$T1PERIOD0$0$0({1}SC:U),I,0,0
S:G$T1PERIOD1$0$0({1}SC:U),I,0,0
S:G$T1PERIOD$0$0({2}SI:U),I,0,0
S:G$T1STATUS$0$0({1}SC:U),I,0,0
S:G$T2CLKSRC$0$0({1}SC:U),I,0,0
S:G$T2CNT0$0$0({1}SC:U),I,0,0
S:G$T2CNT1$0$0({1}SC:U),I,0,0
S:G$T2CNT$0$0({2}SI:U),I,0,0
S:G$T2MODE$0$0({1}SC:U),I,0,0
S:G$T2PERIOD0$0$0({1}SC:U),I,0,0
S:G$T2PERIOD1$0$0({1}SC:U),I,0,0
S:G$T2PERIOD$0$0({2}SI:U),I,0,0
S:G$T2STATUS$0$0({1}SC:U),I,0,0
S:G$U0CTRL$0$0({1}SC:U),I,0,0
S:G$U0MODE$0$0({1}SC:U),I,0,0
S:G$U0SHREG$0$0({1}SC:U),I,0,0
S:G$U0STATUS$0$0({1}SC:U),I,0,0
S:G$U1CTRL$0$0({1}SC:U),I,0,0
S:G$U1MODE$0$0({1}SC:U),I,0,0
S:G$U1SHREG$0$0({1}SC:U),I,0,0
S:G$U1STATUS$0$0({1}SC:U),I,0,0
S:G$WDTCFG$0$0({1}SC:U),I,0,0
S:G$WDTRESET$0$0({1}SC:U),I,0,0
S:G$WTCFGA$0$0({1}SC:U),I,0,0
S:G$WTCFGB$0$0({1}SC:U),I,0,0
S:G$WTCNTA0$0$0({1}SC:U),I,0,0
S:G$WTCNTA1$0$0({1}SC:U),I,0,0
S:G$WTCNTA$0$0({2}SI:U),I,0,0
S:G$WTCNTB0$0$0({1}SC:U),I,0,0
S:G$WTCNTB1$0$0({1}SC:U),I,0,0
S:G$WTCNTB$0$0({2}SI:U),I,0,0
S:G$WTCNTR1$0$0({1}SC:U),I,0,0
S:G$WTEVTA0$0$0({1}SC:U),I,0,0
S:G$WTEVTA1$0$0({1}SC:U),I,0,0
S:G$WTEVTA$0$0({2}SI:U),I,0,0
S:G$WTEVTB0$0$0({1}SC:U),I,0,0
S:G$WTEVTB1$0$0({1}SC:U),I,0,0
S:G$WTEVTB$0$0({2}SI:U),I,0,0
S:G$WTEVTC0$0$0({1}SC:U),I,0,0
S:G$WTEVTC1$0$0({1}SC:U),I,0,0
S:G$WTEVTC$0$0({2}SI:U),I,0,0
S:G$WTEVTD0$0$0({1}SC:U),I,0,0
S:G$WTEVTD1$0$0({1}SC:U),I,0,0
S:G$WTEVTD$0$0({2}SI:U),I,0,0
S:G$WTIRQEN$0$0({1}SC:U),I,0,0
S:G$WTSTAT$0$0({1}SC:U),I,0,0
S:G$ACC_0$0$0({1}SX:U),J,0,0
S:G$ACC_1$0$0({1}SX:U),J,0,0
S:G$ACC_2$0$0({1}SX:U),J,0,0
S:G$ACC_3$0$0({1}SX:U),J,0,0
S:G$ACC_4$0$0({1}SX:U),J,0,0
S:G$ACC_5$0$0({1}SX:U),J,0,0
S:G$ACC_6$0$0({1}SX:U),J,0,0
S:G$ACC_7$0$0({1}SX:U),J,0,0
S:G$B_0$0$0({1}SX:U),J,0,0
S:G$B_1$0$0({1}SX:U),J,0,0
S:G$B_2$0$0({1}SX:U),J,0,0
S:G$B_3$0$0({1}SX:U),J,0,0
S:G$B_4$0$0({1}SX:U),J,0,0
S:G$B_5$0$0({1}SX:U),J,0,0
S:G$B_6$0$0({1}SX:U),J,0,0
S:G$B_7$0$0({1}SX:U),J,0,0
S:G$E2IE_0$0$0({1}SX:U),J,0,0
S:G$E2IE_1$0$0({1}SX:U),J,0,0
S:G$E2IE_2$0$0({1}SX:U),J,0,0
S:G$E2IE_3$0$0({1}SX:U),J,0,0
S:G$E2IE_4$0$0({1}SX:U),J,0,0
S:G$E2IE_5$0$0({1}SX:U),J,0,0
S:G$E2IE_6$0$0({1}SX:U),J,0,0
S:G$E2IE_7$0$0({1}SX:U),J,0,0
S:G$E2IP_0$0$0({1}SX:U),J,0,0
S:G$E2IP_1$0$0({1}SX:U),J,0,0
S:G$E2IP_2$0$0({1}SX:U),J,0,0
S:G$E2IP_3$0$0({1}SX:U),J,0,0
S:G$E2IP_4$0$0({1}SX:U),J,0,0
S:G$E2IP_5$0$0({1}SX:U),J,0,0
S:G$E2IP_6$0$0({1}SX:U),J,0,0
S:G$E2IP_7$0$0({1}SX:U),J,0,0
S:G$EIE_0$0$0({1}SX:U),J,0,0
S:G$EIE_1$0$0({1}SX:U),J,0,0
S:G$EIE_2$0$0({1}SX:U),J,0,0
S:G$EIE_3$0$0({1}SX:U),J,0,0
S:G$EIE_4$0$0({1}SX:U),J,0,0
S:G$EIE_5$0$0({1}SX:U),J,0,0
S:G$EIE_6$0$0({1}SX:U),J,0,0
S:G$EIE_7$0$0({1}SX:U),J,0,0
S:G$EIP_0$0$0({1}SX:U),J,0,0
S:G$EIP_1$0$0({1}SX:U),J,0,0
S:G$EIP_2$0$0({1}SX:U),J,0,0
S:G$EIP_3$0$0({1}SX:U),J,0,0
S:G$EIP_4$0$0({1}SX:U),J,0,0
S:G$EIP_5$0$0({1}SX:U),J,0,0
S:G$EIP_6$0$0({1}SX:U),J,0,0
S:G$EIP_7$0$0({1}SX:U),J,0,0
S:G$IE_0$0$0({1}SX:U),J,0,0
S:G$IE_1$0$0({1}SX:U),J,0,0
S:G$IE_2$0$0({1}SX:U),J,0,0
S:G$IE_3$0$0({1}SX:U),J,0,0
S:G$IE_4$0$0({1}SX:U),J,0,0
S:G$IE_5$0$0({1}SX:U),J,0,0
S:G$IE_6$0$0({1}SX:U),J,0,0
S:G$IE_7$0$0({1}SX:U),J,0,0
S:G$EA$0$0({1}SX:U),J,0,0
S:G$IP_0$0$0({1}SX:U),J,0,0
S:G$IP_1$0$0({1}SX:U),J,0,0
S:G$IP_2$0$0({1}SX:U),J,0,0
S:G$IP_3$0$0({1}SX:U),J,0,0
S:G$IP_4$0$0({1}SX:U),J,0,0
S:G$IP_5$0$0({1}SX:U),J,0,0
S:G$IP_6$0$0({1}SX:U),J,0,0
S:G$IP_7$0$0({1}SX:U),J,0,0
S:G$P$0$0({1}SX:U),J,0,0
S:G$F1$0$0({1}SX:U),J,0,0
S:G$OV$0$0({1}SX:U),J,0,0
S:G$RS0$0$0({1}SX:U),J,0,0
S:G$RS1$0$0({1}SX:U),J,0,0
S:G$F0$0$0({1}SX:U),J,0,0
S:G$AC$0$0({1}SX:U),J,0,0
S:G$CY$0$0({1}SX:U),J,0,0
S:G$PINA_0$0$0({1}SX:U),J,0,0
S:G$PINA_1$0$0({1}SX:U),J,0,0
S:G$PINA_2$0$0({1}SX:U),J,0,0
S:G$PINA_3$0$0({1}SX:U),J,0,0
S:G$PINA_4$0$0({1}SX:U),J,0,0
S:G$PINA_5$0$0({1}SX:U),J,0,0
S:G$PINA_6$0$0({1}SX:U),J,0,0
S:G$PINA_7$0$0({1}SX:U),J,0,0
S:G$PINB_0$0$0({1}SX:U),J,0,0
S:G$PINB_1$0$0({1}SX:U),J,0,0
S:G$PINB_2$0$0({1}SX:U),J,0,0
S:G$PINB_3$0$0({1}SX:U),J,0,0
S:G$PINB_4$0$0({1}SX:U),J,0,0
S:G$PINB_5$0$0({1}SX:U),J,0,0
S:G$PINB_6$0$0({1}SX:U),J,0,0
S:G$PINB_7$0$0({1}SX:U),J,0,0
S:G$PINC_0$0$0({1}SX:U),J,0,0
S:G$PINC_1$0$0({1}SX:U),J,0,0
S:G$PINC_2$0$0({1}SX:U),J,0,0
S:G$PINC_3$0$0({1}SX:U),J,0,0
S:G$PINC_4$0$0({1}SX:U),J,0,0
S:G$PINC_5$0$0({1}SX:U),J,0,0
S:G$PINC_6$0$0({1}SX:U),J,0,0
S:G$PINC_7$0$0({1}SX:U),J,0,0
S:G$PORTA_0$0$0({1}SX:U),J,0,0
S:G$PORTA_1$0$0({1}SX:U),J,0,0
S:G$PORTA_2$0$0({1}SX:U),J,0,0
S:G$PORTA_3$0$0({1}SX:U),J,0,0
S:G$PORTA_4$0$0({1}SX:U),J,0,0
S:G$PORTA_5$0$0({1}SX:U),J,0,0
S:G$PORTA_6$0$0({1}SX:U),J,0,0
S:G$PORTA_7$0$0({1}SX:U),J,0,0
S:G$PORTB_0$0$0({1}SX:U),J,0,0
S:G$PORTB_1$0$0({1}SX:U),J,0,0
S:G$PORTB_2$0$0({1}SX:U),J,0,0
S:G$PORTB_3$0$0({1}SX:U),J,0,0
S:G$PORTB_4$0$0({1}SX:U),J,0,0
S:G$PORTB_5$0$0({1}SX:U),J,0,0
S:G$PORTB_6$0$0({1}SX:U),J,0,0
S:G$PORTB_7$0$0({1}SX:U),J,0,0
S:G$PORTC_0$0$0({1}SX:U),J,0,0
S:G$PORTC_1$0$0({1}SX:U),J,0,0
S:G$PORTC_2$0$0({1}SX:U),J,0,0
S:G$PORTC_3$0$0({1}SX:U),J,0,0
S:G$PORTC_4$0$0({1}SX:U),J,0,0
S:G$PORTC_5$0$0({1}SX:U),J,0,0
S:G$PORTC_6$0$0({1}SX:U),J,0,0
S:G$PORTC_7$0$0({1}SX:U),J,0,0
S:G$delay$0$0({2}DF,SV:S),C,0,0
S:G$random$0$0({2}DF,SI:U),C,0,0
S:G$signextend12$0$0({2}DF,SL:S),C,0,0
S:G$signextend16$0$0({2}DF,SL:S),C,0,0
S:G$signextend20$0$0({2}DF,SL:S),C,0,0
S:G$signextend24$0$0({2}DF,SL:S),C,0,0
S:G$hweight8$0$0({2}DF,SC:U),C,0,0
S:G$hweight16$0$0({2}DF,SC:U),C,0,0
S:G$hweight32$0$0({2}DF,SC:U),C,0,0
S:G$signedlimit16$0$0({2}DF,SI:S),C,0,0
S:G$checksignedlimit16$0$0({2}DF,SC:U),C,0,0
S:G$signedlimit32$0$0({2}DF,SL:S),C,0,0
S:G$checksignedlimit32$0$0({2}DF,SC:U),C,0,0
S:G$gray_encode8$0$0({2}DF,SC:U),C,0,0
S:G$gray_decode8$0$0({2}DF,SC:U),C,0,0
S:G$rev8$0$0({2}DF,SC:U),C,0,0
S:G$fmemset$0$0({2}DF,SV:S),C,0,0
S:G$fmemcpy$0$0({2}DF,SV:S),C,0,0
S:G$get_startcause$0$0({2}DF,SC:U),C,0,0
S:G$wtimer_standby$0$0({2}DF,SV:S),C,0,0
S:G$enter_standby$0$0({2}DF,SV:S),C,0,0
S:G$enter_deepsleep$0$0({2}DF,SV:S),C,0,0
S:G$enter_sleep$0$0({2}DF,SV:S),C,0,0
S:G$enter_sleep_cont$0$0({2}DF,SV:S),C,0,0
S:G$reset_cpu$0$0({2}DF,SV:S),C,0,0
S:G$enter_critical$0$0({2}DF,SC:U),C,0,0
S:G$exit_critical$0$0({2}DF,SV:S),C,0,0
S:G$reenter_critical$0$0({2}DF,SV:S),C,0,0
S:G$__enable_irq$0$0({2}DF,SV:S),C,0,0
S:G$__disable_irq$0$0({2}DF,SV:S),C,0,0
S:G$axradio_init$0$0({2}DF,SC:U),C,0,0
S:G$axradio_cansleep$0$0({2}DF,SC:U),C,0,0
S:G$axradio_set_mode$0$0({2}DF,SC:U),C,0,0
S:G$axradio_get_mode$0$0({2}DF,SC:U),C,0,0
S:G$axradio_set_channel$0$0({2}DF,SC:U),C,0,0
S:G$axradio_get_channel$0$0({2}DF,SC:U),C,0,0
S:G$axradio_get_pllrange$0$0({2}DF,SI:U),C,0,0
S:G$axradio_get_pllvcoi$0$0({2}DF,SC:U),C,0,0
S:G$axradio_set_local_address$0$0({2}DF,SV:S),C,0,0
S:G$axradio_get_local_address$0$0({2}DF,SV:S),C,0,0
S:G$axradio_set_default_remote_address$0$0({2}DF,SV:S),C,0,0
S:G$axradio_get_default_remote_address$0$0({2}DF,SV:S),C,0,0
S:G$axradio_transmit$0$0({2}DF,SC:U),C,0,0
S:G$axradio_set_freqoffset$0$0({2}DF,SC:U),C,0,0
S:G$axradio_get_freqoffset$0$0({2}DF,SL:S),C,0,0
S:G$axradio_conv_freq_tohz$0$0({2}DF,SL:S),C,0,0
S:G$axradio_conv_freq_fromhz$0$0({2}DF,SL:S),C,0,0
S:G$axradio_conv_timeinterval_totimer0$0$0({2}DF,SL:S),C,0,0
S:G$axradio_conv_time_totimer0$0$0({2}DF,SL:U),C,0,0
S:G$axradio_agc_freeze$0$0({2}DF,SC:U),C,0,0
S:G$axradio_agc_thaw$0$0({2}DF,SC:U),C,0,0
S:G$axradio_calibrate_lposc$0$0({2}DF,SV:S),C,0,0
S:G$axradio_check_fourfsk_modulation$0$0({2}DF,SC:U),C,0,0
S:G$axradio_get_transmitter_pa_type$0$0({2}DF,SC:U),C,0,0
S:G$axradio_setup_pincfg1$0$0({2}DF,SV:S),C,0,0
S:G$axradio_setup_pincfg2$0$0({2}DF,SV:S),C,0,0
S:G$axradio_commsleepexit$0$0({2}DF,SV:S),C,0,0
S:G$axradio_dbgpkt_enableIRQ$0$0({2}DF,SV:S),C,0,0
S:G$axradio_isr$0$0({2}DF,SV:S),C,0,0
S:G$radio_read16$0$0({2}DF,SI:U),C,0,0
S:G$radio_read24$0$0({2}DF,SL:U),C,0,0
S:G$radio_read32$0$0({2}DF,SL:U),C,0,0
S:G$radio_write16$0$0({2}DF,SV:S),C,0,0
S:G$radio_write24$0$0({2}DF,SV:S),C,0,0
S:G$radio_write32$0$0({2}DF,SV:S),C,0,0
S:G$ax5031_comminit$0$0({2}DF,SV:S),C,0,0
S:G$ax5031_commsleepexit$0$0({2}DF,SV:S),C,0,0
S:G$ax5031_reset$0$0({2}DF,SC:U),C,0,0
S:G$ax5031_rclk_enable$0$0({2}DF,SV:S),C,0,0
S:G$ax5031_rclk_disable$0$0({2}DF,SV:S),C,0,0
S:G$ax5031_readfifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5031_writefifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5042_comminit$0$0({2}DF,SV:S),C,0,0
S:G$ax5042_commsleepexit$0$0({2}DF,SV:S),C,0,0
S:G$ax5042_reset$0$0({2}DF,SC:U),C,0,0
S:G$ax5042_rclk_enable$0$0({2}DF,SV:S),C,0,0
S:G$ax5042_rclk_disable$0$0({2}DF,SV:S),C,0,0
S:G$ax5042_readfifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5042_writefifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_comminit$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_commsleepexit$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_reset$0$0({2}DF,SC:U),C,0,0
S:G$ax5043_enter_deepsleep$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_wakeup_deepsleep$0$0({2}DF,SC:U),C,0,0
S:G$ax5043_rclk_enable$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_rclk_disable$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_rclk_wait_stable$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_readfifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_writefifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_set_pwramp_pin$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_get_pwramp_pin$0$0({2}DF,SC:U),C,0,0
S:G$ax5043_set_antsel_pin$0$0({2}DF,SV:S),C,0,0
S:G$ax5043_get_antsel_pin$0$0({2}DF,SC:U),C,0,0
S:G$ax5044_45_comminit$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_commsleepexit$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_reset$0$0({2}DF,SC:U),C,0,0
S:G$ax5044_45_enter_deepsleep$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_wakeup_deepsleep$0$0({2}DF,SC:U),C,0,0
S:G$ax5044_45_rclk_enable$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_rclk_disable$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_rclk_wait_stable$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_readfifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_writefifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_set_pwramp_pin$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_get_pwramp_pin$0$0({2}DF,SC:U),C,0,0
S:G$ax5044_45_set_antsel_pin$0$0({2}DF,SV:S),C,0,0
S:G$ax5044_45_get_antsel_pin$0$0({2}DF,SC:U),C,0,0
S:G$ax5051_comminit$0$0({2}DF,SV:S),C,0,0
S:G$ax5051_commsleepexit$0$0({2}DF,SV:S),C,0,0
S:G$ax5051_reset$0$0({2}DF,SC:U),C,0,0
S:G$ax5051_rclk_enable$0$0({2}DF,SV:S),C,0,0
S:G$ax5051_rclk_disable$0$0({2}DF,SV:S),C,0,0
S:G$ax5051_readfifo$0$0({2}DF,SV:S),C,0,0
S:G$ax5051_writefifo$0$0({2}DF,SV:S),C,0,0
S:G$flash_unlock$0$0({2}DF,SV:S),C,0,0
S:G$flash_lock$0$0({2}DF,SV:S),C,0,0
S:G$flash_wait$0$0({2}DF,SC:S),C,0,0
S:G$flash_pageerase$0$0({2}DF,SC:S),C,0,0
S:G$flash_write$0$0({2}DF,SC:S),C,0,0
S:G$flash_read$0$0({2}DF,SI:U),C,0,0
S:G$flash_apply_calibration$0$0({2}DF,SC:U),C,0,0
S:G$wtimer0_setconfig$0$0({2}DF,SV:S),C,0,0
S:G$wtimer1_setconfig$0$0({2}DF,SV:S),C,0,0
S:G$wtimer_init$0$0({2}DF,SV:S),C,0,0
S:G$wtimer_init_deepsleep$0$0({2}DF,SV:S),C,0,0
S:G$wtimer_idle$0$0({2}DF,SC:U),C,0,0
S:G$wtimer_runcallbacks$0$0({2}DF,SC:U),C,0,0
S:G$wtimer0_curtime$0$0({2}DF,SL:U),C,0,0
S:G$wtimer1_curtime$0$0({2}DF,SL:U),C,0,0
S:G$wtimer0_addabsolute$0$0({2}DF,SV:S),C,0,0
S:G$wtimer1_addabsolute$0$0({2}DF,SV:S),C,0,0
S:G$wtimer0_addrelative$0$0({2}DF,SV:S),C,0,0
S:G$wtimer1_addrelative$0$0({2}DF,SV:S),C,0,0
S:G$wtimer_remove$0$0({2}DF,SC:U),C,0,0
S:G$wtimer0_remove$0$0({2}DF,SC:U),C,0,0
S:G$wtimer1_remove$0$0({2}DF,SC:U),C,0,0
S:G$wtimer_add_callback$0$0({2}DF,SV:S),C,0,0
S:G$wtimer_remove_callback$0$0({2}DF,SC:U),C,0,0
S:G$wtimer_cansleep$0$0({2}DF,SC:U),C,0,0
S:G$wtimer_irq$0$0({2}DF,SV:S),C,0,0
S:G$turn_off_xosc$0$0({2}DF,SV:S),C,0,0
S:G$turn_off_lpxosc$0$0({2}DF,SV:S),C,0,0
S:G$wtimer0_correctinterval$0$0({2}DF,SL:U),C,0,0
S:G$wtimer1_correctinterval$0$0({2}DF,SL:U),C,0,0
S:G$setup_xosc$0$0({2}DF,SV:S),C,0,0
S:G$setup_lpxosc$0$0({2}DF,SV:S),C,0,0
S:G$setup_osc_calibration$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_irq$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_poll$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_txbufptr$0$0({2}DF,DX,SC:U),C,0,0
S:G$lcd2_txfreelinear$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_txidle$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_txfree$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_txbuffersize$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_txpokecmd$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_txpoke$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_txpokehex$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_txadvance$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_init$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_portinit$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_wait_txdone$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_wait_txfree$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_tx$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_txcmdshort$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_txcmdlong$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_setpos$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_cleardisplay$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_clear$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_writestr$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_writenum16$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_writehex16$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_writenum32$0$0({2}DF,SC:U),C,0,0
S:G$lcd2_writehex32$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_irq$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_poll$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_txbufptr$0$0({2}DF,DX,SC:U),C,0,0
S:G$dbglink_txfreelinear$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_txidle$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_txfree$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0
S:G$dbglink_rxcountlinear$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_rxcount$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_txbuffersize$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_rxbuffersize$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_rxpeek$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_txpoke$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_txpokehex$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_rxadvance$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_txadvance$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_init$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_wait_txdone$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_wait_txfree$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_wait_rxcount$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_rx$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_tx$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_writestr$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_writenum16$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_writehex16$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_writenum32$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_writehex32$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_writehexu16$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_writehexu32$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_writeu16$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_writeu32$0$0({2}DF,SV:S),C,0,0
S:G$crc_ccitt_byte$0$0({2}DF,SI:U),C,0,0
S:G$crc_ccitt_msb_byte$0$0({2}DF,SI:U),C,0,0
S:G$crc_ccitt$0$0({2}DF,SI:U),C,0,0
S:G$crc_ccitt_msb$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16_byte$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16_msb_byte$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16_msb$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16dnp_byte$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16dnp_msb_byte$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16dnp$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc16dnp_msb$0$0({2}DF,SI:U),C,0,0
S:G$crc_crc32_byte$0$0({2}DF,SL:U),C,0,0
S:G$crc_crc32_msb_byte$0$0({2}DF,SL:U),C,0,0
S:G$crc_crc32$0$0({2}DF,SL:U),C,0,0
S:G$crc_crc32_msb$0$0({2}DF,SL:U),C,0,0
S:G$crc_crc8ccitt_byte$0$0({2}DF,SC:U),C,0,0
S:G$crc_crc8ccitt_msb_byte$0$0({2}DF,SC:U),C,0,0
S:G$crc_crc8ccitt$0$0({2}DF,SC:U),C,0,0
S:G$crc_crc8ccitt_msb$0$0({2}DF,SC:U),C,0,0
S:G$crc_crc8onewire_byte$0$0({2}DF,SC:U),C,0,0
S:G$crc_crc8onewire_msb_byte$0$0({2}DF,SC:U),C,0,0
S:G$crc_crc8onewire$0$0({2}DF,SC:U),C,0,0
S:G$crc_crc8onewire_msb$0$0({2}DF,SC:U),C,0,0
S:G$crc8_ccitt_byte$0$0({2}DF,SC:U),C,0,0
S:G$crc8_ccitt$0$0({2}DF,SC:U),C,0,0
S:G$crc8_onewire_byte$0$0({2}DF,SC:U),C,0,0
S:G$crc8_onewire$0$0({2}DF,SC:U),C,0,0
S:G$pn9_advance$0$0({2}DF,SI:U),C,0,0
S:G$pn9_advance_bit$0$0({2}DF,SI:U),C,0,0
S:G$pn9_advance_bits$0$0({2}DF,SI:U),C,0,0
S:G$pn9_advance_byte$0$0({2}DF,SI:U),C,0,0
S:G$pn9_buffer$0$0({2}DF,SI:U),C,0,0
S:G$pn15_advance$0$0({2}DF,SI:U),C,0,0
S:G$pn15_output$0$0({2}DF,SC:U),C,0,0
S:G$uart_timer0_baud$0$0({2}DF,SV:S),C,0,0
S:G$uart_timer1_baud$0$0({2}DF,SV:S),C,0,0
S:G$uart_timer2_baud$0$0({2}DF,SV:S),C,0,0
S:G$adc_measure_temperature$0$0({2}DF,SI:S),C,0,0
S:G$adc_calibrate_gain$0$0({2}DF,SV:S),C,0,0
S:G$adc_calibrate_temp$0$0({2}DF,SV:S),C,0,0
S:G$adc_calibrate$0$0({2}DF,SV:S),C,0,0
S:G$adc_uncalibrate$0$0({2}DF,SV:S),C,0,0
S:G$adc_singleended_offset_x01$0$0({2}DF,SI:U),C,0,0
S:G$adc_singleended_offset_x1$0$0({2}DF,SI:U),C,0,0
S:G$adc_singleended_offset_x10$0$0({2}DF,SI:U),C,0,0
S:G$bch3121_syndrome$0$0({2}DF,SI:U),C,0,0
S:G$bch3121_encode$0$0({2}DF,SL:U),C,0,0
S:G$bch3121_encode_parity$0$0({2}DF,SL:U),C,0,0
S:G$bch3121_decode$0$0({2}DF,SL:U),C,0,0
S:G$bch3121_decode_parity$0$0({2}DF,SL:U),C,0,0
S:G$uart0_irq$0$0({2}DF,SV:S),C,0,0
S:G$uart0_poll$0$0({2}DF,SC:U),C,0,0
S:G$uart0_txbufptr$0$0({2}DF,DX,SC:U),C,0,0
S:G$uart0_txfreelinear$0$0({2}DF,SC:U),C,0,0
S:G$uart0_txidle$0$0({2}DF,SC:U),C,0,0
S:G$uart0_txbusy$0$0({2}DF,SC:U),C,0,0
S:G$uart0_txfree$0$0({2}DF,SC:U),C,0,0
S:G$uart0_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0
S:G$uart0_rxcountlinear$0$0({2}DF,SC:U),C,0,0
S:G$uart0_rxcount$0$0({2}DF,SC:U),C,0,0
S:G$uart0_txbuffersize$0$0({2}DF,SC:U),C,0,0
S:G$uart0_rxbuffersize$0$0({2}DF,SC:U),C,0,0
S:G$uart0_rxpeek$0$0({2}DF,SC:U),C,0,0
S:G$uart0_txpoke$0$0({2}DF,SV:S),C,0,0
S:G$uart0_txpokehex$0$0({2}DF,SV:S),C,0,0
S:G$uart0_rxadvance$0$0({2}DF,SV:S),C,0,0
S:G$uart0_txadvance$0$0({2}DF,SV:S),C,0,0
S:G$uart0_init$0$0({2}DF,SV:S),C,0,0
S:G$uart0_stop$0$0({2}DF,SV:S),C,0,0
S:G$uart0_wait_txdone$0$0({2}DF,SV:S),C,0,0
S:G$uart0_wait_txfree$0$0({2}DF,SV:S),C,0,0
S:G$uart0_wait_rxcount$0$0({2}DF,SV:S),C,0,0
S:G$uart0_rx$0$0({2}DF,SC:U),C,0,0
S:G$uart0_tx$0$0({2}DF,SV:S),C,0,0
S:G$uart0_writestr$0$0({2}DF,SV:S),C,0,0
S:G$uart0_writenum16$0$0({2}DF,SC:U),C,0,0
S:G$uart0_writehex16$0$0({2}DF,SC:U),C,0,0
S:G$uart0_writenum32$0$0({2}DF,SC:U),C,0,0
S:G$uart0_writehex32$0$0({2}DF,SC:U),C,0,0
S:G$uart0_writehexu16$0$0({2}DF,SV:S),C,0,0
S:G$uart0_writehexu32$0$0({2}DF,SV:S),C,0,0
S:G$uart0_writeu16$0$0({2}DF,SV:S),C,0,0
S:G$uart0_writeu32$0$0({2}DF,SV:S),C,0,0
S:G$uart1_irq$0$0({2}DF,SV:S),C,0,0
S:G$uart1_poll$0$0({2}DF,SC:U),C,0,0
S:G$uart1_txbufptr$0$0({2}DF,DX,SC:U),C,0,0
S:G$uart1_txfreelinear$0$0({2}DF,SC:U),C,0,0
S:G$uart1_txidle$0$0({2}DF,SC:U),C,0,0
S:G$uart1_txbusy$0$0({2}DF,SC:U),C,0,0
S:G$uart1_txfree$0$0({2}DF,SC:U),C,0,0
S:G$uart1_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0
S:G$uart1_rxcountlinear$0$0({2}DF,SC:U),C,0,0
S:G$uart1_rxcount$0$0({2}DF,SC:U),C,0,0
S:G$uart1_txbuffersize$0$0({2}DF,SC:U),C,0,0
S:G$uart1_rxbuffersize$0$0({2}DF,SC:U),C,0,0
S:G$uart1_rxpeek$0$0({2}DF,SC:U),C,0,0
S:G$uart1_txpoke$0$0({2}DF,SV:S),C,0,0
S:G$uart1_txpokehex$0$0({2}DF,SV:S),C,0,0
S:G$uart1_rxadvance$0$0({2}DF,SV:S),C,0,0
S:G$uart1_txadvance$0$0({2}DF,SV:S),C,0,0
S:G$uart1_init$0$0({2}DF,SV:S),C,0,0
S:G$uart1_stop$0$0({2}DF,SV:S),C,0,0
S:G$uart1_wait_txdone$0$0({2}DF,SV:S),C,0,0
S:G$uart1_wait_txfree$0$0({2}DF,SV:S),C,0,0
S:G$uart1_wait_rxcount$0$0({2}DF,SV:S),C,0,0
S:G$uart1_rx$0$0({2}DF,SC:U),C,0,0
S:G$uart1_tx$0$0({2}DF,SV:S),C,0,0
S:G$uart1_writestr$0$0({2}DF,SV:S),C,0,0
S:G$uart1_writenum16$0$0({2}DF,SC:U),C,0,0
S:G$uart1_writehex16$0$0({2}DF,SC:U),C,0,0
S:G$uart1_writenum32$0$0({2}DF,SC:U),C,0,0
S:G$uart1_writehex32$0$0({2}DF,SC:U),C,0,0
S:G$uart1_writehexu16$0$0({2}DF,SV:S),C,0,0
S:G$uart1_writehexu32$0$0({2}DF,SV:S),C,0,0
S:G$uart1_writeu16$0$0({2}DF,SV:S),C,0,0
S:G$uart1_writeu32$0$0({2}DF,SV:S),C,0,0
S:G$com0_inituart0$0$0({2}DF,SV:S),C,0,0
S:G$com0_portinit$0$0({2}DF,SV:S),C,0,0
S:G$com0_init$0$0({2}DF,SV:S),C,0,0
S:G$com0_setpos$0$0({2}DF,SV:S),C,0,0
S:G$com0_writestr$0$0({2}DF,SV:S),C,0,0
S:G$com0_tx$0$0({2}DF,SV:S),C,0,0
S:G$com0_clear$0$0({2}DF,SV:S),C,0,0
S:G$memcpy$0$0({2}DF,DG,SV:S),C,0,0
S:G$memmove$0$0({2}DF,DG,SV:S),C,0,0
S:G$strcpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcat$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncat$0$0({2}DF,DG,SC:U),C,0,0
S:G$memcmp$0$0({2}DF,SI:S),C,0,0
S:G$strcmp$0$0({2}DF,SI:S),C,0,0
S:G$strncmp$0$0({2}DF,SI:S),C,0,0
S:G$strxfrm$0$0({2}DF,SI:U),C,0,0
S:G$memchr$0$0({2}DF,DG,SV:S),C,0,0
S:G$strchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcspn$0$0({2}DF,SI:U),C,0,0
S:G$strpbrk$0$0({2}DF,DG,SC:U),C,0,0
S:G$strrchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strspn$0$0({2}DF,SI:U),C,0,0
S:G$strstr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strtok$0$0({2}DF,DG,SC:U),C,0,0
S:G$memset$0$0({2}DF,DG,SV:S),C,0,0
S:G$strlen$0$0({2}DF,SI:U),C,0,0
S:G$display_received_packet$0$0({2}DF,SC:U),C,0,0
S:G$dbglink_received_packet$0$0({2}DF,SV:S),C,0,0
S:G$delay_ms$0$0({2}DF,SV:S),C,0,0
S:G$lcd2_display_radio_error$0$0({2}DF,SV:S),C,0,0
S:G$com0_display_radio_error$0$0({2}DF,SV:S),C,0,0
S:G$dbglink_display_radio_error$0$0({2}DF,SV:S),C,0,0
S:Fmain$pwrmgmt_irq$0$0({2}DF,SV:S),C,0,0
S:Fmain$transmit_packet$0$0({2}DF,SV:S),C,0,0
S:Fmain$display_transmit_packet$0$0({2}DF,SV:S),C,0,0
S:Fmain$wakeup_callback$0$0({2}DF,SV:S),C,0,0
S:G$_sdcc_external_startup$0$0({2}DF,SC:U),C,0,0
S:G$main$0$0({2}DF,SI:S),C,0,0
S:G$axradio_framing_maclen$0$0({1}SC:U),D,0,0
S:G$axradio_framing_addrlen$0$0({1}SC:U),D,0,0
S:G$remoteaddr$0$0({5}STaxradio_address:S),D,0,0
S:G$localaddr$0$0({10}STaxradio_address_mask:S),D,0,0
S:G$demo_packet$0$0({6}DA6d,SC:U),D,0,0
S:G$framing_insert_counter$0$0({1}SC:U),D,0,0
S:G$framing_counter_pos$0$0({1}SC:U),D,0,0
S:G$lpxosc_settlingtime$0$0({2}SI:U),D,0,0
S:G$crc_ccitt_table$0$0({512}DA256d,SI:U),D,0,0
S:G$crc_ccitt_msbtable$0$0({512}DA256d,SI:U),D,0,0
S:G$crc_crc16_table$0$0({512}DA256d,SI:U),D,0,0
S:G$crc_crc16_msbtable$0$0({512}DA256d,SI:U),D,0,0
S:G$crc_crc16dnp_table$0$0({512}DA256d,SI:U),D,0,0
S:G$crc_crc16dnp_msbtable$0$0({512}DA256d,SI:U),D,0,0
S:G$crc_crc32_table$0$0({1024}DA256d,SL:U),D,0,0
S:G$crc_crc32_msbtable$0$0({1024}DA256d,SL:U),D,0,0
S:G$crc_crc8ccitt_table$0$0({256}DA256d,SC:U),D,0,0
S:G$crc_crc8ccitt_msbtable$0$0({256}DA256d,SC:U),D,0,0
S:G$crc_crc8onewire_table$0$0({256}DA256d,SC:U),D,0,0
S:G$crc_crc8onewire_msbtable$0$0({256}DA256d,SC:U),D,0,0
S:G$pn9_table$0$0({512}DA512d,SC:U),D,0,0
S:G$pn15_adv_table$0$0({512}DA256d,SI:U),D,0,0
S:G$pn15_out_table$0$0({256}DA256d,SC:U),D,0,0
S:G$bch3121_syndrometable$0$0({2048}DA1024d,SI:U),D,0,0
S:Fmain$__str_0$0$0({7}DA7d,SC:S),D,0,0
S:Fmain$__str_1$0$0({5}DA5d,SC:S),D,0,0
S:Fmain$__str_2$0$0({7}DA7d,SC:S),D,0,0
S:Fmain$__str_3$0$0({7}DA7d,SC:S),D,0,0
|
alire-project/GNAT-FSF-builds | Ada | 174 | adb | with Lib_Pack;
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
begin
Put_Line ("=== Main start ===");
Lib_Pack.Test;
Put_Line ("=== Main end ===");
end Main;
|
annexi-strayline/ASAP-HEX | Ada | 4,406 | ads | ------------------------------------------------------------------------------
-- --
-- Generic HEX String Handling Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2018-2019, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai, Ensi Martini, Aninda Poddar, Noshen Atashe --
-- (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. --
-- --
------------------------------------------------------------------------------
-- Standard, verified package to represent an 20-bit modular value
with Hex.Modular_Codec;
package Hex.Unsigned_20
with SPARK_Mode => On
is
pragma Assertion_Policy (Pre => Check,
Post => Ignore,
Assert => Ignore);
type Unsigned_20 is mod 2**20;
package Codec is new Hex.Modular_Codec
(Modular_Value => Unsigned_20,
Bit_Width => 20);
Maximum_Length: Positive renames Codec.Max_Nibbles;
function Decode (Input: String) return Unsigned_20
renames Codec.Decode;
procedure Decode (Input : in String;
Value : out Unsigned_20)
renames Codec.Decode;
function Encode (Value: Unsigned_20; Use_Case: Set_Case := Lower_Case)
return String
renames Codec.Encode;
procedure Encode (Value : in Unsigned_20;
Buffer : out String;
Use_Case: in Set_Case := Lower_Case)
renames Codec.Encode;
end Hex.Unsigned_20;
|
reznikmm/matreshka | Ada | 3,930 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016, 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 WebAPI.DOM.Event_Targets;
package WebAPI.XHR.Event_Targets is
pragma Preelaborate;
type Event_Target is limited interface
and WebAPI.DOM.Event_Targets.Event_Target;
-- The following are the event handlers (and their corresponding event
-- handler event types) that must be supported on objects implementing
-- an interface that inherits from XMLHttpRequestEventTarget as attributes:
--
-- * "loadstart"
-- * "progress"
-- * "abort"
-- * "error"
-- * "load"
-- * "timeout"
-- * "loadend"
end WebAPI.XHR.Event_Targets;
|
reznikmm/template | Ada | 214 | ads | -- SPDX-FileCopyrightText: 2021 Max Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package Template is
pragma Pure;
end Template; |
charlie5/cBound | Ada | 1,540 | 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_is_list_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
ret_val : aliased xcb.xcb_glx_bool32_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_is_list_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_is_list_reply_t.Item,
Element_Array => xcb.xcb_glx_is_list_reply_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_is_list_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_is_list_reply_t.Pointer,
Element_Array => xcb.xcb_glx_is_list_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_is_list_reply_t;
|
stcarrez/ada-asf | Ada | 3,564 | ads | -----------------------------------------------------------------------
-- asf-beans-injections -- Injection of parameters, headers, cookies in beans
-- Copyright (C) 2015 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.Strings;
with ASF.Requests;
package ASF.Beans.Injections is
type Inject_Type;
-- The injection handler is a procedure that extracts the information from a request
-- object and injects the value in the Ada bean instance.
type Injection_Handler is not null access
procedure (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Define and control the injection of a value in some Ada bean.
type Inject_Type is record
-- The handler that retrieves the value from the request object and injects it in the bean.
Handler : Injection_Handler;
-- The bean property name in the Ada bean.
Name : Util.Strings.Name_Access;
-- The HTTP header name, the query parameter name or the cookie name to inject.
Param : Util.Strings.Name_Access;
-- The path component to inject.
Pos : Natural := 0;
end record;
type Inject_Array_Type is array (Positive) of Inject_Type;
-- Inject the request header whose name is defined by Descriptor.Param.
procedure Header (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject the request query string parameter whose name is defined by Descriptor.Param.
procedure Query_Param (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject the request cookie whose name is defined by Descriptor.Param.
procedure Cookie (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject the request URI path component whose position is defined by Descriptor.Pos.
procedure Path_Param (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject into the Ada bean a set of information extracted from the request object.
-- The value is obtained from a request header, a cookie, a query string parameter or
-- from a URI path component. The value is injected by using the bean operation
-- <tt>Set_Value</tt>.
procedure Inject (Into : in out Util.Beans.Basic.Bean'Class;
List : in Inject_Array_Type;
Request : in ASF.Requests.Request'Class);
end ASF.Beans.Injections;
|
anshumang/cp-snucl | Ada | 189 | adb | -- RUN: %llvmgcc -S %s
procedure VCE_LV is
type P is access String ;
type T is new P (5 .. 7);
subtype U is String (5 .. 7);
X : T := new U'(others => 'A');
begin
null;
end;
|
reznikmm/matreshka | Ada | 4,591 | 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.Rotation_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Rotation_Attribute_Node is
begin
return Self : Draw_Rotation_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_Rotation_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Rotation_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Rotation_Attribute,
Draw_Rotation_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Rotation_Attributes;
|
stcarrez/ada-keystore | Ada | 20,533 | adb | -----------------------------------------------------------------------
-- keystore-passwords-gpg -- Password protected by GPG
-- Copyright (C) 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 Ada.Unchecked_Deallocation;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with GNAT.Regpat;
with Util.Streams;
with Util.Log.Loggers;
with Util.Encoders;
with Util.Processes;
with Util.Streams.Texts;
with Keystore.Random;
-- === GPG Header data ===
--
-- The GPG encrypted data contains the following information:
-- ```
-- +------------------+-----
-- | TAG | 4b
-- +------------------+-----
-- | Lock Key | 32b
-- | Lock IV | 16b
-- | Wallet Key | 32b
-- | Wallet IV | 16b
-- | Wallet Sign | 32b
-- +------------------+-----
-- ```
package body Keystore.Passwords.GPG is
use Ada.Streams;
use Ada.Strings.Unbounded;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Passwords.GPG");
function Get_Le_Long (Data : in Ada.Streams.Stream_Element_Array)
return Interfaces.Unsigned_32;
function Get_Unsigned_32 (Data : in Stream_Element_Array) return Interfaces.Unsigned_32;
procedure Put_Unsigned_32 (Data : out Stream_Element_Array;
Value : in Interfaces.Unsigned_32);
-- Headers of GPG packet.
GPG_OLD_TAG_1 : constant Ada.Streams.Stream_Element := 16#85#;
GPG_TAG_2 : constant Ada.Streams.Stream_Element := 16#84#;
GPG_NEW_VERSION : constant Ada.Streams.Stream_Element := 16#03#;
function Get_Unsigned_32 (Data : in Stream_Element_Array) return Interfaces.Unsigned_32 is
use Interfaces;
begin
return Shift_Left (Unsigned_32 (Data (Data'First)), 24) or
Shift_Left (Unsigned_32 (Data (Data'First + 1)), 16) or
Shift_Left (Unsigned_32 (Data (Data'First + 2)), 8) or
Unsigned_32 (Data (Data'First + 3));
end Get_Unsigned_32;
procedure Put_Unsigned_32 (Data : out Stream_Element_Array;
Value : in Interfaces.Unsigned_32) is
use Interfaces;
begin
Data (Data'First) := Stream_Element (Shift_Right (Value, 24));
Data (Data'First + 1) := Stream_Element (Shift_Right (Value, 16) and 16#0ff#);
Data (Data'First + 2) := Stream_Element (Shift_Right (Value, 8) and 16#0ff#);
Data (Data'First + 3) := Stream_Element (Value and 16#0ff#);
end Put_Unsigned_32;
function Get_Le_Long (Data : in Ada.Streams.Stream_Element_Array)
return Interfaces.Unsigned_32 is
use Interfaces;
begin
return Shift_Left (Unsigned_32 (Data (Data'First)), 24) or
Shift_Left (Unsigned_32 (Data (Data'First + 1)), 16) or
Shift_Left (Unsigned_32 (Data (Data'First + 2)), 8) or
Unsigned_32 (Data (Data'First + 3));
end Get_Le_Long;
-- ------------------------------
-- Extract the Key ID from the data content when it is encrypted by GPG2.
-- ------------------------------
function Extract_Key_Id (Data : in Ada.Streams.Stream_Element_Array) return String is
L1 : Interfaces.Unsigned_32;
L2 : Interfaces.Unsigned_32;
Encode : constant Util.Encoders.Encoder := Util.Encoders.Create ("hex");
begin
if Data'Length < 16 then
return "";
end if;
-- Look for: 84 5e 03 <key-id>
if Data (Data'First + 4) = GPG_TAG_2 then
if Data (Data'First + 6) /= GPG_NEW_VERSION then
return "";
end if;
L1 := Get_Le_Long (Data (Data'First + 4 + 3 .. Data'Last));
L2 := Get_Le_Long (Data (Data'First + 8 + 3 .. Data'Last));
return Encode.Encode_Unsigned_32 (L1) & Encode.Encode_Unsigned_32 (L2);
end if;
-- Look for: 85 01 0C 03 <key-id>
if Data (Data'First + 4) /= GPG_OLD_TAG_1 then
return "";
end if;
if Data (Data'First + 7) /= GPG_NEW_VERSION then
return "";
end if;
if Data (Data'First + 5) > 4 then
return "";
end if;
L1 := Get_Le_Long (Data (Data'First + 4 + 4 .. Data'Last));
L2 := Get_Le_Long (Data (Data'First + 8 + 4 .. Data'Last));
return Encode.Encode_Unsigned_32 (L1) & Encode.Encode_Unsigned_32 (L2);
end Extract_Key_Id;
-- ------------------------------
-- Get the list of GPG secret keys that could be capable for decrypting a content for us.
-- ------------------------------
procedure List_GPG_Secret_Keys (Context : in out Context_Type;
List : in out Util.Strings.Sets.Set) is
procedure Parse (Line : in String);
-- GPG1 command output:
-- ssb::<key-size>:<key-algo>:<key-id>:<create-date>:<expire-date>:::::<e>:
REGEX1 : constant String
:= "^(ssb|sec):u?:[1-9][0-9][0-9][0-9]:[0-9]:([0-9a-fA-F]+):[0-9-]+:[0-9-]*:::::.*";
-- GPG2 command output:
-- ssb:u:<key-size>:<key-algo>:<key-id>:<create-date>:<expire-date>:::::<e>:
REGEX2 : constant String
:= "^(ssb|sec):u?:[1-9][0-9]+:[0-9]+:([0-9a-fA-F]+):[0-9]+:[0-9]*:::::[esa]+::.*";
Pattern1 : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile (REGEX1);
Pattern2 : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile (REGEX2);
procedure Parse (Line : in String) is
Matches : GNAT.Regpat.Match_Array (0 .. 2);
begin
Log.Debug ("Check {0}", Line);
if GNAT.Regpat.Match (Pattern2, Line) then
GNAT.Regpat.Match (Pattern2, Line, Matches);
List.Include (Line (Matches (2).First .. Matches (2).Last));
Log.Debug ("Found key '{0}'", Line (Matches (2).First .. Matches (2).Last));
elsif GNAT.Regpat.Match (Pattern1, Line) then
GNAT.Regpat.Match (Pattern1, Line, Matches);
List.Include (Line (Matches (2).First .. Matches (2).Last));
end if;
end Parse;
Command : constant String := To_String (Context.List_Key_Command);
Proc : Util.Processes.Process;
Output : Util.Streams.Input_Stream_Access;
Input : Util.Streams.Output_Stream_Access;
Reader : Util.Streams.Texts.Reader_Stream;
begin
Log.Info ("Looking for GPG secrets using {0}", Command);
Util.Processes.Spawn (Proc => Proc,
Command => Command,
Mode => Util.Processes.READ_WRITE_ALL);
Input := Util.Processes.Get_Input_Stream (Proc);
Output := Util.Processes.Get_Output_Stream (Proc);
Reader.Initialize (Output, 4096);
Input.Close;
while not Reader.Is_Eof loop
declare
Line : Ada.Strings.Unbounded.Unbounded_String;
begin
Reader.Read_Line (Line, True);
Parse (To_String (Line));
end;
end loop;
Util.Processes.Wait (Proc);
if Util.Processes.Get_Exit_Status (Proc) /= 0 then
Log.Warn ("GPG list command '{0}' terminated with exit code{1}", Command,
Natural'Image (Util.Processes.Get_Exit_Status (Proc)));
end if;
exception
when E : Util.Processes.Process_Error =>
Log.Warn ("Cannot execute GPG command '{0}': {1}",
Command, Ada.Exceptions.Exception_Message (E));
end List_GPG_Secret_Keys;
-- ------------------------------
-- Create a secret to protect the keystore.
-- ------------------------------
procedure Create_Secret (Context : in out Context_Type;
Data : in Ada.Streams.Stream_Element_Array) is
P : Secret_Provider_Access;
Tag : constant Tag_Type := Get_Unsigned_32 (Data);
begin
P := new Secret_Provider '(Tag => Tag,
Next => Context.First,
others => <>);
Context.First := P;
Util.Encoders.Create (Data (POS_LOCK_KEY .. POS_LOCK_KEY_LAST), P.Key);
Util.Encoders.Create (Data (POS_LOCK_IV .. POS_LOCK_IV_LAST), P.IV);
Context.Current := P;
end Create_Secret;
-- ------------------------------
-- Create a secret to protect the keystore.
-- ------------------------------
procedure Create_Secret (Context : in out Context_Type) is
Rand : Keystore.Random.Generator;
begin
Rand.Generate (Context.Data);
Context.Create_Secret (Context.Data);
end Create_Secret;
procedure Create_Secret (Context : in out Context_Type;
Image : in Context_Type'Class) is
begin
Context.Encrypt_Command := Image.Encrypt_Command;
Context.Decrypt_Command := Image.Decrypt_Command;
Context.List_Key_Command := Image.List_Key_Command;
Context.Create_Secret;
Context.Data (POS_WALLET_KEY .. POS_WALLET_SIGN_LAST)
:= Image.Data (POS_WALLET_KEY .. POS_WALLET_SIGN_LAST);
end Create_Secret;
procedure Create_Secret (Context : in out Context_Type;
Key_Provider : in Keys.Key_Provider'Class) is
begin
Context.Create_Secret;
if Key_Provider in Keystore.Passwords.Internal_Key_Provider'Class then
Keystore.Passwords.Internal_Key_Provider'Class (Key_Provider).Save_Key
(Context.Data (POS_WALLET_KEY .. POS_WALLET_SIGN_LAST));
end if;
end Create_Secret;
-- ------------------------------
-- Save the GPG secret by encrypting it using the user's GPG key and storing
-- the encrypted data in the keystore data header.
-- ------------------------------
procedure Save_Secret (Context : in out Context_Type;
User : in String;
Index : in Keystore.Header_Slot_Index_Type;
Wallet : in out Keystore.Files.Wallet_File) is
Cmd : constant String := Context.Get_Encrypt_Command (User);
Proc : Util.Processes.Process;
Result : Ada.Streams.Stream_Element_Array (1 .. MAX_ENCRYPT_SIZE);
Last : Ada.Streams.Stream_Element_Offset := 0;
Last2 : Ada.Streams.Stream_Element_Offset;
Input : Util.Streams.Output_Stream_Access;
Output : Util.Streams.Input_Stream_Access;
begin
Log.Info ("Encrypt GPG secret using {0}", Cmd);
Put_Unsigned_32 (Result, Context.Current.Tag);
Last := 4;
Util.Processes.Spawn (Proc => Proc,
Command => Cmd,
Mode => Util.Processes.READ_WRITE);
Input := Util.Processes.Get_Input_Stream (Proc);
Input.Write (Context.Data (POS_LOCK_KEY .. Context.Data'Last));
Input.Close;
Output := Util.Processes.Get_Output_Stream (Proc);
while Last < Result'Last loop
Output.Read (Result (Last + 1 .. Result'Last), Last2);
exit when Last2 = Last;
Last := Last2;
end loop;
Util.Processes.Wait (Proc);
if Util.Processes.Get_Exit_Status (Proc) /= 0 or else Last <= 4 then
Log.Warn ("GPG encrypt command '{0}' terminated with exit code{1}", Cmd,
Natural'Image (Util.Processes.Get_Exit_Status (Proc)));
raise Keystore.Bad_Password;
end if;
Keystore.Files.Set_Header_Data (Wallet, Index,
Keystore.SLOT_KEY_GPG2, Result (1 .. Last));
Context.Index := Context.Index + 1;
exception
when E : Util.Processes.Process_Error =>
Log.Warn ("Cannot execute GPG encrypt command '{0}': {1}",
Cmd, Ada.Exceptions.Exception_Message (E));
raise Keystore.Bad_Password;
end Save_Secret;
-- ------------------------------
-- Load the GPG secrets stored in the keystore header.
-- ------------------------------
procedure Load_Secrets (Context : in out Context_Type;
Wallet : in out Keystore.Files.Wallet_File) is
Data : Ada.Streams.Stream_Element_Array (1 .. MAX_ENCRYPT_SIZE);
Last : Ada.Streams.Stream_Element_Offset;
Kind : Keystore.Header_Slot_Type;
List : Util.Strings.Sets.Set;
begin
-- Get the list of known secret keys.
Context.List_GPG_Secret_Keys (List);
for Index in Header_Slot_Index_Type'Range loop
Wallet.Get_Header_Data (Index, Kind, Data, Last);
exit when Last < Data'First;
if Kind = Keystore.SLOT_KEY_GPG2 then
declare
Key_Id : constant String := Extract_Key_Id (Data (Data'First .. Last));
begin
Log.Info ("Extracted key {0}", Key_Id);
if List.Contains (Key_Id) then
Context.Decrypt_GPG_Secret (Data (Data'First .. Last));
exit when Context.Valid_Key;
end if;
end;
end if;
end loop;
Context.Current := Context.First;
end Load_Secrets;
-- ------------------------------
-- Get the password through the Getter operation.
-- ------------------------------
overriding
procedure Get_Password (From : in Context_Type;
Getter : not null
access procedure (Password : in Secret_Key)) is
begin
Getter (From.Current.Key);
end Get_Password;
-- ------------------------------
-- Get the key and IV through the Getter operation.
-- ------------------------------
overriding
procedure Get_Key (From : in Context_Type;
Getter : not null
access procedure (Key : in Secret_Key;
IV : in Secret_Key)) is
begin
Getter (From.Current.Key, From.Current.IV);
end Get_Key;
-- ------------------------------
-- Get the Key, IV and signature.
-- ------------------------------
overriding
procedure Get_Keys (From : in Context_Type;
Key : out Secret_Key;
IV : out Secret_Key;
Sign : out Secret_Key) is
begin
Util.Encoders.Create (From.Data (POS_WALLET_KEY .. POS_WALLET_KEY_LAST), Key);
Util.Encoders.Create (From.Data (POS_WALLET_IV .. POS_WALLET_IV_LAST), IV);
Util.Encoders.Create (From.Data (POS_WALLET_SIGN .. POS_WALLET_SIGN_LAST), Sign);
end Get_Keys;
-- ------------------------------
-- Get the key slot number associated with the GPG password.
-- ------------------------------
overriding
function Get_Tag (From : in Context_Type) return Tag_Type is
begin
return From.Current.Tag;
end Get_Tag;
-- ------------------------------
-- Returns true if the provider has a GPG password.
-- ------------------------------
overriding
function Has_Password (From : in Context_Type) return Boolean is
begin
return From.Current /= null;
end Has_Password;
-- ------------------------------
-- Move to the next GPG password.
-- ------------------------------
overriding
procedure Next (From : in out Context_Type) is
begin
From.Current := From.Current.Next;
end Next;
-- ------------------------------
-- Get the command to encrypt the secret for the given GPG user/keyid.
-- ------------------------------
function Get_Encrypt_Command (Context : in Context_Type;
User : in String) return String is
use Ada.Strings.Fixed;
USER_LABEL : constant String := "$USER";
Cmd : constant String := To_String (Context.Encrypt_Command);
Result : Unbounded_String;
First : Positive := Cmd'First;
Pos : Natural;
begin
loop
Pos := Index (Cmd, USER_LABEL, First);
if Pos = 0 then
Append (Result, Cmd (First .. Cmd'Last));
return To_String (Result);
end if;
Append (Result, Cmd (First .. Pos - 1));
Append (Result, User);
First := Pos + USER_LABEL'Length;
end loop;
end Get_Encrypt_Command;
-- ------------------------------
-- Decrypt the data array that was encrypted using GPG2.
-- ------------------------------
procedure Decrypt_GPG_Secret (Context : in out Context_Type;
Data : in Ada.Streams.Stream_Element_Array) is
Proc : Util.Processes.Process;
Last : Ada.Streams.Stream_Element_Offset := 0;
Last2 : Ada.Streams.Stream_Element_Offset;
Cmd : constant String := To_String (Context.Decrypt_Command);
Status : Natural;
begin
Log.Info ("Decrypt GPG secret using {0}", Cmd);
Context.Data (POS_TAG .. POS_TAG_LAST) := Data (Data'First .. Data'First + 3);
Last := POS_TAG_LAST;
Util.Processes.Spawn (Proc => Proc,
Command => Cmd,
Mode => Util.Processes.READ_WRITE);
Util.Processes.Get_Input_Stream (Proc).Write (Data (POS_LOCK_KEY .. Data'Last));
Util.Processes.Get_Input_Stream (Proc).Close;
while Last < Context.Data'Last loop
Util.Processes.Get_Output_Stream (Proc).Read
(Context.Data (Last + 1 .. Context.Data'Last), Last2);
exit when Last2 = Last;
Last := Last2;
end loop;
Util.Processes.Wait (Proc);
Status := Util.Processes.Get_Exit_Status (Proc);
Context.Valid_Key := Status = 0 and then Last > 4;
if Context.Valid_Key then
Context.Create_Secret (Context.Data);
elsif Status /= 0 then
Log.Warn ("GPG decrypt command '{0}' terminated with exit code{1}", Cmd,
Natural'Image (Status));
end if;
Context.Data (POS_TAG .. POS_LOCK_IV_LAST) := (others => 0);
exception
when E : Util.Processes.Process_Error =>
Log.Warn ("Cannot execute GPG decrypt command '{0}': {1}",
Cmd, Ada.Exceptions.Exception_Message (E));
Context.Valid_Key := False;
end Decrypt_GPG_Secret;
-- ------------------------------
-- Setup the command to be executed to encrypt the secret with GPG2.
-- ------------------------------
procedure Set_Encrypt_Command (Into : in out Context_Type;
Command : in String) is
begin
Into.Encrypt_Command := To_Unbounded_String (Command);
end Set_Encrypt_Command;
-- ------------------------------
-- Setup the command to be executed to decrypt the secret with GPG2.
-- ------------------------------
procedure Set_Decrypt_Command (Into : in out Context_Type;
Command : in String) is
begin
Into.Decrypt_Command := To_Unbounded_String (Command);
end Set_Decrypt_Command;
-- ------------------------------
-- Setup the command to be executed to get the list of available GPG secret keys.
-- ------------------------------
procedure Set_List_Key_Command (Into : in out Context_Type;
Command : in String) is
begin
Into.List_Key_Command := To_Unbounded_String (Command);
end Set_List_Key_Command;
overriding
procedure Initialize (Context : in out Context_Type) is
begin
Context.Encrypt_Command := To_Unbounded_String (ENCRYPT_COMMAND);
Context.Decrypt_Command := To_Unbounded_String (DECRYPT_COMMAND);
Context.List_Key_Command := To_Unbounded_String (LIST_COMMAND);
end Initialize;
overriding
procedure Finalize (Context : in out Context_Type) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Secret_Provider,
Name => Secret_Provider_Access);
begin
Context.Data := (others => 0);
while Context.First /= null loop
Context.Current := Context.First.Next;
Free (Context.First);
Context.First := Context.Current;
end loop;
end Finalize;
end Keystore.Passwords.GPG;
|
AaronC98/PlaneSystem | Ada | 9,618 | adb | ------------------------------------------------------------------------------
-- Templates Parser --
-- --
-- Copyright (C) 2010-2019, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
separate (Templates_Parser)
package body Simplifier is
procedure Run (T : in out Tree) is
procedure Rewrite (T : in out Data.Tree);
-- Optimize data tree T
procedure Link_End (T, To : Tree; Link : out Tree);
-- Link To at end of tree T, Link is the pointer to the last node
--------------
-- Link_End --
--------------
procedure Link_End (T, To : Tree; Link : out Tree) is
N : Tree := T;
begin
while N.Next /= null loop
N := N.Next;
end loop;
N.Next := To;
Link := N;
end Link_End;
-------------
-- Rewrite --
-------------
procedure Rewrite (T : in out Data.Tree) is
use type Data.NKind;
use type Data.Tree;
D, Prev : Data.Tree;
Moved : Boolean := False;
Old : Data.Tree;
begin
D := T;
while D /= null loop
case D.Kind is
when Data.Text =>
if Prev = null
and then T.Kind = Data.Text
and then D /= T
then
Append (T.Value, D.Value);
Old := T.Next;
T.Next := D.Next;
D := D.Next;
Moved := True;
Data.Release (Old, Single => True);
elsif Prev /= null and then Prev.Kind = Data.Text then
Append (Prev.Value, D.Value);
Old := Prev.Next;
Prev.Next := D.Next;
D := D.Next;
Moved := True;
Data.Release (Old, Single => True);
end if;
when Data.Var =>
-- Rewrite also the macro if any
if D.Var.Is_Macro then
Run (D.Var.Def);
-- Check if we have a single resulting TEXT node
if D.Var.Def /= null
and then D.Var.Def.Kind = Text
and then D.Var.Def.Text.Kind = Data.Text
and then D.Var.Def.Text.Next = null
and then D.Var.Def.Next = null
then
declare
C : aliased Filter.Filter_Context (P_Size => 0);
begin
if Prev = null then
-- First node is a variable (line starting with
-- a tag variable), replace it by the
-- corresponding text node.
Old := T;
T := new Data.Node'
(Kind => Data.Text,
Col => D.Var.Def.Text.Col,
Next => D.Var.Def.Text.Next,
Value => To_Unbounded_String
(Data.Translate
(D.Var,
To_String (D.Var.Def.Text.Value),
C'Access)));
D := D.Next;
Moved := True;
Data.Release (Old, Single => True);
elsif Prev.Kind = Data.Text then
-- First node was a text, merge the values
Append (Prev.Value, D.Var.Def.Text.Value);
Old := Prev.Next;
Prev.Next := D.Next;
D := D.Next;
Moved := True;
Data.Release (Old, Single => True);
end if;
end;
end if;
end if;
end case;
if not Moved then
Prev := D;
D := D.Next;
else
Moved := False;
end if;
end loop;
end Rewrite;
N : Tree := T;
Prev, P : Tree;
Moved : Boolean := False;
begin
T := N;
while N /= null loop
case N.Kind is
when Text =>
Rewrite (N.Text);
when Table_Stmt =>
Run (N.Blocks);
when Section_Block =>
Run (N.Common);
Run (N.Sections);
when Section_Stmt =>
Run (N.N_Section);
when If_Stmt =>
declare
V : constant String := Expr.Analyze (N.Cond);
begin
if V = Expr.Unknown then
Run (N.N_True);
Run (N.N_False);
elsif (Expr.Is_True (V) and then N.N_True = null)
or else (not Expr.Is_True (V) and then N.N_False = null)
then
-- The corresponding branch does not exist, skip IF
Expr.Release (N.Cond);
Release (N.N_True);
Release (N.N_False);
declare
Old : Tree;
begin
if Prev = null then
Old := T;
T := T.Next;
else
Old := Prev.Next;
Prev.Next := N.Next;
end if;
N := N.Next;
Unchecked_Free (Old);
end;
Moved := True;
elsif Expr.Is_True (V) then
Expr.Release (N.Cond);
Release (N.N_False);
Run (N.N_True);
if Prev = null then
Link_End (N.N_True, T.Next, Link => P);
Unchecked_Free (T);
T := N.N_True;
else
Link_End (N.N_True, N.Next, Link => P);
Unchecked_Free (Prev.Next);
Prev.Next := N.N_True;
end if;
Prev := P;
N := N.Next;
Moved := True;
else
Expr.Release (N.Cond);
Release (N.N_True);
Run (N.N_False);
if Prev = null then
Link_End (N.N_False, T.Next, Link => P);
Unchecked_Free (T);
T := N.N_False;
else
Link_End (N.N_False, N.Next, Link => P);
Unchecked_Free (Prev.Next);
Prev.Next := N.N_False;
end if;
Prev := P;
N := N.Next;
Moved := True;
end if;
end;
when others =>
null;
end case;
if Moved then
Moved := False;
else
Prev := N;
N := N.Next;
end if;
end loop;
end Run;
end Simplifier;
|
optikos/oasis | Ada | 4,068 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Record_Component_Associations;
with Program.Elements.Record_Aggregates;
with Program.Element_Visitors;
package Program.Nodes.Record_Aggregates is
pragma Preelaborate;
type Record_Aggregate is
new Program.Nodes.Node
and Program.Elements.Record_Aggregates.Record_Aggregate
and Program.Elements.Record_Aggregates.Record_Aggregate_Text
with private;
function Create
(Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Components : Program.Elements.Record_Component_Associations
.Record_Component_Association_Vector_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Record_Aggregate;
type Implicit_Record_Aggregate is
new Program.Nodes.Node
and Program.Elements.Record_Aggregates.Record_Aggregate
with private;
function Create
(Components : Program.Elements.Record_Component_Associations
.Record_Component_Association_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Record_Aggregate
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Record_Aggregate is
abstract new Program.Nodes.Node
and Program.Elements.Record_Aggregates.Record_Aggregate
with record
Components : Program.Elements.Record_Component_Associations
.Record_Component_Association_Vector_Access;
end record;
procedure Initialize (Self : aliased in out Base_Record_Aggregate'Class);
overriding procedure Visit
(Self : not null access Base_Record_Aggregate;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Components
(Self : Base_Record_Aggregate)
return Program.Elements.Record_Component_Associations
.Record_Component_Association_Vector_Access;
overriding function Is_Record_Aggregate_Element
(Self : Base_Record_Aggregate)
return Boolean;
overriding function Is_Expression_Element
(Self : Base_Record_Aggregate)
return Boolean;
type Record_Aggregate is
new Base_Record_Aggregate
and Program.Elements.Record_Aggregates.Record_Aggregate_Text
with record
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Record_Aggregate_Text
(Self : aliased in out Record_Aggregate)
return Program.Elements.Record_Aggregates.Record_Aggregate_Text_Access;
overriding function Left_Bracket_Token
(Self : Record_Aggregate)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Right_Bracket_Token
(Self : Record_Aggregate)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Record_Aggregate is
new Base_Record_Aggregate
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Record_Aggregate_Text
(Self : aliased in out Implicit_Record_Aggregate)
return Program.Elements.Record_Aggregates.Record_Aggregate_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Record_Aggregate)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Record_Aggregate)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Record_Aggregate)
return Boolean;
end Program.Nodes.Record_Aggregates;
|
AdaCore/Ada_Drivers_Library | Ada | 48,948 | 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.RCC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_HSITRIM_Field is HAL.UInt5;
subtype CR_HSICAL_Field is HAL.UInt8;
-- clock control register
type CR_Register is record
-- Internal high-speed clock enable
HSION : Boolean := True;
-- Read-only. Internal high-speed clock ready flag
HSIRDY : Boolean := True;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Internal high-speed clock trimming
HSITRIM : CR_HSITRIM_Field := 16#10#;
-- Read-only. Internal high-speed clock calibration
HSICAL : CR_HSICAL_Field := 16#0#;
-- HSE clock enable
HSEON : Boolean := False;
-- Read-only. HSE clock ready flag
HSERDY : Boolean := False;
-- HSE clock bypass
HSEBYP : Boolean := False;
-- Clock security system enable
CSSON : Boolean := False;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
-- Main PLL (PLL) enable
PLLON : Boolean := False;
-- Read-only. Main PLL (PLL) clock ready flag
PLLRDY : Boolean := False;
-- PLLI2S enable
PLLI2SON : Boolean := False;
-- Read-only. PLLI2S clock ready flag
PLLI2SRDY : Boolean := False;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
HSION at 0 range 0 .. 0;
HSIRDY at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
HSITRIM at 0 range 3 .. 7;
HSICAL at 0 range 8 .. 15;
HSEON at 0 range 16 .. 16;
HSERDY at 0 range 17 .. 17;
HSEBYP at 0 range 18 .. 18;
CSSON at 0 range 19 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
PLLON at 0 range 24 .. 24;
PLLRDY at 0 range 25 .. 25;
PLLI2SON at 0 range 26 .. 26;
PLLI2SRDY at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype PLLCFGR_PLLM_Field is HAL.UInt6;
subtype PLLCFGR_PLLN_Field is HAL.UInt9;
subtype PLLCFGR_PLLP_Field is HAL.UInt2;
subtype PLLCFGR_PLLQ_Field is HAL.UInt4;
-- PLL configuration register
type PLLCFGR_Register is record
-- Division factor for the main PLL (PLL) and audio PLL (PLLI2S) input
-- clock
PLLM : PLLCFGR_PLLM_Field := 16#10#;
-- Main PLL (PLL) multiplication factor for VCO
PLLN : PLLCFGR_PLLN_Field := 16#C0#;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Main PLL (PLL) division factor for main system clock
PLLP : PLLCFGR_PLLP_Field := 16#0#;
-- unspecified
Reserved_18_21 : HAL.UInt4 := 16#0#;
-- Main PLL(PLL) and audio PLL (PLLI2S) entry clock source
PLLSRC : Boolean := False;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- Main PLL (PLL) division factor for USB OTG FS, SDIO and random number
-- generator clocks
PLLQ : PLLCFGR_PLLQ_Field := 16#4#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#2#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PLLCFGR_Register use record
PLLM at 0 range 0 .. 5;
PLLN at 0 range 6 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
PLLP at 0 range 16 .. 17;
Reserved_18_21 at 0 range 18 .. 21;
PLLSRC at 0 range 22 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
PLLQ at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype CFGR_SW_Field is HAL.UInt2;
subtype CFGR_SWS_Field is HAL.UInt2;
subtype CFGR_HPRE_Field is HAL.UInt4;
-- CFGR_PPRE array element
subtype CFGR_PPRE_Element is HAL.UInt3;
-- CFGR_PPRE array
type CFGR_PPRE_Field_Array is array (1 .. 2) of CFGR_PPRE_Element
with Component_Size => 3, Size => 6;
-- Type definition for CFGR_PPRE
type CFGR_PPRE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PPRE as a value
Val : HAL.UInt6;
when True =>
-- PPRE as an array
Arr : CFGR_PPRE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CFGR_PPRE_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
subtype CFGR_RTCPRE_Field is HAL.UInt5;
subtype CFGR_MCO1_Field is HAL.UInt2;
subtype CFGR_MCO1PRE_Field is HAL.UInt3;
subtype CFGR_MCO2PRE_Field is HAL.UInt3;
subtype CFGR_MCO2_Field is HAL.UInt2;
-- clock configuration register
type CFGR_Register is record
-- System clock switch
SW : CFGR_SW_Field := 16#0#;
-- Read-only. System clock switch status
SWS : CFGR_SWS_Field := 16#0#;
-- AHB prescaler
HPRE : CFGR_HPRE_Field := 16#0#;
-- unspecified
Reserved_8_9 : HAL.UInt2 := 16#0#;
-- APB Low speed prescaler (APB1)
PPRE : CFGR_PPRE_Field := (As_Array => False, Val => 16#0#);
-- HSE division factor for RTC clock
RTCPRE : CFGR_RTCPRE_Field := 16#0#;
-- Microcontroller clock output 1
MCO1 : CFGR_MCO1_Field := 16#0#;
-- I2S clock selection
I2SSRC : Boolean := False;
-- MCO1 prescaler
MCO1PRE : CFGR_MCO1PRE_Field := 16#0#;
-- MCO2 prescaler
MCO2PRE : CFGR_MCO2PRE_Field := 16#0#;
-- Microcontroller clock output 2
MCO2 : CFGR_MCO2_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR_Register use record
SW at 0 range 0 .. 1;
SWS at 0 range 2 .. 3;
HPRE at 0 range 4 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
PPRE at 0 range 10 .. 15;
RTCPRE at 0 range 16 .. 20;
MCO1 at 0 range 21 .. 22;
I2SSRC at 0 range 23 .. 23;
MCO1PRE at 0 range 24 .. 26;
MCO2PRE at 0 range 27 .. 29;
MCO2 at 0 range 30 .. 31;
end record;
-- clock interrupt register
type CIR_Register is record
-- Read-only. LSI ready interrupt flag
LSIRDYF : Boolean := False;
-- Read-only. LSE ready interrupt flag
LSERDYF : Boolean := False;
-- Read-only. HSI ready interrupt flag
HSIRDYF : Boolean := False;
-- Read-only. HSE ready interrupt flag
HSERDYF : Boolean := False;
-- Read-only. Main PLL (PLL) ready interrupt flag
PLLRDYF : Boolean := False;
-- Read-only. PLLI2S ready interrupt flag
PLLI2SRDYF : Boolean := False;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- Read-only. Clock security system interrupt flag
CSSF : Boolean := False;
-- LSI ready interrupt enable
LSIRDYIE : Boolean := False;
-- LSE ready interrupt enable
LSERDYIE : Boolean := False;
-- HSI ready interrupt enable
HSIRDYIE : Boolean := False;
-- HSE ready interrupt enable
HSERDYIE : Boolean := False;
-- Main PLL (PLL) ready interrupt enable
PLLRDYIE : Boolean := False;
-- PLLI2S ready interrupt enable
PLLI2SRDYIE : Boolean := False;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Write-only. LSI ready interrupt clear
LSIRDYC : Boolean := False;
-- Write-only. LSE ready interrupt clear
LSERDYC : Boolean := False;
-- Write-only. HSI ready interrupt clear
HSIRDYC : Boolean := False;
-- Write-only. HSE ready interrupt clear
HSERDYC : Boolean := False;
-- Write-only. Main PLL(PLL) ready interrupt clear
PLLRDYC : Boolean := False;
-- Write-only. PLLI2S ready interrupt clear
PLLI2SRDYC : Boolean := False;
-- unspecified
Reserved_22_22 : HAL.Bit := 16#0#;
-- Write-only. Clock security system interrupt clear
CSSC : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CIR_Register use record
LSIRDYF at 0 range 0 .. 0;
LSERDYF at 0 range 1 .. 1;
HSIRDYF at 0 range 2 .. 2;
HSERDYF at 0 range 3 .. 3;
PLLRDYF at 0 range 4 .. 4;
PLLI2SRDYF at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
CSSF at 0 range 7 .. 7;
LSIRDYIE at 0 range 8 .. 8;
LSERDYIE at 0 range 9 .. 9;
HSIRDYIE at 0 range 10 .. 10;
HSERDYIE at 0 range 11 .. 11;
PLLRDYIE at 0 range 12 .. 12;
PLLI2SRDYIE at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
LSIRDYC at 0 range 16 .. 16;
LSERDYC at 0 range 17 .. 17;
HSIRDYC at 0 range 18 .. 18;
HSERDYC at 0 range 19 .. 19;
PLLRDYC at 0 range 20 .. 20;
PLLI2SRDYC at 0 range 21 .. 21;
Reserved_22_22 at 0 range 22 .. 22;
CSSC at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- AHB1 peripheral reset register
type AHB1RSTR_Register is record
-- IO port A reset
GPIOARST : Boolean := False;
-- IO port B reset
GPIOBRST : Boolean := False;
-- IO port C reset
GPIOCRST : Boolean := False;
-- IO port D reset
GPIODRST : Boolean := False;
-- IO port E reset
GPIOERST : Boolean := False;
-- IO port F reset
GPIOFRST : Boolean := False;
-- IO port G reset
GPIOGRST : Boolean := False;
-- IO port H reset
GPIOHRST : Boolean := False;
-- IO port I reset
GPIOIRST : Boolean := False;
-- unspecified
Reserved_9_11 : HAL.UInt3 := 16#0#;
-- CRC reset
CRCRST : Boolean := False;
-- unspecified
Reserved_13_20 : HAL.UInt8 := 16#0#;
-- DMA2 reset
DMA1RST : Boolean := False;
-- DMA2 reset
DMA2RST : Boolean := False;
-- unspecified
Reserved_23_24 : HAL.UInt2 := 16#0#;
-- Ethernet MAC reset
ETHMACRST : Boolean := False;
-- unspecified
Reserved_26_28 : HAL.UInt3 := 16#0#;
-- USB OTG HS module reset
OTGHSRST : Boolean := False;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB1RSTR_Register use record
GPIOARST at 0 range 0 .. 0;
GPIOBRST at 0 range 1 .. 1;
GPIOCRST at 0 range 2 .. 2;
GPIODRST at 0 range 3 .. 3;
GPIOERST at 0 range 4 .. 4;
GPIOFRST at 0 range 5 .. 5;
GPIOGRST at 0 range 6 .. 6;
GPIOHRST at 0 range 7 .. 7;
GPIOIRST at 0 range 8 .. 8;
Reserved_9_11 at 0 range 9 .. 11;
CRCRST at 0 range 12 .. 12;
Reserved_13_20 at 0 range 13 .. 20;
DMA1RST at 0 range 21 .. 21;
DMA2RST at 0 range 22 .. 22;
Reserved_23_24 at 0 range 23 .. 24;
ETHMACRST at 0 range 25 .. 25;
Reserved_26_28 at 0 range 26 .. 28;
OTGHSRST at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- AHB2 peripheral reset register
type AHB2RSTR_Register is record
-- Camera interface reset
DCMIRST : Boolean := False;
-- unspecified
Reserved_1_5 : HAL.UInt5 := 16#0#;
-- Random number generator module reset
RNGRST : Boolean := False;
-- USB OTG FS module reset
OTGFSRST : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB2RSTR_Register use record
DCMIRST at 0 range 0 .. 0;
Reserved_1_5 at 0 range 1 .. 5;
RNGRST at 0 range 6 .. 6;
OTGFSRST at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- AHB3 peripheral reset register
type AHB3RSTR_Register is record
-- Flexible static memory controller module reset
FSMCRST : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB3RSTR_Register use record
FSMCRST at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- APB1 peripheral reset register
type APB1RSTR_Register is record
-- TIM2 reset
TIM2RST : Boolean := False;
-- TIM3 reset
TIM3RST : Boolean := False;
-- TIM4 reset
TIM4RST : Boolean := False;
-- TIM5 reset
TIM5RST : Boolean := False;
-- TIM6 reset
TIM6RST : Boolean := False;
-- TIM7 reset
TIM7RST : Boolean := False;
-- TIM12 reset
TIM12RST : Boolean := False;
-- TIM13 reset
TIM13RST : Boolean := False;
-- TIM14 reset
TIM14RST : Boolean := False;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- Window watchdog reset
WWDGRST : Boolean := False;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- SPI 2 reset
SPI2RST : Boolean := False;
-- SPI 3 reset
SPI3RST : Boolean := False;
-- unspecified
Reserved_16_16 : HAL.Bit := 16#0#;
-- USART 2 reset
UART2RST : Boolean := False;
-- USART 3 reset
UART3RST : Boolean := False;
-- USART 4 reset
UART4RST : Boolean := False;
-- USART 5 reset
UART5RST : Boolean := False;
-- I2C 1 reset
I2C1RST : Boolean := False;
-- I2C 2 reset
I2C2RST : Boolean := False;
-- I2C3 reset
I2C3RST : Boolean := False;
-- unspecified
Reserved_24_24 : HAL.Bit := 16#0#;
-- CAN1 reset
CAN1RST : Boolean := False;
-- CAN2 reset
CAN2RST : Boolean := False;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- Power interface reset
PWRRST : Boolean := False;
-- DAC reset
DACRST : Boolean := False;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1RSTR_Register use record
TIM2RST at 0 range 0 .. 0;
TIM3RST at 0 range 1 .. 1;
TIM4RST at 0 range 2 .. 2;
TIM5RST at 0 range 3 .. 3;
TIM6RST at 0 range 4 .. 4;
TIM7RST at 0 range 5 .. 5;
TIM12RST at 0 range 6 .. 6;
TIM13RST at 0 range 7 .. 7;
TIM14RST at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGRST at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2RST at 0 range 14 .. 14;
SPI3RST at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
UART2RST at 0 range 17 .. 17;
UART3RST at 0 range 18 .. 18;
UART4RST at 0 range 19 .. 19;
UART5RST at 0 range 20 .. 20;
I2C1RST at 0 range 21 .. 21;
I2C2RST at 0 range 22 .. 22;
I2C3RST at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CAN1RST at 0 range 25 .. 25;
CAN2RST at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
PWRRST at 0 range 28 .. 28;
DACRST at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- APB2 peripheral reset register
type APB2RSTR_Register is record
-- TIM1 reset
TIM1RST : Boolean := False;
-- TIM8 reset
TIM8RST : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- USART1 reset
USART1RST : Boolean := False;
-- USART6 reset
USART6RST : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- ADC interface reset (common to all ADCs)
ADCRST : Boolean := False;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- SDIO reset
SDIORST : Boolean := False;
-- SPI 1 reset
SPI1RST : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- System configuration controller reset
SYSCFGRST : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- TIM9 reset
TIM9RST : Boolean := False;
-- TIM10 reset
TIM10RST : Boolean := False;
-- TIM11 reset
TIM11RST : 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 APB2RSTR_Register use record
TIM1RST at 0 range 0 .. 0;
TIM8RST at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
USART1RST at 0 range 4 .. 4;
USART6RST at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
ADCRST at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
SDIORST at 0 range 11 .. 11;
SPI1RST at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
SYSCFGRST at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM9RST at 0 range 16 .. 16;
TIM10RST at 0 range 17 .. 17;
TIM11RST at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- AHB1 peripheral clock register
type AHB1ENR_Register is record
-- IO port A clock enable
GPIOAEN : Boolean := False;
-- IO port B clock enable
GPIOBEN : Boolean := False;
-- IO port C clock enable
GPIOCEN : Boolean := False;
-- IO port D clock enable
GPIODEN : Boolean := False;
-- IO port E clock enable
GPIOEEN : Boolean := False;
-- IO port F clock enable
GPIOFEN : Boolean := False;
-- IO port G clock enable
GPIOGEN : Boolean := False;
-- IO port H clock enable
GPIOHEN : Boolean := False;
-- IO port I clock enable
GPIOIEN : Boolean := False;
-- unspecified
Reserved_9_11 : HAL.UInt3 := 16#0#;
-- CRC clock enable
CRCEN : Boolean := False;
-- unspecified
Reserved_13_17 : HAL.UInt5 := 16#0#;
-- Backup SRAM interface clock enable
BKPSRAMEN : Boolean := False;
-- unspecified
Reserved_19_20 : HAL.UInt2 := 16#2#;
-- DMA1 clock enable
DMA1EN : Boolean := False;
-- DMA2 clock enable
DMA2EN : Boolean := False;
-- unspecified
Reserved_23_24 : HAL.UInt2 := 16#0#;
-- Ethernet MAC clock enable
ETHMACEN : Boolean := False;
-- Ethernet Transmission clock enable
ETHMACTXEN : Boolean := False;
-- Ethernet Reception clock enable
ETHMACRXEN : Boolean := False;
-- Ethernet PTP clock enable
ETHMACPTPEN : Boolean := False;
-- USB OTG HS clock enable
OTGHSEN : Boolean := False;
-- USB OTG HSULPI clock enable
OTGHSULPIEN : Boolean := False;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB1ENR_Register use record
GPIOAEN at 0 range 0 .. 0;
GPIOBEN at 0 range 1 .. 1;
GPIOCEN at 0 range 2 .. 2;
GPIODEN at 0 range 3 .. 3;
GPIOEEN at 0 range 4 .. 4;
GPIOFEN at 0 range 5 .. 5;
GPIOGEN at 0 range 6 .. 6;
GPIOHEN at 0 range 7 .. 7;
GPIOIEN at 0 range 8 .. 8;
Reserved_9_11 at 0 range 9 .. 11;
CRCEN at 0 range 12 .. 12;
Reserved_13_17 at 0 range 13 .. 17;
BKPSRAMEN at 0 range 18 .. 18;
Reserved_19_20 at 0 range 19 .. 20;
DMA1EN at 0 range 21 .. 21;
DMA2EN at 0 range 22 .. 22;
Reserved_23_24 at 0 range 23 .. 24;
ETHMACEN at 0 range 25 .. 25;
ETHMACTXEN at 0 range 26 .. 26;
ETHMACRXEN at 0 range 27 .. 27;
ETHMACPTPEN at 0 range 28 .. 28;
OTGHSEN at 0 range 29 .. 29;
OTGHSULPIEN at 0 range 30 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-- AHB2 peripheral clock enable register
type AHB2ENR_Register is record
-- Camera interface enable
DCMIEN : Boolean := False;
-- unspecified
Reserved_1_5 : HAL.UInt5 := 16#0#;
-- Random number generator clock enable
RNGEN : Boolean := False;
-- USB OTG FS clock enable
OTGFSEN : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB2ENR_Register use record
DCMIEN at 0 range 0 .. 0;
Reserved_1_5 at 0 range 1 .. 5;
RNGEN at 0 range 6 .. 6;
OTGFSEN at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- AHB3 peripheral clock enable register
type AHB3ENR_Register is record
-- Flexible static memory controller module clock enable
FSMCEN : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB3ENR_Register use record
FSMCEN at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- APB1 peripheral clock enable register
type APB1ENR_Register is record
-- TIM2 clock enable
TIM2EN : Boolean := False;
-- TIM3 clock enable
TIM3EN : Boolean := False;
-- TIM4 clock enable
TIM4EN : Boolean := False;
-- TIM5 clock enable
TIM5EN : Boolean := False;
-- TIM6 clock enable
TIM6EN : Boolean := False;
-- TIM7 clock enable
TIM7EN : Boolean := False;
-- TIM12 clock enable
TIM12EN : Boolean := False;
-- TIM13 clock enable
TIM13EN : Boolean := False;
-- TIM14 clock enable
TIM14EN : Boolean := False;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- Window watchdog clock enable
WWDGEN : Boolean := False;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- SPI2 clock enable
SPI2EN : Boolean := False;
-- SPI3 clock enable
SPI3EN : Boolean := False;
-- unspecified
Reserved_16_16 : HAL.Bit := 16#0#;
-- USART 2 clock enable
USART2EN : Boolean := False;
-- USART3 clock enable
USART3EN : Boolean := False;
-- UART4 clock enable
UART4EN : Boolean := False;
-- UART5 clock enable
UART5EN : Boolean := False;
-- I2C1 clock enable
I2C1EN : Boolean := False;
-- I2C2 clock enable
I2C2EN : Boolean := False;
-- I2C3 clock enable
I2C3EN : Boolean := False;
-- unspecified
Reserved_24_24 : HAL.Bit := 16#0#;
-- CAN 1 clock enable
CAN1EN : Boolean := False;
-- CAN 2 clock enable
CAN2EN : Boolean := False;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- Power interface clock enable
PWREN : Boolean := False;
-- DAC interface clock enable
DACEN : Boolean := False;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1ENR_Register use record
TIM2EN at 0 range 0 .. 0;
TIM3EN at 0 range 1 .. 1;
TIM4EN at 0 range 2 .. 2;
TIM5EN at 0 range 3 .. 3;
TIM6EN at 0 range 4 .. 4;
TIM7EN at 0 range 5 .. 5;
TIM12EN at 0 range 6 .. 6;
TIM13EN at 0 range 7 .. 7;
TIM14EN at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGEN at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2EN at 0 range 14 .. 14;
SPI3EN at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
USART2EN at 0 range 17 .. 17;
USART3EN at 0 range 18 .. 18;
UART4EN at 0 range 19 .. 19;
UART5EN at 0 range 20 .. 20;
I2C1EN at 0 range 21 .. 21;
I2C2EN at 0 range 22 .. 22;
I2C3EN at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CAN1EN at 0 range 25 .. 25;
CAN2EN at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
PWREN at 0 range 28 .. 28;
DACEN at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- APB2 peripheral clock enable register
type APB2ENR_Register is record
-- TIM1 clock enable
TIM1EN : Boolean := False;
-- TIM8 clock enable
TIM8EN : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- USART1 clock enable
USART1EN : Boolean := False;
-- USART6 clock enable
USART6EN : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- ADC1 clock enable
ADC1EN : Boolean := False;
-- ADC2 clock enable
ADC2EN : Boolean := False;
-- ADC3 clock enable
ADC3EN : Boolean := False;
-- SDIO clock enable
SDIOEN : Boolean := False;
-- SPI1 clock enable
SPI1EN : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- System configuration controller clock enable
SYSCFGEN : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- TIM9 clock enable
TIM9EN : Boolean := False;
-- TIM10 clock enable
TIM10EN : Boolean := False;
-- TIM11 clock enable
TIM11EN : 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 APB2ENR_Register use record
TIM1EN at 0 range 0 .. 0;
TIM8EN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
USART1EN at 0 range 4 .. 4;
USART6EN at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
ADC1EN at 0 range 8 .. 8;
ADC2EN at 0 range 9 .. 9;
ADC3EN at 0 range 10 .. 10;
SDIOEN at 0 range 11 .. 11;
SPI1EN at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
SYSCFGEN at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM9EN at 0 range 16 .. 16;
TIM10EN at 0 range 17 .. 17;
TIM11EN at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- AHB1 peripheral clock enable in low power mode register
type AHB1LPENR_Register is record
-- IO port A clock enable during sleep mode
GPIOALPEN : Boolean := True;
-- IO port B clock enable during Sleep mode
GPIOBLPEN : Boolean := True;
-- IO port C clock enable during Sleep mode
GPIOCLPEN : Boolean := True;
-- IO port D clock enable during Sleep mode
GPIODLPEN : Boolean := True;
-- IO port E clock enable during Sleep mode
GPIOELPEN : Boolean := True;
-- IO port F clock enable during Sleep mode
GPIOFLPEN : Boolean := True;
-- IO port G clock enable during Sleep mode
GPIOGLPEN : Boolean := True;
-- IO port H clock enable during Sleep mode
GPIOHLPEN : Boolean := True;
-- IO port I clock enable during Sleep mode
GPIOILPEN : Boolean := True;
-- unspecified
Reserved_9_11 : HAL.UInt3 := 16#0#;
-- CRC clock enable during Sleep mode
CRCLPEN : Boolean := True;
-- unspecified
Reserved_13_14 : HAL.UInt2 := 16#0#;
-- Flash interface clock enable during Sleep mode
FLITFLPEN : Boolean := True;
-- SRAM 1interface clock enable during Sleep mode
SRAM1LPEN : Boolean := True;
-- SRAM 2 interface clock enable during Sleep mode
SRAM2LPEN : Boolean := True;
-- Backup SRAM interface clock enable during Sleep mode
BKPSRAMLPEN : Boolean := True;
-- unspecified
Reserved_19_20 : HAL.UInt2 := 16#0#;
-- DMA1 clock enable during Sleep mode
DMA1LPEN : Boolean := True;
-- DMA2 clock enable during Sleep mode
DMA2LPEN : Boolean := True;
-- unspecified
Reserved_23_24 : HAL.UInt2 := 16#0#;
-- Ethernet MAC clock enable during Sleep mode
ETHMACLPEN : Boolean := True;
-- Ethernet transmission clock enable during Sleep mode
ETHMACTXLPEN : Boolean := True;
-- Ethernet reception clock enable during Sleep mode
ETHMACRXLPEN : Boolean := True;
-- Ethernet PTP clock enable during Sleep mode
ETHMACPTPLPEN : Boolean := True;
-- USB OTG HS clock enable during Sleep mode
OTGHSLPEN : Boolean := True;
-- USB OTG HS ULPI clock enable during Sleep mode
OTGHSULPILPEN : Boolean := True;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB1LPENR_Register use record
GPIOALPEN at 0 range 0 .. 0;
GPIOBLPEN at 0 range 1 .. 1;
GPIOCLPEN at 0 range 2 .. 2;
GPIODLPEN at 0 range 3 .. 3;
GPIOELPEN at 0 range 4 .. 4;
GPIOFLPEN at 0 range 5 .. 5;
GPIOGLPEN at 0 range 6 .. 6;
GPIOHLPEN at 0 range 7 .. 7;
GPIOILPEN at 0 range 8 .. 8;
Reserved_9_11 at 0 range 9 .. 11;
CRCLPEN at 0 range 12 .. 12;
Reserved_13_14 at 0 range 13 .. 14;
FLITFLPEN at 0 range 15 .. 15;
SRAM1LPEN at 0 range 16 .. 16;
SRAM2LPEN at 0 range 17 .. 17;
BKPSRAMLPEN at 0 range 18 .. 18;
Reserved_19_20 at 0 range 19 .. 20;
DMA1LPEN at 0 range 21 .. 21;
DMA2LPEN at 0 range 22 .. 22;
Reserved_23_24 at 0 range 23 .. 24;
ETHMACLPEN at 0 range 25 .. 25;
ETHMACTXLPEN at 0 range 26 .. 26;
ETHMACRXLPEN at 0 range 27 .. 27;
ETHMACPTPLPEN at 0 range 28 .. 28;
OTGHSLPEN at 0 range 29 .. 29;
OTGHSULPILPEN at 0 range 30 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-- AHB2 peripheral clock enable in low power mode register
type AHB2LPENR_Register is record
-- Camera interface enable during Sleep mode
DCMILPEN : Boolean := True;
-- unspecified
Reserved_1_5 : HAL.UInt5 := 16#18#;
-- Random number generator clock enable during Sleep mode
RNGLPEN : Boolean := True;
-- USB OTG FS clock enable during Sleep mode
OTGFSLPEN : Boolean := True;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB2LPENR_Register use record
DCMILPEN at 0 range 0 .. 0;
Reserved_1_5 at 0 range 1 .. 5;
RNGLPEN at 0 range 6 .. 6;
OTGFSLPEN at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- AHB3 peripheral clock enable in low power mode register
type AHB3LPENR_Register is record
-- Flexible static memory controller module clock enable during Sleep
-- mode
FSMCLPEN : Boolean := True;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB3LPENR_Register use record
FSMCLPEN at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- APB1 peripheral clock enable in low power mode register
type APB1LPENR_Register is record
-- TIM2 clock enable during Sleep mode
TIM2LPEN : Boolean := True;
-- TIM3 clock enable during Sleep mode
TIM3LPEN : Boolean := True;
-- TIM4 clock enable during Sleep mode
TIM4LPEN : Boolean := True;
-- TIM5 clock enable during Sleep mode
TIM5LPEN : Boolean := True;
-- TIM6 clock enable during Sleep mode
TIM6LPEN : Boolean := True;
-- TIM7 clock enable during Sleep mode
TIM7LPEN : Boolean := True;
-- TIM12 clock enable during Sleep mode
TIM12LPEN : Boolean := True;
-- TIM13 clock enable during Sleep mode
TIM13LPEN : Boolean := True;
-- TIM14 clock enable during Sleep mode
TIM14LPEN : Boolean := True;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- Window watchdog clock enable during Sleep mode
WWDGLPEN : Boolean := True;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- SPI2 clock enable during Sleep mode
SPI2LPEN : Boolean := True;
-- SPI3 clock enable during Sleep mode
SPI3LPEN : Boolean := True;
-- unspecified
Reserved_16_16 : HAL.Bit := 16#0#;
-- USART2 clock enable during Sleep mode
USART2LPEN : Boolean := True;
-- USART3 clock enable during Sleep mode
USART3LPEN : Boolean := True;
-- UART4 clock enable during Sleep mode
UART4LPEN : Boolean := True;
-- UART5 clock enable during Sleep mode
UART5LPEN : Boolean := True;
-- I2C1 clock enable during Sleep mode
I2C1LPEN : Boolean := True;
-- I2C2 clock enable during Sleep mode
I2C2LPEN : Boolean := True;
-- I2C3 clock enable during Sleep mode
I2C3LPEN : Boolean := True;
-- unspecified
Reserved_24_24 : HAL.Bit := 16#0#;
-- CAN 1 clock enable during Sleep mode
CAN1LPEN : Boolean := True;
-- CAN 2 clock enable during Sleep mode
CAN2LPEN : Boolean := True;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- Power interface clock enable during Sleep mode
PWRLPEN : Boolean := True;
-- DAC interface clock enable during Sleep mode
DACLPEN : Boolean := True;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1LPENR_Register use record
TIM2LPEN at 0 range 0 .. 0;
TIM3LPEN at 0 range 1 .. 1;
TIM4LPEN at 0 range 2 .. 2;
TIM5LPEN at 0 range 3 .. 3;
TIM6LPEN at 0 range 4 .. 4;
TIM7LPEN at 0 range 5 .. 5;
TIM12LPEN at 0 range 6 .. 6;
TIM13LPEN at 0 range 7 .. 7;
TIM14LPEN at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGLPEN at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2LPEN at 0 range 14 .. 14;
SPI3LPEN at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
USART2LPEN at 0 range 17 .. 17;
USART3LPEN at 0 range 18 .. 18;
UART4LPEN at 0 range 19 .. 19;
UART5LPEN at 0 range 20 .. 20;
I2C1LPEN at 0 range 21 .. 21;
I2C2LPEN at 0 range 22 .. 22;
I2C3LPEN at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CAN1LPEN at 0 range 25 .. 25;
CAN2LPEN at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
PWRLPEN at 0 range 28 .. 28;
DACLPEN at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- APB2 peripheral clock enabled in low power mode register
type APB2LPENR_Register is record
-- TIM1 clock enable during Sleep mode
TIM1LPEN : Boolean := True;
-- TIM8 clock enable during Sleep mode
TIM8LPEN : Boolean := True;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- USART1 clock enable during Sleep mode
USART1LPEN : Boolean := True;
-- USART6 clock enable during Sleep mode
USART6LPEN : Boolean := True;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- ADC1 clock enable during Sleep mode
ADC1LPEN : Boolean := True;
-- ADC2 clock enable during Sleep mode
ADC2LPEN : Boolean := True;
-- ADC 3 clock enable during Sleep mode
ADC3LPEN : Boolean := True;
-- SDIO clock enable during Sleep mode
SDIOLPEN : Boolean := True;
-- SPI 1 clock enable during Sleep mode
SPI1LPEN : Boolean := True;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- System configuration controller clock enable during Sleep mode
SYSCFGLPEN : Boolean := True;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- TIM9 clock enable during sleep mode
TIM9LPEN : Boolean := True;
-- TIM10 clock enable during Sleep mode
TIM10LPEN : Boolean := True;
-- TIM11 clock enable during Sleep mode
TIM11LPEN : Boolean := True;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2LPENR_Register use record
TIM1LPEN at 0 range 0 .. 0;
TIM8LPEN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
USART1LPEN at 0 range 4 .. 4;
USART6LPEN at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
ADC1LPEN at 0 range 8 .. 8;
ADC2LPEN at 0 range 9 .. 9;
ADC3LPEN at 0 range 10 .. 10;
SDIOLPEN at 0 range 11 .. 11;
SPI1LPEN at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
SYSCFGLPEN at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM9LPEN at 0 range 16 .. 16;
TIM10LPEN at 0 range 17 .. 17;
TIM11LPEN at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- BDCR_RTCSEL array
type BDCR_RTCSEL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for BDCR_RTCSEL
type BDCR_RTCSEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- RTCSEL as a value
Val : HAL.UInt2;
when True =>
-- RTCSEL as an array
Arr : BDCR_RTCSEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for BDCR_RTCSEL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Backup domain control register
type BDCR_Register is record
-- External low-speed oscillator enable
LSEON : Boolean := False;
-- Read-only. External low-speed oscillator ready
LSERDY : Boolean := False;
-- External low-speed oscillator bypass
LSEBYP : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- RTC clock source selection
RTCSEL : BDCR_RTCSEL_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_10_14 : HAL.UInt5 := 16#0#;
-- RTC clock enable
RTCEN : Boolean := False;
-- Backup domain software reset
BDRST : 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 BDCR_Register use record
LSEON at 0 range 0 .. 0;
LSERDY at 0 range 1 .. 1;
LSEBYP at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
RTCSEL at 0 range 8 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
RTCEN at 0 range 15 .. 15;
BDRST at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- clock control & status register
type CSR_Register is record
-- Internal low-speed oscillator enable
LSION : Boolean := False;
-- Read-only. Internal low-speed oscillator ready
LSIRDY : Boolean := False;
-- unspecified
Reserved_2_23 : HAL.UInt22 := 16#0#;
-- Remove reset flag
RMVF : Boolean := False;
-- BOR reset flag
BORRSTF : Boolean := True;
-- PIN reset flag
PADRSTF : Boolean := True;
-- POR/PDR reset flag
PORRSTF : Boolean := True;
-- Software reset flag
SFTRSTF : Boolean := False;
-- Independent watchdog reset flag
WDGRSTF : Boolean := False;
-- Window watchdog reset flag
WWDGRSTF : Boolean := False;
-- Low-power reset flag
LPWRRSTF : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
LSION at 0 range 0 .. 0;
LSIRDY at 0 range 1 .. 1;
Reserved_2_23 at 0 range 2 .. 23;
RMVF at 0 range 24 .. 24;
BORRSTF at 0 range 25 .. 25;
PADRSTF at 0 range 26 .. 26;
PORRSTF at 0 range 27 .. 27;
SFTRSTF at 0 range 28 .. 28;
WDGRSTF at 0 range 29 .. 29;
WWDGRSTF at 0 range 30 .. 30;
LPWRRSTF at 0 range 31 .. 31;
end record;
subtype SSCGR_MODPER_Field is HAL.UInt13;
subtype SSCGR_INCSTEP_Field is HAL.UInt15;
-- spread spectrum clock generation register
type SSCGR_Register is record
-- Modulation period
MODPER : SSCGR_MODPER_Field := 16#0#;
-- Incrementation step
INCSTEP : SSCGR_INCSTEP_Field := 16#0#;
-- unspecified
Reserved_28_29 : HAL.UInt2 := 16#0#;
-- Spread Select
SPREADSEL : Boolean := False;
-- Spread spectrum modulation enable
SSCGEN : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SSCGR_Register use record
MODPER at 0 range 0 .. 12;
INCSTEP at 0 range 13 .. 27;
Reserved_28_29 at 0 range 28 .. 29;
SPREADSEL at 0 range 30 .. 30;
SSCGEN at 0 range 31 .. 31;
end record;
subtype PLLI2SCFGR_PLLI2SNx_Field is HAL.UInt9;
subtype PLLI2SCFGR_PLLI2SRx_Field is HAL.UInt3;
-- PLLI2S configuration register
type PLLI2SCFGR_Register is record
-- unspecified
Reserved_0_5 : HAL.UInt6 := 16#0#;
-- PLLI2S multiplication factor for VCO
PLLI2SNx : PLLI2SCFGR_PLLI2SNx_Field := 16#C0#;
-- unspecified
Reserved_15_27 : HAL.UInt13 := 16#0#;
-- PLLI2S division factor for I2S clocks
PLLI2SRx : PLLI2SCFGR_PLLI2SRx_Field := 16#2#;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PLLI2SCFGR_Register use record
Reserved_0_5 at 0 range 0 .. 5;
PLLI2SNx at 0 range 6 .. 14;
Reserved_15_27 at 0 range 15 .. 27;
PLLI2SRx at 0 range 28 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Reset and clock control
type RCC_Peripheral is record
-- clock control register
CR : aliased CR_Register;
-- PLL configuration register
PLLCFGR : aliased PLLCFGR_Register;
-- clock configuration register
CFGR : aliased CFGR_Register;
-- clock interrupt register
CIR : aliased CIR_Register;
-- AHB1 peripheral reset register
AHB1RSTR : aliased AHB1RSTR_Register;
-- AHB2 peripheral reset register
AHB2RSTR : aliased AHB2RSTR_Register;
-- AHB3 peripheral reset register
AHB3RSTR : aliased AHB3RSTR_Register;
-- APB1 peripheral reset register
APB1RSTR : aliased APB1RSTR_Register;
-- APB2 peripheral reset register
APB2RSTR : aliased APB2RSTR_Register;
-- AHB1 peripheral clock register
AHB1ENR : aliased AHB1ENR_Register;
-- AHB2 peripheral clock enable register
AHB2ENR : aliased AHB2ENR_Register;
-- AHB3 peripheral clock enable register
AHB3ENR : aliased AHB3ENR_Register;
-- APB1 peripheral clock enable register
APB1ENR : aliased APB1ENR_Register;
-- APB2 peripheral clock enable register
APB2ENR : aliased APB2ENR_Register;
-- AHB1 peripheral clock enable in low power mode register
AHB1LPENR : aliased AHB1LPENR_Register;
-- AHB2 peripheral clock enable in low power mode register
AHB2LPENR : aliased AHB2LPENR_Register;
-- AHB3 peripheral clock enable in low power mode register
AHB3LPENR : aliased AHB3LPENR_Register;
-- APB1 peripheral clock enable in low power mode register
APB1LPENR : aliased APB1LPENR_Register;
-- APB2 peripheral clock enabled in low power mode register
APB2LPENR : aliased APB2LPENR_Register;
-- Backup domain control register
BDCR : aliased BDCR_Register;
-- clock control & status register
CSR : aliased CSR_Register;
-- spread spectrum clock generation register
SSCGR : aliased SSCGR_Register;
-- PLLI2S configuration register
PLLI2SCFGR : aliased PLLI2SCFGR_Register;
end record
with Volatile;
for RCC_Peripheral use record
CR at 16#0# range 0 .. 31;
PLLCFGR at 16#4# range 0 .. 31;
CFGR at 16#8# range 0 .. 31;
CIR at 16#C# range 0 .. 31;
AHB1RSTR at 16#10# range 0 .. 31;
AHB2RSTR at 16#14# range 0 .. 31;
AHB3RSTR at 16#18# range 0 .. 31;
APB1RSTR at 16#20# range 0 .. 31;
APB2RSTR at 16#24# range 0 .. 31;
AHB1ENR at 16#30# range 0 .. 31;
AHB2ENR at 16#34# range 0 .. 31;
AHB3ENR at 16#38# range 0 .. 31;
APB1ENR at 16#40# range 0 .. 31;
APB2ENR at 16#44# range 0 .. 31;
AHB1LPENR at 16#50# range 0 .. 31;
AHB2LPENR at 16#54# range 0 .. 31;
AHB3LPENR at 16#58# range 0 .. 31;
APB1LPENR at 16#60# range 0 .. 31;
APB2LPENR at 16#64# range 0 .. 31;
BDCR at 16#70# range 0 .. 31;
CSR at 16#74# range 0 .. 31;
SSCGR at 16#80# range 0 .. 31;
PLLI2SCFGR at 16#84# range 0 .. 31;
end record;
-- Reset and clock control
RCC_Periph : aliased RCC_Peripheral
with Import, Address => System'To_Address (16#40023800#);
end STM32_SVD.RCC;
|
AdaCore/libadalang | Ada | 107,308 | adb | ------------------------------------------------------------------------------
-- --
-- GPR TECHNOLOGY --
-- --
-- Copyright (C) 2011-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 GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
with Ada.Directories;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation; use Ada;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with Gpr_Build_Util; use Gpr_Build_Util;
with Gpr_Script; use Gpr_Script;
with Gpr_Util; use Gpr_Util;
with Gprexch; use Gprexch;
with GPR.Debug; use GPR.Debug;
with GPR.Names; use GPR.Names;
with GPR.Snames; use GPR.Snames;
with GPR.Util; use GPR.Util;
package body Gprbuild.Link is
type Archive_Data is record
Checked : Boolean := False;
Has_Been_Built : Boolean := False;
Exists : Boolean := False;
end record;
type Source_Index_Rec is record
Project : Project_Id;
Id : Source_Id;
Found : Boolean := False;
end record;
-- Used as Source_Indexes component to check if archive needs to be rebuilt
type Source_Index_Array is array (Positive range <>) of Source_Index_Rec;
type Source_Indexes_Ref is access Source_Index_Array;
procedure Free is new Unchecked_Deallocation
(Source_Index_Array, Source_Indexes_Ref);
Initial_Source_Index_Count : constant Positive := 20;
Source_Indexes : Source_Indexes_Ref :=
new Source_Index_Array (1 .. Initial_Source_Index_Count);
-- A list of the Source_Ids, with an indication that they have been found
-- in the archive dependency file.
procedure Build_Global_Archive
(For_Project : Project_Id;
Project_Tree : Project_Tree_Ref;
Has_Been_Built : out Boolean;
Exists : out Boolean;
OK : out Boolean);
-- Build, if necessary, the global archive for a main project.
-- Out parameter Has_Been_Built is True iff the global archive has been
-- built/rebuilt. Exists is False if there is no need for a global archive.
-- OK is False when there is a problem building the global archive.
procedure Link_Main (Main_File : Main_Info);
-- Link a specific main unit
procedure Get_Linker_Options (For_Project : Project_Id);
-- Get the Linker_Options from a project
procedure Add_Rpath (Path : String);
-- Add a path name to Rpath
procedure Rpaths_Relative_To
(Exec_Dir : Path_Name_Type; Origin : Name_Id);
-- Change all paths in table Rpaths to paths relative to Exec_Dir, if they
-- have at least one non root directory in common.
function Is_In_Library_Project (Object_Path : String) return Boolean;
-- Return True if Object_Path is the path of an object file in a library
-- project.
procedure Display_Command
(Path : String_Access;
Ellipse : Boolean := False);
-- Display the command for a spawned process, if in Verbose_Mode or not in
-- Quiet_Output. In non verbose mode, when Ellipse is True, display "..."
-- in place of the first argument that has Display set to False.
procedure Add_Argument
(Arg : String_Access;
Display : Boolean;
Simple_Name : Boolean := False);
procedure Add_Argument
(Arg : String;
Display : Boolean;
Simple_Name : Boolean := False);
-- Add an argument to Arguments. Reallocate if necessary
procedure Add_Arguments
(Args : Argument_List;
Display : Boolean;
Simple_Name : Boolean := False);
-- Add a list of arguments to Arguments. Reallocate if necessary
No_Archive_Data : constant Archive_Data :=
(Checked => False,
Has_Been_Built => False,
Exists => False);
package Global_Archives_Built is new GNAT.HTable.Simple_HTable
(Header_Num => GPR.Header_Num,
Element => Archive_Data,
No_Element => No_Archive_Data,
Key => Name_Id,
Hash => GPR.Hash,
Equal => "=");
-- A hash table to record what global archives have been already built
package Cache_Args is new GNAT.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 200,
Table_Increment => 100);
-- A table to cache arguments, to avoid multiple allocation of the same
-- strings. It is not possible to use a hash table, because String is
-- an unconstrained type.
package Rpaths is new GNAT.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 200,
Table_Increment => 50);
-- Directories to be put in the run path option
package Library_Dirs is new GNAT.HTable.Simple_HTable
(Header_Num => GPR.Header_Num,
Element => Boolean,
No_Element => False,
Key => Path_Name_Type,
Hash => Hash,
Equal => "=");
-- A hash table to store the library dirs, to avoid repeating uselessly
-- the same switch when linking executables.
Last_Source : Natural := 0;
-- The index of the last valid component of Source_Indexes
Initial_Argument_Count : constant Positive := 20;
Arguments : Argument_List_Access :=
new Argument_List (1 .. Initial_Argument_Count);
-- Used to store lists of arguments to be used when spawning a process
Arguments_Displayed : Booleans :=
new Boolean_Array (1 .. Initial_Argument_Count);
-- For each argument in Arguments, indicate if the argument should be
-- displayed when procedure Display_Command is called.
Arguments_Simple_Name : Booleans :=
new Boolean_Array (1 .. Initial_Argument_Count);
-- For each argument that should be displayed, indicate that the argument
-- is a path name and that only the simple name should be displayed.
Last_Argument : Natural := 0;
-- Index of the last valid argument in Arguments
------------------
-- Add_Argument --
------------------
procedure Add_Argument
(Arg : String_Access;
Display : Boolean;
Simple_Name : Boolean := False)
is
begin
-- Nothing to do if no argument is specified or if argument is empty
if Arg /= null and then Arg'Length /= 0 then
-- Reallocate arrays if necessary
if Last_Argument = Arguments'Last then
declare
New_Arguments : constant Argument_List_Access :=
new Argument_List
(1 .. Last_Argument +
Initial_Argument_Count);
New_Arguments_Displayed : constant Booleans :=
new Boolean_Array
(1 .. Last_Argument +
Initial_Argument_Count);
New_Arguments_Simple_Name : constant Booleans :=
new Boolean_Array
(1 .. Last_Argument +
Initial_Argument_Count);
begin
New_Arguments (Arguments'Range) := Arguments.all;
-- To avoid deallocating the strings, nullify all components
-- of Arguments before calling Free.
Arguments.all := (others => null);
Free (Arguments);
Arguments := New_Arguments;
New_Arguments_Displayed (Arguments_Displayed'Range) :=
Arguments_Displayed.all;
Free (Arguments_Displayed);
Arguments_Displayed := New_Arguments_Displayed;
New_Arguments_Simple_Name (Arguments_Simple_Name'Range) :=
Arguments_Simple_Name.all;
Free (Arguments_Simple_Name);
Arguments_Simple_Name := New_Arguments_Simple_Name;
end;
end if;
-- Add the argument and its display indication
Last_Argument := Last_Argument + 1;
Arguments (Last_Argument) := Arg;
Arguments_Displayed (Last_Argument) := Display;
Arguments_Simple_Name (Last_Argument) := Simple_Name;
end if;
end Add_Argument;
procedure Add_Argument
(Arg : String;
Display : Boolean;
Simple_Name : Boolean := False)
is
Argument : String_Access := null;
begin
-- Nothing to do if argument is empty
if Arg'Length > 0 then
-- Check if the argument is already in the Cache_Args table. If it is
-- already there, reuse the allocated value.
for Index in 1 .. Cache_Args.Last loop
if Cache_Args.Table (Index).all = Arg then
Argument := Cache_Args.Table (Index);
exit;
end if;
end loop;
-- If the argument is not in the cache, create a new entry in the
-- cache.
if Argument = null then
Argument := new String'(Arg);
Cache_Args.Increment_Last;
Cache_Args.Table (Cache_Args.Last) := Argument;
end if;
-- And add the argument
Add_Argument (Argument, Display, Simple_Name);
end if;
end Add_Argument;
-------------------
-- Add_Arguments --
-------------------
procedure Add_Arguments
(Args : Argument_List;
Display : Boolean;
Simple_Name : Boolean := False)
is
begin
-- Reallocate the arrays, if necessary
if Last_Argument + Args'Length > Arguments'Last then
declare
New_Arguments : constant Argument_List_Access :=
new Argument_List
(1 .. Last_Argument + Args'Length +
Initial_Argument_Count);
New_Arguments_Displayed : constant Booleans :=
new Boolean_Array
(1 .. Last_Argument +
Args'Length +
Initial_Argument_Count);
begin
New_Arguments (1 .. Last_Argument) :=
Arguments (1 .. Last_Argument);
-- To avoid deallocating the strings, nullify all components
-- of Arguments before calling Free.
Arguments.all := (others => null);
Free (Arguments);
Arguments := New_Arguments;
New_Arguments_Displayed (1 .. Last_Argument) :=
Arguments_Displayed (1 .. Last_Argument);
Free (Arguments_Displayed);
Arguments_Displayed := New_Arguments_Displayed;
end;
end if;
-- Add the new arguments and the display indications
Arguments (Last_Argument + 1 .. Last_Argument + Args'Length) := Args;
Arguments_Displayed (Last_Argument + 1 .. Last_Argument + Args'Length) :=
(others => Display);
Arguments_Simple_Name (Last_Argument + 1 .. Last_Argument + Args'Length)
:= (others => Simple_Name);
Last_Argument := Last_Argument + Args'Length;
end Add_Arguments;
---------------
-- Add_Rpath --
---------------
procedure Add_Rpath (Path : String) is
begin
-- Nothing to do if Path is empty
if Path'Length > 0 then
-- Nothing to do if the directory is already in the Rpaths table
for J in 1 .. Rpaths.Last loop
if Rpaths.Table (J).all = Path then
return;
end if;
end loop;
Rpaths.Append (new String'(Path));
end if;
end Add_Rpath;
--------------------------
-- Build_Global_Archive --
--------------------------
procedure Build_Global_Archive
(For_Project : Project_Id;
Project_Tree : Project_Tree_Ref;
Has_Been_Built : out Boolean;
Exists : out Boolean;
OK : out Boolean)
is
Archive_Name : constant String :=
"lib"
& Get_Name_String (For_Project.Name)
& Archive_Suffix (For_Project);
-- The name of the archive file for this project
Archive_Dep_Name : constant String :=
"lib"
& Get_Name_String (For_Project.Name) & ".deps";
-- The name of the archive dependency file for this project
File : GPR.Util.Text_File;
Object_Path : Path_Name_Type;
Time_Stamp : Time_Stamp_Type;
First_Object : Natural;
Discard : Boolean;
Proj_List : Project_List;
Src_Id : Source_Id;
S_Id : Source_Id;
Success : Boolean;
Real_Last_Argument : Positive;
Current_Object_Pos : Positive;
Size : Natural;
Global_Archive_Data : Archive_Data;
Need_To_Build : Boolean;
procedure Add_Sources (Proj : Project_Id);
-- Add all the sources of project Proj to Sources_Index
procedure Add_Objects (Proj : Project_Id);
-- Add all the object paths of project Proj to Arguments
-----------------
-- Add_Sources --
-----------------
procedure Add_Sources (Proj : Project_Id) is
Project : Project_Id := Proj;
Id : Source_Id;
Iter : Source_Iterator;
procedure Add_Source_Id (Project : Project_Id; Id : Source_Id);
-- Add a source id to Source_Indexes, with Found set to False
-------------------
-- Add_Source_Id --
-------------------
procedure Add_Source_Id (Project : Project_Id; Id : Source_Id) is
begin
-- Reallocate the array, if necessary
if Last_Source = Source_Indexes'Last then
declare
New_Indexes : constant Source_Indexes_Ref :=
new Source_Index_Array
(1 .. Source_Indexes'Last +
Initial_Source_Index_Count);
begin
New_Indexes (Source_Indexes'Range) := Source_Indexes.all;
Free (Source_Indexes);
Source_Indexes := New_Indexes;
end;
end if;
Last_Source := Last_Source + 1;
Source_Indexes (Last_Source) := (Project, Id, False);
end Add_Source_Id;
begin
while Project /= No_Project loop
Iter := For_Each_Source (Project_Tree, Project);
loop
Id := GPR.Element (Iter);
exit when Id = No_Source;
if Is_Compilable (Id)
and then Id.Kind = Impl
and then Id.Unit = No_Unit_Index
then
Add_Source_Id (Proj, Id);
end if;
Next (Iter);
end loop;
Project := Project.Extends;
end loop;
end Add_Sources;
-----------------
-- Add_Objects --
-----------------
procedure Add_Objects (Proj : Project_Id) is
Project : Project_Id := Proj;
Id : Source_Id;
Iter : Source_Iterator;
type Arg_Record;
type Arg_Access is access Arg_Record;
type Arg_Record is record
Path : Name_Id;
Display : Boolean;
Simple : Boolean;
Next : Arg_Access;
end record;
First_Arg : Arg_Access := null;
-- Head of the list of arguments in ascending order of paths
procedure Add
(Path : String;
Display : Boolean;
Simple : Boolean);
-- Ad an argument in the list in the correct order
---------
-- Add --
---------
procedure Add
(Path : String;
Display : Boolean;
Simple : Boolean)
is
Arg_Ptr : Arg_Access;
Current : Arg_Access;
begin
Name_Len := 0;
Add_Str_To_Name_Buffer (Path);
Arg_Ptr := new Arg_Record'(Name_Find, Display, Simple, null);
if First_Arg = null
or else Path < Get_Name_String (First_Arg.Path)
then
Arg_Ptr.Next := First_Arg;
First_Arg := Arg_Ptr;
else
Current := First_Arg;
while Current.Next /= null
and then Path > Get_Name_String (Current.Next.Path)
loop
Current := Current.Next;
end loop;
Arg_Ptr.Next := Current.Next;
Current.Next := Arg_Ptr;
end if;
end Add;
begin
loop
if Project.Object_Directory /= No_Path_Information then
if Project.Externally_Built then
-- If project is externally built, include all object files
-- in the object directory in the global archive.
declare
Obj_Dir : constant String :=
Get_Name_String
(Project.Object_Directory.Display_Name);
Dir_Obj : Dir_Type;
begin
if Is_Regular_File (Obj_Dir) then
Open (Dir_Obj, Obj_Dir);
loop
Read (Dir_Obj, Name_Buffer, Name_Len);
exit when Name_Len = 0;
Canonical_Case_File_Name
(Name_Buffer (1 .. Name_Len));
if Name_Len > Object_Suffix'Length
and then
Name_Buffer
(Name_Len - Object_Suffix'Length + 1
.. Name_Len) = Object_Suffix
then
Add
(Obj_Dir & Directory_Separator &
Name_Buffer (1 .. Name_Len),
Opt.Verbose_Mode,
Simple => not Opt.Verbose_Mode);
end if;
end loop;
Close (Dir_Obj);
end if;
end;
else
Iter := For_Each_Source (Project_Tree, Project);
loop
Id := GPR.Element (Iter);
exit when Id = No_Source;
if Object_To_Global_Archive (Id) then
-- The source record may not be initialized if
-- gprbuild was called with the switch -l.
Initialize_Source_Record (Id);
Add
(Get_Name_String (Id.Object_Path),
Opt.Verbose_Mode,
Simple => not Opt.Verbose_Mode);
end if;
Next (Iter);
end loop;
end if;
end if;
Project := Project.Extends;
exit when Project = No_Project;
end loop;
-- Add the object files in the arguments in acending order of paths
-- so that the global archive is always built the same way.
while First_Arg /= null loop
Add_Argument
(Get_Name_String (First_Arg.Path),
First_Arg.Display,
First_Arg.Simple);
First_Arg := First_Arg.Next;
end loop;
end Add_Objects;
begin
Exists := False;
Has_Been_Built := False;
OK := True;
-- No need to build the global archive, if it has already been done
if For_Project.Object_Directory /= No_Path_Information then
Global_Archive_Data :=
Global_Archives_Built.Get (Name_Id (For_Project.Path.Name));
if Global_Archive_Data.Checked then
Exists := Global_Archive_Data.Exists;
Has_Been_Built := Global_Archive_Data.Has_Been_Built;
else
Change_To_Object_Directory (For_Project);
-- Put all non Ada sources in the project tree in Source_Indexes
Last_Source := 0;
Add_Sources (For_Project);
Proj_List := For_Project.All_Imported_Projects;
while Proj_List /= null loop
if not Proj_List.Project.Library then
Add_Sources (Proj_List.Project);
end if;
Proj_List := Proj_List.Next;
end loop;
Need_To_Build := Opt.Force_Compilations;
if not Need_To_Build then
if Opt.Verbosity_Level > Opt.Low then
Put (" Checking ");
Put (Archive_Name);
Put_Line (" ...");
end if;
-- If the archive does not exist, of course it needs to be
-- built.
if not Is_Regular_File (Archive_Name) then
Need_To_Build := True;
if Opt.Verbosity_Level > Opt.Low then
Put_Line (" -> archive does not exist");
end if;
else
-- Archive does exist
-- Check the archive dependency file
Open (File, Archive_Dep_Name);
-- If the archive dependency file does not exist, we need to
-- to rebuild the archive and to create its dependency file.
if not Is_Valid (File) then
Need_To_Build := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> archive dependency file ");
Put (Archive_Dep_Name);
Put_Line (" does not exist");
end if;
else
-- Read the dependency file, line by line
while not End_Of_File (File) loop
Get_Line (File, Name_Buffer, Name_Len);
-- First line is the path of the object file
Object_Path := Name_Find;
Src_Id := No_Source;
-- Check if this object file is for a source of this
-- project.
for S in 1 .. Last_Source loop
S_Id := Source_Indexes (S).Id;
if not Source_Indexes (S).Found
and then S_Id.Object_Path = Object_Path
then
-- We have found the object file: get the
-- source data, and mark it as found.
Src_Id := S_Id;
Source_Indexes (S).Found := True;
exit;
end if;
end loop;
-- If it is not for a source of this project, then the
-- archive needs to be rebuilt.
if Src_Id = No_Source then
Need_To_Build := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> ");
Put (Get_Name_String (Object_Path));
Put_Line (" is not an object of any project");
end if;
exit;
end if;
-- The second line is the time stamp of the object
-- file. If there is no next line, then the dependency
-- file is truncated, and the archive need to be
-- rebuilt.
if End_Of_File (File) then
Need_To_Build := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> archive dependency file ");
Put_Line (" is truncated");
end if;
exit;
end if;
Get_Line (File, Name_Buffer, Name_Len);
-- If the line has the wrong number of characters,
-- then the dependency file is incorrectly formatted,
-- and the archive needs to be rebuilt.
if Name_Len /= Time_Stamp_Length then
Need_To_Build := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> archive dependency file ");
Put_Line
(" is incorrectly formatted (time stamp)");
end if;
exit;
end if;
Time_Stamp :=
Time_Stamp_Type (Name_Buffer (1 .. Name_Len));
-- If the time stamp in the dependency file is
-- different from the time stamp of the object file,
-- then the archive needs to be rebuilt. The
-- comparaison is done with String type values,
-- because two values of type Time_Stamp_Type are
-- equal if they differ by 2 seconds or less; here the
-- check is for an exact match.
if String (Time_Stamp) /=
String (Src_Id.Object_TS)
then
Need_To_Build := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> time stamp of ");
Put (Get_Name_String (Object_Path));
Put (" is incorrect in the archive");
Put_Line (" dependency file");
Put (" recorded time stamp: ");
Put_Line (String (Time_Stamp));
Put (" actual time stamp: ");
Put_Line (String (Src_Id.Object_TS));
end if;
exit;
elsif Debug_Flag_T then
Put (" -> time stamp of ");
Put (Get_Name_String (Object_Path));
Put (" is correct in the archive");
Put_Line (" dependency file");
Put (" recorded time stamp: ");
Put_Line (String (Time_Stamp));
Put (" actual time stamp: ");
Put_Line (String (Src_Id.Object_TS));
end if;
end loop;
Close (File);
end if;
end if;
end if;
if not Need_To_Build then
for S in 1 .. Last_Source loop
if not Source_Indexes (S).Found
and then Object_To_Global_Archive (Source_Indexes (S).Id)
then
Need_To_Build := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> object file ");
Put (Get_Name_String
(Source_Indexes (S).Id.Object_Path));
Put_Line (" is not in the dependency file");
end if;
exit;
end if;
end loop;
end if;
if not Need_To_Build then
if Opt.Verbosity_Level > Opt.Low then
Put_Line (" -> up to date");
end if;
Exists := True;
Has_Been_Built := False;
-- Archive needs to be rebuilt
else
Check_Archive_Builder;
-- If archive already exists, first delete it, but if this is
-- not possible, continue: if archive cannot be built, we will
-- fail later on.
if Is_Regular_File (Archive_Name) then
Delete_File (Archive_Name, Discard);
end if;
Last_Argument := 0;
-- Start with the minimal options
Add_Arguments
(Archive_Builder_Opts.Options
(1 .. Archive_Builder_Opts.Last),
True);
-- Followed by the archive name
Add_Argument
(Archive_Name, True, Simple_Name => not Opt.Verbose_Mode);
First_Object := Last_Argument + 1;
-- Followed by all the object files of the non library projects
Add_Objects (For_Project);
Proj_List := For_Project.All_Imported_Projects;
while Proj_List /= null loop
if not Proj_List.Project.Library then
Add_Objects (Proj_List.Project);
end if;
Proj_List := Proj_List.Next;
end loop;
-- No global archive, if there is no object file to put into
if Last_Argument < First_Object then
Has_Been_Built := False;
Exists := False;
if Opt.Verbosity_Level > Opt.Low
then
Put_Line (" -> there is no global archive");
end if;
else
Real_Last_Argument := Last_Argument;
-- If there is an Archive_Builder_Append_Option, we may have
-- to build the archive in chuck.
if Archive_Builder_Append_Opts.Last = 0 then
Current_Object_Pos := Real_Last_Argument + 1;
else
Size := 0;
for J in 1 .. First_Object - 1 loop
Size := Size + Arguments (J)'Length + 1;
end loop;
Current_Object_Pos := First_Object;
while Current_Object_Pos <= Real_Last_Argument loop
Size :=
Size + Arguments (Current_Object_Pos)'Length + 1;
exit when Size > Maximum_Size;
Current_Object_Pos := Current_Object_Pos + 1;
end loop;
Last_Argument := Current_Object_Pos - 1;
end if;
if not Opt.Quiet_Output then
if Opt.Verbose_Mode then
Display_Command
(Archive_Builder_Path,
Ellipse => True);
else
Display
(Section => GPR.Link,
Command => "archive",
Argument => Archive_Name);
end if;
end if;
Spawn_And_Script_Write
(Archive_Builder_Path.all,
Arguments (1 .. Last_Argument),
Success);
-- If the archive has not been built completely, add the
-- remaining chunks.
if Success
and then Current_Object_Pos <= Real_Last_Argument
then
Last_Argument := 0;
Add_Arguments
(Archive_Builder_Append_Opts.Options
(1 .. Archive_Builder_Append_Opts.Last),
True);
Add_Argument
(Archive_Name, True,
Simple_Name => not Opt.Verbose_Mode);
First_Object := Last_Argument + 1;
while Current_Object_Pos <= Real_Last_Argument loop
Size := 0;
for J in 1 .. First_Object - 1 loop
Size := Size + Arguments (J)'Length + 1;
end loop;
Last_Argument := First_Object - 1;
while Current_Object_Pos <= Real_Last_Argument loop
Size :=
Size + Arguments (Current_Object_Pos)'Length + 1;
exit when Size > Maximum_Size;
Last_Argument := Last_Argument + 1;
Arguments (Last_Argument) :=
Arguments (Current_Object_Pos);
Current_Object_Pos := Current_Object_Pos + 1;
end loop;
if Opt.Verbose_Mode then
Display_Command
(Archive_Builder_Path,
Ellipse => True);
end if;
Spawn_And_Script_Write
(Archive_Builder_Path.all,
Arguments (1 .. Last_Argument),
Success);
exit when not Success;
end loop;
end if;
-- If the archive was built, run the archive indexer
-- (ranlib) if there is one.
if Success then
-- If the archive was built, run the archive indexer
-- (ranlib), if there is one.
if Archive_Indexer_Path /= null then
Last_Argument := 0;
Add_Arguments
(Archive_Indexer_Opts.Options
(1 .. Archive_Indexer_Opts.Last),
True);
Add_Argument
(Archive_Name,
True,
Simple_Name => not Opt.Verbose_Mode);
if not Opt.Quiet_Output then
if Opt.Verbose_Mode then
Display_Command
(Archive_Indexer_Path);
else
Display
(Section => GPR.Link,
Command => "index",
Argument => Archive_Name);
end if;
end if;
Spawn_And_Script_Write
(Archive_Indexer_Path.all,
Arguments (1 .. Last_Argument),
Success);
if not Success then
-- Running the archive indexer failed, delete the
-- dependency file, if it exists.
if Is_Regular_File (Archive_Dep_Name) then
Delete_File (Archive_Dep_Name, Success);
end if;
end if;
end if;
end if;
if Success then
-- The archive was correctly built, create its dependency
-- file.
declare
Dep_File : Text_IO.File_Type;
begin
-- Create the file in Append mode, to avoid automatic
-- insertion of an end of line if file is empty.
Create (Dep_File, Append_File, Archive_Dep_Name);
for S in 1 .. Last_Source loop
Src_Id := Source_Indexes (S).Id;
if Object_To_Global_Archive (Src_Id) then
Put_Line
(Dep_File,
Get_Name_String (Src_Id.Object_Path));
Put_Line (Dep_File, String (Src_Id.Object_TS));
end if;
end loop;
Close (Dep_File);
exception
when others =>
if Is_Open (Dep_File) then
Close (Dep_File);
end if;
end;
Has_Been_Built := True;
Exists := True;
else
-- Building the archive failed, delete dependency file if
-- one exists.
if Is_Regular_File (Archive_Dep_Name) then
Delete_File (Archive_Dep_Name, Success);
end if;
Put ("global archive for project ");
Put
(Get_Name_String (For_Project.Display_Name));
Put_Line (" could not be built");
OK := False;
return;
end if;
end if;
end if;
Global_Archives_Built.Set
(Name_Id (For_Project.Path.Name),
(Checked => True,
Has_Been_Built => Has_Been_Built,
Exists => Exists));
end if;
end if;
end Build_Global_Archive;
---------------------
-- Display_Command --
---------------------
procedure Display_Command
(Path : String_Access;
Ellipse : Boolean := False)
is
Display_Ellipse : Boolean := Ellipse;
begin
-- Only display the command in Verbose Mode (-v) or when
-- not in Quiet Output (no -q).
if not Opt.Quiet_Output then
Name_Len := 0;
if Opt.Verbose_Mode then
if Opt.Verbosity_Level = Opt.Low then
Add_Str_To_Name_Buffer
(Ada.Directories.Base_Name (Path.all));
else
Add_Str_To_Name_Buffer (Path.all);
end if;
for Arg in 1 .. Last_Argument loop
if Arguments_Displayed (Arg) then
Add_Str_To_Name_Buffer (" ");
if Arguments_Simple_Name (Arg) then
Add_Str_To_Name_Buffer (Base_Name (Arguments (Arg).all));
else
Add_Str_To_Name_Buffer (Arguments (Arg).all);
end if;
elsif Display_Ellipse then
Add_Str_To_Name_Buffer (" ...");
Display_Ellipse := False;
end if;
end loop;
Put_Line (Name_Buffer (1 .. Name_Len));
end if;
end if;
end Display_Command;
------------------------
-- Get_Linker_Options --
------------------------
procedure Get_Linker_Options (For_Project : Project_Id) is
Linker_Lib_Dir_Option : String_Access;
procedure Recursive_Add
(Proj : Project_Id;
Tree : Project_Tree_Ref;
Dummy : in out Boolean);
-- The recursive routine used to add linker options
-------------------
-- Recursive_Add --
-------------------
procedure Recursive_Add
(Proj : Project_Id;
Tree : Project_Tree_Ref;
Dummy : in out Boolean)
is
pragma Unreferenced (Dummy);
Linker_Package : Package_Id;
Options : Variable_Value;
begin
if Proj /= For_Project then
Linker_Package :=
GPR.Util.Value_Of
(Name => Name_Linker,
In_Packages => Proj.Decl.Packages,
Shared => Tree.Shared);
Options :=
GPR.Util.Value_Of
(Name => Name_Ada,
Index => 0,
Attribute_Or_Array_Name => Name_Linker_Options,
In_Package => Linker_Package,
Shared => Tree.Shared);
-- If attribute is present, add the project with
-- the attribute to table Linker_Opts.
if Options /= Nil_Variable_Value then
Linker_Opts.Increment_Last;
Linker_Opts.Table (Linker_Opts.Last) :=
(Project => Proj, Options => Options.Values);
end if;
end if;
end Recursive_Add;
procedure For_All_Projects is
new For_Every_Project_Imported (Boolean, Recursive_Add);
Dummy : Boolean := False;
-- Start of processing for Get_Linker_Options
begin
if For_Project.Config.Linker_Lib_Dir_Option = No_Name then
Linker_Lib_Dir_Option := new String'("-L");
else
Linker_Lib_Dir_Option :=
new String'
(Get_Name_String (For_Project.Config.Linker_Lib_Dir_Option));
end if;
Linker_Opts.Init;
For_All_Projects
(For_Project, Project_Tree, Dummy, Imported_First => True);
for Index in reverse 1 .. Linker_Opts.Last loop
declare
Options : String_List_Id := Linker_Opts.Table (Index).Options;
Proj : constant Project_Id :=
Linker_Opts.Table (Index).Project;
Option : Name_Id;
Dir_Path : constant String :=
Get_Name_String (Proj.Directory.Display_Name);
begin
while Options /= Nil_String loop
Option :=
Project_Tree.Shared.String_Elements.Table (Options).Value;
Get_Name_String (Option);
-- Do not consider empty linker options
if Name_Len /= 0 then
-- Object files and -L switches specified with relative
-- paths must be converted to absolute paths.
if Name_Len > Linker_Lib_Dir_Option'Length
and then
Name_Buffer (1 .. Linker_Lib_Dir_Option'Length) =
Linker_Lib_Dir_Option.all
then
if Is_Absolute_Path
(Name_Buffer
(Linker_Lib_Dir_Option'Length + 1 .. Name_Len))
then
Add_Argument (Name_Buffer (1 .. Name_Len), True);
else
declare
Dir : constant String :=
Dir_Path &
Directory_Separator &
Name_Buffer
(Linker_Lib_Dir_Option'Length + 1 .. Name_Len);
begin
if Is_Directory (Dir) then
Add_Argument
(Linker_Lib_Dir_Option.all & Dir, True);
else
Add_Argument
(Name_Buffer (1 .. Name_Len), True);
end if;
end;
end if;
elsif Name_Buffer (1) = '-' or else
Is_Absolute_Path (Name_Buffer (1 .. Name_Len))
then
Add_Argument (Name_Buffer (1 .. Name_Len), True);
else
declare
File : constant String :=
Dir_Path &
Directory_Separator &
Name_Buffer (1 .. Name_Len);
begin
if Is_Regular_File (File) then
Add_Argument
(File, True, Simple_Name => True);
else
Add_Argument (Name_Buffer (1 .. Name_Len), True);
end if;
end;
end if;
end if;
Options :=
Project_Tree.Shared.String_Elements.Table (Options).Next;
end loop;
end;
end loop;
end Get_Linker_Options;
---------------------------
-- Is_In_Library_Project --
---------------------------
function Is_In_Library_Project (Object_Path : String) return Boolean is
Path_Id : constant Path_Name_Type := Create_Name (Object_Path);
Src : Source_Id;
Iter : Source_Iterator;
begin
Iter := For_Each_Source (Project_Tree);
loop
Src := GPR.Element (Iter);
exit when Src = No_Source;
if Src.Object_Path = Path_Id then
return Src.Project.Library;
end if;
Next (Iter);
end loop;
return False;
end Is_In_Library_Project;
------------------------
-- Rpaths_Relative_To --
------------------------
procedure Rpaths_Relative_To
(Exec_Dir : Path_Name_Type;
Origin : Name_Id)
is
Exec : String :=
Normalize_Pathname
(Get_Name_String (Exec_Dir),
Case_Sensitive => False);
Last_Exec : Positive;
Curr_Exec : Positive;
Last_Path : Positive;
Curr_Path : Positive;
Nmb : Natural;
Origin_Name : constant String := Get_Name_String (Origin);
begin
-- Replace all directory separators with '/' to ease search
if Directory_Separator /= '/' then
for J in Exec'Range loop
if Exec (J) = Directory_Separator then
Exec (J) := '/';
end if;
end loop;
end if;
for Npath in 1 .. Rpaths.Last loop
declare
Insensitive_Path : String :=
Normalize_Pathname
(Rpaths.Table (Npath).all,
Case_Sensitive => False);
Path : constant String :=
Normalize_Pathname (Rpaths.Table (Npath).all);
begin
-- Replace all directory separators with '/' to ease search
if Directory_Separator /= '/' then
for J in Insensitive_Path'Range loop
if Insensitive_Path (J) = Directory_Separator then
Insensitive_Path (J) := '/';
end if;
end loop;
end if;
-- Find the number of common directories between the path and the
-- exec directory.
Nmb := 0;
Curr_Path := Insensitive_Path'First;
Curr_Exec := Exec'First;
loop
exit when
Curr_Path > Insensitive_Path'Last
or else Curr_Exec > Exec'Last
or else Insensitive_Path (Curr_Path) /= Exec (Curr_Exec);
if Insensitive_Path (Curr_Path) = '/' then
Nmb := Nmb + 1;
Last_Path := Curr_Path;
Last_Exec := Curr_Exec;
elsif Curr_Exec = Exec'Last
and then Curr_Path > Insensitive_Path'Last
then
Nmb := Nmb + 1;
Last_Path := Curr_Path + 1;
Last_Exec := Curr_Exec + 1;
exit;
end if;
Curr_Path := Curr_Path + 1;
Curr_Exec := Curr_Exec + 1;
end loop;
-- If there is more than one common directories (the root
-- directory does not count), then change the absolute path to a
-- relative path.
if Nmb > 1 then
Nmb := 0;
for J in Last_Exec .. Exec'Last - 1 loop
if Exec (J) = '/' then
Nmb := Nmb + 1;
end if;
end loop;
if Nmb = 0 then
if Last_Path >= Path'Last then
-- Case of the path being the exec dir
Rpaths.Table (Npath) :=
new String'(Origin_Name & Directory_Separator & ".");
else
-- Case of the path being a subdir of the exec dir
Rpaths.Table (Npath) :=
new String'
(Origin_Name & Directory_Separator &
Path (Last_Path + 1 .. Path'Last));
end if;
else
if Last_Path >= Path'Last then
-- Case of the exec dir being a subdir of the path
Rpaths.Table (Npath) :=
new String'
(Origin_Name & Directory_Separator &
(Nmb - 1) * (".." & Directory_Separator) & "..");
else
-- General case of path and exec dir having a common root
Rpaths.Table (Npath) :=
new String'
(Origin_Name & Directory_Separator &
Nmb * (".." & Directory_Separator) &
Path (Last_Path + 1 .. Path'Last));
end if;
end if;
end if;
end;
end loop;
end Rpaths_Relative_To;
---------------
-- Link_Main --
---------------
procedure Link_Main (Main_File : Main_Info) is
function Global_Archive_Name (For_Project : Project_Id) return String;
-- Returns the name of the global archive for a project
Linker_Name : String_Access := null;
Linker_Path : String_Access;
Min_Linker_Opts : Name_List_Index;
Exchange_File : Text_IO.File_Type;
Line : String (1 .. 1_000);
Last : Natural;
-- Success : Boolean := False;
Section : Binding_Section := No_Binding_Section;
Linker_Needs_To_Be_Called : Boolean;
Executable_TS : Time_Stamp_Type;
Main_Object_TS : Time_Stamp_Type;
Binder_Exchange_TS : Time_Stamp_Type;
Binder_Object_TS : Time_Stamp_Type := Dummy_Time_Stamp;
Global_Archive_TS : Time_Stamp_Type;
Global_Archive_Has_Been_Built : Boolean;
Global_Archive_Exists : Boolean;
OK : Boolean;
Disregard : Boolean;
B_Data : Binding_Data;
-- Main already has the right canonical casing
Main : constant String := Get_Name_String (Main_File.File);
Main_Source : constant Source_Id := Main_File.Source;
Main_Id : File_Name_Type;
Exec_Name : File_Name_Type;
Exec_Path_Name : Path_Name_Type;
Main_Proj : Project_Id;
Main_Base_Name_Index : File_Name_Type;
First_Object_Index : Natural := 0;
Last_Object_Index : Natural := 0;
Index_Separator : Character;
Response_File_Name : Path_Name_Type := No_Path;
Response_2 : Path_Name_Type := No_Path;
-------------------------
-- Global_Archive_Name --
-------------------------
function Global_Archive_Name (For_Project : Project_Id) return String is
begin
return
"lib" &
Get_Name_String (For_Project.Name) &
Archive_Suffix (For_Project);
end Global_Archive_Name;
begin
-- Make sure that the table Rpaths is emptied after each main, so
-- that the same rpaths are not duplicated.
Rpaths.Set_Last (0);
Linker_Needs_To_Be_Called := Opt.Force_Compilations;
Main_Id := Create_Name (Base_Name (Main));
Main_Proj := Ultimate_Extending_Project_Of (Main_Source.Project);
Change_To_Object_Directory (Main_Proj);
-- Build the global archive for this project, if needed
Build_Global_Archive
(Main_Proj,
Main_File.Tree,
Global_Archive_Has_Been_Built,
Global_Archive_Exists,
OK);
if not OK then
Stop_Spawning := True;
Bad_Processes.Append (Main_File);
return;
end if;
-- Get the main base name
Index_Separator :=
Main_Source.Language.Config.Multi_Unit_Object_Separator;
Main_Base_Name_Index :=
Base_Name_Index_For (Main, Main_File.Index, Index_Separator);
if not Linker_Needs_To_Be_Called and then
Opt.Verbosity_Level > Opt.Low
then
Put (" Checking executable for ");
Put (Get_Name_String (Main_Source.File));
Put_Line (" ...");
end if;
if Output_File_Name /= null then
Name_Len := 0;
Add_Str_To_Name_Buffer (Output_File_Name.all);
-- If an executable name was specified without an extension and
-- there is a non empty executable suffix, add the suffix to the
-- executable name.
if Main_Proj.Config.Executable_Suffix /= No_Name
and then Length_Of_Name (Main_Proj.Config.Executable_Suffix) > 0
then
declare
Suffix : String := Get_Name_String
(Main_Proj.Config.Executable_Suffix);
File_Name : String := Output_File_Name.all;
begin
if Index (File_Name, ".") = 0 then
Canonical_Case_File_Name (Suffix);
Canonical_Case_File_Name (File_Name);
if Name_Len <= Suffix'Length
or else File_Name
(File_Name'Last - Suffix'Length + 1 .. File_Name'Last)
/= Suffix
then
Add_Str_To_Name_Buffer (Suffix);
end if;
end if;
end;
end if;
Exec_Name := Name_Find;
else
Exec_Name := Executable_Of
(Project => Main_Proj,
Shared => Main_File.Tree.Shared,
Main => Main_Id,
Index => Main_Source.Index,
Language => Get_Name_String (Main_Source.Language.Name));
end if;
if Main_Proj.Exec_Directory = Main_Proj.Object_Directory
or else Is_Absolute_Path (Get_Name_String (Exec_Name))
then
Exec_Path_Name := Path_Name_Type (Exec_Name);
else
Get_Name_String (Main_Proj.Exec_Directory.Display_Name);
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Directory_Separator;
Add_Str_To_Name_Buffer (Get_Name_String (Exec_Name));
Exec_Path_Name := Name_Find;
end if;
Executable_TS := File_Stamp (Exec_Path_Name);
if not Linker_Needs_To_Be_Called
and then Executable_TS = Empty_Time_Stamp
then
Linker_Needs_To_Be_Called := True;
if Opt.Verbosity_Level > Opt.Low then
Put_Line (" -> executable does not exist");
end if;
end if;
-- Get the path of the linker driver
if Main_Proj.Config.Linker /= No_Path then
Linker_Name := new String'(Get_Name_String (Main_Proj.Config.Linker));
Linker_Path := Locate_Exec_On_Path (Linker_Name.all);
if Linker_Path = null then
Fail_Program
(Main_File.Tree,
"unable to find linker " & Linker_Name.all);
end if;
else
Fail_Program
(Main_File.Tree,
"no linker specified and " &
"no default linker in the configuration");
end if;
Last_Argument := 0;
Initialize_Source_Record (Main_Source);
Main_Object_TS := File_Stamp (File_Name_Type (Main_Source.Object_Path));
if not Linker_Needs_To_Be_Called then
if Main_Object_TS = Empty_Time_Stamp then
if Opt.Verbosity_Level > Opt.Low then
Put_Line (" -> main object does not exist");
end if;
Linker_Needs_To_Be_Called := True;
elsif String (Main_Object_TS) > String (Executable_TS) then
if Opt.Verbosity_Level > Opt.Low then
Put_Line
(" -> main object more recent than executable");
end if;
Linker_Needs_To_Be_Called := True;
end if;
end if;
if Main_Object_TS = Empty_Time_Stamp then
Put ("main object for ");
Put (Get_Name_String (Main_Source.File));
Put_Line (" does not exist");
Record_Failure (Main_File);
return;
end if;
if Main_Proj = Main_Source.Object_Project then
Add_Argument (Get_Name_String (Main_Source.Object), True);
else
Add_Argument (Get_Name_String (Main_Source.Object_Path), True);
end if;
-- Add the Leading_Switches if there are any in package Linker
declare
The_Packages : constant Package_Id :=
Main_Proj.Decl.Packages;
Linker_Package : constant GPR.Package_Id :=
GPR.Util.Value_Of
(Name => Name_Linker,
In_Packages => The_Packages,
Shared => Main_File.Tree.Shared);
Switches : Variable_Value;
Switch_List : String_List_Id;
Element : String_Element;
begin
if Linker_Package /= No_Package then
declare
Switches_Array : constant Array_Element_Id :=
GPR.Util.Value_Of
(Name => Name_Leading_Switches,
In_Arrays =>
Main_File.Tree.Shared.Packages.Table
(Linker_Package).Decl.Arrays,
Shared => Main_File.Tree.Shared);
Option : String_Access;
begin
Switches :=
GPR.Util.Value_Of
(Index => Name_Id (Main_Id),
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared);
if Switches = Nil_Variable_Value then
Switches :=
GPR.Util.Value_Of
(Index =>
Main_Source.Language.Name,
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared,
Force_Lower_Case_Index => True);
end if;
if Switches = Nil_Variable_Value then
Switches :=
GPR.Util.Value_Of
(Index => All_Other_Names,
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared,
Force_Lower_Case_Index => True);
end if;
case Switches.Kind is
when Undefined | Single =>
null;
when GPR.List =>
Switch_List := Switches.Values;
while Switch_List /= Nil_String loop
Element :=
Main_File.Tree.Shared.String_Elements.Table
(Switch_List);
Get_Name_String (Element.Value);
if Name_Len > 0 then
Option :=
new String'(Name_Buffer (1 .. Name_Len));
Add_Argument (Option.all, True);
end if;
Switch_List := Element.Next;
end loop;
end case;
end;
end if;
end;
Find_Binding_Languages (Main_File.Tree, Main_File.Project);
if Builder_Data (Main_File.Tree).There_Are_Binder_Drivers then
First_Object_Index := Last_Argument + 1;
Binding_Options.Init;
B_Data := Builder_Data (Main_File.Tree).Binding;
Binding_Loop :
while B_Data /= null loop
declare
Exchange_File_Name : constant String :=
Binder_Exchange_File_Name
(Main_Base_Name_Index,
B_Data.Binder_Prefix).all;
Binding_Not_Necessary : Boolean;
begin
if Is_Regular_File (Exchange_File_Name) then
Binder_Exchange_TS :=
File_Stamp
(Path_Name_Type'(Create_Name
(Exchange_File_Name)));
Open (Exchange_File, In_File, Exchange_File_Name);
Get_Line (Exchange_File, Line, Last);
Binding_Not_Necessary :=
Line (1 .. Last) = Binding_Label (Nothing_To_Bind);
Close (Exchange_File);
if Binding_Not_Necessary then
goto No_Binding;
end if;
if not Linker_Needs_To_Be_Called
and then
String (Binder_Exchange_TS) > String (Executable_TS)
then
Linker_Needs_To_Be_Called := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> binder exchange file """);
Put (Exchange_File_Name);
Put_Line (""" is more recent than executable");
end if;
end if;
Open (Exchange_File, In_File, Exchange_File_Name);
while not End_Of_File (Exchange_File) loop
Get_Line (Exchange_File, Line, Last);
if Last > 0 then
if Line (1) = '[' then
Section :=
Get_Binding_Section (Line (1 .. Last));
else
case Section is
when Generated_Object_File =>
Binder_Object_TS :=
File_Stamp
(Path_Name_Type'
(Create_Name
(Line (1 .. Last))));
Add_Argument
(Line (1 .. Last), Opt.Verbose_Mode);
when Bound_Object_Files =>
if Normalize_Pathname
(Line (1 .. Last),
Case_Sensitive => False) /=
Normalize_Pathname
(Get_Name_String
(Main_Source.Object_Path),
Case_Sensitive => False)
and then
not Is_In_Library_Project
(Line (1 .. Last))
then
Add_Argument
(Line (1 .. Last), Opt.Verbose_Mode);
end if;
when Resulting_Options =>
if Line (1 .. Last) /= "-static"
and then Line (1 .. Last) /= "-shared"
then
Binding_Options.Append
(new String'(Line (1 .. Last)));
end if;
when Gprexch.Run_Path_Option =>
if Opt.Run_Path_Option
and then
Main_Proj.Config.Run_Path_Option /=
No_Name_List
then
Add_Rpath (Line (1 .. Last));
Add_Rpath
(Shared_Libgcc_Dir
(Line (1 .. Last)));
end if;
when others =>
null;
end case;
end if;
end if;
end loop;
Close (Exchange_File);
if Binder_Object_TS = Empty_Time_Stamp then
if not Linker_Needs_To_Be_Called
and then Opt.Verbosity_Level > Opt.Low
then
Put_Line
(" -> no binder generated object file");
end if;
Put ("no binder generated object file for ");
Put_Line (Get_Name_String (Main_File.File));
Record_Failure (Main_File);
return;
elsif not Linker_Needs_To_Be_Called
and then
String (Binder_Object_TS) > String (Executable_TS)
then
Linker_Needs_To_Be_Called := True;
if Opt.Verbosity_Level > Opt.Low then
Put_Line
(" -> binder generated object is more " &
"recent than executable");
end if;
end if;
else
Put ("binder exchange file ");
Put (Exchange_File_Name);
Put_Line (" does not exist");
Record_Failure (Main_File);
return;
end if;
end;
<<No_Binding>>
B_Data := B_Data.Next;
end loop Binding_Loop;
Last_Object_Index := Last_Argument;
end if;
-- Add the global archive, if there is one
if Global_Archive_Exists then
Global_Archive_TS :=
File_Stamp
(Path_Name_Type'
(Create_Name (Global_Archive_Name (Main_Proj))));
if Global_Archive_TS = Empty_Time_Stamp then
if not Linker_Needs_To_Be_Called
and then Opt.Verbosity_Level > Opt.Low
then
Put_Line (" -> global archive does not exist");
end if;
Put ("global archive for project file ");
Put (Get_Name_String (Main_Proj.Name));
Put_Line (" does not exist");
end if;
end if;
if not Linker_Needs_To_Be_Called
and then Global_Archive_Has_Been_Built
then
Linker_Needs_To_Be_Called := True;
if Opt.Verbosity_Level > Opt.Low then
Put_Line (" -> global archive has just been built");
end if;
end if;
if not Linker_Needs_To_Be_Called
and then Global_Archive_Exists
and then String (Global_Archive_TS) > String (Executable_TS)
then
Linker_Needs_To_Be_Called := True;
if Opt.Verbosity_Level > Opt.Low then
Put_Line (" -> global archive is more recent than " &
"executable");
end if;
end if;
-- Check if there are library files that are more recent than
-- executable.
declare
List : Project_List := Main_Proj.All_Imported_Projects;
Proj : Project_Id;
Current_Dir : constant String := Get_Current_Dir;
begin
while List /= null loop
Proj := List.Project;
List := List.Next;
if Proj.Extended_By = No_Project
and then Proj.Library
and then Proj.Object_Directory /= No_Path_Information
and then (Is_Static (Proj)
or else Proj.Standalone_Library = No)
then
-- Put the full path name of the library file in Name_Buffer
Get_Name_String (Proj.Library_Dir.Display_Name);
if Is_Static (Proj) then
Add_Str_To_Name_Buffer ("lib");
Add_Str_To_Name_Buffer (Get_Name_String (Proj.Library_Name));
if Proj.Config.Archive_Suffix = No_File then
Add_Str_To_Name_Buffer (".a");
else
Add_Str_To_Name_Buffer
(Get_Name_String (Proj.Config.Archive_Suffix));
end if;
else
-- Shared libraries
if Proj.Config.Shared_Lib_Prefix = No_File then
Add_Str_To_Name_Buffer ("lib");
else
Add_Str_To_Name_Buffer
(Get_Name_String (Proj.Config.Shared_Lib_Prefix));
end if;
Add_Str_To_Name_Buffer (Get_Name_String (Proj.Library_Name));
if Proj.Config.Shared_Lib_Suffix = No_File then
Add_Str_To_Name_Buffer (".so");
else
Add_Str_To_Name_Buffer
(Get_Name_String (Proj.Config.Shared_Lib_Suffix));
end if;
end if;
-- Check that library file exists and that it is not more
-- recent than the executable.
declare
Lib_TS : constant Time_Stamp_Type :=
File_Stamp (File_Name_Type'(Name_Find));
begin
if Lib_TS = Empty_Time_Stamp then
Linker_Needs_To_Be_Called := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> library file """);
Put (Name_Buffer (1 .. Name_Len));
Put_Line (""" not found");
end if;
exit;
elsif String (Lib_TS) > String (Executable_TS) then
Linker_Needs_To_Be_Called := True;
if Opt.Verbosity_Level > Opt.Low then
Put (" -> library file """);
Put (Name_Buffer (1 .. Name_Len));
Put_Line
(""" is more recent than executable");
end if;
exit;
end if;
end;
end if;
end loop;
Change_Dir (Current_Dir);
end;
if not Linker_Needs_To_Be_Called then
if Opt.Verbosity_Level > Opt.Low then
Put_Line (" -> up to date");
elsif not Opt.Quiet_Output then
Inform (Exec_Name, "up to date");
end if;
else
if Global_Archive_Exists then
Add_Argument (Global_Archive_Name (Main_Proj), Opt.Verbose_Mode);
end if;
-- Add the library switches, if there are libraries
Process_Imported_Libraries (Main_Proj, There_Are_SALs => Disregard);
Library_Dirs.Reset;
for J in reverse 1 .. Library_Projs.Last loop
if not Library_Projs.Table (J).Is_Aggregated then
if Is_Static (Library_Projs.Table (J).Proj) then
Add_Argument
(Get_Name_String
(Library_Projs.Table (J).Proj.Library_Dir.Display_Name)
& "lib"
& Get_Name_String
(Library_Projs.Table (J).Proj.Library_Name)
& Archive_Suffix (Library_Projs.Table (J).Proj),
Opt.Verbose_Mode);
else
-- Do not issue several time the same -L switch if
-- several library projects share the same library
-- directory.
if not Library_Dirs.Get
(Library_Projs.Table (J).Proj.Library_Dir.Name)
then
Library_Dirs.Set
(Library_Projs.Table (J).Proj.Library_Dir.Name, True);
if Main_Proj.Config.Linker_Lib_Dir_Option = No_Name then
Add_Argument
("-L" &
Get_Name_String
(Library_Projs.Table (J).
Proj.Library_Dir.Display_Name),
Opt.Verbose_Mode);
else
Add_Argument
(Get_Name_String
(Main_Proj.Config.Linker_Lib_Dir_Option) &
Get_Name_String
(Library_Projs.Table (J).
Proj.Library_Dir.Display_Name),
Opt.Verbose_Mode);
end if;
if Opt.Run_Path_Option
and then
Main_Proj.Config.Run_Path_Option /= No_Name_List
then
Add_Rpath
(Get_Name_String
(Library_Projs.Table
(J).Proj.Library_Dir.Display_Name));
end if;
end if;
if Main_Proj.Config.Linker_Lib_Name_Option = No_Name then
Add_Argument
("-l" &
Get_Name_String
(Library_Projs.Table (J).Proj.Library_Name),
Opt.Verbose_Mode);
else
Add_Argument
(Get_Name_String
(Main_Proj.Config.Linker_Lib_Name_Option) &
Get_Name_String
(Library_Projs.Table (J).Proj.Library_Name),
Opt.Verbose_Mode);
end if;
end if;
end if;
end loop;
-- Put the options in the project file, if any
declare
The_Packages : constant Package_Id :=
Main_Proj.Decl.Packages;
Linker_Package : constant GPR.Package_Id :=
GPR.Util.Value_Of
(Name => Name_Linker,
In_Packages => The_Packages,
Shared => Main_File.Tree.Shared);
Switches : Variable_Value;
Switch_List : String_List_Id;
Element : String_Element;
begin
if Linker_Package /= No_Package then
declare
Defaults : constant Array_Element_Id :=
GPR.Util.Value_Of
(Name => Name_Default_Switches,
In_Arrays =>
Main_File.Tree.Shared.Packages.Table
(Linker_Package).Decl.Arrays,
Shared => Main_File.Tree.Shared);
Switches_Array : constant Array_Element_Id :=
GPR.Util.Value_Of
(Name => Name_Switches,
In_Arrays =>
Main_File.Tree.Shared.Packages.Table
(Linker_Package).Decl.Arrays,
Shared => Main_File.Tree.Shared);
Option : String_Access;
begin
Switches :=
GPR.Util.Value_Of
(Index => Name_Id (Main_Id),
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared,
Allow_Wildcards => True);
if Switches = Nil_Variable_Value then
Switches :=
GPR.Util.Value_Of
(Index =>
Main_Source.Language.Name,
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared,
Force_Lower_Case_Index => True);
end if;
if Switches = Nil_Variable_Value then
Switches :=
GPR.Util.Value_Of
(Index => All_Other_Names,
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared,
Force_Lower_Case_Index => True);
end if;
if Switches = Nil_Variable_Value then
Switches :=
GPR.Util.Value_Of
(Index =>
Main_Source.Language.Name,
Src_Index => 0,
In_Array => Defaults,
Shared => Main_File.Tree.Shared);
end if;
case Switches.Kind is
when Undefined | Single =>
null;
when GPR.List =>
Switch_List := Switches.Values;
while Switch_List /= Nil_String loop
Element :=
Main_File.Tree.Shared.String_Elements.Table
(Switch_List);
Get_Name_String (Element.Value);
if Name_Len > 0 then
Option :=
new String'(Name_Buffer (1 .. Name_Len));
Test_If_Relative_Path
(Option,
Get_Name_String (Main_Proj.Directory.Name),
Dash_L);
Add_Argument (Option.all, True);
end if;
Switch_List := Element.Next;
end loop;
end case;
end;
end if;
end;
-- Get the Linker_Options, if any
Get_Linker_Options (For_Project => Main_Proj);
-- Add the linker switches specified on the command line
for J in 1 .. Command_Line_Linker_Options.Last loop
Add_Argument
(Command_Line_Linker_Options.Table (J), Opt.Verbose_Mode);
end loop;
-- Then the binding options
for J in 1 .. Binding_Options.Last loop
Add_Argument (Binding_Options.Table (J), Opt.Verbose_Mode);
end loop;
-- Then the required switches, if any. These are put here because,
-- if they include -L switches for example, the link may fail because
-- the wrong objects or libraries are linked in.
Min_Linker_Opts :=
Main_Proj.Config.Trailing_Linker_Required_Switches;
while Min_Linker_Opts /= No_Name_List loop
Add_Argument
(Get_Name_String
(Main_File.Tree.Shared.Name_Lists.Table
(Min_Linker_Opts).Name),
Opt.Verbose_Mode);
Min_Linker_Opts := Main_File.Tree.Shared.Name_Lists.Table
(Min_Linker_Opts).Next;
end loop;
-- Finally the Trailing_Switches if there are any in package Linker.
-- They are put here so that it is possible to override the required
-- switches from the configuration project file.
declare
The_Packages : constant Package_Id :=
Main_Proj.Decl.Packages;
Linker_Package : constant GPR.Package_Id :=
GPR.Util.Value_Of
(Name => Name_Linker,
In_Packages => The_Packages,
Shared => Main_File.Tree.Shared);
Switches : Variable_Value;
Switch_List : String_List_Id;
Element : String_Element;
begin
if Linker_Package /= No_Package then
declare
Switches_Array : constant Array_Element_Id :=
GPR.Util.Value_Of
(Name => Name_Trailing_Switches,
In_Arrays =>
Main_File.Tree.Shared.Packages.Table
(Linker_Package).Decl.Arrays,
Shared => Main_File.Tree.Shared);
Option : String_Access;
begin
Switches :=
GPR.Util.Value_Of
(Index => Name_Id (Main_Id),
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared);
if Switches = Nil_Variable_Value then
Switches :=
GPR.Util.Value_Of
(Index =>
Main_Source.Language.Name,
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared,
Force_Lower_Case_Index => True);
end if;
if Switches = Nil_Variable_Value then
Switches :=
GPR.Util.Value_Of
(Index => All_Other_Names,
Src_Index => 0,
In_Array => Switches_Array,
Shared => Main_File.Tree.Shared,
Force_Lower_Case_Index => True);
end if;
case Switches.Kind is
when Undefined | Single =>
null;
when GPR.List =>
Switch_List := Switches.Values;
while Switch_List /= Nil_String loop
Element :=
Main_File.Tree.Shared.String_Elements.Table
(Switch_List);
Get_Name_String (Element.Value);
if Name_Len > 0 then
Option :=
new String'(Name_Buffer (1 .. Name_Len));
Add_Argument (Option.all, True);
end if;
Switch_List := Element.Next;
end loop;
end case;
end;
end if;
end;
-- Remove duplicate stack size setting coming from pragmas
-- Linker_Options or Link_With and linker switches ("-Xlinker
-- --stack=R,C" or "-Wl,--stack=R"). Only the first stack size
-- setting option should be taken into account, because the one in
-- the project file or on the command line will always be the first
-- one. And any subsequent stack setting option will overwrite the
-- previous one.
-- Also, if Opt.Maximum_Processes is greater than one, check for
-- switches --lto or -flto and add =nn to the switch.
Clean_Link_Option_Set : declare
J : Natural := Last_Object_Index + 1;
Stack_Op : Boolean := False;
begin
while J <= Last_Argument loop
-- Check for two switches "-Xlinker" followed by "--stack=..."
if Arguments (J).all = "-Xlinker"
and then J < Last_Argument
and then Arguments (J + 1)'Length > 8
and then Arguments (J + 1) (1 .. 8) = "--stack="
then
if Stack_Op then
Arguments (J .. Last_Argument - 2) :=
Arguments (J + 2 .. Last_Argument);
Last_Argument := Last_Argument - 2;
else
Stack_Op := True;
end if;
end if;
-- Check for single switch
if (Arguments (J)'Length > 17
and then Arguments (J) (1 .. 17) = "-Xlinker --stack=")
or else
(Arguments (J)'Length > 12
and then Arguments (J) (1 .. 12) = "-Wl,--stack=")
then
if Stack_Op then
Arguments (J .. Last_Argument - 1) :=
Arguments (J + 1 .. Last_Argument);
Last_Argument := Last_Argument - 1;
else
Stack_Op := True;
end if;
end if;
if Opt.Maximum_Processes > 1 then
if Arguments (J).all = "--lto" or else
Arguments (J).all = "-flto"
then
declare
Img : String := Opt.Maximum_Processes'Img;
begin
Img (1) := '=';
Arguments (J) := new String'(Arguments (J).all & Img);
end;
end if;
end if;
J := J + 1;
end loop;
end Clean_Link_Option_Set;
-- Look for the last switch -shared-libgcc or -static-libgcc and
-- remove all the others.
declare
Dash_Shared_Libgcc : Boolean := False;
Dash_Static_Libgcc : Boolean := False;
Arg : Natural;
procedure Remove_Argument;
-- Remove Arguments (Arg)
procedure Remove_Argument is
begin
Arguments (Arg .. Last_Argument - 1) :=
Arguments (Arg + 1 .. Last_Argument);
Last_Argument := Last_Argument - 1;
end Remove_Argument;
begin
Arg := Last_Argument;
loop
if Arguments (Arg).all = "-shared-libgcc" then
if Dash_Shared_Libgcc or Dash_Static_Libgcc then
Remove_Argument;
else
Dash_Shared_Libgcc := True;
end if;
elsif Arguments (Arg).all = "-static-libgcc" then
if Dash_Shared_Libgcc or Dash_Static_Libgcc then
Remove_Argument;
else
Dash_Static_Libgcc := True;
end if;
end if;
Arg := Arg - 1;
exit when Arg = 0;
end loop;
-- If -shared-libgcc was the last switch, then put in the
-- run path option the shared libgcc dir.
if Dash_Shared_Libgcc
and then Opt.Run_Path_Option
and then Main_Proj.Config.Run_Path_Option /= No_Name_List
then
-- Look for the adalib directory in -L switches.
-- If it is found, then add the shared libgcc
-- directory to the run path option.
for J in 1 .. Last_Argument loop
declare
Option : String (1 .. Arguments (J)'Length);
Last : Natural := Option'Last;
begin
Option := Arguments (J).all;
if Last > 2 and then Option (1 .. 2) = "-L" then
if Option (Last) = '/'
or else Option (Last) = Directory_Separator
then
Last := Last - 1;
end if;
if Last > 10
and then Option (Last - 5 .. Last) = "adalib"
then
Add_Rpath
(Shared_Libgcc_Dir (Option (3 .. Last)));
exit;
end if;
end if;
end;
end loop;
end if;
end;
-- Add the run path option, if necessary
if Opt.Run_Path_Option
and then Main_Proj.Config.Run_Path_Option /= No_Name_List
and then Rpaths.Last > 0
then
declare
Nam_Nod : Name_Node :=
Main_File.Tree.Shared.Name_Lists.Table
(Main_Proj.Config.Run_Path_Option);
Length : Natural := 0;
Arg : String_Access := null;
begin
if Main_Proj.Config.Run_Path_Origin /= No_Name
and then
Get_Name_String (Main_Proj.Config.Run_Path_Origin) /= ""
then
Rpaths_Relative_To
(Main_Proj.Exec_Directory.Display_Name,
Main_Proj.Config.Run_Path_Origin);
end if;
if Main_Proj.Config.Separate_Run_Path_Options then
for J in 1 .. Rpaths.Last loop
Nam_Nod := Main_File.Tree.Shared.Name_Lists.Table
(Main_Proj.Config.Run_Path_Option);
while Nam_Nod.Next /= No_Name_List loop
Add_Argument
(Get_Name_String (Nam_Nod.Name), True);
Nam_Nod := Main_File.Tree.Shared.Name_Lists.Table
(Nam_Nod.Next);
end loop;
Get_Name_String (Nam_Nod.Name);
Add_Str_To_Name_Buffer (Rpaths.Table (J).all);
Add_Argument
(Name_Buffer (1 .. Name_Len), Opt.Verbose_Mode);
end loop;
else
while Nam_Nod.Next /= No_Name_List loop
Add_Argument (Get_Name_String (Nam_Nod.Name), True);
Nam_Nod := Main_File.Tree.Shared.Name_Lists.Table
(Nam_Nod.Next);
end loop;
-- Compute the length of the argument
Get_Name_String (Nam_Nod.Name);
Length := Name_Len;
for J in 1 .. Rpaths.Last loop
Length := Length + Rpaths.Table (J)'Length + 1;
end loop;
Length := Length - 1;
-- Create the argument
Arg := new String (1 .. Length);
Length := Name_Len;
Arg (1 .. Name_Len) := Name_Buffer (1 .. Name_Len);
for J in 1 .. Rpaths.Last loop
if J /= 1 then
Length := Length + 1;
Arg (Length) := Path_Separator;
end if;
Arg (Length + 1 .. Length + Rpaths.Table (J)'Length)
:= Rpaths.Table (J).all;
Length := Length + Rpaths.Table (J)'Length;
end loop;
Add_Argument (Arg, Opt.Verbose_Mode);
end if;
end;
end if;
-- Add the map file option, if supported and requested
if Map_File /= null
and then Main_Proj.Config.Map_File_Option /= No_Name
then
Get_Name_String (Main_Proj.Config.Map_File_Option);
if Map_File'Length > 0 then
Add_Str_To_Name_Buffer (Map_File.all);
else
Add_Str_To_Name_Buffer
(Get_Name_String (Main_Base_Name_Index));
Add_Str_To_Name_Buffer (".map");
end if;
Add_Argument (Name_Buffer (1 .. Name_Len), Opt.Verbose_Mode);
end if;
-- Add the switch(es) to specify the name of the executable
declare
List : Name_List_Index :=
Main_Proj.Config.Linker_Executable_Option;
Nam : Name_Node;
procedure Add_Executable_Name;
-- Add the name of the executable to to current name buffer,
-- then the content of the name buffer as the next argument.
-------------------------
-- Add_Executable_Name --
-------------------------
procedure Add_Executable_Name is
begin
Add_Str_To_Name_Buffer (Get_Name_String (Exec_Path_Name));
Add_Argument
(Name_Buffer (1 .. Name_Len),
True,
Simple_Name => not Opt.Verbose_Mode);
end Add_Executable_Name;
begin
if List /= No_Name_List then
loop
Nam := Main_File.Tree.Shared.Name_Lists.Table (List);
Get_Name_String (Nam.Name);
if Nam.Next = No_Name_List then
Add_Executable_Name;
exit;
else
Add_Argument (Name_Buffer (1 .. Name_Len), True);
end if;
List := Nam.Next;
end loop;
else
Add_Argument ("-o", True);
Name_Len := 0;
Add_Executable_Name;
end if;
end;
-- If response files are supported, check the length of the
-- command line and the number of object files, then create
-- a response file if needed.
if Main_Proj.Config.Max_Command_Line_Length > 0
and then Main_Proj.Config.Resp_File_Format /= GPR.None
and then First_Object_Index > 0
then
declare
Arg_Length : Natural := 0;
Min_Number_Of_Objects : Natural := 0;
begin
for J in 1 .. Last_Argument loop
Arg_Length := Arg_Length + Arguments (J)'Length + 1;
end loop;
if Arg_Length > Main_Proj.Config.Max_Command_Line_Length then
if Main_Proj.Config.Resp_File_Options = No_Name_List then
Min_Number_Of_Objects := 0;
else
Min_Number_Of_Objects := 1;
end if;
-- Don't create a response file if there would not be
-- a smaller number of arguments.
if Last_Object_Index - First_Object_Index + 1 >
Min_Number_Of_Objects
then
declare
Resp_File_Options : String_List_Access :=
new String_List (1 .. 0);
List : Name_List_Index :=
Main_Proj.Config.
Resp_File_Options;
Nam_Nod : Name_Node;
begin
while List /= No_Name_List loop
Nam_Nod :=
Main_File.Tree.Shared.Name_Lists.Table (List);
Resp_File_Options :=
new String_List'
(Resp_File_Options.all
& new String'
(Get_Name_String (Nam_Nod.Name)));
List := Nam_Nod.Next;
end loop;
Create_Response_File
(Format =>
Main_Proj.Config.Resp_File_Format,
Objects => Arguments
(First_Object_Index .. Last_Object_Index),
Other_Arguments =>
Arguments (Last_Object_Index + 1 ..
Last_Argument),
Resp_File_Options => Resp_File_Options.all,
Name_1 => Response_File_Name,
Name_2 => Response_2);
Record_Temp_File
(Shared => Main_File.Tree.Shared,
Path => Response_File_Name);
if Response_2 /= No_Path then
Record_Temp_File
(Shared => Main_File.Tree.Shared,
Path => Response_2);
end if;
if Main_Proj.Config.Resp_File_Format = GCC
or else
Main_Proj.Config.Resp_File_Format = GCC_GNU
or else
Main_Proj.Config.Resp_File_Format = GCC_Object_List
or else
Main_Proj.Config.Resp_File_Format = GCC_Option_List
then
Arguments (First_Object_Index) :=
new String'("@" &
Get_Name_String
(Response_File_Name));
Last_Argument := First_Object_Index;
else
-- Replace the first object file arguments
-- with the argument(s) specifying the
-- response file. No need to update
-- Arguments_Displayed, as the values are
-- already correct (= Verbose_Mode).
if Resp_File_Options'Length = 0 then
Arguments (First_Object_Index) :=
new String'(Get_Name_String
(Response_File_Name));
First_Object_Index := First_Object_Index + 1;
else
for J in Resp_File_Options'First ..
Resp_File_Options'Last - 1
loop
Arguments (First_Object_Index) :=
Resp_File_Options (J);
First_Object_Index :=
First_Object_Index + 1;
end loop;
Arguments (First_Object_Index) :=
new String'(Resp_File_Options
(Resp_File_Options'Last).all
&
Get_Name_String
(Response_File_Name));
First_Object_Index :=
First_Object_Index + 1;
end if;
-- And put the arguments following the object
-- files immediately after the response file
-- argument(s). Update Arguments_Displayed
-- too.
Arguments (First_Object_Index ..
Last_Argument -
Last_Object_Index +
First_Object_Index -
1) :=
Arguments (Last_Object_Index + 1 ..
Last_Argument);
Arguments_Displayed
(First_Object_Index ..
Last_Argument -
Last_Object_Index +
First_Object_Index -
1) :=
Arguments_Displayed
(Last_Object_Index + 1 ..
Last_Argument);
Last_Argument :=
Last_Argument - Last_Object_Index +
First_Object_Index - 1;
end if;
end;
end if;
end if;
end;
end if;
-- Delete an eventual executable, in case it is a symbolic
-- link as we don't want to modify the target of the link.
declare
Dummy : Boolean;
pragma Unreferenced (Dummy);
begin
Delete_File (Get_Name_String (Exec_Path_Name), Dummy);
end;
if not Opt.Quiet_Output then
if Opt.Verbose_Mode then
Display_Command (Linker_Path);
else
Display
(Section => GPR.Link,
Command => "link",
Argument => Main);
end if;
end if;
declare
Pid : Process_Id;
begin
Script_Write (Linker_Path.all, Arguments (1 .. Last_Argument));
Pid := Non_Blocking_Spawn
(Linker_Path.all, Arguments (1 .. Last_Argument));
if Pid = Invalid_Pid then
Record_Failure (Main_File);
else
Add_Process
(Pid,
(Linking, Pid, Main_File));
Display_Processes ("link");
end if;
end;
end if;
end Link_Main;
---------
-- Run --
---------
procedure Run is
Main : Main_Info;
procedure Do_Link (Project : Project_Id; Tree : Project_Tree_Ref);
procedure Await_Link;
procedure Wait_For_Available_Slot;
----------------
-- Await_Link --
----------------
procedure Await_Link is
Data : Process_Data;
OK : Boolean;
begin
loop
Await_Process (Data, OK);
if Data /= No_Process_Data then
if not OK then
Record_Failure (Data.Main);
end if;
Display_Processes ("link");
return;
end if;
end loop;
end Await_Link;
-------------
-- Do_Link --
-------------
procedure Do_Link (Project : Project_Id; Tree : Project_Tree_Ref) is
pragma Unreferenced (Project);
Main_File : Main_Info;
begin
if Builder_Data (Tree).Need_Linking and then not Stop_Spawning then
Mains.Reset;
loop
Main_File := Mains.Next_Main;
exit when Main_File = No_Main_Info;
if Main_File.Tree = Tree
and then not Project_Compilation_Failed (Main_File.Project)
then
Wait_For_Available_Slot;
exit when Stop_Spawning;
Link_Main (Main_File);
exit when Stop_Spawning;
end if;
end loop;
end if;
end Do_Link;
procedure Link_All is new For_Project_And_Aggregated (Do_Link);
-----------------------------
-- Wait_For_Available_Slot --
-----------------------------
procedure Wait_For_Available_Slot is
begin
while Outstanding_Processes >= Opt.Maximum_Processes loop
Await_Link;
end loop;
end Wait_For_Available_Slot;
begin
Outstanding_Processes := 0;
Stop_Spawning := False;
Link_All (Main_Project, Project_Tree);
while Outstanding_Processes > 0 loop
Await_Link;
end loop;
if Bad_Processes.Last = 1 then
Main := Bad_Processes.Table (1);
Fail_Program
(Main.Tree,
"link of " & Get_Name_String (Main.File) & " failed");
elsif Bad_Processes.Last > 1 then
for J in 1 .. Bad_Processes.Last loop
Main := Bad_Processes.Table (J);
Put (" link of ");
Put (Get_Name_String (Main.File));
Put_Line (" failed");
end loop;
Fail_Program (Main.Tree, "*** link phase failed");
end if;
end Run;
end Gprbuild.Link;
|
skrtbhtngr/presto | Ada | 3,331 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib-thin.adb,val 1.8 2003/12/14 18:27:31 vagul Exp $
package body ZLib.Thin is
ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
--------------
-- Avail_In --
--------------
function Avail_In (Strm : in Z_Stream) return UInt is
begin
return Strm.Avail_In;
end Avail_In;
---------------
-- Avail_Out --
---------------
function Avail_Out (Strm : in Z_Stream) return UInt is
begin
return Strm.Avail_Out;
end Avail_Out;
------------------
-- Deflate_Init --
------------------
function Deflate_Init
(strm : Z_Streamp;
level : Int;
method : Int;
windowBits : Int;
memLevel : Int;
strategy : Int)
return Int is
begin
return deflateInit2
(strm,
level,
method,
windowBits,
memLevel,
strategy,
ZLIB_VERSION,
Z_Stream_Size);
end Deflate_Init;
------------------
-- Inflate_Init --
------------------
function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is
begin
return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size);
end Inflate_Init;
------------------------
-- Last_Error_Message --
------------------------
function Last_Error_Message (Strm : in Z_Stream) return String is
use Interfaces.C.Strings;
begin
if Strm.msg = Null_Ptr then
return "";
else
return Value (Strm.msg);
end if;
end Last_Error_Message;
------------
-- Set_In --
------------
procedure Set_In
(Strm : in out Z_Stream;
Buffer : in Voidp;
Size : in UInt) is
begin
Strm.Next_In := Buffer;
Strm.Avail_In := Size;
end Set_In;
------------------
-- Set_Mem_Func --
------------------
procedure Set_Mem_Func
(Strm : in out Z_Stream;
Opaque : in Voidp;
Alloc : in alloc_func;
Free : in free_func) is
begin
Strm.opaque := Opaque;
Strm.zalloc := Alloc;
Strm.zfree := Free;
end Set_Mem_Func;
-------------
-- Set_Out --
-------------
procedure Set_Out
(Strm : in out Z_Stream;
Buffer : in Voidp;
Size : in UInt) is
begin
Strm.Next_Out := Buffer;
Strm.Avail_Out := Size;
end Set_Out;
--------------
-- Total_In --
--------------
function Total_In (Strm : in Z_Stream) return ULong is
begin
return Strm.Total_In;
end Total_In;
---------------
-- Total_Out --
---------------
function Total_Out (Strm : in Z_Stream) return ULong is
begin
return Strm.Total_Out;
end Total_Out;
end ZLib.Thin;
|
reznikmm/matreshka | Ada | 5,472 | 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 Ada.Wide_Wide_Text_IO;
with Interfaces;
with Asis.Expressions;
with League.String_Vectors;
package body Properties.Expressions.Integer_Literal is
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
pragma Unreferenced (Engine, Name);
Image : constant Wide_String := Asis.Expressions.Value_Image (Element);
Result : League.Strings.Universal_String :=
League.Strings.From_UTF_16_Wide_String (Image);
begin
if Result.Index ('.') > 0 then
declare
Value : constant Long_Long_Float :=
Long_Long_Float'Wide_Value (Image);
Text : constant Wide_Wide_String :=
Long_Long_Float'Wide_Wide_Image (Value);
begin
Result :=
League.Strings.To_Universal_String (Text (2 .. Text'Last));
end;
elsif Result.Starts_With ("16#") then
declare
package IO is
new Ada.Wide_Wide_Text_IO.Modular_IO (Interfaces.Unsigned_32);
Value : constant Interfaces.Unsigned_32 :=
Interfaces.Unsigned_32'Wide_Value (Image);
Text : Wide_Wide_String (1 .. 19);
List : League.String_Vectors.Universal_String_Vector;
begin
IO.Put (Text, Value, 16);
Result := League.Strings.To_Universal_String (Text);
List := Result.Split ('#');
Result.Clear;
Result.Append ("0x");
Result.Append (List.Element (2));
end;
else
declare
Value : constant Interfaces.Unsigned_32 :=
Interfaces.Unsigned_32'Wide_Value (Image);
Text : constant Wide_Wide_String :=
Interfaces.Unsigned_32'Wide_Wide_Image (Value);
begin
Result :=
League.Strings.To_Universal_String (Text (2 .. Text'Last));
end;
end if;
return Result;
end Code;
end Properties.Expressions.Integer_Literal;
|
charlie5/lace | Ada | 1,002 | adb | with eGL.Binding,
eGL.Pointers,
System;
package body openGL.Display
is
use eGL,
eGL.Binding,
eGL.Pointers;
function Default return Item
is
use type System.Address, eGL.EGLBoolean;
the_Display : Display.item;
Success : EGLBoolean;
Status : EGLBoolean;
begin
the_Display.Thin := eglGetDisplay (Display_Pointer (EGL_DEFAULT_DISPLAY));
if the_Display.Thin = egl_NO_DISPLAY then
raise openGL.Error with "Failed to open the default Display with eGL.";
end if;
Success := eglInitialize (the_Display.Thin, the_Display.Version_major'Unchecked_Access,
the_Display.Version_minor'Unchecked_Access);
if Success = egl_False then
raise openGL.Error with "Failed to initialise eGL using the default Display.";
end if;
Status := eglBindAPI (EGL_OPENGL_ES_API);
return the_Display;
end Default;
end openGL.Display;
|
alire-project/libhello | Ada | 559 | ads | -- Configuration for libhello generated by Alire
pragma Restrictions (No_Elaboration_Code);
pragma Style_Checks (Off);
package Libhello_Config is
pragma Pure;
Crate_Version : constant String := "1.0.1";
Crate_Name : constant String := "libhello";
Alire_Host_OS : constant String := "linux";
Alire_Host_Arch : constant String := "x86_64";
Alire_Host_Distro : constant String := "ubuntu";
type Build_Profile_Kind is (release, validation, development);
Build_Profile : constant Build_Profile_Kind := release;
end Libhello_Config;
|
sungyeon/drake | Ada | 25 | adb | ../../x86_64/a-nudsge.adb |
Subsets and Splits