repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
charlie5/cBound | Ada | 1,785 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_integerv_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;
pad1 : aliased swig.int8_t_Array (0 .. 3);
n : aliased Interfaces.Unsigned_32;
datum : aliased Interfaces.Integer_32;
pad2 : aliased swig.int8_t_Array (0 .. 11);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_get_integerv_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_integerv_reply_t.Item,
Element_Array => xcb.xcb_glx_get_integerv_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_get_integerv_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_integerv_reply_t.Pointer,
Element_Array => xcb.xcb_glx_get_integerv_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_integerv_reply_t;
|
flyx/OpenGLAda | Ada | 1,284 | ads | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
generic
type Index_Type is (<>);
type Element_Type is private;
with function "+" (Left, Right : Element_Type) return Element_Type is <>;
with function "-" (Left, Right : Element_Type) return Element_Type is <>;
with function "-" (Left : Element_Type) return Element_Type is <>;
with function "*" (Left, Right : Element_Type) return Element_Type is <>;
with function "/" (Left, Right : Element_Type) return Element_Type is <>;
package GL.Vectors is
pragma Preelaborate;
type Vector is array (Index_Type) of aliased Element_Type;
pragma Convention (C, Vector);
function "+" (Left, Right : Vector) return Vector;
function "-" (Left, Right : Vector) return Vector;
function "-" (Left : Vector) return Vector;
function "*" (Left : Vector; Right : Element_Type) return Vector;
function "*" (Left : Element_Type; Right : Vector) return Vector;
function "/" (Left : Vector; Right : Element_Type) return Vector;
function Dot_Product (Left, Right : Vector) return Element_Type;
pragma Inline ("+");
pragma Inline ("-");
pragma Inline ("*");
pragma Inline ("/");
end GL.Vectors;
|
stcarrez/ada-ado | Ada | 2,923 | adb | -----------------------------------------------------------------------
-- ado-utils -- Utility operations for ADO
-- Copyright (C) 2013, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body ADO.Utils is
-- ------------------------------
-- Build a bean object from the identifier.
-- ------------------------------
function To_Object (Id : in ADO.Identifier) return Util.Beans.Objects.Object is
begin
if Id = ADO.NO_IDENTIFIER then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (Id));
end if;
end To_Object;
-- ------------------------------
-- Build the identifier from the bean object.
-- ------------------------------
function To_Identifier (Value : in Util.Beans.Objects.Object) return ADO.Identifier is
begin
if Util.Beans.Objects.Is_Null (Value) then
return ADO.NO_IDENTIFIER;
else
return ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
end if;
end To_Identifier;
-- ------------------------------
-- Compute the hash of the identifier.
-- ------------------------------
function Hash (Key : in ADO.Identifier) return Ada.Containers.Hash_Type is
use Ada.Containers;
begin
if Key < 0 then
return Hash_Type (-Key);
else
return Hash_Type (Key);
end if;
end Hash;
-- ------------------------------
-- Return the identifier list as a comma separated list of identifiers.
-- ------------------------------
function To_Parameter_List (List : in Identifier_Vector) return String is
use Identifier_Vectors;
Result : Ada.Strings.Unbounded.Unbounded_String;
Pos : Identifier_Cursor := List.First;
Need_Comma : Boolean := False;
begin
while Identifier_Vectors.Has_Element (Pos) loop
if Need_Comma then
Ada.Strings.Unbounded.Append (Result, ",");
end if;
Ada.Strings.Unbounded.Append (Result, ADO.Identifier'Image (Element (Pos)));
Need_Comma := True;
Next (Pos);
end loop;
return Ada.Strings.Unbounded.To_String (Result);
end To_Parameter_List;
end ADO.Utils;
|
iyan22/AprendeAda | Ada | 1,277 | adb | with Ada.Text_Io; use Ada.Text_Io;
with datos; use datos;
with eliminar_repetidos, escribir_lista;
procedure prueba_eliminar_repetidos is
V1, V2: Lista_Enteros;
begin
put_line("Primera prueba: eliminar_repetidos(1,2,3,4,5,6,7,8,9,10)");
V1.Numeros := (1,2,3,4,5,6,7,8,9,10, OTHERS => 0);
V1.Cont := 10;
escribir_lista(V1);
new_line;
put_line("Despues de eliminar repetidos:");
eliminar_repetidos(V1, V2);
escribir_lista(V2);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
put_line("Segunda prueba: eliminar_repetidos(1,1,1,1,1,1,1,1,1,1)");
V1.Numeros := (1,1,1,1,1,1,1,1,1,1, OTHERS => 0);
V1.Cont := 10;
escribir_lista(V1);
new_line;
put_line("Despues de eliminar repetidos:");
eliminar_repetidos(V1, V2);
escribir_lista(V2);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
put_line("Tercera prueba: eliminar_repetidos(2,2,4,4,6,6,8,8,10,10)");
V1.Numeros := (2,2,4,4,6,6,8,8,10,10, OTHERS => 0);
V1.Cont := 10;
escribir_lista(V1);
new_line;
put_line("Despues de eliminar repetidos:");
eliminar_repetidos(V1, V2);
escribir_lista(V2);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
end prueba_eliminar_repetidos;
|
reznikmm/matreshka | Ada | 58,038 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015-2018, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Asis.Extensions.Flat_Kinds;
with League.Strings;
with Properties.Common;
with Properties.Declarations.Component_Declaration;
with Properties.Declarations.Constant_Declarations;
with Properties.Declarations.Defining_Expanded_Name;
with Properties.Declarations.Defining_Names;
with Properties.Declarations.Element_Iterator_Specification;
with Properties.Declarations.Function_Declarations;
with Properties.Declarations.Function_Renaming_Declaration;
with Properties.Declarations.Generic_Declaration;
with Properties.Declarations.Incomplete_Type;
with Properties.Declarations.Loop_Parameter_Specification;
with Properties.Declarations.Ordinary_Type;
with Properties.Declarations.Package_Declaration;
with Properties.Declarations.Package_Instantiation;
with Properties.Declarations.Private_Type;
with Properties.Declarations.Procedure_Body_Declarations;
with Properties.Declarations.Procedure_Declaration;
with Properties.Declarations.Subprogram_Instantiation;
with Properties.Definitions.Access_To_Object;
with Properties.Definitions.Component_Definition;
with Properties.Definitions.Constrained_Array_Type;
with Properties.Definitions.Derived_Type;
with Properties.Definitions.Discriminant_Constraint;
with Properties.Definitions.Enumeration_Type;
with Properties.Definitions.Float_Point;
with Properties.Definitions.Index_Constraint;
with Properties.Definitions.Modular;
with Properties.Definitions.Others_Choice;
with Properties.Definitions.Range_Attribute;
with Properties.Definitions.Record_Type;
with Properties.Definitions.Signed;
with Properties.Definitions.Simple_Expression_Range;
with Properties.Definitions.Subtype_Indication;
with Properties.Definitions.Tagged_Record_Type;
with Properties.Definitions.Unconstrained_Array_Type;
with Properties.Definitions.Variant_Part;
with Properties.Definitions.Variant;
with Properties.Expressions.Allocation;
with Properties.Expressions.Allocation_From_Subtype;
with Properties.Expressions.Array_Component_Association;
with Properties.Expressions.Attribute_Reference;
with Properties.Expressions.Case_Expression;
with Properties.Expressions.Enumeration_Literal;
with Properties.Expressions.Explicit_Dereference;
with Properties.Expressions.Extension_Aggregate;
with Properties.Expressions.Function_Calls;
with Properties.Expressions.Identifiers;
with Properties.Expressions.If_Expression;
with Properties.Expressions.Indexed_Component;
with Properties.Expressions.Integer_Literal;
with Properties.Expressions.Membership_Test;
with Properties.Expressions.Null_Literal;
with Properties.Expressions.Parameter_Association;
with Properties.Expressions.Parenthesized;
with Properties.Expressions.Pos_Array_Aggregate;
with Properties.Expressions.Record_Aggregate;
with Properties.Expressions.Record_Component_Association;
with Properties.Expressions.Selected_Components;
with Properties.Expressions.Short_Circuit;
with Properties.Expressions.Slice;
with Properties.Expressions.String_Literal;
with Properties.Expressions.Type_Conversion;
with Properties.Statements.Assignment_Statement;
with Properties.Statements.Block_Statement;
with Properties.Statements.Case_Statement;
with Properties.Statements.Exit_Statement;
with Properties.Statements.Extended_Return;
with Properties.Statements.For_Loop_Statement;
with Properties.Statements.If_Statement;
with Properties.Statements.Loop_Statement;
with Properties.Statements.Procedure_Call_Statement;
with Properties.Statements.Raise_Statement;
with Properties.Statements.Return_Statement;
with Properties.Statements.While_Loop_Statement;
procedure Engines.Registry_All_Actions
(Self : in out Engines.Contexts.Context)
is
type Text_Callback is access function
(Engine : access Engines.Contexts.Context;
Element : Asis.Element;
Name : Engines.Text_Property) return League.Strings.Universal_String;
type Action_Item is record
Name : Engines.Text_Property;
Kind : Asis.Extensions.Flat_Kinds.Flat_Element_Kinds;
Action : Text_Callback;
end record;
type Boolean_Callback is access function
(Engine : access Engines.Contexts.Context;
Element : Asis.Element;
Name : Engines.Boolean_Property) return Boolean;
type Boolean_Action_Item is record
Name : Engines.Boolean_Property;
Kind : Asis.Extensions.Flat_Kinds.Flat_Element_Kinds;
Action : Boolean_Callback;
end record;
type Integer_Callback is access function
(Engine : access Engines.Contexts.Context;
Element : Asis.Element;
Name : Engines.Integer_Property) return Integer;
type Integer_Action_Item is record
Name : Engines.Integer_Property;
Kind : Asis.Extensions.Flat_Kinds.Flat_Element_Kinds;
Action : Integer_Callback;
end record;
type Action_Array is array (Positive range <>) of Action_Item;
type Action_Range is record
Name : Engines.Text_Property;
From, To : Asis.Extensions.Flat_Kinds.Flat_Element_Kinds;
Action : Text_Callback;
end record;
type Range_Array is array (Positive range <>) of Action_Range;
package F renames Asis.Extensions.Flat_Kinds;
package N renames Engines;
package P renames Properties;
Action_List : constant Action_Array :=
-- Address
((Name => N.Address,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Address'Access),
(Name => N.Address,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Code'Access),
(Name => N.Address,
Kind => F.A_Type_Conversion,
Action => P.Expressions.Type_Conversion.Code'Access),
(Name => N.Address,
Kind => F.An_Explicit_Dereference,
Action => P.Expressions.Explicit_Dereference.Address'Access),
(Name => N.Address,
Kind => F.An_Indexed_Component,
Action => P.Expressions.Indexed_Component.Address'Access),
-- Associations
(Name => N.Associations,
Kind => F.A_Record_Component_Association,
Action =>
P.Expressions.Record_Component_Association.Associations'Access),
-- Code
(Name => N.Code,
Kind => F.A_Use_Package_Clause,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Constant_Declaration,
Action => P.Declarations.Constant_Declarations.Code'Access),
(Name => N.Code,
Kind => F.A_Return_Constant_Specification,
Action => P.Declarations.Constant_Declarations.Code'Access),
(Name => N.Code,
Kind => F.A_Return_Variable_Specification,
Action => P.Declarations.Constant_Declarations.Code'Access),
(Name => N.Code,
Kind => F.A_Deferred_Constant_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Function_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Package_Declaration,
Action => P.Declarations.Package_Declaration.Code'Access),
(Name => N.Code,
Kind => F.A_Package_Body_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Generic_Package_Declaration,
Action => P.Declarations.Generic_Declaration.Code'Access),
(Name => N.Code,
Kind => F.A_Generic_Package_Renaming_Declaration,
Action => P.Declarations.Generic_Declaration.Code'Access),
(Name => N.Code,
Kind => F.A_Generic_Function_Renaming_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Generic_Function_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Generic_Procedure_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Package_Renaming_Declaration, -- FIXME
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.An_Object_Renaming_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.An_Integer_Number_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Real_Number_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Private_Extension_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Tagged_Incomplete_Type_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Private_Type_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.An_Incomplete_Type_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Procedure_Body_Declaration,
Action => P.Declarations.Procedure_Body_Declarations.Code'Access),
(Name => N.Code,
Kind => F.A_Function_Body_Declaration,
Action => P.Declarations.Procedure_Body_Declarations.Code'Access),
(Name => N.Code,
Kind => F.A_Procedure_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Null_Procedure_Declaration,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Loop_Parameter_Specification,
Action =>
P.Declarations.Loop_Parameter_Specification.Code'Access),
(Name => N.Code,
Kind => F.An_Element_Iterator_Specification,
Action =>
P.Declarations.Element_Iterator_Specification.Code'Access),
(Name => N.Code,
Kind => F.A_Subtype_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Variable_Declaration,
Action => P.Declarations.Constant_Declarations.Code'Access),
(Name => N.Code,
Kind => F.A_Function_Renaming_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Procedure_Renaming_Declaration,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Defining_Identifier,
Action => P.Declarations.Defining_Names.Code'Access),
(Name => N.Code,
Kind => F.A_Defining_Enumeration_Literal,
Action => P.Declarations.Defining_Names.Code'Access),
(Name => N.Code,
Kind => F.A_Defining_Expanded_Name,
Action => P.Declarations.Defining_Expanded_Name.Code'Access),
(Name => N.Code,
Kind => F.A_Package_Instantiation,
Action => P.Declarations.Package_Instantiation.Code'Access),
(Name => N.Code,
Kind => F.A_Procedure_Instantiation,
Action => P.Declarations.Subprogram_Instantiation.Code'Access),
(Name => N.Code,
Kind => F.A_Function_Instantiation,
Action => P.Declarations.Subprogram_Instantiation.Code'Access),
(Name => N.Code,
Kind => F.An_Enumeration_Type_Definition,
Action => P.Definitions.Enumeration_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Signed_Integer_Type_Definition,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Code'Access),
(Name => N.Code,
Kind => F.A_Constrained_Array_Definition,
Action => P.Definitions.Constrained_Array_Type.Code'Access),
(Name => N.Code,
Kind => F.An_Unconstrained_Array_Definition,
Action => P.Definitions.Unconstrained_Array_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Component_Definition,
Action => P.Definitions.Component_Definition.Initialize'Access),
(Name => N.Code,
Kind => F.A_Derived_Type_Definition,
Action => P.Definitions.Derived_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Derived_Record_Extension_Definition,
Action => P.Definitions.Tagged_Record_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Tagged_Record_Type_Definition,
Action => P.Definitions.Tagged_Record_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Limited_Interface,
Action => P.Definitions.Tagged_Record_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Record_Type_Definition,
Action => P.Definitions.Record_Type.Code'Access),
(Name => N.Code,
Kind => F.A_Discriminant_Constraint,
Action => P.Definitions.Discriminant_Constraint.Code'Access),
(Name => N.Code,
Kind => F.An_Index_Constraint,
Action => P.Definitions.Index_Constraint.Code'Access),
(Name => N.Code,
Kind => F.An_Others_Choice,
Action => P.Definitions.Others_Choice.Code'Access),
(Name => N.Code,
Kind => F.An_Access_To_Variable,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.An_Access_To_Constant,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Pool_Specific_Access_To_Variable,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.An_Access_To_Procedure,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.An_Access_To_Function,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Box_Expression,
Action => P.Common.Empty'Access), -- return "" for <>
(Name => N.Code,
Kind => F.An_Allocation_From_Qualified_Expression,
Action => P.Expressions.Allocation.Code'Access),
(Name => N.Code,
Kind => F.An_Allocation_From_Subtype,
Action => P.Expressions.Allocation_From_Subtype.Code'Access),
(Name => N.Code,
Kind => F.An_Enumeration_Literal,
Action => P.Expressions.Enumeration_Literal.Code'Access),
(Name => N.Code,
Kind => F.An_Explicit_Dereference,
Action => P.Expressions.Explicit_Dereference.Code'Access),
(Name => N.Code,
Kind => F.A_Function_Call,
Action => P.Expressions.Function_Calls.Code'Access),
(Name => N.Code,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Code'Access),
(Name => N.Code,
Kind => F.An_Indexed_Component,
Action => P.Expressions.Indexed_Component.Code'Access),
(Name => N.Code,
Kind => F.A_Slice,
Action => P.Expressions.Slice.Code'Access),
(Name => N.Code,
Kind => F.An_Integer_Literal,
Action => P.Expressions.Integer_Literal.Code'Access),
(Name => N.Code,
Kind => F.A_Real_Literal,
Action => P.Expressions.Integer_Literal.Code'Access),
(Name => N.Code,
Kind => F.A_Named_Array_Aggregate,
Action => P.Expressions.Pos_Array_Aggregate.Code'Access),
(Name => N.Code,
Kind => F.A_Positional_Array_Aggregate,
Action => P.Expressions.Pos_Array_Aggregate.Code'Access),
(Name => N.Code,
Kind => F.An_In_Membership_Test,
Action => P.Expressions.Membership_Test.Code'Access),
(Name => N.Code,
Kind => F.A_Not_In_Membership_Test,
Action => P.Expressions.Membership_Test.Code'Access),
(Name => N.Code,
Kind => F.An_Or_Else_Short_Circuit,
Action => P.Expressions.Short_Circuit.Code'Access),
(Name => N.Code,
Kind => F.A_Record_Aggregate,
Action => P.Expressions.Record_Aggregate.Code'Access),
(Name => N.Code,
Kind => F.An_Extension_Aggregate,
Action => P.Expressions.Extension_Aggregate.Code'Access),
(Name => N.Code,
Kind => F.An_Array_Component_Association,
Action => P.Expressions.Array_Component_Association.Code'Access),
(Name => N.Code,
Kind => F.A_Record_Component_Association,
Action => P.Expressions.Record_Component_Association.Code'Access),
(Name => N.Code,
Kind => F.A_Null_Literal,
Action => P.Expressions.Null_Literal.Code'Access),
(Name => N.Code,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Code'Access),
(Name => N.Code,
Kind => F.A_String_Literal,
Action => P.Expressions.String_Literal.Code'Access),
(Name => N.Code,
Kind => F.A_Type_Conversion,
Action => P.Expressions.Type_Conversion.Code'Access),
(Name => N.Code,
Kind => F.A_Qualified_Expression,
Action => P.Expressions.Type_Conversion.Code'Access),
(Name => N.Code,
Kind => F.A_Parenthesized_Expression,
Action => P.Expressions.Parenthesized.Code'Access),
(Name => N.Code,
Kind => F.An_If_Expression,
Action => P.Expressions.If_Expression.Code'Access),
(Name => N.Code,
Kind => F.A_Case_Expression,
Action => P.Expressions.Case_Expression.Code'Access),
(Name => N.Code,
Kind => F.An_Assignment_Statement,
Action => P.Statements.Assignment_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_Block_Statement,
Action => P.Statements.Block_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_Case_Statement,
Action => P.Statements.Case_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_For_Loop_Statement,
Action => P.Statements.For_Loop_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_Loop_Statement,
Action => P.Statements.Loop_Statement.Code'Access),
(Name => N.Code,
Kind => F.An_If_Statement,
Action => P.Statements.If_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_Null_Statement,
Action => P.Common.Empty'Access),
(Name => N.Code,
Kind => F.A_Use_Type_Clause,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Use_All_Type_Clause,
Action => P.Common.Empty'Access), -- Ignore
(Name => N.Code,
Kind => F.A_Procedure_Call_Statement,
Action => P.Statements.Procedure_Call_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_Return_Statement,
Action => P.Statements.Return_Statement.Code'Access),
(Name => N.Code,
Kind => F.An_Extended_Return_Statement,
Action => P.Statements.Extended_Return.Code'Access),
(Name => N.Code,
Kind => F.An_Exit_Statement,
Action => P.Statements.Exit_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_While_Loop_Statement,
Action => P.Statements.While_Loop_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_Raise_Statement,
Action => P.Statements.Raise_Statement.Code'Access),
(Name => N.Code,
Kind => F.A_With_Clause,
Action => P.Common.Empty'Access),
(Name => N.Condition,
Kind => F.An_Element_Iterator_Specification,
Action =>
P.Declarations.Element_Iterator_Specification.Condition'Access),
(Name => N.Condition,
Kind => F.A_Loop_Parameter_Specification,
Action =>
P.Declarations.Loop_Parameter_Specification.Condition'Access),
-- Assign
(Name => N.Assign,
Kind => F.A_Component_Declaration,
Action => P.Declarations.Component_Declaration.Assign'Access),
(Name => N.Assign,
Kind => F.A_Discriminant_Specification,
Action => P.Declarations.Component_Declaration.Assign'Access),
(Name => N.Assign,
Kind => F.A_Variant_Part,
Action => P.Definitions.Variant_Part.Assign'Access),
(Name => N.Assign,
Kind => F.A_Variant,
Action => P.Definitions.Variant.Assign'Access),
(Name => N.Assign,
Kind => F.A_Null_Component,
Action => P.Common.Empty'Access),
-- Bounds
(Name => N.Bounds,
Kind => F.A_Constant_Declaration,
Action => P.Declarations.Constant_Declarations.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Variable_Declaration,
Action => P.Declarations.Constant_Declarations.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Component_Declaration,
Action => P.Declarations.Constant_Declarations.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Component_Definition,
Action => P.Definitions.Component_Definition.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Bounds'Access),
(Name => N.Bounds,
Kind => F.An_Index_Constraint,
Action => P.Definitions.Index_Constraint.Bounds'Access),
(Name => N.Bounds,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Bounds'Access),
(Name => N.Bounds,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Bounds,
Kind => F.A_Constrained_Array_Definition,
Action => P.Definitions.Constrained_Array_Type.Bounds'Access),
(Name => N.Bounds,
Kind => F.An_Unconstrained_Array_Definition,
Action => P.Common.Empty'Access),
(Name => N.Bounds,
Kind => F.A_Return_Statement,
Action => P.Statements.Return_Statement.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Derived_Type_Definition,
Action => P.Definitions.Derived_Type.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Parameter_Association,
Action => P.Expressions.Parameter_Association.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Subtype_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Bounds,
Kind => F.A_Record_Component_Association,
Action => P.Expressions.Record_Component_Association.Bounds'Access),
(Name => N.Bounds,
Kind => F.A_Qualified_Expression,
Action => P.Expressions.Type_Conversion.Bounds'Access),
(Name => N.Bounds,
Kind => F.An_Assignment_Statement,
Action => P.Statements.Assignment_Statement.Bounds'Access),
-- Initialize
(Name => N.Initialize,
Kind => F.A_Constant_Declaration,
Action => P.Declarations.Constant_Declarations.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Return_Constant_Specification,
Action => P.Declarations.Constant_Declarations.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Return_Variable_Specification,
Action => P.Declarations.Constant_Declarations.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Discriminant_Specification,
Action => P.Declarations.Constant_Declarations.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Component_Declaration,
Action => P.Declarations.Constant_Declarations.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Variable_Declaration,
Action => P.Declarations.Constant_Declarations.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Subtype_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Private_Extension_Declaration,
Action => P.Declarations.Private_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Derived_Record_Extension_Definition,
Action => P.Definitions.Tagged_Record_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Tagged_Record_Type_Definition,
Action => P.Definitions.Tagged_Record_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Private_Type_Declaration,
Action => P.Declarations.Private_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Loop_Parameter_Specification,
Action =>
P.Declarations.Loop_Parameter_Specification.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Element_Iterator_Specification,
Action =>
P.Declarations.Element_Iterator_Specification.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Component_Definition,
Action => P.Definitions.Component_Definition.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Access_To_Variable,
Action => P.Definitions.Access_To_Object.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Access_To_Constant,
Action => P.Definitions.Access_To_Object.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Anonymous_Access_To_Variable,
Action => P.Definitions.Access_To_Object.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Anonymous_Access_To_Constant,
Action => P.Definitions.Access_To_Object.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Constrained_Array_Definition,
Action => P.Definitions.Constrained_Array_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Derived_Type_Definition,
Action => P.Definitions.Derived_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Record_Type_Definition,
Action => P.Definitions.Record_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.An_Enumeration_Type_Definition,
Action => P.Definitions.Enumeration_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Signed_Integer_Type_Definition,
Action => P.Definitions.Enumeration_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Modular_Type_Definition,
Action => P.Definitions.Enumeration_Type.Initialize'Access),
(Name => N.Initialize,
Kind => F.A_Floating_Point_Definition,
Action => P.Definitions.Enumeration_Type.Initialize'Access),
(Name => N.Lower,
Kind => F.A_Discrete_Simple_Expression_Range_As_Subtype_Definition,
Action => P.Definitions.Simple_Expression_Range.Lower'Access),
(Name => N.Upper,
Kind => F.A_Discrete_Simple_Expression_Range_As_Subtype_Definition,
Action => P.Definitions.Simple_Expression_Range.Upper'Access),
(Name => N.Lower,
Kind => F.A_Discrete_Simple_Expression_Range,
Action => P.Definitions.Simple_Expression_Range.Lower'Access),
(Name => N.Upper,
Kind => F.A_Discrete_Simple_Expression_Range,
Action => P.Definitions.Simple_Expression_Range.Upper'Access),
(Name => N.Lower,
Kind => F.A_Simple_Expression_Range,
Action => P.Definitions.Simple_Expression_Range.Lower'Access),
(Name => N.Upper,
Kind => F.A_Simple_Expression_Range,
Action => P.Definitions.Simple_Expression_Range.Upper'Access),
(Name => N.Upper,
Kind => F.A_Discrete_Subtype_Indication_As_Subtype_Definition,
Action => P.Definitions.Subtype_Indication.Bounds'Access),
(Name => N.Lower,
Kind => F.A_Discrete_Subtype_Indication_As_Subtype_Definition,
Action => P.Definitions.Subtype_Indication.Bounds'Access),
(Name => N.Upper,
Kind => F.A_Discrete_Range_Attribute_Reference_As_Subtype_Definition,
Action => P.Definitions.Range_Attribute.Upper'Access),
(Name => N.Lower,
Kind => F.A_Discrete_Range_Attribute_Reference_As_Subtype_Definition,
Action => P.Definitions.Range_Attribute.Lower'Access),
(Name => N.Upper,
Kind => F.A_Discrete_Range_Attribute_Reference,
Action => P.Definitions.Range_Attribute.Upper'Access),
(Name => N.Lower,
Kind => F.A_Discrete_Range_Attribute_Reference,
Action => P.Definitions.Range_Attribute.Lower'Access),
(Name => N.Upper,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Bounds'Access),
(Name => N.Lower,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Bounds'Access),
(Name => N.Upper,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Lower,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Lower,
Kind => F.An_Enumeration_Type_Definition,
Action => P.Definitions.Enumeration_Type.Lower'Access),
(Name => N.Upper,
Kind => F.An_Enumeration_Type_Definition,
Action => P.Definitions.Enumeration_Type.Upper'Access),
(Name => N.Lower,
Kind => F.A_Subtype_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Upper,
Kind => F.A_Subtype_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Lower,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Bounds'Access),
(Name => N.Upper,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Bounds'Access),
-- Intrinsic_Name
(Name => N.Intrinsic_Name,
Kind => F.A_Function_Declaration,
Action => P.Declarations.Function_Declarations.Intrinsic_Name'Access),
(Name => N.Intrinsic_Name,
Kind => F.A_Function_Renaming_Declaration,
Action => P.Declarations.Function_Renaming_Declaration
.Intrinsic_Name'Access),
(Name => N.Intrinsic_Name,
Kind => F.A_Procedure_Declaration,
Action => P.Declarations.Procedure_Declaration.Intrinsic_Name'Access),
(Name => N.Intrinsic_Name,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Intrinsic_Name'Access),
(Name => N.Intrinsic_Name,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components
.Intrinsic_Name'Access),
-- Method_Name
(Name => N.Method_Name,
Kind => F.A_Defining_Identifier,
Action => P.Declarations.Defining_Names.Method_Name'Access),
(Name => N.Method_Name,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Code'Access),
(Name => N.Method_Name,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Method_Name'Access),
-- Size
(Name => N.Size,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Code'Access),
(Name => N.Size,
Kind => F.A_Subtype_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Size,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Bounds'Access),
(Name => N.Size,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Size'Access),
(Name => N.Size,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Size,
Kind => F.A_Component_Declaration,
Action => P.Declarations.Constant_Declarations.Bounds'Access),
(Name => N.Size,
Kind => F.A_Component_Definition,
Action => P.Definitions.Component_Definition.Size'Access),
(Name => N.Size,
Kind => F.A_Derived_Type_Definition,
Action => P.Definitions.Derived_Type.Bounds'Access),
(Name => N.Size,
Kind => F.A_Floating_Point_Definition,
Action => P.Definitions.Float_Point.Size'Access),
(Name => N.Size,
Kind => F.A_Record_Type_Definition,
Action => P.Definitions.Record_Type.Size'Access),
(Name => N.Size,
Kind => F.A_Constrained_Array_Definition,
Action => P.Definitions.Constrained_Array_Type.Size'Access),
(Name => N.Size,
Kind => F.A_Modular_Type_Definition,
Action => P.Definitions.Modular.Size'Access),
(Name => N.Size,
Kind => F.A_Signed_Integer_Type_Definition,
Action => P.Definitions.Modular.Size'Access),
(Name => N.Size,
Kind => F.A_Private_Type_Declaration,
Action => P.Declarations.Private_Type.Initialize'Access),
-- Tag_Name
(Name => N.Tag_Name,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Code'Access),
(Name => N.Tag_Name,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Code'Access),
(Name => N.Tag_Name,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Initialize'Access),
(Name => N.Tag_Name,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Tag_Name,
Kind => F.A_Private_Extension_Declaration,
Action => P.Declarations.Private_Type.Initialize'Access),
(Name => N.Tag_Name,
Kind => F.A_Private_Type_Declaration,
Action => P.Declarations.Private_Type.Initialize'Access),
(Name => N.Tag_Name,
Kind => F.A_Subtype_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Tag_Name,
Kind => F.A_Derived_Record_Extension_Definition,
Action => P.Definitions.Tagged_Record_Type.Tag_Name'Access),
(Name => N.Tag_Name,
Kind => F.A_Tagged_Record_Type_Definition,
Action => P.Definitions.Tagged_Record_Type.Tag_Name'Access),
(Name => N.Tag_Name,
Kind => F.A_Limited_Interface,
Action => P.Definitions.Tagged_Record_Type.Tag_Name'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Initialize'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Derived_Type_Definition,
Action => P.Definitions.Derived_Type.Bounds'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Code'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Floating_Point_Definition,
Action => P.Definitions.Float_Point.Typed_Array_Item_Type'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Modular_Type_Definition,
Action => P.Definitions.Modular.Typed_Array_Item_Type'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Signed_Integer_Type_Definition,
Action => P.Definitions.Signed.Typed_Array_Item_Type'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Constrained_Array_Definition,
Action => P.Common.Empty'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Record_Type_Definition,
Action => P.Common.Empty'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Bounds'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Private_Type_Declaration,
Action => P.Declarations.Private_Type.Initialize'Access),
(Name => N.Typed_Array_Item_Type,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components
.Typed_Array_Item_Type'Access),
(Name => N.Typed_Array_Initialize,
Kind => F.A_Positional_Array_Aggregate,
Action => P.Expressions.Pos_Array_Aggregate
.Typed_Array_Initialize'Access),
(Name => N.Typed_Array_Initialize,
Kind => F.A_Record_Aggregate,
Action => P.Expressions.Record_Aggregate.Typed_Array_Initialize'Access)
);
Range_List : constant Range_Array :=
((N.Code,
F.An_And_Operator, F.A_Not_Operator,
P.Expressions.Identifiers.Code'Access),
(N.Code,
F.A_Defining_And_Operator, F.A_Defining_Not_Operator,
Action => P.Declarations.Defining_Names.Code'Access),
(N.Code,
F.An_Access_Attribute, F.An_Implementation_Defined_Attribute,
P.Expressions.Attribute_Reference.Code'Access),
(N.Intrinsic_Name,
F.An_Access_Attribute, F.An_Unknown_Attribute,
P.Expressions.Attribute_Reference.Intrinsic_Name'Access),
(N.Intrinsic_Name,
F.An_And_Operator, F.A_Not_Operator,
P.Expressions.Identifiers.Intrinsic_Name'Access),
(N.Method_Name,
F.A_Defining_And_Operator, F.A_Defining_Not_Operator,
Action => P.Declarations.Defining_Names.Method_Name'Access));
Integer_Actions : constant array (Positive range <>) of Integer_Action_Item
:=
((Name => N.Alignment,
Kind => F.A_Subtype_Indication,
Action => P.Definitions.Subtype_Indication.Alignment'Access),
(Name => N.Alignment,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Alignment'Access),
(Name => N.Alignment,
Kind => F.An_Ordinary_Type_Declaration,
Action => P.Declarations.Ordinary_Type.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Component_Declaration,
Action => P.Declarations.Component_Declaration.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Component_Definition,
Action => P.Definitions.Component_Definition.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Derived_Type_Definition,
Action => P.Definitions.Derived_Type.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Record_Type_Definition,
Action => P.Definitions.Record_Type.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Floating_Point_Definition,
Action => P.Definitions.Float_Point.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Modular_Type_Definition,
Action => P.Definitions.Modular.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Signed_Integer_Type_Definition,
Action => P.Definitions.Modular.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Private_Type_Declaration,
Action => P.Declarations.Private_Type.Alignment'Access),
(Name => N.Alignment,
Kind => F.A_Constrained_Array_Definition,
Action => P.Definitions.Constrained_Array_Type.Alignment'Access));
Boolean_Actions : constant array (Positive range <>) of Boolean_Action_Item
:=
((Name => N.Export,
Kind => F.A_Function_Body_Declaration,
Action => P.Declarations.Procedure_Body_Declarations.Export'Access),
(Name => N.Export,
Kind => F.A_Function_Declaration,
Action => P.Declarations.Function_Declarations.Export'Access),
(Name => N.Export,
Kind => F.A_Procedure_Body_Declaration,
Action => P.Declarations.Procedure_Body_Declarations.Export'Access),
(Name => N.Export,
Kind => F.A_Procedure_Declaration,
Action => P.Declarations.Function_Declarations.Export'Access),
(Kind => F.A_Parameter_Specification,
Name => N.Has_Simple_Output,
Action => P.Declarations.Constant_Declarations
.Has_Simple_Output'Access),
(Name => N.Has_Simple_Output,
Kind => F.A_Procedure_Body_Declaration,
Action => P.Declarations.Procedure_Body_Declarations
.Has_Simple_Output'Access),
(Name => N.Has_Simple_Output,
Kind => F.A_Function_Body_Declaration,
Action => P.Declarations.Procedure_Body_Declarations
.Has_Simple_Output'Access),
(Kind => F.A_Function_Declaration,
Name => N.Is_Dispatching,
Action => P.Declarations.Function_Declarations.Is_Dispatching'Access),
(Kind => F.A_Procedure_Declaration,
Name => N.Is_Dispatching,
Action => P.Declarations.Function_Declarations.Is_Dispatching'Access),
(Kind => F.A_Null_Procedure_Declaration,
Name => N.Is_Dispatching,
Action => P.Declarations.Function_Declarations.Is_Dispatching'Access),
(Kind => F.A_Function_Body_Declaration,
Name => N.Is_Dispatching,
Action =>
P.Declarations.Procedure_Body_Declarations.Is_Dispatching'Access),
(Kind => F.A_Procedure_Body_Declaration,
Name => N.Is_Dispatching,
Action =>
P.Declarations.Procedure_Body_Declarations.Is_Dispatching'Access),
(Kind => F.A_Selected_Component,
Name => N.Is_Dispatching,
Action => P.Expressions.Selected_Components.Is_Dispatching'Access),
(Kind => F.An_Identifier,
Name => N.Is_Dispatching,
Action => P.Expressions.Identifiers.Is_Dispatching'Access),
(Kind => F.A_Function_Renaming_Declaration,
Name => N.Is_Dispatching,
Action => P.Declarations.Function_Renaming_Declaration
.Is_Dispatching'Access),
(Kind => F.A_Procedure_Renaming_Declaration,
Name => N.Is_Dispatching,
Action => P.Declarations.Function_Renaming_Declaration
.Is_Dispatching'Access),
(Name => N.Is_Dispatching,
Kind => F.A_Procedure_Instantiation,
Action =>
P.Declarations.Subprogram_Instantiation.Is_Dispatching'Access),
(Name => N.Is_Dispatching,
Kind => F.A_Function_Instantiation,
Action =>
P.Declarations.Subprogram_Instantiation.Is_Dispatching'Access),
(Name => N.Is_Dispatching,
Kind => F.A_Generic_Procedure_Declaration,
Action => P.Common.False'Access),
(Name => N.Is_Dispatching,
Kind => F.A_Generic_Function_Declaration,
Action => P.Common.False'Access),
(Kind => F.An_Object_Renaming_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Constant_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Return_Constant_Specification,
Name => N.Is_Simple_Ref,
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Return_Variable_Specification,
Name => N.Is_Simple_Ref,
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Deferred_Constant_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Component_Declaration,
Name => N.Is_Simple_Ref, -- The same as constant
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Discriminant_Specification,
Name => N.Is_Simple_Ref, -- The same as constant
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Variable_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.A_Parameter_Specification,
Name => N.Is_Simple_Ref,
Action => P.Declarations.Constant_Declarations.Is_Simple_Ref'Access),
(Kind => F.An_Ordinary_Type_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Private_Type_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Private_Extension_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Subtype_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Procedure_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Function_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Function_Renaming_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Procedure_Renaming_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Null_Procedure_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Procedure_Instantiation,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Function_Instantiation,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.An_Element_Iterator_Specification,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Loop_Parameter_Specification,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.An_Integer_Number_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.A_Real_Number_Declaration,
Name => N.Is_Simple_Ref,
Action => P.Common.False'Access),
(Kind => F.An_Indexed_Component,
Name => N.Is_Simple_Ref,
Action => P.Expressions.Indexed_Component.Is_Simple_Ref'Access),
(Kind => F.A_Component_Definition,
Name => N.Is_Simple_Ref,
Action => P.Definitions.Component_Definition.Is_Simple_Ref'Access),
(Kind => F.A_Subtype_Indication,
Name => N.Is_Simple_Type,
Action => P.Definitions.Subtype_Indication.Is_Simple_Type'Access),
(Kind => F.A_Selected_Component,
Name => N.Is_Simple_Type,
Action => P.Expressions.Selected_Components.Is_Dispatching'Access),
(Kind => F.An_Identifier,
Name => N.Is_Simple_Type,
Action => P.Expressions.Identifiers.Is_Dispatching'Access),
(Kind => F.An_Ordinary_Type_Declaration,
Name => N.Is_Simple_Type,
Action => P.Declarations.Ordinary_Type.Is_Simple_Type'Access),
(Kind => F.A_Subtype_Declaration,
Name => N.Is_Simple_Type,
Action => P.Declarations.Ordinary_Type.Is_Simple_Type'Access),
(Kind => F.A_Private_Type_Declaration,
Name => N.Is_Simple_Type,
Action => P.Declarations.Private_Type.Is_Simple_Type'Access),
(Kind => F.A_Tagged_Incomplete_Type_Declaration,
Name => N.Is_Simple_Type,
Action => P.Common.False'Access),
(Kind => F.An_Incomplete_Type_Declaration,
Name => N.Is_Simple_Type,
Action => P.Declarations.Incomplete_Type.Is_Simple_Type'Access),
(Kind => F.An_Enumeration_Type_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Enumeration_Type.Is_Simple_Type'Access),
(Kind => F.A_Signed_Integer_Type_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Enumeration_Type.Is_Simple_Type'Access),
(Kind => F.A_Modular_Type_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Enumeration_Type.Is_Simple_Type'Access),
(Kind => F.A_Floating_Point_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Enumeration_Type.Is_Simple_Type'Access),
(Kind => F.A_Universal_Real_Definition,
Name => N.Is_Simple_Type,
Action => P.Common.True'Access),
(Kind => F.An_Access_To_Variable,
Name => N.Is_Simple_Type,
Action => P.Definitions.Enumeration_Type.Is_Simple_Type'Access),
(Kind => F.An_Access_To_Constant,
Name => N.Is_Simple_Type,
Action => P.Definitions.Enumeration_Type.Is_Simple_Type'Access),
(Kind => F.A_Record_Type_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Constrained_Array_Type.Is_Simple_Type'Access),
(Kind => F.A_Private_Extension_Declaration,
Name => N.Is_Simple_Type,
Action => P.Definitions.Constrained_Array_Type.Is_Simple_Type'Access),
(Kind => F.A_Derived_Type_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Derived_Type.Is_Simple_Type'Access),
(Kind => F.A_Derived_Record_Extension_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Tagged_Record_Type.Is_Simple_Type'Access),
(Kind => F.A_Tagged_Record_Type_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Tagged_Record_Type.Is_Simple_Type'Access),
(Kind => F.A_Limited_Interface,
Name => N.Is_Simple_Type,
Action => P.Definitions.Constrained_Array_Type.Is_Simple_Type'Access),
(Kind => F.A_Constrained_Array_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Constrained_Array_Type.Is_Simple_Type'Access),
(Kind => F.An_Unconstrained_Array_Definition,
Name => N.Is_Simple_Type,
Action => P.Definitions.Constrained_Array_Type.Is_Simple_Type'Access),
(Kind => F.A_Class_Attribute,
Name => N.Is_Simple_Type,
Action => P.Common.False'Access),
(Kind => F.A_Base_Attribute,
Name => N.Is_Simple_Type,
Action => P.Common.True'Access),
(Kind => F.An_Anonymous_Access_To_Constant,
Name => N.Is_Simple_Type,
Action => P.Common.True'Access),
(Kind => F.An_Anonymous_Access_To_Variable,
Name => N.Is_Simple_Type,
Action => P.Common.True'Access),
(Kind => F.A_Constrained_Array_Definition,
Name => N.Is_Array_Of_Simple,
Action => P.Definitions.Constrained_Array_Type
.Is_Array_Of_Simple'Access),
(Kind => F.An_Unconstrained_Array_Definition,
Name => N.Is_Array_Of_Simple,
Action => P.Definitions.Constrained_Array_Type
.Is_Array_Of_Simple'Access));
begin
for X of Action_List loop
Self.Text.Register_Calculator (X.Kind, X.Name, X.Action);
end loop;
for X of Range_List loop
for J in X.From .. X.To loop
Self.Text.Register_Calculator (J, X.Name, X.Action);
end loop;
end loop;
-- Call_Convention
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Function_Call,
Action => P.Expressions.Function_Calls.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.An_Identifier,
Action => P.Expressions.Identifiers.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Function_Declaration,
Action => P.Declarations.Function_Declarations.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Function_Renaming_Declaration,
Action => P.Declarations.Function_Renaming_Declaration
.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Procedure_Renaming_Declaration,
Action => P.Declarations.Function_Renaming_Declaration
.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Procedure_Declaration,
Action => P.Declarations.Procedure_Declaration.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Null_Procedure_Declaration,
Action => P.Declarations.Procedure_Declaration.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Selected_Component,
Action => P.Expressions.Selected_Components.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Procedure_Instantiation,
Action =>
P.Declarations.Subprogram_Instantiation.Call_Convention'Access);
Self.Call_Convention.Register_Calculator
(Name => N.Call_Convention,
Kind => F.A_Function_Instantiation,
Action =>
P.Declarations.Subprogram_Instantiation.Call_Convention'Access);
for X in F.An_And_Operator .. F.A_Not_Operator loop
Self.Call_Convention.Register_Calculator
(Kind => X,
Name => N.Call_Convention,
Action => P.Expressions.Identifiers.Call_Convention'Access);
end loop;
for X in F.An_Access_Attribute .. F.An_Unknown_Attribute loop
Self.Call_Convention.Register_Calculator
(Kind => X,
Name => N.Call_Convention,
Action => P.Expressions.Attribute_Reference.Call_Convention'Access);
end loop;
for X in F.Flat_Declaration_Kinds loop
Self.Boolean.Register_Calculator
(Kind => X,
Name => N.Inside_Package,
Action => P.Declarations.Inside_Package'Access);
end loop;
for X in F.An_And_Operator .. F.A_Not_Operator loop
Self.Boolean.Register_Calculator
(Kind => X,
Name => N.Is_Dispatching,
Action => P.Expressions.Identifiers.Is_Dispatching'Access);
end loop;
for X of Integer_Actions loop
Self.Integer.Register_Calculator
(Kind => X.Kind,
Name => X.Name,
Action => X.Action);
end loop;
for X of Boolean_Actions loop
Self.Boolean.Register_Calculator
(Kind => X.Kind,
Name => X.Name,
Action => X.Action);
end loop;
end Engines.Registry_All_Actions;
|
reznikmm/matreshka | Ada | 35,508 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Classifiers;
with AMF.String_Collections;
with AMF.UML.Artifacts.Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Manifestations.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Operations.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors;
package AMF.Internals.UML_Artifacts is
type UML_Artifact_Proxy is
limited new AMF.Internals.UML_Classifiers.UML_Classifier_Proxy
and AMF.UML.Artifacts.UML_Artifact with null record;
overriding function Get_File_Name
(Self : not null access constant UML_Artifact_Proxy)
return AMF.Optional_String;
-- Getter of Artifact::fileName.
--
-- A concrete name that is used to refer to the Artifact in a physical
-- context. Example: file system name, universal resource locator.
overriding procedure Set_File_Name
(Self : not null access UML_Artifact_Proxy;
To : AMF.Optional_String);
-- Setter of Artifact::fileName.
--
-- A concrete name that is used to refer to the Artifact in a physical
-- context. Example: file system name, universal resource locator.
overriding function Get_Manifestation
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Manifestations.Collections.Set_Of_UML_Manifestation;
-- Getter of Artifact::manifestation.
--
-- The set of model elements that are manifested in the Artifact. That is,
-- these model elements are utilized in the construction (or generation)
-- of the artifact.
overriding function Get_Nested_Artifact
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Artifacts.Collections.Set_Of_UML_Artifact;
-- Getter of Artifact::nestedArtifact.
--
-- The Artifacts that are defined (nested) within the Artifact. The
-- association is a specialization of the ownedMember association from
-- Namespace to NamedElement.
overriding function Get_Owned_Attribute
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property;
-- Getter of Artifact::ownedAttribute.
--
-- The attributes or association ends defined for the Artifact. The
-- association is a specialization of the ownedMember association.
overriding function Get_Owned_Operation
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation;
-- Getter of Artifact::ownedOperation.
--
-- The Operations defined for the Artifact. The association is a
-- specialization of the ownedMember association.
overriding function Get_Attribute
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
overriding function Get_Collaboration_Use
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
overriding function Get_Feature
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
overriding function Get_General
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
overriding function Get_Generalization
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
overriding function Get_Inherited_Member
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
overriding function Get_Is_Abstract
(Self : not null access constant UML_Artifact_Proxy)
return Boolean;
-- Getter of Classifier::isAbstract.
--
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding function Get_Is_Final_Specialization
(Self : not null access constant UML_Artifact_Proxy)
return Boolean;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding procedure Set_Is_Final_Specialization
(Self : not null access UML_Artifact_Proxy;
To : Boolean);
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access);
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Owned_Use_Case
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
overriding function Get_Powertype_Extent
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
overriding function Get_Redefined_Classifier
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
overriding function Get_Representation
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding procedure Set_Representation
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access);
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding function Get_Substitution
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access);
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Use_Case
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
overriding function Get_Element_Import
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Artifact_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Package
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Packages.UML_Package_Access;
-- Getter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding procedure Set_Package
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.Packages.UML_Package_Access);
-- Setter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Artifact_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access);
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Template_Binding
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Artifact_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Artifact_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function All_Features
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
overriding function Conforms_To
(Self : not null access constant UML_Artifact_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::conformsTo.
--
-- The query conformsTo() gives true for a classifier that defines a type
-- that conforms to another. This is used, for example, in the
-- specification of signature conformance for operations.
overriding function General
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
overriding function Has_Visibility_Of
(Self : not null access constant UML_Artifact_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
overriding function Inherit
(Self : not null access constant UML_Artifact_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inherit.
--
-- The query inherit() defines how to inherit a set of elements. Here the
-- operation is defined to inherit them all. It is intended to be
-- redefined in circumstances where inheritance is affected by
-- redefinition.
-- The inherit operation is overridden to exclude redefined properties.
overriding function Inheritable_Members
(Self : not null access constant UML_Artifact_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
overriding function Inherited_Member
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant UML_Artifact_Proxy)
return Boolean;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
overriding function May_Specialize_Type
(Self : not null access constant UML_Artifact_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
overriding function Exclude_Collisions
(Self : not null access constant UML_Artifact_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant UML_Artifact_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant UML_Artifact_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Artifact_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Artifact_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Conforms_To
(Self : not null access constant UML_Artifact_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean;
-- Operation Type::conformsTo.
--
-- The query conformsTo() gives true for a type that conforms to another.
-- By default, two types do not conform to each other. This query is
-- intended to be redefined for specific conformance situations.
overriding function Is_Compatible_With
(Self : not null access constant UML_Artifact_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UML_Artifact_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Parameterable_Elements
(Self : not null access constant UML_Artifact_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
overriding function Is_Consistent_With
(Self : not null access constant UML_Artifact_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Artifact_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding procedure Enter_Element
(Self : not null access constant UML_Artifact_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Artifact_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Artifact_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Artifacts;
|
zhmu/ananas | Ada | 6,257 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 2 1 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_121 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_121;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
------------
-- Get_121 --
------------
function Get_121
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_121
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_121;
------------
-- Set_121 --
------------
procedure Set_121
(Arr : System.Address;
N : Natural;
E : Bits_121;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_121;
end System.Pack_121;
|
zhmu/ananas | Ada | 280 | adb | -- { dg-do compile }
with Discr23_Pkg; use Discr23_Pkg;
package body Discr23 is
N : constant Text := Get;
function Try (A : in Text) return Text is
begin
return A;
exception
when others => return N;
end;
procedure Dummy is begin null; end;
end Discr23;
|
rogermc2/GA_Ada | Ada | 715 | ads |
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with GL.Types;
package Silo is
type Label_Data is private;
Empty_Stack : Exception;
procedure Get_Data (Label_String : out Unbounded_String;
Label_Position : out GL.Types.Singles.Vector2);
procedure Push (Data : Label_Data);
function Pull return Label_Data;
function Set_Data (Label_String : Unbounded_String;
Label_Position : GL.Types.Singles.Vector2)
return Label_Data;
function Size return Integer;
private
type Label_Data is record
Label_String : Unbounded_String;
Label_Position : GL.Types.Singles.Vector2;
end record;
end Silo;
|
jensew97/Exercise7 | Ada | 3,142 | adb | with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
procedure exercise7 is
Count_Failed : exception; -- Exception to be raised when counting fails
Gen : Generator; -- Random number generator
protected type Transaction_Manager (N : Positive) is
entry Finished;
function Commit return Boolean;
procedure Signal_Abort;
private
Finished_Gate_Open : Boolean := False;
Aborted : Boolean := False;
Should_Commit : Boolean := True;
end Transaction_Manager;
protected body Transaction_Manager is
entry Finished when Finished_Gate_Open or Finished'Count = N is
begin
------------------------------------------
-- PART 3: Complete the exit protocol here
------------------------------------------
end Finished;
procedure Signal_Abort is
begin
Aborted := True;
end Signal_Abort;
function Commit return Boolean is
begin
return Should_Commit;
end Commit;
end Transaction_Manager;
function Unreliable_Slow_Add (x : Integer) return Integer is
Error_Rate : Constant := 0.15; -- (between 0 and 1)
begin
-------------------------------------------
-- PART 1: Create the transaction work here
-------------------------------------------
end Unreliable_Slow_Add;
task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager);
task body Transaction_Worker is
Num : Integer := Initial;
Prev : Integer := Num;
Round_Num : Integer := 0;
begin
Put_Line ("Worker" & Integer'Image(Initial) & " started");
loop
Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num));
Round_Num := Round_Num + 1;
---------------------------------------
-- PART 2: Do the transaction work here
---------------------------------------
if Manager.Commit = True then
Put_Line (" Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num));
else
Put_Line (" Worker" & Integer'Image(Initial) &
" reverting from" & Integer'Image(Num) &
" to" & Integer'Image(Prev));
-------------------------------------------
-- PART 2: Roll back to previous value here
-------------------------------------------
end if;
Prev := Num;
delay 0.5;
end loop;
end Transaction_Worker;
Manager : aliased Transaction_Manager (3);
Worker_1 : Transaction_Worker (0, Manager'Access);
Worker_2 : Transaction_Worker (1, Manager'Access);
Worker_3 : Transaction_Worker (2, Manager'Access);
begin
Reset(Gen); -- Seed the random number generator
end exercise7;
|
reznikmm/matreshka | Ada | 4,566 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Svg.Ascent_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Ascent_Attribute_Node is
begin
return Self : Svg_Ascent_Attribute_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Svg_Ascent_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Ascent_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Ascent_Attribute,
Svg_Ascent_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Ascent_Attributes;
|
onox/orka | Ada | 1,103 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.SIMD.SSE2.Integers;
package Orka.SIMD.SSE4_1.Integers.Logical is
pragma Pure;
use SIMD.SSE2.Integers;
function Test_All_Zero (Elements, Mask : m128i) return Boolean
with Inline_Always;
function Test_All_Ones (Elements, Mask : m128i) return Boolean
with Inline_Always;
function Test_Mix_Ones_Zeros (Elements, Mask : m128i) return Boolean
with Inline_Always;
end Orka.SIMD.SSE4_1.Integers.Logical;
|
reznikmm/matreshka | Ada | 3,764 | 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_Force_Manual_Attributes is
pragma Preelaborate;
type ODF_Presentation_Force_Manual_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Presentation_Force_Manual_Attribute_Access is
access all ODF_Presentation_Force_Manual_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Presentation_Force_Manual_Attributes;
|
reznikmm/matreshka | Ada | 3,669 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Text_Ruby_Text_Elements is
pragma Preelaborate;
type ODF_Text_Ruby_Text is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Ruby_Text_Access is
access all ODF_Text_Ruby_Text'Class
with Storage_Size => 0;
end ODF.DOM.Text_Ruby_Text_Elements;
|
reznikmm/matreshka | Ada | 4,703 | 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.Fill_Image_Ref_Point_Y_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Fill_Image_Ref_Point_Y_Attribute_Node is
begin
return Self : Draw_Fill_Image_Ref_Point_Y_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_Fill_Image_Ref_Point_Y_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Fill_Image_Ref_Point_Y_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Fill_Image_Ref_Point_Y_Attribute,
Draw_Fill_Image_Ref_Point_Y_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Fill_Image_Ref_Point_Y_Attributes;
|
reznikmm/matreshka | Ada | 5,032 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body League.Holders.Generic_Holders is
-----------------
-- Constructor --
-----------------
overriding function Constructor
(Is_Empty : not null access Boolean) return Element_Container
is
pragma Assert (Is_Empty.all);
begin
return
(Counter => <>,
Is_Empty => Is_Empty.all,
Value => <>);
end Constructor;
-------------
-- Element --
-------------
function Element (Self : Holder) return Element_Type is
begin
if Self.Data.all not in Element_Container then
raise Constraint_Error with "invalid type of value";
end if;
if Self.Data.Is_Empty then
raise Constraint_Error with "value is empty";
end if;
return Element_Container'Class (Self.Data.all).Value;
end Element;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element (Self : in out Holder; To : Element_Type) is
begin
if Self.Data.all not in Element_Container then
raise Constraint_Error with "invalid type of value";
end if;
-- XXX This subprogram can be improved to reuse shared segment when
-- possible.
Dereference (Self.Data);
Self.Data :=
new Element_Container'(Counter => <>, Is_Empty => False, Value => To);
end Replace_Element;
---------------
-- To_Holder --
---------------
function To_Holder (Item : Element_Type) return Holder is
begin
return
(Ada.Finalization.Controlled with
new Element_Container'
(Counter => <>, Is_Empty => False, Value => Item));
end To_Holder;
end League.Holders.Generic_Holders;
|
charlie5/aIDE | Ada | 2,587 | adb | with
AdaM.Factory,
AdaM.Entity,
AdaM.a_Package;
package body AdaM.Declaration.of_exception
is
-- Storage Pool
--
record_Version : constant := 1;
pool_Size : constant := 5_000;
package Pool is new AdaM.Factory.Pools (".adam-store",
"Declarations.of_exception",
pool_Size,
record_Version,
Declaration.of_exception.item,
Declaration.of_exception.view);
-- Forge
--
procedure define (Self : in out Item; Name : in String)
is
begin
Self.Name := +Name;
end define;
overriding
procedure destruct (Self : in out Item)
is
begin
null;
end destruct;
function new_Declaration (Name : in String) return Declaration.of_exception.view
is
new_View : constant Declaration.of_exception.view := Pool.new_Item;
begin
define (Declaration.of_exception.item (new_View.all), Name);
return new_View;
end new_Declaration;
procedure free (Self : in out Declaration.of_exception.view)
is
begin
destruct (Declaration.of_exception.item (Self.all));
Pool.free (Self);
end free;
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id
is
begin
return Pool.to_Id (Self);
end Id;
function full_Name (Self : in Item) return Identifier
is
use type Entity.view;
begin
if Self.parent_Entity = null
then
return "Standard." & (+Self.Name);
else
return a_Package.view (Self.parent_Entity).full_Name & "." & (+Self.Name);
end if;
end full_Name;
overriding
function to_Source (Self : in Item) return text_Vectors.Vector
is
use ada.Strings.Unbounded;
the_Line : Text;
the_Source : text_Vectors.Vector;
begin
append (the_Line, Self.Name);
append (the_Line, " : exception;");
the_Source.append (the_Line);
return the_Source;
end to_Source;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View)
renames Pool.View_write;
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View)
renames Pool.View_read;
end AdaM.Declaration.of_exception;
|
AdaCore/training_material | Ada | 107 | ads | package Weights is
type Weight is tagged null record;
procedure P (O : Weight) is null;
end Weights;
|
reznikmm/matreshka | Ada | 4,711 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body Fixeds is
-------------------------------
-- Decimal_Fixed_Conversions --
-------------------------------
package body Decimal_Fixed_Conversions is
--------------------------
-- From_Universal_Fixed --
--------------------------
function From_Universal_Fixed (Value : Universal_Fixed) return Num is
begin
return 0.0;
end From_Universal_Fixed;
------------------------
-- To_Universal_Fixed --
------------------------
function To_Universal_Fixed (Value : Num) return Universal_Fixed is
begin
return (0, 0);
end To_Universal_Fixed;
end Decimal_Fixed_Conversions;
--------------------------------
-- Ordinary_Fixed_Conversions --
--------------------------------
package body Ordinary_Fixed_Conversions is
--------------------------
-- From_Universal_Fixed --
--------------------------
function From_Universal_Fixed (Value : Universal_Fixed) return Num is
begin
return 0.0;
end From_Universal_Fixed;
------------------------
-- To_Universal_Fixed --
------------------------
function To_Universal_Fixed (Value : Num) return Universal_Fixed is
begin
return (0, 0);
end To_Universal_Fixed;
end Ordinary_Fixed_Conversions;
end Fixeds;
|
damaki/SPARKNaCl | Ada | 3,826 | adb | with HAL; use HAL;
with HiFive1.LEDs; use HiFive1.LEDs;
with FE310;
with FE310.CLINT;
with FE310.Time; use FE310.Time;
with Interfaces; use Interfaces;
with IO;
with SPARKNaCl; use SPARKNaCl;
with SPARKNaCl.Core; use SPARKNaCl.Core;
with SPARKNaCl.Stream; use SPARKNaCl.Stream;
with TweetNaCl_API;
with RISCV.CSR; use RISCV.CSR;
with FE310.Performance_Monitor; use FE310.Performance_Monitor;
procedure TCore is
subtype U64 is Unsigned_64;
C1, C2 : Byte_Seq (0 .. 2047);
N : HSalsa20_Nonce;
K : Salsa20_Key;
T1, T2 : UInt64;
Total_Time : Unsigned_64;
CPU_Hz1, CPU_Hz2 : UInt32;
procedure Report;
procedure Report
is
begin
IO.Put_Line ("Total time: ", Total_Time);
end Report;
procedure Tweet_HSalsa20 (C : out Byte_Seq; -- Output stream
N : in HSalsa20_Nonce; -- Nonce
K : in Salsa20_Key); -- Key
procedure Tweet_HSalsa20 (C : out Byte_Seq;
N : in HSalsa20_Nonce;
K : in Salsa20_Key)
is
begin
TweetNaCl_API.HSalsa20 (C, U64 (C'Length), N, K);
end Tweet_HSalsa20;
begin
CPU_Hz1 := FE310.CPU_Frequency;
-- The SPI flash clock divider should be as small as possible to increase
-- the execution speed of instructions that are not yet in the instruction
-- cache.
FE310.Set_SPI_Flash_Clock_Divider (2);
-- Load the internal oscillator factory calibration to be sure it
-- oscillates at a known frequency.
FE310.Load_Internal_Oscilator_Calibration;
-- Use the HiFive1 16 MHz crystal oscillator which is more acurate than the
-- internal oscillator.
FE310.Use_Crystal_Oscillator;
HiFive1.LEDs.Initialize;
CPU_Hz2 := FE310.CPU_Frequency;
IO.Put_Line ("CPU Frequency reset was: ", U64 (CPU_Hz1));
IO.Put_Line ("CPU Frequency now is: ", U64 (CPU_Hz2));
FE310.Performance_Monitor.Set_Commit_Events (3, No_Commit_Events);
FE310.Performance_Monitor.Set_Commit_Events (4, No_Commit_Events);
Turn_On (Red_LED);
T1 := FE310.CLINT.Machine_Time;
T2 := FE310.CLINT.Machine_Time;
IO.Put_Line ("Null timing test:", U64 (T2 - T1));
T1 := Mcycle.Read;
Delay_S (1);
T2 := Mcycle.Read;
IO.Put_Line ("One second test (CYCLE): ", U64 (T2 - T1));
T1 := Minstret.Read;
Delay_S (1);
T2 := Minstret.Read;
IO.Put_Line ("One second test (INSTRET):", U64 (T2 - T1));
T1 := FE310.CLINT.Machine_Time;
Delay_S (1);
T2 := FE310.CLINT.Machine_Time;
IO.Put_Line ("One second test (CLINT): ", U64 (T2 - T1));
IO.Put_Line ("SPARKNaCl.Stream.HSalsa20 test");
-- Arbitrary nonce.
N := (0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23);
-- Arbitrary key
Construct (K, Bytes_32'(5, 1, 5, 1, 5, 1, 5, 1,
5, 1, 5, 1, 5, 1, 5, 1,
5, 1, 5, 1, 5, 1, 5, 1,
5, 1, 5, 1, 5, 1, 5, 1));
T1 := Mcycle.Read;
SPARKNaCl.Stream.HSalsa20 (C1, N, K);
T2 := Mcycle.Read;
Total_Time := Unsigned_64 (T2 - T1);
Report;
Turn_Off (Red_LED);
Turn_On (Green_LED);
IO.New_Line;
IO.Put_Line ("TweetNaCl.Core test");
T1 := Mcycle.Read;
Tweet_HSalsa20 (C2, N, K);
T2 := Mcycle.Read;
Total_Time := Unsigned_64 (T2 - T1);
Report;
if C1 = C2 then
IO.Put ("Pass");
else
IO.Put ("Fail");
end if;
IO.New_Line;
IO.New_Line;
Turn_Off (Green_LED);
-- Blinky!
loop
Turn_On (Red_LED);
Delay_S (1);
Turn_Off (Red_LED);
Turn_On (Green_LED);
Delay_S (1);
Turn_Off (Green_LED);
Turn_On (Blue_LED);
Delay_S (1);
Turn_Off (Blue_LED);
end loop;
end TCore;
|
reznikmm/matreshka | Ada | 4,592 | 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_Xlink.Actuate_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Xlink_Actuate_Attribute_Node is
begin
return Self : Xlink_Actuate_Attribute_Node do
Matreshka.ODF_Xlink.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Xlink_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Xlink_Actuate_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Actuate_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Xlink_URI,
Matreshka.ODF_String_Constants.Actuate_Attribute,
Xlink_Actuate_Attribute_Node'Tag);
end Matreshka.ODF_Xlink.Actuate_Attributes;
|
GPUWorks/lumen2 | Ada | 978 | ads |
-- Lumen.Font -- Display textual information
--
-- Chip Richards, NiEstu, Phoenix AZ, Summer 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
package Lumen.Font is
pragma Pure (Lumen.Font);
end Lumen.Font;
|
LiberatorUSA/GUCEF | Ada | 20,571 | adb | package body agar.gui.widget.numerical is
use type c.int;
package cbinds is
function allocate
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr) return numerical_access_t;
pragma import (c, allocate, "AG_NumericalNew");
function allocate_float
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : float_access_t) return numerical_access_t;
pragma import (c, allocate_float, "AG_NumericalNewFlt");
function allocate_float_ranged
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : float_access_t;
min : float_t;
max : float_t) return numerical_access_t;
pragma import (c, allocate_float_ranged, "AG_NumericalNewFltR");
function allocate_double
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : double_access_t) return numerical_access_t;
pragma import (c, allocate_double, "AG_NumericalNewDbl");
function allocate_double_ranged
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : double_access_t;
min : double_t;
max : double_t) return numerical_access_t;
pragma import (c, allocate_double_ranged, "AG_NumericalNewDblR");
function allocate_integer
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : integer_access_t) return numerical_access_t;
pragma import (c, allocate_integer, "AG_NumericalNewInt");
function allocate_integer_ranged
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : integer_access_t;
min : integer_t;
max : integer_t) return numerical_access_t;
pragma import (c, allocate_integer_ranged, "AG_NumericalNewIntR");
function allocate_unsigned
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : unsigned_access_t) return numerical_access_t;
pragma import (c, allocate_unsigned, "AG_NumericalNewUint");
function allocate_unsigned_ranged
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : unsigned_access_t;
min : unsigned_t;
max : unsigned_t) return numerical_access_t;
pragma import (c, allocate_unsigned_ranged, "AG_NumericalNewUintR");
function allocate_uint8
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : agar.core.types.uint8_ptr_t) return numerical_access_t;
pragma import (c, allocate_uint8, "AG_NumericalNewUint8");
function allocate_uint16
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : agar.core.types.uint16_ptr_t) return numerical_access_t;
pragma import (c, allocate_uint16, "AG_NumericalNewUint16");
function allocate_uint32
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : agar.core.types.uint32_ptr_t) return numerical_access_t;
pragma import (c, allocate_uint32, "AG_NumericalNewUint32");
function allocate_int8
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : agar.core.types.int8_ptr_t) return numerical_access_t;
pragma import (c, allocate_int8, "AG_NumericalNewSint8");
function allocate_int16
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : agar.core.types.int16_ptr_t) return numerical_access_t;
pragma import (c, allocate_int16, "AG_NumericalNewSint16");
function allocate_int32
(parent : widget_access_t;
flags : flags_t;
unit : cs.chars_ptr;
label : cs.chars_ptr;
value : agar.core.types.int32_ptr_t) return numerical_access_t;
pragma import (c, allocate_int32, "AG_NumericalNewSint32");
function set_unit_system
(numerical : numerical_access_t;
unit : cs.chars_ptr) return c.int;
pragma import (c, set_unit_system, "AG_NumericalSetUnitSystem");
procedure select_unit
(numerical : numerical_access_t;
unit : cs.chars_ptr);
pragma import (c, select_unit, "AG_NumericalSelectUnit");
procedure set_precision
(numerical : numerical_access_t;
format : cs.chars_ptr;
precision : c.int);
pragma import (c, set_precision, "AG_NumericalSetPrecision");
procedure set_writeable
(numerical : numerical_access_t;
writeable : c.int);
pragma import (c, set_writeable, "AG_NumericalSetWriteable");
end cbinds;
function allocate
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access));
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access));
end;
end if;
end allocate;
function allocate_float
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : float_access_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_float
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_float
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_float;
function allocate_float_ranged
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : float_access_t;
min : float_t;
max : float_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_float_ranged
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_float_ranged
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
end;
end if;
end allocate_float_ranged;
function allocate_double
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : double_access_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_double
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_double
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_double;
function allocate_double_ranged
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : double_access_t;
min : double_t;
max : double_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_double_ranged
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_double_ranged
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
end;
end if;
end allocate_double_ranged;
function allocate_integer
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : integer_access_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_integer
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_integer
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_integer;
function allocate_integer_ranged
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : integer_access_t;
min : integer_t;
max : integer_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_integer_ranged
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_integer_ranged
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
end;
end if;
end allocate_integer_ranged;
function allocate_unsigned
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : unsigned_access_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_unsigned
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_unsigned
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_unsigned;
function allocate_unsigned_ranged
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : unsigned_access_t;
min : unsigned_t;
max : unsigned_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_unsigned_ranged
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_unsigned_ranged
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value,
min => min,
max => max);
end;
end if;
end allocate_unsigned_ranged;
function allocate_uint8
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : agar.core.types.uint8_ptr_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_uint8
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_uint8
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_uint8;
function allocate_uint16
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : agar.core.types.uint16_ptr_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_uint16
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_uint16
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_uint16;
function allocate_uint32
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : agar.core.types.uint32_ptr_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_uint32
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_uint32
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_uint32;
function allocate_int8
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : agar.core.types.int8_ptr_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_int8
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_int8
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_int8;
function allocate_int16
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : agar.core.types.int16_ptr_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_int16
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_int16
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_int16;
function allocate_int32
(parent : widget_access_t;
flags : flags_t;
unit : string;
label : string;
value : agar.core.types.int32_ptr_t) return numerical_access_t
is
c_label : aliased c.char_array := c.to_c (label);
begin
if unit /= no_unit then
return cbinds.allocate_int32
(parent => parent,
flags => flags,
unit => cs.null_ptr,
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
else
declare
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.allocate_int32
(parent => parent,
flags => flags,
unit => cs.to_chars_ptr (c_unit'unchecked_access),
label => cs.to_chars_ptr (c_label'unchecked_access),
value => value);
end;
end if;
end allocate_int32;
function set_unit_system
(numerical : numerical_access_t;
unit : string) return boolean
is
c_unit : aliased c.char_array := c.to_c (unit);
begin
return cbinds.set_unit_system
(numerical => numerical,
unit => cs.to_chars_ptr (c_unit'unchecked_access)) = 0;
end set_unit_system;
procedure select_unit
(numerical : numerical_access_t;
unit : string)
is
c_unit : aliased c.char_array := c.to_c (unit);
begin
cbinds.select_unit
(numerical => numerical,
unit => cs.to_chars_ptr (c_unit'unchecked_access));
end select_unit;
procedure set_precision
(numerical : numerical_access_t;
format : string;
precision : positive)
is
c_format : aliased c.char_array := c.to_c (format);
begin
cbinds.set_precision
(numerical => numerical,
format => cs.to_chars_ptr (c_format'unchecked_access),
precision => c.int (precision));
end set_precision;
procedure set_writeable
(numerical : numerical_access_t;
writeable : boolean) is
begin
if writeable then
cbinds.set_writeable (numerical, 1);
else
cbinds.set_writeable (numerical, 0);
end if;
end set_writeable;
procedure sub_value
(numerical : numerical_access_t;
value : double_t) is
begin
add_value (numerical, 0.0 - value);
end sub_value;
function widget (numerical : numerical_access_t) return widget_access_t is
begin
return numerical.widget'access;
end widget;
end agar.gui.widget.numerical;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 159 | ads | with STM32_SVD; use STM32_SVD;
package STM32GD.USART is
pragma Preelaborate;
type USART_Data is array (Natural range <>) of Byte;
end STM32GD.USART;
|
druzzt/NIEZAWODNE_SYSTEMY_INFORMATYCZNE | Ada | 3,905 | ads | package Railway with SPARK_Mode is
type One_Signal_State is (Red, Green);
type Route_Type is (Route_Left_Middle, -- lewy do srodkowego
Route_Middle_Right, -- srodkowy do prawego
Route_Right_Middle, -- prawy do srodkowego
Route_Middle_Left, -- srodkowy do lewego
Route_Enter_Left, -- wjazd z lewej
Route_Leave_Right, -- wyjazd z prawej
Route_Enter_Right, -- wjazd z prawej
Route_Leave_Left); -- wyjazd z lewej
type One_Segment_State is (Occupied_Standing, -- zajety, stoi
Occupied_Moving_Left, -- zajety, w lewo
Occupied_Moving_Right, -- zajety, w prawo
Reserved_Moving_From_Left, -- resvd, mv z lew
Reserved_Moving_From_Right, -- rsvd, mv z praw
Free); -- WOLNE
type Segment_State_Type is
record
Left, -- lewy segment
Middle, -- srodkowy segment
Right : One_Segment_State; -- prawy segment
end record;
type Signal_State_Type is
record
Left_Middle, -- lewy do srodkowego stan
Middle_Left, -- srodkowy do lewego stan
Middle_Right, -- srodkowy do prawego stan
Right_Middle: One_Signal_State; -- prawy do srodkowego stan
end record;
Segment_State : Segment_State_Type := (others => Free); -- stan segmentu
Signal_State : Signal_State_Type := (others => Red); -- stan sygnalizatora
function Correct_Signals return Boolean
is
(
(if Signal_State.Left_Middle = Green then
Segment_State.Left = Occupied_Moving_Right and
Segment_State.Middle = Reserved_Moving_From_Left) and then
(if Signal_state.Middle_Left = Green then
Segment_State.Middle = Occupied_Moving_Left and
Segment_State.Left = Reserved_Moving_From_Right) and then
(if Signal_state.Middle_Right = Green then
Segment_State.Middle = Occupied_Moving_Right and
Segment_State.Right = Reserved_Moving_From_Left) and then
(if Signal_state.Right_Middle = Green then
Segment_State.Right = Occupied_Moving_Left and
Segment_State.Middle = Reserved_Moving_From_Right));
function Correct_Segments return Boolean
is
(
(if Segment_State.Left /= Reserved_Moving_From_Right then
Signal_State.Middle_Left = Red) and
(if Segment_State.Middle /= Reserved_Moving_From_Left then
Signal_State.Left_Middle = Red) and
(if Segment_State.Middle /= Reserved_Moving_From_Right then
Signal_State.Right_Middle = Red) and
(if Segment_State.Right /= Reserved_Moving_From_Left then
Signal_State.Middle_Right = Red));
procedure Open_Route (Route: in Route_Type; Success: out Boolean)
with
Global => (In_Out => (Segment_State, Signal_State)),
Pre => Correct_Signals and Correct_Segments,
Depends => ((Segment_State, Success) => (Route, Segment_State),
Signal_State => (Segment_State, Route, Signal_State)),
Post => Correct_Signals and Correct_Segments;
procedure Move_Train (Route: in Route_Type; Success: out Boolean)
with
Global => (In_Out => (Segment_State, Signal_State)),
Pre => Correct_Signals and Correct_Segments,
Depends => ((Segment_State, Success) => (Route, Segment_State),
Signal_State => (Segment_State, Route, Signal_State)),
Post => Correct_Signals and Correct_Segments;
--Just to Open_Route and then if possible Move_Train.
procedure Train (Route : in Route_Type; retval : in out Boolean);
end Railway;
|
reznikmm/matreshka | Ada | 7,002 | 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_Office.Event_Listeners_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Office_Event_Listeners_Element_Node is
begin
return Self : Office_Event_Listeners_Element_Node do
Matreshka.ODF_Office.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Office_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Office_Event_Listeners_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_Office_Event_Listeners
(ODF.DOM.Office_Event_Listeners_Elements.ODF_Office_Event_Listeners_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 Office_Event_Listeners_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Event_Listeners_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Office_Event_Listeners_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_Office_Event_Listeners
(ODF.DOM.Office_Event_Listeners_Elements.ODF_Office_Event_Listeners_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 Office_Event_Listeners_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_Office_Event_Listeners
(Visitor,
ODF.DOM.Office_Event_Listeners_Elements.ODF_Office_Event_Listeners_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.Office_URI,
Matreshka.ODF_String_Constants.Event_Listeners_Element,
Office_Event_Listeners_Element_Node'Tag);
end Matreshka.ODF_Office.Event_Listeners_Elements;
|
zhmu/ananas | Ada | 3,252 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M _ I O --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- A simple text I/O package, used for diagnostic output in the runtime,
-- This package is also preelaborated, unlike Text_Io, and can thus be
-- with'ed by preelaborated library units. It includes only Put routines
-- for character, integer, string and a new line function
package System.IO is
pragma Preelaborate;
procedure Put (X : Integer);
procedure Put (C : Character);
procedure Put (S : String);
procedure Put_Line (S : String);
procedure New_Line (Spacing : Positive := 1);
type File_Type is limited private;
function Standard_Error return File_Type;
function Standard_Output return File_Type;
procedure Set_Output (File : File_Type);
private
type File_Type is (Stdout, Stderr);
-- Stdout = Standard_Output, Stderr = Standard_Error
pragma Inline (Standard_Error);
pragma Inline (Standard_Output);
end System.IO;
|
zhmu/ananas | Ada | 132 | ads | -- { dg-do compile }
package Synchronized2 with SPARK_Mode, Abstract_State => (State with Synchronous) is
procedure Dummy;
end;
|
stcarrez/swagger-ada | Ada | 980 | ads | -----------------------------------------------------------------------
-- openapi-testsuite - Swagger Test suite
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package OpenAPI.Testsuite is
function Suite return Util.Tests.Access_Test_Suite;
end OpenAPI.Testsuite;
|
sungyeon/drake | Ada | 1,818 | ads | pragma License (Unrestricted);
-- extended unit
package Ada.Float is
-- Ada.Decimal-like (and more) utilities for float types.
pragma Pure;
generic
type Float_Type is digits <>;
function Infinity return Float_Type;
pragma Inline (Infinity);
generic
type Float_Type is digits <>;
function NaN return Float_Type;
pragma Inline (NaN);
generic
type Float_Type is digits <>;
function Is_Infinity (X : Float_Type) return Boolean;
pragma Inline (Is_Infinity);
generic
type Float_Type is digits <>;
function Is_NaN (X : Float_Type) return Boolean;
pragma Inline (Is_NaN);
generic
type Float_Type is digits <>;
function Is_Negative (X : Float_Type) return Boolean
with Import, Convention => Intrinsic;
generic
type Dividend_Type is digits <>;
type Divisor_Type is digits <>;
type Quotient_Type is digits <>;
type Remainder_Type is digits <>;
procedure Divide (
Dividend : Dividend_Type;
Divisor : Divisor_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type);
pragma Inline (Divide);
generic
type Dividend_Type is digits <>;
type Quotient_Type is digits <>;
type Remainder_Type is digits <>;
procedure Divide_By_1 (
Dividend : Dividend_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type); -- sign of Remainder = sign of Dividend
pragma Inline (Divide_By_1);
generic
type Dividend_Type is digits <>;
type Quotient_Type is digits <>;
type Remainder_Type is digits <>;
procedure Modulo_Divide_By_1 (
Dividend : Dividend_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type); -- Remainder >= 0
pragma Inline (Modulo_Divide_By_1);
end Ada.Float;
|
ohenley/ada-util | Ada | 2,623 | adb | -----------------------------------------------------------------------
-- util-streams-buffered-encoders-tests -- Unit tests for encoding buffered streams
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with Util.Streams.Files;
with Util.Streams.Texts;
with Util.Files;
with Ada.Streams.Stream_IO;
package body Util.Streams.Buffered.Encoders.Tests is
use Util.Tests;
use Util.Streams.Files;
use Ada.Streams.Stream_IO;
package Caller is new Util.Test_Caller (Test, "Streams.Buffered.Encoders");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Encoders.Write, Read",
Test_Base64_Stream'Access);
end Add_Tests;
procedure Test_Base64_Stream (T : in out Test) is
Stream : aliased File_Stream;
Buffer : aliased Util.Streams.Buffered.Encoders.Encoding_Stream;
Print : Util.Streams.Texts.Print_Stream;
Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/test-stream.b64");
Expect : constant String := Util.Tests.Get_Path ("regtests/expect/test-stream.b64");
begin
Print.Initialize (Output => Buffer'Unchecked_Access, Size => 5);
Buffer.Initialize (Output => Stream'Unchecked_Access,
Size => 1024,
Format => Util.Encoders.BASE_64);
Stream.Create (Mode => Out_File, Name => Path);
for I in 1 .. 32 loop
Print.Write ("abcd");
Print.Write (" fghij");
Print.Write (ASCII.LF);
end loop;
Print.Flush;
Stream.Close;
Util.Tests.Assert_Equal_Files (T => T,
Expect => Expect,
Test => Path,
Message => "Base64 stream");
end Test_Base64_Stream;
end Util.Streams.Buffered.Encoders.Tests;
|
thierr26/ada-keystore | Ada | 3,042 | adb | -----------------------------------------------------------------------
-- akt -- Ada Keystore Tool
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with Util.Properties;
package body AKT is
-- ------------------------------
-- Configure the logs.
-- ------------------------------
procedure Configure_Logs (Debug : in Boolean;
Dump : in Boolean;
Verbose : in Boolean) is
Log_Config : Util.Properties.Manager;
begin
Log_Config.Set ("log4j.rootCategory", "ERROR,console");
Log_Config.Set ("log4j.appender.console", "Console");
Log_Config.Set ("log4j.appender.console.level", "ERROR");
Log_Config.Set ("log4j.appender.console.layout", "message");
Log_Config.Set ("log4j.appender.console.stderr", "true");
Log_Config.Set ("log4j.logger.Util", "FATAL");
Log_Config.Set ("log4j.logger.Util.Events", "ERROR");
Log_Config.Set ("log4j.logger.Keystore", "ERROR");
Log_Config.Set ("log4j.logger.AKT", "ERROR");
if Verbose or Debug or Dump then
Log_Config.Set ("log4j.logger.Util", "WARN");
Log_Config.Set ("log4j.logger.AKT", "INFO");
Log_Config.Set ("log4j.logger.Keystore.IO", "WARN");
Log_Config.Set ("log4j.logger.Keystore", "INFO");
Log_Config.Set ("log4j.rootCategory", "INFO,console,verbose");
Log_Config.Set ("log4j.appender.verbose", "Console");
Log_Config.Set ("log4j.appender.verbose.level", "INFO");
Log_Config.Set ("log4j.appender.verbose.layout", "level-message");
end if;
if Debug or Dump then
Log_Config.Set ("log4j.logger.Util.Processes", "INFO");
Log_Config.Set ("log4j.logger.AKT", "DEBUG");
Log_Config.Set ("log4j.logger.Keystore.IO", "INFO");
Log_Config.Set ("log4j.logger.Keystore", "DEBUG");
Log_Config.Set ("log4j.rootCategory", "DEBUG,console,debug");
Log_Config.Set ("log4j.appender.debug", "Console");
Log_Config.Set ("log4j.appender.debug.level", "DEBUG");
Log_Config.Set ("log4j.appender.debug.layout", "full");
end if;
if Dump then
Log_Config.Set ("log4j.logger.Keystore.IO", "DEBUG");
end if;
Util.Log.Loggers.Initialize (Log_Config);
end Configure_Logs;
end AKT;
|
reznikmm/matreshka | Ada | 3,809 | 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_Glue_Point_Leaving_Directions_Attributes is
pragma Preelaborate;
type ODF_Draw_Glue_Point_Leaving_Directions_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Glue_Point_Leaving_Directions_Attribute_Access is
access all ODF_Draw_Glue_Point_Leaving_Directions_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Glue_Point_Leaving_Directions_Attributes;
|
dan76/Amass | Ada | 1,729 | ads | -- Copyright © by Jeff Foley 2017-2023. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-- SPDX-License-Identifier: Apache-2.0
local json = require("json")
name = "PassiveTotal"
type = "api"
function start()
set_rate_limit(5)
end
function check()
local c
local cfg = datasrc_config()
if (cfg ~= nil) then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and
c.username ~= nil and c.key ~= "" and c.username ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if (cfg ~= nil) then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "" or
c.username == nil or c.username == "") then
return
end
local url = "https://api.passivetotal.org/v2/enrichment/subdomains?query=" .. domain
local resp, err = request(ctx, {
['url']=url,
['id']=c.username,
['pass']=c.key,
})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
return
elseif (resp.status_code < 200 or resp.status_code >= 400) then
log(ctx, "vertical request to service returned with status: " .. resp.status)
return
end
local d = json.decode(resp.body)
if (d == nil) then
log(ctx, "failed to decode the JSON response")
return
elseif (d.success ~= true or #(d.subdomains) == 0) then
return
end
for i, sub in pairs(d.subdomains) do
if (sub ~= nil and sub ~= "") then
new_name(ctx, sub .. "." .. domain)
end
end
end
|
zhmu/ananas | Ada | 338 | ads | package Ghost2 is
type Val_Entry is (A, B, C, D);
function Transition_Valid (L : Val_Entry; R : Val_Entry) return Boolean
is ((L = B and R = C) or
(L = C and R = C) or
(L = C and R = D) or
(L = D and R = B))
with Ghost;
procedure Set;
type Val_Array is array (1 .. 5) of Val_Entry;
end Ghost2;
|
AdaCore/training_material | Ada | 8,476 | ads | package Trains with
SPARK_Mode
is
-- the railroad is composed of a set of one-way tracks, where each track
-- joins two locations. A track has a length that is a multiple of an
-- elementary distance.
Num_Locations : constant := 39;
type Location is new Positive range 1 .. Num_Locations;
type Track is record
From : Location;
To : Location;
Length : Positive;
end record;
Num_Tracks : constant := 51;
type Track_Opt_Id is new Natural range 0 .. Num_Tracks;
subtype Track_Id is Track_Opt_Id range 1 .. Num_Tracks;
No_Track_Id : constant Track_Opt_Id := 0;
-- example railroad going around between locations 1 to 5, with additional
-- tracks from 1 to 3, 2 to 5 and 3 to 5.
Tracks : array (Track_Id) of Track := (others => (1, 1, 1));
-- the map of previous tracks records for each location the tracks that
-- precede it. This information should be consistent with the one in
-- Tracks.
Max_Num_Previous_Tracks : constant := 3;
type Prev_Id is range 1 .. Max_Num_Previous_Tracks;
type Track_Ids is array (Prev_Id) of Track_Opt_Id;
Previous_Tracks : array (Location) of Track_Ids := (others => (0, 0, 0));
-- the railroad should respect the property that no track precedes itself
function No_Track_Precedes_Itself return Boolean is
(for all Track in Track_Id =>
(for all Id in Prev_Id =>
Previous_Tracks (Tracks (Track).From) (Id) /= Track));
-- a train is identified by its unique identifier. The position of each
-- train is given by the starting track it's in (Track_Begin) and the
-- position in this track (Pos_Begin), with the ending track it's in
-- (Track_End) which can be the same as the starting track. A train
-- can never be on three tracks.
Max_Num_Trains : constant := 20;
type Train_Id is new Positive range 1 .. Max_Num_Trains;
type Train_Position is record
Track_Begin : Track_Id;
Pos_Begin : Natural;
Track_End : Track_Id;
end record;
Cur_Num_Trains : Train_Id := Train_Id'First;
Trains : array (Train_Id) of Train_Position;
function Entering_A_Track (Position : Train_Position) return Boolean is
(Position.Track_Begin /= Position.Track_End and then
(for some Id in Prev_Id =>
Position.Track_End = Previous_Tracks (Tracks (Position.Track_Begin).From) (Id)));
function Inside_A_Track (Position : Train_Position) return Boolean is
(Position.Track_Begin = Position.Track_End);
-- it should always hold that there is at most one train in every track
-- segment
function One_Train_At_Most_Per_Track return Boolean is
(for all Train in Train_Id range 1 .. Cur_Num_Trains =>
(for all Other_Train in Train_Id range 1 .. Cur_Num_Trains =>
(if Other_Train /= Train then
Trains (Train).Track_Begin /= Trains (Other_Train).Track_Begin and then
Trains (Train).Track_Begin /= Trains (Other_Train).Track_End and then
Trains (Train).Track_End /= Trains (Other_Train).Track_Begin and then
Trains (Train).Track_End /= Trains (Other_Train).Track_End)));
-- at each instant, the behavior of the train depends on the value of the
-- signal on the track it's in and on the track ahead
type Signal is (Green, Orange, Red);
Track_Signals : array (Track_Id) of Signal;
-- the signal should be Red on every track on which there is a train, and
-- Orange on every previous track, unless already Red on that track.
function Occupied_Tracks_On_Red return Boolean is
(for all Train in Train_Id range 1 .. Cur_Num_Trains =>
Track_Signals (Trains (Train).Track_Begin) = Red and then
Track_Signals (Trains (Train).Track_End) = Red);
-- Return the Id'th track that precedes the ending track of the train
function Get_Previous_Track
(Position : Train_Position;
Id : Prev_Id) return Track_Opt_Id
is
(Previous_Tracks (Tracks (Position.Track_End).From) (Id));
-- Return the Id'th track that precedes the starting track of the train,
-- provided it is different from the ending track of the train
function Get_Other_Previous_Track
(Position : Train_Position;
Id : Prev_Id) return Track_Opt_Id
is
(if Previous_Tracks (Tracks (Position.Track_Begin).From) (Id) =
Position.Track_End
then
No_Track_Id
else
Previous_Tracks (Tracks (Position.Track_Begin).From) (Id));
function Is_Previous_Track
(Position : Train_Position;
Track : Track_Id) return Boolean
is
(for some Id in Prev_Id =>
Track = Get_Previous_Track (Position, Id)
or else
Track = Get_Other_Previous_Track (Position, Id));
function Previous_Tracks_On_Orange_Or_Red return Boolean is
(for all Train in Train_Id range 1 .. Cur_Num_Trains =>
(for all Id in Prev_Id =>
(if Get_Previous_Track (Trains (Train), Id) /= No_Track_Id then
Track_Signals (Get_Previous_Track (Trains (Train), Id)) in
Orange | Red)
and then
(if Get_Other_Previous_Track (Trains (Train), Id) /= No_Track_Id then
Track_Signals (Get_Other_Previous_Track (Trains (Train), Id)) in
Orange | Red)));
function Safe_Signaling return Boolean is
(Occupied_Tracks_On_Red and then
Previous_Tracks_On_Orange_Or_Red);
-- valid movements of trains can be of 3 kinds:
-- . moving inside one or two tracks
-- . entering a new track
-- . leaving a track
-- The following functions correspond each to one of these kinds of
-- movements. Function Valid_Move returns whether a movement is among
-- these 3 kinds.
function Moving_Inside_Current_Tracks
(Cur_Position : Train_Position;
New_Position : Train_Position) return Boolean
is
(Cur_Position.Track_Begin = New_Position.Track_Begin and then
Cur_Position.Track_End = New_Position.Track_End);
function Moving_To_A_New_Track
(Cur_Position : Train_Position;
New_Position : Train_Position) return Boolean
is
(Inside_A_Track (Cur_Position) and then
Entering_A_Track (New_Position) and then
Cur_Position.Track_Begin = New_Position.Track_End);
function Moving_Away_From_Current_Track
(Cur_Position : Train_Position;
New_Position : Train_Position) return Boolean
is
(Entering_A_Track (Cur_Position) and then
Inside_A_Track (New_Position) and then
Cur_Position.Track_Begin = New_Position.Track_End);
function Valid_Move
(Cur_Position : Train_Position;
New_Position : Train_Position) return Boolean
is
-- either the train keeps moving in the current tracks
(Moving_Inside_Current_Tracks (Cur_Position, New_Position)
or else
-- or the train was inside a track and enters a new track
Moving_To_A_New_Track (Cur_Position, New_Position)
or else
-- or the train was entering a track and leaves the previous one
Moving_Away_From_Current_Track (Cur_Position, New_Position));
-- moving the train ahead along a valid movement can result in:
-- . Full_Speed: the movement was performed, the position of the train
-- (Trains) and the signals (Track_Signals) have been
-- updated, and the train can continue full speed.
-- . Slow_Down: Same as Full_Speed, but the train is entering an Orange
-- track and should slow down.
-- . Keep_Going: Same as Full_Speed, but the train should keep its
-- current speed.
-- . Stop: No movement performed, the train should stop here,
-- prior to entering a Red track.
type Move_Result is (Full_Speed, Slow_Down, Keep_Going, Stop);
procedure Move
(Train : Train_Id;
New_Position : Train_Position;
Result : out Move_Result)
with
Global => (Input => Cur_Num_Trains,
In_Out => (Trains, Track_Signals)),
Pre => Train in 1 .. Cur_Num_Trains and then
Valid_Move (Trains (Train), New_Position) and then
One_Train_At_Most_Per_Track and then
Safe_Signaling,
Post => One_Train_At_Most_Per_Track and then
Safe_Signaling;
end Trains;
|
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.Office_Title_Attributes is
pragma Preelaborate;
type ODF_Office_Title_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Office_Title_Attribute_Access is
access all ODF_Office_Title_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Office_Title_Attributes;
|
reznikmm/matreshka | Ada | 3,601 | 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.Activities.Hash is
new AMF.Elements.Generic_Hash (UML_Activity, UML_Activity_Access);
|
Rodeo-McCabe/orka | Ada | 2,098 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 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 Orka.Terminals;
package body Orka.Loggers.Formatting is
function Format_Message
(From : Source;
Kind : Message_Type;
Level : Severity;
ID : Natural;
Message : String) return String
is
Level_Color : constant Terminals.Color
:= (case Level is
when Error => Terminals.Red,
when Warning => Terminals.Yellow,
when Info => Terminals.Blue,
when Debug => Terminals.Green);
Time_Image : constant String := Terminals.Time_Image;
begin
return Terminals.Colorize ("[" & Time_Image & " " & Level'Image & "]", Level_Color) &
" " &
Terminals.Colorize ("[" & From'Image & ":" & Kind'Image & "]", Terminals.Magenta) &
(if ID > 0 then ID'Image & ": " else " ") & Terminals.Strip_Line_Term (Message);
end Format_Message;
function Format_Message_No_Color
(From : Source;
Kind : Message_Type;
Level : Severity;
ID : Natural;
Message : String) return String
is
Time_Image : constant String := Terminals.Time_Image;
begin
return "[" & Time_Image & " " & Level'Image & "]" &
" " &
"[" & From'Image & ":" & Kind'Image & "]" &
(if ID > 0 then ID'Image & ": " else " ") & Terminals.Strip_Line_Term (Message);
end Format_Message_No_Color;
end Orka.Loggers.Formatting;
|
reznikmm/matreshka | Ada | 5,427 | 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.UMLDI.UML_Multiplicity_Labels.Collections is
pragma Preelaborate;
package UMLDI_UML_Multiplicity_Label_Collections is
new AMF.Generic_Collections
(UMLDI_UML_Multiplicity_Label,
UMLDI_UML_Multiplicity_Label_Access);
type Set_Of_UMLDI_UML_Multiplicity_Label is
new UMLDI_UML_Multiplicity_Label_Collections.Set with null record;
Empty_Set_Of_UMLDI_UML_Multiplicity_Label : constant Set_Of_UMLDI_UML_Multiplicity_Label;
type Ordered_Set_Of_UMLDI_UML_Multiplicity_Label is
new UMLDI_UML_Multiplicity_Label_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UMLDI_UML_Multiplicity_Label : constant Ordered_Set_Of_UMLDI_UML_Multiplicity_Label;
type Bag_Of_UMLDI_UML_Multiplicity_Label is
new UMLDI_UML_Multiplicity_Label_Collections.Bag with null record;
Empty_Bag_Of_UMLDI_UML_Multiplicity_Label : constant Bag_Of_UMLDI_UML_Multiplicity_Label;
type Sequence_Of_UMLDI_UML_Multiplicity_Label is
new UMLDI_UML_Multiplicity_Label_Collections.Sequence with null record;
Empty_Sequence_Of_UMLDI_UML_Multiplicity_Label : constant Sequence_Of_UMLDI_UML_Multiplicity_Label;
private
Empty_Set_Of_UMLDI_UML_Multiplicity_Label : constant Set_Of_UMLDI_UML_Multiplicity_Label
:= (UMLDI_UML_Multiplicity_Label_Collections.Set with null record);
Empty_Ordered_Set_Of_UMLDI_UML_Multiplicity_Label : constant Ordered_Set_Of_UMLDI_UML_Multiplicity_Label
:= (UMLDI_UML_Multiplicity_Label_Collections.Ordered_Set with null record);
Empty_Bag_Of_UMLDI_UML_Multiplicity_Label : constant Bag_Of_UMLDI_UML_Multiplicity_Label
:= (UMLDI_UML_Multiplicity_Label_Collections.Bag with null record);
Empty_Sequence_Of_UMLDI_UML_Multiplicity_Label : constant Sequence_Of_UMLDI_UML_Multiplicity_Label
:= (UMLDI_UML_Multiplicity_Label_Collections.Sequence with null record);
end AMF.UMLDI.UML_Multiplicity_Labels.Collections;
|
reznikmm/matreshka | Ada | 3,588 | 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.Types.Hash is
new AMF.Elements.Generic_Hash (UML_Type, UML_Type_Access);
|
reznikmm/matreshka | Ada | 4,017 | 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.Draw_Symbol_Color_Attributes;
package Matreshka.ODF_Draw.Symbol_Color_Attributes is
type Draw_Symbol_Color_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Symbol_Color_Attributes.ODF_Draw_Symbol_Color_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Symbol_Color_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Symbol_Color_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Symbol_Color_Attributes;
|
jquorning/iNow | Ada | 1,869 | adb | pragma License (Restricted);
--
-- Copyright (C) 2020 Jesper Quorning All Rights Reserved.
--
-- 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 Ada.Text_IO;
with Ada.Exceptions;
with Setup;
with Command_Line;
with Database.Jobs;
with SQL_Database;
with Parser;
-- with Web_Server;
with Terminal_IO;
with Interactive;
with Navigate;
with Files;
procedure iDoNu_Program
is
Config : Setup.Configuration;
begin
Terminal_IO.Put_Banner;
declare
List : Files.Collection_List;
begin
Files.Append_Collections (List, ".");
Files.Append_Collections (List, "..");
Files.Append_Collections (List, "/Users/jquorning/");
Files.Append_Collections (List, "/Users/jquorning/var/");
end;
Command_Line.Parse (Config);
Interactive.Initialize;
SQL_Database.Open;
-- Web_Server.Startup;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("List:");
Navigate.Build_Path (Database.Jobs.Get_Current_Job);
Terminal_IO.Put_Path;
Navigate.Refresh_List;
Terminal_IO.Put_Jobs;
loop
Parser.Parse_Input (Interactive.Get_Line);
exit when Parser.Exit_Program;
end loop;
-- Web_Server.Shutdown;
Interactive.Finalize;
Command_Line.Set_Exit_Status (Command_Line.Success);
exception
when Command_Line.Terminate_Program =>
null;
when Occurrence : others =>
declare
use Ada.Exceptions;
Message : String renames Exception_Message (Occurrence);
begin
if Message = "" then
raise;
else
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Message);
end if;
end;
end iDoNu_Program;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 4,343 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with nRF51.GPIO; use nRF51.GPIO;
package MicroBit.IOs is
type Pin_Id is range 0 .. 20;
type IO_Features is (Digital, Analog, Touch);
function Supports (Pin : Pin_Id; Feature : IO_Features) return Boolean is
(case Feature is
when Digital => (case Pin is
when 0 .. 16 | 19 .. 20 => True,
when others => False),
when Analog => (case Pin is
when 0 .. 4 | 10 => True,
when others => False),
when Touch => (case Pin is
when 0 | 1 | 2 => True,
when others => False));
procedure Set (Pin : Pin_Id; Value : Boolean)
with Pre => Supports (Pin, Digital);
function Set (Pin : Pin_Id) return Boolean
with Pre => Supports (Pin, Digital);
type Analog_Value is range 0 .. 1023;
procedure Set_Analog_Period_Us (Period : Natural);
-- Set the period (in microseconds) of the PWM signal for all analog output
-- pins.
procedure Write (Pin : Pin_Id; Value : Analog_Value)
with Pre => Supports (Pin, Analog);
function Analog (Pin : Pin_Id) return Analog_Value
with Pre => Supports (Pin, Analog);
-- Read the voltagle applied to the pin. 0 means 0V 1023 means 3.3V
private
-- Mapping between pin id and GPIO_Points
Points : array (Pin_Id) of GPIO_Point :=
(0 => MB_P0,
1 => MB_P1,
2 => MB_P2,
3 => MB_P3,
4 => MB_P4,
5 => MB_P5,
6 => MB_P6,
7 => MB_P7,
8 => MB_P8,
9 => MB_P9,
10 => MB_P10,
11 => MB_P11,
12 => MB_P12,
13 => MB_P13,
14 => MB_P14,
15 => MB_P15,
16 => MB_P16,
17 => MB_P0, -- There's no pin17, using P0 to fill in...
18 => MB_P0, -- There's no pin18, using P0 to fill in...
19 => MB_P19,
20 => MB_P20);
end MicroBit.IOs;
|
reznikmm/matreshka | Ada | 5,622 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Stream_Element_Vectors;
with League.Strings;
with Web_Services.SOAP.Messages;
with Web_Services.SOAP.Payloads;
package Web_Services.SOAP.Clients is
type Abstract_Transport is abstract tagged limited null record;
not overriding procedure Post_Request
(Self : in out Abstract_Transport;
Content_Type : League.Stream_Element_Vectors.Stream_Element_Vector;
Request_Data : League.Stream_Element_Vectors.Stream_Element_Vector;
Response_Data : out League.Stream_Element_Vectors.Stream_Element_Vector)
is abstract;
-- Send given request and return reply.
not overriding function Is_Multipart_Content
(Self : in out Abstract_Transport) return Boolean is abstract;
-- If server return multipart replies
not overriding procedure Next_Response
(Self : in out Abstract_Transport;
Response_Data : out League.Stream_Element_Vectors.Stream_Element_Vector)
is abstract;
-- Get next responce. Only if server return multipart replies
not overriding procedure Finalyze (Self : in out Abstract_Transport)
is abstract;
-- Clean up internal data before transport deallocation
type SOAP_Client (Transport : access Abstract_Transport'Class) is
tagged limited private;
not overriding procedure Call
(Self : in out SOAP_Client;
Request : Web_Services.SOAP.Payloads.SOAP_Payload_Access;
Response : out Web_Services.SOAP.Payloads.SOAP_Payload_Access;
User : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String;
Password : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String;
Action : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String);
-- Call server
not overriding procedure Next_Response
(Self : in out SOAP_Client;
Response : out Web_Services.SOAP.Payloads.SOAP_Payload_Access);
private
type SOAP_Client (Transport : access Abstract_Transport'Class) is
tagged limited null record;
procedure Call
(Self : in out SOAP_Client;
Input : Web_Services.SOAP.Messages.SOAP_Message_Access;
Response : out Web_Services.SOAP.Payloads.SOAP_Payload_Access);
end Web_Services.SOAP.Clients;
|
kevans91/synth | Ada | 55,960 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Calendar.Arithmetic;
with Ada.Calendar.Formatting;
with Ada.Direct_IO;
with Unix;
package body PortScan.Buildcycle is
package ACA renames Ada.Calendar.Arithmetic;
package ACF renames Ada.Calendar.Formatting;
---------------------
-- build_package --
---------------------
function build_package (id : builders;
sequence_id : port_id;
interactive : Boolean := False;
interphase : phases := fetch) return Boolean
is
R : Boolean;
begin
trackers (id).seq_id := sequence_id;
trackers (id).loglines := 0;
if uselog then
if not initialize_log (id) then
finalize_log (id);
return False;
end if;
end if;
for phase in phases'Range loop
trackers (id).phase := phase;
case phase is
when check_sanity | fetch | checksum | extract | patch |
pkg_package =>
R := exec_phase_generic (id, phase);
when pkg_depends | fetch_depends | extract_depends |
patch_depends | build_depends | lib_depends | run_depends =>
R := exec_phase_depends (id, phase);
when configure =>
if testing then
if lock_localbase then
set_localbase_protection (id, True);
end if;
mark_file_system (id, "preconfig");
end if;
R := exec_phase_generic (id, phase);
when build =>
R := exec_phase_build (id);
when stage =>
if testing then
mark_file_system (id, "prestage");
end if;
R := exec_phase_generic (id, phase);
when install_mtree | install | check_plist =>
if testing then
R := exec_phase_generic (id, phase);
end if;
when deinstall =>
if testing then
R := exec_phase_deinstall (id);
end if;
end case;
exit when R = False;
exit when interactive and then interphase = phase;
end loop;
if uselog then
finalize_log (id);
end if;
if interactive then
interact_with_builder (id);
end if;
return R;
end build_package;
----------------------
-- initialize_log --
----------------------
function initialize_log (id : builders) return Boolean
is
FA : access TIO.File_Type;
H_ENV : constant String := "Environment";
H_OPT : constant String := "Options";
H_CFG : constant String := "/etc/make.conf";
UNAME : constant String := JT.USS (uname_mrv);
BENV : constant String := get_environment (id);
COPTS : constant String := get_options_configuration (id);
MCONF : constant String := dump_make_conf (id);
PTVAR : JT.Text := get_port_variables (id);
begin
trackers (id).dynlink.Clear;
trackers (id).head_time := CAL.Clock;
declare
log_path : constant String := log_name (trackers (id).seq_id);
begin
if AD.Exists (log_path) then
AD.Delete_File (log_path);
end if;
TIO.Create (File => trackers (id).log_handle,
Mode => TIO.Out_File,
Name => log_path);
FA := trackers (id).log_handle'Access;
exception
when error : others =>
raise cycle_log_error
with "failed to create log " & log_path;
end;
TIO.Put_Line (FA.all, "=> Building " &
get_catport (all_ports (trackers (id).seq_id)));
TIO.Put_Line (FA.all, "Started : " & timestamp (trackers (id).head_time));
TIO.Put (FA.all, "Platform: " & UNAME);
if BENV = discerr then
TIO.Put_Line (FA.all, LAT.LF & "Environment definition failed, " &
"aborting entire build");
return False;
end if;
TIO.Put_Line (FA.all, LAT.LF & log_section (H_ENV, True));
TIO.Put (FA.all, BENV);
TIO.Put_Line (FA.all, log_section (H_ENV, False) & LAT.LF);
TIO.Put_Line (FA.all, log_section (H_OPT, True));
TIO.Put (FA.all, COPTS);
TIO.Put_Line (FA.all, log_section (H_OPT, False) & LAT.LF);
dump_port_variables (id => id, content => PTVAR);
TIO.Put_Line (FA.all, log_section (H_CFG, True));
TIO.Put (FA.all, MCONF);
TIO.Put_Line (FA.all, log_section (H_CFG, False) & LAT.LF);
return True;
end initialize_log;
--------------------
-- finalize_log --
--------------------
procedure finalize_log (id : builders) is
begin
trackers (id).tail_time := CAL.Clock;
TIO.Put_Line (trackers (id).log_handle,
"Finished: " & timestamp (trackers (id).tail_time));
TIO.Put_Line (trackers (id).log_handle,
log_duration (start => trackers (id).head_time,
stop => trackers (id).tail_time));
TIO.Close (trackers (id).log_handle);
end finalize_log;
--------------------
-- log_duration --
--------------------
function log_duration (start, stop : CAL.Time) return String
is
raw : JT.Text := JT.SUS ("Duration:");
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
use type ACA.Day_Count;
begin
ACA.Difference (Left => stop,
Right => start,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
if diff_days > 0 then
if diff_days = 1 then
JT.SU.Append (raw, " 1 day and" &
ACF.Image (Elapsed_Time => diff_secs));
else
JT.SU.Append (raw, diff_days'Img & " days and" &
ACF.Image (Elapsed_Time => diff_secs));
end if;
else
JT.SU.Append (raw, " " & ACF.Image (Elapsed_Time => diff_secs));
end if;
return JT.USS (raw);
end log_duration;
------------------------
-- elapsed_HH_MM_SS --
------------------------
function elapsed_HH_MM_SS (start, stop : CAL.Time) return String
is
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
secs_per_hour : constant Integer := 3600;
total_hours : Integer;
total_minutes : Integer;
work_hours : Integer;
work_seconds : Integer;
use type ACA.Day_Count;
begin
ACA.Difference (Left => stop,
Right => start,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
-- Seems the ACF image is shit, so let's roll our own. If more than
-- 100 hours, change format to "HHH:MM.M"
work_seconds := Integer (diff_secs);
total_hours := work_seconds / secs_per_hour;
total_hours := total_hours + Integer (diff_days) * 24;
if total_hours < 24 then
if work_seconds < 0 then
return "--:--:--";
else
work_seconds := work_seconds - (total_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := work_seconds - (total_minutes * 60);
return
JT.zeropad (total_hours, 2) & LAT.Colon &
JT.zeropad (total_minutes, 2) & LAT.Colon &
JT.zeropad (work_seconds, 2);
end if;
elsif total_hours < 100 then
if work_seconds < 0 then
return JT.zeropad (total_hours, 2) & ":00:00";
else
work_hours := work_seconds / secs_per_hour;
work_seconds := work_seconds - (work_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := work_seconds - (total_minutes * 60);
return
JT.zeropad (total_hours, 2) & LAT.Colon &
JT.zeropad (total_minutes, 2) & LAT.Colon &
JT.zeropad (work_seconds, 2);
end if;
else
if work_seconds < 0 then
return JT.zeropad (total_hours, 3) & ":00.0";
else
work_hours := work_seconds / secs_per_hour;
work_seconds := work_seconds - (work_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := (work_seconds - (total_minutes * 60)) * 10 / 60;
return
JT.zeropad (total_hours, 3) & LAT.Colon &
JT.zeropad (total_minutes, 2) & '.' &
JT.int2str (work_seconds);
end if;
end if;
end elapsed_HH_MM_SS;
-------------------
-- elapsed_now --
-------------------
function elapsed_now return String is
begin
return elapsed_HH_MM_SS (start => start_time, stop => CAL.Clock);
end elapsed_now;
-----------------
-- timestamp --
-----------------
function timestamp (hack : CAL.Time) return String
is
function MON (num : CAL.Month_Number) return String;
function WKDAY (day : ACF.Day_Name) return String;
function MON (num : CAL.Month_Number) return String is
begin
case num is
when 1 => return "JAN";
when 2 => return "FEB";
when 3 => return "MAR";
when 4 => return "APR";
when 5 => return "MAY";
when 6 => return "JUN";
when 7 => return "JUL";
when 8 => return "AUG";
when 9 => return "SEP";
when 10 => return "OCT";
when 11 => return "NOV";
when 12 => return "DEC";
end case;
end MON;
function WKDAY (day : ACF.Day_Name) return String is
begin
case day is
when ACF.Monday => return "Monday";
when ACF.Tuesday => return "Tuesday";
when ACF.Wednesday => return "Wednesday";
when ACF.Thursday => return "Thursday";
when ACF.Friday => return "Friday";
when ACF.Saturday => return "Saturday";
when ACF.Sunday => return "Sunday";
end case;
end WKDAY;
begin
return WKDAY (ACF.Day_Of_Week (hack)) & "," & CAL.Day (hack)'Img & " " &
MON (CAL.Month (hack)) & CAL.Year (hack)'Img & " at" &
ACF.Image (hack)(11 .. 19) & " UTC";
end timestamp;
-----------------------------
-- generic_system_command --
-----------------------------
function generic_system_command (command : String) return JT.Text
is
content : JT.Text;
status : Integer;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise cycle_cmd_error with "cmd: " & command &
" (return code =" & status'Img & ")";
end if;
return content;
end generic_system_command;
---------------------
-- set_uname_mrv --
---------------------
procedure set_uname_mrv
is
command : constant String := "/usr/bin/uname -mrv";
begin
uname_mrv := generic_system_command (command);
exception
when others =>
uname_mrv := JT.SUS (discerr);
end set_uname_mrv;
----------------
-- get_root --
----------------
function get_root (id : builders) return String
is
id_image : constant String := Integer (id)'Img;
suffix : String := "/SL00";
begin
if id < 10 then
suffix (5) := id_image (2);
else
suffix (4 .. 5) := id_image (2 .. 3);
end if;
return JT.USS (PM.configuration.dir_buildbase) & suffix;
end get_root;
-----------------------
-- get_environment --
-----------------------
function get_environment (id : builders) return String
is
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override;
begin
return JT.USS (generic_system_command (command));
exception
when others =>
return discerr;
end get_environment;
---------------------------------
-- get_options_configuration --
---------------------------------
function get_options_configuration (id : builders) return String
is
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override &
"/usr/bin/make -C /xports/" &
get_catport (all_ports (trackers (id).seq_id)) &
" showconfig";
begin
return JT.USS (generic_system_command (command));
exception
when others =>
return discerr;
end get_options_configuration;
------------------------
-- split_collection --
------------------------
function split_collection (line : JT.Text; title : String) return String
is
meat : JT.Text;
waiting : Boolean := True;
quoted : Boolean := False;
keepit : Boolean;
counter : Natural := 0;
meatlen : Natural := 0;
linelen : Natural := JT.SU.Length (line);
onechar : String (1 .. 1);
meatstr : String (1 .. linelen);
begin
loop
counter := counter + 1;
exit when counter > linelen;
keepit := True;
onechar := JT.SU.Slice (Source => line,
Low => counter,
High => counter);
if onechar (1) = LAT.Space then
if waiting then
keepit := False;
else
if not quoted then
-- name-pair ended, reset
waiting := True;
quoted := False;
onechar (1) := LAT.LF;
end if;
end if;
else
waiting := False;
if onechar (1) = LAT.Quotation then
quoted := not quoted;
end if;
end if;
if keepit then
meatlen := meatlen + 1;
meatstr (meatlen) := onechar (1);
end if;
end loop;
return log_section (title, True) & LAT.LF &
meatstr (1 .. meatlen) & LAT.LF &
log_section (title, False) & LAT.LF;
end split_collection;
--------------------------
-- get_port_variables --
--------------------------
function get_port_variables (id : builders) return JT.Text
is
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override &
"/usr/bin/make -C /xports/" &
get_catport (all_ports (trackers (id).seq_id)) &
" -VCONFIGURE_ENV -VCONFIGURE_ARGS -VMAKE_ENV -VMAKE_ARGS" &
" -VPLIST_SUB -VSUB_LIST";
begin
return generic_system_command (command);
exception
when others =>
return JT.SUS (discerr);
end get_port_variables;
---------------------------
-- dump_port_variables --
---------------------------
procedure dump_port_variables (id : builders; content : JT.Text)
is
LA : access TIO.File_Type := trackers (id).log_handle'Access;
topline : JT.Text;
concopy : JT.Text := content;
type result_range is range 1 .. 6;
begin
for k in result_range loop
JT.nextline (lineblock => concopy, firstline => topline);
case k is
when 1 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ENV"));
when 2 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ARGS"));
when 3 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ENV"));
when 4 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ARGS"));
when 5 => TIO.Put_Line
(LA.all, split_collection (topline, "PLIST_SUB"));
when 6 => TIO.Put_Line
(LA.all, split_collection (topline, "SUB_LIST"));
end case;
end loop;
end dump_port_variables;
----------------
-- log_name --
----------------
function log_name (sid : port_id) return String
is
catport : constant String := get_catport (all_ports (sid));
begin
return JT.USS (PM.configuration.dir_logs) & "/" &
JT.part_1 (catport) & "___" & JT.part_2 (catport) & ".log";
end log_name;
-----------------
-- dump_file --
-----------------
function dump_file (filename : String) return String
is
File_Size : Natural := Natural (AD.Size (filename));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => filename);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
return String (Contents);
end dump_file;
----------------------
-- dump_make_conf --
----------------------
function dump_make_conf (id : builders) return String
is
root : constant String := get_root (id);
filename : constant String := root & "/etc/make.conf";
begin
return dump_file (filename);
end dump_make_conf;
------------------
-- initialize --
------------------
procedure initialize (test_mode : Boolean; jail_env : JT.Text) is
begin
set_uname_mrv;
testing := test_mode;
lock_localbase := testing and then Unix.env_variable_defined ("LOCK");
slave_env := jail_env;
declare
logdir : constant String := JT.USS (PM.configuration.dir_logs);
begin
if not AD.Exists (logdir) then
AD.Create_Path (New_Directory => logdir);
end if;
exception
when error : others =>
raise cycle_log_error
with "failed to create " & logdir;
end;
obtain_custom_environment;
end initialize;
-------------------
-- log_section --
-------------------
function log_section (title : String; header : Boolean) return String
is
first_part : constant String := "[ " & title;
begin
if header then
return first_part & " HEAD ]";
else
return first_part & " TAIL ]";
end if;
end log_section;
---------------------
-- log_phase_end --
---------------------
procedure log_phase_end (id : builders)
is
dash : constant String := "=========================";
begin
TIO.Put_Line (trackers (id).log_handle, dash & dash & dash & LAT.LF);
end log_phase_end;
-----------------------
-- log_phase_begin --
-----------------------
procedure log_phase_begin (phase : String; id : builders)
is
plast : constant Natural := 10 + phase'Length;
dash : constant String := "========================";
middle : String := "< phase : >";
begin
middle (11 .. plast) := phase;
TIO.Put_Line (trackers (id).log_handle, dash & middle & dash);
end log_phase_begin;
--------------------------
-- exec_phase_generic --
--------------------------
function exec_phase_generic (id : builders; phase : phases) return Boolean
is
time_limit : execution_limit := max_time_without_output (phase);
begin
return exec_phase (id => id, phase => phase, time_limit => time_limit);
end exec_phase_generic;
--------------------------
-- exec_phase_depends --
--------------------------
function exec_phase_depends (id : builders; phase : phases) return Boolean
is
time_limit : execution_limit := max_time_without_output (phase);
phaseenv : String := "USE_PACKAGE_DEPENDS_ONLY=1";
begin
return exec_phase (id => id, phase => phase, phaseenv => phaseenv,
time_limit => time_limit,
depends_phase => True);
end exec_phase_depends;
------------------------
-- exec_phase_build --
------------------------
function exec_phase_build (id : builders) return Boolean
is
time_limit : execution_limit := max_time_without_output (build);
passed : Boolean;
begin
passed := exec_phase (id => id,
phase => build,
time_limit => time_limit,
skip_header => False,
skip_footer => True);
if testing and then passed then
if lock_localbase then
set_localbase_protection (id, False);
end if;
passed := detect_leftovers_and_MIA
(id, "preconfig", "between port configure and build");
end if;
if uselog then
log_phase_end (id);
end if;
return passed;
end exec_phase_build;
----------------------------
-- exec_phase_deinstall --
----------------------------
function exec_phase_deinstall (id : builders) return Boolean
is
time_limit : execution_limit := max_time_without_output (deinstall);
result : Boolean;
begin
-- This is only run during "testing" so assume that.
if uselog then
log_phase_begin (phase2str (deinstall), id);
log_linked_libraries (id);
end if;
result := exec_phase (id => id,
phase => deinstall,
time_limit => time_limit,
skip_header => True,
skip_footer => True);
if not result then
if uselog then
log_phase_end (id);
end if;
return False;
end if;
if uselog then
result := detect_leftovers_and_MIA
(id, "prestage", "between staging and package deinstallation");
log_phase_end (id);
end if;
return result;
end exec_phase_deinstall;
-----------------------
-- generic_execute --
-----------------------
function generic_execute (id : builders; command : String;
dogbite : out Boolean;
time_limit : execution_limit) return Boolean
is
subtype time_cycle is execution_limit range 1 .. time_limit;
subtype one_minute is Positive range 1 .. 230; -- lose 10 in rounding
type dim_watchdog is array (time_cycle) of Natural;
use type Unix.process_exit;
watchdog : dim_watchdog;
squirrel : time_cycle := time_cycle'First;
cycle_done : Boolean := False;
pid : Unix.pid_t;
status : Unix.process_exit;
lock_lines : Natural;
quartersec : one_minute := one_minute'First;
hangmonitor : constant Boolean := True;
synthexec : constant String := host_localbase & "/libexec/synthexec";
truecommand : constant String := synthexec & " " &
log_name (trackers (id).seq_id) & " " & command;
begin
dogbite := False;
watchdog (squirrel) := trackers (id).loglines;
pid := Unix.launch_process (truecommand);
if Unix.fork_failed (pid) then
return False;
end if;
loop
delay 0.25;
if quartersec = one_minute'Last then
quartersec := one_minute'First;
-- increment squirrel
if squirrel = time_cycle'Last then
squirrel := time_cycle'First;
cycle_done := True;
else
squirrel := squirrel + 1;
end if;
if hangmonitor then
lock_lines := trackers (id).loglines;
if cycle_done then
if watchdog (squirrel) = lock_lines then
-- Log hasn't advanced in a full cycle so bail out
dogbite := True;
Unix.kill_process_tree (process_group => pid);
delay 5.0; -- Give some time for error to write to log
return False;
end if;
end if;
watchdog (squirrel) := lock_lines;
end if;
else
quartersec := quartersec + 1;
end if;
status := Unix.process_status (pid);
if status = Unix.exited_normally then
return True;
end if;
if status = Unix.exited_with_error then
return False;
end if;
end loop;
end generic_execute;
------------------
-- exec_phase --
------------------
function exec_phase (id : builders; phase : phases;
time_limit : execution_limit;
phaseenv : String := "";
depends_phase : Boolean := False;
skip_header : Boolean := False;
skip_footer : Boolean := False)
return Boolean
is
root : constant String := get_root (id);
port_flags : String := " NO_DEPENDS=yes ";
pid : port_id := trackers (id).seq_id;
catport : constant String := get_catport (all_ports (pid));
result : Boolean;
timed_out : Boolean;
begin
if testing or else depends_phase
then
port_flags := (others => LAT.Space);
end if;
-- Nasty, we have to switch open and close the log file for each
-- phase because we have to switch between File_Type and File
-- Descriptors. I can't find a safe way to get the File Descriptor
-- out of the File type.
if uselog then
if not skip_header then
log_phase_begin (phase2str (phase), id);
end if;
TIO.Close (trackers (id).log_handle);
end if;
declare
command : constant String := chroot & root & environment_override &
phaseenv & port_flags &
"/usr/bin/make -C /xports/" & catport & " " & phase2str (phase);
begin
result := generic_execute (id, command, timed_out, time_limit);
end;
-- Reopen the log. I guess we can leave off the exception check
-- since it's been passing before
if uselog then
TIO.Open (File => trackers (id).log_handle,
Mode => TIO.Append_File,
Name => log_name (trackers (id).seq_id));
if timed_out then
TIO.Put_Line (trackers (id).log_handle,
"### Watchdog killed runaway process! ###");
end if;
if not skip_footer then
log_phase_end (id);
end if;
end if;
return result;
end exec_phase;
--------------------------
-- dynamically_linked --
--------------------------
function dynamically_linked (base, filename : String) return Boolean
is
command : String := chroot & base & " /usr/bin/file -b " &
"-e ascii -e encoding -e tar -e compress " &
LAT.Quotation & filename & LAT.Quotation;
comres : JT.Text;
begin
comres := generic_system_command (command);
return JT.contains (comres, "dynamically linked");
exception
when others =>
return False;
end dynamically_linked;
----------------------------
-- log_linked_libraries --
----------------------------
procedure stack_linked_libraries (id : builders; base, filename : String)
is
command : String := chroot & base & " /usr/bin/objdump -p " & filename;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
begin
comres := generic_system_command (command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if not JT.IsBlank (topline) then
if JT.contains (topline, "NEEDED") then
if not trackers (id).dynlink.Contains (topline) then
trackers (id).dynlink.Append (topline);
end if;
end if;
end if;
end loop;
exception
-- the command result was not zero, so it was an expected format
-- or static file. Just skip it. (Should never happen)
when bad_result : others => null;
end stack_linked_libraries;
----------------------------
-- log_linked_libraries --
----------------------------
procedure log_linked_libraries (id : builders)
is
procedure log_dump (cursor : string_crate.Cursor);
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
pkgfile : constant String := JT.USS
(all_ports (trackers (id).seq_id).package_name);
pkgname : constant String := pkgfile (1 .. pkgfile'Last - 4);
root : constant String := get_root (id);
command : constant String := chroot & root & " " &
host_localbase & "/sbin/pkg query %Fp " & pkgname;
procedure log_dump (cursor : string_crate.Cursor) is
begin
TIO.Put_Line (trackers (id).log_handle,
JT.USS (string_crate.Element (Position => cursor)));
end log_dump;
begin
TIO.Put_Line (trackers (id).log_handle,
"=> Checking shared library dependencies");
comres := generic_system_command (command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if dynamically_linked (root, JT.USS (topline)) then
stack_linked_libraries (id, root, JT.USS (topline));
end if;
end loop;
trackers (id).dynlink.Iterate (log_dump'Access);
exception
when others => null;
end log_linked_libraries;
----------------------------
-- environment_override --
----------------------------
function environment_override (enable_tty : Boolean := False) return String
is
function set_terminal (enable_tty : Boolean) return String;
function set_terminal (enable_tty : Boolean) return String is
begin
if enable_tty then
return "TERM=cons25 ";
end if;
return "TERM=dumb ";
end set_terminal;
PATH : constant String := "PATH=/sbin:/bin:/usr/sbin:/usr/bin:" &
"/usr/local/sbin:/usr/local/bin ";
TERM : constant String := set_terminal (enable_tty);
USER : constant String := "USER=root ";
HOME : constant String := "HOME=/root ";
LANG : constant String := "LANG=C ";
CENV : constant String := JT.USS (customenv);
JENV : constant String := JT.USS (slave_env);
begin
return " /usr/bin/env -i " &
USER & HOME & LANG & TERM & PATH & JENV & CENV;
end environment_override;
---------------------
-- set_log_lines --
---------------------
procedure set_log_lines (id : builders)
is
log_path : constant String := log_name (trackers (id).seq_id);
command : constant String := "/usr/bin/wc -l " & log_path;
comres : JT.Text;
begin
if not uselog then
trackers (id).loglines := 0;
return;
end if;
comres := JT.trim (generic_system_command (command));
declare
numtext : constant String :=
JT.part_1 (S => JT.USS (comres), separator => " ");
begin
trackers (id).loglines := Natural'Value (numtext);
end;
exception
when others => null; -- just skip this cycle
end set_log_lines;
-----------------
-- phase2str --
-----------------
function phase2str (phase : phases) return String is
begin
case phase is
when check_sanity => return "check-sanity";
when pkg_depends => return "pkg-depends";
when fetch_depends => return "fetch-depends";
when fetch => return "fetch";
when checksum => return "checksum";
when extract_depends => return "extract-depends";
when extract => return "extract";
when patch_depends => return "patch-depends";
when patch => return "patch";
when build_depends => return "build-depends";
when lib_depends => return "lib-depends";
when configure => return "configure";
when build => return "build";
when run_depends => return "run-depends";
when stage => return "stage";
when pkg_package => return "package";
when install_mtree => return "install-mtree";
when install => return "install";
when deinstall => return "deinstall";
when check_plist => return "check-plist";
end case;
end phase2str;
-----------------------
-- format_loglines --
-----------------------
function format_loglines (numlines : Natural) return String
is
begin
if numlines < 10000000 then -- 10 million
return JT.int2str (numlines);
end if;
declare
kilo : constant Natural := numlines / 1000;
kilotxt : constant String := JT.int2str (kilo);
begin
if numlines < 100000000 then -- 100 million
return kilotxt (1 .. 2) & "." & kilotxt (3 .. 5) & 'M';
elsif numlines < 1000000000 then -- 1 billion
return kilotxt (1 .. 3) & "." & kilotxt (3 .. 4) & 'M';
else
return kilotxt (1 .. 4) & "." & kilotxt (3 .. 3) & 'M';
end if;
end;
end format_loglines;
----------------------
-- builder_status --
----------------------
function builder_status (id : builders;
shutdown : Boolean := False;
idle : Boolean := False)
return Display.builder_rec
is
result : Display.builder_rec;
begin
-- 123456789 123456789 123456789 123456789 1234
-- SL elapsed phase lines origin
-- 01 00:00:00 extract-depends 9999999 www/joe
result.id := id;
result.slavid := JT.zeropad (Natural (id), 2);
result.LLines := (others => ' ');
result.phase := (others => ' ');
result.origin := (others => ' ');
result.shutdown := False;
result.idle := False;
if shutdown then
-- Overrides "idle" if both Shutdown and Idle are True
result.Elapsed := "Shutdown";
result.shutdown := True;
return result;
end if;
if idle then
result.Elapsed := "Idle ";
result.idle := True;
return result;
end if;
declare
phasestr : constant String := phase2str (trackers (id).phase);
catport : constant String :=
get_catport (all_ports (trackers (id).seq_id));
numlines : constant String := format_loglines (trackers (id).loglines);
linehead : constant Natural := 8 - numlines'Length;
begin
result.Elapsed := elapsed_HH_MM_SS (start => trackers (id).head_time,
stop => CAL.Clock);
result.LLines (linehead .. 7) := numlines;
result.phase (1 .. phasestr'Length) := phasestr;
if catport'Length > 37 then
result.origin (1 .. 36) := catport (1 .. 36);
result.origin (37) := LAT.Asterisk;
else
result.origin (1 .. catport'Length) := catport;
end if;
end;
return result;
end builder_status;
---------------------
-- elapsed_build --
---------------------
function elapsed_build (id : builders) return String is
begin
return elapsed_HH_MM_SS (start => trackers (id).head_time,
stop => trackers (id).tail_time);
end elapsed_build;
-----------------------------
-- get_packages_per_hour --
-----------------------------
function get_packages_per_hour (packages_done : Natural;
from_when : CAL.Time)
return Natural
is
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
result : Natural;
rightnow : CAL.Time := CAL.Clock;
work_seconds : Integer;
work_days : Integer;
use type ACA.Day_Count;
begin
if packages_done = 0 then
return 0;
end if;
ACA.Difference (Left => rightnow,
Right => from_when,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
work_seconds := Integer (diff_secs);
work_days := Integer (diff_days);
work_seconds := work_seconds + (work_days * 3600 * 24);
if work_seconds < 0 then
-- should be impossible to get here.
return 0;
end if;
result := packages_done * 3600;
result := result / work_seconds;
return result;
exception
when others => return 0;
end get_packages_per_hour;
-------------------------------
-- max_time_without_output --
-------------------------------
function max_time_without_output (phase : phases) return execution_limit
is
base : Integer;
begin
case phase is
when check_sanity => base := 1;
when pkg_depends => base := 3;
when fetch_depends => base := 3;
when fetch | checksum => return 480; -- 8 hours
when extract_depends => base := 3;
when extract => base := 20;
when patch_depends => base := 3;
when patch => base := 3;
when build_depends => base := 5;
when lib_depends => base := 5;
when configure => base := 15;
when build => base := 25; -- for gcc linking, tex
when run_depends => base := 15; -- octave-forge is driver
when stage => base := 20; -- desire 15 but too many rogue builders-in-stage
when check_plist => base := 10; -- For packages with thousands of files
when pkg_package => base := 80;
when install_mtree => base := 3;
when install => base := 10;
when deinstall => base := 10;
end case;
declare
multiplier_x10 : constant Positive := timeout_multiplier_x10;
begin
return execution_limit (base * multiplier_x10 / 10);
end;
end max_time_without_output;
------------------------
-- mark_file_system --
------------------------
procedure mark_file_system (id : builders; action : String)
is
function attributes (action : String) return String;
function attributes (action : String) return String
is
core : constant String := "uid,gid,mode,md5digest";
begin
if action = "preconfig" then
return core & ",time";
else
return core;
end if;
end attributes;
path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base";
path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" &
JT.zeropad (Natural (id), 2);
mtfile : constant String := path_mm & "/mtree." & action & ".exclude";
command : constant String := "/usr/sbin/mtree -X " & mtfile &
" -cn -k " & attributes (action) & " -p " & path_sm;
filename : constant String := path_sm & "/tmp/mtree." & action;
result : JT.Text;
resfile : TIO.File_Type;
begin
result := generic_system_command (command);
TIO.Create (File => resfile, Mode => TIO.Out_File, Name => filename);
TIO.Put (resfile, JT.USS (result));
TIO.Close (resfile);
exception
when cycle_cmd_error => null;
when others =>
if TIO.Is_Open (resfile) then
TIO.Close (resfile);
end if;
end mark_file_system;
--------------------------------
-- detect_leftovers_and_MIA --
--------------------------------
function detect_leftovers_and_MIA (id : builders; action : String;
description : String) return Boolean
is
package crate is new AC.Vectors (Index_Type => Positive,
Element_Type => JT.Text,
"=" => JT.SU."=");
package sorter is new crate.Generic_Sorting ("<" => JT.SU."<");
function ignore_modifications return Boolean;
procedure print (cursor : crate.Cursor);
procedure close_active_modifications;
path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base";
path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" &
JT.zeropad (Natural (id), 2);
mtfile : constant String := path_mm & "/mtree." & action & ".exclude";
filename : constant String := path_sm & "/tmp/mtree." & action;
command : constant String := "/usr/sbin/mtree -X " & mtfile & " -f " &
filename & " -p " & path_sm;
status : Integer;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
toplen : Natural;
skiprest : Boolean;
passed : Boolean := True;
activemod : Boolean := False;
modport : JT.Text := JT.blank;
reasons : JT.Text := JT.blank;
leftover : crate.Vector;
missing : crate.Vector;
changed : crate.Vector;
function ignore_modifications return Boolean
is
-- Some modifications need to be ignored
-- A) */ls-R
-- #ls-R files from texmf are often regenerated
-- B) share/xml/catalog.ports
-- # xmlcatmgr is constantly updating catalog.ports, ignore
-- C) share/octave/octave_packages
-- # Octave packages database, blank lines can be inserted
-- # between pre-install and post-deinstall
-- D) info/dir | */info/dir
-- E) lib/gio/modules/giomodule.cache
-- # gio modules cache could be modified for any gio modules
-- F) etc/gconf/gconf.xml.defaults/%gconf-tree*.xml
-- # gconftool-2 --makefile-uninstall-rule is unpredictable
-- G) %%PEARDIR%%/.depdb | %%PEARDIR%%/.filemap
-- # The is pear database cache
-- H) "." with timestamp modification
-- # this happens when ./tmp or ./var is used, which is legal
filename : constant String := JT.USS (modport);
fnlen : constant Natural := filename'Length;
begin
if filename = "usr/local/share/xml/catalog.ports" or else
filename = "usr/local/share/octave/octave_packages" or else
filename = "usr/local/info/dir" or else
filename = "usr/local/lib/gio/modules/giomodule.cache" or else
filename = "usr/local/share/pear/.depdb" or else
filename = "usr/local/share/pear/.filemap"
then
return True;
end if;
if filename = "." and then JT.equivalent (reasons, "modification") then
return True;
end if;
if fnlen > 17 and then filename (1 .. 10) = "usr/local/"
then
if filename (fnlen - 4 .. fnlen) = "/ls-R" or else
filename (fnlen - 8 .. fnlen) = "/info/dir"
then
return True;
end if;
end if;
if fnlen > 56 and then filename (1 .. 39) =
"usr/local/etc/gconf/gconf.xml.defaults/" and then
filename (fnlen - 3 .. fnlen) = ".xml"
then
if JT.contains (filename, "/%gconf-tree") then
return True;
end if;
end if;
return False;
end ignore_modifications;
procedure close_active_modifications is
begin
if activemod and then not ignore_modifications then
JT.SU.Append (modport, " [ ");
JT.SU.Append (modport, reasons);
JT.SU.Append (modport, " ]");
if not changed.Contains (modport) then
changed.Append (modport);
end if;
end if;
activemod := False;
reasons := JT.blank;
modport := JT.blank;
end close_active_modifications;
procedure print (cursor : crate.Cursor)
is
dossier : constant String := JT.USS (crate.Element (cursor));
begin
TIO.Put_Line (trackers (id).log_handle, LAT.HT & dossier);
end print;
begin
-- we can't use generic_system_command because exit code /= 0 normally
comres := Unix.piped_command (command, status);
crlen1 := JT.SU.Length (comres);
loop
skiprest := False;
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
toplen := JT.SU.Length (topline);
if not skiprest and then JT.SU.Length (topline) > 6 then
declare
sx : constant Natural := toplen - 5;
caboose : constant String := JT.SU.Slice (topline, sx, toplen);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 1, sx - 1));
begin
if caboose = " extra" then
close_active_modifications;
if not leftover.Contains (filename) then
leftover.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest and then JT.SU.Length (topline) > 7 then
declare
canopy : constant String := JT.SU.Slice (topline, 1, 7);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 8, toplen));
begin
if canopy = "extra: " then
close_active_modifications;
if not leftover.Contains (filename) then
leftover.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest and then JT.SU.Length (topline) > 10 then
declare
sx : constant Natural := toplen - 7;
caboose : constant String := JT.SU.Slice (topline, sx, toplen);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 3, sx - 1));
begin
if caboose = " missing" then
close_active_modifications;
if not missing.Contains (filename) then
missing.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest then
declare
line : constant String := JT.USS (topline);
blank8 : constant String := " ";
sx : constant Natural := toplen - 7;
begin
if toplen > 5 and then line (1) = LAT.HT then
-- reason, but only valid if modification is active
if activemod then
if JT.IsBlank (reasons) then
reasons := JT.SUS (JT.part_1 (line (2 .. toplen), " "));
else
JT.SU.Append (reasons, " | ");
JT.SU.Append (reasons, JT.part_1
(line (2 .. toplen), " "));
end if;
end if;
skiprest := True;
end if;
if not skiprest and then line (toplen) = LAT.Colon then
close_active_modifications;
activemod := True;
modport := JT.SUS (line (1 .. toplen - 1));
skiprest := True;
end if;
if not skiprest and then
JT.SU.Slice (topline, sx, toplen) = " changed"
then
close_active_modifications;
activemod := True;
modport := JT.SUS (line (1 .. toplen - 8));
skiprest := True;
end if;
end;
end if;
end loop;
close_active_modifications;
sorter.Sort (Container => changed);
sorter.Sort (Container => missing);
sorter.Sort (Container => leftover);
TIO.Put_Line (trackers (id).log_handle, LAT.LF & "=> Checking for " &
"system changes " & description);
if not leftover.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Left over files/directories:");
leftover.Iterate (Process => print'Access);
end if;
if not missing.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Missing files/directories:");
missing.Iterate (Process => print'Access);
end if;
if not changed.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Modified files/directories:");
changed.Iterate (Process => print'Access);
end if;
if passed then
TIO.Put_Line (trackers (id).log_handle, "Everything is fine.");
end if;
return passed;
end detect_leftovers_and_MIA;
-----------------------------
-- interact_with_builder --
-----------------------------
procedure interact_with_builder (id : builders)
is
root : constant String := get_root (id);
command : constant String := chroot & root &
environment_override (enable_tty => True) & "/bin/tcsh";
result : Boolean;
begin
TIO.Put_Line ("Entering interactive test mode at the builder root " &
"directory.");
TIO.Put_Line ("Type 'exit' when done exploring.");
result := Unix.external_command (command);
end interact_with_builder;
------------------------
-- valid_test_phase --
------------------------
function valid_test_phase (afterphase : String) return phases is
begin
if afterphase = "extract" then
return extract;
elsif afterphase = "patch" then
return patch;
elsif afterphase = "configure" then
return configure;
elsif afterphase = "build" then
return build;
elsif afterphase = "stage" then
return check_plist;
elsif afterphase = "install" then
return install;
elsif afterphase = "deinstall" then
return deinstall;
else
return check_sanity;
end if;
end valid_test_phase;
---------------------------------
-- obtain_custom_environment --
---------------------------------
procedure obtain_custom_environment
is
target_name : constant String := PM.synth_confdir & "/" &
JT.USS (PM.configuration.profile) & "-environment";
fragment : TIO.File_Type;
begin
customenv := JT.blank;
if AD.Exists (target_name) then
TIO.Open (File => fragment, Mode => TIO.In_File, Name => target_name);
while not TIO.End_Of_File (fragment) loop
declare
Line : String := TIO.Get_Line (fragment);
begin
if JT.contains (Line, "=") then
JT.SU.Append (customenv, JT.trim (Line) & " ");
end if;
end;
end loop;
TIO.Close (fragment);
end if;
exception
when others =>
if TIO.Is_Open (fragment) then
TIO.Close (fragment);
end if;
end obtain_custom_environment;
--------------------------------
-- set_localbase_protection --
--------------------------------
procedure set_localbase_protection (id : builders; lock : Boolean)
is
procedure remount (readonly : Boolean);
procedure dismount;
smount : constant String := get_root (id);
lbase : constant String := "/usr/local";
slave_local : constant String := smount & "_localbase";
procedure remount (readonly : Boolean)
is
cmd_freebsd : String := "/sbin/mount_nullfs ";
cmd_dragonfly : String := "/sbin/mount_null ";
points : String := slave_local & " " & smount & lbase;
options : String := "-o ro ";
cmd : JT.Text;
cmd_output : JT.Text;
begin
if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then
cmd := JT.SUS (cmd_freebsd);
else
cmd := JT.SUS (cmd_dragonfly);
end if;
if readonly then
JT.SU.Append (cmd, options);
end if;
JT.SU.Append (cmd, points);
if not Unix.piped_mute_command (JT.USS (cmd), cmd_output) then
if uselog then
TIO.Put_Line (trackers (id).log_handle,
"command failed: " & JT.USS (cmd));
if not JT.IsBlank (cmd_output) then
TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output));
end if;
end if;
end if;
end remount;
procedure dismount
is
cmd_unmount : constant String := "/sbin/umount " & smount & lbase;
cmd_output : JT.Text;
begin
if not Unix.piped_mute_command (cmd_unmount, cmd_output) then
if uselog then
TIO.Put_Line (trackers (id).log_handle,
"command failed: " & cmd_unmount);
if not JT.IsBlank (cmd_output) then
TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output));
end if;
end if;
end if;
end dismount;
begin
if lock then
dismount;
remount (readonly => True);
else
dismount;
remount (readonly => False);
end if;
end set_localbase_protection;
------------------------------
-- timeout_multiplier_x10 --
------------------------------
function timeout_multiplier_x10 return Positive
is
command : String := "/usr/bin/env LANG=C /sbin/sysctl vm.loadavg";
comres : JT.Text;
begin
comres := generic_system_command (command);
declare
highend : constant Natural := JT.SU.Length (comres) - 1;
stripped : constant String := JT.SU.Slice (Source => comres, Low => 15, High => highend);
section2 : constant String := JT.part_2 (stripped, " ");
average5 : constant String := JT.part_1 (section2, " ");
avefloat : Float;
begin
avefloat := Float'Value (average5) / Float (number_cores);
if avefloat <= 1.0 then
return 10;
else
return Integer (avefloat * 10.0);
end if;
exception
when others => return 10;
end;
exception
when others => return 10;
end timeout_multiplier_x10;
end PortScan.Buildcycle;
|
jorge-real/TTS-Runtime-Ravenscar | Ada | 9,476 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Ravenscar/HIE version of this package
-- This package provides necessary definitions to handle simple (i.e without
-- entries) protected objects.
-- All the routines that handle protected objects with entries have been moved
-- to two children: Entries and Operations. Note that Entries only contains
-- the type declaration and the OO primitives. This is needed to avoid
-- circular dependency.
-- This package is part of the high level tasking interface used by the
-- compiler to expand Ada 95 tasking constructs into simpler run time calls
-- (aka GNARLI, GNU Ada Run-time Library Interface)
-- Note: the compiler generates direct calls to this interface, via Rtsfind.
-- Any changes to this interface may require corresponding compiler changes
-- in exp_ch9.adb and possibly exp_ch7.adb
with System.Multiprocessors.Fair_Locks;
package System.Tasking.Protected_Objects is
pragma Elaborate_Body;
---------------------------------
-- Compiler Interface (GNARLI) --
---------------------------------
-- The compiler will expand in the GNAT tree the following construct:
-- protected PO is
-- procedure P;
-- private
-- open : boolean := false;
-- end PO;
-- protected body PO is
-- procedure P is
-- ...variable declarations...
-- begin
-- ...B...
-- end P;
-- end PO;
-- as follows:
-- protected type poT is
-- procedure p;
-- private
-- open : boolean := false;
-- end poT;
-- type poTV is limited record
-- open : boolean := false;
-- _object : aliased protection;
-- end record;
-- procedure poPT__pN (_object : in out poTV);
-- procedure poPT__pP (_object : in out poTV);
-- freeze poTV [
-- procedure poTVIP (_init : in out poTV) is
-- begin
-- _init.open := false;
-- obj-init-proc (_init._object);
-- initialize_protection (_init._object'unchecked_access,
-- unspecified_priority);
-- return;
-- end poTVIP;
-- ]
-- po : poT;
-- poTVIP (poTV!(po));
-- procedure poPT__pN (_object : in out poTV) is
-- poR : protection renames _object._object;
-- openP : boolean renames _object.open;
-- ...variable declarations...
-- begin
-- ...B...
-- return;
-- end poPT__pN;
-- procedure poPT__pP (_object : in out poTV) is
-- procedure _clean is
-- begin
-- unlock (_object._object'unchecked_access);
-- return;
-- end _clean;
-- begin
-- lock (_object._object'unchecked_access);
-- B2b : begin
-- poPT__pN (_object);
-- at end
-- _clean;
-- end B2b;
-- return;
-- end poPT__pP;
Null_Protected_Entry : constant := Null_Entry;
Max_Protected_Entry : constant := Max_Entry;
type Protected_Entry_Index is new Entry_Index
range Null_Protected_Entry .. Max_Protected_Entry;
-- Index of the entry (and in some cases of the queue)
type Barrier_Function_Pointer is access
function
(O : System.Address;
E : Protected_Entry_Index)
return Boolean;
-- Pointer to a function which evaluates the barrier of a protected
-- entry body. O is a pointer to the compiler-generated record
-- representing the protected object, and E is the index of the
-- entry serviced by the body.
type Entry_Action_Pointer is access
procedure
(O : System.Address;
P : System.Address;
E : Protected_Entry_Index);
-- Pointer to a procedure which executes the sequence of statements
-- of a protected entry body. O is a pointer to the compiler-generated
-- record representing the protected object, P is a pointer to the
-- record of entry parameters, and E is the index of the
-- entry serviced by the body.
type Entry_Body is record
Barrier : Barrier_Function_Pointer;
Action : Entry_Action_Pointer;
end record;
-- The compiler-generated code passes objects of this type to the GNARL
-- to allow it to access the executable code of an entry body.
type Protection is limited private;
-- This type contains the GNARL state of a protected object. The
-- application-defined portion of the state (i.e. private objects)
-- is maintained by the compiler-generated code.
--
-- Note that there are now 2 Protection types. One for the simple
-- case (no entries) and one for the general case that needs the whole
-- Finalization mechanism.
--
-- This split helps in the case of restricted run time where we want to
-- minimize the size of the code.
type Protection_Access is access all Protection;
Null_PO : constant Protection_Access := null;
procedure Initialize_Protection
(Object : Protection_Access;
Ceiling_Priority : Integer);
-- Initialize the Object parameter so that it can be used by the runtime
-- to keep track of the runtime state of a protected object.
procedure Lock (Object : Protection_Access);
-- Lock a protected object for write access. Upon return, the caller owns
-- the lock to this object, and no other call to Lock with the same
-- argument will return until the corresponding call to Unlock has been
-- made by the caller.
procedure Lock_Read_Only (Object : Protection_Access) renames Lock;
-- Lock a protected object for read access. Upon return, the caller
-- owns the lock for read access, and no other calls to Lock with the
-- same argument will return until the corresponding call to Unlock
-- has been made by the caller. Other calls to Lock_Read_Only may (but
-- need not) return before the call to Unlock, and the corresponding
-- callers will also own the lock for read access.
procedure Unlock (Object : Protection_Access);
-- Relinquish ownership of the lock for the object represented by the
-- Object parameter. One of the tasks waiting on this lock (if any) will
-- be given the lock and allowed to return from the Lock call.
private
type Protection is record
Ceiling : System.Any_Priority;
-- Ceiling priority associated to the protected object
Caller_Priority : System.Any_Priority;
-- Task's active priority when the protected operation was called. This
-- priority is restored when the task relinquish the protected object.
Owner : Task_Id;
-- This field contains the protected object's owner. Null_Task
-- indicates that the protected object is not currently being used.
-- This information is used for detecting the type of potentially
-- blocking operations described in the ARM 9.5.1, par. 15 (external
-- calls on a protected subprogram with the same target object as that
-- of the protected action).
Lock : Multiprocessors.Fair_Locks.Fair_Lock;
-- SMP lock
end record;
pragma Suppress_Initialization (Protection);
end System.Tasking.Protected_Objects;
|
stcarrez/ada-util | Ada | 22,026 | adb | -----------------------------------------------------------------------
-- util-concurrent-tests -- Unit tests for concurrency package
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2019, 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.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Finalization;
with Util.Concurrent.Counters;
with Util.Test_Caller;
with Util.Measures;
with Util.Log.Loggers;
with Util.Concurrent.Copies;
with Util.Concurrent.Pools;
with Util.Concurrent.Fifos;
with Util.Concurrent.Arrays;
with Util.Concurrent.Sequence_Queues;
package body Util.Concurrent.Tests is
use Util.Tests;
use Util.Concurrent.Counters;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Concurrent.Tests");
type Connection is new Ada.Finalization.Controlled with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Value : Natural := 0;
end record;
overriding
function "=" (Left, Right : in Connection) return Boolean;
overriding
procedure Finalize (C : in out Connection);
overriding
function "=" (Left, Right : in Connection) return Boolean is
begin
return Left.Value = Right.Value;
end "=";
package Connection_Pool is new Util.Concurrent.Pools (Connection);
package Connection_Fifo is new Util.Concurrent.Fifos (Connection, 7);
package Connection_Arrays is new Util.Concurrent.Arrays (Connection);
package Connection_Sequences is
new Util.Concurrent.Sequence_Queues (Connection, Natural, 13);
package Caller is new Util.Test_Caller (Test, "Concurrent");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Concurrent.Counter.Increment",
Test_Increment'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Counter.Decrement",
Test_Decrement'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Counter.Decrement + Test",
Test_Decrement_And_Test'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Copies.Get + Set",
Test_Copy'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Pools.Get_Instance",
Test_Pool'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Pools (concurrent test)",
Test_Concurrent_Pool'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Fifos",
Test_Fifo'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Fifos (concurrent test)",
Test_Concurrent_Fifo'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Arrays",
Test_Array'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Sequence_Queues",
Test_Concurrent_Sequences'Access);
end Add_Tests;
overriding
procedure Finalize (C : in out Connection) is
begin
null;
end Finalize;
-- ------------------------------
-- Test concurrent pool
-- ------------------------------
procedure Test_Pool (T : in out Test) is
use Ada.Strings.Unbounded;
P : Connection_Pool.Pool;
C : Connection;
begin
-- Set the pool capacity.
P.Set_Size (Capacity => 10);
-- Insert the objects.
for I in 1 .. 10 loop
C.Name := To_Unbounded_String (Integer'Image (I));
P.Release (C);
end loop;
-- Use the pool and verify the objects.
declare
C : array (1 .. 10) of Connection;
begin
for J in 1 .. 3 loop
-- Get each object and verify that it matches our instance.
for I in reverse 1 .. 10 loop
P.Get_Instance (C (I));
Assert_Equals (T, Integer'Image (I), To_String (C (I).Name), "Invalid pool object");
end loop;
-- Put the object back in the pool.
for I in 1 .. 10 loop
P.Release (C (I));
end loop;
end loop;
end;
declare
S : Util.Measures.Stamp;
begin
for I in 1 .. 1_000 loop
P.Get_Instance (C);
P.Release (C);
end loop;
Util.Measures.Report (S, "Pool Get_Instance+Release", 1000);
end;
end Test_Pool;
-- ------------------------------
-- Test concurrent pool
-- ------------------------------
procedure Test_Concurrent_Pool (T : in out Test) is
use Ada.Strings.Unbounded;
Count_By_Task : constant Natural := 10_001;
Task_Count : constant Natural := 17;
Capacity : constant Natural := 5;
P : Connection_Pool.Pool;
C : Connection;
S : Util.Measures.Stamp;
begin
-- Set the pool capacity.
P.Set_Size (Capacity => Capacity);
-- Insert the objects.
for I in 1 .. Capacity loop
C.Name := To_Unbounded_String (Integer'Image (I));
P.Release (C);
end loop;
declare
-- A task that picks an object from the pool, increment the value and puts
-- back the object in the pool.
task type Worker is
entry Start (Count : in Natural);
end Worker;
task body Worker is
Cnt : Natural;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Get an object from the pool, increment the value and put it back in the pool.
for I in 1 .. Cnt loop
declare
C : Connection;
begin
P.Get_Instance (C);
C.Value := C.Value + 1;
P.Release (C);
end;
end loop;
exception
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Worker;
type Worker_Array is array (1 .. Task_Count) of Worker;
Tasks : Worker_Array;
begin
for I in Tasks'Range loop
Tasks (I).Start (Count_By_Task);
end loop;
-- Leaving the Worker task scope means we are waiting for our tasks to finish.
end;
Util.Measures.Report (S, "Executed Get+Release "
& Natural'Image (Count_By_Task * Task_Count));
declare
Total : Natural := 0;
begin
for I in 1 .. Capacity loop
P.Get_Instance (C);
Total := Total + C.Value;
end loop;
Assert_Equals (T, Count_By_Task * Task_Count, Total, "Invalid computation");
end;
end Test_Concurrent_Pool;
procedure Test_Increment (T : in out Test) is
C : Counter;
begin
Increment (C);
Assert_Equals (T, Value (C), 1, "Increment failed");
end Test_Increment;
procedure Test_Decrement (T : in out Test) is
C : Counter;
begin
Increment (C);
Decrement (C);
Assert_Equals (T, Value (C), 0, "Increment + Decrement failed");
end Test_Decrement;
procedure Test_Decrement_And_Test (T : in out Test) is
C : Counter;
Is_Zero : Boolean;
begin
Increment (C);
Assert_Equals (T, Value (C), 1, "Increment failed");
Decrement (C, Is_Zero);
Assert_Equals (T, Value (C), 0, "Decrement failed");
T.Assert (Is_Zero, "Counter should be zero");
Increment (C);
Increment (C);
Decrement (C, Is_Zero);
T.Assert (not Is_Zero, "Counter should not be zero");
end Test_Decrement_And_Test;
procedure Test_Copy (T : in out Test) is
type Data is record
C : Natural := 0;
L : Long_Long_Integer := 1;
B : Boolean := False;
F : Float := 1.0;
S : String (1 .. 10) := (others => ' ');
end record;
package Data_Atomic is new Util.Concurrent.Copies (Data);
D : Data_Atomic.Atomic;
V : Data;
V2 : Data;
begin
V.C := 1;
V.B := True;
V.S := "0123456789";
D.Set (V);
V2 := D.Get;
Assert_Equals (T, 1, V2.C, "Invalid Data.C");
Assert_Equals (T, "0123456789", V2.S, "Invalid Data.S");
-- Concurrent test:
-- o increment the long long integer
-- o rotate the string by 1 position
declare
Count_By_Task : constant Natural := 100_001;
Task_Count : constant Natural := 17;
-- A task that increments the shared counter <b>Unsafe</b> and <b>Counter</b> by
-- the specified amount.
task type Worker is
entry Start (Count : in Natural);
end Worker;
task body Worker is
Cnt : Natural;
Val : Data;
C : Character;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Increment the two counters as many times as necessary.
for I in 1 .. Cnt loop
Val := D.Get;
-- Val := V;
Val.L := Val.L + 1;
C := Val.S (1);
Val.S (1 .. 9) := Val.S (2 .. 10);
Val.S (10) := C;
D.Set (Val);
-- V := Val;
Val.S (1 .. 9) := Val.S (2 .. 10);
Val.S (10) := C;
end loop;
exception
when others =>
Ada.Text_IO.Put_Line ("Exception raised.");
end Worker;
type Worker_Array is array (1 .. Task_Count) of Worker;
Tasks : Worker_Array;
begin
for I in Tasks'Range loop
Tasks (I).Start (Count_By_Task);
end loop;
-- Leaving the Worker task scope means we are waiting for our tasks to finish.
end;
-- We can't predict the exact value for string after the rotation passes.
-- At least, we must have one of the following values (when using an unprotected
-- copy, the string value contains garbage).
T.Assert (D.Get.S = "0123456789" or else D.Get.S = "1234567890" or else
D.Get.S = "2345678901" or else D.Get.S = "3456789012" or else
D.Get.S = "4567890123" or else D.Get.S = "5678901234" or else
D.Get.S = "6789012345" or else D.Get.S = "7890123456" or else
D.Get.S = "8901234567" or else D.Get.S = "9012345678",
"Invalid result: " & D.Get.S);
end Test_Copy;
-- ------------------------------
-- Test fifo
-- ------------------------------
procedure Test_Fifo (T : in out Test) is
Q : Connection_Fifo.Fifo;
Val : Connection;
Res : Connection;
Cnt : Natural;
begin
for I in 1 .. 100 loop
Cnt := I mod 8;
for J in 1 .. Cnt loop
Val.Name := Ada.Strings.Unbounded.To_Unbounded_String (Natural'Image (I));
Val.Value := I * J;
Q.Enqueue (Val);
Util.Tests.Assert_Equals (T, J, Q.Get_Count, "Invalid queue size");
end loop;
for J in 1 .. Cnt loop
Q.Dequeue (Res);
Util.Tests.Assert_Equals (T, I * J, Res.Value, "Invalid dequeue at "
& Natural'Image (I) & " - " & Natural'Image (J));
Util.Tests.Assert_Equals (T, Natural'Image (I), Val.Name, "Invalid dequeue at "
& Natural'Image (I) & " - " & Natural'Image (J));
end loop;
declare
S : Util.Measures.Stamp;
begin
for J in 1 .. 7 loop
Q.Enqueue (Val);
end loop;
Util.Measures.Report (S, "Enqueue 7 elements ");
end;
declare
S : Util.Measures.Stamp;
begin
for J in 1 .. 7 loop
Q.Dequeue (Val);
end loop;
Util.Measures.Report (S, "Dequeue 7 elements ");
end;
end loop;
for I in 1 .. 100 loop
Q.Set_Size (I);
end loop;
end Test_Fifo;
-- Test concurrent aspects of fifo.
procedure Test_Concurrent_Fifo (T : in out Test) is
Count_By_Task : constant Natural := 60_001;
Task_Count : constant Natural := 17;
Q : Connection_Fifo.Fifo;
S : Util.Measures.Stamp;
begin
Q.Set_Size (23);
declare
-- A task that adds elements in the shared queue.
task type Producer is
entry Start (Count : in Natural);
end Producer;
-- A task that consumes the elements.
task type Consumer is
entry Start (Count : in Natural);
entry Get (Result : out Long_Long_Integer);
end Consumer;
task body Producer is
Cnt : Natural;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Send Cnt values in the queue.
for I in 1 .. Cnt loop
declare
C : Connection;
begin
C.Value := I;
Q.Enqueue (C);
end;
end loop;
exception
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Producer;
task body Consumer is
Cnt : Natural;
Tot : Long_Long_Integer := 0;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Get an object from the pool, increment the value and put it back in the pool.
for I in 1 .. Cnt loop
declare
C : Connection;
begin
Q.Dequeue (C);
-- if C.Value /= I then
-- Ada.Text_IO.Put_Line ("Value: " & Natural'Image (C.Value)
-- & " instead of " & Natural'Image (I));
-- end if;
Tot := Tot + Long_Long_Integer (C.Value);
end;
end loop;
-- Ada.Text_IO.Put_Line ("Total: " & Natural'Image (Tot));
accept Get (Result : out Long_Long_Integer) do
Result := Tot;
end Get;
exception
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Consumer;
type Worker_Array is array (1 .. Task_Count) of Producer;
type Consummer_Array is array (1 .. Task_Count) of Consumer;
Producers : Worker_Array;
Consumers : Consummer_Array;
Value : Long_Long_Integer;
Total : Long_Long_Integer := 0;
Expect : Long_Long_Integer;
begin
for I in Producers'Range loop
Producers (I).Start (Count_By_Task);
end loop;
for I in Consumers'Range loop
Consumers (I).Start (Count_By_Task);
end loop;
for I in Consumers'Range loop
Consumers (I).Get (Value);
Total := Total + Value;
end loop;
Expect := Long_Long_Integer ((Count_By_Task * (Count_By_Task + 1)) / 2);
Expect := Expect * Long_Long_Integer (Task_Count);
Assert_Equals (T, Expect, Total, "Invalid computation");
end;
Util.Measures.Report (S, "Executed Queue+Dequeue "
& Natural'Image (Count_By_Task * Task_Count)
& " task count: " & Natural'Image (Task_Count));
end Test_Concurrent_Fifo;
-- ------------------------------
-- Test concurrent arrays.
-- ------------------------------
procedure Test_Array (T : in out Test) is
procedure Sum_All (C : in Connection);
List : Connection_Arrays.Vector;
L : Connection_Arrays.Ref;
Val : Connection;
Sum : Natural;
procedure Sum_All (C : in Connection) is
begin
Sum := Sum + C.Value;
end Sum_All;
begin
L := List.Get;
T.Assert (L.Is_Empty, "List should be empty");
Val.Value := 1;
List.Append (Val);
T.Assert (L.Is_Empty, "List should be empty");
L := List.Get;
T.Assert (not L.Is_Empty, "List should not be empty");
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 1, Sum, "List iterate failed");
for I in 1 .. 100 loop
Val.Value := I;
List.Append (Val);
end loop;
-- The list refered to by 'L' should not change.
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 1, Sum, "List iterate failed");
-- After getting the list again, we should see the new elements.
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051, Sum, "List iterate failed");
Sum := 0;
L.Reverse_Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051, Sum, "List reverse iterate failed");
-- Remove last value.
Val.Value := 100;
List.Remove (Val);
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051 - 100, Sum, "List iterate failed");
-- Remove first value.
Val.Value := 1;
List.Remove (Val);
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051 - 100 - 1, Sum, "List iterate failed");
-- Remove middle value.
Val.Value := 50;
List.Remove (Val);
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051 - 100 - 1 - 50, Sum, "List iterate failed");
end Test_Array;
-- ------------------------------
-- Test concurrent aspects of sequences.
-- ------------------------------
procedure Test_Concurrent_Sequences (T : in out Test) is
Count_By_Task : constant Natural := 60_001;
Task_Count : constant Natural := 8;
Pool_Count : constant Natural := 23;
Last_Sequence : constant Natural := 1_000;
Q : Connection_Sequences.Queue;
F : Connection_Pool.Pool;
S : Util.Measures.Stamp;
Seq_Error : Boolean := True;
First_Error : Natural := 0;
Expect_Seq : Natural := 0;
begin
Q.Set_Size (Pool_Count * 2);
F.Set_Size (Pool_Count);
declare
-- A task that picks elements and work on them.
task type Worker is
entry Start;
end Worker;
task body Worker is
begin
accept Start do
null;
end Start;
-- Send Cnt values in the queue.
loop
declare
C : Connection;
begin
F.Get_Instance (C, 3.0);
Q.Enqueue (C, C.Value);
exit when C.Value = Last_Sequence;
end;
end loop;
exception
when Connection_Pool.Timeout =>
null;
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Worker;
type Worker_Array is array (1 .. Task_Count) of Worker;
Producers : Worker_Array;
C : Connection;
Seq : Natural;
Avail : Natural;
Next : Natural := 0;
begin
for I in Producers'Range loop
Producers (I).Start;
end loop;
Seq_Error := False;
while Next < Last_Sequence loop
F.Get_Available (Avail);
if Avail /= Pool_Count and then Next - Expect_Seq <= Pool_Count then
C.Value := Next;
F.Release (C);
Next := Next + 1;
else
Q.Dequeue (C, Seq, 3.0);
if Seq /= Expect_Seq then
if First_Error = 0 then
Ada.Text_IO.Put_Line ("Got" & Natural'Image (Seq) & " expecting"
& Natural'Image (Expect_Seq));
First_Error := Seq;
end if;
Seq_Error := True;
end if;
Expect_Seq := Seq + 1;
end if;
end loop;
loop
Q.Dequeue (C, Seq);
if Seq /= Expect_Seq then
if First_Error = 0 then
First_Error := Seq;
end if;
Seq_Error := True;
end if;
Expect_Seq := Seq + 1;
exit when Expect_Seq = Last_Sequence - 1;
end loop;
exception
when Connection_Sequences.Timeout =>
Seq_Error := True;
First_Error := Expect_Seq + 1_000_000;
end;
Util.Measures.Report (S, "Executed Queue+Dequeue "
& Natural'Image (Count_By_Task * Task_Count)
& " task count: " & Natural'Image (Task_Count));
T.Assert (not Seq_Error, "Incorrect sequences " & Natural'Image (First_Error)
& " Expect_Seq=" & Natural'Image (Expect_Seq));
end Test_Concurrent_Sequences;
end Util.Concurrent.Tests;
|
AdaCore/libadalang | Ada | 524 | ads | package Invalid is
Inconsistent_Type : constant Integer := Integer'Max (1, 1.0);
--% node.f_default_expr.p_eval_as_int
No_Args : constant Integer := Integer'Max;
--% node.f_default_expr.p_eval_as_int
One_Arg : constant Integer := Integer'Max (1);
--% node.f_default_expr.p_eval_as_int
Three_Args : constant Integer := Integer'Max (1, 2, 3);
--% node.f_default_expr.p_eval_as_int
For_Enum : constant Boolean := Boolean'Min (True, False);
--% node.f_default_expr.p_eval_as_int
end Invalid;
|
reznikmm/matreshka | Ada | 4,581 | 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_Db.Extension_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Db_Extension_Attribute_Node is
begin
return Self : Db_Extension_Attribute_Node do
Matreshka.ODF_Db.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Db_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Db_Extension_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Extension_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Db_URI,
Matreshka.ODF_String_Constants.Extension_Attribute,
Db_Extension_Attribute_Node'Tag);
end Matreshka.ODF_Db.Extension_Attributes;
|
reznikmm/matreshka | Ada | 4,774 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Table_Source_Service_Elements;
package Matreshka.ODF_Table.Source_Service_Elements is
type Table_Source_Service_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_Source_Service_Elements.ODF_Table_Source_Service
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Source_Service_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Source_Service_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_Source_Service_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Table_Source_Service_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Table_Source_Service_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Table.Source_Service_Elements;
|
AdaCore/libadalang | Ada | 332 | ads | package Dic is
type Set1 is private
with Default_Initial_Condition => Is_Empty (Set1);
pragma Test_Block;
function Is_Empty (S : Set1) return Boolean;
type Set2 is private;
pragma Default_Initial_Condition (Is_Empty (Set2));
pragma Test_Statement;
function Is_Empty (S : Set2) return Boolean;
end Dic;
|
cborao/Ada-P4-chat | Ada | 1,085 | ads |
--PRÁCTICA 4: CÉSAR BORAO MORATINOS (Chat_Procedures.ads)
with Ada.Text_IO;
with Hash_Maps_G;
with Ada.Calendar;
with Ordered_Maps_G;
with Lower_Layer_UDP;
with Ada.Command_Line;
with Ada.Strings.Unbounded;
package Chat_Procedures is
package ATI renames Ada.Text_IO;
package LLU renames Lower_Layer_UDP;
package ACL renames Ada.Command_Line;
package ASU renames Ada.Strings.Unbounded;
use type ASU.Unbounded_String;
type Data is record
Client_EP: LLU.End_Point_Type;
Time: Ada.Calendar.Time;
end record;
type Old_Data is record
Nick: ASU.Unbounded_String;
Time: Ada.Calendar.Time;
end record;
function Max_Valid (Max_Clients: Natural) return Boolean;
procedure Print_Active_Map;
procedure Print_Old_Map;
procedure Case_Init (I_Buffer: access LLU.Buffer_Type;
O_Buffer: access LLU.Buffer_Type);
procedure Case_Writer (I_Buffer: access LLU.Buffer_Type;
O_Buffer: access LLU.Buffer_Type);
procedure Case_Logout (I_Buffer: access LLU.Buffer_Type;
O_Buffer: access LLU.Buffer_Type);
end Chat_Procedures;
|
AdaCore/Ada_Drivers_Library | Ada | 17,346 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_usart.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief USARTS HAL module driver. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with System; use System;
with STM32_SVD.USART; use STM32_SVD, STM32_SVD.USART;
with STM32.Device; use STM32.Device;
package body STM32.USARTs is
---------------
-- APB_Clock --
---------------
function APB_Clock (This : USART) return UInt32 is
Clocks : constant RCC_System_Clocks := System_Clock_Frequencies;
begin
if This.Periph.all'Address = USART1_Base
or
This.Periph.all'Address = USART6_Base
then
return Clocks.PCLK2;
else
return Clocks.PCLK1;
end if;
end APB_Clock;
------------
-- Enable --
------------
procedure Enable (This : in out USART) is
begin
This.Periph.CR1.UE := True;
end Enable;
-------------
-- Disable --
-------------
procedure Disable (This : in out USART) is
begin
This.Periph.CR1.UE := False;
end Disable;
-------------
-- Enabled --
-------------
function Enabled (This : USART) return Boolean is
(This.Periph.CR1.UE);
-------------------
-- Set_Stop_Bits --
-------------------
procedure Set_Stop_Bits (This : in out USART; To : Stop_Bits)
is
begin
This.Periph.CR2.STOP := Stop_Bits'Enum_Rep (To);
end Set_Stop_Bits;
---------------------
-- Set_Word_Length --
---------------------
procedure Set_Word_Length
(This : in out USART;
To : Word_Lengths)
is
begin
This.Periph.CR1.M := To = Word_Length_9;
end Set_Word_Length;
----------------
-- Set_Parity --
----------------
procedure Set_Parity (This : in out USART; To : Parities) is
begin
case To is
when No_Parity =>
This.Periph.CR1.PCE := False;
This.Periph.CR1.PS := False;
when Even_Parity =>
This.Periph.CR1.PCE := True;
This.Periph.CR1.PS := False;
when Odd_Parity =>
This.Periph.CR1.PCE := True;
This.Periph.CR1.PS := True;
end case;
end Set_Parity;
-------------------
-- Set_Baud_Rate --
-------------------
procedure Set_Baud_Rate (This : in out USART; To : Baud_Rates)
is
Clock : constant UInt32 := APB_Clock (This);
Over_By_8 : constant Boolean := This.Periph.CR1.OVER8;
Int_Scale : constant UInt32 := (if Over_By_8 then 2 else 4);
Int_Divider : constant UInt32 := (25 * Clock) / (Int_Scale * To);
Frac_Divider : constant UInt32 := Int_Divider rem 100;
begin
-- the integer part of the divi
if Over_By_8 then
This.Periph.BRR.DIV_Fraction :=
BRR_DIV_Fraction_Field (((Frac_Divider * 8) + 50) / 100 mod 8);
else
This.Periph.BRR.DIV_Fraction :=
BRR_DIV_Fraction_Field (((Frac_Divider * 16) + 50) / 100 mod 16);
end if;
This.Periph.BRR.DIV_Mantissa :=
BRR_DIV_Mantissa_Field (Int_Divider / 100);
end Set_Baud_Rate;
---------------------------
-- Set_Oversampling_Mode --
---------------------------
procedure Set_Oversampling_Mode
(This : in out USART;
To : Oversampling_Modes)
is
begin
This.Periph.CR1.OVER8 := To = Oversampling_By_8;
end Set_Oversampling_Mode;
--------------
-- Set_Mode --
--------------
procedure Set_Mode (This : in out USART; To : UART_Modes) is
begin
This.Periph.CR1.RE := To /= Tx_Mode;
This.Periph.CR1.TE := To /= Rx_Mode;
end Set_Mode;
----------------------
-- Set_Flow_Control --
----------------------
procedure Set_Flow_Control (This : in out USART; To : Flow_Control) is
begin
case To is
when No_Flow_Control =>
This.Periph.CR3.RTSE := False;
This.Periph.CR3.CTSE := False;
when RTS_Flow_Control =>
This.Periph.CR3.RTSE := True;
This.Periph.CR3.CTSE := False;
when CTS_Flow_Control =>
This.Periph.CR3.RTSE := False;
This.Periph.CR3.CTSE := True;
when RTS_CTS_Flow_Control =>
This.Periph.CR3.RTSE := True;
This.Periph.CR3.CTSE := True;
end case;
end Set_Flow_Control;
---------
-- Put --
---------
procedure Transmit (This : in out USART; Data : UInt9) is
begin
This.Periph.DR.DR := Data;
end Transmit;
---------
-- Get --
---------
procedure Receive (This : USART; Data : out UInt9) is
begin
Data := Current_Input (This);
end Receive;
-------------------
-- Current_Input --
-------------------
function Current_Input (This : USART) return UInt9 is (This.Periph.DR.DR);
--------------
-- Tx_Ready --
--------------
function Tx_Ready (This : USART) return Boolean is
begin
return This.Periph.SR.TXE;
end Tx_Ready;
--------------
-- Rx_Ready --
--------------
function Rx_Ready (This : USART) return Boolean is
begin
return This.Periph.SR.RXNE;
end Rx_Ready;
------------
-- Status --
------------
function Status (This : USART; Flag : USART_Status_Flag) return Boolean is
begin
case Flag is
when Parity_Error_Indicated =>
return This.Periph.SR.PE;
when Framing_Error_Indicated =>
return This.Periph.SR.FE;
when USART_Noise_Error_Indicated =>
return This.Periph.SR.NF;
when Overrun_Error_Indicated =>
return This.Periph.SR.ORE;
when Idle_Line_Detection_Indicated =>
return This.Periph.SR.IDLE;
when Read_Data_Register_Not_Empty =>
return This.Periph.SR.RXNE;
when Transmission_Complete_Indicated =>
return This.Periph.SR.TC;
when Transmit_Data_Register_Empty =>
return This.Periph.SR.TXE;
when Line_Break_Detection_Indicated =>
return This.Periph.SR.LBD;
when Clear_To_Send_Indicated =>
return This.Periph.SR.CTS;
end case;
end Status;
------------------
-- Clear_Status --
------------------
procedure Clear_Status (This : in out USART; Flag : USART_Status_Flag) is
begin
case Flag is
when Parity_Error_Indicated =>
This.Periph.SR.PE := False;
when Framing_Error_Indicated =>
This.Periph.SR.FE := False;
when USART_Noise_Error_Indicated =>
This.Periph.SR.NF := False;
when Overrun_Error_Indicated =>
This.Periph.SR.ORE := False;
when Idle_Line_Detection_Indicated =>
This.Periph.SR.IDLE := False;
when Read_Data_Register_Not_Empty =>
This.Periph.SR.RXNE := False;
when Transmission_Complete_Indicated =>
This.Periph.SR.TC := False;
when Transmit_Data_Register_Empty =>
This.Periph.SR.TXE := False;
when Line_Break_Detection_Indicated =>
This.Periph.SR.LBD := False;
when Clear_To_Send_Indicated =>
This.Periph.SR.CTS := False;
end case;
end Clear_Status;
-----------------------
-- Enable_Interrupts --
-----------------------
procedure Enable_Interrupts
(This : in out USART;
Source : USART_Interrupt)
is
begin
case Source is
when Parity_Error =>
This.Periph.CR1.PEIE := True;
when Transmit_Data_Register_Empty =>
This.Periph.CR1.TXEIE := True;
when Transmission_Complete =>
This.Periph.CR1.TCIE := True;
when Received_Data_Not_Empty =>
This.Periph.CR1.RXNEIE := True;
when Idle_Line_Detection =>
This.Periph.CR1.IDLEIE := True;
when Line_Break_Detection =>
This.Periph.CR2.LBDIE := True;
when Clear_To_Send =>
This.Periph.CR3.CTSIE := True;
when Error =>
This.Periph.CR3.EIE := True;
end case;
end Enable_Interrupts;
------------------------
-- Disable_Interrupts --
------------------------
procedure Disable_Interrupts
(This : in out USART;
Source : USART_Interrupt)
is
begin
case Source is
when Parity_Error =>
This.Periph.CR1.PEIE := False;
when Transmit_Data_Register_Empty =>
This.Periph.CR1.TXEIE := False;
when Transmission_Complete =>
This.Periph.CR1.TCIE := False;
when Received_Data_Not_Empty =>
This.Periph.CR1.RXNEIE := False;
when Idle_Line_Detection =>
This.Periph.CR1.IDLEIE := False;
when Line_Break_Detection =>
This.Periph.CR2.LBDIE := False;
when Clear_To_Send =>
This.Periph.CR3.CTSIE := False;
when Error =>
This.Periph.CR3.EIE := False;
end case;
end Disable_Interrupts;
-----------------------
-- Interrupt_Enabled --
-----------------------
function Interrupt_Enabled
(This : USART;
Source : USART_Interrupt)
return Boolean
is
begin
case Source is
when Parity_Error =>
return This.Periph.CR1.PEIE;
when Transmit_Data_Register_Empty =>
return This.Periph.CR1.TXEIE;
when Transmission_Complete =>
return This.Periph.CR1.TCIE;
when Received_Data_Not_Empty =>
return This.Periph.CR1.RXNEIE;
when Idle_Line_Detection =>
return This.Periph.CR1.IDLEIE;
when Line_Break_Detection =>
return This.Periph.CR2.LBDIE;
when Clear_To_Send =>
return This.Periph.CR3.CTSIE;
when Error =>
return This.Periph.CR3.EIE;
end case;
end Interrupt_Enabled;
----------------------------------
-- Enable_DMA_Transmit_Requests --
----------------------------------
procedure Enable_DMA_Transmit_Requests (This : in out USART) is
begin
This.Periph.CR3.DMAT := True;
end Enable_DMA_Transmit_Requests;
---------------------------------
-- Enable_DMA_Receive_Requests --
---------------------------------
procedure Enable_DMA_Receive_Requests (This : in out USART) is
begin
This.Periph.CR3.DMAR := True;
end Enable_DMA_Receive_Requests;
-----------------------------------
-- Disable_DMA_Transmit_Requests --
-----------------------------------
procedure Disable_DMA_Transmit_Requests (This : in out USART) is
begin
This.Periph.CR3.DMAT := False;
end Disable_DMA_Transmit_Requests;
----------------------------------
-- Disable_DMA_Receive_Requests --
----------------------------------
procedure Disable_DMA_Receive_Requests (This : in out USART) is
begin
This.Periph.CR3.DMAR := False;
end Disable_DMA_Receive_Requests;
-----------------------------------
-- DMA_Transmit_Requests_Enabled --
-----------------------------------
function DMA_Transmit_Requests_Enabled (This : USART) return Boolean is
(This.Periph.CR3.DMAT);
----------------------------------
-- DMA_Receive_Requests_Enabled --
----------------------------------
function DMA_Receive_Requests_Enabled (This : USART) return Boolean is
(This.Periph.CR3.DMAR);
-----------------------------
-- Resume_DMA_Transmission --
-----------------------------
procedure Resume_DMA_Transmission (This : in out USART) is
begin
Enable_DMA_Transmit_Requests (This);
if not Enabled (This) then
Enable (This);
end if;
end Resume_DMA_Transmission;
--------------------------
-- Resume_DMA_Reception --
--------------------------
procedure Resume_DMA_Reception (This : in out USART) is
begin
Enable_DMA_Receive_Requests (This);
if not Enabled (This) then
Enable (This);
end if;
end Resume_DMA_Reception;
---------------------------
-- Data_Register_Address --
---------------------------
function Data_Register_Address (This : USART) return System.Address is
(This.Periph.DR'Address);
---------------
-- Data_Size --
---------------
overriding
function Data_Size (This : USART) return HAL.UART.UART_Data_Size
is
begin
if This.Periph.CR1.M then
return Data_Size_9b;
else
return Data_Size_8b;
end if;
end Data_Size;
--------------
-- Transmit --
--------------
overriding
procedure Transmit
(This : in out USART;
Data : UART_Data_8b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
pragma Unreferenced (Status, Timeout);
begin
for Elt of Data loop
loop
exit when This.Tx_Ready;
end loop;
This.Transmit (UInt9 (Elt));
end loop;
Status := Ok;
end Transmit;
--------------
-- Transmit --
--------------
overriding
procedure Transmit
(This : in out USART;
Data : UART_Data_9b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
pragma Unreferenced (Status, Timeout);
begin
for Elt of Data loop
loop
exit when This.Tx_Ready;
end loop;
This.Transmit (Elt);
end loop;
Status := Ok;
end Transmit;
-------------
-- Receive --
-------------
overriding
procedure Receive
(This : in out USART;
Data : out UART_Data_8b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
pragma Unreferenced (Status, Timeout);
begin
for Elt of Data loop
loop
exit when This.Rx_Ready;
end loop;
This.Receive (UInt9 (Elt));
end loop;
Status := Ok;
end Receive;
-------------
-- Receive --
-------------
overriding
procedure Receive
(This : in out USART;
Data : out UART_Data_9b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
pragma Unreferenced (Status, Timeout);
begin
for Elt of Data loop
loop
exit when This.Rx_Ready;
end loop;
This.Receive (Elt);
end loop;
Status := Ok;
end Receive;
end STM32.USARTs;
|
sungyeon/drake | Ada | 2,166 | adb | package body System.Fat_Lflt is
function frexp (value : Long_Float; exp : access Integer)
return Long_Float
with Import, Convention => Intrinsic, External_Name => "__builtin_frexp";
function inf return Long_Float
with Import, Convention => Intrinsic, External_Name => "__builtin_inf";
function isfinite (X : Long_Float) return Integer
with Import,
Convention => Intrinsic, External_Name => "__builtin_isfinite";
pragma Warnings (Off, isfinite); -- [gcc 4.6] excessive prototype checking
package body Attr_Long_Float is
function Compose (Fraction : Long_Float; Exponent : Integer)
return Long_Float is
begin
return Scaling (Attr_Long_Float.Fraction (Fraction), Exponent);
end Compose;
function Exponent (X : Long_Float) return Integer is
Result : aliased Integer;
Dummy : Long_Float;
begin
Dummy := frexp (X, Result'Access);
return Result;
end Exponent;
function Fraction (X : Long_Float) return Long_Float is
Dummy : aliased Integer;
begin
return frexp (X, Dummy'Access);
end Fraction;
function Leading_Part (X : Long_Float; Radix_Digits : Integer)
return Long_Float
is
S : constant Integer := Radix_Digits - Exponent (X);
begin
return Scaling (Truncation (Scaling (X, S)), -S);
end Leading_Part;
function Machine (X : Long_Float) return Long_Float is
begin
return Long_Float (Long_Long_Float (X)); -- ???
end Machine;
function Pred (X : Long_Float) return Long_Float is
begin
return Adjacent (X, -inf);
end Pred;
function Succ (X : Long_Float) return Long_Float is
begin
return Adjacent (X, inf);
end Succ;
function Unbiased_Rounding (X : Long_Float) return Long_Float is
begin
return X - Remainder (X, 1.0);
end Unbiased_Rounding;
function Valid (X : not null access Long_Float) return Boolean is
begin
return isfinite (X.all) /= 0;
end Valid;
end Attr_Long_Float;
end System.Fat_Lflt;
|
reznikmm/matreshka | Ada | 9,723 | adb | ------------------------------------------------------------------------------
-- --
-- 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.DC.Holders.Alignment_Kinds;
with AMF.DC.Holders.Bounds;
with AMF.DC.Holders.Colors;
with AMF.DC.Holders.Dimensions;
with AMF.DC.Holders.Known_Colors;
with AMF.DC.Holders.Points;
package body AMF.DC.Holders is
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DC.Optional_DC_Alignment_Kind is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DC.Holders.Alignment_Kinds.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DC.Holders.Alignment_Kinds.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DC.Optional_DC_Bounds is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DC.Holders.Bounds.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DC.Holders.Bounds.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DC.Optional_DC_Color is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DC.Holders.Colors.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DC.Holders.Colors.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DC.Optional_DC_Dimension is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DC.Holders.Dimensions.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DC.Holders.Dimensions.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DC.Optional_DC_Known_Color is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DC.Holders.Known_Colors.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DC.Holders.Known_Colors.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DC.Optional_DC_Point is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DC.Holders.Points.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DC.Holders.Points.Element (Holder));
end if;
end Element;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DC.Optional_DC_Alignment_Kind)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DC.Holders.Alignment_Kinds.Value_Tag);
if not Element.Is_Empty then
AMF.DC.Holders.Alignment_Kinds.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DC.Optional_DC_Bounds)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DC.Holders.Bounds.Value_Tag);
if not Element.Is_Empty then
AMF.DC.Holders.Bounds.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DC.Optional_DC_Color)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DC.Holders.Colors.Value_Tag);
if not Element.Is_Empty then
AMF.DC.Holders.Colors.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DC.Optional_DC_Dimension)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DC.Holders.Dimensions.Value_Tag);
if not Element.Is_Empty then
AMF.DC.Holders.Dimensions.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DC.Optional_DC_Known_Color)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DC.Holders.Known_Colors.Value_Tag);
if not Element.Is_Empty then
AMF.DC.Holders.Known_Colors.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DC.Optional_DC_Point)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DC.Holders.Points.Value_Tag);
if not Element.Is_Empty then
AMF.DC.Holders.Points.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
end AMF.DC.Holders;
|
zhmu/ananas | Ada | 215 | adb | -- { dg-do compile }
-- { dg-options "-gnatwa" }
with Interfaces; use Interfaces;
package body Warn30 is
procedure Incr (X : in out Interfaces.Integer_64) is
begin
X := X + 1;
end Incr;
end Warn30; |
charlie5/cBound | Ada | 1,739 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_mapfv_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;
pad1 : aliased swig.int8_t_Array (0 .. 3);
n : aliased Interfaces.Unsigned_32;
datum : aliased xcb.xcb_glx_float32_t;
pad2 : aliased swig.int8_t_Array (0 .. 11);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_get_mapfv_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_mapfv_reply_t.Item,
Element_Array => xcb.xcb_glx_get_mapfv_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_get_mapfv_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_mapfv_reply_t.Pointer,
Element_Array => xcb.xcb_glx_get_mapfv_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_mapfv_reply_t;
|
usnistgov/rcslib | Ada | 1,121 | adb | with Nml;
with Nml_Test_Format_N_Ada;
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Unchecked_Conversion;
with Interfaces.C;
with Ada.Command_Line;
procedure Nml_TEst_Server_Ada is
Connection1 : Nml.NmlConnection_Access;
begin
if Ada.Command_Line.Argument_Count < 3 then
Ada.Text_IO.Put("usage: buffername processname cfgsource");
Ada.Text_IO.New_Line;
Ada.Command_Line.Set_Exit_Status(Ada.Command_Line.Failure);
return;
end if;
Nml.Set_To_Server;
Connection1 := Nml.CreateConnection(Nml_Test_Format_N_Ada.Format'Access,
Ada.Command_Line.Argument(1),
Ada.Command_Line.Argument(2),
Ada.Command_Line.Argument(3));
if True /= Nml.Valid(Connection1) then
Nml.Free(Connection1);
Ada.Command_Line.Set_Exit_Status(Ada.Command_Line.Failure);
return;
end if;
-- Nml.Run_Servers; does not return until someone presses Control-C or
-- the process is sent SIGINT;
Nml.Run_Servers;
Nml.Free(Connection1);
end Nml_Test_Server_Ada;
|
reznikmm/matreshka | Ada | 8,283 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_01D7 is
pragma Preelaborate;
Group_01D7 : aliased constant Core_Second_Stage
:= (16#15# => -- 01D715
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#1C# .. 16#34# => -- 01D71C .. 01D734
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Math
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#35# => -- 01D735
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4F# => -- 01D74F
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#56# .. 16#6E# => -- 01D756 .. 01D76E
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Math
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#6F# => -- 01D76F
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#89# => -- 01D789
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#90# .. 16#A8# => -- 01D790 .. 01D7A8
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Math
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#A9# => -- 01D7A9
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#C3# => -- 01D7C3
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#CA# => -- 01D7CA
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Math
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#CC# .. 16#CD# => -- 01D7CC .. 01D7CD
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#CE# .. 16#FF# => -- 01D7CE .. 01D7FF
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Other_Math
| Grapheme_Base
| ID_Continue
| Math
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
others =>
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Math
| Alphabetic
| Cased
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| Math
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_01D7;
|
reznikmm/matreshka | Ada | 4,057 | 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.Draw_Fill_Image_Height_Attributes;
package Matreshka.ODF_Draw.Fill_Image_Height_Attributes is
type Draw_Fill_Image_Height_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Fill_Image_Height_Attributes.ODF_Draw_Fill_Image_Height_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Fill_Image_Height_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Fill_Image_Height_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Fill_Image_Height_Attributes;
|
sungyeon/drake | Ada | 1,475 | ads | pragma License (Unrestricted);
-- extended unit
package Ada.IO_Modes is
-- Root types of File_Mode and for the parameters Form.
pragma Pure;
type File_Mode is (In_File, Out_File, Append_File);
type Inout_File_Mode is (In_File, Inout_File, Out_File); -- Direct_IO
-- the types for the parameters Form of Stream_IO
type File_Shared_Spec is (
Allow, -- "shared=allow", "shared=yes", or "shared=no"
Read_Only, -- "shared=read"
Deny, -- "shared=deny"
By_Mode); -- default
type File_Shared is new File_Shared_Spec range Allow .. Deny;
-- subtype File_Wait is Boolean;
-- False as "wait=false", or default
-- True as "wait=true"
-- subtype File_Overwrite is Boolean;
-- False as "overwrite=false"
-- True as "overwrite=true", or default
-- the types for the parameters Form of Text_IO
type File_External_Base is (
Terminal,
UTF_8, -- "external=utf-8", or "wcem=8"
Locale, -- "external=dbcs", Windows only
By_Target); -- default, UTF_8 in POSIX, or Locale in Windows
type File_External_Spec is new File_External_Base range UTF_8 .. By_Target;
type File_External is new File_External_Base range Terminal .. Locale;
type File_New_Line_Spec is (
LF, -- "nl=lf"
CR, -- "nl=cr"
CR_LF, -- "nl=m"
By_Target); -- default, LF in POSIX, or CR_LF in Windows
type File_New_Line is new File_New_Line_Spec range LF .. CR_LF;
end Ada.IO_Modes;
|
burratoo/Acton | Ada | 1,141 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK PROJECT SUPPORT PACKAGE --
-- ST STM32F4 --
-- --
-- OAK.PROJECT_SUPPORT_PACKAGE.MICROCONTROLLER --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
package Oak.Project_Support_Package.Microcontroller with Preelaborate is
procedure Setup
with Export, Convention => Assembly,
External_Name => "microcontroller_setup";
end Oak.Project_Support_Package.Microcontroller;
|
reznikmm/gela | Ada | 21,402 | adb | with League.Characters;
with League.String_Vectors;
package body Gela.Plain_Symbol_Sets is
use Gela.Lexical_Types;
function To_Operator_Symbol
(Text : League.Strings.Universal_String) return First_Symbols;
-- Return symbol corresponding to an operator (rem mod not xor or abs and)
-- or '0' otherwise
-- Cast List_Index into SYmbol/Symbol_List and backward
function To_Symbol
(Value : List_Index) return Gela.Lexical_Types.Symbol;
function To_Symbol_List (List : List_Index) return List_Symbol;
function From_Symbol
(Value : Gela.Lexical_Types.Symbol) return List_Index;
function From_Symbol_List (List : List_Symbol) return List_Index;
Map_1 : constant array (Wide_Wide_Character range '&' .. '>') of
First_Symbols :=
('<' => Token_Kind'Pos (Less_Token),
'=' => Token_Kind'Pos (Equal_Token),
'>' => Token_Kind'Pos (Greater_Token),
'-' => Token_Kind'Pos (Hyphen_Token),
'/' => Token_Kind'Pos (Slash_Token),
'*' => Token_Kind'Pos (Star_Token),
'&' => Token_Kind'Pos (Ampersand_Token),
'+' => Token_Kind'Pos (Plus_Token),
others => 0);
-- Single char operators
Map_2 : constant array (Wide_Wide_Character range '/' .. '>') of
First_Symbols :=
('<' => Token_Kind'Pos (Less_Or_Equal_Token),
'/' => Token_Kind'Pos (Inequality_Token),
'>' => Token_Kind'Pos (Greater_Or_Equal_Token),
others => 0);
-- First char of two chars operator (<=, /=, >=)
Power_Value : constant Operator_Symbol :=
Token_Kind'Pos (Double_Star_Token);
-- ** operator symbol
-- Images of predefined operators
A1 : constant array (Symbol range 1 .. 8) of Wide_Wide_String (1 .. 3) :=
("""<""", """=""", """>""", """-""",
"""/""", """*""", """&""", """+""");
A2 : constant array (Symbol range 9 .. 13) of Wide_Wide_String (1 .. 4)
:= ("""<=""", """>=""", """/=""", """**""", """or""");
A3 : constant array (Symbol range 14 .. 19) of Wide_Wide_String (1 .. 5)
:= ("""and""", """xor""", """mod""", """rem""", """abs""", """not""");
-----------------
-- Create_List --
-----------------
overriding procedure Create_List
(Self : in out Symbol_Set;
Head : Gela.Lexical_Types.Symbol;
Tail : Gela.Lexical_Types.Symbol_List :=
Gela.Lexical_Types.Empty_Symbol_List;
Value : out Gela.Lexical_Types.Symbol_List)
is
Node : constant List_Node := (Head, Gela.Lexical_Types.Symbol (Tail));
Cursor : List_Maps.Cursor;
begin
if Tail = Gela.Lexical_Types.Empty_Symbol_List then
-- Symbol and Symbol_List have the same encoding, just cast.
Value := Gela.Lexical_Types.Symbol_List (Head);
return;
end if;
Cursor := Self.List_Map.Find (Node);
if List_Maps.Has_Element (Cursor) then
Value := To_Symbol_List (List_Maps.Element (Cursor));
else
Self.Lists.Append (Node);
Self.List_Map.Insert (Node, Self.Lists.Last_Index);
Value := To_Symbol_List (Self.Lists.Last_Index);
end if;
end Create_List;
-----------------
-- Create_List --
-----------------
overriding procedure Create_List
(Self : in out Symbol_Set;
Head : Gela.Lexical_Types.Symbol_List;
Tail : Gela.Lexical_Types.Symbol_List;
Value : out Gela.Lexical_Types.Symbol_List) is
begin
if Head = Empty_Symbol_List then
Value := Tail;
else
Self.Create_List (Head => Self.Tail (Head),
Tail => Tail,
Value => Value);
Self.Create_List (Head => Self.Head (Head),
Tail => Value,
Value => Value);
end if;
end Create_List;
-----------
-- Fetch --
-----------
overriding procedure Fetch
(Self : in out Symbol_Set;
Image : League.Strings.Universal_String;
Value : out Gela.Lexical_Types.Symbol) is
begin
if Image.Element (1).To_Wide_Wide_Character in ''' | '"' | '%' then
Value := Self.Get (Image);
return;
elsif Image.Index ('.') > 0 then
declare
List : League.String_Vectors.Universal_String_Vector;
Suffix : Gela.Lexical_Types.Symbol;
begin
List := Image.Split ('.');
Self.Fetch (List.Element (1), Value);
for J in 2 .. List.Length loop
Self.Fetch (List.Element (J), Suffix);
Self.Join (Value, Suffix, Value);
end loop;
return;
end;
end if;
declare
Cursor : String_Maps.Cursor := Self.Original.Find (Image);
Folded : League.Strings.Universal_String;
begin
if String_Maps.Has_Element (Cursor) then
Value := String_Maps.Element (Cursor);
return;
end if;
Folded := Image.To_Simple_Casefold;
Cursor := Self.Folded.Find (Folded);
if String_Maps.Has_Element (Cursor) then
Value := String_Maps.Element (Cursor);
return;
end if;
Self.Values.Append ((Original => Image, Folded => Folded));
Value := Gela.Lexical_Types.Symbol (Self.Values.Last_Index);
Self.Original.Insert (Image, Value);
Self.Folded.Insert (Folded, Value);
end;
end Fetch;
------------
-- Folded --
------------
overriding function Folded
(Self : Symbol_Set;
Value : Gela.Lexical_Types.Symbol)
return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
begin
if Value not in Simple_Symbol then
return Folded (Self, Self.Prefix (Value)) & '.' &
Folded (Self, Self.Selector (Value));
elsif Value < 16#11_0000# then
return Self.Image (Value);
else
return Self.Values.Element (Symbol_Index (Value)).Folded;
end if;
end Folded;
-----------------
-- From_Symbol --
-----------------
function From_Symbol
(Value : Gela.Lexical_Types.Symbol) return List_Index is
begin
return List_Index (Value - Compound_Symbol'First);
end From_Symbol;
----------------------
-- From_Symbol_List --
----------------------
function From_Symbol_List (List : List_Symbol) return List_Index is
begin
return List_Index (List - List_Symbol'First);
end From_Symbol_List;
---------
-- Get --
---------
overriding function Get
(Self : Symbol_Set;
Image : League.Strings.Universal_String)
return Gela.Lexical_Types.Symbol
is
use type League.Characters.Universal_Character;
Length : constant Natural := Image.Length;
First : constant Wide_Wide_Character :=
Image.Element (1).To_Wide_Wide_Character;
Char : Wide_Wide_Character;
begin
if First = ''' then -- Character literal
return Wide_Wide_Character'Pos
(Image.Element (2).To_Wide_Wide_Character);
elsif First /= '"' then -- Identifier
if Image.Index ('.') > 0 then -- Compound name
declare
List : League.String_Vectors.Universal_String_Vector;
Suffix : Gela.Lexical_Types.Symbol;
Value : Gela.Lexical_Types.Symbol;
Node : List_Node;
Cursor : List_Maps.Cursor;
begin
List := Image.Split ('.');
Value := Self.Get (List.Element (1));
if Value = Gela.Lexical_Types.No_Symbol then
return Gela.Lexical_Types.No_Symbol;
end if;
for J in 2 .. List.Length loop
Suffix := Self.Get (List.Element (J));
Node := (Value, Suffix);
Cursor := Self.List_Map.Find (Node);
if List_Maps.Has_Element (Cursor) then
Value := To_Symbol (List_Maps.Element (Cursor));
else
return Gela.Lexical_Types.No_Symbol;
end if;
end loop;
return Value;
end;
end if;
declare
Cursor : String_Maps.Cursor := Self.Original.Find (Image);
begin
if String_Maps.Has_Element (Cursor) then
return String_Maps.Element (Cursor);
end if;
Cursor := Self.Folded.Find (Image.To_Simple_Casefold);
if String_Maps.Has_Element (Cursor) then
return String_Maps.Element (Cursor);
end if;
return Gela.Lexical_Types.No_Symbol;
end;
elsif Length = 3 then -- String literal (one charater) "#"
Char := Image.Element (2).To_Wide_Wide_Character;
if Char in Map_1'Range then
return Map_1 (Char);
end if;
elsif Length = 4 then -- String literal (two charaters) "##"
if Image.Element (3) = '=' then
Char := Image.Element (2).To_Wide_Wide_Character;
if Char in Map_2'Range then
return Map_2 (Char);
end if;
elsif Image.Element (2) = '*' and Image.Element (3) = '*' then
return Power_Value;
else -- This could be "or"
return To_Operator_Symbol (Image);
end if;
elsif Length = 5 then -- String literal (three charaters) "###"
return To_Operator_Symbol (Image);
end if;
return Gela.Lexical_Types.No_Symbol;
end Get;
----------
-- Hash --
----------
function Hash (Item : List_Node) return Ada.Containers.Hash_Type is
use type Ada.Containers.Hash_Type;
begin
return Ada.Containers.Hash_Type (Item.Right) * 3571 +
Ada.Containers.Hash_Type (Item.Left);
end Hash;
----------
-- Head --
----------
overriding function Head
(Self : Symbol_Set;
Value : Gela.Lexical_Types.Symbol_List)
return Gela.Lexical_Types.Symbol is
begin
if Value in List_Symbol then
declare
Index : constant List_Index := From_Symbol_List (Value);
Node : constant List_Node := Self.Lists.Element (Index);
begin
return Node.Left;
end;
else
-- Symbol and Symbol_List have the same encoding, just cast.
return Gela.Lexical_Types.Symbol (Value);
end if;
end Head;
-----------
-- Image --
-----------
overriding function Image
(Self : Symbol_Set;
Value : Gela.Lexical_Types.Symbol)
return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
begin
case Value is
when 0 =>
return League.Strings.Empty_Universal_String;
when Operator_Symbol =>
return Self.Operator (Value);
when 20 .. 16#10_FFFF# =>
declare
Result : Wide_Wide_String := "'_'";
begin
Result (2) := Wide_Wide_Character'Val (Value);
return League.Strings.To_Universal_String (Result);
end;
when 16#11_0000# .. Simple_Symbol'Last =>
return Self.Values.Element (Symbol_Index (Value)).Original;
when Compound_Symbol =>
return Self.Image (Self.Prefix (Value)) & '.' &
Self.Image (Self.Selector (Value));
when others =>
raise Constraint_Error;
end case;
end Image;
----------------
-- Initialize --
----------------
not overriding procedure Initialize (Self : in out Symbol_Set) is
pragma Warnings (Off); -- Disable unreferenced warning for literals
type Predefined_Symbol_Name is
(All_Calls_Remote_Symbol,
Assert_Symbol,
Assertion_Policy_Symbol,
Asynchronous_Symbol,
Atomic_Symbol,
Atomic_Components_Symbol,
Attach_Handler_Symbol,
Controlled_Symbol,
Convention_Symbol,
Detect_Blocking_Symbol,
Discard_Names_Symbol,
Elaborate_Symbol,
Elaborate_All_Symbol,
Elaborate_Body_Symbol,
Export_Symbol,
Import_Symbol,
Inline_Symbol,
Inspection_Point_Symbol,
Interrupt_Handler_Symbol,
Interrupt_Priority_Symbol,
Linker_Options_Symbol,
List_Symbol,
Locking_Policy_Symbol,
No_Return_Symbol,
Normalize_Scalars_Symbol,
Optimize_Symbol,
Pack_Symbol,
Page_Symbol,
Partition_Elaboration_Policy_Symbol,
Preelaborable_Initialization_Symbol,
Preelaborate_Symbol,
Priority_Specific_Dispatching_Symbol,
Profile_Symbol,
Pure_Symbol,
Queuing_Policy_Symbol,
Relative_Deadline_Symbol,
Remote_Call_Interface_Symbol,
Remote_Types_Symbol,
Restrictions_Symbol,
Reviewable_Symbol,
Shared_Passive_Symbol,
Suppress_Symbol,
Task_Dispatching_Policy_Symbol,
Unchecked_Union_Symbol,
Unsuppress_Symbol,
Volatile_Symbol,
Volatile_Components_Symbol,
Access_Symbol,
Address_Symbol,
Adjacent_Symbol,
Aft_Symbol,
Alignment_Symbol,
Base_Symbol,
Bit_Order_Symbol,
Body_Version_Symbol,
Callable_Symbol,
Caller_Symbol,
Ceiling_Symbol,
Class_Symbol,
Component_Size_Symbol,
Compose_Symbol,
Constrained_Symbol,
Copy_Sign_Symbol,
Count_Symbol,
Definite_Symbol,
Delta_Symbol,
Denorm_Symbol,
Digits_Symbol,
Exponent_Symbol,
External_Tag_Symbol,
First_Symbol,
First_Bit_Symbol,
Floor_Symbol,
Fore_Symbol,
Fraction_Symbol,
Identity_Symbol,
Image_Symbol,
Input_Symbol,
Last_Symbol,
Last_Bit_Symbol,
Leading_Part_Symbol,
Length_Symbol,
Machine_Symbol,
Machine_Emax_Symbol,
Machine_Emin_Symbol,
Machine_Mantissa_Symbol,
Machine_Overflows_Symbol,
Machine_Radix_Symbol,
Machine_Rounding_Symbol,
Machine_Rounds_Symbol,
Max_Symbol,
Max_Size_In_Storage_Elements_Symbol,
Min_Symbol,
Mod_Symbol,
Model_Symbol,
Model_Emin_Symbol,
Model_Epsilon_Symbol,
Model_Mantissa_Symbol,
Model_Small_Symbol,
Modulus_Symbol,
Output_Symbol,
Partition_ID_Symbol,
Pos_Symbol,
Position_Symbol,
Pred_Symbol,
Priority_Symbol,
Range_Symbol,
Read_Symbol,
Remainder_Symbol,
Round_Symbol,
Rounding_Symbol,
Safe_First_Symbol,
Safe_Last_Symbol,
Scale_Symbol,
Scaling_Symbol,
Signed_Zeros_Symbol,
Size_Symbol,
Small_Symbol,
Storage_Pool_Symbol,
Storage_Size_Symbol,
Stream_Size_Symbol,
Succ_Symbol,
Tag_Symbol,
Terminated_Symbol,
Truncation_Symbol,
Unbiased_Rounding_Symbol,
Unchecked_Access_Symbol,
Val_Symbol,
Valid_Symbol,
Value_Symbol,
Version_Symbol,
Wide_Image_Symbol,
Wide_Value_Symbol,
Wide_Wide_Image_Symbol,
Wide_Wide_Value_Symbol,
Wide_Wide_Width_Symbol,
Wide_Width_Symbol,
Width_Symbol,
Write_Symbol,
Standard_Symbol,
Boolean_Symbol,
Integer_Symbol,
Float_Symbol,
Character_Symbol,
Wide_Character_Symbol,
Wide_Wide_Character_Symbol,
String_Symbol,
Wide_String_Symbol,
Wide_Wide_String_Symbol,
Duration_Symbol,
Root_Integer_Symbol,
Root_Real_Symbol);
pragma Warnings (On);
function To_Mixed_Case
(Name : Wide_Wide_String) return League.Strings.Universal_String;
-------------------
-- To_Mixed_Case --
-------------------
function To_Mixed_Case
(Name : Wide_Wide_String) return League.Strings.Universal_String
is
List : League.String_Vectors.Universal_String_Vector;
Image : League.Strings.Universal_String;
Upper : constant League.Strings.Universal_String :=
League.Strings.To_Universal_String (Name);
begin
List := Upper.Split ('_');
for K in 1 .. List.Length loop
Image := List.Element (K).To_Lowercase;
Image.Replace (1, 1, List.Element (K).Slice (1, 1));
List.Replace (K, Image);
end loop;
Image := List.Join ('_');
return Image;
end To_Mixed_Case;
Ignore : Gela.Lexical_Types.Symbol;
begin
for J in A1'Range loop
Self.Operator (J) := League.Strings.To_Universal_String (A1 (J));
end loop;
for J in A2'Range loop
Self.Operator (J) := League.Strings.To_Universal_String (A2 (J));
end loop;
for J in A3'Range loop
Self.Operator (J) := League.Strings.To_Universal_String (A3 (J));
end loop;
for J in Self.Operator'Range loop
Self.Fetch (Self.Operator (J), Ignore);
end loop;
for J in Predefined_Symbol_Name'Range loop
declare
Name : constant Wide_Wide_String :=
Predefined_Symbol_Name'Wide_Wide_Image (J);
Image : constant League.Strings.Universal_String :=
To_Mixed_Case (Name (1 .. Name'Last - 7));
begin
Self.Fetch (Image, Ignore);
if Ignore /= 16#11_0000# + Predefined_Symbol_Name'Pos (J) then
raise Constraint_Error;
end if;
end;
end loop;
end Initialize;
----------
-- Join --
----------
overriding procedure Join
(Self : in out Symbol_Set;
Left : Gela.Lexical_Types.Symbol;
Right : Gela.Lexical_Types.Symbol;
Value : out Gela.Lexical_Types.Symbol)
is
Node : constant List_Node := (Left, Right);
Cursor : constant List_Maps.Cursor := Self.List_Map.Find (Node);
begin
if List_Maps.Has_Element (Cursor) then
Value := To_Symbol (List_Maps.Element (Cursor));
else
Self.Lists.Append (Node);
Self.List_Map.Insert (Node, Self.Lists.Last_Index);
Value := To_Symbol (Self.Lists.Last_Index);
end if;
end Join;
------------
-- Prefix --
------------
overriding function Prefix
(Self : Symbol_Set;
Value : Gela.Lexical_Types.Symbol)
return Gela.Lexical_Types.Symbol is
begin
if Value in Simple_Symbol then
return Gela.Lexical_Types.No_Symbol;
else
return Self.Lists.Element (From_Symbol (Value)).Left;
end if;
end Prefix;
--------------
-- Selector --
--------------
overriding function Selector
(Self : Symbol_Set;
Value : Gela.Lexical_Types.Symbol)
return Gela.Lexical_Types.Symbol is
begin
if Value in Simple_Symbol then
return Value;
else
return Self.Lists.Element (From_Symbol (Value)).Right;
end if;
end Selector;
----------
-- Tail --
----------
overriding function Tail
(Self : Symbol_Set;
Value : Gela.Lexical_Types.Symbol_List)
return Gela.Lexical_Types.Symbol_List is
begin
if Value in List_Symbol then
declare
Index : constant List_Index := From_Symbol_List (Value);
Node : constant List_Node := Self.Lists.Element (Index);
begin
-- Symbol and Symbol_List have the same encoding, just cast.
return Gela.Lexical_Types.Symbol_List (Node.Right);
end;
else
return Gela.Lexical_Types.Empty_Symbol_List;
end if;
end Tail;
------------------------
-- To_Operator_Symbol --
------------------------
function To_Operator_Symbol
(Text : League.Strings.Universal_String) return First_Symbols
is
X : constant Wide_Wide_String :=
Text.Slice (2, Text.Length - 1).To_Simple_Casefold.To_Wide_Wide_String;
begin
if X = "abs" then
return Token_Kind'Pos (Abs_Token);
elsif X = "and" then
return Token_Kind'Pos (And_Token);
elsif X = "mod" then
return Token_Kind'Pos (Mod_Token);
elsif X = "not" then
return Token_Kind'Pos (Not_Token);
elsif X = "or" then
return Token_Kind'Pos (Or_Token);
elsif X = "rem" then
return Token_Kind'Pos (Rem_Token);
elsif X = "xor" then
return Token_Kind'Pos (Xor_Token);
else
return 0;
end if;
end To_Operator_Symbol;
---------------
-- To_Symbol --
---------------
function To_Symbol
(Value : List_Index)
return Gela.Lexical_Types.Symbol is
begin
return Gela.Lexical_Types.Symbol (Value) + Compound_Symbol'First;
end To_Symbol;
--------------------
-- To_Symbol_List --
--------------------
function To_Symbol_List (List : List_Index) return List_Symbol is
begin
return Gela.Lexical_Types.Symbol_List (List) + List_Symbol'First;
end To_Symbol_List;
end Gela.Plain_Symbol_Sets;
|
reznikmm/matreshka | Ada | 3,774 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, 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 package for internal use only.
------------------------------------------------------------------------------
with Matreshka.Internals.SQL_Drivers;
package SQL.Databases.Internals is
function Internal
(Self : SQL_Database'Class)
return Matreshka.Internals.SQL_Drivers.Database_Access;
pragma Inline (Internal);
-- Returns internal object. Reference counter is untouched.
end SQL.Databases.Internals;
|
AdaCore/Ada_Drivers_Library | Ada | 7,689 | ads | -- This spec has been automatically generated from STM32F7x9.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.FLASH is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ACR_LATENCY_Field is HAL.UInt3;
-- Flash access control register
type ACR_Register is record
-- Latency
LATENCY : ACR_LATENCY_Field := 16#0#;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- Prefetch enable
PRFTEN : Boolean := False;
-- Instruction cache enable
ICEN : Boolean := False;
-- Data cache enable
DCEN : Boolean := False;
-- Write-only. Instruction cache reset
ICRST : Boolean := False;
-- Data cache reset
DCRST : Boolean := False;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ACR_Register use record
LATENCY at 0 range 0 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
PRFTEN at 0 range 8 .. 8;
ICEN at 0 range 9 .. 9;
DCEN at 0 range 10 .. 10;
ICRST at 0 range 11 .. 11;
DCRST at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
-- Status register
type SR_Register is record
-- End of operation
EOP : Boolean := False;
-- Operation error
OPERR : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Write protection error
WRPERR : Boolean := False;
-- Programming alignment error
PGAERR : Boolean := False;
-- Programming parallelism error
PGPERR : Boolean := False;
-- Programming sequence error
PGSERR : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- Read-only. Busy
BSY : 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 SR_Register use record
EOP at 0 range 0 .. 0;
OPERR at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
WRPERR at 0 range 4 .. 4;
PGAERR at 0 range 5 .. 5;
PGPERR at 0 range 6 .. 6;
PGSERR at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
BSY at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype CR_SNB_Field is HAL.UInt5;
subtype CR_PSIZE_Field is HAL.UInt2;
-- Control register
type CR_Register is record
-- Programming
PG : Boolean := False;
-- Sector Erase
SER : Boolean := False;
-- Mass Erase of sectors 0 to 11
MER : Boolean := False;
-- Sector number
SNB : CR_SNB_Field := 16#0#;
-- Program size
PSIZE : CR_PSIZE_Field := 16#0#;
-- unspecified
Reserved_10_14 : HAL.UInt5 := 16#0#;
-- Mass Erase of sectors 12 to 23
MER1 : Boolean := False;
-- Start
STRT : Boolean := False;
-- unspecified
Reserved_17_23 : HAL.UInt7 := 16#0#;
-- End of operation interrupt enable
EOPIE : Boolean := False;
-- Error interrupt enable
ERRIE : Boolean := False;
-- unspecified
Reserved_26_30 : HAL.UInt5 := 16#0#;
-- Lock
LOCK : Boolean := True;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
PG at 0 range 0 .. 0;
SER at 0 range 1 .. 1;
MER at 0 range 2 .. 2;
SNB at 0 range 3 .. 7;
PSIZE at 0 range 8 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
MER1 at 0 range 15 .. 15;
STRT at 0 range 16 .. 16;
Reserved_17_23 at 0 range 17 .. 23;
EOPIE at 0 range 24 .. 24;
ERRIE at 0 range 25 .. 25;
Reserved_26_30 at 0 range 26 .. 30;
LOCK at 0 range 31 .. 31;
end record;
subtype OPTCR_BOR_LEV_Field is HAL.UInt2;
subtype OPTCR_RDP_Field is HAL.UInt8;
subtype OPTCR_nWRP_Field is HAL.UInt12;
-- Flash option control register
type OPTCR_Register is record
-- Option lock
OPTLOCK : Boolean := True;
-- Option start
OPTSTRT : Boolean := False;
-- BOR reset Level
BOR_LEV : OPTCR_BOR_LEV_Field := 16#3#;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- WDG_SW User option bytes
WDG_SW : Boolean := True;
-- nRST_STOP User option bytes
nRST_STOP : Boolean := True;
-- nRST_STDBY User option bytes
nRST_STDBY : Boolean := True;
-- Read protect
RDP : OPTCR_RDP_Field := 16#AA#;
-- Not write protect
nWRP : OPTCR_nWRP_Field := 16#FFF#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OPTCR_Register use record
OPTLOCK at 0 range 0 .. 0;
OPTSTRT at 0 range 1 .. 1;
BOR_LEV at 0 range 2 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
WDG_SW at 0 range 5 .. 5;
nRST_STOP at 0 range 6 .. 6;
nRST_STDBY at 0 range 7 .. 7;
RDP at 0 range 8 .. 15;
nWRP at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype OPTCR1_nWRP_Field is HAL.UInt12;
-- Flash option control register 1
type OPTCR1_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Not write protect
nWRP : OPTCR1_nWRP_Field := 16#FFF#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OPTCR1_Register use record
Reserved_0_15 at 0 range 0 .. 15;
nWRP at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- FLASH
type FLASH_Peripheral is record
-- Flash access control register
ACR : aliased ACR_Register;
-- Flash key register
KEYR : aliased HAL.UInt32;
-- Flash option key register
OPTKEYR : aliased HAL.UInt32;
-- Status register
SR : aliased SR_Register;
-- Control register
CR : aliased CR_Register;
-- Flash option control register
OPTCR : aliased OPTCR_Register;
-- Flash option control register 1
OPTCR1 : aliased OPTCR1_Register;
end record
with Volatile;
for FLASH_Peripheral use record
ACR at 16#0# range 0 .. 31;
KEYR at 16#4# range 0 .. 31;
OPTKEYR at 16#8# range 0 .. 31;
SR at 16#C# range 0 .. 31;
CR at 16#10# range 0 .. 31;
OPTCR at 16#14# range 0 .. 31;
OPTCR1 at 16#18# range 0 .. 31;
end record;
-- FLASH
FLASH_Periph : aliased FLASH_Peripheral
with Import, Address => System'To_Address (16#40023C00#);
end STM32_SVD.FLASH;
|
AdaCore/Ada_Drivers_Library | Ada | 4,925 | 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 nRF.GPIO; use nRF.GPIO;
with MicroBit.Time; use MicroBit.Time;
package body MicroBit.Buttons is
type Button_State_Array is array (Button_Id) of Button_State;
Points : constant array (Button_Id) of GPIO_Point := (MB_P5, MB_P11);
States : Button_State_Array := (others => Released);
Subscribers : array (1 .. 10) of Button_Callback := (others => null);
procedure Initialize;
procedure Tick_Handler;
----------------
-- Initialize --
----------------
procedure Initialize is
Conf : GPIO_Configuration;
begin
Conf.Mode := Mode_In;
Conf.Resistors := No_Pull;
Conf.Input_Buffer := Input_Buffer_Connect;
Conf.Sense := Sense_Disabled;
for Pt of Points loop
Pt.Configure_IO (Conf);
end loop;
if not Tick_Subscribe (Tick_Handler'Access) then
raise Program_Error;
end if;
end Initialize;
------------------
-- Tick_Handler --
------------------
procedure Tick_Handler is
Prev_States : constant Button_State_Array := States;
begin
-- Update all components of States array
for Id in Button_Id loop
if not Set (Points (Id)) then
States (Id) := Pressed;
else
States (Id) := Released;
end if;
end loop;
-- Notify changes to subscribers
for Id in Button_Id loop
if States (Id) /= Prev_States (Id) then
for Sub of Subscribers loop
if Sub /= null then
Sub.all (Id, States (Id));
end if;
end loop;
end if;
end loop;
end Tick_Handler;
-----------
-- State --
-----------
function State (Button : Button_Id) return Button_State is
begin
return States (Button);
end State;
---------------
-- Subscribe --
---------------
function Subscribe (Callback : not null Button_Callback) return Boolean is
begin
for Subs of Subscribers loop
if Subs = null then
Subs := Callback;
return True;
end if;
end loop;
return False;
end Subscribe;
-----------------
-- Unsubscribe --
-----------------
function Unsubscribe (Callback : not null Button_Callback) return Boolean is
begin
for Subs of Subscribers loop
if Subs = Callback then
Subs := null;
return True;
end if;
end loop;
return False;
end Unsubscribe;
begin
Initialize;
end MicroBit.Buttons;
|
AdaCore/libadalang | Ada | 61 | adb | package body Test is
procedure Bar is separate;
end Test;
|
johnleimon/robot | Ada | 6,880 | adb | -----------------------------------------------------------------
-- --
-- Robot Utility --
-- --
-- Copyright (c) 2017 John Leimon --
-- --
-- Permission to use, copy, modify, and/or distribute --
-- this software for any purpose with or without fee --
-- is hereby granted, provided that the above copyright --
-- notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR --
-- DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE --
-- INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY --
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE --
-- FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL --
-- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS --
-- OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF --
-- CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING --
-- OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF --
-- THIS SOFTWARE. --
-- --
-- Run a command when the time stamp on a set of files is --
-- changed. --
-- --
-- Example: --
-- --
-- robot "gcc hello_world.c" "*.c" --
-- --
-----------------------------------------------------------------
with Ada.Calendar; use Ada.Calendar;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Directories; use Ada.Directories;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Indefinite_Vectors; use Ada.Containers;
with Interfaces.C;
procedure Robot is
package US renames Ada.Strings.Unbounded;
RED_TEXT : constant String := Character'Val (16#1B#) & "[31m";
GREEN_TEXT : constant String := Character'Val (16#1B#) & "[32m";
NORMAL_TEXT : constant String := Character'Val (16#1B#) & "[39m";
CLEAR_TERM : constant String := Character'Val (16#1B#) & "c";
Search_Period : constant Duration := 0.25;
type Source_Record is record
Name : US.Unbounded_String;
Last_Modified : Time;
end record;
type Command_Type is (Clear_Screen, Run_Command, None);
package Source_Record_Vectors is new
Indefinite_Vectors (Natural, Source_Record);
use Source_Record_Vectors;
-----------------
-- Get_Command --
-----------------
function Get_Command
return Command_Type
is
Key : Character;
Available : Boolean;
begin
Get_Immediate (Key, Available);
if Available then
case Key is
when 'r' | 'R' =>
return Run_Command;
when 'c' | 'C' =>
return Clear_Screen;
when others =>
return None;
end case;
end if;
return None;
end Get_Command;
-----------------
-- Run_Command --
-----------------
procedure Run_Command
(Command : String)
is
use Interfaces.C;
function System (Arguments : Char_Array) return Integer;
pragma Import (C, System, "system");
begin
if System (To_C(Command)) = 0 then
Put_Line(GREEN_TEXT & "[SUCCESS]" & NORMAL_TEXT);
else
Put_Line(RED_TEXT & "[FAILED]" & NORMAL_TEXT);
end if;
end Run_Command;
----------
-- Walk --
----------
procedure Walk
(Name : in String;
Pattern : in String;
Output : in out Source_Record_Vectors.Vector)
is
procedure Add
(Item : Directory_Entry_Type)
is
Source : Source_Record;
begin
Source.Name := US.To_Unbounded_String (Full_Name (Item));
Source.Last_Modified := Modification_Time (Full_Name (Item));
Output.Append(Source);
end Add;
procedure Walk
(Item : Directory_Entry_Type)
is
begin
if Simple_Name (Item) /= "." and then Simple_Name (Item) /= ".." then
Walk (Full_Name (Item), Pattern, Output);
end if;
exception
when Ada.Directories.Name_Error => null;
end Walk;
begin
Search (Name, Pattern, (others => True), Add'Access);
Search (Name, "", (Directory => True, others => False), Walk'Access);
end Walk;
-------------------
-- Stamp_Sources --
-------------------
procedure Stamp_Sources
(Sources : in out Source_Record_Vectors.Vector)
is
begin
for I in Natural range 2 .. Argument_Count loop
Walk (".", Argument(I), Sources);
end loop;
end Stamp_Sources;
----------------
-- Put_Config --
----------------
procedure Put_Config is
begin
Put ("MONITORING: [");
for I in Natural range 2 .. Argument_Count loop
Put (Argument (I));
end loop;
Put ("] RUN ON MODIFY: [");
Put (Argument (1));
Put_Line ("]");
end Put_Config;
---------------------
-- Execute Command --
---------------------
procedure Execute_Command
(Command : Command_Type)
is
begin
case Command is
when Run_Command =>
Run_Command(Argument(1));
when Clear_Screen =>
Put(CLEAR_TERM);
Put_Config;
when None =>
null;
end case;
end Execute_Command;
Old_Fingerprint : Source_Record_Vectors.Vector;
New_Fingerprint : Source_Record_Vectors.Vector;
Command : Command_Type := None;
begin
if Argument_Count < 2 then
Put_Line ("Usage: robot <command> <file_pattern> [ .. <file_pattern> ]");
New_Line;
Put_Line ("Run time commands:");
Put_Line (" R-key : Run command");
Put_Line (" C-key : Clear terminal");
return;
end if;
Put_Config;
Stamp_Sources (New_Fingerprint);
loop
delay Search_Period;
Old_Fingerprint := New_Fingerprint;
New_Fingerprint.Clear;
Stamp_Sources (New_Fingerprint);
Command := Get_Command;
if New_Fingerprint /= Old_Fingerprint then
Command := Run_Command;
end if;
Execute_Command (Command);
end loop;
end Robot;
|
wookey-project/ewok-legacy | Ada | 1,352 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
package ewok.debug
with spark_mode => off
is
type t_level is (DEBUG, INFO, WARNING, ERROR, ALERT);
BG_COLOR_BLACK : constant string := ASCII.ESC & "[37;40m";
BG_COLOR_RED : constant string := ASCII.ESC & "[37;41m";
BG_COLOR_ORANGE : constant string := ASCII.ESC & "[37;43m";
BG_COLOR_BLUE : constant string := ASCII.ESC & "[37;44m";
procedure log (s : string; nl : boolean := true);
procedure log (level : t_level; s : string);
procedure alert (s : string);
procedure newline;
procedure panic (s : string);
end ewok.debug;
|
fayak/cryptada | Ada | 7,130 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with bits_stdint_uintn_h;
with bits_stdint_intn_h;
with Interfaces.C.Strings;
package bn_h is
-- arg-macro: procedure likely (x)
-- __builtin_expect(notnot(x), 1)
-- arg-macro: procedure unlikely (x)
-- __builtin_expect(notnot(x), 0)
BN_ARRAY_SIZE : constant := 128; -- bn.h:34
STR_DEST_SIZE : constant := 256; -- bn.h:35
-- unsupported macro: require(p,msg) assert(p && #msg)
BASE : constant := 256; -- bn.h:39
WORD_SIZE : constant := 8; -- bn.h:40
WORD_MASK : constant := 16#ff#; -- bn.h:41
KARATSUBA_MIN : constant := 8; -- bn.h:44
--Big number library - arithmetic on multiple-precision unsigned integers.
--This library is an implementation of arithmetic on arbitrarily large integers.
--The difference between this and other implementations, is that the data structure
--has optimal memory utilization (i.e. a 1024 bit integer takes up 128 bytes RAM),
--and all memory is allocated statically: no dynamic allocation for better or worse.
--Primary goals are correctness, clarity of code and clean, portable implementation.
--Secondary goal is a memory footprint small enough to make it suitable for use in
--embedded applications.
--The current state is correct functionality and adequate performance.
--There may well be room for performance-optimizations and improvements.
--
-- MUST BE % 4 !
-- Custom assert macro - easy to disable
--static uint8_t KARATSUBA_MIN = 6;
-- Data-holding structure: array of DTYPEs
type anon887_c_array_array is array (0 .. 127) of aliased bits_stdint_uintn_h.uint8_t;
type bn is record
c_array : aliased anon887_c_array_array; -- bn.h:49
size : aliased bits_stdint_uintn_h.uint32_t; -- bn.h:50
neg : aliased bits_stdint_uintn_h.uint8_t; -- bn.h:51
end record
with Convention => C_Pass_By_Copy; -- bn.h:47
-- Tokens returned by bignum_cmp() for value comparison
-- Initialization functions:
procedure bignum_init (n : access bn) -- bn.h:58
with Import => True,
Convention => C,
External_Name => "bignum_init";
procedure bignum_from_int (n : access bn; i : bits_stdint_intn_h.int32_t) -- bn.h:59
with Import => True,
Convention => C,
External_Name => "bignum_from_int";
function bignum_to_int (n : access bn) return int -- bn.h:60
with Import => True,
Convention => C,
External_Name => "bignum_to_int";
procedure bignum_from_string
(n : access bn;
str : Interfaces.C.Strings.chars_ptr;
nbytes : bits_stdint_uintn_h.uint32_t) -- bn.h:61
with Import => True,
Convention => C,
External_Name => "bignum_from_string";
procedure bignum_to_string
(n : access bn;
str : Interfaces.C.Strings.chars_ptr;
maxsize : bits_stdint_uintn_h.uint32_t) -- bn.h:62
with Import => True,
Convention => C,
External_Name => "bignum_to_string";
-- Basic arithmetic operations:
-- c = a + b
procedure bignum_add
(a : access bn;
b : access bn;
c : access bn) -- bn.h:65
with Import => True,
Convention => C,
External_Name => "bignum_add";
-- c = a - b
procedure bignum_sub
(a : access bn;
b : access bn;
c : access bn) -- bn.h:66
with Import => True,
Convention => C,
External_Name => "bignum_sub";
-- c = a * b
procedure bignum_mul
(a : access bn;
b : access bn;
c : access bn) -- bn.h:67
with Import => True,
Convention => C,
External_Name => "bignum_mul";
-- c = a / b
procedure bignum_div
(a : access bn;
b : access bn;
c : access bn) -- bn.h:68
with Import => True,
Convention => C,
External_Name => "bignum_div";
-- c = a % b
procedure bignum_mod
(a : access bn;
b : access bn;
c : access bn) -- bn.h:69
with Import => True,
Convention => C,
External_Name => "bignum_mod";
-- void bignum_divmod(struct bn* a, struct bn* b, struct bn* c, struct bn* d); /* c = a/b, d = a%b
procedure bignum_powmod
(a : access bn;
b : access bn;
n : access bn;
res : access bn) -- bn.h:71
with Import => True,
Convention => C,
External_Name => "bignum_powmod";
-- /* Bitwise operations:
-- c = a & b
procedure bignum_and
(a : access bn;
b : access bn;
c : access bn) -- bn.h:74
with Import => True,
Convention => C,
External_Name => "bignum_and";
-- c = a | b
procedure bignum_or
(a : access bn;
b : access bn;
c : access bn) -- bn.h:75
with Import => True,
Convention => C,
External_Name => "bignum_or";
-- c = a ^ b
procedure bignum_xor
(a : access bn;
b : access bn;
c : access bn) -- bn.h:76
with Import => True,
Convention => C,
External_Name => "bignum_xor";
-- b = a << nbits
procedure bignum_lshift
(a : access bn;
b : access bn;
nbits : bits_stdint_uintn_h.uint32_t) -- bn.h:77
with Import => True,
Convention => C,
External_Name => "bignum_lshift";
-- b = a >> nbits
procedure bignum_rshift
(a : access bn;
b : access bn;
nbits : bits_stdint_uintn_h.uint32_t) -- bn.h:78
with Import => True,
Convention => C,
External_Name => "bignum_rshift";
-- /* Special operators and comparison
-- Compare: returns LARGER, EQUAL or SMALLER
function bignum_cmp (a : access bn; b : access bn) return int -- bn.h:81
with Import => True,
Convention => C,
External_Name => "bignum_cmp";
-- For comparison with zero
function bignum_is_zero (n : access bn) return int -- bn.h:82
with Import => True,
Convention => C,
External_Name => "bignum_is_zero";
-- Increment: add one to n
procedure bignum_inc (n : access bn) -- bn.h:83
with Import => True,
Convention => C,
External_Name => "bignum_inc";
-- Decrement: subtract one from n
procedure bignum_dec (n : access bn) -- bn.h:84
with Import => True,
Convention => C,
External_Name => "bignum_dec";
-- Calculate a^b -- e.g. 2^10 => 1024
procedure bignum_pow
(a : access bn;
b : access bn;
c : access bn) -- bn.h:85
with Import => True,
Convention => C,
External_Name => "bignum_pow";
-- void bignum_isqrt(struct bn* a, struct bn* b); /* Integer square root -- e.g. isqrt(5) => 2
-- Copy src into dst -- dst := src
procedure bignum_assign (dst : access bn; src : access bn) -- bn.h:87
with Import => True,
Convention => C,
External_Name => "bignum_assign";
function bignum_nb_bits (n : access bn) return bits_stdint_uintn_h.uint32_t -- bn.h:90
with Import => True,
Convention => C,
External_Name => "bignum_nb_bits";
end bn_h;
|
reznikmm/matreshka | Ada | 3,669 | 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_Fy_Attributes is
pragma Preelaborate;
type ODF_Svg_Fy_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_Fy_Attribute_Access is
access all ODF_Svg_Fy_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_Fy_Attributes;
|
coolsnowwolf/luci | Ada | 140 | ads | address=/p.tanx.com/0.0.0.0
address=/googlesyndication.com/0.0.0.0
address=/linkvans.com/0.0.0.0
server=/valf.atm.youku.com/114.114.114.114
|
reznikmm/matreshka | Ada | 4,932 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Connectors.Collections is
pragma Preelaborate;
package UML_Connector_Collections is
new AMF.Generic_Collections
(UML_Connector,
UML_Connector_Access);
type Set_Of_UML_Connector is
new UML_Connector_Collections.Set with null record;
Empty_Set_Of_UML_Connector : constant Set_Of_UML_Connector;
type Ordered_Set_Of_UML_Connector is
new UML_Connector_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Connector : constant Ordered_Set_Of_UML_Connector;
type Bag_Of_UML_Connector is
new UML_Connector_Collections.Bag with null record;
Empty_Bag_Of_UML_Connector : constant Bag_Of_UML_Connector;
type Sequence_Of_UML_Connector is
new UML_Connector_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Connector : constant Sequence_Of_UML_Connector;
private
Empty_Set_Of_UML_Connector : constant Set_Of_UML_Connector
:= (UML_Connector_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Connector : constant Ordered_Set_Of_UML_Connector
:= (UML_Connector_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Connector : constant Bag_Of_UML_Connector
:= (UML_Connector_Collections.Bag with null record);
Empty_Sequence_Of_UML_Connector : constant Sequence_Of_UML_Connector
:= (UML_Connector_Collections.Sequence with null record);
end AMF.UML.Connectors.Collections;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 4,493 | ads | -- This spec has been automatically generated from STM32F030.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces; use Interfaces;
with System;
-- STM32F030
package STM32_SVD is
pragma Preelaborate;
---------------
-- Base type --
---------------
type UInt32 is new Interfaces.Unsigned_32;
type UInt16 is new Interfaces.Unsigned_16;
type Byte is new Interfaces.Unsigned_8;
type Bit is mod 2**1
with Size => 1;
type UInt2 is mod 2**2
with Size => 2;
type UInt3 is mod 2**3
with Size => 3;
type UInt4 is mod 2**4
with Size => 4;
type UInt5 is mod 2**5
with Size => 5;
type UInt6 is mod 2**6
with Size => 6;
type UInt7 is mod 2**7
with Size => 7;
type UInt9 is mod 2**9
with Size => 9;
type UInt10 is mod 2**10
with Size => 10;
type UInt11 is mod 2**11
with Size => 11;
type UInt12 is mod 2**12
with Size => 12;
type UInt13 is mod 2**13
with Size => 13;
type UInt14 is mod 2**14
with Size => 14;
type UInt15 is mod 2**15
with Size => 15;
type UInt17 is mod 2**17
with Size => 17;
type UInt18 is mod 2**18
with Size => 18;
type UInt19 is mod 2**19
with Size => 19;
type UInt20 is mod 2**20
with Size => 20;
type UInt21 is mod 2**21
with Size => 21;
type UInt22 is mod 2**22
with Size => 22;
type UInt23 is mod 2**23
with Size => 23;
type UInt24 is mod 2**24
with Size => 24;
type UInt25 is mod 2**25
with Size => 25;
type UInt26 is mod 2**26
with Size => 26;
type UInt27 is mod 2**27
with Size => 27;
type UInt28 is mod 2**28
with Size => 28;
type UInt29 is mod 2**29
with Size => 29;
type UInt30 is mod 2**30
with Size => 30;
type UInt31 is mod 2**31
with Size => 31;
--------------------
-- Base addresses --
--------------------
CRC_Base : constant System.Address :=
System'To_Address (16#40023000#);
GPIOF_Base : constant System.Address :=
System'To_Address (16#48001400#);
GPIOD_Base : constant System.Address :=
System'To_Address (16#48000C00#);
GPIOC_Base : constant System.Address :=
System'To_Address (16#48000800#);
GPIOB_Base : constant System.Address :=
System'To_Address (16#48000400#);
GPIOA_Base : constant System.Address :=
System'To_Address (16#48000000#);
SPI1_Base : constant System.Address :=
System'To_Address (16#40013000#);
SPI2_Base : constant System.Address :=
System'To_Address (16#40003800#);
PWR_Base : constant System.Address :=
System'To_Address (16#40007000#);
I2C1_Base : constant System.Address :=
System'To_Address (16#40005400#);
I2C2_Base : constant System.Address :=
System'To_Address (16#40005800#);
IWDG_Base : constant System.Address :=
System'To_Address (16#40003000#);
WWDG_Base : constant System.Address :=
System'To_Address (16#40002C00#);
TIM1_Base : constant System.Address :=
System'To_Address (16#40012C00#);
TIM3_Base : constant System.Address :=
System'To_Address (16#40000400#);
TIM14_Base : constant System.Address :=
System'To_Address (16#40002000#);
TIM6_Base : constant System.Address :=
System'To_Address (16#40001000#);
EXTI_Base : constant System.Address :=
System'To_Address (16#40010400#);
NVIC_Base : constant System.Address :=
System'To_Address (16#E000E100#);
DMA_Base : constant System.Address :=
System'To_Address (16#40020000#);
RCC_Base : constant System.Address :=
System'To_Address (16#40021000#);
SYSCFG_Base : constant System.Address :=
System'To_Address (16#40010000#);
ADC_Base : constant System.Address :=
System'To_Address (16#40012400#);
USART1_Base : constant System.Address :=
System'To_Address (16#40013800#);
USART2_Base : constant System.Address :=
System'To_Address (16#40004400#);
RTC_Base : constant System.Address :=
System'To_Address (16#40002800#);
TIM15_Base : constant System.Address :=
System'To_Address (16#40014000#);
TIM16_Base : constant System.Address :=
System'To_Address (16#40014400#);
TIM17_Base : constant System.Address :=
System'To_Address (16#40014800#);
Flash_Base : constant System.Address :=
System'To_Address (16#40022000#);
DBGMCU_Base : constant System.Address :=
System'To_Address (16#40015800#);
end STM32_SVD;
|
reznikmm/matreshka | Ada | 3,422 | 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$
------------------------------------------------------------------------------
with WUI.Slots.Booleans;
package WUI.Boolean_Slots renames WUI.Slots.Booleans;
|
reznikmm/matreshka | Ada | 18,544 | 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.UMLDI.UML_Activity_Diagrams;
with AMF.UMLDI.UML_Association_End_Labels;
with AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes;
with AMF.UMLDI.UML_Class_Diagrams;
with AMF.UMLDI.UML_Classifier_Shapes;
with AMF.UMLDI.UML_Compartmentable_Shapes;
with AMF.UMLDI.UML_Compartments;
with AMF.UMLDI.UML_Component_Diagrams;
with AMF.UMLDI.UML_Composite_Structure_Diagrams;
with AMF.UMLDI.UML_Deployment_Diagrams;
with AMF.UMLDI.UML_Edges;
with AMF.UMLDI.UML_Interaction_Diagrams;
with AMF.UMLDI.UML_Interaction_Table_Labels;
with AMF.UMLDI.UML_Keyword_Labels;
with AMF.UMLDI.UML_Labels;
with AMF.UMLDI.UML_Multiplicity_Labels;
with AMF.UMLDI.UML_Name_Labels;
with AMF.UMLDI.UML_Object_Diagrams;
with AMF.UMLDI.UML_Package_Diagrams;
with AMF.UMLDI.UML_Profile_Diagrams;
with AMF.UMLDI.UML_Redefines_Labels;
with AMF.UMLDI.UML_Shapes;
with AMF.UMLDI.UML_State_Machine_Diagrams;
with AMF.UMLDI.UML_State_Shapes;
with AMF.UMLDI.UML_Stereotype_Property_Value_Labels;
with AMF.UMLDI.UML_Styles;
with AMF.UMLDI.UML_Typed_Element_Labels;
with AMF.UMLDI.UML_Use_Case_Diagrams;
package AMF.Visitors.UMLDI_Visitors is
pragma Preelaborate;
type UMLDI_Visitor is limited interface and AMF.Visitors.Abstract_Visitor;
not overriding procedure Enter_UML_Activity_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Activity_Diagrams.UMLDI_UML_Activity_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Activity_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Activity_Diagrams.UMLDI_UML_Activity_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Association_End_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Association_End_Labels.UMLDI_UML_Association_End_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Association_End_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Association_End_Labels.UMLDI_UML_Association_End_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Association_Or_Connector_Or_Link_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Association_Or_Connector_Or_Link_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Class_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Class_Diagrams.UMLDI_UML_Class_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Class_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Class_Diagrams.UMLDI_UML_Class_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Classifier_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Classifier_Shapes.UMLDI_UML_Classifier_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Classifier_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Classifier_Shapes.UMLDI_UML_Classifier_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Compartment
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Compartments.UMLDI_UML_Compartment_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Compartment
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Compartments.UMLDI_UML_Compartment_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Compartmentable_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Compartmentable_Shapes.UMLDI_UML_Compartmentable_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Compartmentable_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Compartmentable_Shapes.UMLDI_UML_Compartmentable_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Component_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Component_Diagrams.UMLDI_UML_Component_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Component_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Component_Diagrams.UMLDI_UML_Component_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Composite_Structure_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Composite_Structure_Diagrams.UMLDI_UML_Composite_Structure_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Composite_Structure_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Composite_Structure_Diagrams.UMLDI_UML_Composite_Structure_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Deployment_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Deployment_Diagrams.UMLDI_UML_Deployment_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Deployment_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Deployment_Diagrams.UMLDI_UML_Deployment_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Edge
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Edges.UMLDI_UML_Edge_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Edge
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Edges.UMLDI_UML_Edge_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Interaction_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Interaction_Diagrams.UMLDI_UML_Interaction_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Interaction_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Interaction_Diagrams.UMLDI_UML_Interaction_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Interaction_Table_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Interaction_Table_Labels.UMLDI_UML_Interaction_Table_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Interaction_Table_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Interaction_Table_Labels.UMLDI_UML_Interaction_Table_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Keyword_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Keyword_Labels.UMLDI_UML_Keyword_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Keyword_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Keyword_Labels.UMLDI_UML_Keyword_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Multiplicity_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Multiplicity_Labels.UMLDI_UML_Multiplicity_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Multiplicity_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Multiplicity_Labels.UMLDI_UML_Multiplicity_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Name_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Name_Labels.UMLDI_UML_Name_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Name_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Name_Labels.UMLDI_UML_Name_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Object_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Object_Diagrams.UMLDI_UML_Object_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Object_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Object_Diagrams.UMLDI_UML_Object_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Package_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Package_Diagrams.UMLDI_UML_Package_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Package_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Package_Diagrams.UMLDI_UML_Package_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Profile_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Profile_Diagrams.UMLDI_UML_Profile_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Profile_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Profile_Diagrams.UMLDI_UML_Profile_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Redefines_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Redefines_Labels.UMLDI_UML_Redefines_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Redefines_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Redefines_Labels.UMLDI_UML_Redefines_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Shapes.UMLDI_UML_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Shapes.UMLDI_UML_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_State_Machine_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_State_Machine_Diagrams.UMLDI_UML_State_Machine_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_State_Machine_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_State_Machine_Diagrams.UMLDI_UML_State_Machine_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_State_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_State_Shapes.UMLDI_UML_State_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_State_Shape
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_State_Shapes.UMLDI_UML_State_Shape_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Stereotype_Property_Value_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Stereotype_Property_Value_Labels.UMLDI_UML_Stereotype_Property_Value_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Stereotype_Property_Value_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Stereotype_Property_Value_Labels.UMLDI_UML_Stereotype_Property_Value_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Style
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Style
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Typed_Element_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Typed_Element_Labels.UMLDI_UML_Typed_Element_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Typed_Element_Label
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Typed_Element_Labels.UMLDI_UML_Typed_Element_Label_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_UML_Use_Case_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Use_Case_Diagrams.UMLDI_UML_Use_Case_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_UML_Use_Case_Diagram
(Self : in out UMLDI_Visitor;
Element : not null AMF.UMLDI.UML_Use_Case_Diagrams.UMLDI_UML_Use_Case_Diagram_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
end AMF.Visitors.UMLDI_Visitors;
|
reznikmm/matreshka | Ada | 7,002 | 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_Number.Currency_Symbol_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Number_Currency_Symbol_Element_Node is
begin
return Self : Number_Currency_Symbol_Element_Node do
Matreshka.ODF_Number.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Number_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Number_Currency_Symbol_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_Number_Currency_Symbol
(ODF.DOM.Number_Currency_Symbol_Elements.ODF_Number_Currency_Symbol_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 Number_Currency_Symbol_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Currency_Symbol_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Number_Currency_Symbol_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_Number_Currency_Symbol
(ODF.DOM.Number_Currency_Symbol_Elements.ODF_Number_Currency_Symbol_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 Number_Currency_Symbol_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_Number_Currency_Symbol
(Visitor,
ODF.DOM.Number_Currency_Symbol_Elements.ODF_Number_Currency_Symbol_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.Number_URI,
Matreshka.ODF_String_Constants.Currency_Symbol_Element,
Number_Currency_Symbol_Element_Node'Tag);
end Matreshka.ODF_Number.Currency_Symbol_Elements;
|
reznikmm/matreshka | Ada | 4,623 | 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.Display_Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Display_Name_Attribute_Node is
begin
return Self : Draw_Display_Name_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_Display_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Display_Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Display_Name_Attribute,
Draw_Display_Name_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Display_Name_Attributes;
|
MinimSecure/unum-sdk | Ada | 809 | adb | -- Copyright 2012-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Break_Me is
begin
null;
end Break_Me;
end Pck;
|
stcarrez/ada-util | Ada | 5,433 | ads | -----------------------------------------------------------------------
-- util-beans-factory -- Bean Registration and Factory
-- Copyright (C) 2010, 2018, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Beans.Basic;
with Util.Beans.Methods;
private with Ada.Containers.Indefinite_Hashed_Maps;
private with Ada.Strings.Unbounded.Hash;
-- The <b>EL.Beans.Factory</b> package is a registry for the creation
-- of request, session and application beans.
package Util.Beans.Factory is
-- The bean definition is a small descriptor used by the
-- factory to create the bean instance when it is needed.
-- It also defines the methods that can be specified and
-- invoked as part of a <b>Method_Expression</b>.
type Bean_Definition (Method_Count : Natural) is abstract tagged limited record
Methods : Util.Beans.Methods.Method_Binding_Array (1 .. Method_Count);
end record;
type Bean_Definition_Access is access constant Bean_Definition'Class;
-- Create a bean.
function Create (Def : in Bean_Definition)
return Util.Beans.Basic.Readonly_Bean_Access is abstract;
-- Free the bean instance.
procedure Destroy (Def : in Bean_Definition;
Bean : in out Util.Beans.Basic.Readonly_Bean_Access) is abstract;
-- Defines the scope of the bean instance.
type Scope_Type is
(
-- Application scope means the bean is shared by all sessions and requests
APPLICATION_SCOPE,
-- Session scope means the bean is created one for each session.
SESSION_SCOPE,
-- Request scope means the bean is created for each request
REQUEST_SCOPE,
ANY_SCOPE);
-- ------------------------------
-- Binding
-- ------------------------------
type Binding is interface;
type Binding_Access is access all Binding'Class;
procedure Create (Factory : in Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type) is abstract;
-- ------------------------------
-- Bean Factory
-- ------------------------------
-- Factory for bean creation
type Bean_Factory is limited private;
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Definition : in Bean_Definition_Access;
Scope : in Scope_Type := REQUEST_SCOPE);
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Bind : in Binding_Access);
-- Register all the definitions from a factory to a main factory.
procedure Register (Factory : in out Bean_Factory;
From : in Bean_Factory);
-- Create a bean by using the create operation registered for the name
procedure Create (Factory : in Bean_Factory;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type);
type Simple_Binding is new Binding with private;
overriding
procedure Create (Factory : in Simple_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type);
private
type Simple_Binding is new Binding with record
Def : Bean_Definition_Access;
Scope : Scope_Type;
end record;
type Simple_Binding_Access is access all Simple_Binding;
use Ada.Strings.Unbounded;
package Bean_Maps is new
Ada.Containers.Indefinite_Hashed_Maps (Key_Type => Unbounded_String,
Element_Type => Binding_Access,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => "=");
type Bean_Factory is limited record
Map : Bean_Maps.Map;
end record;
end Util.Beans.Factory;
|
dendisuhubdy/coinapi-sdk | Ada | 6,061 | adb | -- OEML _ REST API
-- This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>
--
-- The version of the OpenAPI document: v1
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 4.3.1.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with Swagger.Streams;
package body .Clients is
-- Get balances
-- Get current currency balance from all or single exchange.
procedure V1_Balances_Get
(Client : in out Client_Type;
Exchange_Id : in Swagger.Nullable_UString;
Result : out .Models.Balance_Type_Vectors.Vector) is
URI : Swagger.Clients.URI_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
URI.Add_Param ("exchange_id", Exchange_Id);
URI.Set_Path ("/v1/balances");
Client.Call (Swagger.Clients.GET, URI, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Balances_Get;
-- Cancel all orders request
-- This request cancels all open orders on single specified exchange.
procedure V1_Orders_Cancel_All_Post
(Client : in out Client_Type;
Order_Cancel_All_Request_Type : in .Models.OrderCancelAllRequest_Type;
Result : out .Models.Message_Type) is
URI : Swagger.Clients.URI_Type;
Req : Swagger.Clients.Request_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
.Models.Serialize (Req.Stream, "", Order_Cancel_All_Request_Type);
URI.Set_Path ("/v1/orders/cancel/all");
Client.Call (Swagger.Clients.POST, URI, Req, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Cancel_All_Post;
-- Cancel order request
-- Request cancel for an existing order. The order can be canceled using the `client_order_id` or `exchange_order_id`.
procedure V1_Orders_Cancel_Post
(Client : in out Client_Type;
Order_Cancel_Single_Request_Type : in .Models.OrderCancelSingleRequest_Type;
Result : out .Models.OrderExecutionReport_Type) is
URI : Swagger.Clients.URI_Type;
Req : Swagger.Clients.Request_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
.Models.Serialize (Req.Stream, "", Order_Cancel_Single_Request_Type);
URI.Set_Path ("/v1/orders/cancel");
Client.Call (Swagger.Clients.POST, URI, Req, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Cancel_Post;
-- Get open orders
-- Get last execution reports for open orders across all or single exchange.
procedure V1_Orders_Get
(Client : in out Client_Type;
Exchange_Id : in Swagger.Nullable_UString;
Result : out .Models.OrderExecutionReport_Type_Vectors.Vector) is
URI : Swagger.Clients.URI_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
URI.Add_Param ("exchange_id", Exchange_Id);
URI.Set_Path ("/v1/orders");
Client.Call (Swagger.Clients.GET, URI, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Get;
-- Send new order
-- This request creating new order for the specific exchange.
procedure V1_Orders_Post
(Client : in out Client_Type;
Order_New_Single_Request_Type : in .Models.OrderNewSingleRequest_Type;
Result : out .Models.OrderExecutionReport_Type) is
URI : Swagger.Clients.URI_Type;
Req : Swagger.Clients.Request_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
.Models.Serialize (Req.Stream, "", Order_New_Single_Request_Type);
URI.Set_Path ("/v1/orders");
Client.Call (Swagger.Clients.POST, URI, Req, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Post;
-- Get order execution report
-- Get the last order execution report for the specified order. The requested order does not need to be active or opened.
procedure V1_Orders_Status_Client_Order_Id_Get
(Client : in out Client_Type;
Client_Order_Id : in Swagger.UString;
Result : out .Models.OrderExecutionReport_Type) is
URI : Swagger.Clients.URI_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
URI.Set_Path ("/v1/orders/status/{client_order_id}");
URI.Set_Path_Param ("client_order_id", Client_Order_Id);
Client.Call (Swagger.Clients.GET, URI, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Status_Client_Order_Id_Get;
-- Get open positions
-- Get current open positions across all or single exchange.
procedure V1_Positions_Get
(Client : in out Client_Type;
Exchange_Id : in Swagger.Nullable_UString;
Result : out .Models.Position_Type_Vectors.Vector) is
URI : Swagger.Clients.URI_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
URI.Add_Param ("exchange_id", Exchange_Id);
URI.Set_Path ("/v1/positions");
Client.Call (Swagger.Clients.GET, URI, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Positions_Get;
end .Clients;
|
reznikmm/matreshka | Ada | 3,684 | 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.Attributes;
package ODF.DOM.Attributes.Text.Name is
type ODF_Text_Name is
new XML.DOM.Attributes.DOM_Attribute with private;
type ODF_Text_Name_Access is access all ODF_Text_Name'Class;
private
type ODF_Text_Name is
new XML.DOM.Attributes.DOM_Attribute with null record;
end ODF.DOM.Attributes.Text.Name;
|
tum-ei-rcs/StratoX | Ada | 626 | ads | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Author: Martin Becker ([email protected])
--
with Ada.Tags;
-- @summary
-- implements a LUT/registration scheme to map ULOG messages
-- to unique numeric identifiers.
--
-- The only operations for Tags are ":=", "=" and whatever is
-- specified in Ada.Tags.
--
-- Inspired by Rationale for Ada 2005 §2.6
package ULog.Identifiers is
procedure Register (The_Tag : Ada.Tags.Tag; Code : Character);
function Decode (Code : Character) return Ada.Tags.Tag;
end ULog.Identifiers;
|
AdaCore/ada-traits-containers | Ada | 2,785 | adb | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System;
package body Conts.Elements.Arrays is
package body Fat_Pointers is
type C_Fat_Pointer is record
Data, Bounds : System.Address;
end record;
type Array_Access is access all Array_Type;
pragma No_Strict_Aliasing (Array_Access);
pragma Warnings (Off); -- strict aliasing
function To_FP is new Ada.Unchecked_Conversion
(C_Fat_Pointer, Array_Access);
pragma Warnings (On); -- strict aliasing
procedure Set (FP : in out Fat_Pointer; A : Array_Type) is
begin
FP.Data (1 .. A'Length) := A;
FP.Bounds := (1, A'Length);
end Set;
function Get
(FP : not null access constant Fat_Pointer) return Constant_Ref_Type
is
F : constant C_Fat_Pointer := (FP.Data'Address, FP.Bounds'Address);
AC : constant Array_Access := To_FP (F);
begin
return Constant_Ref_Type'(Element => AC);
end Get;
end Fat_Pointers;
package body Impl is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Array_Type, Array_Access);
---------------
-- To_Stored --
---------------
function To_Stored (A : Array_Type) return Stored_Array is
begin
if A'Length <= Short_Size then
return S : Stored_Array (Short_Array) do
Fat_Pointers.Set (S.Short, A);
end return;
else
return S : Stored_Array (Long_Array) do
S.Long := new Array_Type'(A);
end return;
end if;
end To_Stored;
------------
-- To_Ref --
------------
function To_Ref (S : Stored_Array) return Constant_Ref_Type is
begin
if S.Kind = Short_Array then
return Fat_Pointers.Get (S.Short'Access);
else
return Constant_Ref_Type'(Element => S.Long);
end if;
end To_Ref;
----------
-- Copy --
----------
function Copy (S : Stored_Array) return Stored_Array is
begin
case S.Kind is
when Short_Array =>
return S;
when Long_Array =>
return R : Stored_Array (Long_Array) do
R.Long := new Array_Type'(S.Long.all);
end return;
end case;
end Copy;
-------------
-- Release --
-------------
procedure Release (S : in out Stored_Array) is
begin
if S.Kind = Long_Array then
Unchecked_Free (S.Long);
end if;
end Release;
end Impl;
end Conts.Elements.Arrays;
|
osannolik/ada-canopen | Ada | 1,330 | ads | private with ADA.Containers.Vectors;
package ACO.Drivers.Dummy is
type Dummy_Driver is new Driver with private;
overriding
procedure Receive_Message_Blocking
(This : in out Dummy_Driver;
Msg : out ACO.Messages.Message);
overriding
procedure Send_Message
(This : in out Dummy_Driver;
Msg : in ACO.Messages.Message);
overriding
procedure Initialize
(This : in out Dummy_Driver);
overriding
procedure Finalize
(This : in out Dummy_Driver);
overriding
function Is_Message_Pending
(This : Dummy_Driver)
return Boolean;
procedure Get_First_Sent
(This : in out Dummy_Driver;
Msg : out ACO.Messages.Message);
function Nof_Sent (This : Dummy_Driver) return Natural;
overriding
function Current_Time (This : Dummy_Driver) return Ada.Real_Time.Time;
procedure Set_Time
(This : in out Dummy_Driver;
T : in Ada.Real_Time.Time);
private
use type ACO.Messages.Message;
package V_Message is new Ada.Containers.Vectors
(Natural, ACO.Messages.Message);
subtype Message_Vec is V_Message.Vector;
type Dummy_Driver is new Driver with record
T_Now : Ada.Real_Time.Time := Ada.Real_Time.Time_First;
Tx_Buffer : Message_Vec;
end record;
end ACO.Drivers.Dummy;
|
BrickBot/Bound-T-H8-300 | Ada | 2,472 | ads | -- Options.File_Sets (decl)
--
-- Sets of files (file-names) as options.
--
-- 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:50 $
--
-- $Log: options-file_sets.ads,v $
-- Revision 1.2 2015/10/24 19:36:50 niklas
-- Moved to free licence.
--
-- Revision 1.1 2011-08-31 04:17:13 niklas
-- Added for BT-CH-0222: Option registry. Option -dump. External help files.
--
with Options.String_Sets;
package Options.File_Sets is
type Option_T is new Options.String_Sets.Option_T with null record;
--
-- An option that contains a set of file names.
overriding
function Type_And_Default (Option : access Option_T)
return String;
end Options.File_Sets;
|
thalium/icebox | Ada | 13,143 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: test.adb $
-- The program has a few aims.
-- 1. Test ZLib.Ada95 thick binding functionality.
-- 2. Show the example of use main functionality of the ZLib.Ada95 binding.
-- 3. Build this program automatically compile all ZLib.Ada95 packages under
-- GNAT Ada95 compiler.
with ZLib.Streams;
with Ada.Streams.Stream_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
with Ada.Calendar;
procedure Test is
use Ada.Streams;
use Stream_IO;
------------------------------------
-- Test configuration parameters --
------------------------------------
File_Size : Count := 100_000;
Continuous : constant Boolean := False;
Header : constant ZLib.Header_Type := ZLib.Default;
-- ZLib.None;
-- ZLib.Auto;
-- ZLib.GZip;
-- Do not use Header other then Default in ZLib versions 1.1.4
-- and older.
Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy;
Init_Random : constant := 10;
-- End --
In_File_Name : constant String := "testzlib.in";
-- Name of the input file
Z_File_Name : constant String := "testzlib.zlb";
-- Name of the compressed file.
Out_File_Name : constant String := "testzlib.out";
-- Name of the decompressed file.
File_In : File_Type;
File_Out : File_Type;
File_Back : File_Type;
File_Z : ZLib.Streams.Stream_Type;
Filter : ZLib.Filter_Type;
Time_Stamp : Ada.Calendar.Time;
procedure Generate_File;
-- Generate file of spetsified size with some random data.
-- The random data is repeatable, for the good compression.
procedure Compare_Streams
(Left, Right : in out Root_Stream_Type'Class);
-- The procedure compearing data in 2 streams.
-- It is for compare data before and after compression/decompression.
procedure Compare_Files (Left, Right : String);
-- Compare files. Based on the Compare_Streams.
procedure Copy_Streams
(Source, Target : in out Root_Stream_Type'Class;
Buffer_Size : in Stream_Element_Offset := 1024);
-- Copying data from one stream to another. It is for test stream
-- interface of the library.
procedure Data_In
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- this procedure is for generic instantiation of
-- ZLib.Generic_Translate.
-- reading data from the File_In.
procedure Data_Out (Item : in Stream_Element_Array);
-- this procedure is for generic instantiation of
-- ZLib.Generic_Translate.
-- writing data to the File_Out.
procedure Stamp;
-- Store the timestamp to the local variable.
procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count);
-- Print the time statistic with the message.
procedure Translate is new ZLib.Generic_Translate
(Data_In => Data_In,
Data_Out => Data_Out);
-- This procedure is moving data from File_In to File_Out
-- with compression or decompression, depend on initialization of
-- Filter parameter.
-------------------
-- Compare_Files --
-------------------
procedure Compare_Files (Left, Right : String) is
Left_File, Right_File : File_Type;
begin
Open (Left_File, In_File, Left);
Open (Right_File, In_File, Right);
Compare_Streams (Stream (Left_File).all, Stream (Right_File).all);
Close (Left_File);
Close (Right_File);
end Compare_Files;
---------------------
-- Compare_Streams --
---------------------
procedure Compare_Streams
(Left, Right : in out Ada.Streams.Root_Stream_Type'Class)
is
Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#);
Left_Last, Right_Last : Stream_Element_Offset;
begin
loop
Read (Left, Left_Buffer, Left_Last);
Read (Right, Right_Buffer, Right_Last);
if Left_Last /= Right_Last then
Ada.Text_IO.Put_Line ("Compare error :"
& Stream_Element_Offset'Image (Left_Last)
& " /= "
& Stream_Element_Offset'Image (Right_Last));
raise Constraint_Error;
elsif Left_Buffer (0 .. Left_Last)
/= Right_Buffer (0 .. Right_Last)
then
Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal.");
raise Constraint_Error;
end if;
exit when Left_Last < Left_Buffer'Last;
end loop;
end Compare_Streams;
------------------
-- Copy_Streams --
------------------
procedure Copy_Streams
(Source, Target : in out Ada.Streams.Root_Stream_Type'Class;
Buffer_Size : in Stream_Element_Offset := 1024)
is
Buffer : Stream_Element_Array (1 .. Buffer_Size);
Last : Stream_Element_Offset;
begin
loop
Read (Source, Buffer, Last);
Write (Target, Buffer (1 .. Last));
exit when Last < Buffer'Last;
end loop;
end Copy_Streams;
-------------
-- Data_In --
-------------
procedure Data_In
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
Read (File_In, Item, Last);
end Data_In;
--------------
-- Data_Out --
--------------
procedure Data_Out (Item : in Stream_Element_Array) is
begin
Write (File_Out, Item);
end Data_Out;
-------------------
-- Generate_File --
-------------------
procedure Generate_File is
subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
package Random_Elements is
new Ada.Numerics.Discrete_Random (Visible_Symbols);
Gen : Random_Elements.Generator;
Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10;
Buffer_Count : constant Count := File_Size / Buffer'Length;
-- Number of same buffers in the packet.
Density : constant Count := 30; -- from 0 to Buffer'Length - 2;
procedure Fill_Buffer (J, D : in Count);
-- Change the part of the buffer.
-----------------
-- Fill_Buffer --
-----------------
procedure Fill_Buffer (J, D : in Count) is
begin
for K in 0 .. D loop
Buffer
(Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1))
:= Random_Elements.Random (Gen);
end loop;
end Fill_Buffer;
begin
Random_Elements.Reset (Gen, Init_Random);
Create (File_In, Out_File, In_File_Name);
Fill_Buffer (1, Buffer'Length - 2);
for J in 1 .. Buffer_Count loop
Write (File_In, Buffer);
Fill_Buffer (J, Density);
end loop;
-- fill remain size.
Write
(File_In,
Buffer
(1 .. Stream_Element_Offset
(File_Size - Buffer'Length * Buffer_Count)));
Flush (File_In);
Close (File_In);
end Generate_File;
---------------------
-- Print_Statistic --
---------------------
procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is
use Ada.Calendar;
use Ada.Text_IO;
package Count_IO is new Integer_IO (ZLib.Count);
Curr_Dur : Duration := Clock - Time_Stamp;
begin
Put (Msg);
Set_Col (20);
Ada.Text_IO.Put ("size =");
Count_IO.Put
(Data_Size,
Width => Stream_IO.Count'Image (File_Size)'Length);
Put_Line (" duration =" & Duration'Image (Curr_Dur));
end Print_Statistic;
-----------
-- Stamp --
-----------
procedure Stamp is
begin
Time_Stamp := Ada.Calendar.Clock;
end Stamp;
begin
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
loop
Generate_File;
for Level in ZLib.Compression_Level'Range loop
Ada.Text_IO.Put_Line ("Level ="
& ZLib.Compression_Level'Image (Level));
-- Test generic interface.
Open (File_In, In_File, In_File_Name);
Create (File_Out, Out_File, Z_File_Name);
Stamp;
-- Deflate using generic instantiation.
ZLib.Deflate_Init
(Filter => Filter,
Level => Level,
Strategy => Strategy,
Header => Header);
Translate (Filter);
Print_Statistic ("Generic compress", ZLib.Total_Out (Filter));
ZLib.Close (Filter);
Close (File_In);
Close (File_Out);
Open (File_In, In_File, Z_File_Name);
Create (File_Out, Out_File, Out_File_Name);
Stamp;
-- Inflate using generic instantiation.
ZLib.Inflate_Init (Filter, Header => Header);
Translate (Filter);
Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter));
ZLib.Close (Filter);
Close (File_In);
Close (File_Out);
Compare_Files (In_File_Name, Out_File_Name);
-- Test stream interface.
-- Compress to the back stream.
Open (File_In, In_File, In_File_Name);
Create (File_Back, Out_File, Z_File_Name);
Stamp;
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.Out_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => True,
Level => Level,
Strategy => Strategy,
Header => Header);
Copy_Streams
(Source => Stream (File_In).all,
Target => File_Z);
-- Flushing internal buffers to the back stream.
ZLib.Streams.Flush (File_Z, ZLib.Finish);
Print_Statistic ("Write compress",
ZLib.Streams.Write_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_In);
Close (File_Back);
-- Compare reading from original file and from
-- decompression stream.
Open (File_In, In_File, In_File_Name);
Open (File_Back, In_File, Z_File_Name);
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.In_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => True,
Header => Header);
Stamp;
Compare_Streams (Stream (File_In).all, File_Z);
Print_Statistic ("Read decompress",
ZLib.Streams.Read_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_In);
Close (File_Back);
-- Compress by reading from compression stream.
Open (File_Back, In_File, In_File_Name);
Create (File_Out, Out_File, Z_File_Name);
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.In_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => False,
Level => Level,
Strategy => Strategy,
Header => Header);
Stamp;
Copy_Streams
(Source => File_Z,
Target => Stream (File_Out).all);
Print_Statistic ("Read compress",
ZLib.Streams.Read_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_Out);
Close (File_Back);
-- Decompress to decompression stream.
Open (File_In, In_File, Z_File_Name);
Create (File_Back, Out_File, Out_File_Name);
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.Out_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => False,
Header => Header);
Stamp;
Copy_Streams
(Source => Stream (File_In).all,
Target => File_Z);
Print_Statistic ("Write decompress",
ZLib.Streams.Write_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_In);
Close (File_Back);
Compare_Files (In_File_Name, Out_File_Name);
end loop;
Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok.");
exit when not Continuous;
File_Size := File_Size + 1;
end loop;
end Test;
|
sudoadminservices/bugbountyservices | Ada | 1,804 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "CIRCL"
type = "api"
function start()
setratelimit(2)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.username ~= nil and
c.password ~= nil and c.username ~= "" and c.password ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.username == nil or
c.username == "" or c.password == nil or c.password == "") then
return
end
local page, err = request({
url=buildurl(domain),
headers={['Content-Type']="application/json"},
id=c['username'],
pass=c['password'],
})
if (err ~= nil and err ~= "") then
return
end
for line in page:gmatch("([^\n]*)\n?") do
local j = json.decode(line)
if (j ~= nil and j.rrname ~= "") then
newname(ctx, j.rrname)
if (j.rrtype == "A" or j.rrtype == "AAAA") then
newaddr(ctx, j.rdata, domain)
else
sendnames(ctx, j.rdata)
end
end
end
end
function buildurl(domain)
return "https://www.circl.lu/pdns/query/" .. domain
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
local found = {}
for i, v in pairs(names) do
if found[v] == nil then
newname(ctx, v)
found[v] = true
end
end
end
|
optikos/oasis | Ada | 6,029 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Formal_Private_Type_Definitions is
function Create
(Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access;
Tagged_Token : Program.Lexical_Elements.Lexical_Element_Access;
Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
Private_Token : not null Program.Lexical_Elements.Lexical_Element_Access)
return Formal_Private_Type_Definition is
begin
return Result : Formal_Private_Type_Definition :=
(Abstract_Token => Abstract_Token, Tagged_Token => Tagged_Token,
Limited_Token => Limited_Token, Private_Token => Private_Token,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Abstract : Boolean := False;
Has_Tagged : Boolean := False;
Has_Limited : Boolean := False)
return Implicit_Formal_Private_Type_Definition is
begin
return Result : Implicit_Formal_Private_Type_Definition :=
(Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance,
Has_Abstract => Has_Abstract, Has_Tagged => Has_Tagged,
Has_Limited => Has_Limited, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Abstract_Token
(Self : Formal_Private_Type_Definition)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Abstract_Token;
end Abstract_Token;
overriding function Tagged_Token
(Self : Formal_Private_Type_Definition)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Tagged_Token;
end Tagged_Token;
overriding function Limited_Token
(Self : Formal_Private_Type_Definition)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Limited_Token;
end Limited_Token;
overriding function Private_Token
(Self : Formal_Private_Type_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Private_Token;
end Private_Token;
overriding function Has_Abstract
(Self : Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Abstract_Token.Assigned;
end Has_Abstract;
overriding function Has_Tagged
(Self : Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Tagged_Token.Assigned;
end Has_Tagged;
overriding function Has_Limited
(Self : Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Limited_Token.Assigned;
end Has_Limited;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Abstract
(Self : Implicit_Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Has_Abstract;
end Has_Abstract;
overriding function Has_Tagged
(Self : Implicit_Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Has_Tagged;
end Has_Tagged;
overriding function Has_Limited
(Self : Implicit_Formal_Private_Type_Definition)
return Boolean is
begin
return Self.Has_Limited;
end Has_Limited;
procedure Initialize
(Self : aliased in out Base_Formal_Private_Type_Definition'Class) is
begin
null;
end Initialize;
overriding function Is_Formal_Private_Type_Definition_Element
(Self : Base_Formal_Private_Type_Definition)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Formal_Private_Type_Definition_Element;
overriding function Is_Formal_Type_Definition_Element
(Self : Base_Formal_Private_Type_Definition)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Formal_Type_Definition_Element;
overriding function Is_Definition_Element
(Self : Base_Formal_Private_Type_Definition)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Definition_Element;
overriding procedure Visit
(Self : not null access Base_Formal_Private_Type_Definition;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Formal_Private_Type_Definition (Self);
end Visit;
overriding function To_Formal_Private_Type_Definition_Text
(Self : aliased in out Formal_Private_Type_Definition)
return Program.Elements.Formal_Private_Type_Definitions
.Formal_Private_Type_Definition_Text_Access is
begin
return Self'Unchecked_Access;
end To_Formal_Private_Type_Definition_Text;
overriding function To_Formal_Private_Type_Definition_Text
(Self : aliased in out Implicit_Formal_Private_Type_Definition)
return Program.Elements.Formal_Private_Type_Definitions
.Formal_Private_Type_Definition_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Formal_Private_Type_Definition_Text;
end Program.Nodes.Formal_Private_Type_Definitions;
|
reznikmm/matreshka | Ada | 4,534 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Svg.Fx_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Fx_Attribute_Node is
begin
return Self : Svg_Fx_Attribute_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Svg_Fx_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Fx_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Fx_Attribute,
Svg_Fx_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Fx_Attributes;
|
zhmu/ananas | Ada | 628 | adb | -- { dg-do compile }
-- { dg-options "-gnatX" }
procedure AI12_0086_Example is
type Enum is (Aa, Bb, Cc, Dd, Ee, Ff, Gg, Hh, Ii, Jj, Kk, Ll, MM,
Nn, Oo, Pp, Qq, Rr, Ss, Tt, Uu, Vv, Ww, Xx, Yy, Zz);
subtype S is Enum range Dd .. Hh;
type Rec (D : Enum) is record
case D is
when S => Foo, Bar : Integer;
when others => null;
end case;
end record;
function Make (D : S) return Rec is
begin
return (D => D, Foo => 123, Bar => 456); -- legal
end;
begin
if Make (Ff).Bar /= 456 then
raise Program_Error;
end if;
end AI12_0086_Example; |
Hamster-Furtif/JeremyPlusPlus | Ada | 1,508 | adb | with Ada.Text_IO;
use Ada.Text_IO;
with GNAT.OS_Lib;
use GNAT.OS_Lib;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Fixed;
use Ada.Strings.Fixed;
procedure Launcher is
Java : constant String := "C:\Program Files\Java\jre1.8.0_191\bin\java";
Engine : constant String := "lib/engine.jar";
Ref_Name : constant String := "Javabot";
Ref_Bot : constant String := "lib/bot.jar";
Ada_Name : constant String := "Adabot";
Ada_Bot : constant String := "obj/bot";
Result : Boolean;
Arguments : Argument_List :=
(
1 => new String'("-jar"),
2 => new String'(Engine),
3 => new String'(Ref_Name),
4 => new String'(Java & " -jar " & Ref_Bot),
--4 => new String'("obj/bot2"),
--4 => new String'(Ada_Bot),
5 => new String'(Ada_Name),
6 => new String'(Ada_Bot),
7 => null
);
package Rand_Int is new Ada.Numerics.Discrete_Random(Positive);
seed : Integer;
generator : Rand_Int.Generator;
seedStr : String_Access;
begin
-- Get a random number as a seed for the engine
Put_Line("Launching...");
Rand_Int.Reset(generator);
seed := Rand_Int.Random(generator);
seedStr := new String'(Trim(Positive'Image(seed), Ada.Strings.Left));
Arguments(7) := seedStr;
Spawn(
Program_Name => Java,
Args => Arguments,
Success => Result
);
if (not Result) then
Put_Line("Engine execution failed: please check your configuration.");
end if;
end Launcher;
|
HeisenbugLtd/open_weather_map_api | Ada | 8,308 | adb | --------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
--------------------------------------------------------------------------------
pragma License (Unrestricted);
with Ada.Environment_Variables;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with GNATCOLL.JSON;
package body Open_Weather_Map.Client is
My_Debug : constant not null GNATCOLL.Traces.Trace_Handle :=
GNATCOLL.Traces.Create (Unit_Name => "OWM.CLIENT");
-----------------------------------------------------------------------------
-- Free
-----------------------------------------------------------------------------
procedure Free is
new Ada.Unchecked_Deallocation
(Object => AWS.Client.HTTP_Connection,
Name => AWS.Client.HTTP_Connection_Access);
type T_Local_Access is access all T;
-----------------------------------------------------------------------------
-- Free
-----------------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation (Object => T,
Name => T_Local_Access);
-----------------------------------------------------------------------------
-- Connection
-----------------------------------------------------------------------------
function Connection
(Self : in out T) return not null AWS.Client.HTTP_Connection_Access
is
use type Ada.Real_Time.Time;
Next_Allowed : constant Ada.Real_Time.Time := Self.Last_Access + Self.Rate_Limit;
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
My_Debug.all.Trace (Message => "Connection");
if Next_Allowed > Now then
My_Debug.all.Trace
(Message => "Connection: Rate limit exceeded, throttling...");
delay until Next_Allowed;
My_Debug.all.Trace (Message => "Connection: Rate limited.");
Self.Last_Access := Next_Allowed;
else
Self.Last_Access := Now;
end if;
return Self.HTTP_Connection;
end Connection;
-----------------------------------------------------------------------------
-- Create
-----------------------------------------------------------------------------
function Create
(Configuration : in GNATCOLL.JSON.JSON_Value;
Rate_Limit : in Ada.Real_Time.Time_Span := Default_Rate_Limit) return T_Access
is
Result : T_Access;
begin
My_Debug.all.Trace (Message => "Create");
begin
Result := new T;
Result.all.Initialize (Configuration => Configuration,
Rate_Limit => Rate_Limit);
return Result;
exception
when others =>
Destroy (Result);
raise;
end;
end Create;
-----------------------------------------------------------------------------
-- Destroy
-----------------------------------------------------------------------------
procedure Destroy (Self : in out T_Access) is
begin
if Self /= null then
Self.all.Finalize;
Free (T_Local_Access (Self));
end if;
end Destroy;
-----------------------------------------------------------------------------
-- Finalize
-----------------------------------------------------------------------------
overriding procedure Finalize (Self : in out T) is
begin
My_Debug.all.Trace (Message => "Finalize");
Free (Self.HTTP_Connection);
end Finalize;
-----------------------------------------------------------------------------
-- Initialize
-----------------------------------------------------------------------------
procedure Initialize
(Self : out T;
Configuration : in GNATCOLL.JSON.JSON_Value;
Rate_Limit : in Ada.Real_Time.Time_Span := Default_Rate_Limit)
is
-- Proxy information.
Network_Address : Ada.Strings.Unbounded.Unbounded_String;
User : Ada.Strings.Unbounded.Unbounded_String;
Password : Ada.Strings.Unbounded.Unbounded_String;
--------------------------------------------------------------------------
-- "+"
--------------------------------------------------------------------------
function "+"
(Source : in Ada.Strings.Unbounded.Unbounded_String) return String
renames Ada.Strings.Unbounded.To_String;
begin
My_Debug.all.Trace (Message => "Initialize");
Self.Rate_Limit := Rate_Limit;
Self.Last_Access := Ada.Real_Time.Time_First;
Get_Proxy_Information :
declare
use type Ada.Strings.Unbounded.Unbounded_String;
begin
-- TODO: Better error handling.
My_Debug.all.Trace
(Message => "Initialize: Loading proxy configuration...");
-- Try to get proxy URL from configuration file.
if
Configuration.Has_Field (Field => Config_Names.Field_Network_Address)
then
Network_Address :=
Configuration.Get (Field => Config_Names.Field_Network_Address);
end if;
-- If there's still no proxy URL, try to get it from the environment
-- variables.
if
Network_Address = AWS.Client.No_Data and then
Ada.Environment_Variables.Exists
(Name => Config_Names.Env_Network_Address)
then
Network_Address :=
Ada.Strings.Unbounded.To_Unbounded_String
(Source =>
Ada.Environment_Variables.Value
(Name => Config_Names.Env_Network_Address));
end if;
-- Proxy user and password are only useful if there actually is a
-- proxy.
if Network_Address /= AWS.Client.No_Data then
if Configuration.Has_Field (Field => Config_Names.Field_User) then
User := Configuration.Get (Field => Config_Names.Field_User);
-- Passwords only make sense if there's also a username.
if
Configuration.Has_Field (Field => Config_Names.Field_Password)
then
Password :=
Configuration.Get (Field => Config_Names.Field_Password);
end if;
end if;
end if;
My_Debug.all.Trace
(Message => "Initialize: Proxy configuration loaded.");
exception
when E : others =>
My_Debug.all.Trace
(E => E,
Msg => "Initialize: Error parsing configuration data: ");
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item =>
"Warning: Missing or invalid JSON data, " &
"proxy configuration may only be partial.");
end Get_Proxy_Information;
My_Debug.all.Trace
(Message =>
"Initialize: Proxy """ & (+Network_Address) & """" &
", user: """ & (+User) & """, password not shown.");
Create_Network_Connection :
begin
My_Debug.all.Trace
(Message => "Initialize: Creating network connection...");
Self.HTTP_Connection := new AWS.Client.HTTP_Connection'
(AWS.Client.Create
(Host => API_Host,
Proxy => +Network_Address,
Proxy_User => +User,
Proxy_Pwd => +Password,
Timeouts => AWS.Client.Timeouts (Each => 10.0)));
My_Debug.all.Trace
(Message => "Initialize: Network connection created.");
exception
when E : others =>
My_Debug.all.Trace
(E => E,
Msg => "Initialize: Error creating network connection: ");
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item => "Error: HTTP connection failed!");
end Create_Network_Connection;
end Initialize;
end Open_Weather_Map.Client;
|
persan/gprTools | Ada | 1,482 | ads | with GNAT.Sockets;
with GNAT.Spitbol.Table_VString;
with Ada.Containers.Vectors;
package GPR_Tools.Gprslaves.DB is
type Host_Address is record
Name : GNAT.Spitbol.VString;
Port : GNAT.Sockets.Port_Type;
end record;
package Host_Info_Vectors is new
Ada.Containers.Vectors (Natural, Host_Address);
type Info_Struct is tagged record
Host : Host_Address;
Keys : GNAT.Spitbol.Table_VString.Table (32);
end record;
function Get_Free_Port (Default : GNAT.Sockets.Port_Type := 8484) return GNAT.Sockets.Port_Type;
function Get_Gnat_Version return String;
procedure Initialize (Self : in out Info_Struct;
HostName : String := GNAT.Sockets.Host_Name;
Port : GNAT.Sockets.Port_Type := Get_Free_Port);
procedure Append (Self : in out Info_Struct;
Key_Name : String;
Key_Value : String);
type Table is tagged private;
procedure Register (Self : in out Table;
Host : Host_Address;
Keys : GNAT.Spitbol.Table_VString.Table);
function Find (Self : Table;
Keys : GNAT.Spitbol.Table_VString.Table)
return Host_Info_Vectors.Vector;
private
package Host_Vectors is new Ada.Containers.Vectors (Natural, Info_Struct);
type Table is tagged record
Hosts : Host_Vectors.Vector;
end record;
end GPR_Tools.Gprslaves.DB;
|
RREE/ada-util | Ada | 1,569 | ads | -----------------------------------------------------------------------
-- util-texts-builders_tests -- Unit tests for text builders
-- Copyright (C) 2013, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Util.Texts.Builders_Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test the length operation.
procedure Test_Length (T : in out Test);
-- Test the append operation.
procedure Test_Append (T : in out Test);
-- Test the iterate operation.
procedure Test_Iterate (T : in out Test);
-- Test the clear operation.
procedure Test_Clear (T : in out Test);
-- Test the tail operation.
procedure Test_Tail (T : in out Test);
-- Test the append and iterate performance.
procedure Test_Perf (T : in out Test);
end Util.Texts.Builders_Tests;
|
zhmu/ananas | Ada | 40,986 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . F O R M A L _ O R D E R E D _ M A P S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
------------------------------------------------------------------------------
-- This spec is derived from package Ada.Containers.Bounded_Ordered_Maps in
-- the Ada 2012 RM. The modifications are meant to facilitate formal proofs by
-- making it easier to express properties, and by making the specification of
-- this unit compatible with SPARK 2014. Note that the API of this unit may be
-- subject to incompatible changes as SPARK 2014 evolves.
-- The modifications are:
-- A parameter for the container is added to every function reading the
-- content of a container: Key, Element, Next, Query_Element, Previous,
-- Has_Element, Iterate, Reverse_Iterate. This change is motivated by the
-- need to have cursors which are valid on different containers (typically a
-- container C and its previous version C'Old) for expressing properties,
-- which is not possible if cursors encapsulate an access to the underlying
-- container. The operators "<" and ">" that could not be modified that way
-- have been removed.
-- Iteration over maps is done using the Iterable aspect, which is SPARK
-- compatible. "For of" iteration ranges over keys instead of elements.
with Ada.Containers.Functional_Vectors;
with Ada.Containers.Functional_Maps;
private with Ada.Containers.Red_Black_Trees;
generic
type Key_Type is private;
type Element_Type is private;
with function "<" (Left, Right : Key_Type) return Boolean is <>;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Formal_Ordered_Maps with
SPARK_Mode
is
-- Contracts in this unit are meant for analysis only, not for run-time
-- checking.
pragma Assertion_Policy (Pre => Ignore);
pragma Assertion_Policy (Post => Ignore);
pragma Assertion_Policy (Contract_Cases => Ignore);
pragma Annotate (CodePeer, Skip_Analysis);
function Equivalent_Keys (Left, Right : Key_Type) return Boolean with
Global => null,
Post =>
Equivalent_Keys'Result = (not (Left < Right) and not (Right < Left));
pragma Annotate (GNATprove, Inline_For_Proof, Equivalent_Keys);
type Map (Capacity : Count_Type) is private with
Iterable => (First => First,
Next => Next,
Has_Element => Has_Element,
Element => Key),
Default_Initial_Condition => Is_Empty (Map);
pragma Preelaborable_Initialization (Map);
type Cursor is record
Node : Count_Type;
end record;
No_Element : constant Cursor := (Node => 0);
Empty_Map : constant Map;
function Length (Container : Map) return Count_Type with
Global => null,
Post => Length'Result <= Container.Capacity;
pragma Unevaluated_Use_Of_Old (Allow);
package Formal_Model with Ghost is
subtype Positive_Count_Type is Count_Type range 1 .. Count_Type'Last;
package M is new Ada.Containers.Functional_Maps
(Element_Type => Element_Type,
Key_Type => Key_Type,
Equivalent_Keys => Equivalent_Keys);
function "="
(Left : M.Map;
Right : M.Map) return Boolean renames M."=";
function "<="
(Left : M.Map;
Right : M.Map) return Boolean renames M."<=";
package K is new Ada.Containers.Functional_Vectors
(Element_Type => Key_Type,
Index_Type => Positive_Count_Type);
function "="
(Left : K.Sequence;
Right : K.Sequence) return Boolean renames K."=";
function "<"
(Left : K.Sequence;
Right : K.Sequence) return Boolean renames K."<";
function "<="
(Left : K.Sequence;
Right : K.Sequence) return Boolean renames K."<=";
function K_Bigger_Than_Range
(Container : K.Sequence;
Fst : Positive_Count_Type;
Lst : Count_Type;
Key : Key_Type) return Boolean
with
Global => null,
Pre => Lst <= K.Length (Container),
Post =>
K_Bigger_Than_Range'Result =
(for all I in Fst .. Lst => K.Get (Container, I) < Key);
pragma Annotate (GNATprove, Inline_For_Proof, K_Bigger_Than_Range);
function K_Smaller_Than_Range
(Container : K.Sequence;
Fst : Positive_Count_Type;
Lst : Count_Type;
Key : Key_Type) return Boolean
with
Global => null,
Pre => Lst <= K.Length (Container),
Post =>
K_Smaller_Than_Range'Result =
(for all I in Fst .. Lst => Key < K.Get (Container, I));
pragma Annotate (GNATprove, Inline_For_Proof, K_Smaller_Than_Range);
function K_Is_Find
(Container : K.Sequence;
Key : Key_Type;
Position : Count_Type) return Boolean
with
Global => null,
Pre => Position - 1 <= K.Length (Container),
Post =>
K_Is_Find'Result =
((if Position > 0 then
K_Bigger_Than_Range (Container, 1, Position - 1, Key))
and
(if Position < K.Length (Container) then
K_Smaller_Than_Range
(Container,
Position + 1,
K.Length (Container),
Key)));
pragma Annotate (GNATprove, Inline_For_Proof, K_Is_Find);
function Find (Container : K.Sequence; Key : Key_Type) return Count_Type
-- Search for Key in Container
with
Global => null,
Post =>
(if Find'Result > 0 then
Find'Result <= K.Length (Container)
and Equivalent_Keys (Key, K.Get (Container, Find'Result)));
package P is new Ada.Containers.Functional_Maps
(Key_Type => Cursor,
Element_Type => Positive_Count_Type,
Equivalent_Keys => "=",
Enable_Handling_Of_Equivalence => False);
function "="
(Left : P.Map;
Right : P.Map) return Boolean renames P."=";
function "<="
(Left : P.Map;
Right : P.Map) return Boolean renames P."<=";
function P_Positions_Shifted
(Small : P.Map;
Big : P.Map;
Cut : Positive_Count_Type;
Count : Count_Type := 1) return Boolean
with
Global => null,
Post =>
P_Positions_Shifted'Result =
-- Big contains all cursors of Small
(P.Keys_Included (Small, Big)
-- Cursors located before Cut are not moved, cursors located
-- after are shifted by Count.
and (for all I of Small =>
(if P.Get (Small, I) < Cut then
P.Get (Big, I) = P.Get (Small, I)
else
P.Get (Big, I) - Count = P.Get (Small, I)))
-- New cursors of Big (if any) are between Cut and Cut - 1 +
-- Count.
and (for all I of Big =>
P.Has_Key (Small, I)
or P.Get (Big, I) - Count in Cut - Count .. Cut - 1));
function Model (Container : Map) return M.Map with
-- The high-level model of a map is a map from keys to elements. Neither
-- cursors nor order of elements are represented in this model. Keys are
-- modeled up to equivalence.
Ghost,
Global => null;
function Keys (Container : Map) return K.Sequence with
-- The Keys sequence represents the underlying list structure of maps
-- that is used for iteration. It stores the actual values of keys in
-- the map. It does not model cursors nor elements.
Ghost,
Global => null,
Post =>
K.Length (Keys'Result) = Length (Container)
-- It only contains keys contained in Model
and (for all Key of Keys'Result =>
M.Has_Key (Model (Container), Key))
-- It contains all the keys contained in Model
and (for all Key of Model (Container) =>
(Find (Keys'Result, Key) > 0
and then Equivalent_Keys
(K.Get (Keys'Result, Find (Keys'Result, Key)),
Key)))
-- It is sorted in increasing order
and (for all I in 1 .. Length (Container) =>
Find (Keys'Result, K.Get (Keys'Result, I)) = I
and K_Is_Find (Keys'Result, K.Get (Keys'Result, I), I));
pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Keys);
function Positions (Container : Map) return P.Map with
-- The Positions map is used to model cursors. It only contains valid
-- cursors and maps them to their position in the container.
Ghost,
Global => null,
Post =>
not P.Has_Key (Positions'Result, No_Element)
-- Positions of cursors are smaller than the container's length.
and then
(for all I of Positions'Result =>
P.Get (Positions'Result, I) in 1 .. Length (Container)
-- No two cursors have the same position. Note that we do not
-- state that there is a cursor in the map for each position, as
-- it is rarely needed.
and then
(for all J of Positions'Result =>
(if P.Get (Positions'Result, I) = P.Get (Positions'Result, J)
then I = J)));
procedure Lift_Abstraction_Level (Container : Map) with
-- Lift_Abstraction_Level is a ghost procedure that does nothing but
-- assume that we can access the same elements by iterating over
-- positions or cursors.
-- This information is not generally useful except when switching from
-- a low-level, cursor-aware view of a container, to a high-level,
-- position-based view.
Ghost,
Global => null,
Post =>
(for all Key of Keys (Container) =>
(for some I of Positions (Container) =>
K.Get (Keys (Container), P.Get (Positions (Container), I)) =
Key));
function Contains
(C : M.Map;
K : Key_Type) return Boolean renames M.Has_Key;
-- To improve readability of contracts, we rename the function used to
-- search for a key in the model to Contains.
function Element
(C : M.Map;
K : Key_Type) return Element_Type renames M.Get;
-- To improve readability of contracts, we rename the function used to
-- access an element in the model to Element.
end Formal_Model;
use Formal_Model;
function "=" (Left, Right : Map) return Boolean with
Global => null,
Post => "="'Result = (Model (Left) = Model (Right));
function Is_Empty (Container : Map) return Boolean with
Global => null,
Post => Is_Empty'Result = (Length (Container) = 0);
procedure Clear (Container : in out Map) with
Global => null,
Post => Length (Container) = 0 and M.Is_Empty (Model (Container));
procedure Assign (Target : in out Map; Source : Map) with
Global => null,
Pre => Target.Capacity >= Length (Source),
Post =>
Model (Target) = Model (Source)
and Keys (Target) = Keys (Source)
and Length (Source) = Length (Target);
function Copy (Source : Map; Capacity : Count_Type := 0) return Map with
Global => null,
Pre => Capacity = 0 or else Capacity >= Source.Capacity,
Post =>
Model (Copy'Result) = Model (Source)
and Keys (Copy'Result) = Keys (Source)
and Positions (Copy'Result) = Positions (Source)
and (if Capacity = 0 then
Copy'Result.Capacity = Source.Capacity
else
Copy'Result.Capacity = Capacity);
function Key (Container : Map; Position : Cursor) return Key_Type with
Global => null,
Pre => Has_Element (Container, Position),
Post =>
Key'Result =
K.Get (Keys (Container), P.Get (Positions (Container), Position));
pragma Annotate (GNATprove, Inline_For_Proof, Key);
function Element
(Container : Map;
Position : Cursor) return Element_Type
with
Global => null,
Pre => Has_Element (Container, Position),
Post =>
Element'Result = Element (Model (Container), Key (Container, Position));
pragma Annotate (GNATprove, Inline_For_Proof, Element);
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type)
with
Global => null,
Pre => Has_Element (Container, Position),
Post =>
-- Order of keys and cursors is preserved
Keys (Container) = Keys (Container)'Old
and Positions (Container) = Positions (Container)'Old
-- New_Item is now associated with the key at position Position in
-- Container.
and Element (Container, Position) = New_Item
-- Elements associated with other keys are preserved
and M.Same_Keys (Model (Container), Model (Container)'Old)
and M.Elements_Equal_Except
(Model (Container),
Model (Container)'Old,
Key (Container, Position));
function At_End
(E : not null access constant Map) return not null access constant Map
is (E)
with Ghost,
Annotate => (GNATprove, At_End_Borrow);
function At_End
(E : access constant Element_Type) return access constant Element_Type
is (E)
with Ghost,
Annotate => (GNATprove, At_End_Borrow);
function Constant_Reference
(Container : aliased Map;
Position : Cursor) return not null access constant Element_Type
with
Global => null,
Pre => Has_Element (Container, Position),
Post =>
Constant_Reference'Result.all =
Element (Model (Container), Key (Container, Position));
function Reference
(Container : not null access Map;
Position : Cursor) return not null access Element_Type
with
Global => null,
Pre => Has_Element (Container.all, Position),
Post =>
-- Order of keys and cursors is preserved
Keys (At_End (Container).all) = Keys (Container.all)
and Positions (At_End (Container).all) = Positions (Container.all)
-- The value designated by the result of Reference is now associated
-- with the key at position Position in Container.
and Element (At_End (Container).all, Position) =
At_End (Reference'Result).all
-- Elements associated with other keys are preserved
and M.Same_Keys
(Model (At_End (Container).all),
Model (Container.all))
and M.Elements_Equal_Except
(Model (At_End (Container).all),
Model (Container.all),
Key (At_End (Container).all, Position));
function Constant_Reference
(Container : aliased Map;
Key : Key_Type) return not null access constant Element_Type
with
Global => null,
Pre => Contains (Container, Key),
Post =>
Constant_Reference'Result.all = Element (Model (Container), Key);
function Reference
(Container : not null access Map;
Key : Key_Type) return not null access Element_Type
with
Global => null,
Pre => Contains (Container.all, Key),
Post =>
-- Order of keys and cursors is preserved
Keys (At_End (Container).all) = Keys (Container.all)
and Positions (At_End (Container).all) = Positions (Container.all)
-- The value designated by the result of Reference is now associated
-- with Key in Container.
and Element (Model (At_End (Container).all), Key) =
At_End (Reference'Result).all
-- Elements associated with other keys are preserved
and M.Same_Keys
(Model (At_End (Container).all),
Model (Container.all))
and M.Elements_Equal_Except
(Model (At_End (Container).all),
Model (Container.all),
Key);
procedure Move (Target : in out Map; Source : in out Map) with
Global => null,
Pre => Target.Capacity >= Length (Source),
Post =>
Model (Target) = Model (Source)'Old
and Keys (Target) = Keys (Source)'Old
and Length (Source)'Old = Length (Target)
and Length (Source) = 0;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
with
Global => null,
Pre =>
Length (Container) < Container.Capacity or Contains (Container, Key),
Post =>
Contains (Container, Key)
and Has_Element (Container, Position)
and Equivalent_Keys
(Formal_Ordered_Maps.Key (Container, Position), Key)
and K_Is_Find
(Keys (Container),
Key,
P.Get (Positions (Container), Position)),
Contract_Cases =>
-- If Key is already in Container, it is not modified and Inserted is
-- set to False.
(Contains (Container, Key) =>
not Inserted
and Model (Container) = Model (Container)'Old
and Keys (Container) = Keys (Container)'Old
and Positions (Container) = Positions (Container)'Old,
-- Otherwise, Key is inserted in Container and Inserted is set to True
others =>
Inserted
and Length (Container) = Length (Container)'Old + 1
-- Key now maps to New_Item
and Formal_Ordered_Maps.Key (Container, Position) = Key
and Element (Model (Container), Key) = New_Item
-- Other mappings are preserved
and Model (Container)'Old <= Model (Container)
and M.Keys_Included_Except
(Model (Container),
Model (Container)'Old,
Key)
-- The keys of Container located before Position are preserved
and K.Range_Equal
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => 1,
Lst => P.Get (Positions (Container), Position) - 1)
-- Other keys are shifted by 1
and K.Range_Shifted
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => P.Get (Positions (Container), Position),
Lst => Length (Container)'Old,
Offset => 1)
-- A new cursor has been inserted at position Position in
-- Container.
and P_Positions_Shifted
(Positions (Container)'Old,
Positions (Container),
Cut => P.Get (Positions (Container), Position)));
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
with
Global => null,
Pre =>
Length (Container) < Container.Capacity
and then (not Contains (Container, Key)),
Post =>
Length (Container) = Length (Container)'Old + 1
and Contains (Container, Key)
-- Key now maps to New_Item
and K.Get (Keys (Container), Find (Keys (Container), Key)) = Key
and Element (Model (Container), Key) = New_Item
-- Other mappings are preserved
and Model (Container)'Old <= Model (Container)
and M.Keys_Included_Except
(Model (Container),
Model (Container)'Old,
Key)
-- The keys of Container located before Key are preserved
and K.Range_Equal
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => 1,
Lst => Find (Keys (Container), Key) - 1)
-- Other keys are shifted by 1
and K.Range_Shifted
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => Find (Keys (Container), Key),
Lst => Length (Container)'Old,
Offset => 1)
-- A new cursor has been inserted in Container
and P_Positions_Shifted
(Positions (Container)'Old,
Positions (Container),
Cut => Find (Keys (Container), Key));
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
with
Global => null,
Pre =>
Length (Container) < Container.Capacity or Contains (Container, Key),
Post =>
Contains (Container, Key) and Element (Container, Key) = New_Item,
Contract_Cases =>
-- If Key is already in Container, Key is mapped to New_Item
(Contains (Container, Key) =>
-- Cursors are preserved
Positions (Container) = Positions (Container)'Old
-- The key equivalent to Key in Container is replaced by Key
and K.Get
(Keys (Container), Find (Keys (Container), Key)) = Key
and K.Equal_Except
(Keys (Container)'Old,
Keys (Container),
Find (Keys (Container), Key))
-- Elements associated with other keys are preserved
and M.Same_Keys (Model (Container), Model (Container)'Old)
and M.Elements_Equal_Except
(Model (Container),
Model (Container)'Old,
Key),
-- Otherwise, Key is inserted in Container
others =>
Length (Container) = Length (Container)'Old + 1
-- Other mappings are preserved
and Model (Container)'Old <= Model (Container)
and M.Keys_Included_Except
(Model (Container),
Model (Container)'Old,
Key)
-- Key is inserted in Container
and K.Get
(Keys (Container), Find (Keys (Container), Key)) = Key
-- The keys of Container located before Key are preserved
and K.Range_Equal
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => 1,
Lst => Find (Keys (Container), Key) - 1)
-- Other keys are shifted by 1
and K.Range_Shifted
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => Find (Keys (Container), Key),
Lst => Length (Container)'Old,
Offset => 1)
-- A new cursor has been inserted in Container
and P_Positions_Shifted
(Positions (Container)'Old,
Positions (Container),
Cut => Find (Keys (Container), Key)));
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
with
Global => null,
Pre => Contains (Container, Key),
Post =>
-- Cursors are preserved
Positions (Container) = Positions (Container)'Old
-- The key equivalent to Key in Container is replaced by Key
and K.Get (Keys (Container), Find (Keys (Container), Key)) = Key
and K.Equal_Except
(Keys (Container)'Old,
Keys (Container),
Find (Keys (Container), Key))
-- New_Item is now associated with the Key in Container
and Element (Model (Container), Key) = New_Item
-- Elements associated with other keys are preserved
and M.Same_Keys (Model (Container), Model (Container)'Old)
and M.Elements_Equal_Except
(Model (Container),
Model (Container)'Old,
Key);
procedure Exclude (Container : in out Map; Key : Key_Type) with
Global => null,
Post => not Contains (Container, Key),
Contract_Cases =>
-- If Key is not in Container, nothing is changed
(not Contains (Container, Key) =>
Model (Container) = Model (Container)'Old
and Keys (Container) = Keys (Container)'Old
and Positions (Container) = Positions (Container)'Old,
-- Otherwise, Key is removed from Container
others =>
Length (Container) = Length (Container)'Old - 1
-- Other mappings are preserved
and Model (Container) <= Model (Container)'Old
and M.Keys_Included_Except
(Model (Container)'Old,
Model (Container),
Key)
-- The keys of Container located before Key are preserved
and K.Range_Equal
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => 1,
Lst => Find (Keys (Container), Key)'Old - 1)
-- The keys located after Key are shifted by 1
and K.Range_Shifted
(Left => Keys (Container),
Right => Keys (Container)'Old,
Fst => Find (Keys (Container), Key)'Old,
Lst => Length (Container),
Offset => 1)
-- A cursor has been removed from Container
and P_Positions_Shifted
(Positions (Container),
Positions (Container)'Old,
Cut => Find (Keys (Container), Key)'Old));
procedure Delete (Container : in out Map; Key : Key_Type) with
Global => null,
Pre => Contains (Container, Key),
Post =>
Length (Container) = Length (Container)'Old - 1
-- Key is no longer in Container
and not Contains (Container, Key)
-- Other mappings are preserved
and Model (Container) <= Model (Container)'Old
and M.Keys_Included_Except
(Model (Container)'Old,
Model (Container),
Key)
-- The keys of Container located before Key are preserved
and K.Range_Equal
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => 1,
Lst => Find (Keys (Container), Key)'Old - 1)
-- The keys located after Key are shifted by 1
and K.Range_Shifted
(Left => Keys (Container),
Right => Keys (Container)'Old,
Fst => Find (Keys (Container), Key)'Old,
Lst => Length (Container),
Offset => 1)
-- A cursor has been removed from Container
and P_Positions_Shifted
(Positions (Container),
Positions (Container)'Old,
Cut => Find (Keys (Container), Key)'Old);
procedure Delete (Container : in out Map; Position : in out Cursor) with
Global => null,
Depends => (Container =>+ Position, Position => null),
Pre => Has_Element (Container, Position),
Post =>
Position = No_Element
and Length (Container) = Length (Container)'Old - 1
-- The key at position Position is no longer in Container
and not Contains (Container, Key (Container, Position)'Old)
and not P.Has_Key (Positions (Container), Position'Old)
-- Other mappings are preserved
and Model (Container) <= Model (Container)'Old
and M.Keys_Included_Except
(Model (Container)'Old,
Model (Container),
Key (Container, Position)'Old)
-- The keys of Container located before Position are preserved.
and K.Range_Equal
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => 1,
Lst => P.Get (Positions (Container)'Old, Position'Old) - 1)
-- The keys located after Position are shifted by 1
and K.Range_Shifted
(Left => Keys (Container),
Right => Keys (Container)'Old,
Fst => P.Get (Positions (Container)'Old, Position'Old),
Lst => Length (Container),
Offset => 1)
-- Position has been removed from Container
and P_Positions_Shifted
(Positions (Container),
Positions (Container)'Old,
Cut => P.Get (Positions (Container)'Old, Position'Old));
procedure Delete_First (Container : in out Map) with
Global => null,
Contract_Cases =>
(Length (Container) = 0 => Length (Container) = 0,
others =>
Length (Container) = Length (Container)'Old - 1
-- The first key has been removed from Container
and not Contains (Container, First_Key (Container)'Old)
-- Other mappings are preserved
and Model (Container) <= Model (Container)'Old
and M.Keys_Included_Except
(Model (Container)'Old,
Model (Container),
First_Key (Container)'Old)
-- Other keys are shifted by 1
and K.Range_Shifted
(Left => Keys (Container),
Right => Keys (Container)'Old,
Fst => 1,
Lst => Length (Container),
Offset => 1)
-- First has been removed from Container
and P_Positions_Shifted
(Positions (Container),
Positions (Container)'Old,
Cut => 1));
procedure Delete_Last (Container : in out Map) with
Global => null,
Contract_Cases =>
(Length (Container) = 0 => Length (Container) = 0,
others =>
Length (Container) = Length (Container)'Old - 1
-- The last key has been removed from Container
and not Contains (Container, Last_Key (Container)'Old)
-- Other mappings are preserved
and Model (Container) <= Model (Container)'Old
and M.Keys_Included_Except
(Model (Container)'Old,
Model (Container),
Last_Key (Container)'Old)
-- Others keys of Container are preserved
and K.Range_Equal
(Left => Keys (Container)'Old,
Right => Keys (Container),
Fst => 1,
Lst => Length (Container))
-- Last cursor has been removed from Container
and Positions (Container) <= Positions (Container)'Old);
function First (Container : Map) return Cursor with
Global => null,
Contract_Cases =>
(Length (Container) = 0 =>
First'Result = No_Element,
others =>
Has_Element (Container, First'Result)
and P.Get (Positions (Container), First'Result) = 1);
function First_Element (Container : Map) return Element_Type with
Global => null,
Pre => not Is_Empty (Container),
Post =>
First_Element'Result =
Element (Model (Container), First_Key (Container));
function First_Key (Container : Map) return Key_Type with
Global => null,
Pre => not Is_Empty (Container),
Post =>
First_Key'Result = K.Get (Keys (Container), 1)
and K_Smaller_Than_Range
(Keys (Container), 2, Length (Container), First_Key'Result);
function Last (Container : Map) return Cursor with
Global => null,
Contract_Cases =>
(Length (Container) = 0 =>
Last'Result = No_Element,
others =>
Has_Element (Container, Last'Result)
and P.Get (Positions (Container), Last'Result) =
Length (Container));
function Last_Element (Container : Map) return Element_Type with
Global => null,
Pre => not Is_Empty (Container),
Post =>
Last_Element'Result = Element (Model (Container), Last_Key (Container));
function Last_Key (Container : Map) return Key_Type with
Global => null,
Pre => not Is_Empty (Container),
Post =>
Last_Key'Result = K.Get (Keys (Container), Length (Container))
and K_Bigger_Than_Range
(Keys (Container), 1, Length (Container) - 1, Last_Key'Result);
function Next (Container : Map; Position : Cursor) return Cursor with
Global => null,
Pre =>
Has_Element (Container, Position) or else Position = No_Element,
Contract_Cases =>
(Position = No_Element
or else P.Get (Positions (Container), Position) = Length (Container)
=>
Next'Result = No_Element,
others =>
Has_Element (Container, Next'Result)
and then P.Get (Positions (Container), Next'Result) =
P.Get (Positions (Container), Position) + 1);
procedure Next (Container : Map; Position : in out Cursor) with
Global => null,
Pre =>
Has_Element (Container, Position) or else Position = No_Element,
Contract_Cases =>
(Position = No_Element
or else P.Get (Positions (Container), Position) = Length (Container)
=>
Position = No_Element,
others =>
Has_Element (Container, Position)
and then P.Get (Positions (Container), Position) =
P.Get (Positions (Container), Position'Old) + 1);
function Previous (Container : Map; Position : Cursor) return Cursor with
Global => null,
Pre =>
Has_Element (Container, Position) or else Position = No_Element,
Contract_Cases =>
(Position = No_Element
or else P.Get (Positions (Container), Position) = 1
=>
Previous'Result = No_Element,
others =>
Has_Element (Container, Previous'Result)
and then P.Get (Positions (Container), Previous'Result) =
P.Get (Positions (Container), Position) - 1);
procedure Previous (Container : Map; Position : in out Cursor) with
Global => null,
Pre =>
Has_Element (Container, Position) or else Position = No_Element,
Contract_Cases =>
(Position = No_Element
or else P.Get (Positions (Container), Position) = 1
=>
Position = No_Element,
others =>
Has_Element (Container, Position)
and then P.Get (Positions (Container), Position) =
P.Get (Positions (Container), Position'Old) - 1);
function Find (Container : Map; Key : Key_Type) return Cursor with
Global => null,
Contract_Cases =>
-- If Key is not contained in Container, Find returns No_Element
(not Contains (Model (Container), Key) =>
not P.Has_Key (Positions (Container), Find'Result)
and Find'Result = No_Element,
-- Otherwise, Find returns a valid cursor in Container
others =>
P.Has_Key (Positions (Container), Find'Result)
and P.Get (Positions (Container), Find'Result) =
Find (Keys (Container), Key)
-- The key designated by the result of Find is Key
and Equivalent_Keys
(Formal_Ordered_Maps.Key (Container, Find'Result), Key));
function Element (Container : Map; Key : Key_Type) return Element_Type with
Global => null,
Pre => Contains (Container, Key),
Post => Element'Result = Element (Model (Container), Key);
pragma Annotate (GNATprove, Inline_For_Proof, Element);
function Floor (Container : Map; Key : Key_Type) return Cursor with
Global => null,
Contract_Cases =>
(Length (Container) = 0 or else Key < First_Key (Container) =>
Floor'Result = No_Element,
others =>
Has_Element (Container, Floor'Result)
and not (Key < K.Get (Keys (Container),
P.Get (Positions (Container), Floor'Result)))
and K_Is_Find
(Keys (Container),
Key,
P.Get (Positions (Container), Floor'Result)));
function Ceiling (Container : Map; Key : Key_Type) return Cursor with
Global => null,
Contract_Cases =>
(Length (Container) = 0 or else Last_Key (Container) < Key =>
Ceiling'Result = No_Element,
others =>
Has_Element (Container, Ceiling'Result)
and not (K.Get
(Keys (Container),
P.Get (Positions (Container), Ceiling'Result)) < Key)
and K_Is_Find
(Keys (Container),
Key,
P.Get (Positions (Container), Ceiling'Result)));
function Contains (Container : Map; Key : Key_Type) return Boolean with
Global => null,
Post => Contains'Result = Contains (Model (Container), Key);
pragma Annotate (GNATprove, Inline_For_Proof, Contains);
function Has_Element (Container : Map; Position : Cursor) return Boolean
with
Global => null,
Post =>
Has_Element'Result = P.Has_Key (Positions (Container), Position);
pragma Annotate (GNATprove, Inline_For_Proof, Has_Element);
private
pragma SPARK_Mode (Off);
pragma Inline (Next);
pragma Inline (Previous);
subtype Node_Access is Count_Type;
use Red_Black_Trees;
type Node_Type is record
Has_Element : Boolean := False;
Parent : Node_Access := 0;
Left : Node_Access := 0;
Right : Node_Access := 0;
Color : Red_Black_Trees.Color_Type := Red;
Key : Key_Type;
Element : aliased Element_Type;
end record;
package Tree_Types is
new Ada.Containers.Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type);
type Map (Capacity : Count_Type) is record
Content : Tree_Types.Tree_Type (Capacity);
end record;
Empty_Map : constant Map := (Capacity => 0, others => <>);
end Ada.Containers.Formal_Ordered_Maps;
|
reznikmm/matreshka | Ada | 5,417 | 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.
------------------------------------------------------------------------------
-- WriteStructuralFeatureAction is an abstract class for structural feature
-- actions that change structural feature values.
------------------------------------------------------------------------------
limited with AMF.UML.Input_Pins;
limited with AMF.UML.Output_Pins;
with AMF.UML.Structural_Feature_Actions;
package AMF.UML.Write_Structural_Feature_Actions is
pragma Preelaborate;
type UML_Write_Structural_Feature_Action is limited interface
and AMF.UML.Structural_Feature_Actions.UML_Structural_Feature_Action;
type UML_Write_Structural_Feature_Action_Access is
access all UML_Write_Structural_Feature_Action'Class;
for UML_Write_Structural_Feature_Action_Access'Storage_Size use 0;
not overriding function Get_Result
(Self : not null access constant UML_Write_Structural_Feature_Action)
return AMF.UML.Output_Pins.UML_Output_Pin_Access is abstract;
-- Getter of WriteStructuralFeatureAction::result.
--
-- Gives the output pin on which the result is put.
not overriding procedure Set_Result
(Self : not null access UML_Write_Structural_Feature_Action;
To : AMF.UML.Output_Pins.UML_Output_Pin_Access) is abstract;
-- Setter of WriteStructuralFeatureAction::result.
--
-- Gives the output pin on which the result is put.
not overriding function Get_Value
(Self : not null access constant UML_Write_Structural_Feature_Action)
return AMF.UML.Input_Pins.UML_Input_Pin_Access is abstract;
-- Getter of WriteStructuralFeatureAction::value.
--
-- Value to be added or removed from the structural feature.
not overriding procedure Set_Value
(Self : not null access UML_Write_Structural_Feature_Action;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is abstract;
-- Setter of WriteStructuralFeatureAction::value.
--
-- Value to be added or removed from the structural feature.
end AMF.UML.Write_Structural_Feature_Actions;
|
MinimSecure/unum-sdk | Ada | 950 | adb | -- Copyright 2014-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
-- The goal here is to have an array whose bounds are not
-- known at compile time.
BT : Bounded := New_Bounded (Low => 1, High => 3);
begin
Do_Nothing (BT'Address); -- STOP
end Foo;
|
stcarrez/dynamo | Ada | 197 | ads | -- part of ParserTools, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package Lexer is
pragma Pure;
Lexer_Error : exception;
end Lexer;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.