repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 3,749 | 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_Direction_Attributes is
pragma Preelaborate;
type ODF_Presentation_Direction_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Presentation_Direction_Attribute_Access is
access all ODF_Presentation_Direction_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Presentation_Direction_Attributes;
|
persan/AdaYaml | Ada | 690 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Yaml.Dom.Vectors;
with Yaml.Events.Queue;
with Yaml.Destination;
package Yaml.Dom.Dumping is
function To_Event_Queue (Document : Document_Reference)
return Events.Queue.Reference;
function To_Event_Queue (Documents : Vectors.Vector)
return Events.Queue.Reference;
procedure Dump (Document : Document_Reference;
Output : not null Destination.Pointer);
procedure Dump (Documents : Vectors.Vector;
Output : not null Destination.Pointer);
end Yaml.Dom.Dumping;
|
AdaCore/training_material | Ada | 455 | ads | with System.Storage_Elements;
package Alarm is
type Alarm_Status is (On, Off);
function Get_Temperature return Integer;
function Get_Status return Alarm_Status;
procedure Set_Status;
private
Temperature : Integer with
Address => System.Storage_Elements.To_Address (16#FFFF_FFF0#),
Volatile;
Status : Alarm_Status := Off with
Address => System.Storage_Elements.To_Address (16#FFFF_FFF4#),
Volatile;
end Alarm;
|
PThierry/ewok-kernel | Ada | 24 | adb | ../stm32f439/soc-rng.adb |
AdaCore/gpr | Ada | 14,483 | ads | --
-- Copyright (C) 2019-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Unchecked_Deallocation;
with Gpr_Parser_Support.Adalog.Solver_Interface;
with Gpr_Parser_Support.Vectors;
generic
with package Solver_Ifc
is new Gpr_Parser_Support.Adalog.Solver_Interface (<>);
package Gpr_Parser_Support.Adalog.Solver is
use Solver_Ifc;
use Logic_Vars;
type Relation_Type (<>) is private;
type Relation is access all Relation_Type;
-- Type for a relation. A relation is either an atomic relation, or a
-- compound relation, which can represent a tree of relations of unbounded
-- depth. Solving a relation will assign values to every logic variable
-- involved in the relation or fail.
--
-- A relation is manually ref-counted, and has an ownership share of every
-- sub-relation. When the ref-count of a root relation, reaches 0, the
-- ownership share of each of its sub-relations is destroyed.
No_Relation : constant Relation := null;
procedure Inc_Ref (Self : Relation);
-- Increment the reference count of Self
procedure Dec_Ref (Self : in out Relation);
-- Decrement the reference count of Self. If no reference is left,
-- deallocate ``Self.all`` and set ``Self`` to ``null``.
procedure Solve
(Self : Relation;
Solution_Callback : access function
(Vars : Logic_Var_Array) return Boolean;
Solve_Options : Solve_Options_Type := Default_Options;
Timeout : Natural := 0);
-- Run the solver on the ``Self`` relation. For every solution found, call
-- ``Solution_Callback`` with the variables involved in ``Self``, and
-- continue looking for other solutions iff it returns True. See
-- ``Solve_Options Type`` for the available way to configure the resolution
-- process.
--
-- ``Timeout`` determines the maximum of times we evaluate atoms before
-- aborting the solver. If left to 0, no timeout applies.
function Solve_First
(Self : Relation;
Solve_Options : Solve_Options_Type := Default_Options;
Timeout : Natural := 0) return Boolean;
-- Run the solver on the ``Self`` relation. Return whether there is at
-- least one valid solution. See ``Solve_Options Type`` for the available
-- way to configure the resolution process.
--
-- ``Timeout`` determines the maximum of times we evaluate atoms before
-- aborting the solver. If left to 0, no timeout applies.
function Image (Self : Relation) return String;
-- Return a textual representation of ``Self`` as a multi-line string
---------------------------
-- Relation constructors --
---------------------------
package Relation_Vectors is new Gpr_Parser_Support.Vectors
(Relation, Small_Vector_Capacity => 16);
subtype Relation_Array is Relation_Vectors.Elements_Array;
No_Relation_Array : Relation_Array renames Relation_Vectors.Empty_Array;
-- In all constructor functions below, ``Debug_String`` is an optional
-- string attached to the returned relation, to be used in the result of
-- the ``Image`` function. Relations do not manage their lifetimes: it is
-- up to users to free them when appropriate.
function Create_Predicate
(Logic_Var : Logic_Vars.Logic_Var;
Pred : Predicate_Type'Class;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully when calling ``Pred`` on
-- the value of ``Logic_Var`` returns ``True``.
function Create_N_Predicate
(Logic_Vars : Logic_Var_Array;
Pred : N_Predicate_Type'Class;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully when calling ``Pred`` on
-- the values of all variables in ``Logic_Vars`` returns ``True``.
function Create_Assign
(Logic_Var : Logic_Vars.Logic_Var;
Value : Value_Type;
Conv : Converter_Type'Class := No_Converter;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully if it is possible to
-- assign the given ``Value`` to ``Logic_Var``. Two attempts to assign
-- different values to the same logic variable will make the relation
-- always fail.
--
-- If ``Conv`` is provided, the actually assigned value is the result of
-- ``Conv`` when called on ``Value``.
function Create_Unify
(Left, Right : Logic_Vars.Logic_Var;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully if ``Left`` and ``Right``
-- can be assigned the same value.
function Create_Propagate
(From, To : Logic_Vars.Logic_Var;
Conv : Converter_Type'Class := No_Converter;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully if it is possible to
-- assign the value in ``From`` to the ``To`` variable.
--
-- If ``Conv`` is provided, the actually assigned value is the result of
-- ``Conv`` when called on ``From``'s value.
function Create_N_Propagate
(To : Logic_Var;
Comb : Combiner_Type'Class;
Logic_Vars : Logic_Var_Array;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully if it is possible to
-- assign to ``To`` the value computed by calling ``Comb`` on the given
-- ``Logic_Vars``.
function Create_Domain
(Logic_Var : Logic_Vars.Logic_Var;
Domain : Value_Array;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully if it is possible to
-- assign one value in ``Domain`` to ``Logic_Var``.
--
-- This is a shortcut: ``Domain (Var, (A, B, ...))`` is equivalent to
-- ``Any (Assign (Var, A), Assign (Var, B), ...)``.
function Create_Any
(Relations : Relation_Array;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully when at least one of the
-- the relations in ``Relations`` solves successfully.
function Create_All
(Relations : Relation_Array;
Debug_String : String_Access := null) return Relation;
-- Create a relation that will solve successfully when all of the
-- relations in ``Relations`` solve successfully.
function Create_Or
(L, R : Relation;
Debug_String : String_Access := null) return Relation
is (Create_Any ((L, R), Debug_String));
function Create_And
(L, R : Relation;
Debug_String : String_Access := null) return Relation
is (Create_All ((L, R), Debug_String));
function Create_True (Debug_String : String_Access := null) return Relation;
-- Return a relation that always solves successfully
function Create_False
(Debug_String : String_Access := null) return Relation;
-- Return a relation that never solves successfully
private
type Converter_Access is access all Converter_Type'Class;
type Combiner_Access is access all Combiner_Type'Class;
type Predicate_Access is access all Predicate_Type'Class;
type N_Predicate_Access is access all N_Predicate_Type'Class;
procedure Free is new Ada.Unchecked_Deallocation
(Converter_Type'Class, Converter_Access);
procedure Free is new Ada.Unchecked_Deallocation
(Combiner_Type'Class, Combiner_Access);
procedure Free is new Ada.Unchecked_Deallocation
(Predicate_Type'Class, Predicate_Access);
procedure Free is new Ada.Unchecked_Deallocation
(N_Predicate_Type'Class, N_Predicate_Access);
package Logic_Var_Vectors is new Gpr_Parser_Support.Vectors (Logic_Var);
subtype Logic_Var_Vector is Logic_Var_Vectors.Vector;
type Logic_Var_Vector_Access is access Logic_Var_Vector;
---------------------
-- Atomic_Relation --
---------------------
type Atomic_Kind is (Propagate, N_Propagate, Unify, Assign, Predicate,
N_Predicate, True, False);
type Atomic_Relation_Type (Kind : Atomic_Kind := Propagate) is record
Target : Logic_Var;
-- What is the Target and whether it is considered as a "used" or
-- "defined" logic variable depends on the kind of relation. See the
-- "Atomic relations dependency graph" section for more information.
case Kind is
when Assign | Propagate =>
Conv : Converter_Access := null;
-- Conversion function for the value to assign/propagate. If left
-- to null, use the value itself.
case Kind is
when Assign =>
Val : Value_Type;
-- The value we want to assign to ``Target``
when Propagate =>
From : Logic_Var;
-- The variable from which we want to propagate to
-- ``Target``.
when others => null;
end case;
when N_Propagate =>
Comb_Vars : Logic_Var_Vector;
-- List of logic variables used by the converter
Comb : Combiner_Access;
-- Combiner function to assign a value to Target that is computed
-- from the value of N_Propagate_Vars.
when Predicate =>
Pred : Predicate_Access;
-- The predicate that will be applied as part of this relation
when N_Predicate =>
Vars : Logic_Var_Vector;
-- List of logic variables used by the predicate
N_Pred : N_Predicate_Access;
-- The predicate that will be applied as part of this relation
when Unify =>
Unify_From : Logic_Var;
when True | False =>
null;
end case;
end record;
-- An atomic relation is a relation that has no children. When we get to
-- solve a specific solution, we expect to have a set of only atomic
-- relations.
--
-- Atomic relations can be either ``Assign``, ``Propagate, or
-- ``Predicate``. Their semantics are defined in the corresponding public
-- relation constructors.
function Image (Self : Atomic_Relation_Type) return String;
-- Helper for the ``Image`` primitive of ``Relation``
procedure Destroy (Self : in out Atomic_Relation_Type);
-- Destroy this atomic relation
----------------------------------------
-- Atomic relations dependency graph --
----------------------------------------
-- This section defines operations to explore the dependency graph between
-- atomic relations. They are used to:
--
-- 1. Sort a list of atomic relations topologically, so that they form an
-- executable sequence of instructions.
--
-- 2. Define a map from vars to atomic rels where for every logic variable
-- ``V``, the map maps ``V -> [R1, R2, R3, ...]`` where
-- ``Used_Var (Rn) = V``. This map will allow us to cut some branches of
-- the solution tree early.
--
-- To compute dependencies, we consider for each relation which variable it
-- defines (sets a value: see the ``Defined_Var`` function below) or which
-- variable it uses (copies/checks the value associated to this variable:
-- see the ``Used_Var`` below).
--
-- TODO??? Some relations actually use multiple logic variables
-- (N_Predicate), while Unify does not really use/define any, but actually
-- treats both variables as aliases. This dataflow analysis probably
-- deserves a refactoring to clarify this.
function Is_Defined_Or_Null (Var : Logic_Var) return Boolean
is
(Var = null or else Is_Defined (Var));
-- Shortcut predicate. Returns whether a variable is defined or is null
function Defined_Var (Self : Atomic_Relation_Type) return Logic_Var;
-- Return the variable that this atomic relation defines, if there is one
-----------------------
-- Compound relation --
-----------------------
type Compound_Kind is (Kind_All, Kind_Any);
type Compound_Relation_Type is record
Kind : Compound_Kind;
Rels : Relation_Vectors.Vector;
end record;
procedure Destroy (Self : in out Compound_Relation_Type);
--------------
-- Relation --
--------------
type Relation_Kind is (Atomic, Compound);
type Relation_Type (Kind : Relation_Kind) is record
Ref_Count : Natural;
-- Number of ownership shares for this relation. When it drops to zero,
-- it must be deallocated.
Id : Natural;
-- Id for this relation, for debugging purposes: dealing with small
-- integers is much easier for humans than dealing with addresses, or
-- even with relation images when one wants to quickly know if two
-- relations are the same in the logs.
--
-- Ids are assigned right before starting relation
-- simplification/solving, and are as much as possible propagated when
-- creating a new relation to replace a previous one.
--
-- 0 means "Id unassigned".
Debug_Info : Ada.Strings.Unbounded.String_Access := null;
case Kind is
when Atomic => Atomic_Rel : Atomic_Relation_Type;
when Compound => Compound_Rel : Compound_Relation_Type;
end case;
end record;
procedure Destroy (Self : Relation);
-- TODO??? Use predicates once the GNAT bug is fixed.
--
-- .. code::
--
-- subtype Atomic_Relation is Relation
-- with Predicate => Atomic_Relation = null
-- or else Atomic_Relation.Kind = Atomic;
--
-- subtype Compound_Relation is Relation
-- with Predicate => Compound_Relation = null
-- or else Compound_Relation.Kind = Compound;
--
-- subtype Any_Rel is Compound_Relation
-- with Predicate => Any_Rel.Compound_Rel.Kind = Kind_Any;
subtype Atomic_Relation is Relation;
subtype Compound_Relation is Relation;
subtype Any_Rel is Relation;
function Solve_Atomic (Self : Atomic_Relation) return Boolean;
-- Solve this atomic relation, return if we have found a valid solution.
-- Note that this assumes that all "input" logic variables in Self are
-- already defined.
end Gpr_Parser_Support.Adalog.Solver;
|
MinimSecure/unum-sdk | Ada | 887 | adb | -- Copyright 2008-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 Types; use Types;
procedure Foo is
R : Rectangle := (1, 2, 3, 4);
S : Object'Class := Ident (R);
begin
Do_Nothing (R); -- STOP
Do_Nothing (S);
end Foo;
|
HeisenbugLtd/open_weather_map_api | Ada | 2,394 | 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 GNATCOLL.JSON.Conversions;
package body Open_Weather_Map.API.Service.Utilities is
My_Debug : constant not null GNATCOLL.Traces.Trace_Handle :=
GNATCOLL.Traces.Create (Unit_Name => "OWM.API.SERVICE.UTILITIES");
package Field_Names is
package Coordinates is
Latitude : constant String := "lat";
Longitude : constant String := "lon";
end Coordinates;
end Field_Names;
-----------------------------------------------------------------------------
-- Decode_Coordinates
-----------------------------------------------------------------------------
function Decode_Coordinates
(Coordinates : in GNATCOLL.JSON.JSON_Value) return Geo_Coordinates
is
package Conversions renames GNATCOLL.JSON.Conversions;
begin
My_Debug.all.Trace (Message => "Decode_Coordinates");
return
Geo_Coordinates'(Latitude =>
Conversions.To_Latitude
(Value => Coordinates,
Field => Field_Names.Coordinates.Latitude),
Longitude =>
Conversions.To_Longitude
(Value => Coordinates,
Field => Field_Names.Coordinates.Longitude));
end Decode_Coordinates;
-----------------------------------------------------------------------------
-- Has_Coord_Fields
-----------------------------------------------------------------------------
function Has_Coord_Fields
(Coordinates : in GNATCOLL.JSON.JSON_Value) return Boolean is
begin
My_Debug.all.Trace (Message => "Has_Coord_Fields");
return
Coordinates.Has_Field (Field => Field_Names.Coordinates.Latitude) and then
Coordinates.Has_Field (Field => Field_Names.Coordinates.Longitude);
end Has_Coord_Fields;
end Open_Weather_Map.API.Service.Utilities;
|
charlie5/cBound | Ada | 1,534 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_intern_atom_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;
atom : aliased xcb.xcb_atom_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_intern_atom_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_intern_atom_reply_t.Item,
Element_Array => xcb.xcb_intern_atom_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_intern_atom_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_intern_atom_reply_t.Pointer,
Element_Array => xcb.xcb_intern_atom_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_intern_atom_reply_t;
|
zhmu/ananas | Ada | 6,276 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . V A L _ W C H A R --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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 Interfaces; use Interfaces;
with System.Val_Util; use System.Val_Util;
with System.WCh_Cnv; use System.WCh_Cnv;
with System.WCh_Con; use System.WCh_Con;
package body System.Val_WChar is
--------------------------
-- Value_Wide_Character --
--------------------------
function Value_Wide_Character
(Str : String;
EM : System.WCh_Con.WC_Encoding_Method) return Wide_Character
is
WC : constant Wide_Wide_Character := Value_Wide_Wide_Character (Str, EM);
WV : constant Unsigned_32 := Wide_Wide_Character'Pos (WC);
begin
if WV > 16#FFFF# then
Bad_Value (Str);
else
return Wide_Character'Val (WV);
end if;
end Value_Wide_Character;
-------------------------------
-- Value_Wide_Wide_Character --
-------------------------------
function Value_Wide_Wide_Character
(Str : String;
EM : System.WCh_Con.WC_Encoding_Method) return Wide_Wide_Character
is
F : Natural;
L : Natural;
S : String (Str'Range) := Str;
begin
Normalize_String (S, F, L);
-- Character literal case
if S (F) = ''' and then S (L) = ''' then
-- Must be at least three characters
if L - F < 2 then
Bad_Value (Str);
-- If just three characters, simple character case
elsif L - F = 2 then
return Wide_Wide_Character'Val (Character'Pos (S (F + 1)));
-- Only other possibility for quoted string is wide char sequence
else
declare
P : Natural;
W : Wide_Wide_Character;
function In_Char return Character;
-- Function for instantiations of Char_Sequence_To_UTF_32
-------------
-- In_Char --
-------------
function In_Char return Character is
begin
P := P + 1;
if P = Str'Last then
Bad_Value (Str);
end if;
return Str (P);
end In_Char;
function UTF_32 is
new Char_Sequence_To_UTF_32 (In_Char);
begin
P := F + 1;
-- Brackets encoding
if S (F + 1) = '[' then
W := Wide_Wide_Character'Val (UTF_32 ('[', WCEM_Brackets));
else
W := Wide_Wide_Character'Val (UTF_32 (S (F + 1), EM));
end if;
if P /= L - 1 then
Bad_Value (Str);
end if;
return W;
end;
end if;
-- Deal with Hex_hhhhhhhh cases for wide_[wide_]character cases
elsif Str'Length = 12
and then Str (Str'First .. Str'First + 3) = "Hex_"
then
declare
W : Unsigned_32 := 0;
begin
for J in Str'First + 4 .. Str'First + 11 loop
W := W * 16 + Character'Pos (Str (J));
if Str (J) in '0' .. '9' then
W := W - Character'Pos ('0');
elsif Str (J) in 'A' .. 'F' then
W := W - Character'Pos ('A') + 10;
elsif Str (J) in 'a' .. 'f' then
W := W - Character'Pos ('a') + 10;
else
Bad_Value (Str);
end if;
end loop;
if W > 16#7FFF_FFFF# then
Bad_Value (Str);
else
return Wide_Wide_Character'Val (W);
end if;
end;
-- Otherwise must be one of the special names for Character
else
return
Wide_Wide_Character'Val (Character'Pos (Character'Value (Str)));
end if;
exception
when Constraint_Error =>
Bad_Value (Str);
end Value_Wide_Wide_Character;
end System.Val_WChar;
|
charlie5/cBound | Ada | 357 | adb |
with
TensorFlow_C.Binding,
interfaces.C.Strings,
ada.Text_IO;
procedure hello_TF
is
use Ada.Text_IO,
Interfaces,
interfaces.C,
Interfaces.C.Strings,
Tensorflow_C.Binding;
Version : String := Value (TF_Version);
begin
put_Line ("Hello Tensorflow.");
put_Line ("Version: " & Version);
end hello_TF; |
chinaofmelon/Loli3 | Ada | 3,391 | adb | M:main
F:G$Delay1ms$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$delay_ms$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$EEPROM_read$0_0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$EEPROM_write$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$EEPROM_clean$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Data_change$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$DATA_read1$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$DATA_save1$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Model_data_reset$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Model_adress$0_0$0({2}DF,SI:U),C,0,0,0,0,0
F:G$DATA_read2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$DATA_save2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$SPI$0_0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$REG_write$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$REG_read$0_0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$FIFO_write$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$FIFO_write2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$FIFO_read$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$FIFO_read2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$TX_address$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$RX_address$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$RX_mode$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$TX_mode$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$NRF_power$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$NRF_size$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$NRF_channel$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$NRF_init$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$NRF_test$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$device_connect$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$LCD$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$location$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$LCD_ON$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$LCD_OFF$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$LCD_clean$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$LCD_init$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$send$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$send2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$send2_rev$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$send2_hex$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$send3$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$write$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$write0$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$photo$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_trim1$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_trim2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_throttle$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$warning$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$write_num100$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$write_num1000$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$move_cursor$0_0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$displayModel$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_menu$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_mapping$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_receiver_mode$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_switch$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_bar$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$point$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_curve$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$display_curve2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Xdata_check$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$rounding$0_0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$get_curve$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$get_curve2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$function_size$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$function_inverted$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$function_mix$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$function_curve$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$function_curve2$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$function_mapping$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$change_trim$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$CH_calib$0_0$0({2}DF,SI:S),C,0,0,0,0,0
F:G$function_filter$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Switch_Check$0_0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$UartInit$0_0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$initial$0_0$0({2}DF,SV:S),C,0,0,0,0,0
|
clairvoyant/anagram | Ada | 485 | ads | -- Copyright (c) 2010-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Anagram.Grammars;
with Anagram.Grammars.LR_Tables;
package Anagram.Grammars_Debug is
procedure Print (Self : Anagram.Grammars.Grammar);
procedure Print_Conflicts
(Self : Anagram.Grammars.Grammar;
Table : Anagram.Grammars.LR_Tables.Table);
end Anagram.Grammars_Debug;
|
MinimSecure/unum-sdk | Ada | 997 | adb | -- Copyright 2011-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Dn; use Dn;
package body Pck is
procedure Hello is
procedure Nested is
I : Integer := 0;
begin
Do_Nothing (I'Address);
end Nested;
begin
Nested;
end Hello;
procedure There is
begin
null;
end There;
end Pck;
|
stcarrez/ada-util | Ada | 13,330 | adb | -----------------------------------------------------------------------
-- util-http-clients -- HTTP Clients
-- Copyright (C) 2011, 2012, 2013, 2017, 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Log.Loggers;
package body Util.Http.Clients is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Http.Clients");
procedure Initialize (Form : in out Form_Data;
Size : in Positive) is
begin
Form.Buffer.Initialize (Output => null,
Size => Size);
Form.Initialize (Form.Buffer'Unchecked_Access);
end Initialize;
-- ------------------------------
-- Returns a boolean indicating whether the named response header has already
-- been set.
-- ------------------------------
overriding
function Contains_Header (Reply : in Response;
Name : in String) return Boolean is
begin
if Reply.Delegate = null then
return False;
else
return Reply.Delegate.Contains_Header (Name);
end if;
end Contains_Header;
-- ------------------------------
-- Returns the value of the specified response header as a String. If the response
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
-- ------------------------------
overriding
function Get_Header (Reply : in Response;
Name : in String) return String is
begin
if Reply.Delegate = null then
return "";
else
return Reply.Delegate.Get_Header (Name);
end if;
end Get_Header;
-- ------------------------------
-- Sets a message header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
-- ------------------------------
overriding
procedure Set_Header (Reply : in out Response;
Name : in String;
Value : in String) is
begin
Reply.Delegate.Set_Header (Name, Value);
end Set_Header;
-- ------------------------------
-- Adds a request header with the given name and value.
-- This method allows request headers to have multiple values.
-- ------------------------------
overriding
procedure Add_Header (Reply : in out Response;
Name : in String;
Value : in String) is
begin
Reply.Delegate.Add_Header (Name, Value);
end Add_Header;
-- ------------------------------
-- Iterate over the response headers and executes the <b>Process</b> procedure.
-- ------------------------------
overriding
procedure Iterate_Headers (Reply : in Response;
Process : not null access
procedure (Name : in String;
Value : in String)) is
begin
if Reply.Delegate /= null then
Reply.Delegate.Iterate_Headers (Process);
end if;
end Iterate_Headers;
-- ------------------------------
-- Get the response body as a string.
-- ------------------------------
overriding
function Get_Body (Reply : in Response) return String is
begin
if Reply.Delegate = null then
return "";
else
return Reply.Delegate.Get_Body;
end if;
end Get_Body;
overriding
function Get_Body (Reply : in Response) return Util.Blobs.Blob_Ref is
begin
if Reply.Delegate = null then
return Util.Blobs.Null_Blob;
else
return Reply.Delegate.Get_Body;
end if;
end Get_Body;
-- ------------------------------
-- Get the response status code.
-- ------------------------------
overriding
function Get_Status (Reply : in Response) return Natural is
begin
return Reply.Delegate.Get_Status;
end Get_Status;
-- ------------------------------
-- Returns a boolean indicating whether the named response header has already
-- been set.
-- ------------------------------
overriding
function Contains_Header (Request : in Client;
Name : in String) return Boolean is
begin
if Request.Delegate = null then
return False;
else
return Request.Delegate.Contains_Header (Name);
end if;
end Contains_Header;
-- ------------------------------
-- Returns the value of the specified request header as a String. If the request
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
-- ------------------------------
overriding
function Get_Header (Request : in Client;
Name : in String) return String is
begin
if Request.Delegate = null then
return "";
else
return Request.Delegate.Get_Header (Name);
end if;
end Get_Header;
-- ------------------------------
-- Sets a header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
-- ------------------------------
overriding
procedure Set_Header (Request : in out Client;
Name : in String;
Value : in String) is
begin
Request.Delegate.Set_Header (Name, Value);
end Set_Header;
-- ------------------------------
-- Adds a header with the given name and value.
-- This method allows headers to have multiple values.
-- ------------------------------
overriding
procedure Add_Header (Request : in out Client;
Name : in String;
Value : in String) is
begin
Request.Delegate.Add_Header (Name, Value);
end Add_Header;
-- ------------------------------
-- Iterate over the request headers and executes the <b>Process</b> procedure.
-- ------------------------------
overriding
procedure Iterate_Headers (Request : in Client;
Process : not null access
procedure (Name : in String;
Value : in String)) is
begin
Request.Delegate.Iterate_Headers (Process);
end Iterate_Headers;
-- ------------------------------
-- Removes all headers with the given name.
-- ------------------------------
procedure Remove_Header (Request : in out Client;
Name : in String) is
begin
null;
end Remove_Header;
-- ------------------------------
-- Initialize the client
-- ------------------------------
overriding
procedure Initialize (Http : in out Client) is
begin
Http.Delegate := null;
Http.Manager := Default_Http_Manager;
if Http.Manager = null then
Log.Error ("No HTTP manager was defined");
raise Program_Error with "No HTTP manager was defined.";
end if;
Http.Manager.Create (Http);
end Initialize;
overriding
procedure Finalize (Http : in out Client) is
procedure Free is new Ada.Unchecked_Deallocation (Http_Request'Class,
Http_Request_Access);
begin
Free (Http.Delegate);
end Finalize;
-- ------------------------------
-- Execute an http GET request on the given URL. Additional request parameters,
-- cookies and headers should have been set on the client object.
-- ------------------------------
procedure Get (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Get (Request, URL, Reply);
end Get;
-- ------------------------------
-- Execute an http POST request on the given URL. The post data is passed in <b>Data</b>.
-- Additional request cookies and headers should have been set on the client object.
-- ------------------------------
procedure Post (Request : in out Client;
URL : in String;
Data : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Post (Request, URL, Data, Reply);
end Post;
procedure Post (Request : in out Client;
URL : in String;
Data : in Form_Data'Class;
Reply : out Response'Class) is
begin
Request.Manager.Do_Post (Request, URL, Util.Streams.Texts.To_String (Data.Buffer), Reply);
end Post;
-- ------------------------------
-- Execute an http PUT request on the given URL. The post data is passed in <b>Data</b>.
-- Additional request cookies and headers should have been set on the client object.
-- ------------------------------
procedure Put (Request : in out Client;
URL : in String;
Data : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Put (Request, URL, Data, Reply);
end Put;
-- ------------------------------
-- Execute an http PATCH request on the given URL. The post data is passed in <b>Data</b>.
-- Additional request cookies and headers should have been set on the client object.
-- ------------------------------
procedure Patch (Request : in out Client;
URL : in String;
Data : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Patch (Request, URL, Data, Reply);
end Patch;
-- ------------------------------
-- Execute a http DELETE request on the given URL.
-- ------------------------------
procedure Delete (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Delete (Request, URL, Reply);
end Delete;
-- ------------------------------
-- Execute an http HEAD request on the given URL. Additional request parameters,
-- cookies and headers should have been set on the client object.
-- ------------------------------
procedure Head (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Head (Request, URL, Reply);
end Head;
-- ------------------------------
-- Execute an http OPTIONS request on the given URL. Additional request parameters,
-- cookies and headers should have been set on the client object.
-- ------------------------------
procedure Options (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Options (Request, URL, Reply);
end Options;
-- ------------------------------
-- Set the timeout for the connection.
-- ------------------------------
procedure Set_Timeout (Request : in out Client;
Timeout : in Duration) is
begin
Request.Manager.Set_Timeout (Request, Timeout);
end Set_Timeout;
-- ------------------------------
-- Adds the specified cookie to the request. This method can be called multiple
-- times to set more than one cookie.
-- ------------------------------
procedure Add_Cookie (Http : in out Client;
Cookie : in Util.Http.Cookies.Cookie) is
begin
null;
end Add_Cookie;
-- ------------------------------
-- Free the resource used by the response.
-- ------------------------------
overriding
procedure Finalize (Reply : in out Response) is
procedure Free is new Ada.Unchecked_Deallocation (Http_Response'Class,
Http_Response_Access);
begin
Free (Reply.Delegate);
end Finalize;
end Util.Http.Clients;
|
zhmu/ananas | Ada | 30,407 | adb | -- { dg-do run }
with Ada.Text_IO; use Ada.Text_IO;
with GNAT; use GNAT;
with GNAT.Lists; use GNAT.Lists;
procedure Linkedlist is
procedure Destroy (Val : in out Integer) is null;
package Integer_Lists is new Doubly_Linked_Lists
(Element_Type => Integer,
"=" => "=",
Destroy_Element => Destroy);
use Integer_Lists;
procedure Check_Empty
(Caller : String;
L : Doubly_Linked_List;
Low_Elem : Integer;
High_Elem : Integer);
-- Ensure that none of the elements in the range Low_Elem .. High_Elem are
-- present in list L, and that the list's length is 0.
procedure Check_Locked_Mutations
(Caller : String;
L : in out Doubly_Linked_List);
-- Ensure that all mutation operations of list L are locked
procedure Check_Present
(Caller : String;
L : Doubly_Linked_List;
Low_Elem : Integer;
High_Elem : Integer);
-- Ensure that all elements in the range Low_Elem .. High_Elem are present
-- in list L.
procedure Check_Unlocked_Mutations
(Caller : String;
L : in out Doubly_Linked_List);
-- Ensure that all mutation operations of list L are unlocked
procedure Populate_With_Append
(L : Doubly_Linked_List;
Low_Elem : Integer;
High_Elem : Integer);
-- Add elements in the range Low_Elem .. High_Elem in that order in list L
procedure Test_Append;
-- Verify that Append properly inserts at the tail of a list
procedure Test_Contains
(Low_Elem : Integer;
High_Elem : Integer);
-- Verify that Contains properly identifies that elements in the range
-- Low_Elem .. High_Elem are within a list.
procedure Test_Create;
-- Verify that all list operations fail on a non-created list
procedure Test_Delete
(Low_Elem : Integer;
High_Elem : Integer);
-- Verify that Delete properly removes elements in the range Low_Elem ..
-- High_Elem from a list.
procedure Test_Delete_First
(Low_Elem : Integer;
High_Elem : Integer);
-- Verify that Delete properly removes elements in the range Low_Elem ..
-- High_Elem from the head of a list.
procedure Test_Delete_Last
(Low_Elem : Integer;
High_Elem : Integer);
-- Verify that Delete properly removes elements in the range Low_Elem ..
-- High_Elem from the tail of a list.
procedure Test_First;
-- Verify that First properly returns the head of a list
procedure Test_Insert_After;
-- Verify that Insert_After properly adds an element after some other
-- element.
procedure Test_Insert_Before;
-- Vefity that Insert_Before properly adds an element before some other
-- element.
procedure Test_Is_Empty;
-- Verify that Is_Empty properly returns this status of a list
procedure Test_Iterate;
-- Verify that iterators properly manipulate mutation operations
procedure Test_Iterate_Empty;
-- Verify that iterators properly manipulate mutation operations of an
-- empty list.
procedure Test_Iterate_Forced
(Low_Elem : Integer;
High_Elem : Integer);
-- Verify that an iterator that is forcefully advanced by Next properly
-- unlocks the mutation operations of a list.
procedure Test_Last;
-- Verify that Last properly returns the tail of a list
procedure Test_Prepend;
-- Verify that Prepend properly inserts at the head of a list
procedure Test_Replace;
-- Verify that Replace properly substitutes old elements with new ones
procedure Test_Size;
-- Verify that Size returns the correct size of a list
-----------------
-- Check_Empty --
-----------------
procedure Check_Empty
(Caller : String;
L : Doubly_Linked_List;
Low_Elem : Integer;
High_Elem : Integer)
is
Len : constant Natural := Size (L);
begin
for Elem in Low_Elem .. High_Elem loop
if Contains (L, Elem) then
Put_Line ("ERROR: " & Caller & ": extra element" & Elem'Img);
end if;
end loop;
if Len /= 0 then
Put_Line ("ERROR: " & Caller & ": wrong length");
Put_Line ("expected: 0");
Put_Line ("got :" & Len'Img);
end if;
end Check_Empty;
----------------------------
-- Check_Locked_Mutations --
----------------------------
procedure Check_Locked_Mutations
(Caller : String;
L : in out Doubly_Linked_List) is
begin
begin
Append (L, 1);
Put_Line ("ERROR: " & Caller & ": Append: no exception raised");
exception
when Iterated =>
null;
when others =>
Put_Line ("ERROR: " & Caller & ": Append: unexpected exception");
end;
begin
Delete (L, 1);
Put_Line ("ERROR: " & Caller & ": Delete: no exception raised");
exception
when List_Empty =>
null;
when Iterated =>
null;
when others =>
Put_Line ("ERROR: " & Caller & ": Delete: unexpected exception");
end;
begin
Delete_First (L);
Put_Line ("ERROR: " & Caller & ": Delete_First: no exception raised");
exception
when List_Empty =>
null;
when Iterated =>
null;
when others =>
Put_Line
("ERROR: " & Caller & ": Delete_First: unexpected exception");
end;
begin
Delete_Last (L);
Put_Line ("ERROR: " & Caller & ": Delete_List: no exception raised");
exception
when List_Empty =>
null;
when Iterated =>
null;
when others =>
Put_Line
("ERROR: " & Caller & ": Delete_Last: unexpected exception");
end;
begin
Destroy (L);
Put_Line ("ERROR: " & Caller & ": Destroy: no exception raised");
exception
when Iterated =>
null;
when others =>
Put_Line ("ERROR: " & Caller & ": Destroy: unexpected exception");
end;
begin
Insert_After (L, 1, 2);
Put_Line ("ERROR: " & Caller & ": Insert_After: no exception raised");
exception
when Iterated =>
null;
when others =>
Put_Line
("ERROR: " & Caller & ": Insert_After: unexpected exception");
end;
begin
Insert_Before (L, 1, 2);
Put_Line
("ERROR: " & Caller & ": Insert_Before: no exception raised");
exception
when Iterated =>
null;
when others =>
Put_Line
("ERROR: " & Caller & ": Insert_Before: unexpected exception");
end;
begin
Prepend (L, 1);
Put_Line ("ERROR: " & Caller & ": Prepend: no exception raised");
exception
when Iterated =>
null;
when others =>
Put_Line ("ERROR: " & Caller & ": Prepend: unexpected exception");
end;
begin
Replace (L, 1, 2);
Put_Line ("ERROR: " & Caller & ": Replace: no exception raised");
exception
when Iterated =>
null;
when others =>
Put_Line ("ERROR: " & Caller & ": Replace: unexpected exception");
end;
end Check_Locked_Mutations;
-------------------
-- Check_Present --
-------------------
procedure Check_Present
(Caller : String;
L : Doubly_Linked_List;
Low_Elem : Integer;
High_Elem : Integer)
is
Elem : Integer;
Iter : Iterator;
begin
Iter := Iterate (L);
for Exp_Elem in Low_Elem .. High_Elem loop
Next (Iter, Elem);
if Elem /= Exp_Elem then
Put_Line ("ERROR: " & Caller & ": Check_Present: wrong element");
Put_Line ("expected:" & Exp_Elem'Img);
Put_Line ("got :" & Elem'Img);
end if;
end loop;
-- At this point all elements should have been accounted for. Check for
-- extra elements.
while Has_Next (Iter) loop
Next (Iter, Elem);
Put_Line
("ERROR: " & Caller & ": Check_Present: extra element" & Elem'Img);
end loop;
exception
when Iterator_Exhausted =>
Put_Line
("ERROR: "
& Caller
& "Check_Present: incorrect number of elements");
end Check_Present;
------------------------------
-- Check_Unlocked_Mutations --
------------------------------
procedure Check_Unlocked_Mutations
(Caller : String;
L : in out Doubly_Linked_List)
is
begin
Append (L, 1);
Append (L, 2);
Append (L, 3);
Delete (L, 1);
Delete_First (L);
Delete_Last (L);
Insert_After (L, 2, 3);
Insert_Before (L, 2, 1);
Prepend (L, 0);
Replace (L, 3, 4);
end Check_Unlocked_Mutations;
--------------------------
-- Populate_With_Append --
--------------------------
procedure Populate_With_Append
(L : Doubly_Linked_List;
Low_Elem : Integer;
High_Elem : Integer)
is
begin
for Elem in Low_Elem .. High_Elem loop
Append (L, Elem);
end loop;
end Populate_With_Append;
-----------------
-- Test_Append --
-----------------
procedure Test_Append is
L : Doubly_Linked_List := Create;
begin
Append (L, 1);
Append (L, 2);
Append (L, 3);
Append (L, 4);
Append (L, 5);
Check_Present
(Caller => "Test_Append",
L => L,
Low_Elem => 1,
High_Elem => 5);
Destroy (L);
end Test_Append;
-------------------
-- Test_Contains --
-------------------
procedure Test_Contains
(Low_Elem : Integer;
High_Elem : Integer)
is
Low_Bogus : constant Integer := Low_Elem - 1;
High_Bogus : constant Integer := High_Elem + 1;
L : Doubly_Linked_List := Create;
begin
Populate_With_Append (L, Low_Elem, High_Elem);
-- Ensure that the elements are contained in the list
for Elem in Low_Elem .. High_Elem loop
if not Contains (L, Elem) then
Put_Line
("ERROR: Test_Contains: element" & Elem'Img & " not in list");
end if;
end loop;
-- Ensure that arbitrary elements which were not inserted in the list
-- are not contained in the list.
if Contains (L, Low_Bogus) then
Put_Line
("ERROR: Test_Contains: element" & Low_Bogus'Img & " in list");
end if;
if Contains (L, High_Bogus) then
Put_Line
("ERROR: Test_Contains: element" & High_Bogus'Img & " in list");
end if;
Destroy (L);
end Test_Contains;
-----------------
-- Test_Create --
-----------------
procedure Test_Create is
Count : Natural;
Flag : Boolean;
Iter : Iterator;
L : Doubly_Linked_List;
Val : Integer;
begin
-- Ensure that every routine defined in the API fails on a list which
-- has not been created yet.
begin
Append (L, 1);
Put_Line ("ERROR: Test_Create: Append: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Append: unexpected exception");
end;
begin
Flag := Contains (L, 1);
Put_Line ("ERROR: Test_Create: Contains: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Contains: unexpected exception");
end;
begin
Delete (L, 1);
Put_Line ("ERROR: Test_Create: Delete: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Delete: unexpected exception");
end;
begin
Delete_First (L);
Put_Line ("ERROR: Test_Create: Delete_First: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line
("ERROR: Test_Create: Delete_First: unexpected exception");
end;
begin
Delete_Last (L);
Put_Line ("ERROR: Test_Create: Delete_Last: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Delete_Last: unexpected exception");
end;
begin
Val := First (L);
Put_Line ("ERROR: Test_Create: First: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: First: unexpected exception");
end;
begin
Insert_After (L, 1, 2);
Put_Line ("ERROR: Test_Create: Insert_After: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line
("ERROR: Test_Create: Insert_After: unexpected exception");
end;
begin
Insert_Before (L, 1, 2);
Put_Line ("ERROR: Test_Create: Insert_Before: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line
("ERROR: Test_Create: Insert_Before: unexpected exception");
end;
begin
Flag := Is_Empty (L);
Put_Line ("ERROR: Test_Create: Is_Empty: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Is_Empty: unexpected exception");
end;
begin
Iter := Iterate (L);
Put_Line ("ERROR: Test_Create: Iterate: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Iterate: unexpected exception");
end;
begin
Val := Last (L);
Put_Line ("ERROR: Test_Create: Last: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Last: unexpected exception");
end;
begin
Prepend (L, 1);
Put_Line ("ERROR: Test_Create: Prepend: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Prepend: unexpected exception");
end;
begin
Replace (L, 1, 2);
Put_Line ("ERROR: Test_Create: Replace: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Replace: unexpected exception");
end;
begin
Count := Size (L);
Put_Line ("ERROR: Test_Create: Size: no exception raised");
exception
when Not_Created =>
null;
when others =>
Put_Line ("ERROR: Test_Create: Size: unexpected exception");
end;
end Test_Create;
-----------------
-- Test_Delete --
-----------------
procedure Test_Delete
(Low_Elem : Integer;
High_Elem : Integer)
is
Iter : Iterator;
L : Doubly_Linked_List := Create;
begin
Populate_With_Append (L, Low_Elem, High_Elem);
-- Delete the first element, which is technically the head
Delete (L, Low_Elem);
-- Ensure that all remaining elements except for the head are present in
-- the list.
Check_Present
(Caller => "Test_Delete",
L => L,
Low_Elem => Low_Elem + 1,
High_Elem => High_Elem);
-- Delete the last element, which is technically the tail
Delete (L, High_Elem);
-- Ensure that all remaining elements except for the head and tail are
-- present in the list.
Check_Present
(Caller => "Test_Delete",
L => L,
Low_Elem => Low_Elem + 1,
High_Elem => High_Elem - 1);
-- Delete all even elements
for Elem in Low_Elem + 1 .. High_Elem - 1 loop
if Elem mod 2 = 0 then
Delete (L, Elem);
end if;
end loop;
-- Ensure that all remaining elements except the head, tail, and even
-- elements are present in the list.
for Elem in Low_Elem + 1 .. High_Elem - 1 loop
if Elem mod 2 /= 0 and then not Contains (L, Elem) then
Put_Line ("ERROR: Test_Delete: missing element" & Elem'Img);
end if;
end loop;
-- Delete all odd elements
for Elem in Low_Elem + 1 .. High_Elem - 1 loop
if Elem mod 2 /= 0 then
Delete (L, Elem);
end if;
end loop;
-- At this point the list should be completely empty
Check_Empty
(Caller => "Test_Delete",
L => L,
Low_Elem => Low_Elem,
High_Elem => High_Elem);
-- Try to delete an element. This operation should raise List_Empty.
begin
Delete (L, Low_Elem);
Put_Line ("ERROR: Test_Delete: List_Empty not raised");
exception
when List_Empty =>
null;
when others =>
Put_Line ("ERROR: Test_Delete: unexpected exception");
end;
Destroy (L);
end Test_Delete;
-----------------------
-- Test_Delete_First --
-----------------------
procedure Test_Delete_First
(Low_Elem : Integer;
High_Elem : Integer)
is
L : Doubly_Linked_List := Create;
begin
Populate_With_Append (L, Low_Elem, High_Elem);
-- Delete the head of the list, and verify that the remaining elements
-- are still present in the list.
for Elem in Low_Elem .. High_Elem loop
Delete_First (L);
Check_Present
(Caller => "Test_Delete_First",
L => L,
Low_Elem => Elem + 1,
High_Elem => High_Elem);
end loop;
-- At this point the list should be completely empty
Check_Empty
(Caller => "Test_Delete_First",
L => L,
Low_Elem => Low_Elem,
High_Elem => High_Elem);
-- Try to delete an element. This operation should raise List_Empty.
begin
Delete_First (L);
Put_Line ("ERROR: Test_Delete_First: List_Empty not raised");
exception
when List_Empty =>
null;
when others =>
Put_Line ("ERROR: Test_Delete_First: unexpected exception");
end;
Destroy (L);
end Test_Delete_First;
----------------------
-- Test_Delete_Last --
----------------------
procedure Test_Delete_Last
(Low_Elem : Integer;
High_Elem : Integer)
is
L : Doubly_Linked_List := Create;
begin
Populate_With_Append (L, Low_Elem, High_Elem);
-- Delete the tail of the list, and verify that the remaining elements
-- are still present in the list.
for Elem in reverse Low_Elem .. High_Elem loop
Delete_Last (L);
Check_Present
(Caller => "Test_Delete_Last",
L => L,
Low_Elem => Low_Elem,
High_Elem => Elem - 1);
end loop;
-- At this point the list should be completely empty
Check_Empty
(Caller => "Test_Delete_Last",
L => L,
Low_Elem => Low_Elem,
High_Elem => High_Elem);
-- Try to delete an element. This operation should raise List_Empty.
begin
Delete_Last (L);
Put_Line ("ERROR: Test_Delete_Last: List_Empty not raised");
exception
when List_Empty =>
null;
when others =>
Put_Line ("ERROR: Test_Delete_First: unexpected exception");
end;
Destroy (L);
end Test_Delete_Last;
----------------
-- Test_First --
----------------
procedure Test_First is
Elem : Integer;
L : Doubly_Linked_List := Create;
begin
-- Try to obtain the head. This operation should raise List_Empty.
begin
Elem := First (L);
Put_Line ("ERROR: Test_First: List_Empty not raised");
exception
when List_Empty =>
null;
when others =>
Put_Line ("ERROR: Test_First: unexpected exception");
end;
Populate_With_Append (L, 1, 2);
-- Obtain the head
Elem := First (L);
if Elem /= 1 then
Put_Line ("ERROR: Test_First: wrong element");
Put_Line ("expected: 1");
Put_Line ("got :" & Elem'Img);
end if;
Destroy (L);
end Test_First;
-----------------------
-- Test_Insert_After --
-----------------------
procedure Test_Insert_After is
L : Doubly_Linked_List := Create;
begin
-- Try to insert after a non-inserted element, in an empty list
Insert_After (L, 1, 2);
-- At this point the list should be completely empty
Check_Empty
(Caller => "Test_Insert_After",
L => L,
Low_Elem => 0,
High_Elem => -1);
Append (L, 1); -- 1
Insert_After (L, 1, 3); -- 1, 3
Insert_After (L, 1, 2); -- 1, 2, 3
Insert_After (L, 3, 4); -- 1, 2, 3, 4
-- Try to insert after a non-inserted element, in a full list
Insert_After (L, 10, 11);
Check_Present
(Caller => "Test_Insert_After",
L => L,
Low_Elem => 1,
High_Elem => 4);
Destroy (L);
end Test_Insert_After;
------------------------
-- Test_Insert_Before --
------------------------
procedure Test_Insert_Before is
L : Doubly_Linked_List := Create;
begin
-- Try to insert before a non-inserted element, in an empty list
Insert_Before (L, 1, 2);
-- At this point the list should be completely empty
Check_Empty
(Caller => "Test_Insert_Before",
L => L,
Low_Elem => 0,
High_Elem => -1);
Append (L, 4); -- 4
Insert_Before (L, 4, 2); -- 2, 4
Insert_Before (L, 2, 1); -- 1, 2, 4
Insert_Before (L, 4, 3); -- 1, 2, 3, 4
-- Try to insert before a non-inserted element, in a full list
Insert_Before (L, 10, 11);
Check_Present
(Caller => "Test_Insert_Before",
L => L,
Low_Elem => 1,
High_Elem => 4);
Destroy (L);
end Test_Insert_Before;
-------------------
-- Test_Is_Empty --
-------------------
procedure Test_Is_Empty is
L : Doubly_Linked_List := Create;
begin
if not Is_Empty (L) then
Put_Line ("ERROR: Test_Is_Empty: list is not empty");
end if;
Append (L, 1);
if Is_Empty (L) then
Put_Line ("ERROR: Test_Is_Empty: list is empty");
end if;
Delete_First (L);
if not Is_Empty (L) then
Put_Line ("ERROR: Test_Is_Empty: list is not empty");
end if;
Destroy (L);
end Test_Is_Empty;
------------------
-- Test_Iterate --
------------------
procedure Test_Iterate is
Elem : Integer;
Iter_1 : Iterator;
Iter_2 : Iterator;
L : Doubly_Linked_List := Create;
begin
Populate_With_Append (L, 1, 5);
-- Obtain an iterator. This action must lock all mutation operations of
-- the list.
Iter_1 := Iterate (L);
-- Ensure that every mutation routine defined in the API fails on a list
-- with at least one outstanding iterator.
Check_Locked_Mutations
(Caller => "Test_Iterate",
L => L);
-- Obtain another iterator
Iter_2 := Iterate (L);
-- Ensure that every mutation is still locked
Check_Locked_Mutations
(Caller => "Test_Iterate",
L => L);
-- Exhaust the first itertor
while Has_Next (Iter_1) loop
Next (Iter_1, Elem);
end loop;
-- Ensure that every mutation is still locked
Check_Locked_Mutations
(Caller => "Test_Iterate",
L => L);
-- Exhaust the second itertor
while Has_Next (Iter_2) loop
Next (Iter_2, Elem);
end loop;
-- Ensure that all mutation operations are once again callable
Check_Unlocked_Mutations
(Caller => "Test_Iterate",
L => L);
Destroy (L);
end Test_Iterate;
------------------------
-- Test_Iterate_Empty --
------------------------
procedure Test_Iterate_Empty is
Elem : Integer;
Iter : Iterator;
L : Doubly_Linked_List := Create;
begin
-- Obtain an iterator. This action must lock all mutation operations of
-- the list.
Iter := Iterate (L);
-- Ensure that every mutation routine defined in the API fails on a list
-- with at least one outstanding iterator.
Check_Locked_Mutations
(Caller => "Test_Iterate_Empty",
L => L);
-- Attempt to iterate over the elements
while Has_Next (Iter) loop
Next (Iter, Elem);
Put_Line
("ERROR: Test_Iterate_Empty: element" & Elem'Img & " exists");
end loop;
-- Ensure that all mutation operations are once again callable
Check_Unlocked_Mutations
(Caller => "Test_Iterate_Empty",
L => L);
Destroy (L);
end Test_Iterate_Empty;
-------------------------
-- Test_Iterate_Forced --
-------------------------
procedure Test_Iterate_Forced
(Low_Elem : Integer;
High_Elem : Integer)
is
Elem : Integer;
Iter : Iterator;
L : Doubly_Linked_List := Create;
begin
Populate_With_Append (L, Low_Elem, High_Elem);
-- Obtain an iterator. This action must lock all mutation operations of
-- the list.
Iter := Iterate (L);
-- Ensure that every mutation routine defined in the API fails on a list
-- with at least one outstanding iterator.
Check_Locked_Mutations
(Caller => "Test_Iterate_Forced",
L => L);
-- Forcibly advance the iterator until it raises an exception
begin
for Guard in Low_Elem .. High_Elem + 1 loop
Next (Iter, Elem);
end loop;
Put_Line
("ERROR: Test_Iterate_Forced: Iterator_Exhausted not raised");
exception
when Iterator_Exhausted =>
null;
when others =>
Put_Line ("ERROR: Test_Iterate_Forced: unexpected exception");
end;
-- Ensure that all mutation operations are once again callable
Check_Unlocked_Mutations
(Caller => "Test_Iterate_Forced",
L => L);
Destroy (L);
end Test_Iterate_Forced;
---------------
-- Test_Last --
---------------
procedure Test_Last is
Elem : Integer;
L : Doubly_Linked_List := Create;
begin
-- Try to obtain the tail. This operation should raise List_Empty.
begin
Elem := First (L);
Put_Line ("ERROR: Test_Last: List_Empty not raised");
exception
when List_Empty =>
null;
when others =>
Put_Line ("ERROR: Test_Last: unexpected exception");
end;
Populate_With_Append (L, 1, 2);
-- Obtain the tail
Elem := Last (L);
if Elem /= 2 then
Put_Line ("ERROR: Test_Last: wrong element");
Put_Line ("expected: 2");
Put_Line ("got :" & Elem'Img);
end if;
Destroy (L);
end Test_Last;
------------------
-- Test_Prepend --
------------------
procedure Test_Prepend is
L : Doubly_Linked_List := Create;
begin
Prepend (L, 5);
Prepend (L, 4);
Prepend (L, 3);
Prepend (L, 2);
Prepend (L, 1);
Check_Present
(Caller => "Test_Prepend",
L => L,
Low_Elem => 1,
High_Elem => 5);
Destroy (L);
end Test_Prepend;
------------------
-- Test_Replace --
------------------
procedure Test_Replace is
L : Doubly_Linked_List := Create;
begin
Populate_With_Append (L, 1, 5);
Replace (L, 3, 8);
Replace (L, 1, 6);
Replace (L, 4, 9);
Replace (L, 5, 10);
Replace (L, 2, 7);
Replace (L, 11, 12);
Check_Present
(Caller => "Test_Replace",
L => L,
Low_Elem => 6,
High_Elem => 10);
Destroy (L);
end Test_Replace;
---------------
-- Test_Size --
---------------
procedure Test_Size is
L : Doubly_Linked_List := Create;
S : Natural;
begin
S := Size (L);
if S /= 0 then
Put_Line ("ERROR: Test_Size: wrong size");
Put_Line ("expected: 0");
Put_Line ("got :" & S'Img);
end if;
Populate_With_Append (L, 1, 2);
S := Size (L);
if S /= 2 then
Put_Line ("ERROR: Test_Size: wrong size");
Put_Line ("expected: 2");
Put_Line ("got :" & S'Img);
end if;
Populate_With_Append (L, 3, 6);
S := Size (L);
if S /= 6 then
Put_Line ("ERROR: Test_Size: wrong size");
Put_Line ("expected: 6");
Put_Line ("got :" & S'Img);
end if;
Destroy (L);
end Test_Size;
-- Start of processing for Operations
begin
Test_Append;
Test_Contains
(Low_Elem => 1,
High_Elem => 5);
Test_Create;
Test_Delete
(Low_Elem => 1,
High_Elem => 10);
Test_Delete_First
(Low_Elem => 1,
High_Elem => 5);
Test_Delete_Last
(Low_Elem => 1,
High_Elem => 5);
Test_First;
Test_Insert_After;
Test_Insert_Before;
Test_Is_Empty;
Test_Iterate;
Test_Iterate_Empty;
Test_Iterate_Forced
(Low_Elem => 1,
High_Elem => 5);
Test_Last;
Test_Prepend;
Test_Replace;
Test_Size;
end Linkedlist;
|
reznikmm/matreshka | Ada | 3,694 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Svg_Descent_Attributes is
pragma Preelaborate;
type ODF_Svg_Descent_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_Descent_Attribute_Access is
access all ODF_Svg_Descent_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_Descent_Attributes;
|
reznikmm/matreshka | Ada | 3,709 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Style_Table_Properties_Elements is
pragma Preelaborate;
type ODF_Style_Table_Properties is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Style_Table_Properties_Access is
access all ODF_Style_Table_Properties'Class
with Storage_Size => 0;
end ODF.DOM.Style_Table_Properties_Elements;
|
dan76/Amass | Ada | 2,507 | 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 = "DNSDB"
type = "api"
local rrtypes = {"A", "AAAA", "CNAME", "NS", "MX"}
function start()
set_rate_limit(1)
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.key ~= "") 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 == "") then
return
end
local ts = oldest_timestamp()
for _, rrtype in ipairs(rrtypes) do
local url = build_url(domain, rrtype)
query(ctx, url, ts, c.key)
end
end
function oldest_timestamp()
local temp = os.date("*t", os.time())
temp['year'] = temp['year'] - 1
return os.time(temp)
end
function query(ctx, url, ts, key)
local resp, err = request(ctx, {
['url']=url,
['header']={
['X-API-Key']=key,
['Accept']="application/x-ndjson",
},
})
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
for line in magiclines(resp.body) do
local d = json.decode(line)
if (d ~= nil and d['obj'] ~= nil) then
local obj = d['obj']
if (obj.rrname ~= nil and obj.rrname ~= "" and
obj.time_last ~= nil and obj.time_last >= ts) then
new_name(ctx, obj.rrname)
end
end
end
end
function build_url(domain, rrtype)
return "https://api.dnsdb.info/dnsdb/v2/lookup/rrset/name/*." .. domain .. "/" .. rrtype .. "?limit=0"
end
function magiclines(str)
local pos = 1;
return function()
if (not pos) then return nil end
local line
local p1, p2 = string.find(str, "\r?\n", pos)
if p1 then
line = str:sub(pos, p1 - 1)
pos = p2 + 1
else
line = str:sub(pos)
pos = nil
end
return line
end
end
|
MayaPosch/NymphRPC | Ada | 206 | ads | -- nymph_logging.ads - Main package for use by NymphRPC clients (Spec).
--
-- 2017/07/01, Maya Posch
-- (c) Nyanko.ws
type LogFunction is not null access procedure (level: in integer, text: in string);
|
kimtg/euler-ada | Ada | 718 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Euler10 Is
function Sum_Prime_Under(N: Integer) return Long_Long_Integer is
Is_Prime : array (2 .. N - 1) of Boolean := (others => True);
Sum : Long_Long_Integer := 0;
begin
for I in Is_Prime'Range loop
if Is_Prime(I) then
Sum := Sum + Long_Long_Integer(I);
declare
J : Integer := I * 2;
begin
while J <= Is_Prime'Last loop
Is_Prime(J) := False;
J := J + I;
end loop;
end;
end if;
end loop;
return Sum;
end;
begin
Put_Line(Long_Long_Integer'Image(Sum_Prime_Under(2_000_000)));
end;
|
charlie5/aIDE | Ada | 1,868 | ads | with
adam.a_Package,
gtk.Widget;
private
with
aIDE.Editor.of_context,
gtk.Text_View,
gtk.Alignment,
gtk.gEntry,
gtk.Label,
gtk.Box;
with Gtk.Scrolled_Window;
with Gtk.Notebook;
with Gtk.Table;
package aIDE.Editor.of_package
is
type Item is new Editor.item with private;
type View is access all Item'Class;
package Forge
is
function to_package_Editor (the_Package : in adam.a_Package.view) return View;
end Forge;
overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
function my_Package (Self : in Item) return adam.a_Package.view;
procedure Package_is (Self : in out Item; Now : in adam.a_Package.view);
overriding
procedure freshen (Self : in out Item);
private
use gtk.Text_View,
Gtk.scrolled_Window,
gtk.Box,
gtk.gEntry,
gtk.Notebook,
gtk.Table,
gtk.Label,
gtk.Alignment;
type Item is new Editor.item with
record
my_Package : adam.a_Package.view;
-- public_Part : Boolean;
Notebook : gtk_Notebook;
public_context_Editor : aIDE.Editor.of_context.view;
public_context_Alignment : gtk_Alignment;
private_context_Editor : aIDE.Editor.of_context.view;
private_context_Alignment : gtk_Alignment;
name_Entry : gtk_Entry;
package_Label : gtk_Label;
declarations_Label : gtk_Label;
simple_attributes_Table : gtk_Table;
top_Window : gtk_scrolled_Window;
top_Box : gtk_Box;
public_entities_Box : gtk_Box;
private_entities_Box : gtk_Box;
declare_Text,
begin_Text,
exception_Text : Gtk_Text_View;
end record;
end aIDE.Editor.of_package;
|
stcarrez/ada-util | Ada | 29,313 | ads | -----------------------------------------------------------------------
-- util-locales -- Locale support
-- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2011, 2012, 2013, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers;
-- The <b>Locales</b> package defines the <b>Locale</b> type to represent
-- the language, country and variant.
--
-- The language is a valid <b>ISO language code</b>. This is a two-letter
-- lower case code defined by IS-639
-- See http://www.loc.gov/standards/iso639-2/englangn.html
--
-- The country is a valid <b>ISO country code</b>. These codes are
-- a two letter upper-case code defined by ISO-3166.
-- See http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
--
-- The variant part is a vendor or browser specific code.
--
-- The <b>Locales</b> package tries to follow the Java <b>Locale</b> class.
package Util.Locales is
pragma Preelaborate;
type Locale is private;
type Locale_Array is array (Positive range <>) of Locale;
-- List of locales.
Locales : constant Locale_Array;
-- Get the lowercase two-letter ISO-639 code.
function Get_Language (Loc : in Locale) return String;
-- Get the ISO 639-2 language code.
function Get_ISO3_Language (Loc : in Locale) return String;
-- Get the uppercase two-letter ISO-3166 code.
function Get_Country (Loc : in Locale) return String;
-- Get the ISO-3166-2 country code.
function Get_ISO3_Country (Loc : in Locale) return String;
-- Get the variant code
function Get_Variant (Loc : in Locale) return String;
-- Get the locale for the given language code
function Get_Locale (Language : in String) return Locale;
-- Get the locale for the given language and country code
function Get_Locale (Language : in String;
Country : in String) return Locale;
-- Get the locale for the given language, country and variant code
function Get_Locale (Language : in String;
Country : in String;
Variant : in String) return Locale;
-- Get the locale code in the form <i>language</i>_<i>country</i>_<i>variant</i>.
function To_String (Loc : in Locale) return String;
-- Compute the hash value of the locale.
function Hash (Loc : in Locale) return Ada.Containers.Hash_Type;
NULL_LOCALE : constant Locale;
-- French language
FRENCH : constant Locale;
-- English language
ENGLISH : constant Locale;
-- German language
GERMAN : constant Locale;
-- Italian language
ITALIAN : constant Locale;
FRANCE : constant Locale;
CANADA : constant Locale;
GERMANY : constant Locale;
ITALY : constant Locale;
US : constant Locale;
UK : constant Locale;
private
type Locale is access constant String;
ALBANIAN_STR : aliased constant String := "sq.sqi";
ALBANIAN_ALBANIA_STR : aliased constant String := "sq_AL.sqi.ALB";
ARABIC_STR : aliased constant String := "ar.ara";
ARABIC_ALGERIA_STR : aliased constant String := "ar_DZ.ara.DZA";
ARABIC_BAHRAIN_STR : aliased constant String := "ar_BH.ara.BHR";
ARABIC_EGYPT_STR : aliased constant String := "ar_EG.ara.EGY";
ARABIC_IRAQ_STR : aliased constant String := "ar_IQ.ara.IRQ";
ARABIC_JORDAN_STR : aliased constant String := "ar_JO.ara.JOR";
ARABIC_KUWAIT_STR : aliased constant String := "ar_KW.ara.KWT";
ARABIC_LEBANON_STR : aliased constant String := "ar_LB.ara.LBN";
ARABIC_LIBYA_STR : aliased constant String := "ar_LY.ara.LBY";
ARABIC_MOROCCO_STR : aliased constant String := "ar_MA.ara.MAR";
ARABIC_OMAN_STR : aliased constant String := "ar_OM.ara.OMN";
ARABIC_QATAR_STR : aliased constant String := "ar_QA.ara.QAT";
ARABIC_SAUDI_ARABIA_STR : aliased constant String := "ar_SA.ara.SAU";
ARABIC_SUDAN_STR : aliased constant String := "ar_SD.ara.SDN";
ARABIC_SYRIA_STR : aliased constant String := "ar_SY.ara.SYR";
ARABIC_TUNISIA_STR : aliased constant String := "ar_TN.ara.TUN";
ARABIC_UNITED_ARAB_EMIRATES_STR : aliased constant String := "ar_AE.ara.ARE";
ARABIC_YEMEN_STR : aliased constant String := "ar_YE.ara.YEM";
BELARUSIAN_STR : aliased constant String := "be.bel";
BELARUSIAN_BELARUS_STR : aliased constant String := "be_BY.bel.BLR";
BULGARIAN_STR : aliased constant String := "bg.bul";
BULGARIAN_BULGARIA_STR : aliased constant String := "bg_BG.bul.BGR";
CATALAN_STR : aliased constant String := "ca.cat";
CATALAN_SPAIN_STR : aliased constant String := "ca_ES.cat.ESP";
CHINESE_STR : aliased constant String := "zh.zho";
CHINESE_CHINA_STR : aliased constant String := "zh_CN.zho.CHN";
CHINESE_HONG_KONG_STR : aliased constant String := "zh_HK.zho.HKG";
CHINESE_SINGAPORE_STR : aliased constant String := "zh_SG.zho.SGP";
CHINESE_TAIWAN_STR : aliased constant String := "zh_TW.zho.TWN";
CROATIAN_STR : aliased constant String := "hr.hrv";
CROATIAN_CROATIA_STR : aliased constant String := "hr_HR.hrv.HRV";
CZECH_STR : aliased constant String := "cs.ces";
CZECH_CZECH_REPUBLIC_STR : aliased constant String := "cs_CZ.ces.CZE";
DANISH_STR : aliased constant String := "da.dan";
DANISH_DENMARK_STR : aliased constant String := "da_DK.dan.DNK";
DUTCH_STR : aliased constant String := "nl.nld";
DUTCH_BELGIUM_STR : aliased constant String := "nl_BE.nld.BEL";
DUTCH_NETHERLANDS_STR : aliased constant String := "nl_NL.nld.NLD";
ENGLISH_STR : aliased constant String := "en.eng";
ENGLISH_AUSTRALIA_STR : aliased constant String := "en_AU.eng.AUS";
ENGLISH_CANADA_STR : aliased constant String := "en_CA.eng.CAN";
ENGLISH_INDIA_STR : aliased constant String := "en_IN.eng.IND";
ENGLISH_IRELAND_STR : aliased constant String := "en_IE.eng.IRL";
ENGLISH_MALTA_STR : aliased constant String := "en_MT.eng.MLT";
ENGLISH_NEW_ZEALAND_STR : aliased constant String := "en_NZ.eng.NZL";
ENGLISH_PHILIPPINES_STR : aliased constant String := "en_PH.eng.PHL";
ENGLISH_SINGAPORE_STR : aliased constant String := "en_SG.eng.SGP";
ENGLISH_SOUTH_AFRICA_STR : aliased constant String := "en_ZA.eng.ZAF";
ENGLISH_UNITED_KINGDOM_STR : aliased constant String := "en_GB.eng.GBR";
ENGLISH_UNITED_STATES_STR : aliased constant String := "en_US.eng.USA";
ESTONIAN_STR : aliased constant String := "et.est";
ESTONIAN_ESTONIA_STR : aliased constant String := "et_EE.est.EST";
FINNISH_STR : aliased constant String := "fi.fin";
FINNISH_FINLAND_STR : aliased constant String := "fi_FI.fin.FIN";
FRENCH_STR : aliased constant String := "fr.fra";
FRENCH_BELGIUM_STR : aliased constant String := "fr_BE.fra.BEL";
FRENCH_CANADA_STR : aliased constant String := "fr_CA.fra.CAN";
FRENCH_FRANCE_STR : aliased constant String := "fr_FR.fra.FRA";
FRENCH_LUXEMBOURG_STR : aliased constant String := "fr_LU.fra.LUX";
FRENCH_SWITZERLAND_STR : aliased constant String := "fr_CH.fra.CHE";
GERMAN_STR : aliased constant String := "de.deu";
GERMAN_AUSTRIA_STR : aliased constant String := "de_AT.deu.AUT";
GERMAN_GERMANY_STR : aliased constant String := "de_DE.deu.DEU";
GERMAN_LUXEMBOURG_STR : aliased constant String := "de_LU.deu.LUX";
GERMAN_SWITZERLAND_STR : aliased constant String := "de_CH.deu.CHE";
GREEK_STR : aliased constant String := "el.ell";
GREEK_CYPRUS_STR : aliased constant String := "el_CY.ell.CYP";
GREEK_GREECE_STR : aliased constant String := "el_GR.ell.GRC";
HEBREW_STR : aliased constant String := "iw.heb";
HEBREW_ISRAEL_STR : aliased constant String := "iw_IL.heb.ISR";
HINDI_INDIA_STR : aliased constant String := "hi_IN.hin.IND";
HUNGARIAN_STR : aliased constant String := "hu.hun";
HUNGARIAN_HUNGARY_STR : aliased constant String := "hu_HU.hun.HUN";
ICELANDIC_STR : aliased constant String := "is.isl";
ICELANDIC_ICELAND_STR : aliased constant String := "is_IS.isl.ISL";
INDONESIAN_STR : aliased constant String := "in.ind";
INDONESIAN_INDONESIA_STR : aliased constant String := "in_ID.ind.IDN";
IRISH_STR : aliased constant String := "ga.gle";
IRISH_IRELAND_STR : aliased constant String := "ga_IE.gle.IRL";
ITALIAN_STR : aliased constant String := "it.ita";
ITALIAN_ITALY_STR : aliased constant String := "it_IT.ita.ITA";
ITALIAN_SWITZERLAND_STR : aliased constant String := "it_CH.ita.CHE";
JAPANESE_STR : aliased constant String := "ja.jpn";
JAPANESE_JAPAN_STR : aliased constant String := "ja_JP.jpn.JPN";
JAPANESE_JAPAN_JP_STR : aliased constant String := "ja_JP_JP.jpn_JP.JPN";
KOREAN_STR : aliased constant String := "ko.kor";
KOREAN_SOUTH_KOREA_STR : aliased constant String := "ko_KR.kor.KOR";
LATVIAN_STR : aliased constant String := "lv.lav";
LATVIAN_LATVIA_STR : aliased constant String := "lv_LV.lav.LVA";
LITHUANIAN_STR : aliased constant String := "lt.lit";
LITHUANIAN_LITHUANIA_STR : aliased constant String := "lt_LT.lit.LTU";
MACEDONIAN_STR : aliased constant String := "mk.mkd";
MACEDONIAN_MACEDONIA_STR : aliased constant String := "mk_MK.mkd.MKD";
MALAY_STR : aliased constant String := "ms.msa";
MALAY_MALAYSIA_STR : aliased constant String := "ms_MY.msa.MYS";
MALTESE_STR : aliased constant String := "mt.mlt";
MALTESE_MALTA_STR : aliased constant String := "mt_MT.mlt.MLT";
NORWEGIAN_STR : aliased constant String := "no.nor";
NORWEGIAN_NORWAY_STR : aliased constant String := "no_NO.nor.NOR";
NORWEGIAN_NORWAY_NYNORSK_STR : aliased constant String := "no_NO_NY.nor_NY.NOR";
POLISH_STR : aliased constant String := "pl.pol";
POLISH_POLAND_STR : aliased constant String := "pl_PL.pol.POL";
PORTUGUESE_STR : aliased constant String := "pt.por";
PORTUGUESE_BRAZIL_STR : aliased constant String := "pt_BR.por.BRA";
PORTUGUESE_PORTUGAL_STR : aliased constant String := "pt_PT.por.PRT";
ROMANIAN_STR : aliased constant String := "ro.ron";
ROMANIAN_ROMANIA_STR : aliased constant String := "ro_RO.ron.ROU";
RUSSIAN_STR : aliased constant String := "ru.rus";
RUSSIAN_RUSSIA_STR : aliased constant String := "ru_RU.rus.RUS";
SERBIAN_STR : aliased constant String := "sr.srp";
SERBIAN_BOSNIA_AND_HERZEGOVINA_STR : aliased constant String := "sr_BA.srp.BIH";
SERBIAN_MONTENEGRO_STR : aliased constant String := "sr_ME.srp.MNE";
SERBIAN_SERBIA_STR : aliased constant String := "sr_RS.srp.SRB";
SERBIAN_SERBIA_AND_MONTENEGRO_STR : aliased constant String := "sr_CS.srp.SCG";
SLOVAK_STR : aliased constant String := "sk.slk";
SLOVAK_SLOVAKIA_STR : aliased constant String := "sk_SK.slk.SVK";
SLOVENIAN_STR : aliased constant String := "sl.slv";
SLOVENIAN_SLOVENIA_STR : aliased constant String := "sl_SI.slv.SVN";
SPANISH_STR : aliased constant String := "es.spa";
SPANISH_ARGENTINA_STR : aliased constant String := "es_AR.spa.ARG";
SPANISH_BOLIVIA_STR : aliased constant String := "es_BO.spa.BOL";
SPANISH_CHILE_STR : aliased constant String := "es_CL.spa.CHL";
SPANISH_COLOMBIA_STR : aliased constant String := "es_CO.spa.COL";
SPANISH_COSTA_RICA_STR : aliased constant String := "es_CR.spa.CRI";
SPANISH_DOMINICAN_REPUBLIC_STR : aliased constant String := "es_DO.spa.DOM";
SPANISH_ECUADOR_STR : aliased constant String := "es_EC.spa.ECU";
SPANISH_EL_SALVADOR_STR : aliased constant String := "es_SV.spa.SLV";
SPANISH_GUATEMALA_STR : aliased constant String := "es_GT.spa.GTM";
SPANISH_HONDURAS_STR : aliased constant String := "es_HN.spa.HND";
SPANISH_MEXICO_STR : aliased constant String := "es_MX.spa.MEX";
SPANISH_NICARAGUA_STR : aliased constant String := "es_NI.spa.NIC";
SPANISH_PANAMA_STR : aliased constant String := "es_PA.spa.PAN";
SPANISH_PARAGUAY_STR : aliased constant String := "es_PY.spa.PRY";
SPANISH_PERU_STR : aliased constant String := "es_PE.spa.PER";
SPANISH_PUERTO_RICO_STR : aliased constant String := "es_PR.spa.PRI";
SPANISH_SPAIN_STR : aliased constant String := "es_ES.spa.ESP";
SPANISH_UNITED_STATES_STR : aliased constant String := "es_US.spa.USA";
SPANISH_URUGUAY_STR : aliased constant String := "es_UY.spa.URY";
SPANISH_VENEZUELA_STR : aliased constant String := "es_VE.spa.VEN";
SWEDISH_STR : aliased constant String := "sv.swe";
SWEDISH_SWEDEN_STR : aliased constant String := "sv_SE.swe.SWE";
THAI_STR : aliased constant String := "th.tha";
THAI_THAILAND_STR : aliased constant String := "th_TH.tha.THA";
THAI_THAILAND_TH_STR : aliased constant String := "th_TH_TH.tha_TH.THA";
TURKISH_STR : aliased constant String := "tr.tur";
TURKISH_TURKEY_STR : aliased constant String := "tr_TR.tur.TUR";
UKRAINIAN_STR : aliased constant String := "uk.ukr";
UKRAINIAN_UKRAINE_STR : aliased constant String := "uk_UA.ukr.UKR";
VIETNAMESE_STR : aliased constant String := "vi.vie";
VIETNAMESE_VIETNAM_STR : aliased constant String := "vi_VN.vie.VNM";
-- The locales must be sorted on the locale string.
Locales : constant Locale_Array (1 .. 152) := (
ARABIC_STR'Access,
ARABIC_UNITED_ARAB_EMIRATES_STR'Access,
ARABIC_BAHRAIN_STR'Access,
ARABIC_ALGERIA_STR'Access,
ARABIC_EGYPT_STR'Access,
ARABIC_IRAQ_STR'Access,
ARABIC_JORDAN_STR'Access,
ARABIC_KUWAIT_STR'Access,
ARABIC_LEBANON_STR'Access,
ARABIC_LIBYA_STR'Access,
ARABIC_MOROCCO_STR'Access,
ARABIC_OMAN_STR'Access,
ARABIC_QATAR_STR'Access,
ARABIC_SAUDI_ARABIA_STR'Access,
ARABIC_SUDAN_STR'Access,
ARABIC_SYRIA_STR'Access,
ARABIC_TUNISIA_STR'Access,
ARABIC_YEMEN_STR'Access,
BELARUSIAN_STR'Access,
BELARUSIAN_BELARUS_STR'Access,
BULGARIAN_STR'Access,
BULGARIAN_BULGARIA_STR'Access,
CATALAN_STR'Access,
CATALAN_SPAIN_STR'Access,
CZECH_STR'Access,
CZECH_CZECH_REPUBLIC_STR'Access,
DANISH_STR'Access,
DANISH_DENMARK_STR'Access,
GERMAN_STR'Access,
GERMAN_AUSTRIA_STR'Access,
GERMAN_SWITZERLAND_STR'Access,
GERMAN_GERMANY_STR'Access,
GERMAN_LUXEMBOURG_STR'Access,
GREEK_STR'Access,
GREEK_CYPRUS_STR'Access,
GREEK_GREECE_STR'Access,
ENGLISH_STR'Access,
ENGLISH_AUSTRALIA_STR'Access,
ENGLISH_CANADA_STR'Access,
ENGLISH_UNITED_KINGDOM_STR'Access,
ENGLISH_IRELAND_STR'Access,
ENGLISH_INDIA_STR'Access,
ENGLISH_MALTA_STR'Access,
ENGLISH_NEW_ZEALAND_STR'Access,
ENGLISH_PHILIPPINES_STR'Access,
ENGLISH_SINGAPORE_STR'Access,
ENGLISH_UNITED_STATES_STR'Access,
ENGLISH_SOUTH_AFRICA_STR'Access,
SPANISH_STR'Access,
SPANISH_ARGENTINA_STR'Access,
SPANISH_BOLIVIA_STR'Access,
SPANISH_CHILE_STR'Access,
SPANISH_COLOMBIA_STR'Access,
SPANISH_COSTA_RICA_STR'Access,
SPANISH_DOMINICAN_REPUBLIC_STR'Access,
SPANISH_ECUADOR_STR'Access,
SPANISH_SPAIN_STR'Access,
SPANISH_GUATEMALA_STR'Access,
SPANISH_HONDURAS_STR'Access,
SPANISH_MEXICO_STR'Access,
SPANISH_NICARAGUA_STR'Access,
SPANISH_PANAMA_STR'Access,
SPANISH_PERU_STR'Access,
SPANISH_PUERTO_RICO_STR'Access,
SPANISH_PARAGUAY_STR'Access,
SPANISH_EL_SALVADOR_STR'Access,
SPANISH_UNITED_STATES_STR'Access,
SPANISH_URUGUAY_STR'Access,
SPANISH_VENEZUELA_STR'Access,
ESTONIAN_STR'Access,
ESTONIAN_ESTONIA_STR'Access,
FINNISH_STR'Access,
FINNISH_FINLAND_STR'Access,
FRENCH_STR'Access,
FRENCH_BELGIUM_STR'Access,
FRENCH_CANADA_STR'Access,
FRENCH_SWITZERLAND_STR'Access,
FRENCH_FRANCE_STR'Access,
FRENCH_LUXEMBOURG_STR'Access,
IRISH_STR'Access,
IRISH_IRELAND_STR'Access,
HINDI_INDIA_STR'Access,
CROATIAN_STR'Access,
CROATIAN_CROATIA_STR'Access,
HUNGARIAN_STR'Access,
HUNGARIAN_HUNGARY_STR'Access,
INDONESIAN_STR'Access,
INDONESIAN_INDONESIA_STR'Access,
ICELANDIC_STR'Access,
ICELANDIC_ICELAND_STR'Access,
ITALIAN_STR'Access,
ITALIAN_SWITZERLAND_STR'Access,
ITALIAN_ITALY_STR'Access,
HEBREW_STR'Access,
HEBREW_ISRAEL_STR'Access,
JAPANESE_STR'Access,
JAPANESE_JAPAN_STR'Access,
JAPANESE_JAPAN_JP_STR'Access,
KOREAN_STR'Access,
KOREAN_SOUTH_KOREA_STR'Access,
LITHUANIAN_STR'Access,
LITHUANIAN_LITHUANIA_STR'Access,
LATVIAN_STR'Access,
LATVIAN_LATVIA_STR'Access,
MACEDONIAN_STR'Access,
MACEDONIAN_MACEDONIA_STR'Access,
MALAY_STR'Access,
MALAY_MALAYSIA_STR'Access,
MALTESE_STR'Access,
MALTESE_MALTA_STR'Access,
DUTCH_STR'Access,
DUTCH_BELGIUM_STR'Access,
DUTCH_NETHERLANDS_STR'Access,
NORWEGIAN_STR'Access,
NORWEGIAN_NORWAY_STR'Access,
NORWEGIAN_NORWAY_NYNORSK_STR'Access,
POLISH_STR'Access,
POLISH_POLAND_STR'Access,
PORTUGUESE_STR'Access,
PORTUGUESE_BRAZIL_STR'Access,
PORTUGUESE_PORTUGAL_STR'Access,
ROMANIAN_STR'Access,
ROMANIAN_ROMANIA_STR'Access,
RUSSIAN_STR'Access,
RUSSIAN_RUSSIA_STR'Access,
SLOVAK_STR'Access,
SLOVAK_SLOVAKIA_STR'Access,
SLOVENIAN_STR'Access,
SLOVENIAN_SLOVENIA_STR'Access,
ALBANIAN_STR'Access,
ALBANIAN_ALBANIA_STR'Access,
SERBIAN_STR'Access,
SERBIAN_BOSNIA_AND_HERZEGOVINA_STR'Access,
SERBIAN_SERBIA_AND_MONTENEGRO_STR'Access,
SERBIAN_MONTENEGRO_STR'Access,
SERBIAN_SERBIA_STR'Access,
SWEDISH_STR'Access,
SWEDISH_SWEDEN_STR'Access,
THAI_STR'Access,
THAI_THAILAND_STR'Access,
THAI_THAILAND_TH_STR'Access,
TURKISH_STR'Access,
TURKISH_TURKEY_STR'Access,
UKRAINIAN_STR'Access,
UKRAINIAN_UKRAINE_STR'Access,
VIETNAMESE_STR'Access,
VIETNAMESE_VIETNAM_STR'Access,
CHINESE_STR'Access,
CHINESE_CHINA_STR'Access,
CHINESE_HONG_KONG_STR'Access,
CHINESE_SINGAPORE_STR'Access,
CHINESE_TAIWAN_STR'Access);
NULL_LOCALE : constant Locale := null;
FRENCH : constant Locale := FRENCH_STR'Access;
ITALIAN : constant Locale := ITALIAN_STR'Access;
GERMAN : constant Locale := GERMAN_STR'Access;
ENGLISH : constant Locale := ENGLISH_STR'Access;
FRANCE : constant Locale := FRENCH_FRANCE_STR'Access;
ITALY : constant Locale := ITALIAN_ITALY_STR'Access;
CANADA : constant Locale := ENGLISH_CANADA_STR'Access;
GERMANY : constant Locale := GERMAN_GERMANY_STR'Access;
US : constant Locale := ENGLISH_UNITED_STATES_STR'Access;
UK : constant Locale := ENGLISH_UNITED_KINGDOM_STR'Access;
end Util.Locales;
|
zhmu/ananas | Ada | 2,573 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . T H I N _ C O M M O N --
-- --
-- S p e c --
-- --
-- Copyright (C) 2008-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package is a placeholder for the sockets binding for platforms where
-- it is not implemented.
package GNAT.Sockets.Thin_Common is
pragma Unimplemented_Unit;
end GNAT.Sockets.Thin_Common;
|
charlie5/cBound | Ada | 1,733 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_tex_parameterfv_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
context_tag : aliased xcb.xcb_glx_context_tag_t;
target : aliased Interfaces.Unsigned_32;
pname : aliased Interfaces.Unsigned_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_get_tex_parameterfv_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_tex_parameterfv_request_t.Item,
Element_Array => xcb.xcb_glx_get_tex_parameterfv_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_get_tex_parameterfv_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_tex_parameterfv_request_t.Pointer,
Element_Array => xcb.xcb_glx_get_tex_parameterfv_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_tex_parameterfv_request_t;
|
reznikmm/matreshka | Ada | 8,070 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.CMOF.Elements;
with AMF.DI.Styles;
with AMF.Internals.UMLDI_UML_Labels;
with AMF.UML.Elements.Collections;
with AMF.UMLDI.UML_Styles;
with AMF.UMLDI.UML_Typed_Element_Labels;
with AMF.Visitors;
with League.Strings;
package AMF.Internals.UMLDI_UML_Typed_Element_Labels is
type UMLDI_UML_Typed_Element_Label_Proxy is
limited new AMF.Internals.UMLDI_UML_Labels.UMLDI_UML_Label_Proxy
and AMF.UMLDI.UML_Typed_Element_Labels.UMLDI_UML_Typed_Element_Label with null record;
overriding function Get_Text
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy)
return League.Strings.Universal_String;
-- Getter of UMLLabel::text.
--
-- String to be rendered.
overriding procedure Set_Text
(Self : not null access UMLDI_UML_Typed_Element_Label_Proxy;
To : League.Strings.Universal_String);
-- Setter of UMLLabel::text.
--
-- String to be rendered.
overriding function Get_Is_Icon
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy)
return Boolean;
-- Getter of UMLDiagramElement::isIcon.
--
-- For modelElements that have an option to be shown with shapes other
-- than rectangles, such as Actors, or with other identifying shapes
-- inside them, such as arrows distinguishing InputPins and OutputPins, or
-- edges that have an option to be shown with lines other than solid with
-- open arrow heads, such as Realization. A value of true for isIcon
-- indicates the alternative notation shall be shown.
overriding procedure Set_Is_Icon
(Self : not null access UMLDI_UML_Typed_Element_Label_Proxy;
To : Boolean);
-- Setter of UMLDiagramElement::isIcon.
--
-- For modelElements that have an option to be shown with shapes other
-- than rectangles, such as Actors, or with other identifying shapes
-- inside them, such as arrows distinguishing InputPins and OutputPins, or
-- edges that have an option to be shown with lines other than solid with
-- open arrow heads, such as Realization. A value of true for isIcon
-- indicates the alternative notation shall be shown.
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy)
return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access;
-- Getter of UMLDiagramElement::localStyle.
--
-- Restricts owned styles to UMLStyles.
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Typed_Element_Label_Proxy;
To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access);
-- Setter of UMLDiagramElement::localStyle.
--
-- Restricts owned styles to UMLStyles.
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of UMLDiagramElement::modelElement.
--
-- Restricts UMLDiagramElements to show UML Elements, rather than other
-- language elements.
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy)
return AMF.CMOF.Elements.CMOF_Element_Access;
-- Getter of DiagramElement::modelElement.
--
-- a reference to a depicted model element, which can be any MOF-based
-- element
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy)
return AMF.DI.Styles.DI_Style_Access;
-- Getter of DiagramElement::localStyle.
--
-- a reference to an optional locally-owned style for this diagram element.
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Typed_Element_Label_Proxy;
To : AMF.DI.Styles.DI_Style_Access);
-- Setter of DiagramElement::localStyle.
--
-- a reference to an optional locally-owned style for this diagram element.
overriding procedure Enter_Element
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant UMLDI_UML_Typed_Element_Label_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.UMLDI_UML_Typed_Element_Labels;
|
stcarrez/swagger-ada | Ada | 4,694 | ads | -- REST API Validation
-- API to validate
--
-- The version of the OpenAPI document: 1.0.0
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.1-2023-08-27.
-- https://openapi-generator.tech
-- Do not edit the class manually.
pragma Warnings (Off, "*is not referenced");
pragma Warnings (Off, "*no entities of*are referenced");
with Swagger.Servers;
with TestBinary.Models;
with Security.Permissions;
with External;
package TestBinary.Skeletons is
pragma Style_Checks ("-bmrIu");
pragma Warnings (Off, "*use clause for package*");
use TestBinary.Models;
type Server_Type is limited interface;
-- Get an image
-- Get an image
procedure Do_Get_Image
(Server : in out Server_Type;
Status : in Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Blob_Ref;
Context : in out Swagger.Servers.Context_Type) is abstract;
-- Get an object
-- Get an object
procedure Do_Get_Object
(Server : in out Server_Type;
Status : in Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Object;
Context : in out Swagger.Servers.Context_Type) is abstract;
-- Get some stat from external struct
procedure Do_Get_Stats
(Server : in out Server_Type;
Status : in Status_Type;
Result : out External.Stat_Vector;
Context : in out Swagger.Servers.Context_Type) is abstract;
generic
type Implementation_Type is limited new Server_Type with private;
URI_Prefix : String := "";
package Skeleton is
procedure Register
(Server : in out Swagger.Servers.Application_Type'Class);
-- Get an image
procedure Do_Get_Image
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type);
-- Get an object
procedure Do_Get_Object
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type);
-- Get some stat from external struct
procedure Do_Get_Stats
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type);
end Skeleton;
generic
type Implementation_Type is limited new Server_Type with private;
URI_Prefix : String := "";
package Shared_Instance is
procedure Register
(Server : in out Swagger.Servers.Application_Type'Class);
-- Get an image
procedure Do_Get_Image
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type);
-- Get an object
procedure Do_Get_Object
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type);
-- Get some stat from external struct
procedure Do_Get_Stats
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type);
private
protected Server is
-- Get an image
procedure Do_Get_Image
(Status : in Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Blob_Ref;
Context : in out Swagger.Servers.Context_Type);
-- Get an object
procedure Do_Get_Object
(Status : in Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Object;
Context : in out Swagger.Servers.Context_Type);
-- Get some stat from external struct
procedure Do_Get_Stats
(Status : in Status_Type;
Result : out External.Stat_Vector;
Context : in out Swagger.Servers.Context_Type);
private
Impl : Implementation_Type;
end Server;
end Shared_Instance;
end TestBinary.Skeletons;
|
reznikmm/matreshka | Ada | 547 | adb | with Styx.Request_Visiters;
with Styx.Reply_Visiters;
package body Styx.Messages.Stats is
-----------
-- Visit --
-----------
procedure Visit
(Visiter : in out Styx.Request_Visiters.Request_Visiter'Class;
Value : Stat_Request) is
begin
Visiter.Stat (Value);
end Visit;
-----------
-- Visit --
-----------
procedure Visit
(Visiter : in out Styx.Reply_Visiters.Reply_Visiter'Class;
Value : Stat_Reply) is
begin
Visiter.Stat (Value);
end Visit;
end Styx.Messages.Stats;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 57,064 | ads | -- This spec has been automatically generated from STM32F103.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.CAN is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CAN_MCR_INRQ_Field is STM32_SVD.Bit;
subtype CAN_MCR_SLEEP_Field is STM32_SVD.Bit;
subtype CAN_MCR_TXFP_Field is STM32_SVD.Bit;
subtype CAN_MCR_RFLM_Field is STM32_SVD.Bit;
subtype CAN_MCR_NART_Field is STM32_SVD.Bit;
subtype CAN_MCR_AWUM_Field is STM32_SVD.Bit;
subtype CAN_MCR_ABOM_Field is STM32_SVD.Bit;
subtype CAN_MCR_TTCM_Field is STM32_SVD.Bit;
subtype CAN_MCR_RESET_Field is STM32_SVD.Bit;
subtype CAN_MCR_DBF_Field is STM32_SVD.Bit;
-- CAN_MCR
type CAN_MCR_Register is record
-- INRQ
INRQ : CAN_MCR_INRQ_Field := 16#0#;
-- SLEEP
SLEEP : CAN_MCR_SLEEP_Field := 16#0#;
-- TXFP
TXFP : CAN_MCR_TXFP_Field := 16#0#;
-- RFLM
RFLM : CAN_MCR_RFLM_Field := 16#0#;
-- NART
NART : CAN_MCR_NART_Field := 16#0#;
-- AWUM
AWUM : CAN_MCR_AWUM_Field := 16#0#;
-- ABOM
ABOM : CAN_MCR_ABOM_Field := 16#0#;
-- TTCM
TTCM : CAN_MCR_TTCM_Field := 16#0#;
-- unspecified
Reserved_8_14 : STM32_SVD.UInt7 := 16#0#;
-- RESET
RESET : CAN_MCR_RESET_Field := 16#0#;
-- DBF
DBF : CAN_MCR_DBF_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_MCR_Register use record
INRQ at 0 range 0 .. 0;
SLEEP at 0 range 1 .. 1;
TXFP at 0 range 2 .. 2;
RFLM at 0 range 3 .. 3;
NART at 0 range 4 .. 4;
AWUM at 0 range 5 .. 5;
ABOM at 0 range 6 .. 6;
TTCM at 0 range 7 .. 7;
Reserved_8_14 at 0 range 8 .. 14;
RESET at 0 range 15 .. 15;
DBF at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype CAN_MSR_INAK_Field is STM32_SVD.Bit;
subtype CAN_MSR_SLAK_Field is STM32_SVD.Bit;
subtype CAN_MSR_ERRI_Field is STM32_SVD.Bit;
subtype CAN_MSR_WKUI_Field is STM32_SVD.Bit;
subtype CAN_MSR_SLAKI_Field is STM32_SVD.Bit;
subtype CAN_MSR_TXM_Field is STM32_SVD.Bit;
subtype CAN_MSR_RXM_Field is STM32_SVD.Bit;
subtype CAN_MSR_SAMP_Field is STM32_SVD.Bit;
subtype CAN_MSR_RX_Field is STM32_SVD.Bit;
-- CAN_MSR
type CAN_MSR_Register is record
-- Read-only. INAK
INAK : CAN_MSR_INAK_Field := 16#0#;
-- Read-only. SLAK
SLAK : CAN_MSR_SLAK_Field := 16#0#;
-- ERRI
ERRI : CAN_MSR_ERRI_Field := 16#0#;
-- WKUI
WKUI : CAN_MSR_WKUI_Field := 16#0#;
-- SLAKI
SLAKI : CAN_MSR_SLAKI_Field := 16#0#;
-- unspecified
Reserved_5_7 : STM32_SVD.UInt3 := 16#0#;
-- Read-only. TXM
TXM : CAN_MSR_TXM_Field := 16#0#;
-- Read-only. RXM
RXM : CAN_MSR_RXM_Field := 16#0#;
-- Read-only. SAMP
SAMP : CAN_MSR_SAMP_Field := 16#0#;
-- Read-only. RX
RX : CAN_MSR_RX_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_MSR_Register use record
INAK at 0 range 0 .. 0;
SLAK at 0 range 1 .. 1;
ERRI at 0 range 2 .. 2;
WKUI at 0 range 3 .. 3;
SLAKI at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
TXM at 0 range 8 .. 8;
RXM at 0 range 9 .. 9;
SAMP at 0 range 10 .. 10;
RX at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype CAN_TSR_RQCP0_Field is STM32_SVD.Bit;
subtype CAN_TSR_TXOK0_Field is STM32_SVD.Bit;
subtype CAN_TSR_ALST0_Field is STM32_SVD.Bit;
subtype CAN_TSR_TERR0_Field is STM32_SVD.Bit;
subtype CAN_TSR_ABRQ0_Field is STM32_SVD.Bit;
subtype CAN_TSR_RQCP1_Field is STM32_SVD.Bit;
subtype CAN_TSR_TXOK1_Field is STM32_SVD.Bit;
subtype CAN_TSR_ALST1_Field is STM32_SVD.Bit;
subtype CAN_TSR_TERR1_Field is STM32_SVD.Bit;
subtype CAN_TSR_ABRQ1_Field is STM32_SVD.Bit;
subtype CAN_TSR_RQCP2_Field is STM32_SVD.Bit;
subtype CAN_TSR_TXOK2_Field is STM32_SVD.Bit;
subtype CAN_TSR_ALST2_Field is STM32_SVD.Bit;
subtype CAN_TSR_TERR2_Field is STM32_SVD.Bit;
subtype CAN_TSR_ABRQ2_Field is STM32_SVD.Bit;
subtype CAN_TSR_CODE_Field is STM32_SVD.UInt2;
-- CAN_TSR_TME array element
subtype CAN_TSR_TME_Element is STM32_SVD.Bit;
-- CAN_TSR_TME array
type CAN_TSR_TME_Field_Array is array (0 .. 2) of CAN_TSR_TME_Element
with Component_Size => 1, Size => 3;
-- Type definition for CAN_TSR_TME
type CAN_TSR_TME_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TME as a value
Val : STM32_SVD.UInt3;
when True =>
-- TME as an array
Arr : CAN_TSR_TME_Field_Array;
end case;
end record
with Unchecked_Union, Size => 3;
for CAN_TSR_TME_Field use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- CAN_TSR_LOW array element
subtype CAN_TSR_LOW_Element is STM32_SVD.Bit;
-- CAN_TSR_LOW array
type CAN_TSR_LOW_Field_Array is array (0 .. 2) of CAN_TSR_LOW_Element
with Component_Size => 1, Size => 3;
-- Type definition for CAN_TSR_LOW
type CAN_TSR_LOW_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LOW as a value
Val : STM32_SVD.UInt3;
when True =>
-- LOW as an array
Arr : CAN_TSR_LOW_Field_Array;
end case;
end record
with Unchecked_Union, Size => 3;
for CAN_TSR_LOW_Field use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- CAN_TSR
type CAN_TSR_Register is record
-- RQCP0
RQCP0 : CAN_TSR_RQCP0_Field := 16#0#;
-- TXOK0
TXOK0 : CAN_TSR_TXOK0_Field := 16#0#;
-- ALST0
ALST0 : CAN_TSR_ALST0_Field := 16#0#;
-- TERR0
TERR0 : CAN_TSR_TERR0_Field := 16#0#;
-- unspecified
Reserved_4_6 : STM32_SVD.UInt3 := 16#0#;
-- ABRQ0
ABRQ0 : CAN_TSR_ABRQ0_Field := 16#0#;
-- RQCP1
RQCP1 : CAN_TSR_RQCP1_Field := 16#0#;
-- TXOK1
TXOK1 : CAN_TSR_TXOK1_Field := 16#0#;
-- ALST1
ALST1 : CAN_TSR_ALST1_Field := 16#0#;
-- TERR1
TERR1 : CAN_TSR_TERR1_Field := 16#0#;
-- unspecified
Reserved_12_14 : STM32_SVD.UInt3 := 16#0#;
-- ABRQ1
ABRQ1 : CAN_TSR_ABRQ1_Field := 16#0#;
-- RQCP2
RQCP2 : CAN_TSR_RQCP2_Field := 16#0#;
-- TXOK2
TXOK2 : CAN_TSR_TXOK2_Field := 16#0#;
-- ALST2
ALST2 : CAN_TSR_ALST2_Field := 16#0#;
-- TERR2
TERR2 : CAN_TSR_TERR2_Field := 16#0#;
-- unspecified
Reserved_20_22 : STM32_SVD.UInt3 := 16#0#;
-- ABRQ2
ABRQ2 : CAN_TSR_ABRQ2_Field := 16#0#;
-- Read-only. CODE
CODE : CAN_TSR_CODE_Field := 16#0#;
-- Read-only. Lowest priority flag for mailbox 0
TME : CAN_TSR_TME_Field := (As_Array => False, Val => 16#0#);
-- Read-only. Lowest priority flag for mailbox 0
LOW : CAN_TSR_LOW_Field := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TSR_Register use record
RQCP0 at 0 range 0 .. 0;
TXOK0 at 0 range 1 .. 1;
ALST0 at 0 range 2 .. 2;
TERR0 at 0 range 3 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
ABRQ0 at 0 range 7 .. 7;
RQCP1 at 0 range 8 .. 8;
TXOK1 at 0 range 9 .. 9;
ALST1 at 0 range 10 .. 10;
TERR1 at 0 range 11 .. 11;
Reserved_12_14 at 0 range 12 .. 14;
ABRQ1 at 0 range 15 .. 15;
RQCP2 at 0 range 16 .. 16;
TXOK2 at 0 range 17 .. 17;
ALST2 at 0 range 18 .. 18;
TERR2 at 0 range 19 .. 19;
Reserved_20_22 at 0 range 20 .. 22;
ABRQ2 at 0 range 23 .. 23;
CODE at 0 range 24 .. 25;
TME at 0 range 26 .. 28;
LOW at 0 range 29 .. 31;
end record;
subtype CAN_RF0R_FMP0_Field is STM32_SVD.UInt2;
subtype CAN_RF0R_FULL0_Field is STM32_SVD.Bit;
subtype CAN_RF0R_FOVR0_Field is STM32_SVD.Bit;
subtype CAN_RF0R_RFOM0_Field is STM32_SVD.Bit;
-- CAN_RF0R
type CAN_RF0R_Register is record
-- Read-only. FMP0
FMP0 : CAN_RF0R_FMP0_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- FULL0
FULL0 : CAN_RF0R_FULL0_Field := 16#0#;
-- FOVR0
FOVR0 : CAN_RF0R_FOVR0_Field := 16#0#;
-- RFOM0
RFOM0 : CAN_RF0R_RFOM0_Field := 16#0#;
-- unspecified
Reserved_6_31 : STM32_SVD.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_RF0R_Register use record
FMP0 at 0 range 0 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
FULL0 at 0 range 3 .. 3;
FOVR0 at 0 range 4 .. 4;
RFOM0 at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype CAN_RF1R_FMP1_Field is STM32_SVD.UInt2;
subtype CAN_RF1R_FULL1_Field is STM32_SVD.Bit;
subtype CAN_RF1R_FOVR1_Field is STM32_SVD.Bit;
subtype CAN_RF1R_RFOM1_Field is STM32_SVD.Bit;
-- CAN_RF1R
type CAN_RF1R_Register is record
-- Read-only. FMP1
FMP1 : CAN_RF1R_FMP1_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- FULL1
FULL1 : CAN_RF1R_FULL1_Field := 16#0#;
-- FOVR1
FOVR1 : CAN_RF1R_FOVR1_Field := 16#0#;
-- RFOM1
RFOM1 : CAN_RF1R_RFOM1_Field := 16#0#;
-- unspecified
Reserved_6_31 : STM32_SVD.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_RF1R_Register use record
FMP1 at 0 range 0 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
FULL1 at 0 range 3 .. 3;
FOVR1 at 0 range 4 .. 4;
RFOM1 at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype CAN_IER_TMEIE_Field is STM32_SVD.Bit;
subtype CAN_IER_FMPIE0_Field is STM32_SVD.Bit;
subtype CAN_IER_FFIE0_Field is STM32_SVD.Bit;
subtype CAN_IER_FOVIE0_Field is STM32_SVD.Bit;
subtype CAN_IER_FMPIE1_Field is STM32_SVD.Bit;
subtype CAN_IER_FFIE1_Field is STM32_SVD.Bit;
subtype CAN_IER_FOVIE1_Field is STM32_SVD.Bit;
subtype CAN_IER_EWGIE_Field is STM32_SVD.Bit;
subtype CAN_IER_EPVIE_Field is STM32_SVD.Bit;
subtype CAN_IER_BOFIE_Field is STM32_SVD.Bit;
subtype CAN_IER_LECIE_Field is STM32_SVD.Bit;
subtype CAN_IER_ERRIE_Field is STM32_SVD.Bit;
subtype CAN_IER_WKUIE_Field is STM32_SVD.Bit;
subtype CAN_IER_SLKIE_Field is STM32_SVD.Bit;
-- CAN_IER
type CAN_IER_Register is record
-- TMEIE
TMEIE : CAN_IER_TMEIE_Field := 16#0#;
-- FMPIE0
FMPIE0 : CAN_IER_FMPIE0_Field := 16#0#;
-- FFIE0
FFIE0 : CAN_IER_FFIE0_Field := 16#0#;
-- FOVIE0
FOVIE0 : CAN_IER_FOVIE0_Field := 16#0#;
-- FMPIE1
FMPIE1 : CAN_IER_FMPIE1_Field := 16#0#;
-- FFIE1
FFIE1 : CAN_IER_FFIE1_Field := 16#0#;
-- FOVIE1
FOVIE1 : CAN_IER_FOVIE1_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- EWGIE
EWGIE : CAN_IER_EWGIE_Field := 16#0#;
-- EPVIE
EPVIE : CAN_IER_EPVIE_Field := 16#0#;
-- BOFIE
BOFIE : CAN_IER_BOFIE_Field := 16#0#;
-- LECIE
LECIE : CAN_IER_LECIE_Field := 16#0#;
-- unspecified
Reserved_12_14 : STM32_SVD.UInt3 := 16#0#;
-- ERRIE
ERRIE : CAN_IER_ERRIE_Field := 16#0#;
-- WKUIE
WKUIE : CAN_IER_WKUIE_Field := 16#0#;
-- SLKIE
SLKIE : CAN_IER_SLKIE_Field := 16#0#;
-- unspecified
Reserved_18_31 : STM32_SVD.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_IER_Register use record
TMEIE at 0 range 0 .. 0;
FMPIE0 at 0 range 1 .. 1;
FFIE0 at 0 range 2 .. 2;
FOVIE0 at 0 range 3 .. 3;
FMPIE1 at 0 range 4 .. 4;
FFIE1 at 0 range 5 .. 5;
FOVIE1 at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
EWGIE at 0 range 8 .. 8;
EPVIE at 0 range 9 .. 9;
BOFIE at 0 range 10 .. 10;
LECIE at 0 range 11 .. 11;
Reserved_12_14 at 0 range 12 .. 14;
ERRIE at 0 range 15 .. 15;
WKUIE at 0 range 16 .. 16;
SLKIE at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype CAN_ESR_EWGF_Field is STM32_SVD.Bit;
subtype CAN_ESR_EPVF_Field is STM32_SVD.Bit;
subtype CAN_ESR_BOFF_Field is STM32_SVD.Bit;
subtype CAN_ESR_LEC_Field is STM32_SVD.UInt3;
subtype CAN_ESR_TEC_Field is STM32_SVD.Byte;
subtype CAN_ESR_REC_Field is STM32_SVD.Byte;
-- CAN_ESR
type CAN_ESR_Register is record
-- Read-only. EWGF
EWGF : CAN_ESR_EWGF_Field := 16#0#;
-- Read-only. EPVF
EPVF : CAN_ESR_EPVF_Field := 16#0#;
-- Read-only. BOFF
BOFF : CAN_ESR_BOFF_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- LEC
LEC : CAN_ESR_LEC_Field := 16#0#;
-- unspecified
Reserved_7_15 : STM32_SVD.UInt9 := 16#0#;
-- Read-only. TEC
TEC : CAN_ESR_TEC_Field := 16#0#;
-- Read-only. REC
REC : CAN_ESR_REC_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_ESR_Register use record
EWGF at 0 range 0 .. 0;
EPVF at 0 range 1 .. 1;
BOFF at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
LEC at 0 range 4 .. 6;
Reserved_7_15 at 0 range 7 .. 15;
TEC at 0 range 16 .. 23;
REC at 0 range 24 .. 31;
end record;
subtype CAN_BTR_BRP_Field is STM32_SVD.UInt10;
subtype CAN_BTR_TS1_Field is STM32_SVD.UInt4;
subtype CAN_BTR_TS2_Field is STM32_SVD.UInt3;
subtype CAN_BTR_SJW_Field is STM32_SVD.UInt2;
subtype CAN_BTR_LBKM_Field is STM32_SVD.Bit;
subtype CAN_BTR_SILM_Field is STM32_SVD.Bit;
-- CAN_BTR
type CAN_BTR_Register is record
-- BRP
BRP : CAN_BTR_BRP_Field := 16#0#;
-- unspecified
Reserved_10_15 : STM32_SVD.UInt6 := 16#0#;
-- TS1
TS1 : CAN_BTR_TS1_Field := 16#0#;
-- TS2
TS2 : CAN_BTR_TS2_Field := 16#0#;
-- unspecified
Reserved_23_23 : STM32_SVD.Bit := 16#0#;
-- SJW
SJW : CAN_BTR_SJW_Field := 16#0#;
-- unspecified
Reserved_26_29 : STM32_SVD.UInt4 := 16#0#;
-- LBKM
LBKM : CAN_BTR_LBKM_Field := 16#0#;
-- SILM
SILM : CAN_BTR_SILM_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_BTR_Register use record
BRP at 0 range 0 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
TS1 at 0 range 16 .. 19;
TS2 at 0 range 20 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
SJW at 0 range 24 .. 25;
Reserved_26_29 at 0 range 26 .. 29;
LBKM at 0 range 30 .. 30;
SILM at 0 range 31 .. 31;
end record;
subtype CAN_TI0R_TXRQ_Field is STM32_SVD.Bit;
subtype CAN_TI0R_RTR_Field is STM32_SVD.Bit;
subtype CAN_TI0R_IDE_Field is STM32_SVD.Bit;
subtype CAN_TI0R_EXID_Field is STM32_SVD.UInt18;
subtype CAN_TI0R_STID_Field is STM32_SVD.UInt11;
-- CAN_TI0R
type CAN_TI0R_Register is record
-- TXRQ
TXRQ : CAN_TI0R_TXRQ_Field := 16#0#;
-- RTR
RTR : CAN_TI0R_RTR_Field := 16#0#;
-- IDE
IDE : CAN_TI0R_IDE_Field := 16#0#;
-- EXID
EXID : CAN_TI0R_EXID_Field := 16#0#;
-- STID
STID : CAN_TI0R_STID_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TI0R_Register use record
TXRQ at 0 range 0 .. 0;
RTR at 0 range 1 .. 1;
IDE at 0 range 2 .. 2;
EXID at 0 range 3 .. 20;
STID at 0 range 21 .. 31;
end record;
subtype CAN_TDT0R_DLC_Field is STM32_SVD.UInt4;
subtype CAN_TDT0R_TGT_Field is STM32_SVD.Bit;
subtype CAN_TDT0R_TIME_Field is STM32_SVD.UInt16;
-- CAN_TDT0R
type CAN_TDT0R_Register is record
-- DLC
DLC : CAN_TDT0R_DLC_Field := 16#0#;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4 := 16#0#;
-- TGT
TGT : CAN_TDT0R_TGT_Field := 16#0#;
-- unspecified
Reserved_9_15 : STM32_SVD.UInt7 := 16#0#;
-- TIME
TIME : CAN_TDT0R_TIME_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TDT0R_Register use record
DLC at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
TGT at 0 range 8 .. 8;
Reserved_9_15 at 0 range 9 .. 15;
TIME at 0 range 16 .. 31;
end record;
-- CAN_TDL0R_DATA array element
subtype CAN_TDL0R_DATA_Element is STM32_SVD.Byte;
-- CAN_TDL0R_DATA array
type CAN_TDL0R_DATA_Field_Array is array (0 .. 3)
of CAN_TDL0R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_TDL0R
type CAN_TDL0R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_TDL0R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_TDL0R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- CAN_TDH0R_DATA array element
subtype CAN_TDH0R_DATA_Element is STM32_SVD.Byte;
-- CAN_TDH0R_DATA array
type CAN_TDH0R_DATA_Field_Array is array (4 .. 7)
of CAN_TDH0R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_TDH0R
type CAN_TDH0R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_TDH0R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_TDH0R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype CAN_TI1R_TXRQ_Field is STM32_SVD.Bit;
subtype CAN_TI1R_RTR_Field is STM32_SVD.Bit;
subtype CAN_TI1R_IDE_Field is STM32_SVD.Bit;
subtype CAN_TI1R_EXID_Field is STM32_SVD.UInt18;
subtype CAN_TI1R_STID_Field is STM32_SVD.UInt11;
-- CAN_TI1R
type CAN_TI1R_Register is record
-- TXRQ
TXRQ : CAN_TI1R_TXRQ_Field := 16#0#;
-- RTR
RTR : CAN_TI1R_RTR_Field := 16#0#;
-- IDE
IDE : CAN_TI1R_IDE_Field := 16#0#;
-- EXID
EXID : CAN_TI1R_EXID_Field := 16#0#;
-- STID
STID : CAN_TI1R_STID_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TI1R_Register use record
TXRQ at 0 range 0 .. 0;
RTR at 0 range 1 .. 1;
IDE at 0 range 2 .. 2;
EXID at 0 range 3 .. 20;
STID at 0 range 21 .. 31;
end record;
subtype CAN_TDT1R_DLC_Field is STM32_SVD.UInt4;
subtype CAN_TDT1R_TGT_Field is STM32_SVD.Bit;
subtype CAN_TDT1R_TIME_Field is STM32_SVD.UInt16;
-- CAN_TDT1R
type CAN_TDT1R_Register is record
-- DLC
DLC : CAN_TDT1R_DLC_Field := 16#0#;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4 := 16#0#;
-- TGT
TGT : CAN_TDT1R_TGT_Field := 16#0#;
-- unspecified
Reserved_9_15 : STM32_SVD.UInt7 := 16#0#;
-- TIME
TIME : CAN_TDT1R_TIME_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TDT1R_Register use record
DLC at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
TGT at 0 range 8 .. 8;
Reserved_9_15 at 0 range 9 .. 15;
TIME at 0 range 16 .. 31;
end record;
-- CAN_TDL1R_DATA array element
subtype CAN_TDL1R_DATA_Element is STM32_SVD.Byte;
-- CAN_TDL1R_DATA array
type CAN_TDL1R_DATA_Field_Array is array (0 .. 3)
of CAN_TDL1R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_TDL1R
type CAN_TDL1R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_TDL1R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_TDL1R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- CAN_TDH1R_DATA array element
subtype CAN_TDH1R_DATA_Element is STM32_SVD.Byte;
-- CAN_TDH1R_DATA array
type CAN_TDH1R_DATA_Field_Array is array (4 .. 7)
of CAN_TDH1R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_TDH1R
type CAN_TDH1R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_TDH1R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_TDH1R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype CAN_TI2R_TXRQ_Field is STM32_SVD.Bit;
subtype CAN_TI2R_RTR_Field is STM32_SVD.Bit;
subtype CAN_TI2R_IDE_Field is STM32_SVD.Bit;
subtype CAN_TI2R_EXID_Field is STM32_SVD.UInt18;
subtype CAN_TI2R_STID_Field is STM32_SVD.UInt11;
-- CAN_TI2R
type CAN_TI2R_Register is record
-- TXRQ
TXRQ : CAN_TI2R_TXRQ_Field := 16#0#;
-- RTR
RTR : CAN_TI2R_RTR_Field := 16#0#;
-- IDE
IDE : CAN_TI2R_IDE_Field := 16#0#;
-- EXID
EXID : CAN_TI2R_EXID_Field := 16#0#;
-- STID
STID : CAN_TI2R_STID_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TI2R_Register use record
TXRQ at 0 range 0 .. 0;
RTR at 0 range 1 .. 1;
IDE at 0 range 2 .. 2;
EXID at 0 range 3 .. 20;
STID at 0 range 21 .. 31;
end record;
subtype CAN_TDT2R_DLC_Field is STM32_SVD.UInt4;
subtype CAN_TDT2R_TGT_Field is STM32_SVD.Bit;
subtype CAN_TDT2R_TIME_Field is STM32_SVD.UInt16;
-- CAN_TDT2R
type CAN_TDT2R_Register is record
-- DLC
DLC : CAN_TDT2R_DLC_Field := 16#0#;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4 := 16#0#;
-- TGT
TGT : CAN_TDT2R_TGT_Field := 16#0#;
-- unspecified
Reserved_9_15 : STM32_SVD.UInt7 := 16#0#;
-- TIME
TIME : CAN_TDT2R_TIME_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_TDT2R_Register use record
DLC at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
TGT at 0 range 8 .. 8;
Reserved_9_15 at 0 range 9 .. 15;
TIME at 0 range 16 .. 31;
end record;
-- CAN_TDL2R_DATA array element
subtype CAN_TDL2R_DATA_Element is STM32_SVD.Byte;
-- CAN_TDL2R_DATA array
type CAN_TDL2R_DATA_Field_Array is array (0 .. 3)
of CAN_TDL2R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_TDL2R
type CAN_TDL2R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_TDL2R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_TDL2R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- CAN_TDH2R_DATA array element
subtype CAN_TDH2R_DATA_Element is STM32_SVD.Byte;
-- CAN_TDH2R_DATA array
type CAN_TDH2R_DATA_Field_Array is array (4 .. 7)
of CAN_TDH2R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_TDH2R
type CAN_TDH2R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_TDH2R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_TDH2R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype CAN_RI0R_RTR_Field is STM32_SVD.Bit;
subtype CAN_RI0R_IDE_Field is STM32_SVD.Bit;
subtype CAN_RI0R_EXID_Field is STM32_SVD.UInt18;
subtype CAN_RI0R_STID_Field is STM32_SVD.UInt11;
-- CAN_RI0R
type CAN_RI0R_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit;
-- Read-only. RTR
RTR : CAN_RI0R_RTR_Field;
-- Read-only. IDE
IDE : CAN_RI0R_IDE_Field;
-- Read-only. EXID
EXID : CAN_RI0R_EXID_Field;
-- Read-only. STID
STID : CAN_RI0R_STID_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_RI0R_Register use record
Reserved_0_0 at 0 range 0 .. 0;
RTR at 0 range 1 .. 1;
IDE at 0 range 2 .. 2;
EXID at 0 range 3 .. 20;
STID at 0 range 21 .. 31;
end record;
subtype CAN_RDT0R_DLC_Field is STM32_SVD.UInt4;
subtype CAN_RDT0R_FMI_Field is STM32_SVD.Byte;
subtype CAN_RDT0R_TIME_Field is STM32_SVD.UInt16;
-- CAN_RDT0R
type CAN_RDT0R_Register is record
-- Read-only. DLC
DLC : CAN_RDT0R_DLC_Field;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4;
-- Read-only. FMI
FMI : CAN_RDT0R_FMI_Field;
-- Read-only. TIME
TIME : CAN_RDT0R_TIME_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_RDT0R_Register use record
DLC at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
FMI at 0 range 8 .. 15;
TIME at 0 range 16 .. 31;
end record;
-- CAN_RDL0R_DATA array element
subtype CAN_RDL0R_DATA_Element is STM32_SVD.Byte;
-- CAN_RDL0R_DATA array
type CAN_RDL0R_DATA_Field_Array is array (0 .. 3)
of CAN_RDL0R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_RDL0R
type CAN_RDL0R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_RDL0R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_RDL0R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- CAN_RDH0R_DATA array element
subtype CAN_RDH0R_DATA_Element is STM32_SVD.Byte;
-- CAN_RDH0R_DATA array
type CAN_RDH0R_DATA_Field_Array is array (4 .. 7)
of CAN_RDH0R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_RDH0R
type CAN_RDH0R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_RDH0R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_RDH0R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype CAN_RI1R_RTR_Field is STM32_SVD.Bit;
subtype CAN_RI1R_IDE_Field is STM32_SVD.Bit;
subtype CAN_RI1R_EXID_Field is STM32_SVD.UInt18;
subtype CAN_RI1R_STID_Field is STM32_SVD.UInt11;
-- CAN_RI1R
type CAN_RI1R_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit;
-- Read-only. RTR
RTR : CAN_RI1R_RTR_Field;
-- Read-only. IDE
IDE : CAN_RI1R_IDE_Field;
-- Read-only. EXID
EXID : CAN_RI1R_EXID_Field;
-- Read-only. STID
STID : CAN_RI1R_STID_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_RI1R_Register use record
Reserved_0_0 at 0 range 0 .. 0;
RTR at 0 range 1 .. 1;
IDE at 0 range 2 .. 2;
EXID at 0 range 3 .. 20;
STID at 0 range 21 .. 31;
end record;
subtype CAN_RDT1R_DLC_Field is STM32_SVD.UInt4;
subtype CAN_RDT1R_FMI_Field is STM32_SVD.Byte;
subtype CAN_RDT1R_TIME_Field is STM32_SVD.UInt16;
-- CAN_RDT1R
type CAN_RDT1R_Register is record
-- Read-only. DLC
DLC : CAN_RDT1R_DLC_Field;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4;
-- Read-only. FMI
FMI : CAN_RDT1R_FMI_Field;
-- Read-only. TIME
TIME : CAN_RDT1R_TIME_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_RDT1R_Register use record
DLC at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
FMI at 0 range 8 .. 15;
TIME at 0 range 16 .. 31;
end record;
-- CAN_RDL1R_DATA array element
subtype CAN_RDL1R_DATA_Element is STM32_SVD.Byte;
-- CAN_RDL1R_DATA array
type CAN_RDL1R_DATA_Field_Array is array (0 .. 3)
of CAN_RDL1R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_RDL1R
type CAN_RDL1R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_RDL1R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_RDL1R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- CAN_RDH1R_DATA array element
subtype CAN_RDH1R_DATA_Element is STM32_SVD.Byte;
-- CAN_RDH1R_DATA array
type CAN_RDH1R_DATA_Field_Array is array (4 .. 7)
of CAN_RDH1R_DATA_Element
with Component_Size => 8, Size => 32;
-- CAN_RDH1R
type CAN_RDH1R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : STM32_SVD.UInt32;
when True =>
-- DATA as an array
Arr : CAN_RDH1R_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CAN_RDH1R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
subtype CAN_FMR_FINIT_Field is STM32_SVD.Bit;
-- CAN_FMR
type CAN_FMR_Register is record
-- FINIT
FINIT : CAN_FMR_FINIT_Field := 16#0#;
-- unspecified
Reserved_1_31 : STM32_SVD.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_FMR_Register use record
FINIT at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- CAN_FM1R_FBM array element
subtype CAN_FM1R_FBM_Element is STM32_SVD.Bit;
-- CAN_FM1R_FBM array
type CAN_FM1R_FBM_Field_Array is array (0 .. 13) of CAN_FM1R_FBM_Element
with Component_Size => 1, Size => 14;
-- Type definition for CAN_FM1R_FBM
type CAN_FM1R_FBM_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FBM as a value
Val : STM32_SVD.UInt14;
when True =>
-- FBM as an array
Arr : CAN_FM1R_FBM_Field_Array;
end case;
end record
with Unchecked_Union, Size => 14;
for CAN_FM1R_FBM_Field use record
Val at 0 range 0 .. 13;
Arr at 0 range 0 .. 13;
end record;
-- CAN_FM1R
type CAN_FM1R_Register is record
-- Filter mode
FBM : CAN_FM1R_FBM_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : STM32_SVD.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_FM1R_Register use record
FBM at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- CAN_FS1R_FSC array element
subtype CAN_FS1R_FSC_Element is STM32_SVD.Bit;
-- CAN_FS1R_FSC array
type CAN_FS1R_FSC_Field_Array is array (0 .. 13) of CAN_FS1R_FSC_Element
with Component_Size => 1, Size => 14;
-- Type definition for CAN_FS1R_FSC
type CAN_FS1R_FSC_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FSC as a value
Val : STM32_SVD.UInt14;
when True =>
-- FSC as an array
Arr : CAN_FS1R_FSC_Field_Array;
end case;
end record
with Unchecked_Union, Size => 14;
for CAN_FS1R_FSC_Field use record
Val at 0 range 0 .. 13;
Arr at 0 range 0 .. 13;
end record;
-- CAN_FS1R
type CAN_FS1R_Register is record
-- Filter scale configuration
FSC : CAN_FS1R_FSC_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : STM32_SVD.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_FS1R_Register use record
FSC at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- CAN_FFA1R_FFA array element
subtype CAN_FFA1R_FFA_Element is STM32_SVD.Bit;
-- CAN_FFA1R_FFA array
type CAN_FFA1R_FFA_Field_Array is array (0 .. 13) of CAN_FFA1R_FFA_Element
with Component_Size => 1, Size => 14;
-- Type definition for CAN_FFA1R_FFA
type CAN_FFA1R_FFA_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FFA as a value
Val : STM32_SVD.UInt14;
when True =>
-- FFA as an array
Arr : CAN_FFA1R_FFA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 14;
for CAN_FFA1R_FFA_Field use record
Val at 0 range 0 .. 13;
Arr at 0 range 0 .. 13;
end record;
-- CAN_FFA1R
type CAN_FFA1R_Register is record
-- Filter FIFO assignment for filter 0
FFA : CAN_FFA1R_FFA_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : STM32_SVD.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_FFA1R_Register use record
FFA at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- CAN_FA1R_FACT array element
subtype CAN_FA1R_FACT_Element is STM32_SVD.Bit;
-- CAN_FA1R_FACT array
type CAN_FA1R_FACT_Field_Array is array (0 .. 13) of CAN_FA1R_FACT_Element
with Component_Size => 1, Size => 14;
-- Type definition for CAN_FA1R_FACT
type CAN_FA1R_FACT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FACT as a value
Val : STM32_SVD.UInt14;
when True =>
-- FACT as an array
Arr : CAN_FA1R_FACT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 14;
for CAN_FA1R_FACT_Field use record
Val at 0 range 0 .. 13;
Arr at 0 range 0 .. 13;
end record;
-- CAN_FA1R
type CAN_FA1R_Register is record
-- Filter active
FACT : CAN_FA1R_FACT_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : STM32_SVD.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAN_FA1R_Register use record
FACT at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- F0R_FB array element
subtype F0R_FB_Element is STM32_SVD.Bit;
-- F0R_FB array
type F0R_FB_Field_Array is array (0 .. 31) of F0R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 0 register 1
type F0R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F0R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F0R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F1R_FB array element
subtype F1R_FB_Element is STM32_SVD.Bit;
-- F1R_FB array
type F1R_FB_Field_Array is array (0 .. 31) of F1R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 1 register 1
type F1R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F1R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F1R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F2R_FB array element
subtype F2R_FB_Element is STM32_SVD.Bit;
-- F2R_FB array
type F2R_FB_Field_Array is array (0 .. 31) of F2R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 2 register 1
type F2R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F2R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F2R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F3R_FB array element
subtype F3R_FB_Element is STM32_SVD.Bit;
-- F3R_FB array
type F3R_FB_Field_Array is array (0 .. 31) of F3R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 3 register 1
type F3R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F3R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F3R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F4R_FB array element
subtype F4R_FB_Element is STM32_SVD.Bit;
-- F4R_FB array
type F4R_FB_Field_Array is array (0 .. 31) of F4R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 4 register 1
type F4R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F4R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F4R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F5R_FB array element
subtype F5R_FB_Element is STM32_SVD.Bit;
-- F5R_FB array
type F5R_FB_Field_Array is array (0 .. 31) of F5R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 5 register 1
type F5R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F5R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F5R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F6R_FB array element
subtype F6R_FB_Element is STM32_SVD.Bit;
-- F6R_FB array
type F6R_FB_Field_Array is array (0 .. 31) of F6R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 6 register 1
type F6R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F6R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F6R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F7R_FB array element
subtype F7R_FB_Element is STM32_SVD.Bit;
-- F7R_FB array
type F7R_FB_Field_Array is array (0 .. 31) of F7R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 7 register 1
type F7R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F7R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F7R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F8R_FB array element
subtype F8R_FB_Element is STM32_SVD.Bit;
-- F8R_FB array
type F8R_FB_Field_Array is array (0 .. 31) of F8R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 8 register 1
type F8R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F8R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F8R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F9R_FB array element
subtype F9R_FB_Element is STM32_SVD.Bit;
-- F9R_FB array
type F9R_FB_Field_Array is array (0 .. 31) of F9R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 9 register 1
type F9R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F9R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F9R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F10R_FB array element
subtype F10R_FB_Element is STM32_SVD.Bit;
-- F10R_FB array
type F10R_FB_Field_Array is array (0 .. 31) of F10R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 10 register 1
type F10R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F10R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F10R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F11R_FB array element
subtype F11R_FB_Element is STM32_SVD.Bit;
-- F11R_FB array
type F11R_FB_Field_Array is array (0 .. 31) of F11R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 11 register 1
type F11R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F11R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F11R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F12R_FB array element
subtype F12R_FB_Element is STM32_SVD.Bit;
-- F12R_FB array
type F12R_FB_Field_Array is array (0 .. 31) of F12R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 4 register 1
type F12R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F12R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F12R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- F13R_FB array element
subtype F13R_FB_Element is STM32_SVD.Bit;
-- F13R_FB array
type F13R_FB_Field_Array is array (0 .. 31) of F13R_FB_Element
with Component_Size => 1, Size => 32;
-- Filter bank 13 register 1
type F13R_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- FB as a value
Val : STM32_SVD.UInt32;
when True =>
-- FB as an array
Arr : F13R_FB_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for F13R_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Controller area network
type CAN_Peripheral is record
-- CAN_MCR
CAN_MCR : aliased CAN_MCR_Register;
-- CAN_MSR
CAN_MSR : aliased CAN_MSR_Register;
-- CAN_TSR
CAN_TSR : aliased CAN_TSR_Register;
-- CAN_RF0R
CAN_RF0R : aliased CAN_RF0R_Register;
-- CAN_RF1R
CAN_RF1R : aliased CAN_RF1R_Register;
-- CAN_IER
CAN_IER : aliased CAN_IER_Register;
-- CAN_ESR
CAN_ESR : aliased CAN_ESR_Register;
-- CAN_BTR
CAN_BTR : aliased CAN_BTR_Register;
-- CAN_TI0R
CAN_TI0R : aliased CAN_TI0R_Register;
-- CAN_TDT0R
CAN_TDT0R : aliased CAN_TDT0R_Register;
-- CAN_TDL0R
CAN_TDL0R : aliased CAN_TDL0R_Register;
-- CAN_TDH0R
CAN_TDH0R : aliased CAN_TDH0R_Register;
-- CAN_TI1R
CAN_TI1R : aliased CAN_TI1R_Register;
-- CAN_TDT1R
CAN_TDT1R : aliased CAN_TDT1R_Register;
-- CAN_TDL1R
CAN_TDL1R : aliased CAN_TDL1R_Register;
-- CAN_TDH1R
CAN_TDH1R : aliased CAN_TDH1R_Register;
-- CAN_TI2R
CAN_TI2R : aliased CAN_TI2R_Register;
-- CAN_TDT2R
CAN_TDT2R : aliased CAN_TDT2R_Register;
-- CAN_TDL2R
CAN_TDL2R : aliased CAN_TDL2R_Register;
-- CAN_TDH2R
CAN_TDH2R : aliased CAN_TDH2R_Register;
-- CAN_RI0R
CAN_RI0R : aliased CAN_RI0R_Register;
-- CAN_RDT0R
CAN_RDT0R : aliased CAN_RDT0R_Register;
-- CAN_RDL0R
CAN_RDL0R : aliased CAN_RDL0R_Register;
-- CAN_RDH0R
CAN_RDH0R : aliased CAN_RDH0R_Register;
-- CAN_RI1R
CAN_RI1R : aliased CAN_RI1R_Register;
-- CAN_RDT1R
CAN_RDT1R : aliased CAN_RDT1R_Register;
-- CAN_RDL1R
CAN_RDL1R : aliased CAN_RDL1R_Register;
-- CAN_RDH1R
CAN_RDH1R : aliased CAN_RDH1R_Register;
-- CAN_FMR
CAN_FMR : aliased CAN_FMR_Register;
-- CAN_FM1R
CAN_FM1R : aliased CAN_FM1R_Register;
-- CAN_FS1R
CAN_FS1R : aliased CAN_FS1R_Register;
-- CAN_FFA1R
CAN_FFA1R : aliased CAN_FFA1R_Register;
-- CAN_FA1R
CAN_FA1R : aliased CAN_FA1R_Register;
-- Filter bank 0 register 1
F0R1 : aliased F0R_Register;
-- Filter bank 0 register 2
F0R2 : aliased F0R_Register;
-- Filter bank 1 register 1
F1R1 : aliased F1R_Register;
-- Filter bank 1 register 2
F1R2 : aliased F1R_Register;
-- Filter bank 2 register 1
F2R1 : aliased F2R_Register;
-- Filter bank 2 register 2
F2R2 : aliased F2R_Register;
-- Filter bank 3 register 1
F3R1 : aliased F3R_Register;
-- Filter bank 3 register 2
F3R2 : aliased F3R_Register;
-- Filter bank 4 register 1
F4R1 : aliased F4R_Register;
-- Filter bank 4 register 2
F4R2 : aliased F4R_Register;
-- Filter bank 5 register 1
F5R1 : aliased F5R_Register;
-- Filter bank 5 register 2
F5R2 : aliased F5R_Register;
-- Filter bank 6 register 1
F6R1 : aliased F6R_Register;
-- Filter bank 6 register 2
F6R2 : aliased F6R_Register;
-- Filter bank 7 register 1
F7R1 : aliased F7R_Register;
-- Filter bank 7 register 2
F7R2 : aliased F7R_Register;
-- Filter bank 8 register 1
F8R1 : aliased F8R_Register;
-- Filter bank 8 register 2
F8R2 : aliased F8R_Register;
-- Filter bank 9 register 1
F9R1 : aliased F9R_Register;
-- Filter bank 9 register 2
F9R2 : aliased F9R_Register;
-- Filter bank 10 register 1
F10R1 : aliased F10R_Register;
-- Filter bank 10 register 2
F10R2 : aliased F10R_Register;
-- Filter bank 11 register 1
F11R1 : aliased F11R_Register;
-- Filter bank 11 register 2
F11R2 : aliased F11R_Register;
-- Filter bank 4 register 1
F12R1 : aliased F12R_Register;
-- Filter bank 12 register 2
F12R2 : aliased F12R_Register;
-- Filter bank 13 register 1
F13R1 : aliased F13R_Register;
-- Filter bank 13 register 2
F13R2 : aliased F13R_Register;
end record
with Volatile;
for CAN_Peripheral use record
CAN_MCR at 16#0# range 0 .. 31;
CAN_MSR at 16#4# range 0 .. 31;
CAN_TSR at 16#8# range 0 .. 31;
CAN_RF0R at 16#C# range 0 .. 31;
CAN_RF1R at 16#10# range 0 .. 31;
CAN_IER at 16#14# range 0 .. 31;
CAN_ESR at 16#18# range 0 .. 31;
CAN_BTR at 16#1C# range 0 .. 31;
CAN_TI0R at 16#180# range 0 .. 31;
CAN_TDT0R at 16#184# range 0 .. 31;
CAN_TDL0R at 16#188# range 0 .. 31;
CAN_TDH0R at 16#18C# range 0 .. 31;
CAN_TI1R at 16#190# range 0 .. 31;
CAN_TDT1R at 16#194# range 0 .. 31;
CAN_TDL1R at 16#198# range 0 .. 31;
CAN_TDH1R at 16#19C# range 0 .. 31;
CAN_TI2R at 16#1A0# range 0 .. 31;
CAN_TDT2R at 16#1A4# range 0 .. 31;
CAN_TDL2R at 16#1A8# range 0 .. 31;
CAN_TDH2R at 16#1AC# range 0 .. 31;
CAN_RI0R at 16#1B0# range 0 .. 31;
CAN_RDT0R at 16#1B4# range 0 .. 31;
CAN_RDL0R at 16#1B8# range 0 .. 31;
CAN_RDH0R at 16#1BC# range 0 .. 31;
CAN_RI1R at 16#1C0# range 0 .. 31;
CAN_RDT1R at 16#1C4# range 0 .. 31;
CAN_RDL1R at 16#1C8# range 0 .. 31;
CAN_RDH1R at 16#1CC# range 0 .. 31;
CAN_FMR at 16#200# range 0 .. 31;
CAN_FM1R at 16#204# range 0 .. 31;
CAN_FS1R at 16#20C# range 0 .. 31;
CAN_FFA1R at 16#214# range 0 .. 31;
CAN_FA1R at 16#21C# range 0 .. 31;
F0R1 at 16#240# range 0 .. 31;
F0R2 at 16#244# range 0 .. 31;
F1R1 at 16#248# range 0 .. 31;
F1R2 at 16#24C# range 0 .. 31;
F2R1 at 16#250# range 0 .. 31;
F2R2 at 16#254# range 0 .. 31;
F3R1 at 16#258# range 0 .. 31;
F3R2 at 16#25C# range 0 .. 31;
F4R1 at 16#260# range 0 .. 31;
F4R2 at 16#264# range 0 .. 31;
F5R1 at 16#268# range 0 .. 31;
F5R2 at 16#26C# range 0 .. 31;
F6R1 at 16#270# range 0 .. 31;
F6R2 at 16#274# range 0 .. 31;
F7R1 at 16#278# range 0 .. 31;
F7R2 at 16#27C# range 0 .. 31;
F8R1 at 16#280# range 0 .. 31;
F8R2 at 16#284# range 0 .. 31;
F9R1 at 16#288# range 0 .. 31;
F9R2 at 16#28C# range 0 .. 31;
F10R1 at 16#290# range 0 .. 31;
F10R2 at 16#294# range 0 .. 31;
F11R1 at 16#298# range 0 .. 31;
F11R2 at 16#29C# range 0 .. 31;
F12R1 at 16#2A0# range 0 .. 31;
F12R2 at 16#2A4# range 0 .. 31;
F13R1 at 16#2A8# range 0 .. 31;
F13R2 at 16#2AC# range 0 .. 31;
end record;
-- Controller area network
CAN1_Periph : aliased CAN_Peripheral
with Import, Address => System'To_Address (16#40006400#);
-- Controller area network
CAN2_Periph : aliased CAN_Peripheral
with Import, Address => System'To_Address (16#40006800#);
end STM32_SVD.CAN;
|
reznikmm/matreshka | Ada | 3,744 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body XML.Schema.Object_Lists.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.XML_Schema.Object_Lists.Object_List_Access)
return XS_Object_List is
begin
Matreshka.XML_Schema.Object_Lists.Reference (Node);
return (Ada.Finalization.Controlled with Node => Node);
end Create;
end XML.Schema.Object_Lists.Internals;
|
strenkml/EE368 | Ada | 5,978 | ads |
with Ada.Finalization; use Ada.Finalization;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Containers.Vectors; use Ada.Containers;
with Distribution; use Distribution;
with Util; use Util;
-- Base package for memory components.
-- This package has prototypes for simulating and generating VHDL.
package Memory is
-- An exception that is raised when the simulation of a memory
-- can complete early. This is used for superoptimization to avoid
-- fully evaluating a memory trace.
Prune_Error : exception;
-- The base data type for memory components.
-- This type should be extended to create new main memories.
-- See Memory.Container to create components.
type Memory_Type is abstract new Controlled with private;
type Memory_Pointer is access all Memory_Type'Class;
-- Type to represent a port.
type Port_Type is record
id : Natural; -- Memory identifier for the port.
word_size : Positive; -- Size of a word in bytes.
addr_bits : Positive; -- Size of an address in bits.
end record;
-- Vector of ports.
package Port_Vectors is new Vectors(Natural, Port_Type);
subtype Port_Vector_Type is Port_Vectors.Vector;
-- Clone this memory.
-- This will allocate a new instance of the memory.
function Clone(mem : Memory_Type) return Memory_Pointer is abstract;
-- Permute some aspect of the current memory component.
procedure Permute(mem : in out Memory_Type;
generator : in Distribution_Type;
max_cost : in Cost_Type) is null;
-- Determine if the evaulation is finished or if the benchmark
-- needs to be re-run.
function Done(mem : Memory_Type) return Boolean;
-- Reset the memory. This should be called between benchmark runs.
-- context is the context being started. This is used for
-- superoptimization of multiple traces.
procedure Reset(mem : in out Memory_Type;
context : in Natural);
-- Set the port being used to access memory.
-- This is used to inform arbiters where an access is coming from.
procedure Set_Port(mem : in out Memory_Type;
port : in Natural;
ready : out Boolean) is null;
-- Simulate a memory read.
procedure Read(mem : in out Memory_Type;
address : in Address_Type;
size : in Positive) is abstract;
-- Simulate a memory write.
procedure Write(mem : in out Memory_Type;
address : in Address_Type;
size : in Positive) is abstract;
-- Simulate idle time.
procedure Idle(mem : in out Memory_Type;
cycles : in Time_Type);
-- Get the current time in cycles.
function Get_Time(mem : Memory_Type) return Time_Type;
-- Get the number of writes to the main memory.
function Get_Writes(mem : Memory_Type) return Long_Integer is abstract;
-- Show statistics.
procedure Show_Stats(mem : in out Memory_Type);
-- Show access statistics (called from Show_Stats).
procedure Show_Access_Stats(mem : in out Memory_Type) is null;
-- Get a string representation of the memory.
function To_String(mem : Memory_Type) return Unbounded_String is abstract;
-- Get the cost of this memory.
function Get_Cost(mem : Memory_Type) return Cost_Type is abstract;
-- Get the word size in bytes.
function Get_Word_Size(mem : Memory_Type) return Positive is abstract;
-- Get the length of the longest path in levels of logic.
-- This is an estimate used to insert registers.
function Get_Path_Length(mem : Memory_Type) return Natural;
-- Generate VHDL for a memory.
procedure Generate(mem : in Memory_Type;
sigs : in out Unbounded_String;
code : in out Unbounded_String) is null;
-- Destroy a memory.
procedure Destroy(mem : in out Memory_Pointer);
-- Get the total access time.
-- This is used for optimization to minimize access time.
function Get_Time(mem : access Memory_Type'Class) return Time_Type;
-- Get the total number of writes.
-- This is used for optimization to minimize writes.
function Get_Writes(mem : access Memory_Type'Class) return Long_Integer;
-- Return 0.
-- This is used for optimization to perform a random walk.
function Get_Zero(mem : access Memory_Type'Class) return Natural;
-- Get a unique identifier for this memory component.
function Get_ID(mem : Memory_Type'Class) return Natural;
-- Advance the access time.
procedure Advance(mem : in out Memory_Type'Class;
cycles : in Time_Type);
-- Get the maximum path length in levels of logic.
function Get_Max_Length(mem : access Memory_Type'Class;
result : Natural := 0) return Natural;
-- Get a vector of end-points.
function Get_Ports(mem : Memory_Type) return Port_Vector_Type is abstract;
private
type Memory_Type is abstract new Controlled with record
id : Natural;
time : Time_Type := 0;
end record;
overriding
procedure Initialize(mem : in out Memory_Type);
overriding
procedure Adjust(mem : in out Memory_Type);
function Get_Port(mem : Memory_Type'Class) return Port_Type;
procedure Declare_Signals(sigs : in out Unbounded_String;
name : in String;
word_bits : in Positive);
procedure Line(dest : in out Unbounded_String;
str : in String := "");
function To_String(a : Address_Type) return String;
function To_String(t : Time_Type) return String;
function To_String(i : Integer) return String renames Util.To_String;
function To_String(i : Long_Integer) return String renames Util.To_String;
function To_String(f : Long_Float) return String renames Util.To_String;
end Memory;
|
HeisenbugLtd/open_weather_map_api | Ada | 8,100 | 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 GNATCOLL.JSON.Conversions;
with Open_Weather_Map.API.Service.Utilities;
with SI_Units.Metric;
with Types;
package body Open_Weather_Map.API.Service.Location is
My_Debug : constant not null GNATCOLL.Traces.Trace_Handle :=
GNATCOLL.Traces.Create (Unit_Name => "OWM.API.LOCATION");
-----------------------------------------------------------------------------
-- Image
-----------------------------------------------------------------------------
function Image is new
SI_Units.Metric.Fixed_Image (Item => Types.Degree,
Default_Aft => 6,
Unit => SI_Units.No_Unit);
package Field_Names is
pragma Warnings (Off, "declaration hides");
package Main is
Humidity : constant String := "humidity";
Pressure : constant String := "pressure";
Temperature : constant String := "temp";
end Main;
package Root is
Coordinates : constant String := "coord";
Date_Time : constant String := "dt";
Main : constant String := "main";
Name : constant String := "name";
Sys : constant String := "sys";
Time_Zone : constant String := "timezone";
end Root;
package Sys is
Sunrise : constant String := "sunrise";
Sunset : constant String := "sunset";
end Sys;
pragma Warnings (On, "declaration hides");
end Field_Names;
-----------------------------------------------------------------------------
-- Decode_Response
-----------------------------------------------------------------------------
overriding function Decode_Response
(Self : in T;
Root : in GNATCOLL.JSON.JSON_Value) return Data_Set
is
pragma Unreferenced (Self);
--------------------------------------------------------------------------
-- Decode_City_Data
--------------------------------------------------------------------------
function Decode_City_Data
(Element : in GNATCOLL.JSON.JSON_Value;
Coord : in GNATCOLL.JSON.JSON_Value;
Main : in GNATCOLL.JSON.JSON_Value;
Sys : in GNATCOLL.JSON.JSON_Value) return City_Data;
--------------------------------------------------------------------------
-- Decode_City_Data
--------------------------------------------------------------------------
function Decode_City_Data
(Element : in GNATCOLL.JSON.JSON_Value;
Coord : in GNATCOLL.JSON.JSON_Value;
Main : in GNATCOLL.JSON.JSON_Value;
Sys : in GNATCOLL.JSON.JSON_Value) return City_Data
is
package Conversions renames GNATCOLL.JSON.Conversions;
package Field_Names_Element renames Field_Names.Root;
begin
My_Debug.all.Trace (Message => "Decode_Response.Decode_City_Data");
return
City_Data'(Location =>
Utilities.Decode_Coordinates (Coordinates => Coord),
Temperature =>
Conversions.To_Temperature
(Value => Main,
Field => Field_Names.Main.Temperature),
Humidity =>
Conversions.To_Humidity
(Value => Main,
Field => Field_Names.Main.Humidity),
Pressure =>
Conversions.To_Pressure
(Value => Main,
Field => Field_Names.Main.Pressure),
Sunrise =>
Conversions.To_Time (Value => Sys,
Field => Field_Names.Sys.Sunrise),
Sunset =>
Conversions.To_Time (Value => Sys,
Field => Field_Names.Sys.Sunset),
Name =>
Element.Get (Field => Field_Names_Element.Name),
Time_Zone =>
Conversions.To_Time_Offset
(Value => Element,
Field => Field_Names_Element.Time_Zone),
Last_Update =>
Conversions.To_Time
(Value => Element,
Field => Field_Names_Element.Date_Time));
end Decode_City_Data;
Cities : City_Lists.Vector;
begin
My_Debug.all.Trace (Message => "Decode_Response");
if
Root.Has_Field (Field => Field_Names.Root.Coordinates) and then
Root.Has_Field (Field => Field_Names.Root.Date_Time) and then
Root.Has_Field (Field => Field_Names.Root.Main) and then
Root.Has_Field (Field => Field_Names.Root.Name) and then
Root.Has_Field (Field => Field_Names.Root.Sys)
then
Check_Data_Fields :
declare
Coord : constant GNATCOLL.JSON.JSON_Value :=
Root.Get (Field => Field_Names.Root.Coordinates);
Main : constant GNATCOLL.JSON.JSON_Value :=
Root.Get (Field => Field_Names.Root.Main);
Sys : constant GNATCOLL.JSON.JSON_Value :=
Root.Get (Field => Field_Names.Root.Sys);
begin
if
Utilities.Has_Coord_Fields (Coordinates => Coord) and then
Main.Has_Field (Field => Field_Names.Main.Humidity) and then
Main.Has_Field (Field => Field_Names.Main.Pressure) and then
Main.Has_Field (Field => Field_Names.Main.Temperature) and then
Root.Has_Field (Field => Field_Names.Root.Time_Zone) and then
Sys.Has_Field (Field => Field_Names.Sys.Sunrise) and then
Sys.Has_Field (Field => Field_Names.Sys.Sunset)
then
Cities.Append (New_Item => Decode_City_Data (Element => Root,
Coord => Coord,
Main => Main,
Sys => Sys));
end if;
end Check_Data_Fields;
end if;
if not Cities.Is_Empty then
return Data_Set'(Valid => True,
Cities => Cities);
end if;
return Invalid_Data_Set;
end Decode_Response;
-----------------------------------------------------------------------------
-- Initialize
-----------------------------------------------------------------------------
procedure Initialize
(Self : out T;
Configuration : in GNATCOLL.JSON.JSON_Value;
Connection : not null Client.T_Access;
Max_Cache_Interval : in Ada.Real_Time.Time_Span := Default_Cache_Interval;
Coordinates : in Geo_Coordinates) is
begin
My_Debug.all.Trace (Message => "Initialize");
Service.T (Self).Initialize
(Configuration => Configuration,
Connection => Connection,
Max_Cache_Interval => Max_Cache_Interval,
For_API_Service => Current_By_Coordinates);
Self.Parameters.Add (Name => "lat",
Value => Image (Value => Coordinates.Latitude));
Self.Parameters.Add (Name => "lon",
Value => Image (Value => Coordinates.Longitude));
end Initialize;
end Open_Weather_Map.API.Service.Location;
|
onox/orka | Ada | 1,821 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Finalization;
package EGL.Objects is
pragma Preelaborate;
type EGL_Object is abstract new Ada.Finalization.Controlled with private;
overriding procedure Initialize (Object : in out EGL_Object);
overriding procedure Adjust (Object : in out EGL_Object);
overriding procedure Finalize (Object : in out EGL_Object);
function ID (Object : EGL_Object) return ID_Type;
function Is_Initialized (Object : EGL_Object) return Boolean;
procedure Post_Initialize (Object : in out EGL_Object) is null;
procedure Pre_Finalize (Object : in out EGL_Object) is null;
overriding
function "=" (Left, Right : EGL_Object) return Boolean;
private
type EGL_Object_Reference is record
ID : ID_Type;
Count : Natural with Atomic;
Active : Boolean with Atomic;
-- Currently only used for contexts to record whether context
-- is current on any task
end record;
type EGL_Object_Reference_Access is access all EGL_Object_Reference;
type EGL_Object is abstract new Ada.Finalization.Controlled with record
Reference : EGL_Object_Reference_Access;
end record;
end EGL.Objects;
|
dan76/Amass | Ada | 4,656 | 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 = "PentestTools"
type = "api"
function start()
set_rate_limit(1)
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.key ~= "") 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 == "") then
return
end
local id = start_scan(domain, c.key)
if (id == "") then
return
end
while(true) do
local status = get_scan_status(id, c.key)
if (status == "failed") then
return
elseif (status == "finished") then
break
end
for _=1,5 do check_rate_limit() end
end
local output = get_output(id, c.key)
if (output ~= "") then
for _, r in pairs(output) do
new_name(ctx, r[1])
new_addr(ctx, r[2], r[1])
end
end
end
function start_scan(domain, key)
local body, err = json.encode({
['op']="start_scan",
['tool_id']=20,
['target']=domain,
['tool_params'] = {
['web_details']="off",
['do_bing_search']="off",
},
})
if (err ~= nil and err ~= "") then
return ""
end
local resp, err = request(ctx, {
['url']=build_url(key),
['method']="POST",
['header']={['Content-Type']="application/json"},
['body']=body,
})
if (err ~= nil and err ~= "") then
log(ctx, "start_scan request to service failed: " .. err)
return ""
elseif (resp.status_code < 200 or resp.status_code >= 400) then
log(ctx, "start_scan request to service returned with status: " .. resp.status)
return ""
end
d = json.decode(resp.body)
if (d == nil) then
log(ctx, "failed to decode the JSON start_scan response")
return ""
elseif (d.op_status == nil or d.op_status ~= "success") then
return ""
end
return d.scan_id
end
function get_scan_status(id, key)
local body, err = json.encode({
['op']="get_scan_status",
['scan_id']=id,
})
if (err ~= nil and err ~= "") then
return "failed"
end
local resp, err = request(ctx, {
['url']=build_url(key),
['method']="POST",
['header']={['Content-Type']="application/json"},
['body']=body,
})
if (err ~= nil and err ~= "") then
log(ctx, "get_scan_status request to service failed: " .. err)
return "failed"
elseif (resp.status_code < 200 or resp.status_code >= 400) then
log(ctx, "get_scan_status request to service returned with status: " .. resp.status)
return "failed"
end
d = json.decode(resp.body)
if (d == nil) then
log(ctx, "failed to decode the JSON get_scan_status response")
return "failed"
elseif (d.op_status == nil or d.op_status ~= "success") then
return "failed"
elseif (d.scan_status ~= nil and (d.scan_status == "waiting" or d.scan_status == "running")) then
return "progress"
else
return "finished"
end
end
function get_output(id, key)
local body, err = json.encode({
['op']="get_output",
['scan_id']=id,
['output_format']="json",
})
if (err ~= nil and err ~= "") then
return ""
end
local resp, err = request(ctx, {
['url']=build_url(key),
['method']="POST",
['header']={['Content-Type']="application/json"},
['body']=body,
})
if (err ~= nil and err ~= "") then
log(ctx, "get_output request to service failed: " .. err)
return ""
elseif (resp.status_code < 200 or resp.status_code >= 400) then
log(ctx, "get_output request to service returned with status: " .. resp.status)
return ""
end
d = json.decode(resp.body)
if (d == nil) then
log(ctx, "failed to decode the JSON get_output response")
return ""
elseif (d.op_status == nil or d.op_status ~= "success" or
d.output_json == nil or #(d['output_json'].output_data) == 0) then
return ""
end
return d['output_json'][1].output_data
end
function build_url(key)
return "https://pentest-tools.com/api?key=" .. key
end
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 20,457 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF51_SVD.LPCOMP is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Shortcut between READY event and SAMPLE task.
type SHORTS_READY_SAMPLE_Field is
(
-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_READY_SAMPLE_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between RADY event and STOP task.
type SHORTS_READY_STOP_Field is
(
-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_READY_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between DOWN event and STOP task.
type SHORTS_DOWN_STOP_Field is
(
-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_DOWN_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between UP event and STOP task.
type SHORTS_UP_STOP_Field is
(
-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_UP_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CROSS event and STOP task.
type SHORTS_CROSS_STOP_Field is
(
-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_CROSS_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcuts for the LPCOMP.
type SHORTS_Register is record
-- Shortcut between READY event and SAMPLE task.
READY_SAMPLE : SHORTS_READY_SAMPLE_Field := NRF51_SVD.LPCOMP.Disabled;
-- Shortcut between RADY event and STOP task.
READY_STOP : SHORTS_READY_STOP_Field := NRF51_SVD.LPCOMP.Disabled;
-- Shortcut between DOWN event and STOP task.
DOWN_STOP : SHORTS_DOWN_STOP_Field := NRF51_SVD.LPCOMP.Disabled;
-- Shortcut between UP event and STOP task.
UP_STOP : SHORTS_UP_STOP_Field := NRF51_SVD.LPCOMP.Disabled;
-- Shortcut between CROSS event and STOP task.
CROSS_STOP : SHORTS_CROSS_STOP_Field := NRF51_SVD.LPCOMP.Disabled;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
READY_SAMPLE at 0 range 0 .. 0;
READY_STOP at 0 range 1 .. 1;
DOWN_STOP at 0 range 2 .. 2;
UP_STOP at 0 range 3 .. 3;
CROSS_STOP at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Enable interrupt on READY event.
type INTENSET_READY_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_READY_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on READY event.
type INTENSET_READY_Field_1 is
(
-- Reset value for the field
Intenset_Ready_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_READY_Field_1 use
(Intenset_Ready_Field_Reset => 0,
Set => 1);
-- Enable interrupt on DOWN event.
type INTENSET_DOWN_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_DOWN_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on DOWN event.
type INTENSET_DOWN_Field_1 is
(
-- Reset value for the field
Intenset_Down_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_DOWN_Field_1 use
(Intenset_Down_Field_Reset => 0,
Set => 1);
-- Enable interrupt on UP event.
type INTENSET_UP_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_UP_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on UP event.
type INTENSET_UP_Field_1 is
(
-- Reset value for the field
Intenset_Up_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_UP_Field_1 use
(Intenset_Up_Field_Reset => 0,
Set => 1);
-- Enable interrupt on CROSS event.
type INTENSET_CROSS_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_CROSS_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on CROSS event.
type INTENSET_CROSS_Field_1 is
(
-- Reset value for the field
Intenset_Cross_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_CROSS_Field_1 use
(Intenset_Cross_Field_Reset => 0,
Set => 1);
-- Interrupt enable set register.
type INTENSET_Register is record
-- Enable interrupt on READY event.
READY : INTENSET_READY_Field_1 := Intenset_Ready_Field_Reset;
-- Enable interrupt on DOWN event.
DOWN : INTENSET_DOWN_Field_1 := Intenset_Down_Field_Reset;
-- Enable interrupt on UP event.
UP : INTENSET_UP_Field_1 := Intenset_Up_Field_Reset;
-- Enable interrupt on CROSS event.
CROSS : INTENSET_CROSS_Field_1 := Intenset_Cross_Field_Reset;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
READY at 0 range 0 .. 0;
DOWN at 0 range 1 .. 1;
UP at 0 range 2 .. 2;
CROSS at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Disable interrupt on READY event.
type INTENCLR_READY_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_READY_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on READY event.
type INTENCLR_READY_Field_1 is
(
-- Reset value for the field
Intenclr_Ready_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_READY_Field_1 use
(Intenclr_Ready_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on DOWN event.
type INTENCLR_DOWN_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_DOWN_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on DOWN event.
type INTENCLR_DOWN_Field_1 is
(
-- Reset value for the field
Intenclr_Down_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_DOWN_Field_1 use
(Intenclr_Down_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on UP event.
type INTENCLR_UP_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_UP_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on UP event.
type INTENCLR_UP_Field_1 is
(
-- Reset value for the field
Intenclr_Up_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_UP_Field_1 use
(Intenclr_Up_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on CROSS event.
type INTENCLR_CROSS_Field is
(
-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_CROSS_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on CROSS event.
type INTENCLR_CROSS_Field_1 is
(
-- Reset value for the field
Intenclr_Cross_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_CROSS_Field_1 use
(Intenclr_Cross_Field_Reset => 0,
Clear => 1);
-- Interrupt enable clear register.
type INTENCLR_Register is record
-- Disable interrupt on READY event.
READY : INTENCLR_READY_Field_1 := Intenclr_Ready_Field_Reset;
-- Disable interrupt on DOWN event.
DOWN : INTENCLR_DOWN_Field_1 := Intenclr_Down_Field_Reset;
-- Disable interrupt on UP event.
UP : INTENCLR_UP_Field_1 := Intenclr_Up_Field_Reset;
-- Disable interrupt on CROSS event.
CROSS : INTENCLR_CROSS_Field_1 := Intenclr_Cross_Field_Reset;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
READY at 0 range 0 .. 0;
DOWN at 0 range 1 .. 1;
UP at 0 range 2 .. 2;
CROSS at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Result of last compare. Decision point SAMPLE task.
type RESULT_RESULT_Field is
(
-- Input voltage is bellow the reference threshold.
Bellow,
-- Input voltage is above the reference threshold.
Above)
with Size => 1;
for RESULT_RESULT_Field use
(Bellow => 0,
Above => 1);
-- Result of last compare.
type RESULT_Register is record
-- Read-only. Result of last compare. Decision point SAMPLE task.
RESULT : RESULT_RESULT_Field;
-- unspecified
Reserved_1_31 : HAL.UInt31;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RESULT_Register use record
RESULT at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Enable or disable LPCOMP.
type ENABLE_ENABLE_Field is
(
-- Disabled LPCOMP.
Disabled,
-- Enable LPCOMP.
Enabled)
with Size => 2;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 1);
-- Enable the LPCOMP.
type ENABLE_Register is record
-- Enable or disable LPCOMP.
ENABLE : ENABLE_ENABLE_Field := NRF51_SVD.LPCOMP.Disabled;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Analog input pin select.
type PSEL_PSEL_Field is
(
-- Use analog input 0 as analog input.
Analoginput0,
-- Use analog input 1 as analog input.
Analoginput1,
-- Use analog input 2 as analog input.
Analoginput2,
-- Use analog input 3 as analog input.
Analoginput3,
-- Use analog input 4 as analog input.
Analoginput4,
-- Use analog input 5 as analog input.
Analoginput5,
-- Use analog input 6 as analog input.
Analoginput6,
-- Use analog input 7 as analog input.
Analoginput7)
with Size => 3;
for PSEL_PSEL_Field use
(Analoginput0 => 0,
Analoginput1 => 1,
Analoginput2 => 2,
Analoginput3 => 3,
Analoginput4 => 4,
Analoginput5 => 5,
Analoginput6 => 6,
Analoginput7 => 7);
-- Input pin select.
type PSEL_Register is record
-- Analog input pin select.
PSEL : PSEL_PSEL_Field := NRF51_SVD.LPCOMP.Analoginput0;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PSEL_Register use record
PSEL at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Reference select.
type REFSEL_REFSEL_Field is
(
-- Use supply with a 1/8 prescaler as reference.
Supplyoneeighthprescaling,
-- Use supply with a 2/8 prescaler as reference.
Supplytwoeighthsprescaling,
-- Use supply with a 3/8 prescaler as reference.
Supplythreeeighthsprescaling,
-- Use supply with a 4/8 prescaler as reference.
Supplyfoureighthsprescaling,
-- Use supply with a 5/8 prescaler as reference.
Supplyfiveeighthsprescaling,
-- Use supply with a 6/8 prescaler as reference.
Supplysixeighthsprescaling,
-- Use supply with a 7/8 prescaler as reference.
Supplyseveneighthsprescaling,
-- Use external analog reference as reference.
Aref)
with Size => 3;
for REFSEL_REFSEL_Field use
(Supplyoneeighthprescaling => 0,
Supplytwoeighthsprescaling => 1,
Supplythreeeighthsprescaling => 2,
Supplyfoureighthsprescaling => 3,
Supplyfiveeighthsprescaling => 4,
Supplysixeighthsprescaling => 5,
Supplyseveneighthsprescaling => 6,
Aref => 7);
-- Reference select.
type REFSEL_Register is record
-- Reference select.
REFSEL : REFSEL_REFSEL_Field :=
NRF51_SVD.LPCOMP.Supplyoneeighthprescaling;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for REFSEL_Register use record
REFSEL at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- External analog reference pin selection.
type EXTREFSEL_EXTREFSEL_Field is
(
-- Use analog reference 0 as reference.
Analogreference0,
-- Use analog reference 1 as reference.
Analogreference1)
with Size => 1;
for EXTREFSEL_EXTREFSEL_Field use
(Analogreference0 => 0,
Analogreference1 => 1);
-- External reference select.
type EXTREFSEL_Register is record
-- External analog reference pin selection.
EXTREFSEL : EXTREFSEL_EXTREFSEL_Field :=
NRF51_SVD.LPCOMP.Analogreference0;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTREFSEL_Register use record
EXTREFSEL at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Analog detect configuration.
type ANADETECT_ANADETECT_Field is
(
-- Generate ANADETEC on crossing, both upwards and downwards crossing.
Cross,
-- Generate ANADETEC on upwards crossing only.
Up,
-- Generate ANADETEC on downwards crossing only.
Down)
with Size => 2;
for ANADETECT_ANADETECT_Field use
(Cross => 0,
Up => 1,
Down => 2);
-- Analog detect configuration.
type ANADETECT_Register is record
-- Analog detect configuration.
ANADETECT : ANADETECT_ANADETECT_Field := NRF51_SVD.LPCOMP.Cross;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ANADETECT_Register use record
ANADETECT at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Peripheral power control.
type POWER_POWER_Field is
(
-- Module power disabled.
Disabled,
-- Module power enabled.
Enabled)
with Size => 1;
for POWER_POWER_Field use
(Disabled => 0,
Enabled => 1);
-- Peripheral power control.
type POWER_Register is record
-- Peripheral power control.
POWER : POWER_POWER_Field := NRF51_SVD.LPCOMP.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
POWER at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Low power comparator.
type LPCOMP_Peripheral is record
-- Start the comparator.
TASKS_START : aliased HAL.UInt32;
-- Stop the comparator.
TASKS_STOP : aliased HAL.UInt32;
-- Sample comparator value.
TASKS_SAMPLE : aliased HAL.UInt32;
-- LPCOMP is ready and output is valid.
EVENTS_READY : aliased HAL.UInt32;
-- Input voltage crossed the threshold going down.
EVENTS_DOWN : aliased HAL.UInt32;
-- Input voltage crossed the threshold going up.
EVENTS_UP : aliased HAL.UInt32;
-- Input voltage crossed the threshold in any direction.
EVENTS_CROSS : aliased HAL.UInt32;
-- Shortcuts for the LPCOMP.
SHORTS : aliased SHORTS_Register;
-- Interrupt enable set register.
INTENSET : aliased INTENSET_Register;
-- Interrupt enable clear register.
INTENCLR : aliased INTENCLR_Register;
-- Result of last compare.
RESULT : aliased RESULT_Register;
-- Enable the LPCOMP.
ENABLE : aliased ENABLE_Register;
-- Input pin select.
PSEL : aliased PSEL_Register;
-- Reference select.
REFSEL : aliased REFSEL_Register;
-- External reference select.
EXTREFSEL : aliased EXTREFSEL_Register;
-- Analog detect configuration.
ANADETECT : aliased ANADETECT_Register;
-- Peripheral power control.
POWER : aliased POWER_Register;
end record
with Volatile;
for LPCOMP_Peripheral use record
TASKS_START at 16#0# range 0 .. 31;
TASKS_STOP at 16#4# range 0 .. 31;
TASKS_SAMPLE at 16#8# range 0 .. 31;
EVENTS_READY at 16#100# range 0 .. 31;
EVENTS_DOWN at 16#104# range 0 .. 31;
EVENTS_UP at 16#108# range 0 .. 31;
EVENTS_CROSS at 16#10C# range 0 .. 31;
SHORTS at 16#200# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
RESULT at 16#400# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
PSEL at 16#504# range 0 .. 31;
REFSEL at 16#508# range 0 .. 31;
EXTREFSEL at 16#50C# range 0 .. 31;
ANADETECT at 16#520# range 0 .. 31;
POWER at 16#FFC# range 0 .. 31;
end record;
-- Low power comparator.
LPCOMP_Periph : aliased LPCOMP_Peripheral
with Import, Address => System'To_Address (16#40013000#);
end NRF51_SVD.LPCOMP;
|
persan/A-gst | Ada | 4,240 | adb | pragma Ada_2012;
with GStreamer.GST_Low_Level.Gstreamer_0_10_Gst_Rtsp_Gstrtspdefs_H;
with Ada.Unchecked_Conversion;
with Interfaces.C.Strings;
with System;
package body GStreamer.Rtsp is
use Interfaces.C;
use GStreamer.GST_Low_Level.Gstreamer_0_10_Gst_Rtsp_Gstrtspdefs_H;
type GcharPtr is access all Glib.Gchar with Storage_Size => 0;
function Convert is new Ada.Unchecked_Conversion (Source => GcharPtr , Target => Interfaces.C.Strings.Chars_Ptr);
function To_Ada ( C : access constant Glib.Gchar) return String is
begin
return (if C /= null
then
Interfaces.C.Strings.Value (Convert (C.all'Unrestricted_Access))
else
"");
end;
---------------
-- Strresult --
---------------
function Strresult (Result : GstRTSPResult) return String is
R : constant access constant Glib.Gchar := Gst_Rtsp_Strresult (Int (Result));
begin
return To_Ada (R);
end Strresult;
--------------------
-- Method_As_Text --
--------------------
function Method_As_Text (Method : GstRTSPMethod) return String is
R : constant access constant Glib.Gchar := Gst_Rtsp_Method_As_Text (Unsigned (Method));
begin
return To_Ada (R);
end Method_As_Text;
---------------------
-- Version_As_Text --
---------------------
function Version_As_Text (Version : GstRTSPVersion) return String is
R : constant access constant Glib.Gchar := Gst_Rtsp_Version_As_Text (Unsigned (Version));
begin
return To_Ada (R);
end Version_As_Text;
--------------------
-- Header_As_Text --
--------------------
function Header_As_Text (Field : GstRTSPHeaderField) return String is
function To_GstRTSPHeaderField is new Ada.Unchecked_Conversion (GstRTSPHeaderField, GStreamer.GST_Low_Level.Gstreamer_0_10_Gst_Rtsp_Gstrtspdefs_H.GstRTSPHeaderField);
R : constant access constant Glib.Gchar := Gst_Rtsp_Header_As_Text (To_GstRTSPHeaderField (Field));
begin
return To_Ada (R);
end Header_As_Text;
--------------------
-- Status_As_Text --
--------------------
function Status_As_Text (Code : GstRTSPStatusCode) return String is
R : constant access constant Glib.Gchar := Gst_Rtsp_Status_As_Text (Unsigned (Code));
begin
return To_Ada (R);
end Status_As_Text;
---------------------
-- Options_As_Text --
---------------------
function Options_As_Text (Options : GstRTSPMethod) return String is
R : constant access constant Glib.Gchar := Gst_Rtsp_Options_As_Text (Unsigned (Options));
begin
return To_Ada (R);
end Options_As_Text;
-----------------------
-- Find_Header_Field --
-----------------------
function To_Gcharptr is new Ada.Unchecked_Conversion (Source => System.Address,
Target => GcharPtr);
function Find_Header_Field (Header : String) return GstRTSPHeaderField is
L_Header : constant String := Header & ASCII.NUL;
function Convert is new Ada.Unchecked_Conversion
(Source => GST_Low_Level.Gstreamer_0_10_Gst_Rtsp_Gstrtspdefs_H.GstRTSPHeaderField,
Target => GstRTSPHeaderField);
begin
return Convert (Gst_Rtsp_Find_Header_Field (To_Gcharptr (L_Header'Address)));
end Find_Header_Field;
-----------------
-- Find_Method --
-----------------
function Find_Method (Method : String) return GstRTSPMethod is
L_Method : constant String := Method & ASCII.NUL;
begin
return GstRTSPMethod (Gst_Rtsp_Find_Method (To_Gcharptr (L_Method'Address)));
end Find_Method;
---------------------------
-- Header_Allow_Multiple --
---------------------------
function Header_Allow_Multiple
(Field : GstRTSPHeaderField)
return GLIB.gboolean
is
begin
return gst_rtsp_header_allow_multiple(GST_Low_Level.Gstreamer_0_10_Gst_Rtsp_Gstrtspdefs_H.GstRTSPHeaderField'Val(GstRTSPHeaderField'Pos(Field)));
end Header_Allow_Multiple;
procedure RetCode_2_Exception (Code : GstRTSPResult) is
begin
if Code /= OK then
raise Rtsp_Error with Strresult (Code);
end if;
end RetCode_2_Exception;
end GStreamer.Rtsp;
|
charlie5/cBound | Ada | 1,625 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_select_buffer_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
context_tag : aliased xcb.xcb_glx_context_tag_t;
size : aliased Interfaces.Integer_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_select_buffer_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_select_buffer_request_t.Item,
Element_Array => xcb.xcb_glx_select_buffer_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_select_buffer_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_select_buffer_request_t.Pointer,
Element_Array => xcb.xcb_glx_select_buffer_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_select_buffer_request_t;
|
godunko/adawebpack | Ada | 4,055 | adb | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2020, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
with Interfaces;
with System;
with WASM.Objects;
with Web.Strings.WASM_Helpers;
package body Web.HTML.Scripts is
--------------
-- Get_Text --
--------------
function Get_Text
(Self : HTML_Script_Element'Class) return Web.Strings.Web_String
is
function Imported
(Identifier : WASM.Objects.Object_Identifier)
return System.Address
with Import => True,
Convention => C,
Link_Name => "__adawebpack__html__Script__text_getter";
begin
return Web.Strings.WASM_Helpers.To_Ada (Imported (Self.Identifier));
end Get_Text;
--------------
-- Set_Text --
--------------
procedure Set_Text
(Self : in out HTML_Script_Element'Class;
To : Web.Strings.Web_String)
is
procedure Imported
(Identifier : WASM.Objects.Object_Identifier;
Address : System.Address;
Size : Interfaces.Unsigned_32)
with Import => True,
Convention => C,
Link_Name => "__adawebpack__html__Script__text_setter";
A : System.Address;
S : Interfaces.Unsigned_32;
begin
Web.Strings.WASM_Helpers.To_JS (To, A, S);
Imported (Self.Identifier, A, S);
end Set_Text;
end Web.HTML.Scripts;
|
godunko/adagl | Ada | 15,920 | ads | ------------------------------------------------------------------------------
-- --
-- Ada binding for OpenGL/WebGL --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2018-2020, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with OpenGL;
with Interfaces.C.Strings;
with System;
package GLEW is
pragma Preelaborate;
type GLuint is new Interfaces.Unsigned_32;
type GLuint_Array is array (Positive range <>) of GLuint
with Convention => C;
type GLint_Array is array (Positive range <>) of OpenGL.GLint
with Convention => C;
type glewGenBuffers is access procedure
(n : OpenGL.GLsizei;
buffers : access GLuint) with Convention => C;
glGenBuffers : glewGenBuffers
with Import, Convention => C, External_Name => "__glewGenBuffers";
type glewBufferData is access procedure
(target : OpenGL.GLenum;
size : Interfaces.C.ptrdiff_t;
data : System.Address;
buffer : GLuint) with Convention => C;
glBufferData : glewBufferData
with Import, Convention => C, External_Name => "__glewBufferData";
type glewBindBuffer is access procedure
(target : OpenGL.GLenum;
buffer : GLuint) with Convention => C;
glBindBuffer : glewBindBuffer
with Import, Convention => C, External_Name => "__glewBindBuffer";
type glewCreateShader is access function
(shaderType : OpenGL.GLenum) return GLuint with Convention => C;
glCreateShader : glewCreateShader
with Import, Convention => C, External_Name => "__glewCreateShader";
type glewShaderSource is access procedure
(shader : GLuint;
count : OpenGL.GLsizei;
string : Interfaces.C.Strings.chars_ptr_array;
length : GLint_Array) with Convention => C;
glShaderSource : glewShaderSource
with Import, Convention => C, External_Name => "__glewShaderSource";
type glewCompileShader is access procedure (shader : GLuint)
with Convention => C;
glCompileShader : glewCompileShader
with Import, Convention => C, External_Name => "__glewCompileShader";
type glewGetShaderiv is access procedure
(shader : GLuint;
pname : OpenGL.GLenum;
params : access OpenGL.GLint) with Convention => C;
glGetShaderiv : glewGetShaderiv
with Import, Convention => C, External_Name => "__glewGetShaderiv";
type glewDeleteShader is access procedure (shader : GLuint)
with Convention => C;
glDeleteShader : glewDeleteShader
with Import, Convention => C, External_Name => "__glewDeleteShader";
type glewGetShaderInfoLog is access procedure
(shader : GLuint;
maxLength : OpenGL.GLsizei;
length : access OpenGL.GLsizei;
infoLog : out Interfaces.C.char_array)
with Convention => C;
glGetShaderInfoLog : glewGetShaderInfoLog
with Import, Convention => C, External_Name => "__glewGetShaderInfoLog";
type glewAttachShader is access procedure
(program : GLuint;
shader : GLuint)
with Convention => C;
glAttachShader : glewAttachShader
with Import, Convention => C, External_Name => "__glewAttachShader";
type glewGetAttribLocation is access function
(program : GLuint;
name : Interfaces.C.char_array) return OpenGL.GLint
with Convention => C;
glGetAttribLocation : glewGetAttribLocation
with Import, Convention => C, External_Name => "__glewGetAttribLocation";
type glewUseProgram is access procedure (program : GLuint)
with Convention => C;
glUseProgram : glewUseProgram
with Import, Convention => C, External_Name => "__glewUseProgram";
type glewCreateProgram is access function return GLuint
with Convention => C;
glCreateProgram : glewCreateProgram
with Import, Convention => C, External_Name => "__glewCreateProgram";
type glewDisableVertexAttribArray is access procedure (index : GLuint)
with Convention => C;
glDisableVertexAttribArray : glewDisableVertexAttribArray
with Import, Convention => C,
External_Name => "__glewDisableVertexAttribArray";
type glewEnableVertexAttribArray is access procedure (index : GLuint)
with Convention => C;
glEnableVertexAttribArray : glewEnableVertexAttribArray
with Import, Convention => C,
External_Name => "__glewEnableVertexAttribArray";
type glewGetProgramiv is access procedure
(program : GLuint;
pname : OpenGL.GLenum;
params : access OpenGL.GLint) with Convention => C;
glGetProgramiv : glewGetProgramiv
with Import, Convention => C, External_Name => "__glewGetProgramiv";
type glewLinkProgram is access procedure (index : GLuint)
with Convention => C;
glLinkProgram : glewLinkProgram
with Import, Convention => C, External_Name => "__glewLinkProgram";
type glewVertexAttribPointer is access procedure
(index : GLuint;
size : OpenGL.GLint;
kind : OpenGL.GLenum;
normalized : OpenGL.GLint;
stride : OpenGL.GLsizei;
pointer : System.Address)
with Convention => C;
glVertexAttribPointer : glewVertexAttribPointer
with Import, Convention => C, External_Name => "__glewVertexAttribPointer";
type glewVertexAttrib1f is access procedure
(index : GLuint;
v0 : OpenGL.GLfloat)
with Convention => C;
glVertexAttrib1f : glewVertexAttrib1f
with Import, Convention => C, External_Name => "__glewVertexAttrib1f";
type glewVertexAttrib2f is access procedure
(index : GLuint;
v0 : OpenGL.GLfloat;
v1 : OpenGL.GLfloat)
with Convention => C;
glVertexAttrib2f : glewVertexAttrib2f
with Import, Convention => C, External_Name => "__glewVertexAttrib2f";
type glewVertexAttrib3f is access procedure
(index : GLuint;
v0 : OpenGL.GLfloat;
v1 : OpenGL.GLfloat;
v2 : OpenGL.GLfloat)
with Convention => C;
glVertexAttrib3f : glewVertexAttrib3f
with Import, Convention => C, External_Name => "__glewVertexAttrib3f";
type glewVertexAttrib4f is access procedure
(index : GLuint;
v0 : OpenGL.GLfloat;
v1 : OpenGL.GLfloat;
v2 : OpenGL.GLfloat;
v4 : OpenGL.GLfloat)
with Convention => C;
glVertexAttrib4f : glewVertexAttrib4f
with Import, Convention => C, External_Name => "__glewVertexAttrib4f";
type glewVertexAttrib2fv is access procedure
(index : GLuint;
v : OpenGL.GLfloat_Matrix_2x2)
with Convention => C;
glVertexAttrib2fv : glewVertexAttrib2fv
with Import, Convention => C, External_Name => "__glewVertexAttrib2fv";
type glewVertexAttrib3fv is access procedure
(index : GLuint;
v : OpenGL.GLfloat_Matrix_3x3)
with Convention => C;
glVertexAttrib3fv : glewVertexAttrib3fv
with Import, Convention => C, External_Name => "__glewVertexAttrib3fv";
type glewVertexAttrib4fv is access procedure
(index : GLuint;
v : OpenGL.GLfloat_Matrix_4x4)
with Convention => C;
glVertexAttrib4fv : glewVertexAttrib4fv
with Import, Convention => C, External_Name => "__glewVertexAttrib4fv";
type glewUniform1i is access procedure
(index : OpenGL.GLint;
v0 : OpenGL.GLint)
with Convention => C;
glUniform1i : glewUniform1i
with Import, Convention => C, External_Name => "__glewUniform1i";
type glewUniform1f is access procedure
(index : OpenGL.GLint;
v0 : OpenGL.GLfloat)
with Convention => C;
glUniform1f : glewUniform1f
with Import, Convention => C, External_Name => "__glewUniform1f";
type glewUniform2f is access procedure
(index : OpenGL.GLint;
v0 : OpenGL.GLfloat;
v1 : OpenGL.GLfloat)
with Convention => C;
glUniform2f : glewUniform2f
with Import, Convention => C, External_Name => "__glewUniform2f";
type glewUniform3f is access procedure
(index : OpenGL.GLint;
v0 : OpenGL.GLfloat;
v1 : OpenGL.GLfloat;
v2 : OpenGL.GLfloat)
with Convention => C;
glUniform3f : glewUniform3f
with Import, Convention => C, External_Name => "__glewUniform3f";
type glewUniform4f is access procedure
(index : OpenGL.GLint;
v0 : OpenGL.GLfloat;
v1 : OpenGL.GLfloat;
v2 : OpenGL.GLfloat;
v4 : OpenGL.GLfloat)
with Convention => C;
glUniform4f : glewUniform4f
with Import, Convention => C, External_Name => "__glewUniform4f";
type glewUniformMatrix2fv is access procedure
(index : OpenGL.GLint;
count : OpenGL.GLsizei;
transpose : OpenGL.GLint;
v : OpenGL.GLfloat_Matrix_2x2)
with Convention => C;
glUniformMatrix2fv : glewUniformMatrix2fv
with Import, Convention => C, External_Name => "__glewUniformMatrix2fv";
type glewUniformMatrix3fv is access procedure
(index : OpenGL.GLint;
count : OpenGL.GLsizei;
transpose : OpenGL.GLint;
v : OpenGL.GLfloat_Matrix_3x3)
with Convention => C;
glUniformMatrix3fv : glewUniformMatrix3fv
with Import, Convention => C, External_Name => "__glewUniformMatrix3fv";
type glewUniformMatrix4fv is access procedure
(index : OpenGL.GLint;
count : OpenGL.GLsizei;
transpose : OpenGL.GLint;
v : OpenGL.GLfloat_Matrix_4x4)
with Convention => C;
glUniformMatrix4fv : glewUniformMatrix4fv
with Import, Convention => C, External_Name => "__glewUniformMatrix4fv";
type glewGetUniformLocation is access function
(program : GLuint;
name : Interfaces.C.char_array) return OpenGL.GLint
with Convention => C;
glGetUniformLocation : glewGetUniformLocation
with Import, Convention => C, External_Name => "__glewGetUniformLocation";
type glewActiveTexture is access procedure (texture : OpenGL.GLenum)
with Convention => C;
glActiveTexture : glewActiveTexture
with Import, Convention => C, External_Name => "__glewActiveTexture";
procedure glClear
(mask : OpenGL.Clear_Buffer_Mask)
with Import, Convention => C, External_Name => "glClear";
procedure glDrawArrays
(mode : OpenGL.GLenum;
first : OpenGL.GLint;
count : OpenGL.GLsizei)
with Import, Convention => C, External_Name => "glDrawArrays";
procedure glDrawElements
(mode : OpenGL.GLenum;
count : OpenGL.GLsizei;
tipe : OpenGL.GLenum;
offset : System.Address)
with Import, Convention => C, External_Name => "glDrawElements";
procedure glEnable(cap : OpenGL.GLenum)
with Import, Convention => C, External_Name => "glEnable";
procedure glDisable(cap : OpenGL.GLenum)
with Import, Convention => C, External_Name => "glDisable";
procedure glBlendFunc
(sfactor : OpenGL.GLenum;
dfactor : OpenGL.GLenum)
with Import, Convention => C, External_Name => "glBlendFunc";
procedure glClearColor
(red, green, blue, alpha : OpenGL.GLclampf)
with Import, Convention => C, External_Name => "glClearColor";
procedure glClearDepth (depth : OpenGL.GLdouble)
with Import, Convention => C, External_Name => "glClearDepth";
procedure glDepthFunc (func : OpenGL.GLenum)
with Import, Convention => C, External_Name => "glDepthFunc";
procedure glFinish
with Import, Convention => C, External_Name => "glFinish";
procedure glFlush
with Import, Convention => C, External_Name => "glFlush";
procedure glViewport
(x, y : OpenGL.GLint;
width, height : OpenGL.GLsizei)
with Import, Convention => C, External_Name => "glViewport";
procedure glBindTexture
(target : OpenGL.GLenum;
texture : GLuint)
with Import, Convention => C, External_Name => "glBindTexture";
procedure glGenTextures
(n : OpenGL.GLsizei;
textures : access GLuint)
with Import, Convention => C, External_Name => "glGenTextures";
procedure glDeleteTextures
(n : OpenGL.GLsizei;
textures : access GLuint)
with Import, Convention => C, External_Name => "glDeleteTextures";
procedure glTexImage2D
(target : OpenGL.GLenum;
level : OpenGL.GLint;
internalformat : OpenGL.GLenum;
width : OpenGL.GLsizei;
height : OpenGL.GLsizei;
border : OpenGL.GLint;
format : OpenGL.GLenum;
tipe : OpenGL.GLenum;
data : System.Address)
with Import, Convention => C, External_Name => "glTexImage2D";
procedure glTexParameteri
(target : OpenGL.GLenum;
pname : OpenGL.GLenum;
param : OpenGL.GLint)
with Import, Convention => C, External_Name => "glTexParameteri";
ARRAY_BUFFER : constant := 16#8892#;
ELEMENT_ARRAY_BUFFER : constant := 16#8893#;
STATIC_DRAW : constant := 16#88E4#;
FRAGMENT_SHADER : constant := 16#8B30#;
VERTEX_SHADER : constant := 16#8B31#;
COMPILE_STATUS : constant := 16#8B81#;
LINK_STATUS : constant := 16#8B82#;
end GLEW;
|
reznikmm/matreshka | Ada | 5,229 | 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.Part_Decompositions.Collections is
pragma Preelaborate;
package UML_Part_Decomposition_Collections is
new AMF.Generic_Collections
(UML_Part_Decomposition,
UML_Part_Decomposition_Access);
type Set_Of_UML_Part_Decomposition is
new UML_Part_Decomposition_Collections.Set with null record;
Empty_Set_Of_UML_Part_Decomposition : constant Set_Of_UML_Part_Decomposition;
type Ordered_Set_Of_UML_Part_Decomposition is
new UML_Part_Decomposition_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Part_Decomposition : constant Ordered_Set_Of_UML_Part_Decomposition;
type Bag_Of_UML_Part_Decomposition is
new UML_Part_Decomposition_Collections.Bag with null record;
Empty_Bag_Of_UML_Part_Decomposition : constant Bag_Of_UML_Part_Decomposition;
type Sequence_Of_UML_Part_Decomposition is
new UML_Part_Decomposition_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Part_Decomposition : constant Sequence_Of_UML_Part_Decomposition;
private
Empty_Set_Of_UML_Part_Decomposition : constant Set_Of_UML_Part_Decomposition
:= (UML_Part_Decomposition_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Part_Decomposition : constant Ordered_Set_Of_UML_Part_Decomposition
:= (UML_Part_Decomposition_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Part_Decomposition : constant Bag_Of_UML_Part_Decomposition
:= (UML_Part_Decomposition_Collections.Bag with null record);
Empty_Sequence_Of_UML_Part_Decomposition : constant Sequence_Of_UML_Part_Decomposition
:= (UML_Part_Decomposition_Collections.Sequence with null record);
end AMF.UML.Part_Decompositions.Collections;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 987 | ads | with STM32_SVD.GPIO;
generic
Pin : GPIO_Pin;
Port : GPIO_Port;
Mode : Pin_IO_Modes := Mode_In;
Output_Type : Pin_Output_Types := Push_Pull;
Pull_Resistor : in Internal_Pin_Resistors := Floating;
Alternate_Function : in GPIO_Alternate_Function := 0;
package STM32GD.GPIO.Pin is
pragma Preelaborate;
procedure Enable;
procedure Disable;
procedure Init;
procedure Set_Mode (Mode : Pin_IO_Modes);
procedure Set_Type (Pin_Type : Pin_Output_Types);
function Get_Pull_Resistor return Internal_Pin_Resistors;
procedure Set_Pull_Resistor (Pull : Internal_Pin_Resistors);
procedure Configure_Alternate_Function (AF : GPIO_Alternate_Function);
procedure Configure_Trigger (Rising : Boolean := False; Falling : Boolean := False);
procedure Wait_For_Trigger;
procedure Clear_Trigger;
function Triggered return Boolean;
function Is_Set return Boolean;
procedure Set;
procedure Clear;
procedure Toggle;
end STM32GD.GPIO.Pin;
|
tum-ei-rcs/StratoX | Ada | 364 | ads | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Module: Main
--
-- Authors: Emanuel Regnath ([email protected])
--
-- Description: The main program
--
-- ToDo:
-- [ ] Implementation
package Main with
Spark_Mode is
procedure Initialize;
procedure Run_Loop;
end Main;
|
io7m/coreland-jack-ada | Ada | 1,881 | ads | with Jack.Client;
with System;
package Jack.Port is
--
-- API
--
-- proc_map : jack_port_get_buffer
function Buffer_Address
(Port : in Jack.Client.Port_t;
Number_Of_Frames : in Jack.Client.Number_Of_Frames_t) return System.Address;
-- proc_map : jack_port_connected
function Connected (Port : in Jack.Client.Port_t) return Boolean;
-- proc_map : jack_port_connected_to
function Connected_To
(Port : in Jack.Client.Port_t;
Port_Name : in Jack.Client.Port_Name_t) return Boolean;
-- proc_map : jack_port_flags
function Flags
(Port : in Jack.Client.Port_t) return Jack.Client.Port_Flags_t;
-- proc_map : jack_port_type
function Get_Type
(Port : in Jack.Client.Port_t) return Jack.Client.Port_Type_t;
-- proc_map : jack_port_get_latency
function Latency
(Port : in Jack.Client.Port_t) return Jack.Client.Number_Of_Frames_t;
-- proc_map : jack_port_name
function Name
(Port : in Jack.Client.Port_t) return Jack.Client.Port_Name_t;
-- proc_map : jack_port_set_alias
procedure Set_Alias
(Port : in Jack.Client.Port_t;
Port_Alias : in Jack.Client.Port_Name_t;
Failed : out Boolean);
-- proc_map : jack_port_set_latency
procedure Set_Latency
(Port : in Jack.Client.Port_t;
Latency : in Jack.Client.Number_Of_Frames_t);
-- proc_map : jack_port_set_name
procedure Set_Name
(Port : in Jack.Client.Port_t;
Port_Name : in Jack.Client.Port_Name_t;
Failed : out Boolean);
-- proc_map : jack_port_short_name
function Short_Name
(Port : in Jack.Client.Port_t) return Jack.Client.Port_Name_t;
-- proc_map : jack_port_unset_alias
procedure Unset_Alias
(Port : in Jack.Client.Port_t;
Port_Alias : in Jack.Client.Port_Name_t;
Failed : out Boolean);
end Jack.Port;
|
faelys/natools | Ada | 3,376 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Time_Statistics is the root of various utilities to measure time --
-- and gather statistics. --
-- It also provides basic constant-space accumulator that keeps a summary --
-- of seen values. --
------------------------------------------------------------------------------
package Natools.Time_Statistics is
pragma Pure;
type Accumulator is limited interface;
procedure Add (Self : in out Accumulator; Measure : in Duration)
is abstract;
-- Add Measure to the accumulated statistics in Self
type Summary is limited new Accumulator with private;
-- Constant-space aggregator of duration values
overriding procedure Add (Self : in out Summary; Measure : in Duration);
-- Add Measure to the accumulated statistics
not overriding function Minimum (Self : Summary) return Duration;
not overriding function Maximum (Self : Summary) return Duration;
not overriding function Mean (Self : Summary) return Duration;
not overriding function Sample_Count (Self : Summary) return Natural;
private
protected type Summary_Data is
procedure Add (Measure : in Duration);
function Minimum return Duration;
function Maximum return Duration;
function Mean return Duration;
function Sample_Count return Natural;
private
Max : Duration := Duration'First;
Min : Duration := Duration'Last;
Current_Mean : Duration := 0.0;
Count : Natural := 0;
end Summary_Data;
type Summary is limited new Accumulator with record
Data : Summary_Data;
end record;
not overriding function Minimum (Self : Summary) return Duration
is (Self.Data.Minimum);
not overriding function Maximum (Self : Summary) return Duration
is (Self.Data.Maximum);
not overriding function Mean (Self : Summary) return Duration
is (Self.Data.Mean);
not overriding function Sample_Count (Self : Summary) return Natural
is (Self.Data.Sample_Count);
end Natools.Time_Statistics;
|
michalkonecny/polypaver | Ada | 212 | ads | package PolyPaver.Integers is
--# function Is_Integer(Variable : Integer) return Boolean;
--# function Is_Range(Variable : Integer; Min : Integer; Max : Integer) return Boolean;
end PolyPaver.Integers;
|
Brawdunoir/administrative-family-tree-manager | Ada | 5,174 | ads | generic
type T_Cle is private; -- Type clé générique.
package Arbre_Binaire is
Cle_Presente_Exception_Bin : Exception; -- une clé est déjà présente dans un arbre.
Cle_Absente_Exception_Bin : Exception; -- une clé est absente d'un arbre.
Emplacement_Reserve_Exception_Bin : Exception; -- L'emplacement du noeud que l'on veut ajouter est déjà pris.
type T_Pointeur_Binaire is private; -- Type pointeur
-- Initialiser un Arbre.
procedure Initialiser(Arbre: out T_Pointeur_Binaire; Cle : in T_Cle);
-- Savoir si un arbre est vide.
-- Paramètre : Arbre L'arbre que l'on veut tester.
function Est_Vide (Arbre : in T_Pointeur_Binaire) return Boolean;
-- Savoir si le sous arbre droit d'un arbre est vide.
-- Paramètre : Arbre L'arbre racine du sous arbre.
function Est_Vide_Fils_Droit (Arbre : in T_Pointeur_Binaire) return Boolean;
-- Savoir si le sous arbre gauche d'un arbre est vide.
-- Paramètre : Arbre L'arbre racine du sous arbre.
function Est_Vide_Fils_Gauche (Arbre : in T_Pointeur_Binaire) return Boolean;
-- Obtenir le sous arbre gauche d'un arbre.
-- Paramètre : Arbre L'arbre racine du sous arbre.
function Retourner_Fils_Gauche (Arbre : in T_Pointeur_Binaire) return T_Pointeur_Binaire;
-- Obtenir le sous arbre droit d'un arbre.
-- Paramètre : Arbre L'arbre racine du sous arbre.
function Retourner_Fils_Droit (Arbre : in T_Pointeur_Binaire) return T_Pointeur_Binaire;
-- Obtenir la clé d'un noeud.
-- Paramètre : Arbre Le pointeur qui pointe vers le noeud dont on veut connaire sa clé.
function Retourner_Cle (Arbre : in T_Pointeur_Binaire) return T_Cle;
-- Obtenir le nombre de fils à partir d'un noeud donné (lui compris).
-- Paramètres :
-- Arbre L'arbre dans lequel on va effectuer le comptage.
-- Cle La clé de l'individu à partir duquel on compte.
-- Exception: Cle_Absente_Exception si Clé n'est pas utilisée l'arbre.
function Nombre_Fils (Arbre : in T_Pointeur_Binaire; Cle : in T_Cle) return Integer with
Post => Nombre_Fils'Result >= 1;
function Nombre_Fils_Recu (Arbre : in T_Pointeur_Binaire) return Integer;
-- Insérer un fils droit à un noeud dans l'arbre.
-- Paramètres :
-- Arbre l'arbre dans lequel on ajoute un noeud.
-- Cle_Parent La cle du noeud auquel on ajoute un fils droit.
-- Cle_Fils La cle du fils que l'on insère dans l'arbre.
-- Exception : Cle_Presente_Exception si la clé est déjà dans l'arbre.
procedure Ajouter_Fils_Droit (Arbre : in out T_Pointeur_Binaire; Cle_Parent : in T_Cle; Cle_Fils : in T_Cle);-- with
--Post => Nombre_Fils (Arbre, Cle_Parent) = Nombre_Fils (Arbre, Cle_Parent)'Old + 1; -- un élément de plus
-- Insérer un fils gauche à un parent dans l'arbre.
-- Paramètres :
-- Arbre l'arbre dans lequel on ajoute un noeud.
-- Cle_Parent La cle du noeud auquel on ajoute un fils gauche.
-- Cle_Fils La cle du fils que l'on insère dans l'arbre.
-- Exception : Cle_Presente_Exception si la clé est déjà dans l'arbre.
procedure Ajouter_Fils_Gauche (Arbre : in out T_Pointeur_Binaire; Cle_Parent : in T_Cle; Cle_Fils : in T_Cle);-- with
--Post => Nombre_Fils (Arbre, Cle_Parent) = Nombre_Fils (Arbre, Cle_Parent)'Old + 1; -- un élément de plus
-- Supprimer le noeud associé à la clé dans l'arbre et le sous-arbre dont il est la base.
-- Paramètres :
--Arbre l'arbre dans lequel on suprimme un sous arbre.
--Cle La cle du noeud à la base du sous-arbre
-- Exception : Cle_Absente_Exception si Clé n'est pas utilisée dans l'arbre.
procedure Supprimer (Arbre : in out T_Pointeur_Binaire ; Cle : in T_Cle);
--Post => Nombre_Fils (Arbre, Cle) = Nombre_Fils (Arbre, Cle)'Old - 1; -- un élément de moins
-- Supprimer tous les éléments d'un arbre.
-- Parametre :
--Arbre l'arbre que l'on veut suprimmer.
-- Doit être utilisée dès qu'on sait qu'un arbre ne sera plus utilisé.
procedure Vider (Arbre : in out T_Pointeur_Binaire) with
Post => Est_Vide (Arbre);
-- Affiche l'arbre à l'aide d'une procedure qui permet d'afficher les clés génériques.
-- Parametre : Arbre l'arbre que l'on veut afficher.
generic
with procedure Afficher_Cle (Cle : in T_Cle);
procedure Afficher_Arbre_Binaire (Arbre : in T_Pointeur_Binaire);
generic
with procedure Afficher_Cle(Cle : in T_Cle);
procedure Afficher_Cle_Binaire (Arbre : in T_Pointeur_Binaire);
-- Procédure qui trouve le pointeur qui pointe vers la cellule dans laquelle se trouve la clé que l'on recherche.
-- Paramètres:
-- Arbre l'arbre dans lequel on recherche la clé.
-- Cle La clé que l'on recherche.
-- Position Le pointeur qui pointe vers la clé.
-- Exception : Cle_Absente_Exception si Clé n'est pas utilisée dans l'arbre.
procedure Rechercher_Position (Arbre : in T_Pointeur_Binaire; Cle : in T_Cle; Pointeur : out T_Pointeur_Binaire);
procedure Ajouter (Arbre : in out T_Pointeur_Binaire; Cle : in T_Cle);
private
type T_Cellule;
type T_Pointeur_Binaire is access T_Cellule;
type T_Cellule is
record
Cle : T_Cle;
Fils_Gauche : T_Pointeur_Binaire;
Fils_Droit : T_Pointeur_Binaire;
end record;
end Arbre_Binaire; |
reznikmm/matreshka | Ada | 4,575 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Volume_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Volume_Attribute_Node is
begin
return Self : Text_Volume_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Volume_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Volume_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Volume_Attribute,
Text_Volume_Attribute_Node'Tag);
end Matreshka.ODF_Text.Volume_Attributes;
|
jhumphry/parse_args | Ada | 1,310 | adb | -- parse_args-concrete.adb
-- A simple command line option parser
-- Copyright (c) 2014 - 2015, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
package body Parse_Args.Generic_Discrete_Array_Options is
-------------------------
-- Element_Array_Image --
-------------------------
function Element_Array_Image (Arg : Element_Array_Access) return String is
begin
if Arg /= null then
return "<Array of length: " & Integer'Image(Arg'Length) & ">";
else
return "<Empty array>";
end if;
end Element_Array_Image;
end Parse_Args.Generic_Discrete_Array_Options;
|
zhmu/ananas | Ada | 448 | adb | with Taft_Type1_Pkg2;
package body Taft_Type1_Pkg1 is
type TAMT1 is new Taft_Type1_Pkg2.Priv (X => 1);
type TAMT2 is new Taft_Type1_Pkg2.Priv;
procedure Check is
Ptr1 : TAMT1_Access := new TAMT1;
Ptr2 : TAMT2_Access := new TAMT2 (X => 2);
begin
if Ptr1.all.X /= 1 then
raise Program_Error;
end if;
if Ptr2.all.X /= 2 then
raise Program_Error;
end if;
end;
end Taft_Type1_Pkg1;
|
ytomino/vampire | Ada | 980 | adb | -- The Village of Vampire by YT, このソースコードはNYSLです
with Ada.Exceptions;
with Ada.Streams.Stream_IO;
with Serialization.YAML;
with YAML.Streams;
with Tabula.Users.User_Info_IO;
procedure Tabula.Users.Load (
Name : in String;
Info : in out User_Info)
is
File : Ada.Streams.Stream_IO.File_Type;
begin
Ada.Streams.Stream_IO.Open (File, Ada.Streams.Stream_IO.In_File, Name => Name);
declare
Parser : aliased YAML.Parser :=
YAML.Streams.Create (Ada.Streams.Stream_IO.Stream (File));
begin
User_Info_IO.IO (
Serialization.YAML.Reading (Parser'Access, User_Info_IO.Yaml_Type).Serializer,
Info);
YAML.Finish (Parser);
end;
Ada.Streams.Stream_IO.Close (File);
exception
when E : others =>
declare
Message : constant String :=
Name & ": " & Ada.Exceptions.Exception_Message (E);
begin
Ada.Debug.Put (Message);
Ada.Exceptions.Raise_Exception (
Ada.Exceptions.Exception_Identity (E),
Message);
end;
end Tabula.Users.Load;
|
damaki/libkeccak | Ada | 9,679 | adb | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Util; use Keccak.Util;
package body Keccak.Generic_Parallel_CSHAKE
is
---------------------------
-- Process_Full_Blocks --
---------------------------
procedure Process_Full_Blocks
(Ctx : in out Context;
Block : in out Types.Byte_Array;
Input : in Types.Byte_Array;
Block_Offset : in out Natural)
with Global => null,
Pre => (Block_Offset < Block'Length
and Block'First = 0
and Block'Length = Rate / 8
and State_Of (Ctx) = Updating),
Post => (Block_Offset < Block'Length
and State_Of (Ctx) = Updating);
procedure Process_Full_Blocks_String
(Ctx : in out Context;
Block : in out Types.Byte_Array;
Input : in String;
Block_Offset : in out Natural)
with Global => null,
Pre => (Block_Offset < Block'Length
and Block'First = 0
and Block'Length = Rate / 8
and State_Of (Ctx) = Updating),
Post => (Block_Offset < Block'Length
and State_Of (Ctx) = Updating);
---------------------------
-- Process_Full_Blocks --
---------------------------
procedure Process_Full_Blocks
(Ctx : in out Context;
Block : in out Types.Byte_Array;
Input : in Types.Byte_Array;
Block_Offset : in out Natural)
is
use type XOF.States;
Block_Length : constant Natural := Block'Length - Block_Offset;
Input_Remaining : Natural := Input'Length;
Input_Offset : Natural := 0;
Length : Natural;
Num_Full_Blocks : Natural;
Pos : Types.Index_Number;
begin
if Block_Offset > 0 then
-- Merge first bytes of Input with the last bytes currently in
-- the block.
if Input_Remaining < Block_Length then
-- Not enough for a full block.
Block (Block_Offset .. Block_Offset + Input_Remaining - 1) :=
Input (Input'First .. Input'First + Input_Remaining - 1);
Input_Offset := Input'Length;
Block_Offset := Block_Offset + Input_Remaining;
Input_Remaining := 0;
else
-- We have enough for a full block
Block (Block_Offset .. Block'Last) :=
Input (Input'First .. Input'First + Block_Length - 1);
XOF.Update_All (Ctx.XOF_Ctx, Block);
Input_Offset := Input_Offset + Block_Length;
Input_Remaining := Input_Remaining - Block_Length;
Block_Offset := 0;
end if;
end if;
pragma Assert_And_Cut
(Input_Offset + Input_Remaining = Input'Length
and Block_Offset < Block'Length
and Block'Length = Rate / 8
and State_Of (Ctx) = Updating
and XOF.State_Of (Ctx.XOF_Ctx) = XOF.Updating
and (if Input_Remaining > 0 then Block_Offset = 0));
-- Now process as many full blocks from Input as we can.
Num_Full_Blocks := Input_Remaining / Block'Length;
if Num_Full_Blocks > 0 then
Pos := Input'First + Input_Offset;
Length := Num_Full_Blocks * Block'Length;
XOF.Update_All (Ctx.XOF_Ctx, Input (Pos .. Pos + Length - 1));
Input_Offset := Input_Offset + Length;
Input_Remaining := Input_Remaining - Length;
end if;
pragma Assert_And_Cut
(Input_Offset + Input_Remaining = Input'Length
and Block_Offset < Block'Length
and Block'Length = Rate / 8
and State_Of (Ctx) = Updating
and (if Input_Remaining > 0 then Block_Offset = 0)
and Input_Remaining < Block'Length);
-- Store any leftover bytes in the block
if Input_Remaining > 0 then
Pos := Input'First + Input_Offset;
Block (0 .. Input_Remaining - 1) := Input (Pos .. Input'Last);
Block_Offset := Input_Remaining;
end if;
end Process_Full_Blocks;
---------------------------------
-- Process_Full_Blocks_String --
---------------------------------
procedure Process_Full_Blocks_String
(Ctx : in out Context;
Block : in out Types.Byte_Array;
Input : in String;
Block_Offset : in out Natural)
is
Bytes : Types.Byte_Array (1 .. 128);
Remaining : Natural := Input'Length;
Offset : Natural := 0;
begin
while Remaining >= Bytes'Length loop
pragma Loop_Invariant (Offset + Remaining = Input'Length);
To_Byte_Array (Bytes, Input (Input'First + Offset ..
Input'First + Offset + Bytes'Length - 1));
Process_Full_Blocks (Ctx, Block, Bytes, Block_Offset);
Offset := Offset + Bytes'Length;
Remaining := Remaining - Bytes'Length;
end loop;
if Remaining > 0 then
To_Byte_Array (Bytes (1 .. Remaining), Input (Input'First + Offset .. Input'Last));
Process_Full_Blocks (Ctx, Block, Bytes (1 .. Remaining), Block_Offset);
end if;
end Process_Full_Blocks_String;
------------
-- Init --
------------
procedure Init (Ctx : out Context;
Customization : in String;
Function_Name : in String)
is
Rate_Bytes : constant Positive := Rate / 8;
Block : Types.Byte_Array (0 .. Rate_Bytes - 1) := (others => 0);
Block_Offset : Natural;
begin
XOF.Init (Ctx.XOF_Ctx);
-- We need to make sure that the data length for each call to
-- XOF.Update_Separate is a multiple of the rate in order to keep the XOF
-- in the "Updating" state. This requires packing the encoded
-- rate, customization string, and function name into a block which is
-- the length of the rate.
--
-- +------+---------------+---------------+
-- | rate | Function_Name | Customization |
-- +------+---------------+---------------+
-- |<-------------->|
-- Rate
Block_Offset := 0;
Process_Full_Blocks
(Ctx => Ctx,
Block => Block,
Input => Left_Encode_NIST (Rate_Bytes),
Block_Offset => Block_Offset);
Process_Full_Blocks
(Ctx => Ctx,
Block => Block,
Input => Left_Encode_NIST_Bit_Length (Function_Name'Length),
Block_Offset => Block_Offset);
Process_Full_Blocks_String
(Ctx => Ctx,
Block => Block,
Input => Function_Name,
Block_Offset => Block_Offset);
Process_Full_Blocks
(Ctx => Ctx,
Block => Block,
Input => Left_Encode_NIST_Bit_Length (Customization'Length),
Block_Offset => Block_Offset);
Process_Full_Blocks_String
(Ctx => Ctx,
Block => Block,
Input => Customization,
Block_Offset => Block_Offset);
if Block_Offset > 0 then
-- Need to add padding zeroes to leftover data
Block (Block_Offset .. Block'Last) := (others => 0);
XOF.Update_All (Ctx.XOF_Ctx, Block);
end if;
end Init;
-----------------------
-- Update_Separate --
-----------------------
procedure Update_Separate (Ctx : in out Context;
Data : in Types.Byte_Array)
is
begin
XOF.Update_Separate (Ctx.XOF_Ctx, Data);
end Update_Separate;
-----------------------
-- Extract_Separate --
-----------------------
procedure Extract_Separate (Ctx : in out Context;
Data : out Types.Byte_Array)
is
begin
XOF.Extract_Separate (Ctx.XOF_Ctx, Data);
end Extract_Separate;
end Keccak.Generic_Parallel_CSHAKE;
|
zhmu/ananas | Ada | 6,218 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . O S _ P R I M I T I V E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2013-2022, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This version is for Linux/x32
with System.Parameters;
package body System.OS_Primitives is
-- ??? These definitions are duplicated from System.OS_Interface
-- because we don't want to depend on any package. Consider removing
-- these declarations in System.OS_Interface and move these ones in
-- the spec.
type time_t is range -2 ** (System.Parameters.time_t_bits - 1)
.. 2 ** (System.Parameters.time_t_bits - 1) - 1;
type timespec is record
tv_sec : time_t;
tv_nsec : Long_Long_Integer;
end record;
pragma Convention (C, timespec);
function nanosleep (rqtp, rmtp : not null access timespec) return Integer;
pragma Import (C, nanosleep, "nanosleep");
-----------
-- Clock --
-----------
function Clock return Duration is
type timeval is array (1 .. 2) of Long_Long_Integer;
procedure timeval_to_duration
(T : not null access timeval;
sec : not null access Long_Integer;
usec : not null access Long_Integer);
pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
Micro : constant := 10**6;
sec : aliased Long_Integer;
usec : aliased Long_Integer;
TV : aliased timeval;
Result : Integer;
pragma Unreferenced (Result);
function gettimeofday
(Tv : access timeval;
Tz : System.Address := System.Null_Address) return Integer;
pragma Import (C, gettimeofday, "gettimeofday");
begin
-- The return codes for gettimeofday are as follows (from man pages):
-- EPERM settimeofday is called by someone other than the superuser
-- EINVAL Timezone (or something else) is invalid
-- EFAULT One of tv or tz pointed outside accessible address space
-- None of these codes signal a potential clock skew, hence the return
-- value is never checked.
Result := gettimeofday (TV'Access, System.Null_Address);
timeval_to_duration (TV'Access, sec'Access, usec'Access);
return Duration (sec) + Duration (usec) / Micro;
end Clock;
-----------------
-- To_Timespec --
-----------------
function To_Timespec (D : Duration) return timespec;
function To_Timespec (D : Duration) return timespec is
S : time_t;
F : Duration;
begin
S := time_t (Long_Long_Integer (D));
F := D - Duration (S);
-- If F has negative value due to a round-up, adjust for positive F
-- value.
if F < 0.0 then
S := S - 1;
F := F + 1.0;
end if;
return
timespec'(tv_sec => S,
tv_nsec => Long_Long_Integer (F * 10#1#E9));
end To_Timespec;
-----------------
-- Timed_Delay --
-----------------
procedure Timed_Delay
(Time : Duration;
Mode : Integer)
is
Request : aliased timespec;
Remaind : aliased timespec;
Rel_Time : Duration;
Abs_Time : Duration;
Base_Time : constant Duration := Clock;
Check_Time : Duration := Base_Time;
Result : Integer;
pragma Unreferenced (Result);
begin
if Mode = Relative then
Rel_Time := Time;
Abs_Time := Time + Check_Time;
else
Rel_Time := Time - Check_Time;
Abs_Time := Time;
end if;
if Rel_Time > 0.0 then
loop
Request := To_Timespec (Rel_Time);
Result := nanosleep (Request'Access, Remaind'Access);
Check_Time := Clock;
exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
Rel_Time := Abs_Time - Check_Time;
end loop;
end if;
end Timed_Delay;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
null;
end Initialize;
end System.OS_Primitives;
|
tum-ei-rcs/StratoX | Ada | 2,775 | adb | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Author: Martin Becker ([email protected])
with Ada.Tags;
with Ada.Text_IO; -- TODO: remove
with ULog.Identifiers;
-- @summary
-- Implements a serialization of log objects (records,
-- string messages, etc.) according to the self-describing
-- ULOG file format used in PX4.
-- The serialized byte array is returned.
-- this package tries to dispatch to the specific decendants,
-- e.g., ULog.GPS.
package body ULog with SPARK_Mode is
procedure Get_Serialization (msg : in Message; bytes : out HIL.Byte_Array) is
begin
-- TODO: serialize things from root type
null;
end Get_Serialization;
procedure Serialize (msg : in Message'Class; bytes : out HIL.Byte_Array) is
thistag : constant Ada.Tags.Tag := msg'Tag; -- private type -> 'Tag not permitted in SPARK
-- this_ID : constant ULog.Identifiers.ID := ULog.Identifiers.Make_ID (thistag);
begin
-- TODO: serialize common fields
-- TODO: then serialize the message ID (use 'this_ID' as ID)
-- finally, dispatch to serialize the specific message body
Get_Serialization (msg, bytes); -- dispatch to msg's specific type
end Serialize;
procedure Format (msg : in Message'Class; bytes : out HIL.Byte_Array) is
begin
Get_Format (msg => msg, bytes => bytes); -- dispatch
end Format;
procedure Get_Format
(msg : in Message; bytes : out HIL.Byte_Array) is
begin
null;
-- TODO
end Get_Format;
function Copy (msg : in Message) return Message'Class is
begin
return msg;
end Copy;
function Get_Size (msg : in Message) return Interfaces.Unsigned_16 is (0);
function Self (msg : in Message) return ULog.Message'Class is begin
Ada.Text_IO.Put_Line ("Self of ulog");
return Message'(msg);
end Self;
function Size (msg : in Message'Class) return Interfaces.Unsigned_16 is
-- descendant : Message'Class := Self;
descendant : Message'Class := Self (msg); -- factory function
begin
--Ada.Text_IO.Put_Line ("Size() called for type=" & Describe_Func (descendant));
return Get_Size (descendant); -- dispatch
end Size;
procedure Get_Header (bytes : out HIL.Byte_Array) is
begin
-- TODO: iterate (if possible) over all types in Message'Class and
-- dump their format in the bytes array
null;
end Get_Header;
function Describe_Func (msg : in Message) return String is
begin
return "base";
end Describe_Func;
procedure Describe (msg : in Message'Class; namestring : out String) is
begin
namestring := Ada.Tags.Expanded_Name (msg'Tag);
end Describe;
end ULog;
|
godunko/adawebpack | Ada | 3,250 | ads | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2022, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
-- This package define indicies of known object's classes to be used with
-- helper functions to create objects. See WASM.Objects.Constructtors for
-- more information.
with Interfaces;
package WASM.Classes is
pragma Pure;
type Class_Index is new Interfaces.Unsigned_32;
-- This declaration must be synchronized with list of class's names in
-- adawebpack.mjs file.
URL_Search_Params : constant := 0;
XML_Http_Request : constant := 1;
end WASM.Classes;
|
reznikmm/matreshka | Ada | 7,307 | 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.
------------------------------------------------------------------------------
-- Interfaces may include receptions (in addition to operations).
--
-- An interface is a kind of classifier that represents a declaration of a
-- set of coherent public features and obligations. An interface specifies a
-- contract; any instance of a classifier that realizes the interface must
-- fulfill that contract. The obligations that may be associated with an
-- interface are in the form of various kinds of constraints (such as pre-
-- and post-conditions) or protocol specifications, which may impose ordering
-- restrictions on interactions through the interface.
--
-- Since an interface specifies conformance characteristics, it does not own
-- detailed behavior specifications. Instead, interfaces may own a protocol
-- state machine that specifies event sequences and pre/post conditions for
-- the operations and receptions described by the interface.
------------------------------------------------------------------------------
with AMF.UML.Classifiers;
limited with AMF.UML.Classifiers.Collections;
limited with AMF.UML.Interfaces.Collections;
limited with AMF.UML.Operations.Collections;
limited with AMF.UML.Properties.Collections;
limited with AMF.UML.Protocol_State_Machines;
limited with AMF.UML.Receptions.Collections;
package AMF.UML.Interfaces is
pragma Preelaborate;
type UML_Interface is limited interface
and AMF.UML.Classifiers.UML_Classifier;
type UML_Interface_Access is
access all UML_Interface'Class;
for UML_Interface_Access'Storage_Size use 0;
not overriding function Get_Nested_Classifier
(Self : not null access constant UML_Interface)
return AMF.UML.Classifiers.Collections.Ordered_Set_Of_UML_Classifier is abstract;
-- Getter of Interface::nestedClassifier.
--
-- References all the Classifiers that are defined (nested) within the
-- Class.
not overriding function Get_Owned_Attribute
(Self : not null access constant UML_Interface)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property is abstract;
-- Getter of Interface::ownedAttribute.
--
-- The attributes (i.e. the properties) owned by the class.
not overriding function Get_Owned_Operation
(Self : not null access constant UML_Interface)
return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation is abstract;
-- Getter of Interface::ownedOperation.
--
-- The operations owned by the class.
not overriding function Get_Owned_Reception
(Self : not null access constant UML_Interface)
return AMF.UML.Receptions.Collections.Set_Of_UML_Reception is abstract;
-- Getter of Interface::ownedReception.
--
-- Receptions that objects providing this interface are willing to accept.
not overriding function Get_Protocol
(Self : not null access constant UML_Interface)
return AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access is abstract;
-- Getter of Interface::protocol.
--
-- References a protocol state machine specifying the legal sequences of
-- the invocation of the behavioral features described in the interface.
not overriding procedure Set_Protocol
(Self : not null access UML_Interface;
To : AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access) is abstract;
-- Setter of Interface::protocol.
--
-- References a protocol state machine specifying the legal sequences of
-- the invocation of the behavioral features described in the interface.
not overriding function Get_Redefined_Interface
(Self : not null access constant UML_Interface)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface is abstract;
-- Getter of Interface::redefinedInterface.
--
-- References all the Interfaces redefined by this Interface.
end AMF.UML.Interfaces;
|
reznikmm/matreshka | Ada | 460 | ads | limited with Types.Taggeds.Interfaces;
package Types.Taggeds is
pragma Preelaborate;
type Tagged_Type is limited interface;
type Tagged_Type_Access is access all Tagged_Type'Class
with Storage_Size => 0;
not overriding function Progenitors
(Self : Tagged_Type) return Types.Taggeds.Interfaces.Interface_Access_Array
is abstract;
-- Return list of interfaces provided by this type/interface. ARM 3.4(3/2)
end Types.Taggeds;
|
datacomo-dm/DMCloud | Ada | 4,341 | ads | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib-streams.ads,v 1.1.1.1 2004/10/04 01:55:30 Administrator Exp $
package ZLib.Streams is
type Stream_Mode is (In_Stream, Out_Stream, Duplex);
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
type Stream_Type is
new Ada.Streams.Root_Stream_Type with private;
procedure Read
(Stream : in out Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write
(Stream : in out Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
procedure Flush
(Stream : in out Stream_Type;
Mode : in Flush_Mode := Sync_Flush);
-- Flush the written data to the back stream,
-- all data placed to the compressor is flushing to the Back stream.
-- Should not be used untill necessary, becouse it is decreasing
-- compression.
function Read_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_In);
-- Return total number of bytes read from back stream so far.
function Read_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_Out);
-- Return total number of bytes read so far.
function Write_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_In);
-- Return total number of bytes written so far.
function Write_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_Out);
-- Return total number of bytes written to the back stream.
procedure Create
(Stream : out Stream_Type;
Mode : in Stream_Mode;
Back : in Stream_Access;
Back_Compressed : in Boolean;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Header : in Header_Type := Default;
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size);
-- Create the Comression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled.
-- If Back_Compressed is true then
-- Data written to the Stream is compressing to the Back stream
-- and data read from the Stream is decompressed data from the Back stream.
-- If Back_Compressed is false then
-- Data written to the Stream is decompressing to the Back stream
-- and data read from the Stream is compressed data from the Back stream.
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
function Is_Open (Stream : Stream_Type) return Boolean;
procedure Close (Stream : in out Stream_Type);
private
use Ada.Streams;
type Buffer_Access is access all Stream_Element_Array;
type Stream_Type
is new Root_Stream_Type with
record
Mode : Stream_Mode;
Buffer : Buffer_Access;
Rest_First : Stream_Element_Offset;
Rest_Last : Stream_Element_Offset;
-- Buffer for Read operation.
-- We need to have this buffer in the record
-- becouse not all read data from back stream
-- could be processed during the read operation.
Buffer_Size : Stream_Element_Offset;
-- Buffer size for write operation.
-- We do not need to have this buffer
-- in the record becouse all data could be
-- processed in the write operation.
Back : Stream_Access;
Reader : Filter_Type;
Writer : Filter_Type;
end record;
end ZLib.Streams;
|
reznikmm/matreshka | Ada | 3,985 | ads | ------------------------------------------------------------------------------
-- --
-- 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$
------------------------------------------------------------------------------
with Abstract_Sources;
with League.Strings;
with League.Strings.Cursors.Characters;
package String_Sources is
type String_Source is new Abstract_Sources.Abstract_Source with private;
overriding function Get_Next
(Self : not null access String_Source)
return Abstract_Sources.Code_Unit_32;
procedure Create
(Self : out String_Source;
Text : League.Strings.Universal_String);
private
type String_Source is new Abstract_Sources.Abstract_Source with record
Text : League.Strings.Universal_String;
Cursor : League.Strings.Cursors.Characters.Character_Cursor;
end record;
end String_Sources;
|
reznikmm/matreshka | Ada | 3,724 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Layout_Mode_Attributes is
pragma Preelaborate;
type ODF_Table_Layout_Mode_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Layout_Mode_Attribute_Access is
access all ODF_Table_Layout_Mode_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Layout_Mode_Attributes;
|
persan/a-cups | Ada | 4,836 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with System;
private package CUPS.cups_pwg_h is
-- arg-macro: function PWG_FROM_POINTS (int)(((n) * 2540 + 36) / 72
-- return int)(((n) * 2540 + 36) / 72;
-- arg-macro: function PWG_TO_POINTS ((n) * 72.0 / 2540.0
-- return (n) * 72.0 / 2540.0;
-- * "$Id: pwg.h 4274 2013-04-09 20:10:23Z msweet $"
-- *
-- * PWG media API definitions for CUPS.
-- *
-- * Copyright 2009-2013 by Apple Inc.
-- *
-- * These coded instructions, statements, and computer programs are the
-- * property of Apple Inc. and are protected by Federal copyright
-- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
-- * which should have been included with this file. If this file is
-- * file is missing or damaged, see the license at "http://www.cups.org/".
-- *
-- * This file is subject to the Apple OS-Developed Software exception.
--
-- * C++ magic...
--
-- * Macros...
--
-- Convert from points to hundredths of millimeters
-- Convert from hundredths of millimeters to points
-- * Types and structures...
--
--*** Map element - PPD to/from PWG
-- PWG media keyword
type pwg_map_s is record
pwg : Interfaces.C.Strings.chars_ptr; -- cups/pwg.h:46
ppd : Interfaces.C.Strings.chars_ptr; -- cups/pwg.h:47
end record;
pragma Convention (C_Pass_By_Copy, pwg_map_s); -- cups/pwg.h:44
-- PPD option keyword
subtype pwg_map_t is pwg_map_s;
--*** Common media size data ***
-- PWG 5101.1 "self describing" name
type pwg_media_s is record
pwg : Interfaces.C.Strings.chars_ptr; -- cups/pwg.h:52
legacy : Interfaces.C.Strings.chars_ptr; -- cups/pwg.h:53
ppd : Interfaces.C.Strings.chars_ptr; -- cups/pwg.h:54
width : aliased int; -- cups/pwg.h:55
length : aliased int; -- cups/pwg.h:56
end record;
pragma Convention (C_Pass_By_Copy, pwg_media_s); -- cups/pwg.h:50
-- IPP/ISO legacy name
-- Standard Adobe PPD name
-- Width in 2540ths
-- Length in 2540ths
subtype pwg_media_t is pwg_media_s;
--*** Size element - PPD to/from PWG
-- Map element
type pwg_size_s is record
map : aliased pwg_map_t; -- cups/pwg.h:61
width : aliased int; -- cups/pwg.h:62
length : aliased int; -- cups/pwg.h:63
left : aliased int; -- cups/pwg.h:64
bottom : aliased int; -- cups/pwg.h:65
right : aliased int; -- cups/pwg.h:66
top : aliased int; -- cups/pwg.h:67
end record;
pragma Convention (C_Pass_By_Copy, pwg_size_s); -- cups/pwg.h:59
-- Width in 2540ths
-- Length in 2540ths
-- Left margin in 2540ths
-- Bottom margin in 2540ths
-- Right margin in 2540ths
-- Top margin in 2540ths
subtype pwg_size_t is pwg_size_s;
-- * Functions...
--
-- * "$Id: pwg.h 4274 2013-04-09 20:10:23Z msweet $"
-- *
-- * PWG media API definitions for CUPS.
-- *
-- * Copyright 2009-2013 by Apple Inc.
-- *
-- * These coded instructions, statements, and computer programs are the
-- * property of Apple Inc. and are protected by Federal copyright
-- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
-- * which should have been included with this file. If this file is
-- * file is missing or damaged, see the license at "http://www.cups.org/".
-- *
-- * This file is subject to the Apple OS-Developed Software exception.
--
function pwgFormatSizeName
(keyword : Interfaces.C.Strings.chars_ptr;
keysize : size_t;
prefix : Interfaces.C.Strings.chars_ptr;
name : Interfaces.C.Strings.chars_ptr;
width : int;
length : int;
units : Interfaces.C.Strings.chars_ptr) return int; -- cups/pwg.h:75
pragma Import (C, pwgFormatSizeName, "pwgFormatSizeName");
function pwgInitSize
(size : access pwg_size_t;
job : System.Address;
margins_set : access int) return int; -- cups/pwg.h:79
pragma Import (C, pwgInitSize, "pwgInitSize");
function pwgMediaForLegacy (legacy : Interfaces.C.Strings.chars_ptr) return access pwg_media_t; -- cups/pwg.h:81
pragma Import (C, pwgMediaForLegacy, "pwgMediaForLegacy");
function pwgMediaForPPD (ppd : Interfaces.C.Strings.chars_ptr) return access pwg_media_t; -- cups/pwg.h:82
pragma Import (C, pwgMediaForPPD, "pwgMediaForPPD");
function pwgMediaForPWG (pwg : Interfaces.C.Strings.chars_ptr) return access pwg_media_t; -- cups/pwg.h:83
pragma Import (C, pwgMediaForPWG, "pwgMediaForPWG");
function pwgMediaForSize (width : int; length : int) return access pwg_media_t; -- cups/pwg.h:84
pragma Import (C, pwgMediaForSize, "pwgMediaForSize");
end CUPS.cups_pwg_h;
|
zhmu/ananas | Ada | 6,246 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 2 5 --
-- --
-- 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_25 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_25;
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_25 --
------------
function Get_25
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_25
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_25;
------------
-- Set_25 --
------------
procedure Set_25
(Arr : System.Address;
N : Natural;
E : Bits_25;
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_25;
end System.Pack_25;
|
reznikmm/matreshka | Ada | 3,729 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Chart_Angle_Offset_Attributes is
pragma Preelaborate;
type ODF_Chart_Angle_Offset_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Chart_Angle_Offset_Attribute_Access is
access all ODF_Chart_Angle_Offset_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Angle_Offset_Attributes;
|
reznikmm/gela | Ada | 1,674 | ads | -- This package provides Compilation_Manager interface and its methods.
with League.Strings;
with Gela.Contexts;
with Gela.Dependency_Lists;
with Gela.Lexical_Types;
package Gela.Compilation_Managers is
pragma Preelaborate;
type Compilation_Manager is limited interface;
-- Compilation manager reads provided compilation or compilation unit
-- together with any dependency of units.
type Compilation_Manager_Access is access all Compilation_Manager'Class;
for Compilation_Manager_Access'Storage_Size use 0;
not overriding function Context
(Self : Compilation_Manager) return Gela.Contexts.Context_Access
is abstract;
-- Return corresponding context
not overriding procedure Read_Compilation
(Self : in out Compilation_Manager;
Name : League.Strings.Universal_String) is abstract;
-- Read compilation with Name resolve and read all semantic dependency.
-- Name interpreted by source finder object and usually just file name.
not overriding procedure Read_Dependency
(Self : in out Compilation_Manager;
List : Gela.Dependency_Lists.Dependency_List_Access) is abstract;
-- Resolve dependency provided by List and read needed compilation units.
not overriding procedure Read_Declaration
(Self : in out Compilation_Manager;
Symbol : Gela.Lexical_Types.Symbol) is abstract;
-- Read declaration with given symbol and any its dependecy.
not overriding procedure Read_Body
(Self : in out Compilation_Manager;
Symbol : Gela.Lexical_Types.Symbol) is abstract;
-- Read body with given symbol and any its dependecy.
end Gela.Compilation_Managers;
|
annexi-strayline/AURA | Ada | 6,709 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2023, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Exceptions;
with CLI;
with UI_Primitives;
with Unit_Names;
with Registrar.Subsystems;
with Registrar.Library_Units;
with Registrar.Queries;
separate (Depreciation_Handlers)
procedure AURA_Subdirectory (OK_To_Proceed: out Boolean) is
AURA_Subsystem_Name: constant Unit_Names.Unit_Name
:= Unit_Names.Set_Name ("aura");
procedure Process_Changes is separate;
Query_Active: Boolean := False;
begin
-- First check to see if we have the AURA subsystem registered, otherwise
-- we can continue normally.
--
-- Since this handler is invoked after Enter_Root, which only enters units
-- in the project root (and not any subsystem subdirectories), then we
-- expect to have the aura subsystem registered at this point if any only if
-- aura subsystem library units exist in the project root.
if not Registrar.Queries.Subsystem_Registered (AURA_Subsystem_Name) then
OK_To_Proceed := True;
return;
else
OK_To_Proceed := False;
end if;
-- Get user's go-ahead before proceeding. This is a little awkward since
-- we will be invoking the User_Queries.Query_Manager to deliver, handle,
-- and obtain the result of query kind of directly.
--
-- Query_Manager is really meant to be invoked from the Worker tasks, but
-- for the purposes of this handler, we really don't need to make things
-- that complicated
--
-- Since this handler is called between parallelized opereations, we
-- shouldn't expect there to be any unandled queries waiting.
declare
use CLI;
use UI_Primitives;
begin
New_Line;
Put_Warn_Tag;
Put_Line (" DEPRECIATED FEATURE WARNING", Style => Bold + Yellow_FG);
Put_Empty_Tag;
Put_Line
(" This project has aura subsystem sources in the project root.");
Put_Empty_Tag;
Put_Line
(" That is now a depreciated project structure. For this and later");
Put_Empty_Tag;
Put_Line
(" verions of AURA CLI, all aura subsystem sources must be in the");
Put_Empty_Tag;
Put_Line
(" 'aura' subdirectory for AURA CLI to proceed.");
New_Line;
Put_Empty_Tag;
Put_Line
(" AURA CLI can move these files for you, but if you elect not to,");
Put_Empty_Tag;
Put_Line
(" this version of the AURA CLI will not be able to proceed.");
New_Line;
end;
UI_Primitives.Immediate_YN_Query
(Prompt => "Move all aura subsystems sources to 'aura'?",
Default => True,
Response => OK_To_Proceed);
if not OK_To_Proceed then
UI_Primitives.Put_Info_Tag;
CLI.Put_Line (" All aura units must be moved to the 'aura' "
& "subdirectory to continue.");
UI_Primitives.Put_Empty_Tag;
CLI.Put_Line (" AURA CLI will now abort.");
CLI.New_Line;
return;
end if;
-- We have been given the go-ahead by the user.
Process_Changes;
-- Process_Changes sets OK_To_Proceed as appropriate
exception
when e: others =>
CLI.New_Line;
UI_Primitives.Put_Fail_Tag;
CLI.Put_Line ("Unexpected exception: "
& Ada.Exceptions.Exception_Information (e));
UI_Primitives.Put_Empty_Tag;
CLI.Put_Line ("Aborting.");
OK_To_Proceed := False;
end AURA_Subdirectory;
|
zhmu/ananas | Ada | 4,756 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . T R A C E B A C K . S Y M B O L I C --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the default implementation for platforms where the full capability
-- is not supported. It returns tracebacks as lists of hexadecimal addresses
-- of the form "0x...".
with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback;
with System.Address_Image;
package body System.Traceback.Symbolic is
-- Note that Suppress_Hex is ignored in this version of this package.
------------------------
-- Symbolic_Traceback --
------------------------
function Symbolic_Traceback
(Traceback : System.Traceback_Entries.Tracebacks_Array) return String
is
begin
if Traceback'Length = 0 then
return "";
else
declare
Img : String := System.Address_Image (Traceback (Traceback'First));
Result : String (1 .. (Img'Length + 3) * Traceback'Length);
Last : Natural := 0;
begin
for J in Traceback'Range loop
Img := System.Address_Image (Traceback (J));
Result (Last + 1 .. Last + 2) := "0x";
Last := Last + 2;
Result (Last + 1 .. Last + Img'Length) := Img;
Last := Last + Img'Length + 1;
Result (Last) := ' ';
end loop;
Result (Last) := ASCII.LF;
return Result (1 .. Last);
end;
end if;
end Symbolic_Traceback;
-- "No_Hex" is ignored in this version, because otherwise we have nothing
-- at all to print.
function Symbolic_Traceback_No_Hex
(Traceback : System.Traceback_Entries.Tracebacks_Array) return String is
begin
return Symbolic_Traceback (Traceback);
end Symbolic_Traceback_No_Hex;
function Symbolic_Traceback
(E : Ada.Exceptions.Exception_Occurrence) return String
is
begin
return Symbolic_Traceback (Ada.Exceptions.Traceback.Tracebacks (E));
end Symbolic_Traceback;
function Symbolic_Traceback_No_Hex
(E : Ada.Exceptions.Exception_Occurrence) return String is
begin
return Symbolic_Traceback (E);
end Symbolic_Traceback_No_Hex;
------------------
-- Enable_Cache --
------------------
procedure Enable_Cache (Include_Modules : Boolean := False) is
begin
null;
end Enable_Cache;
end System.Traceback.Symbolic;
|
AdaCore/libadalang | Ada | 117 | ads | with Aaa.Aaa.Aaa;
pragma Test_Statement;
package Aaa.Aaa.Ccc is
procedure P;
end Aaa.Aaa.Ccc;
pragma Test_Block;
|
zhmu/ananas | Ada | 56,667 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ D B U G --
-- --
-- B o d y --
-- --
-- Copyright (C) 1996-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Alloc;
with Atree; use Atree;
with Debug; use Debug;
with Einfo; use Einfo;
with Einfo.Entities; use Einfo.Entities;
with Einfo.Utils; use Einfo.Utils;
with Exp_Util; use Exp_Util;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Output; use Output;
with Sem_Aux; use Sem_Aux;
with Sem_Eval; use Sem_Eval;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
with Stand; use Stand;
with Stringt; use Stringt;
with Table;
with Tbuild; use Tbuild;
with Urealp; use Urealp;
package body Exp_Dbug is
-- The following table is used to queue up the entities passed as
-- arguments to Qualify_Entity_Names for later processing when
-- Qualify_All_Entity_Names is called.
package Name_Qualify_Units is new Table.Table (
Table_Component_Type => Node_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => Alloc.Name_Qualify_Units_Initial,
Table_Increment => Alloc.Name_Qualify_Units_Increment,
Table_Name => "Name_Qualify_Units");
--------------------------------
-- Use of Qualification Flags --
--------------------------------
-- There are two flags used to keep track of qualification of entities
-- Has_Fully_Qualified_Name
-- Has_Qualified_Name
-- The difference between these is as follows. Has_Qualified_Name is
-- set to indicate that the name has been qualified as required by the
-- spec of this package. As described there, this may involve the full
-- qualification for the name, but for some entities, notably procedure
-- local variables, this full qualification is not required.
-- The flag Has_Fully_Qualified_Name is set if indeed the name has been
-- fully qualified in the Ada sense. If Has_Fully_Qualified_Name is set,
-- then Has_Qualified_Name is also set, but the other way round is not
-- the case.
-- Consider the following example:
-- with ...
-- procedure X is
-- B : Ddd.Ttt;
-- procedure Y is ..
-- Here B is a procedure local variable, so it does not need fully
-- qualification. The flag Has_Qualified_Name will be set on the
-- first attempt to qualify B, to indicate that the job is done
-- and need not be redone.
-- But Y is qualified as x__y, since procedures are always fully
-- qualified, so the first time that an attempt is made to qualify
-- the name y, it will be replaced by x__y, and both flags are set.
-- Why the two flags? Well there are cases where we derive type names
-- from object names. As noted in the spec, type names are always
-- fully qualified. Suppose for example that the backend has to build
-- a padded type for variable B. then it will construct the PAD name
-- from B, but it requires full qualification, so the fully qualified
-- type name will be x__b___PAD. The two flags allow the circuit for
-- building this name to realize efficiently that b needs further
-- qualification.
--------------------
-- Homonym_Suffix --
--------------------
-- The string defined here (and its associated length) is used to gather
-- the homonym string that will be appended to Name_Buffer when the name
-- is complete. Strip_Suffixes appends to this string as does
-- Append_Homonym_Number, and Output_Homonym_Numbers_Suffix appends the
-- string to the end of Name_Buffer.
Homonym_Numbers : String (1 .. 256);
Homonym_Len : Natural := 0;
----------------------
-- Local Procedures --
----------------------
procedure Add_Uint_To_Buffer (U : Uint);
-- Add image of universal integer to Name_Buffer, updating Name_Len
procedure Add_Real_To_Buffer (U : Ureal);
-- Add nnn_ddd to Name_Buffer, where nnn and ddd are integer values of
-- the normalized numerator and denominator of the given real value.
procedure Append_Homonym_Number (E : Entity_Id);
-- If the entity E has homonyms in the same scope, then make an entry
-- in the Homonym_Numbers array, bumping Homonym_Count accordingly.
function Bounds_Match_Size (E : Entity_Id) return Boolean;
-- Determine whether the bounds of E match the size of the type. This is
-- used to determine whether encoding is required for a discrete type.
procedure Output_Homonym_Numbers_Suffix;
-- If homonym numbers are stored, then output them into Name_Buffer
procedure Prepend_String_To_Buffer (S : String);
-- Prepend given string to the contents of the string buffer, updating
-- the value in Name_Len (i.e. string is added at start of buffer).
procedure Prepend_Uint_To_Buffer (U : Uint);
-- Prepend image of universal integer to Name_Buffer, updating Name_Len
procedure Qualify_Entity_Name (Ent : Entity_Id);
-- If not already done, replaces the Chars field of the given entity
-- with the appropriate fully qualified name.
procedure Reset_Buffers;
-- Reset the contents of Name_Buffer and Homonym_Numbers by setting their
-- respective lengths to zero.
procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean);
-- Given an qualified entity name in Name_Buffer, remove any plain X or
-- X{nb} qualification suffix. The contents of Name_Buffer is not changed
-- but Name_Len may be adjusted on return to remove the suffix. If a
-- BNPE suffix is found and stripped, then BNPE_Suffix_Found is set to
-- True. If no suffix is found, then BNPE_Suffix_Found is not modified.
-- This routine also searches for a homonym suffix, and if one is found
-- it is also stripped, and the entries are added to the global homonym
-- list (Homonym_Numbers) so that they can later be put back.
------------------------
-- Add_Real_To_Buffer --
------------------------
procedure Add_Real_To_Buffer (U : Ureal) is
begin
Add_Uint_To_Buffer (Norm_Num (U));
Add_Char_To_Name_Buffer ('_');
Add_Uint_To_Buffer (Norm_Den (U));
end Add_Real_To_Buffer;
------------------------
-- Add_Uint_To_Buffer --
------------------------
procedure Add_Uint_To_Buffer (U : Uint) is
begin
if U < 0 then
Add_Uint_To_Buffer (-U);
Add_Char_To_Name_Buffer ('m');
else
UI_Image (U, Decimal);
Add_Str_To_Name_Buffer (UI_Image_Buffer (1 .. UI_Image_Length));
end if;
end Add_Uint_To_Buffer;
---------------------------
-- Append_Homonym_Number --
---------------------------
procedure Append_Homonym_Number (E : Entity_Id) is
procedure Add_Nat_To_H (Nr : Nat);
-- Little procedure to append Nr to Homonym_Numbers
------------------
-- Add_Nat_To_H --
------------------
procedure Add_Nat_To_H (Nr : Nat) is
begin
if Nr >= 10 then
Add_Nat_To_H (Nr / 10);
end if;
Homonym_Len := Homonym_Len + 1;
Homonym_Numbers (Homonym_Len) :=
Character'Val (Nr mod 10 + Character'Pos ('0'));
end Add_Nat_To_H;
-- Start of processing for Append_Homonym_Number
begin
if Has_Homonym (E) then
if Homonym_Len > 0 then
Homonym_Len := Homonym_Len + 1;
Homonym_Numbers (Homonym_Len) := '_';
end if;
Add_Nat_To_H (Homonym_Number (E));
end if;
end Append_Homonym_Number;
-----------------------
-- Bounds_Match_Size --
-----------------------
function Bounds_Match_Size (E : Entity_Id) return Boolean is
Siz : Uint;
begin
if not Is_OK_Static_Subtype (E) then
return False;
elsif Is_Integer_Type (E)
and then Subtypes_Statically_Match (E, Base_Type (E))
then
return True;
-- Here we check if the static bounds match the natural size, which is
-- the size passed through with the debugging information. This is the
-- Esize rounded up to 8, 16, 32, 64 or 128 as appropriate.
else
declare
Umark : constant Uintp.Save_Mark := Uintp.Mark;
Result : Boolean;
begin
if Esize (E) <= 8 then
Siz := Uint_8;
elsif Esize (E) <= 16 then
Siz := Uint_16;
elsif Esize (E) <= 32 then
Siz := Uint_32;
elsif Esize (E) <= 64 then
Siz := Uint_64;
else
Siz := Uint_128;
end if;
if Is_Modular_Integer_Type (E) or else Is_Enumeration_Type (E) then
Result :=
Expr_Rep_Value (Type_Low_Bound (E)) = 0
and then
2 ** Siz - Expr_Rep_Value (Type_High_Bound (E)) = 1;
else
Result :=
Expr_Rep_Value (Type_Low_Bound (E)) + 2 ** (Siz - 1) = 0
and then
2 ** (Siz - 1) - Expr_Rep_Value (Type_High_Bound (E)) = 1;
end if;
Release (Umark);
return Result;
end;
end if;
end Bounds_Match_Size;
--------------------------------
-- Debug_Renaming_Declaration --
--------------------------------
function Debug_Renaming_Declaration (N : Node_Id) return Node_Id is
pragma Assert
(Nkind (N) in N_Object_Renaming_Declaration
| N_Package_Renaming_Declaration
| N_Exception_Renaming_Declaration);
Loc : constant Source_Ptr := Sloc (N);
Ent : constant Node_Id := Defining_Entity (N);
Nam : constant Node_Id := Name (N);
Ren : Node_Id;
Typ : Entity_Id;
Obj : Entity_Id;
Res : Node_Id;
Enable : Boolean := Nkind (N) = N_Package_Renaming_Declaration;
-- By default, we do not generate an encoding for renaming. This is
-- however done (in which case this is set to True) in a few cases:
-- - when a package is renamed,
-- - when the renaming involves a packed array,
-- - when the renaming involves a packed record.
Last_Is_Indexed_Comp : Boolean := False;
-- Whether the last subscript value was an indexed component access (XS)
procedure Enable_If_Packed_Array (N : Node_Id);
-- Enable encoding generation if N is a packed array
function Output_Subscript (N : Node_Id; S : String) return Boolean;
-- Outputs a single subscript value as ?nnn (subscript is compile time
-- known value with value nnn) or as ?e (subscript is local constant
-- with name e), where S supplies the proper string to use for ?.
-- Returns False if the subscript is not of an appropriate type to
-- output in one of these two forms. The result is prepended to the
-- name stored in Name_Buffer.
function Scope_Contains
(Outer : Entity_Id;
Inner : Entity_Id)
return Boolean;
-- Return whether Inner belongs to the Outer scope
----------------------------
-- Enable_If_Packed_Array --
----------------------------
procedure Enable_If_Packed_Array (N : Node_Id) is
T : constant Entity_Id := Underlying_Type (Etype (N));
begin
Enable :=
Enable
or else
(Ekind (T) in Array_Kind
and then Present (Packed_Array_Impl_Type (T)));
end Enable_If_Packed_Array;
----------------------
-- Output_Subscript --
----------------------
function Output_Subscript (N : Node_Id; S : String) return Boolean is
begin
if Compile_Time_Known_Value (N) then
Prepend_Uint_To_Buffer (Expr_Value (N));
elsif Nkind (N) = N_Identifier
and then Scope_Contains (Scope (Entity (N)), Ent)
and then Ekind (Entity (N)) in E_Constant | E_In_Parameter
then
Prepend_String_To_Buffer (Get_Name_String (Chars (Entity (N))));
else
return False;
end if;
Prepend_String_To_Buffer (S);
return True;
end Output_Subscript;
--------------------
-- Scope_Contains --
--------------------
function Scope_Contains
(Outer : Entity_Id;
Inner : Entity_Id)
return Boolean
is
Cur : Entity_Id := Scope (Inner);
begin
while Present (Cur) loop
if Cur = Outer then
return True;
end if;
Cur := Scope (Cur);
end loop;
return False;
end Scope_Contains;
-- Start of processing for Debug_Renaming_Declaration
begin
if not Comes_From_Source (N) and then not Needs_Debug_Info (Ent) then
return Empty;
end if;
-- Get renamed entity and compute suffix
Name_Len := 0;
Ren := Nam;
loop
-- The expression that designates the renamed object is sometimes
-- expanded into bit-wise operations. We want to work instead on
-- array/record components accesses, so try to analyze the unexpanded
-- forms.
Ren := Original_Node (Ren);
case Nkind (Ren) is
when N_Expanded_Name
| N_Identifier
=>
if No (Entity (Ren))
or else not Present (Renamed_Entity_Or_Object (Entity (Ren)))
then
exit;
end if;
-- This is a renaming of a renaming: traverse until the final
-- renaming to see if anything is packed along the way.
Ren := Renamed_Entity_Or_Object (Entity (Ren));
when N_Selected_Component =>
declare
Sel_Id : constant Entity_Id :=
Entity (Selector_Name (Ren));
First_Bit : Uint;
begin
-- If the renaming involves a call to a primitive function,
-- we are out of the scope of renaming encodings. We will
-- very likely create a variable to hold the renamed value
-- anyway, so the renaming entity will be available in
-- debuggers.
exit when Ekind (Sel_Id) not in E_Component | E_Discriminant;
First_Bit := Normalized_First_Bit (Sel_Id);
Enable :=
Enable
or else Is_Packed
(Underlying_Type (Etype (Prefix (Ren))))
or else (Present (First_Bit)
and then First_Bit /= Uint_0);
end;
Prepend_String_To_Buffer
(Get_Name_String (Chars (Selector_Name (Ren))));
Prepend_String_To_Buffer ("XR");
Ren := Prefix (Ren);
Last_Is_Indexed_Comp := False;
when N_Indexed_Component =>
declare
X : Node_Id;
begin
Enable_If_Packed_Array (Prefix (Ren));
X := Last (Expressions (Ren));
while Present (X) loop
if not Output_Subscript (X, "XS") then
Set_Materialize_Entity (Ent);
return Empty;
end if;
Prev (X);
Last_Is_Indexed_Comp := True;
end loop;
end;
Ren := Prefix (Ren);
when N_Slice =>
-- Assuming X is an array:
-- X (Y1 .. Y2) (Y3)
-- is equivalent to:
-- X (Y3)
-- GDB cannot handle packed array slices, so avoid describing
-- the slice if we can avoid it.
if not Last_Is_Indexed_Comp then
Enable_If_Packed_Array (Prefix (Ren));
Typ := Etype (First_Index (Etype (Ren)));
if not Output_Subscript (Type_High_Bound (Typ), "XS") then
Set_Materialize_Entity (Ent);
return Empty;
end if;
if not Output_Subscript (Type_Low_Bound (Typ), "XL") then
Set_Materialize_Entity (Ent);
return Empty;
end if;
Last_Is_Indexed_Comp := False;
end if;
Ren := Prefix (Ren);
when N_Explicit_Dereference =>
Prepend_String_To_Buffer ("XA");
Ren := Prefix (Ren);
Last_Is_Indexed_Comp := False;
-- For now, anything else simply results in no translation
when others =>
Set_Materialize_Entity (Ent);
return Empty;
end case;
end loop;
-- If we found no reason here to emit an encoding, stop now
if not Enable then
Set_Materialize_Entity (Ent);
return Empty;
end if;
Prepend_String_To_Buffer ("___XE");
-- Include the designation of the form of renaming
case Nkind (N) is
when N_Object_Renaming_Declaration =>
Prepend_String_To_Buffer ("___XR");
when N_Exception_Renaming_Declaration =>
Prepend_String_To_Buffer ("___XRE");
when N_Package_Renaming_Declaration =>
Prepend_String_To_Buffer ("___XRP");
when others =>
return Empty;
end case;
-- Add the name of the renaming entity to the front
Prepend_String_To_Buffer (Get_Name_String (Chars (Ent)));
-- If it is a child unit create a fully qualified name, to disambiguate
-- multiple child units with the same name and different parents.
if Nkind (N) = N_Package_Renaming_Declaration
and then Is_Child_Unit (Ent)
then
Prepend_String_To_Buffer ("__");
Prepend_String_To_Buffer
(Get_Name_String (Chars (Scope (Ent))));
end if;
-- Create the special object whose name is the debug encoding for the
-- renaming declaration.
-- For now, the object name contains the suffix encoding for the renamed
-- object, but not the name of the leading entity. The object is linked
-- the renamed entity using the Debug_Renaming_Link field. Then the
-- Qualify_Entity_Name procedure uses this link to create the proper
-- fully qualified name.
-- The reason we do things this way is that we really need to copy the
-- qualification of the renamed entity, and it is really much easier to
-- do this after the renamed entity has itself been fully qualified.
Obj := Make_Defining_Identifier (Loc, Chars => Name_Enter);
Res :=
Make_Object_Declaration (Loc,
Defining_Identifier => Obj,
Object_Definition => New_Occurrence_Of
(Standard_Debug_Renaming_Type, Loc));
Set_Debug_Renaming_Link (Obj, Entity (Ren));
Set_Debug_Info_Needed (Obj);
-- The renamed entity may be a temporary, e.g. the result of an
-- implicit dereference in an iterator. Indicate that the temporary
-- itself requires debug information. If the renamed entity comes
-- from source this is a no-op.
Set_Debug_Info_Needed (Entity (Ren));
-- Mark the object as internal so that it won't be initialized when
-- pragma Initialize_Scalars or Normalize_Scalars is in use.
Set_Is_Internal (Obj);
return Res;
-- If we get an exception, just figure it is a case that we cannot
-- successfully handle using our current approach, since this is
-- only for debugging, no need to take the compilation with us.
exception
when others =>
return Make_Null_Statement (Loc);
end Debug_Renaming_Declaration;
----------------------
-- Get_Encoded_Name --
----------------------
-- Note: see spec for details on encodings
procedure Get_Encoded_Name (E : Entity_Id) is
Has_Suffix : Boolean;
begin
-- If not generating code, there is no need to create encoded names, and
-- problems when the back-end is called to annotate types without full
-- code generation. See comments in Get_External_Name for additional
-- details.
-- However we do create encoded names if the back end is active, even
-- if Operating_Mode got reset. Otherwise any serious error reported
-- by the backend calling Error_Msg changes the Compilation_Mode to
-- Check_Semantics, which disables the functionality of this routine,
-- causing the generation of spurious additional errors.
-- Couldn't we just test Original_Operating_Mode here? ???
if Operating_Mode /= Generate_Code and then not Generating_Code then
return;
end if;
Get_Name_String (Chars (E));
-- Nothing to do if we do not have a type
if not Is_Type (E)
-- Or if this is an enumeration base type
or else (Is_Enumeration_Type (E) and then Is_Base_Type (E))
-- Or if this is a dummy type for a renaming
or else (Name_Len >= 3 and then
Name_Buffer (Name_Len - 2 .. Name_Len) = "_XR")
or else (Name_Len >= 4 and then
(Name_Buffer (Name_Len - 3 .. Name_Len) = "_XRE"
or else
Name_Buffer (Name_Len - 3 .. Name_Len) = "_XRP"))
-- For all these cases, just return the name unchanged
then
Name_Buffer (Name_Len + 1) := ASCII.NUL;
return;
end if;
Has_Suffix := True;
-- Generate GNAT encodings when asked to for fixed-point case
if GNAT_Encodings = DWARF_GNAT_Encodings_All
and then Is_Fixed_Point_Type (E)
then
Get_External_Name (E, True, "XF_");
Add_Real_To_Buffer (Delta_Value (E));
if Small_Value (E) /= Delta_Value (E) then
Add_Char_To_Name_Buffer ('_');
Add_Real_To_Buffer (Small_Value (E));
end if;
-- Likewise for discrete case where bounds do not match size
elsif GNAT_Encodings = DWARF_GNAT_Encodings_All
and then Is_Discrete_Type (E)
and then not Bounds_Match_Size (E)
then
declare
Lo : constant Node_Id := Type_Low_Bound (E);
Hi : constant Node_Id := Type_High_Bound (E);
Lo_Con : constant Boolean := Compile_Time_Known_Value (Lo);
Hi_Con : constant Boolean := Compile_Time_Known_Value (Hi);
Lo_Discr : constant Boolean :=
Nkind (Lo) = N_Identifier
and then Ekind (Entity (Lo)) = E_Discriminant;
Hi_Discr : constant Boolean :=
Nkind (Hi) = N_Identifier
and then Ekind (Entity (Hi)) = E_Discriminant;
Lo_Encode : constant Boolean := Lo_Con or Lo_Discr;
Hi_Encode : constant Boolean := Hi_Con or Hi_Discr;
Biased : constant Boolean := Has_Biased_Representation (E);
begin
if Biased then
Get_External_Name (E, True, "XB");
else
Get_External_Name (E, True, "XD");
end if;
if Lo_Encode or Hi_Encode then
if Biased then
Add_Char_To_Name_Buffer ('_');
else
if Lo_Encode then
if Hi_Encode then
Add_Str_To_Name_Buffer ("LU_");
else
Add_Str_To_Name_Buffer ("L_");
end if;
else
Add_Str_To_Name_Buffer ("U_");
end if;
end if;
if Lo_Con then
Add_Uint_To_Buffer (Expr_Rep_Value (Lo));
elsif Lo_Discr then
Get_Name_String_And_Append (Chars (Entity (Lo)));
end if;
if Lo_Encode and Hi_Encode then
Add_Str_To_Name_Buffer ("__");
end if;
if Hi_Con then
Add_Uint_To_Buffer (Expr_Rep_Value (Hi));
elsif Hi_Discr then
Get_Name_String_And_Append (Chars (Entity (Hi)));
end if;
end if;
end;
-- For all other cases, the encoded name is the normal type name
else
Has_Suffix := False;
Get_External_Name (E);
end if;
if Debug_Flag_B and then Has_Suffix then
Write_Str ("**** type ");
Write_Name (Chars (E));
Write_Str (" is encoded as ");
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Eol;
end if;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
end Get_Encoded_Name;
-----------------------
-- Get_External_Name --
-----------------------
procedure Get_External_Name
(Entity : Entity_Id;
Has_Suffix : Boolean := False;
Suffix : String := "")
is
procedure Get_Qualified_Name_And_Append (Entity : Entity_Id);
-- Appends fully qualified name of given entity to Name_Buffer
-----------------------------------
-- Get_Qualified_Name_And_Append --
-----------------------------------
procedure Get_Qualified_Name_And_Append (Entity : Entity_Id) is
begin
-- If the entity is a compilation unit, its scope is Standard,
-- there is no outer scope, and the no further qualification
-- is required.
-- If the front end has already computed a fully qualified name,
-- then it is also the case that no further qualification is
-- required.
if Present (Scope (Scope (Entity)))
and then not Has_Fully_Qualified_Name (Entity)
then
Get_Qualified_Name_And_Append (Scope (Entity));
Add_Str_To_Name_Buffer ("__");
Get_Name_String_And_Append (Chars (Entity));
Append_Homonym_Number (Entity);
else
Get_Name_String_And_Append (Chars (Entity));
end if;
end Get_Qualified_Name_And_Append;
-- Local variables
E : Entity_Id := Entity;
-- Start of processing for Get_External_Name
begin
-- If we are not in code generation mode, this procedure may still be
-- called from Back_End (more specifically - from gigi for doing type
-- representation annotation or some representation-specific checks).
-- But in this mode there is no need to mess with external names.
-- Furthermore, the call causes difficulties in this case because the
-- string representing the homonym number is not correctly reset as a
-- part of the call to Output_Homonym_Numbers_Suffix (which is not
-- called in gigi).
if Operating_Mode /= Generate_Code then
return;
end if;
Reset_Buffers;
-- If this is a child unit, we want the child
if Nkind (E) = N_Defining_Program_Unit_Name then
E := Defining_Identifier (Entity);
end if;
-- Case of interface name being used
if Ekind (E) in E_Constant
| E_Exception
| E_Function
| E_Procedure
| E_Variable
and then Present (Interface_Name (E))
and then No (Address_Clause (E))
and then not Has_Suffix
then
Append (Global_Name_Buffer, Strval (Interface_Name (E)));
-- All other cases besides the interface name case
else
-- If this is a library level subprogram (i.e. a subprogram that is a
-- compilation unit other than a subunit), then we prepend _ada_ to
-- ensure distinctions required as described in the spec.
-- Check explicitly for child units, because those are not flagged
-- as Compilation_Units by lib. Should they be ???
if Is_Subprogram (E)
and then (Is_Compilation_Unit (E) or Is_Child_Unit (E))
and then not Has_Suffix
then
Add_Str_To_Name_Buffer ("_ada_");
end if;
-- If the entity is a subprogram instance that is not a compilation
-- unit, generate the name of the original Ada entity, which is the
-- one gdb needs.
if Is_Generic_Instance (E)
and then Is_Subprogram (E)
and then not Is_Compilation_Unit (Scope (E))
and then Ekind (Scope (E)) in E_Package | E_Package_Body
and then Present (Related_Instance (Scope (E)))
then
E := Related_Instance (Scope (E));
end if;
Get_Qualified_Name_And_Append (E);
end if;
if Has_Suffix then
Add_Str_To_Name_Buffer ("___");
Add_Str_To_Name_Buffer (Suffix);
end if;
-- Add a special prefix to distinguish Ghost entities. In Ignored Ghost
-- mode, these entities should not leak in the "living" space and they
-- should be removed by the compiler in a post-processing pass. Thus,
-- the prefix allows anyone to check that the final executable indeed
-- does not contain such entities, in such a case. Do not insert this
-- prefix for compilation units, whose name is used as a basis for the
-- name of the generated elaboration procedure and (when appropriate)
-- the executable produced. Only insert this prefix once, for Ghost
-- entities declared inside other Ghost entities. Three leading
-- underscores are used so that "___ghost_" is a unique substring of
-- names produced for Ghost entities, while "__ghost_" can appear in
-- names of entities inside a child/local package called "Ghost".
-- The compiler-generated finalizer for an enabled Ghost unit is treated
-- specially, as its name must be known to the binder, which has no
-- knowledge of Ghost status. In that case, the finalizer is not marked
-- as Ghost so that no prefix is added. Note that the special ___ghost_
-- prefix is retained when the Ghost unit is ignored, which still allows
-- inspecting the final executable for the presence of an ignored Ghost
-- finalizer procedure.
if Is_Ghost_Entity (E)
and then not Is_Compilation_Unit (E)
and then (Name_Len < 9
or else Name_Buffer (1 .. 9) /= "___ghost_")
then
Insert_Str_In_Name_Buffer ("___ghost_", 1);
end if;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
end Get_External_Name;
--------------------------
-- Get_Variant_Encoding --
--------------------------
procedure Get_Variant_Encoding (V : Node_Id) is
Choice : Node_Id;
procedure Choice_Val (Typ : Character; Choice : Node_Id);
-- Output encoded value for a single choice value. Typ is the key
-- character ('S', 'F', or 'T') that precedes the choice value.
----------------
-- Choice_Val --
----------------
procedure Choice_Val (Typ : Character; Choice : Node_Id) is
begin
if Nkind (Choice) = N_Integer_Literal then
Add_Char_To_Name_Buffer (Typ);
Add_Uint_To_Buffer (Intval (Choice));
-- Character literal with no entity present (this is the case
-- Standard.Character or Standard.Wide_Character as root type)
elsif Nkind (Choice) = N_Character_Literal
and then No (Entity (Choice))
then
Add_Char_To_Name_Buffer (Typ);
Add_Uint_To_Buffer (Char_Literal_Value (Choice));
else
declare
Ent : constant Entity_Id := Entity (Choice);
begin
if Ekind (Ent) = E_Enumeration_Literal then
Add_Char_To_Name_Buffer (Typ);
Add_Uint_To_Buffer (Enumeration_Rep (Ent));
else
pragma Assert (Ekind (Ent) = E_Constant);
Choice_Val (Typ, Constant_Value (Ent));
end if;
end;
end if;
end Choice_Val;
-- Start of processing for Get_Variant_Encoding
begin
Name_Len := 0;
Choice := First (Discrete_Choices (V));
while Present (Choice) loop
if Nkind (Choice) = N_Others_Choice then
Add_Char_To_Name_Buffer ('O');
elsif Nkind (Choice) = N_Range then
Choice_Val ('R', Low_Bound (Choice));
Choice_Val ('T', High_Bound (Choice));
elsif Is_Entity_Name (Choice)
and then Is_Type (Entity (Choice))
then
Choice_Val ('R', Type_Low_Bound (Entity (Choice)));
Choice_Val ('T', Type_High_Bound (Entity (Choice)));
elsif Nkind (Choice) = N_Subtype_Indication then
declare
Rang : constant Node_Id :=
Range_Expression (Constraint (Choice));
begin
Choice_Val ('R', Low_Bound (Rang));
Choice_Val ('T', High_Bound (Rang));
end;
else
Choice_Val ('S', Choice);
end if;
Next (Choice);
end loop;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
if Debug_Flag_B then
declare
VP : constant Node_Id := Parent (V); -- Variant_Part
CL : constant Node_Id := Parent (VP); -- Component_List
RD : constant Node_Id := Parent (CL); -- Record_Definition
FT : constant Node_Id := Parent (RD); -- Full_Type_Declaration
begin
Write_Str ("**** variant for type ");
Write_Name (Chars (Defining_Identifier (FT)));
Write_Str (" is encoded as ");
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Eol;
end;
end if;
end Get_Variant_Encoding;
-----------------------------------------
-- Build_Subprogram_Instance_Renamings --
-----------------------------------------
procedure Build_Subprogram_Instance_Renamings
(N : Node_Id;
Wrapper : Entity_Id)
is
Loc : Source_Ptr;
Decl : Node_Id;
E : Entity_Id;
begin
E := First_Entity (Wrapper);
while Present (E) loop
if Nkind (Parent (E)) = N_Object_Declaration
and then Is_Elementary_Type (Etype (E))
then
Loc := Sloc (Expression (Parent (E)));
Decl := Make_Object_Renaming_Declaration (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc, Chars (E)),
Subtype_Mark => New_Occurrence_Of (Etype (E), Loc),
Name => New_Occurrence_Of (E, Loc));
Append (Decl, Declarations (N));
Set_Debug_Info_Needed (Defining_Identifier (Decl));
end if;
Next_Entity (E);
end loop;
end Build_Subprogram_Instance_Renamings;
------------------------------------
-- Get_Secondary_DT_External_Name --
------------------------------------
procedure Get_Secondary_DT_External_Name
(Typ : Entity_Id;
Ancestor_Typ : Entity_Id;
Suffix_Index : Int)
is
begin
Get_External_Name (Typ);
if Ancestor_Typ /= Typ then
declare
Len : constant Natural := Name_Len;
Save_Str : constant String (1 .. Name_Len)
:= Name_Buffer (1 .. Name_Len);
begin
Get_External_Name (Ancestor_Typ);
-- Append the extended name of the ancestor to the
-- extended name of Typ
Name_Buffer (Len + 2 .. Len + Name_Len + 1) :=
Name_Buffer (1 .. Name_Len);
Name_Buffer (1 .. Len) := Save_Str;
Name_Buffer (Len + 1) := '_';
Name_Len := Len + Name_Len + 1;
end;
end if;
Add_Nat_To_Name_Buffer (Suffix_Index);
end Get_Secondary_DT_External_Name;
---------------------------------
-- Make_Packed_Array_Impl_Type_Name --
---------------------------------
function Make_Packed_Array_Impl_Type_Name
(Typ : Entity_Id;
Csize : Uint)
return Name_Id
is
begin
Get_Name_String (Chars (Typ));
Add_Str_To_Name_Buffer ("___XP");
Add_Uint_To_Buffer (Csize);
return Name_Find;
end Make_Packed_Array_Impl_Type_Name;
-----------------------------------
-- Output_Homonym_Numbers_Suffix --
-----------------------------------
procedure Output_Homonym_Numbers_Suffix is
J : Natural;
begin
if Homonym_Len > 0 then
-- Check for all 1's, in which case we do not output
J := 1;
loop
exit when Homonym_Numbers (J) /= '1';
-- If we reached end of string we do not output
if J = Homonym_Len then
Homonym_Len := 0;
return;
end if;
exit when Homonym_Numbers (J + 1) /= '_';
J := J + 2;
end loop;
-- If we exit the loop then suffix must be output
Add_Str_To_Name_Buffer ("__");
Add_Str_To_Name_Buffer (Homonym_Numbers (1 .. Homonym_Len));
Homonym_Len := 0;
end if;
end Output_Homonym_Numbers_Suffix;
------------------------------
-- Prepend_String_To_Buffer --
------------------------------
procedure Prepend_String_To_Buffer (S : String) is
N : constant Integer := S'Length;
begin
Name_Buffer (1 + N .. Name_Len + N) := Name_Buffer (1 .. Name_Len);
Name_Buffer (1 .. N) := S;
Name_Len := Name_Len + N;
end Prepend_String_To_Buffer;
----------------------------
-- Prepend_Uint_To_Buffer --
----------------------------
procedure Prepend_Uint_To_Buffer (U : Uint) is
begin
if U < 0 then
Prepend_String_To_Buffer ("m");
Prepend_Uint_To_Buffer (-U);
else
UI_Image (U, Decimal);
Prepend_String_To_Buffer (UI_Image_Buffer (1 .. UI_Image_Length));
end if;
end Prepend_Uint_To_Buffer;
------------------------------
-- Qualify_All_Entity_Names --
------------------------------
procedure Qualify_All_Entity_Names is
E : Entity_Id;
Ent : Entity_Id;
Nod : Node_Id;
begin
for J in Name_Qualify_Units.First .. Name_Qualify_Units.Last loop
Nod := Name_Qualify_Units.Table (J);
-- When a scoping construct is ignored Ghost, it is rewritten as
-- a null statement. Skip such constructs as they no longer carry
-- names.
if Nkind (Nod) = N_Null_Statement then
goto Continue;
end if;
E := Defining_Entity (Nod);
Reset_Buffers;
Qualify_Entity_Name (E);
-- Normally entities in the qualification list are scopes, but in the
-- case of a library-level package renaming there is an associated
-- variable that encodes the debugger name and that variable is
-- entered in the list since it occurs in the Aux_Decls list of the
-- compilation and doesn't have a normal scope.
if Ekind (E) /= E_Variable then
Ent := First_Entity (E);
while Present (Ent) loop
Reset_Buffers;
Qualify_Entity_Name (Ent);
Next_Entity (Ent);
-- There are odd cases where Last_Entity (E) = E. This happens
-- in the case of renaming of packages. This test avoids
-- getting stuck in such cases.
exit when Ent = E;
end loop;
end if;
<<Continue>>
null;
end loop;
end Qualify_All_Entity_Names;
-------------------------
-- Qualify_Entity_Name --
-------------------------
procedure Qualify_Entity_Name (Ent : Entity_Id) is
Full_Qualify_Name : String (1 .. Name_Buffer'Length);
Full_Qualify_Len : Natural := 0;
-- Used to accumulate fully qualified name of subprogram
procedure Fully_Qualify_Name (E : Entity_Id);
-- Used to qualify a subprogram or type name, where full
-- qualification up to Standard is always used. Name is set
-- in Full_Qualify_Name with the length in Full_Qualify_Len.
-- Note that this routine does not prepend the _ada_ string
-- required for library subprograms (this is done in the back end).
function Is_BNPE (S : Entity_Id) return Boolean;
-- Determines if S is a BNPE, i.e. Body-Nested Package Entity, which
-- is defined to be a package which is immediately nested within a
-- package body.
function Qualify_Needed (S : Entity_Id) return Boolean;
-- Given a scope, determines if the scope is to be included in the
-- fully qualified name, True if so, False if not. Blocks and loops
-- are excluded from a qualified name.
procedure Set_BNPE_Suffix (E : Entity_Id);
-- Recursive routine to append the BNPE qualification suffix. Works
-- from right to left with E being the current entity in the list.
-- The result does NOT have the trailing n's and trailing b stripped.
-- The caller must do this required stripping.
procedure Set_Entity_Name (E : Entity_Id);
-- Internal recursive routine that does most of the work. This routine
-- leaves the result sitting in Name_Buffer and Name_Len.
BNPE_Suffix_Needed : Boolean := False;
-- Set true if a body-nested package entity suffix is required
Save_Chars : constant Name_Id := Chars (Ent);
-- Save original name
------------------------
-- Fully_Qualify_Name --
------------------------
procedure Fully_Qualify_Name (E : Entity_Id) is
Discard : Boolean := False;
begin
-- Ignore empty entry (can happen in error cases)
if No (E) then
return;
-- If this we are qualifying entities local to a generic instance,
-- use the name of the original instantiation, not that of the
-- anonymous subprogram in the wrapper package, so that gdb doesn't
-- have to know about these.
elsif Is_Generic_Instance (E)
and then Is_Subprogram (E)
and then not Comes_From_Source (E)
and then not Is_Compilation_Unit (Scope (E))
then
Fully_Qualify_Name (Related_Instance (Scope (E)));
return;
end if;
-- If we reached fully qualified name, then just copy it
if Has_Fully_Qualified_Name (E) then
Get_Name_String (Chars (E));
Strip_Suffixes (Discard);
Full_Qualify_Name (1 .. Name_Len) := Name_Buffer (1 .. Name_Len);
Full_Qualify_Len := Name_Len;
Set_Has_Fully_Qualified_Name (Ent);
-- Case of non-fully qualified name
else
if Scope (E) = Standard_Standard then
Set_Has_Fully_Qualified_Name (Ent);
else
Fully_Qualify_Name (Scope (E));
Full_Qualify_Name (Full_Qualify_Len + 1) := '_';
Full_Qualify_Name (Full_Qualify_Len + 2) := '_';
Full_Qualify_Len := Full_Qualify_Len + 2;
end if;
if Has_Qualified_Name (E) then
Get_Unqualified_Name_String (Chars (E));
else
Get_Name_String (Chars (E));
end if;
-- Here we do one step of the qualification
Full_Qualify_Name
(Full_Qualify_Len + 1 .. Full_Qualify_Len + Name_Len) :=
Name_Buffer (1 .. Name_Len);
Full_Qualify_Len := Full_Qualify_Len + Name_Len;
Append_Homonym_Number (E);
end if;
if Is_BNPE (E) then
BNPE_Suffix_Needed := True;
end if;
end Fully_Qualify_Name;
-------------
-- Is_BNPE --
-------------
function Is_BNPE (S : Entity_Id) return Boolean is
begin
return Ekind (S) = E_Package and then Is_Package_Body_Entity (S);
end Is_BNPE;
--------------------
-- Qualify_Needed --
--------------------
function Qualify_Needed (S : Entity_Id) return Boolean is
begin
-- If we got all the way to Standard, then we have certainly
-- fully qualified the name, so set the flag appropriately,
-- and then return False, since we are most certainly done.
if S = Standard_Standard then
Set_Has_Fully_Qualified_Name (Ent, True);
return False;
-- Otherwise figure out if further qualification is required
else
return Is_Subprogram (Ent)
or else Ekind (Ent) = E_Subprogram_Body
or else (Ekind (S) /= E_Block
and then Ekind (S) /= E_Loop
and then not Is_Dynamic_Scope (S));
end if;
end Qualify_Needed;
---------------------
-- Set_BNPE_Suffix --
---------------------
procedure Set_BNPE_Suffix (E : Entity_Id) is
S : constant Entity_Id := Scope (E);
begin
if Qualify_Needed (S) then
Set_BNPE_Suffix (S);
if Is_BNPE (E) then
Add_Char_To_Name_Buffer ('b');
else
Add_Char_To_Name_Buffer ('n');
end if;
else
Add_Char_To_Name_Buffer ('X');
end if;
end Set_BNPE_Suffix;
---------------------
-- Set_Entity_Name --
---------------------
procedure Set_Entity_Name (E : Entity_Id) is
S : constant Entity_Id := Scope (E);
begin
-- If we reach an already qualified name, just take the encoding
-- except that we strip the package body suffixes, since these
-- will be separately put on later.
if Has_Qualified_Name (E) then
Get_Name_String_And_Append (Chars (E));
Strip_Suffixes (BNPE_Suffix_Needed);
-- If the top level name we are adding is itself fully
-- qualified, then that means that the name that we are
-- preparing for the Fully_Qualify_Name call will also
-- generate a fully qualified name.
if Has_Fully_Qualified_Name (E) then
Set_Has_Fully_Qualified_Name (Ent);
end if;
-- Case where upper level name is not encoded yet
else
-- Recurse if further qualification required
if Qualify_Needed (S) then
Set_Entity_Name (S);
Add_Str_To_Name_Buffer ("__");
end if;
-- Otherwise get name and note if it is a BNPE
Get_Name_String_And_Append (Chars (E));
if Is_BNPE (E) then
BNPE_Suffix_Needed := True;
end if;
Append_Homonym_Number (E);
end if;
end Set_Entity_Name;
-- Start of processing for Qualify_Entity_Name
begin
if Has_Qualified_Name (Ent) then
return;
-- If the entity is a variable encoding the debug name for an object
-- renaming, then the qualified name of the entity associated with the
-- renamed object can now be incorporated in the debug name.
elsif Ekind (Ent) = E_Variable
and then Present (Debug_Renaming_Link (Ent))
then
Name_Len := 0;
Qualify_Entity_Name (Debug_Renaming_Link (Ent));
Get_Name_String (Chars (Ent));
-- Retrieve the now-qualified name of the renamed entity and insert
-- it in the middle of the name, just preceding the suffix encoding
-- describing the renamed object.
declare
Renamed_Id : constant String :=
Get_Name_String (Chars (Debug_Renaming_Link (Ent)));
Insert_Len : constant Integer := Renamed_Id'Length + 1;
Index : Natural := Name_Len - 3;
begin
-- Loop backwards through the name to find the start of the "___"
-- sequence associated with the suffix.
while Index >= Name_Buffer'First
and then (Name_Buffer (Index + 1) /= '_'
or else Name_Buffer (Index + 2) /= '_'
or else Name_Buffer (Index + 3) /= '_')
loop
Index := Index - 1;
end loop;
pragma Assert (Name_Buffer (Index + 1 .. Index + 3) = "___");
-- Insert an underscore separator and the entity name just in
-- front of the suffix.
Name_Buffer (Index + 1 + Insert_Len .. Name_Len + Insert_Len) :=
Name_Buffer (Index + 1 .. Name_Len);
Name_Buffer (Index + 1) := '_';
Name_Buffer (Index + 2 .. Index + Insert_Len) := Renamed_Id;
Name_Len := Name_Len + Insert_Len;
end;
-- Reset the name of the variable to the new name that includes the
-- name of the renamed entity.
Set_Chars (Ent, Name_Enter);
-- If the entity needs qualification by its scope then develop it
-- here, add the variable's name, and again reset the entity name.
if Qualify_Needed (Scope (Ent)) then
Name_Len := 0;
Set_Entity_Name (Scope (Ent));
Add_Str_To_Name_Buffer ("__");
Get_Name_String_And_Append (Chars (Ent));
Set_Chars (Ent, Name_Enter);
end if;
Set_Has_Qualified_Name (Ent);
return;
elsif Is_Subprogram (Ent)
or else Ekind (Ent) = E_Subprogram_Body
or else Is_Type (Ent)
or else Ekind (Ent) = E_Exception
then
Fully_Qualify_Name (Ent);
Name_Len := Full_Qualify_Len;
Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len);
-- Qualification needed for enumeration literals when generating C code
-- (to simplify their management in the backend).
elsif Modify_Tree_For_C
and then Ekind (Ent) = E_Enumeration_Literal
and then Scope (Ultimate_Alias (Ent)) /= Standard_Standard
then
Fully_Qualify_Name (Ent);
Name_Len := Full_Qualify_Len;
Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len);
elsif Qualify_Needed (Scope (Ent)) then
Name_Len := 0;
Set_Entity_Name (Ent);
else
Set_Has_Qualified_Name (Ent);
-- If a variable is hidden by a subsequent loop variable, qualify
-- the name of that loop variable to prevent visibility issues when
-- translating to C. Note that gdb probably never handled properly
-- this accidental hiding, given that loops are not scopes at
-- runtime. We also qualify a name if it hides an outer homonym,
-- and both are declared in blocks.
if Modify_Tree_For_C and then Ekind (Ent) = E_Variable then
if Present (Hiding_Loop_Variable (Ent)) then
declare
Var : constant Entity_Id := Hiding_Loop_Variable (Ent);
begin
Set_Entity_Name (Var);
Add_Char_To_Name_Buffer ('L');
Set_Chars (Var, Name_Enter);
end;
elsif Present (Homonym (Ent))
and then Ekind (Scope (Ent)) = E_Block
and then Ekind (Scope (Homonym (Ent))) = E_Block
then
Set_Entity_Name (Ent);
Add_Char_To_Name_Buffer ('B');
Set_Chars (Ent, Name_Enter);
end if;
end if;
return;
end if;
-- Fall through with a fully qualified name in Name_Buffer/Name_Len
Output_Homonym_Numbers_Suffix;
-- Add body-nested package suffix if required
if BNPE_Suffix_Needed
and then Ekind (Ent) /= E_Enumeration_Literal
then
Set_BNPE_Suffix (Ent);
-- Strip trailing n's and last trailing b as required. Note that
-- we know there is at least one b, or no suffix would be generated.
while Name_Buffer (Name_Len) = 'n' loop
Name_Len := Name_Len - 1;
end loop;
Name_Len := Name_Len - 1;
end if;
Set_Chars (Ent, Name_Enter);
Set_Has_Qualified_Name (Ent);
if Debug_Flag_BB then
Write_Str ("*** ");
Write_Name (Save_Chars);
Write_Str (" qualified as ");
Write_Name (Chars (Ent));
Write_Eol;
end if;
end Qualify_Entity_Name;
--------------------------
-- Qualify_Entity_Names --
--------------------------
procedure Qualify_Entity_Names (N : Node_Id) is
begin
Name_Qualify_Units.Append (N);
end Qualify_Entity_Names;
-------------------
-- Reset_Buffers --
-------------------
procedure Reset_Buffers is
begin
Name_Len := 0;
Homonym_Len := 0;
end Reset_Buffers;
--------------------
-- Strip_Suffixes --
--------------------
procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean) is
SL : Natural;
pragma Warnings (Off, BNPE_Suffix_Found);
-- Since this procedure only ever sets the flag
begin
-- Search for and strip BNPE suffix
for J in reverse 2 .. Name_Len loop
if Name_Buffer (J) = 'X' then
Name_Len := J - 1;
BNPE_Suffix_Found := True;
exit;
end if;
exit when Name_Buffer (J) /= 'b' and then Name_Buffer (J) /= 'n';
end loop;
-- Search for and strip homonym numbers suffix
for J in reverse 2 .. Name_Len - 2 loop
if Name_Buffer (J) = '_'
and then Name_Buffer (J + 1) = '_'
then
if Name_Buffer (J + 2) in '0' .. '9' then
if Homonym_Len > 0 then
Homonym_Len := Homonym_Len + 1;
Homonym_Numbers (Homonym_Len) := '-';
end if;
SL := Name_Len - (J + 1);
Homonym_Numbers (Homonym_Len + 1 .. Homonym_Len + SL) :=
Name_Buffer (J + 2 .. Name_Len);
Name_Len := J - 1;
Homonym_Len := Homonym_Len + SL;
end if;
exit;
end if;
end loop;
end Strip_Suffixes;
end Exp_Dbug;
|
stcarrez/ada-css | Ada | 1,616 | ads | -----------------------------------------------------------------------
-- css-analysis-rules-tests -- Unit tests for CSS rule analyzer
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Tests;
package CSS.Analysis.Rules.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test_Case with record
Name : Ada.Strings.Unbounded.Unbounded_String;
File : Ada.Strings.Unbounded.Unbounded_String;
Expect : Ada.Strings.Unbounded.Unbounded_String;
Result : Ada.Strings.Unbounded.Unbounded_String;
Has_Error : Boolean := False;
end record;
type Test_Case_Access is access all Test;
-- Test case name
overriding
function Name (T : Test) return Util.Tests.Message_String;
-- Perform the test.
overriding
procedure Run_Test (T : in out Test);
end CSS.Analysis.Rules.Tests;
|
optikos/oasis | Ada | 4,705 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Real_Range_Specifications;
with Program.Elements.Ordinary_Fixed_Point_Types;
with Program.Element_Visitors;
package Program.Nodes.Ordinary_Fixed_Point_Types is
pragma Preelaborate;
type Ordinary_Fixed_Point_Type is
new Program.Nodes.Node
and Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type
and Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type_Text
with private;
function Create
(Delta_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Delta_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : not null Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access)
return Ordinary_Fixed_Point_Type;
type Implicit_Ordinary_Fixed_Point_Type is
new Program.Nodes.Node
and Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type
with private;
function Create
(Delta_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : not null Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Ordinary_Fixed_Point_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Ordinary_Fixed_Point_Type is
abstract new Program.Nodes.Node
and Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type
with record
Delta_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : not null Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Ordinary_Fixed_Point_Type'Class);
overriding procedure Visit
(Self : not null access Base_Ordinary_Fixed_Point_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Delta_Expression
(Self : Base_Ordinary_Fixed_Point_Type)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Real_Range
(Self : Base_Ordinary_Fixed_Point_Type)
return not null Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
overriding function Is_Ordinary_Fixed_Point_Type_Element
(Self : Base_Ordinary_Fixed_Point_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Ordinary_Fixed_Point_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Ordinary_Fixed_Point_Type)
return Boolean;
type Ordinary_Fixed_Point_Type is
new Base_Ordinary_Fixed_Point_Type
and Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type_Text
with record
Delta_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Ordinary_Fixed_Point_Type_Text
(Self : aliased in out Ordinary_Fixed_Point_Type)
return Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type_Text_Access;
overriding function Delta_Token
(Self : Ordinary_Fixed_Point_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Ordinary_Fixed_Point_Type is
new Base_Ordinary_Fixed_Point_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Ordinary_Fixed_Point_Type_Text
(Self : aliased in out Implicit_Ordinary_Fixed_Point_Type)
return Program.Elements.Ordinary_Fixed_Point_Types
.Ordinary_Fixed_Point_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Ordinary_Fixed_Point_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Ordinary_Fixed_Point_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Ordinary_Fixed_Point_Type)
return Boolean;
end Program.Nodes.Ordinary_Fixed_Point_Types;
|
sungyeon/drake | Ada | 4,629 | adb | with Ada.Command_Line;
with Ada.Environment_Variables;
procedure cmdline is
Count : Natural;
type String_Access is access String;
type Pair is record
Name, Value : String_Access;
end record;
Rec : array (1 .. 255) of Pair;
begin
Ada.Debug.Put (Ada.Command_Line.Command_Name);
-- iterate command line arguments
Ada.Debug.Put ("*** args(1) ***");
for I in 1 .. Ada.Command_Line.Argument_Count loop
Ada.Debug.Put (Ada.Command_Line.Argument (I));
end loop;
-- iterate command line arguments by iterator (forward)
Ada.Debug.Put ("*** args(2) ***");
declare
Count_2 : Natural := 0;
Ite : Ada.Command_Line.Iterator_Interfaces.Reversible_Iterator'Class :=
Ada.Command_Line.Iterate;
Pos : Natural := Ada.Command_Line.Iterator_Interfaces.First (Ite);
begin
while Ada.Command_Line.Has_Element (Pos) loop
Count_2 := Count_2 + 1;
pragma Assert (Count_2 = Pos);
Pos := Ada.Command_Line.Iterator_Interfaces.Next (Ite, Pos);
end loop;
pragma Assert (Count_2 = Ada.Command_Line.Argument_Count);
end;
-- iterate command line arguments by iterator (backward)
Ada.Debug.Put ("*** args(3) ***");
declare
Count_2 : Natural := 0;
Ite : Ada.Command_Line.Iterator_Interfaces.Reversible_Iterator'Class :=
Ada.Command_Line.Iterate;
Pos : Natural := Ada.Command_Line.Iterator_Interfaces.Last (Ite);
begin
while Ada.Command_Line.Has_Element (Pos) loop
pragma Assert (Ada.Command_Line.Argument_Count - Count_2 = Pos);
Count_2 := Count_2 + 1;
Pos := Ada.Command_Line.Iterator_Interfaces.Previous (Ite, Pos);
end loop;
pragma Assert (Count_2 = Ada.Command_Line.Argument_Count);
end;
-- iterate environment variables by closure
Ada.Debug.Put ("*** env(1) ***");
Count := 0;
declare
procedure Process (Name, Value : in String) is
begin
Count := Count + 1;
Rec (Count).Name := new String'(Name);
Rec (Count).Value := new String'(Value);
Ada.Debug.Put (Name & "=" & Value);
end Process;
begin
Ada.Environment_Variables.Iterate (Process'Access);
end;
-- iterate environment variables by iterator
Ada.Debug.Put ("*** env(2) ***");
declare
Count_2 : Natural := 0;
Ite : Ada.Environment_Variables.Iterator_Interfaces.Forward_Iterator'Class :=
Ada.Environment_Variables.Iterate;
Pos : Ada.Environment_Variables.Cursor :=
Ada.Environment_Variables.Iterator_Interfaces.First (Ite);
begin
while Ada.Environment_Variables.Has_Element (Pos) loop
Count_2 := Count_2 + 1;
pragma Assert (Ada.Environment_Variables.Name (Pos) = Rec (Count_2).Name.all);
pragma Assert (Ada.Environment_Variables.Value (Pos) = Rec (Count_2).Value.all);
Pos := Ada.Environment_Variables.Iterator_Interfaces.Next (Ite, Pos);
end loop;
pragma Assert (Count_2 = Count);
end;
-- iterate environment variables by user-defined loop of Ada 2012
Ada.Debug.Put ("*** env(3) ***");
declare
Count_3 : Natural := 0;
begin
for I in Ada.Environment_Variables.Iterate loop
Count_3 := Count_3 + 1;
pragma Assert (Ada.Environment_Variables.Name (I) = Rec (Count_3).Name.all);
pragma Assert (Ada.Environment_Variables.Value (I) = Rec (Count_3).Value.all);
end loop;
pragma Assert (Count_3 = Count);
end;
-- modify environment variables
Ada.Debug.Put ("*** clear ***");
declare
Is_Windows : constant Boolean :=
Ada.Environment_Variables.Exists ("OS")
and then Ada.Environment_Variables.Value ("OS") = "Windows_NT";
Old_Count : constant Natural := Count;
Cleared_Count : Natural;
begin
Ada.Environment_Variables.Clear;
Count := 0;
declare
procedure Process (Name, Value : in String) is
begin
Count := Count + 1;
Ada.Debug.Put (Name & "=" & Value);
end Process;
begin
Ada.Environment_Variables.Iterate (Process'Access);
end;
Cleared_Count := Count;
pragma Assert (Cleared_Count = 0
or else (
Is_Windows -- it could not clear some environment variables in Windows
and then Cleared_Count in 2 .. Old_Count));
Ada.Environment_Variables.Set ("A", "B");
Ada.Environment_Variables.Set ("C", "");
Count := 0;
declare
procedure Process (Name, Value : in String) is
begin
Count := Count + 1;
Ada.Debug.Put (Name & "=" & Value);
if Name = "A" then
pragma Assert (Value = "B");
null;
elsif Name = "C" then
pragma Assert (Value = "");
null;
end if;
end Process;
begin
Ada.Environment_Variables.Iterate (Process'Access);
end;
pragma Assert (Count = Cleared_Count + 2);
pragma Assert (Ada.Environment_Variables.Value ("A") = "B");
pragma Assert (Ada.Environment_Variables.Value ("C") = "");
end;
pragma Debug (Ada.Debug.Put ("OK"));
end cmdline;
|
sbksba/Concurrence-LI330 | Ada | 271 | adb | with Ada.Text_IO, Ada.Integer_Text_IO, Matrice;
use Ada.Text_IO, Ada.Integer_Text_IO, Matrice;
procedure Test_Saisie is
A : Une_Matrice_Entiere(Lignes => 5, Colonnes => 6);
begin
Initialiser(A);
Put_line("Affichage de A :");
Afficher_liste(A);
end Test_Saisie;
|
zhmu/ananas | Ada | 406 | adb | -- { dg-do compile }
with Generic_Inst13_Pkg;
with Generic_Inst13_Pkg.Nested_G;
procedure Generic_Inst13 is
type Item_T is range 1 .. 16;
package My_Inst is new Generic_Inst13_Pkg (Item_T);
package My_Nested is new My_Inst.Nested_G;
procedure Proc (Left, Right : My_Nested.T) is
R : constant My_Nested.List_T := My_Nested."or" (Left, Right);
begin
null;
end;
begin
null;
end;
|
mgrojo/smk | Ada | 6,985 | adb | -- -----------------------------------------------------------------------------
-- smk, the smart make
-- © 2018 Lionel Draghi <[email protected]>
-- SPDX-License-Identifier: APSL-2.0
-- -----------------------------------------------------------------------------
-- 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.Calendar;
with Ada.Directories; use Ada.Directories;
with Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
with Smk.Settings;
with Smk.Run_Files;
separate (Smk.Main)
-- -----------------------------------------------------------------------------
procedure Analyze_Run (Source_Files : out Run_Files.File_Lists.Map;
Target_Files : out Run_Files.File_Lists.Map)
is
Debug : constant Boolean := False;
Prefix : constant String := ""; -- smk-main-analyze_run.adb ";
Strace_Ouput : File_Type;
-- procedure Classify_By_Time (Name : in String) is
-- use type Ada.Calendar.Time;
-- File_Time : constant Ada.Calendar.Time := Modification_Time (Name);
-- -- Due to a limitation in the Modification_Time function
-- -- (subsecond are ignored, Modification_Time returns
-- -- Time_Of (Year, Month, Day, Hour, Minute, Second, 0.0);
-- -- This cause the Modification_Time to be < to the
-- -- command execution time, even when the file is
-- -- modified after command execution start.
-- -- To be clear :
-- -- Exec start will be at second 14.45
-- -- File will be modified at second 14.57
-- -- Modification_Time will return 14 instead of 14.57
-- -- So the file will be considered as not modified by the
-- -- command, and never classified as Target.
-- -- To avoid this, I remove sub-seconds in both time,
-- -- both will have the same time tag ending with second
-- -- 14.00, and when equal, file will be considered a Target.
--
-- Line_Nb : constant Integer := Integer (Ada.Text_IO.Line);
-- TT_Image : constant String := Image (Previous_Run_Time);
-- use Run_Files;
--
-- begin
-- delay (0.1); -- Fixme:
-- if File_Time >= Previous_Run_Time then
-- if not Target_Files.Contains (+Name) then
-- Target_Files.Insert (+Name, File_Time);
-- IO.Put_Debug_Line ("O : " & Image (File_Time,
-- Include_Time_Fraction => True) & " >= "
-- & TT_Image & " : " & Name,
-- Debug => Debug,
-- Prefix => Prefix,
-- -- File => Settings.Strace_Outfile_Name,
-- Line => Line_Nb);
-- end if;
--
-- else
-- if not Source_Files.Contains (+Name) then
-- Source_Files.Insert (+Name, File_Time);
-- IO.Put_Debug_Line ("S : " & Image (File_Time,
-- Include_Time_Fraction => True) & " < "
-- & TT_Image & " : " & Name,
-- Debug => Debug,
-- Prefix => Prefix,
-- -- File => Settings.Strace_Outfile_Name,
-- Line => Line_Nb);
-- end if;
--
-- end if;
-- end Classify_By_Time;
-- --------------------------------------------------------------------------
procedure Classify_By_Cmd (Line : in String;
Name : in String) is
File_Time : constant Ada.Calendar.Time := Modification_Time (Name);
use Ada.Strings.Fixed;
use Run_Files;
begin
if Index (Line, "O_WRONLY") /= 0 or else
Index (Line, "O_RDWR") /= 0 or else
Index (Line, "write", From => 7) /= 0 or else
Index (Line, "creat", From => 7) /= 0
-- Why seven? because the called system function name comes after
-- the pid in strace output :
-- 4372 openat(AT_FDCWD, "/tmp/ccHKHv8W.s", O_RDWR|O_CREAT etc.
then
-- it's a target
if not Target_Files.Contains (+Name) then
Target_Files.Insert (+Name, File_Time);
IO.Put_Debug_Line ("T : " & IO.Image (File_Time) & " " & Name,
Debug => Debug,
Prefix => Prefix);
end if;
if Source_Files.Contains (+Name) then
Source_Files.Delete (+Name);
-- can't be both Target and Source
end if;
else
-- it's a source
if not Source_Files.Contains (+Name)
and not Target_Files.Contains (+Name)
then
Source_Files.Insert (+Name, File_Time);
IO.Put_Debug_Line ("S : " & IO.Image (File_Time) & " " & Name,
Debug => Debug,
Prefix => Prefix);
end if;
end if;
end Classify_By_Cmd;
begin
-- --------------------------------------------------------------------------
IO.Put_Debug_Line ("Openning " & Strace_Outfile_Name, Debug, Prefix);
Open (File => Strace_Ouput,
Name => Strace_Outfile_Name,
Mode => In_File);
while not End_Of_File (Strace_Ouput) loop
File_Filter : declare
use Ada.Strings.Fixed;
Line : constant String := Get_Line (Strace_Ouput);
First : constant Natural := Index (Line, "<");
Last : constant Natural := Index (Line, ">");
begin
-- IO.Put_Debug_Line ("Processing line: " & Line, Debug, Prefix);
if Last > First then
-- the line contains both '<' and '>'.
declare
File_Name : constant String := Line (First + 1 .. Last - 1);
begin
-- Let's ignore :
-- 1. no more existing files after run, that is temporary file
-- 2. special file, e. g. /dev/something,
if Exists (File_Name) and then Kind (File_Name) /= Special_File
then
-- Classify_By_Time (File_Name);
Classify_By_Cmd (Line => Line, Name => File_Name);
end if;
end;
end if;
end File_Filter;
end loop;
if Debug then Close (Strace_Ouput);
else Delete (Strace_Ouput);
end if;
end Analyze_Run;
|
BrickBot/Bound-T-H8-300 | Ada | 16,827 | ads | -- Bounds (decl)
--
-- Bounding the execution of the subprograms under analysis.
--
-- Given: a set of subprograms, represented by control-flow graphs
-- and related by subprogram calls.
--
-- Goal: bounds on the dynamic control flow and stack usage of each
-- "root" subprogram in the set and all its callees.
--
-- To reach the goal, we must compute bounds on the dynamic behaviour of
-- subprograms. Dynamic behaviour arises when the execution flow depends
-- on data variables. The given subprogram set may have several sources
-- of such dynamic behaviour:
--
-- > Some of the control-flow graphs may be incomplete, that is, they
-- may contain unresolved dynamic branches. We try to bound the possible
-- targets of such branches, to help complete the control-flow graphs.
--
-- > Some of the calls may be incompletely resolved, that is, the
-- callee subprogram(s) may be dynamically determined and not yet
-- (fully) known. We try to bound the set of possible callees, to help
-- complete the call-graph of the subprogram set.
--
-- > Loops may (and usually do) have a dynamically defined number of
-- iterations. We try to bound the iterations of counter-based loops.
--
-- > TBA Different conditional branches may be correlated so that
-- certain paths are feasible while others are infeasible. We try
-- to detect the most important infeasible paths and bound the flow
-- model to exclude these paths.
--
-- > Pushing or popping a dynamically determined amount of data onto
-- or off the stack creates dynamic stack consumption. We try to
-- bound the amount of data that is pushed or popped (or the
-- equivalent changes in the stack pointer caused by arithmetic
-- instructions).
--
-- To bound such dynamic behaviour, we create models of the arithmetic
-- computation (data processing) that the subprograms do, and use these
-- models to bound the values of the variables that the dynamic items
-- use. This introduces more forms of dynamic behaviour that concern
-- the computation model itself:
--
-- > There may be dynamically addressed data references (indexed
-- addressing, indirect addressing). We try to bound the set of
-- possible referents, to make the computation model more accurate.
--
-- > The data-flow across a call, from the caller to the callee or vice
-- versa, may use a dynamically defined mapping from the caller's
-- variables (actual parameters) to the callee's variables (formal
-- parameters). This may depend, for example, on the local "stack
-- height" in the caller. We try to bound these mappings to make
-- the computation model more accurate across calls.
--
-- The data-flow across calls is important for two reasons:
--
-- > The computation model of the caller must include the possible
-- effects of the callee on the computation in the caller.
--
-- > In the arithmetic analysis of the callee, it may be essential
-- to use bounds on the values of the input parameters (and global
-- variables) that flow from the caller to the callee.
--
-- Many of the bounds can be "context dependent", that is, different
-- bounds may be computed for different call-paths to a given subprogram.
-- See Programs.Execution.Bounds_T for detail.
--
-- The bounds computed for a given control-flow graph are conservative
-- bounds in the sense that they include all possible executions of the
-- control-flow graph. However, if the control-flow graph is incomplete
-- (ie. if it contains an unresolved dynamic branch), the bounds may
-- _not_ include all executions of the complete flow-graph. Therefore,
-- when a dynamic branch is resolved and the control-flow graph is
-- extended all bounds computed for the incomplete flow-graph should be
-- discarded.
--
-- 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.11 $
-- $Date: 2015/10/24 19:36:47 $
--
-- $Log: bounds.ads,v $
-- Revision 1.11 2015/10/24 19:36:47 niklas
-- Moved to free licence.
--
-- Revision 1.10 2008-02-27 14:58:48 niklas
-- BT-CH-0116: Call-specific time and stack assertions.
--
-- Revision 1.9 2006/10/24 21:41:05 niklas
-- BT-CH-0030.
--
-- Revision 1.8 2006/05/27 21:56:08 niklas
-- Updated for BT-CH-0020.
--
-- Revision 1.7 2005/02/16 21:11:40 niklas
-- BT-CH-0002.
--
-- Revision 1.6 2003/03/11 08:31:06 holsti
-- Using execution-bounds types from Programs.Execution.
--
-- Revision 1.5 2001/03/10 00:48:49 holsti
-- Unused with-clauses deleted.
--
-- Revision 1.4 2000/08/04 08:16:25 saarinen
-- Changed program to be in/out parameter for Bound_Jumps_And_Execution.
--
-- Revision 1.3 2000/07/25 03:14:01 holsti
-- First implementation (incomplete).
--
-- Revision 1.2 2000/07/04 12:07:07 holsti
-- Real Ada text. Added Loop_Bounds_T.
--
with Assertions;
with Programs;
with Programs.Execution;
with Storage;
with Storage.Bounds;
package Bounds is
Recursion : exception;
--
-- Raised when a recursive cycle between target subprograms is
-- detected.
function Fully_Bounded (Item : Programs.Execution.Bounds_Ref)
return Boolean;
--
-- Whether these bounds are complete with respect to the
-- aspects (time, space) we are analysing.
procedure Bound_Execution (
Exec_Bounds : in Programs.Execution.Bounds_Ref;
Params : in Storage.Bounds.Cell_Interval_List_T;
Inherit_Inv : in Storage.Cell_Set_T;
Asserts : in Assertions.Assertion_Set_T;
Bounds_Set : in Programs.Execution.Bounds_Set_T;
Flow_Frozen : out Boolean);
--
-- Tries to bound the execution time and/or stack usage within
-- the given Exec_Bounds, by analysis of the subprogram under
-- these bounds and of its callees, which are recursively analysed
-- if not yet bounded.
--
-- Input parameters:
--
-- Exec_Bounds
-- The execution bounds created for the subprogram to be
-- analysed, in the context to be analysed. The subprogram
-- and the context (call-path) are defined by Exec_Bounds.
--
-- Some quantitative bounds may already be present, for example
-- an asserted execution time or an asserted stack usage. Our
-- task is then to analyse and bound only the as yet unbounded
-- dimensions of the execution.
--
-- The context may be null (universal bounds sought). If the
-- context is not null, the Exec_Bounds refer to the bounds
-- of the caller, that constitute the context for this analysis
-- of the callee subprogram.
--
-- We assume that these Exec_Bounds are not yet stored in the
-- Bounds_Set, thus they are not yet frozen and can be extended
-- with more bounds on eg. the execution time.
--
-- Params
-- Bounds on the input cells for this call, expressed in the
-- subprogram's (the callee's) frame. The bounds may be asserted
-- or (if the call-path is non-empty) derived from the actual
-- parameters or actual data context at any call in the path.
--
-- Inherit_Inv
-- The inherited set of invariant cells. Usage TBA.
--
-- Asserts
-- A set of assertions to constrain the execution of the
-- Subprogram and its callees.
--
-- Bounds_Set
-- A set of execution bounds computed so far.
--
-- Algorithm:
--
-- This procedure uses various forms of static analysis to bound
-- the dynamic execution of the given Subprogram with regard to
-- the following dynamic aspects:
--
-- > Dynamic (indirect, computed) control flow, as represented by
-- elements of type Flow.Boundable_Edge_T (Dynamic_Edge_T),
-- with Role = Boundable_Jump, in the control-flow graph.
-- If a control-flow graph has such elements then the flow-graph
-- is incomplete.
--
-- > Dynamic (indirect, computed) calls, as represented by
-- elements of type Flow.Boundable_Edge_T (Dynamic_Edge_T),
-- with Role = Boundable_Call, in the control-flow graph.
-- If a control-flow graph has such elements then the flow-graph
-- is incomplete (missing call-steps) as is the call-graph
-- rooted at this subprogram.
--
-- > Dynamic (indirect, computed) data variable references, as
-- represented by Arithmetic.Reference elements in the arithmetic
-- effects attached to flow-graph steps.
--
-- > Loop iteration bounds.
--
-- > Parameter-passing mappings at call sites where this mapping
-- depends on dynamic aspects, as represented by dynamic forms
-- of Calling.Protocol_T attached to calls in the flow-graph.
--
-- > Maximum local stack height, as determined by the maximum value
-- assigned to the local stack-height cell at any point in the
-- flow-graph.
--
-- > Maximum total stack usage, as determined by the largest of the
-- maximum value of the local stack height and the maximum, over
-- all calls to other subprograms, of the local stack height at
-- the call (a.k.a. the call's take-off height) and the total stack
-- usage of the callee.
--
-- The static analysis methods used include:
--
-- > Constant propagation.
--
-- > Value-origin analysis.
--
-- > Arithmetic analysis using Presburger Arithmetic.
--
-- We first apply the assertions from the Asserts set, then constant
-- propagation and value-origin analysis if needed, and finally
-- Presburger analysis if some dynamic aspects are still not bounded
-- and the flow-graph is reducible.
--
-- If the subprogram has no unresolved dynamic control flow, its flow-
-- and call-analysis are complete and the execution bounds computed
-- here are valid (but possibly too loose; context-dependent bounds
-- may be added later, as callers are analysed).
--
-- If some dynamic control flow was resolved, new edges were added to
-- the control-flow graph and/or call-graph, so the flow-graph must
-- be extended by repeating the control-flow tracing process.
-- The bounds computed here are not valid for the extended flow-graph,
-- so new bounds must be computed.
--
-- Output parameters:
--
-- Exec_Bounds
-- Updated with the computed bounds.
-- If the analysis has extended the flow-graph, these bounds
-- are now of historic interest only. They apply to the
-- incomplete flow-graph before the extensions, and have no
-- significance for the extended flow-graph (TBC).
--
-- Asserts
-- Updated with usage information.
--
-- Bounds_Set
-- Updated with the computed bounds (unless the control-flow
-- graph was extended).
--
-- Flow_Frozen
-- Whether the control-flow graph of the Subprogram is now
-- completed, that is, dynamic control-flow has been resolved
-- as far as possible and no dynamic edges remain in the graph.
procedure Bound_Executions (
To_Bound : in out Programs.Subprogram_Set_T;
Asserts : in Assertions.Assertion_Set_T;
Bounds_Set : in out Programs.Execution.Bounds_Set_T;
Growing : out Programs.Subprogram_Set_T);
--
-- Analyses a set of subprograms to bound the dynamic aspects of
-- their executions.
--
-- Input parameters:
--
-- To_Bound
-- A set of subprograms provided with control-flow graphs and
-- call graphs, such that for any call from a subprogram in
-- the To_Bound set either the callee is also in To_Bound or
-- the callee has already been bounded and has bounds in the
-- Bound_Set.
--
-- Asserts
-- A set of assertions that constrain the executions of the
-- Program and the subprograms.
--
-- Bounds_Set
-- A set of execution bounds computed so far.
--
-- Algorithm:
--
-- This procedure uses Bound_Execution to bound the dynamic execution
-- of the given subprograms.
--
-- The procedure works bottom-up in the call-graph of the subprograms
-- in the To_Bound set, calling Bound_Execution (Subprogram, ...)
-- for each subprogram.
--
-- The procedure stops at the first subprogram (in the bottom-up
-- call order) for which dynamic control-flow was resolved and the
-- control-flow graph is thus still growing. The subprogram is placed
-- in the Growing set. For this subprogram, flow-analysis (flow tracing)
-- should be continued in order to complete the control-flow graph or,
-- perhaps, discover new dynamic control-flow to be resolved again.
--
-- The procedure propagates the Recursion exception if recursion is
-- detected between the subprograms to be bounded.
--
-- Output parameters:
--
-- Control-flow graphs
-- For the first (if any) subprogram, in bottom-up call order, for
-- which dynamic control-flow was resolved, the control flow-graph
-- is extended with new edges (resolved from the dynamic branches).
-- The new edge may be "bound" (target step exists) or "loose"
-- (target step does not yet exist, only target step-address is
-- specified).
--
-- To_Bound
-- The subset of subprograms, from the initial To_Bound set, for
-- which bounds on the dynamic execution were not yet computed.
-- May or may not include the Resolved set.
--
-- Program
-- TBD?
--
-- Asserts
-- Updated with usage information (TBC).
--
-- Bounds_Set
-- Execution bounds are added for those subprograms To_Bound that
-- had complete control-flow graphs on entry (ie. no unresolved
-- dynamic jumps), or that had dynamic control-flow but for which
-- the dynamic control-flow was resolved away (no new edges, no
-- dynamism left). However, see above for when the algorithm stops;
-- later subprograms (in bottom-up call order) are not processed
-- and remain in To_Bound.
--
-- Growing
-- Returns the subset of subprograms (from To_Bound) for which
-- dynamic control flow was resolved, which means that their
-- control-flow graphs are still growing and can be traced further,
-- after which these subprograms can again be analysed for dynamic
-- bounds.
private
procedure Finish_Bounds (
Exec_Bounds : in Programs.Execution.Bounds_Ref;
Assert_Map : in Assertions.Assertion_Map_T;
Bounds_Set : in Programs.Execution.Bounds_Set_T;
Flow_Frozen : out Boolean);
--
-- Finishing touches for the new Exec_Bounds on a subprogram.
-- The main thing is to check if the dynamic control-flow is
-- sufficiently resolved to declare the Flow_Frozen, and if so
-- to let the Decoder Finish the flow-graph if the bounds
-- are universal and to store the bounds in the Bounds_Set.
--
-- Unresolved dynamic flow is reported as Errors.
-- Unresolved dynamic data is reported as Warnings (optional).
--
-- The Assert_Map is provided for Decoder.Finish. If the subprogram
-- is infeasible, the Assert_Map may be null (uninitialized), but
-- then Decoder.Finish is not called.
end Bounds;
|
sungyeon/drake | Ada | 1,312 | adb | package body System.Storage_Pools.Unbounded is
overriding procedure Initialize (Object : in out Unbounded_Pool) is
begin
Unbounded_Allocators.Initialize (Object.Allocator);
end Initialize;
overriding procedure Finalize (Object : in out Unbounded_Pool) is
begin
Unbounded_Allocators.Finalize (Object.Allocator);
end Finalize;
overriding procedure Allocate (
Pool : in out Unbounded_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is
begin
Unbounded_Allocators.Allocate (
Pool.Allocator,
Storage_Address => Storage_Address,
Size_In_Storage_Elements => Size_In_Storage_Elements,
Alignment => Alignment);
end Allocate;
overriding procedure Deallocate (
Pool : in out Unbounded_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is
begin
Unbounded_Allocators.Deallocate (
Pool.Allocator,
Storage_Address => Storage_Address,
Size_In_Storage_Elements => Size_In_Storage_Elements,
Alignment => Alignment);
end Deallocate;
end System.Storage_Pools.Unbounded;
|
alvaromb/Compilemon | Ada | 4,355 | adb | -- ------------------------------------------------
-- Programa de prova
-- ------------------------------------------------
-- Versio : 0.1
-- Autors : Jose Ruiz Bravo
-- Biel Moya Alcover
-- Alvaro Medina Ballester
-- ------------------------------------------------
-- Programa per comprovar les funcionalitats
-- de la taula de simbols.
--
-- ------------------------------------------------
with Ada.Text_IO,
Ada.Command_Line,
Decls.D_Taula_De_Noms,
Decls.Tn,
Decls.Dgenerals,
D_Token,
Pk_Ulexica_Io,
U_Lexica,
Semantica.Dtsimbols,
Delcs.Dtdesc;
use Ada.Text_IO,
Ada.Command_Line,
Decls.D_Taula_De_Noms,
Decls.Tn,
Decls.Dgenerals,
D_Token,
Pk_Ulexica_Io,
U_Lexica,
Semantica.Dtsimbols,
Decls.Dtdesc;
procedure compiprueba is
ts: tsimbols;
id: id_nom := 1;
d1: descrip(dproc);
d2: descrip(dproc);
d3: descrip(dvar);
d4: descrip(dtipus);
d5: descrip(dtipus);
D6: Descrip(Dvar);
e: boolean;
np1 : num_proc := 5;
np2 : num_proc := 7;
desctip : descriptipus(tsrec);
descarr : descriptipus(tsarr);
begin
--Tbuida
tbuida(ts);
--Posa
d1.np := np1;
d2.np := np2;
id := 1;
posa(ts, id, d1, e);
id := 7;
posa(ts, id, d2, e);
--Cons
--New_Line;
--case cons(ts, 7).td is
-- when dnula => Put_Line("dnula");
-- when dtipus => Put_Line("dtipus");
-- when dvar => Put_Line("dvar");
-- when dproc => Put_Line("dproc");
-- when dconst => Put_Line("dconst");
-- when dargc => Put_Line("dargc");
-- when dcamp => Put_Line("dcamp");
--end case;
--Put_Line("np: "&cons(ts, 7).np'img);
--Entra bloc
entrabloc(ts);
D3.tr := 4;
d3.nv := 3;
posa(ts, id, d3, e);
--Surt bloc
surtbloc(ts);
printts(ts);
--Un altre entra bloc
--entrabloc(ts);
--posa(ts, id, d3, e);
--Comencam amb records
desctip.ocup := 8;
d4.dt := desctip;
id := 8;
posa(ts, id, d4, e);
--Ficam un posa camp
posacamp(ts, 8, 1, d3, e);
printts(ts);
posacamp(ts,8,7,d3,e);
printts(ts);
--Consulta camp
Put_Line("Cons camp: "&conscamp(ts,8,1).nv'img);
Put_Line("Cons camp: "&conscamp(ts,8,7).nv'img);
--Comencam amb els arrays
descarr.ocup := 8;
d5.dt := descarr;
posa(ts, 5, d5, e); --Ficam l'array
posa_idx(ts, 5, 31, e); --Afegim un camp a l'array
printts(ts);
posa_idx(ts, 5, 32, e); --Afegim un altre camp
--a l'array
printts(ts);
--Primer_idx i idx_valid
Put_Line("PRIMER IDX: "
&primer_idx(ts, 5)'img);
Put_Line("IDX VALID: "
&idx_valid(primer_idx(ts, 5))'img);
--Provam el successor del camp 1
Put_Line("SUCCESSOR IDX: "
&succ_idx(ts, primer_idx(ts, 5))'img);
Put_Line("SUCCESSOR IDX: "
&succ_idx(ts, succ_idx(ts,
primer_idx(ts, 5)))'img);
--Consultam idx
Put_Line("CONS IDX: "
&cons_idx(ts, primer_idx(ts, 5))'img);
Put_Line("CONS IDX: "
&cons_idx(ts, succ_idx(ts,
primer_idx(ts, 5)))'img);
--Posa_arg
D6.Tr := 9;
d6.Nv := 5;
Posa(Ts, 9, D6, E); --Parametre variable 8 (argument)
Posa_Arg(Ts, 7, 9, D6, E); --Passam per primera vegada
--l'argument
Posa_Arg(Ts, 7, 9, D6, E); --El passam per segona
--vegada
Printts(Ts);
--Primer_arg
--Actualitza
Put_Line("Antes act: ");
case cons(ts, 7).td is
when dnula => Put_Line("dnula");
when dtipus => Put_Line("dtipus");
when dvar => Put_Line("dvar");
when dproc => Put_Line("dproc");
when dconst => Put_Line("dconst");
when dargc => Put_Line("dargc");
when dcamp => Put_Line("dcamp");
end case;
Actualitza(Ts, 7, D6);
Put_Line("Act dvar: ");
case cons(ts, 7).td is
when dnula => Put_Line("dnula");
when dtipus => Put_Line("dtipus");
when dvar => Put_Line("dvar");
when dproc => Put_Line("dproc");
when dconst => Put_Line("dconst");
when dargc => Put_Line("dargc");
when dcamp => Put_Line("dcamp");
end case;
if e then
put_line("ERROR");
end if;
end compiprueba;
|
godunko/adawebui | Ada | 9,115 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2020, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: 5687 $ $Date: 2017-01-12 15:33:13 +0300 (Thu, 12 Jan 2017) $
------------------------------------------------------------------------------
with Web.Window;
package body Web.UI.Widgets.GL_Widgets is
type GL_Widget_Access is access all Abstract_GL_Widget'Class;
Instance : GL_Widget_Access;
-- XXX Only one instance of Abstract_GL_Widget may be created for now.
Frame_Request_Id : Web.DOM_Unsigned_Long := 0;
-- Identifier of registered request of animation frame, then requested.
-- If there is no active requests it is equal to zero.
procedure Animation_Frame_Request_Handler
(Time : Web.DOM_High_Res_Time_Stamp)
with Convention => C;
-- Calls Animation_Frame procedure for all instances of Abstract_GL_Widget.
procedure Animation_Frame (Self : in out Abstract_GL_Widget'Class);
-- Handles animation frame and requests next animation frame. Animation
-- frames is used to do most of GL related processing, including:
-- - finish of initialization of widget's GL code;
-- - detection of resize of canvas;
-- - redrawing after finish of initialization, on detected resize of the
-- canvas and on request.
---------------------
-- Animation_Frame --
---------------------
procedure Animation_Frame (Self : in out Abstract_GL_Widget'Class) is
Ratio : constant Web.DOM_Double
:= Web.Window.Get_Device_Pixel_Ratio;
Display_Width : constant Web.DOM_Unsigned_Long
:= Web.DOM_Unsigned_Long
(Web.DOM_Double'Floor
(Web.DOM_Double (Self.Canvas.Get_Client_Width) * Ratio));
Display_Height : constant Web.DOM_Unsigned_Long
:= Web.DOM_Unsigned_Long
(Web.DOM_Double'Floor
(Web.DOM_Double (Self.Canvas.Get_Client_Height) * Ratio));
Resize_Needed : constant Boolean
:= not Self.Initialized
or Self.Canvas.Get_Width /= Display_Width
or Self.Canvas.Get_Height /= Display_Height;
-- Whether Resize_GL should be called due to change of canvas size.
begin
Self.Context.Make_Current;
-- Finish initialization of the widget's GL code.
if not Self.Initialized then
Self.Initialized := True;
Abstract_GL_Widget'Class (Self).Initialize_GL;
end if;
-- Complete resize of canvas and notify widget.
if Resize_Needed then
Self.Canvas.Set_Width (Display_Width);
Self.Canvas.Set_Height (Display_Height);
Self.Functions.Viewport
(X => 0,
Y => 0,
Width => OpenGL.GLsizei (Self.Canvas.Get_Width),
Height => OpenGL.GLsizei (Self.Canvas.Get_Height));
Abstract_GL_Widget'Class (Self).Resize_GL
(Integer (Self.Canvas.Get_Width), Integer (Self.Canvas.Get_Height));
end if;
-- Redraw content of canvas when necessary.
if Resize_Needed or Self.Redraw_Needed then
Self.Redraw_Needed := False;
Abstract_GL_Widget'Class (Self).Paint_GL;
Self.Functions.Flush;
end if;
end Animation_Frame;
-------------------------------------
-- Animation_Frame_Request_Handler --
-------------------------------------
procedure Animation_Frame_Request_Handler
(Time : Web.DOM_High_Res_Time_Stamp) is
begin
Frame_Request_Id := 0;
-- Frame request has been completed.
Instance.Animation_Frame;
end Animation_Frame_Request_Handler;
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Abstract_GL_Widget'Class;
Canvas : in out Web.HTML.Canvases.HTML_Canvas_Element'Class) is
begin
Web.UI.Widgets.Constructors.Initialize (Self, Canvas);
Self.Canvas := Web.HTML.Canvases.HTML_Canvas_Element (Canvas);
Self.Canvas.Add_Event_Listener
(+"webglcontextlost", Self.Lost'Unchecked_Access, False);
Self.Canvas.Add_Event_Listener
(+"webglcontextrestored", Self.Lost'Unchecked_Access, False);
Self.Context := new OpenGL.Contexts.OpenGL_Context;
Self.Context.Create (Canvas);
Self.Context.Make_Current;
Instance := Self'Unchecked_Access;
Self.Update;
end Initialize;
end Constructors;
---------------
-- Functions --
---------------
function Functions
(Self : in out Abstract_GL_Widget'Class)
return access OpenGL.Functions.OpenGL_Functions'Class is
begin
return Self.Context.Functions;
end Functions;
------------------
-- Handle_Event --
------------------
overriding procedure Handle_Event
(Self : in out Context_Lost_Dispatcher;
Event : in out Web.DOM.Events.Event'Class) is
begin
Self.Owner.Context_Lost;
end Handle_Event;
------------------
-- Handle_Event --
------------------
overriding procedure Handle_Event
(Self : in out Context_Restored_Dispatcher;
Event : in out Web.DOM.Events.Event'Class) is
begin
Self.Owner.Context_Restored;
end Handle_Event;
------------
-- Update --
------------
procedure Update (Self : in out Abstract_GL_Widget) is
begin
-- Request redraw on processing of next animation frame.
Self.Redraw_Needed := True;
if Frame_Request_Id = 0 then
-- Register request of animation frame, if not registered.
-- Initialization of the GL related features will be continued
-- durin handling of the requested animation frame.
Frame_Request_Id :=
Web.Window.Request_Animation_Frame
(Animation_Frame_Request_Handler'Access);
end if;
end Update;
end Web.UI.Widgets.GL_Widgets;
|
zhmu/ananas | Ada | 6,246 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 6 3 --
-- --
-- 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_63 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_63;
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_63 --
------------
function Get_63
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_63
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_63;
------------
-- Set_63 --
------------
procedure Set_63
(Arr : System.Address;
N : Natural;
E : Bits_63;
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_63;
end System.Pack_63;
|
iyan22/AprendeAda | Ada | 5,172 | adb | with Ada.Text_Io, copia_examenes;
use Ada.Text_Io, copia_examenes;
with se_han_copiado;
procedure prueba_se_han_copiado is
Ex1, Ex2 : T_Examen;
res : boolean;
package Boolean_ES is new Enumeration_IO (boolean); use Boolean_ES;
-- Esto permitira escribir booleanos por pantalla
-- No veo útil la utilización del programa posición, por lo que lo he borrado
begin
put_line ("CASO 1: Examenes con mismo numero de variables y mismo numero de apariciones (sospechoso)");
-- Inicializar examen Ex1
Ex1.Num_Palabras_Diferentes := 3;
Ex1.Palabras(1).Palabra := "Ave ";
Ex1.Palabras(1).N_Apariciones := 8;
Ex1.Palabras(2).Palabra := "Maria ";
Ex1.Palabras(2).N_Apariciones := 4;
Ex1.Palabras(3).Palabra := "Purisima ";
Ex1.Palabras(3).N_Apariciones := 6;
-- Inicializar examen Ex2
Ex2.Num_Palabras_Diferentes := 3;
Ex2.Palabras(1).Palabra := "Virgen ";
Ex2.Palabras(1).N_Apariciones := 4;
Ex2.Palabras(2).Palabra := "Santa ";
Ex2.Palabras(2).N_Apariciones := 6;
Ex2.Palabras(3).Palabra := "Paciencia ";
Ex2.Palabras(3).N_Apariciones := 8;
put ("El programa deberia de decir TRUE");
new_line;
put_line ("y dice");
res := se_han_copiado(Ex1, Ex2);
put(res);
new_line(2);
put_line ("Pulse enter");
skip_line;
put_line ("CASO 2: Examenes con diferente numero de variables (no sospechoso)");
-- Inicializar examen Ex1
Ex1.Num_Palabras_Diferentes := 2;
Ex1.Palabras(1).Palabra := "Need ";
Ex1.Palabras(1).N_Apariciones := 4;
Ex1.Palabras(2).Palabra := "Ayuda ";
Ex1.Palabras(2).N_Apariciones := 6;
-- Inicializar examen Ex2
Ex2.Num_Palabras_Diferentes := 3;
Ex2.Palabras(1).Palabra := "Y ";
Ex2.Palabras(1).N_Apariciones := 8;
Ex2.Palabras(2).Palabra := "Mucha ";
Ex2.Palabras(2).N_Apariciones := 6;
Ex2.Palabras(3).Palabra := "Paciencia ";
Ex2.Palabras(3).N_Apariciones := 4;
put ("El programa deberia de decir FALSE");
new_line;
put_line ("y dice");
res := se_han_copiado(Ex1, Ex2);
put(res);
new_line(2);
put_line ("Pulse enter");
skip_line;
put_line ("CASO 3: Examenes con mismas variables (sospechoso)");
-- Inicializar examen Ex1
Ex1.Num_Palabras_Diferentes := 4;
Ex1.Palabras(1).Palabra := "Hay ";
Ex1.Palabras(1).N_Apariciones := 9;
Ex1.Palabras(2).Palabra := "Que ";
Ex1.Palabras(2).N_Apariciones := 4;
Ex1.Palabras(3).Palabra := "Ser ";
Ex1.Palabras(3).N_Apariciones := 2;
Ex1.Palabras(4).Palabra := "Justo ";
Ex1.Palabras(4).N_Apariciones := 2;
-- Inicializar examen Ex2
Ex2.Num_Palabras_Diferentes := 4;
Ex2.Palabras(1).Palabra := "Justo ";
Ex2.Palabras(1).N_Apariciones := 2;
Ex2.Palabras(2).Palabra := "Hay ";
Ex2.Palabras(2).N_Apariciones := 9;
Ex2.Palabras(3).Palabra := "Que ";
Ex2.Palabras(3).N_Apariciones := 4;
Ex2.Palabras(4).Palabra := "Ser ";
Ex2.Palabras(4).N_Apariciones := 2;
put ("El programa deberia de decir TRUE");
new_line;
put_line ("y dice");
res := se_han_copiado(Ex1, Ex2);
put(res);
new_line(2);
put_line ("Pulse enter");
skip_line;
put_line ("CASO 4: Ejemplo rellenar aula (no sospechoso) (1,2) y (1,3)");
-- Inicializar examen Ex1
Ex1.Num_palabras_diferentes:=5;
Ex1.Palabras(1).Palabra:="elem ";
Ex1.Palabras(1).n_apariciones:=7;
Ex1.Palabras(2).Palabra:="Indice2 ";
Ex1.palabras(2).n_apariciones:=5;
Ex1.Palabras(3).Palabra:="j ";
Ex1.palabras(3).n_apariciones:=2;
Ex1.Palabras(4).Palabra:="var3 ";
Ex1.palabras(4).n_apariciones:=9;
Ex1.Palabras(5).Palabra:="var19 ";
Ex1.palabras(5).n_apariciones:=9;
-- Inicializar examen Ex2
Ex2.Num_Palabras_Diferentes:=5;
Ex2.Palabras(1).Palabra := "elem ";
Ex2.Palabras(1).N_Apariciones := 7;
Ex2.Palabras(2).Palabra := "Indice2 ";
Ex2.palabras(2).N_Apariciones := 5;
Ex2.Palabras(3).Palabra := "j ";
Ex2.palabras(3).N_Apariciones := 9;
Ex2.Palabras(4).Palabra := "x ";
Ex2.palabras(4).N_Apariciones := 2;
Ex2.Palabras(5).Palabra := "z ";
Ex2.palabras(5).N_Apariciones := 2;
put ("El programa deberia de decir FALSE");
new_line;
put_line ("y dice");
res := se_han_copiado(Ex1, Ex2);
put(res);
new_line(2);
put_line ("Pulse enter");
skip_line;
put_line ("CASO 5: El jugon");
-- Inicializar examen Ex1
Ex1.Num_palabras_diferentes:=3;
Ex1.Palabras(1).Palabra:="elem ";
Ex1.Palabras(1).n_apariciones:=1;
Ex1.Palabras(2).Palabra:="Indice2 ";
Ex1.palabras(2).n_apariciones:=3;
Ex1.Palabras(3).Palabra:="j ";
Ex1.palabras(3).n_apariciones:=1;
-- Inicializar examen Ex2
Ex2.Num_Palabras_Diferentes:=3;
Ex2.Palabras(1).Palabra := "elem ";
Ex2.Palabras(1).N_Apariciones := 1;
Ex2.Palabras(2).Palabra := "Indice2 ";
Ex2.palabras(2).N_Apariciones := 3;
Ex2.Palabras(3).Palabra := "j ";
Ex2.palabras(3).N_Apariciones := 10;
put ("El programa deberia de decir FALSE");
new_line;
put_line ("y dice");
res := se_han_copiado(Ex1, Ex2);
put(res);
new_line(2);
put_line ("Pulse enter");
skip_line;
end prueba_se_han_copiado;
|
Tim-Tom/project-euler | Ada | 1,617 | adb | with Ada.Text_IO;
package body Problem_52 is
package IO renames Ada.Text_IO;
procedure Solve is
type Digit is new Natural range 0 .. 9;
type Digit_Count is Array (Digit'Range) of Natural;
function Verify(num : Positive) return Boolean is
base : Digit_Count := (others => 0);
multiplied : Positive := num;
dividend : Natural := num;
begin
while dividend > 0 loop
declare
remainder : constant Digit := Digit(dividend mod 10);
begin
base(remainder) := base(remainder) + 1;
dividend := dividend / 10;
end;
end loop;
for multiplier in 2 .. 6 loop
declare
temp : Digit_Count := (others => 0);
begin
multiplied := multiplied + num;
dividend := multiplied;
while dividend > 0 loop
declare
remainder : constant Digit := Digit(dividend mod 10);
begin
temp(remainder) := temp(remainder) + 1;
if temp(remainder) > base(remainder) then
return false;
end if;
dividend := dividend / 10;
end;
end loop;
end;
end loop;
return True;
end Verify;
begin
for num in 100_000 .. 166_666 loop
if Verify(num) then
IO.Put_Line(Positive'Image(num));
exit;
end if;
end loop;
end Solve;
end Problem_52;
|
zhmu/ananas | Ada | 8,997 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S T Y L E G --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This generic package collects the routines used for style checking, as
-- activated by the relevant command line option. These are gathered in
-- a separate package so that they can more easily be customized. Calls
-- to these subprograms are only made if Opt.Style_Check is set True.
-- Styleg does not depends on the GNAT tree (Atree, Sinfo, ...).
with Types; use Types;
generic
with procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
-- Output a message at specified location
with procedure Error_Msg_S (Msg : String);
-- Output a message at current scan pointer location
with procedure Error_Msg_SC (Msg : String);
-- Output a message at the start of the current token
with procedure Error_Msg_SP (Msg : String);
-- Output a message at the start of the previous token
package Styleg is
procedure Check_Abs_Not;
-- Called after scanning an ABS or NOT operator to check spacing
procedure Check_Apostrophe;
-- Called after scanning an apostrophe to check spacing
procedure Check_Arrow (Inside_Depends : Boolean := False);
-- Called after scanning out an arrow to check spacing. Inside_Depends is
-- True if the call is from an argument of the Depends or Refined_Depends
-- aspect or pragma (where the allowed/required format is =>+).
procedure Check_Attribute_Name (Reserved : Boolean);
-- The current token is an attribute designator. Check that it
-- is capitalized in an appropriate manner. Reserved is set if
-- the attribute designator is a reserved word (access, digits,
-- delta or range) to allow differing rules for the two cases.
procedure Check_Boolean_Operator (Node : Node_Id);
-- Node is a node for an AND or OR operator. Check that the usage meets
-- the style rules.
procedure Check_Box;
-- Called after scanning out a box to check spacing
procedure Check_Binary_Operator;
-- Called after scanning out a binary operator other than a plus, minus
-- or exponentiation operator. Intended for checking spacing rules.
procedure Check_Exponentiation_Operator;
-- Called after scanning out an exponentiation operator. Intended for
-- checking spacing rules.
procedure Check_Colon;
-- Called after scanning out colon to check spacing
procedure Check_Colon_Equal;
-- Called after scanning out colon equal to check spacing
procedure Check_Comma;
-- Called after scanning out comma to check spacing
procedure Check_Comment;
-- Called with Scan_Ptr pointing to the first minus sign of a comment.
-- Intended for checking any specific rules for comment placement/format.
procedure Check_Defining_Identifier_Casing;
-- The current token is an identifier that will be a defining
-- identifier. Check that it is mixed case, if the appropriate
-- switch is set.
procedure Check_Dot_Dot;
-- Called after scanning out dot dot to check spacing
procedure Check_EOF;
-- Called after scanning out EOF mark
procedure Check_HT;
-- Called with Scan_Ptr pointing to a horizontal tab character
procedure Check_Indentation;
-- Called at the start of a new statement or declaration, with Token_Ptr
-- pointing to the first token of the statement or declaration. The check
-- is that the starting column is appropriate to the indentation rules if
-- Token_Ptr is the first token on the line.
procedure Check_Left_Paren;
-- Called after scanning out a left parenthesis to check spacing
procedure Check_Line_Max_Length (Len : Nat);
-- Called with Scan_Ptr pointing to the first line terminator character
-- terminating the current line. Used to check for appropriate line length.
-- The parameter Len is the length of the current line.
procedure Check_Line_Terminator (Len : Nat);
-- Called with Scan_Ptr pointing to the first line terminator terminating
-- the current line, used to check for appropriate line terminator usage.
-- The parameter Len is the length of the current line.
procedure Check_Not_In;
-- Called with Scan_Ptr pointing to an IN token, and Prev_Token_Ptr
-- pointing to a NOT token. Used to check proper layout of NOT IN.
procedure Check_Pragma_Name;
-- The current token is a pragma identifier. Check that it is spelled
-- properly (i.e. with an appropriate casing convention).
procedure Check_Right_Paren;
-- Called after scanning out a right parenthesis to check spacing
procedure Check_Semicolon;
-- Called after scanning out a semicolon to check spacing
procedure Check_Then (If_Loc : Source_Ptr);
-- Called to check that THEN and IF keywords are appropriately positioned.
-- The parameters show the first characters of the two keywords. This
-- procedure is called with Token_Ptr pointing to the THEN keyword.
procedure Check_Separate_Stmt_Lines;
pragma Inline (Check_Separate_Stmt_Lines);
-- Called after scanning THEN (not preceded by AND) or ELSE (not preceded
-- by OR). Used to check that no tokens follow on the same line (which
-- would interfere with coverage testing). Handles case of THEN ABORT as
-- an exception, as well as PRAGMA after ELSE.
procedure Check_Unary_Plus_Or_Minus (Inside_Depends : Boolean := False);
-- Called after scanning a unary plus or minus to check spacing. The flag
-- Inside_Depends is set if we are scanning within a Depends or
-- Refined_Depends pragma or Aspect, in which case =>+ requires a
-- following space.
procedure Check_Vertical_Bar;
-- Called after scanning a vertical bar to check spacing
procedure Check_Xtra_Parens (Loc : Source_Ptr);
-- Called after scanning an if, case, or quantified expression that has at
-- least one level of parentheses around the entire expression.
function Mode_In_Check return Boolean;
pragma Inline (Mode_In_Check);
-- Determines whether style checking is active and the Mode_In_Check is
-- set, forbidding the explicit use of mode IN.
procedure No_End_Name (Name : Node_Id);
-- Called if an END is encountered where a name is allowed but not present.
-- The parameter is the node whose name is the name that is permitted in
-- the END line, and the scan pointer is positioned so that if an error
-- message is to be generated in this situation, it should be generated
-- using Error_Msg_SP.
procedure No_Exit_Name (Name : Node_Id);
-- Called when exiting a named loop, but a name is not present on the EXIT.
-- The parameter is the node whose name should have followed EXIT, and the
-- scan pointer is positioned so that if an error message is to be
-- generated, it should be generated using Error_Msg_SP.
procedure Non_Lower_Case_Keyword;
-- Called if a reserved keyword is scanned which is not spelled in all
-- lower case letters. On entry Token_Ptr points to the keyword token.
-- This is not used for keywords appearing as attribute designators,
-- where instead Check_Attribute_Name (True) is called.
end Styleg;
|
AdaCore/training_material | Ada | 1,067 | adb | with Ada.Exceptions;
with Movies; use Movies;
with Char_Display_Driver; use Char_Display_Driver;
with Ada.Calendar;
use type Ada.Calendar.Time;
with Logs;
with Drawable_Chars.Latin_1;
package body Movie_Servers is
protected body Play_Settings_T is
function FPS return Positive is (FPS_Value);
procedure Set_FPS (Value : Positive) is
begin
-- TODO
null;
end Set_FPS;
function Charset return Sorted_Charset_T is (Charset_Value);
procedure Set_Charset (Value : Sorted_Charset_T) is
begin
-- TODO
null;
end Set_Charset;
end Play_Settings_T;
function Make_Default return Movie_Server_Task_T is
begin
-- How to return a task there?
return XXX; -- TODO
end Make_Default;
procedure Display_Frame
(CD : in out Char_Display; Movie : Movie_T; Frame : Frame_T)
is
begin
null; -- TODO
end Display_Frame;
task body Movie_Server_Task_T is
begin
-- TODO
null;
end Movie_Server_Task_T;
end Movie_Servers;
|
msrLi/portingSources | Ada | 946 | adb | -- Copyright 2008-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Call_Me (Str : String) is
begin
Length := Str'Length;
if Length > 0 then
First := Str (Str'First);
Last := Str (Str'Last);
end if;
end Call_Me;
end Pck;
|
onox/orka | Ada | 4,761 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2022 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
with AUnit.Assertions;
with AUnit.Test_Caller;
with AUnit.Test_Fixtures;
with Orka.SIMD.SSE2.Integers.Logical;
package body Test_SIMD_SSE2_Logical is
use Orka;
use Orka.SIMD.SSE2.Integers;
use Orka.SIMD.SSE2.Integers.Logical;
use AUnit.Assertions;
type Test is new AUnit.Test_Fixtures.Test_Fixture with null record;
function Convert is new Ada.Unchecked_Conversion (Integer_32, Unsigned_32);
function Convert is new Ada.Unchecked_Conversion (Unsigned_32, Integer_32);
function Get_And_Not (Left, Right : Integer_32) return Integer_32 is
(Convert ((not Convert (Left)) and Convert (Right)));
function Get_And (Left, Right : Integer_32) return Integer_32 is
(Convert (Convert (Left) and Convert (Right)));
function Get_Or (Left, Right : Integer_32) return Integer_32 is
(Convert (Convert (Left) or Convert (Right)));
function Get_Xor (Left, Right : Integer_32) return Integer_32 is
(Convert (Convert (Left) xor Convert (Right)));
procedure Test_And_Not (Object : in out Test) is
Left : constant m128i := (0, 1, 2**16, 2**30);
Right : constant m128i := (0, 0, 2**16, 2**30 - 1);
Expected : constant m128i :=
(Get_And_Not (Left (X), Right (X)),
Get_And_Not (Left (Y), Right (Y)),
Get_And_Not (Left (Z), Right (Z)),
Get_And_Not (Left (W), Right (W)));
Result : constant m128i := And_Not (Left, Right);
begin
for I in Index_4D loop
Assert (Expected (I) = Result (I), "Unexpected Integer at " & I'Image);
end loop;
end Test_And_Not;
procedure Test_And (Object : in out Test) is
Left : constant m128i := (0, 1, 2**16, 2**30);
Right : constant m128i := (0, 0, 2**16, 2**30 - 1);
Expected : constant m128i :=
(Get_And (Left (X), Right (X)),
Get_And (Left (Y), Right (Y)),
Get_And (Left (Z), Right (Z)),
Get_And (Left (W), Right (W)));
Result : constant m128i := Left and Right;
begin
for I in Index_4D loop
Assert (Expected (I) = Result (I), "Unexpected Integer at " & I'Image);
end loop;
end Test_And;
procedure Test_Or (Object : in out Test) is
Left : constant m128i := (0, 1, 2**16, 2**30);
Right : constant m128i := (0, 0, 2**16, 2**30 - 1);
Expected : constant m128i :=
(Get_Or (Left (X), Right (X)),
Get_Or (Left (Y), Right (Y)),
Get_Or (Left (Z), Right (Z)),
Get_Or (Left (W), Right (W)));
Result : constant m128i := Left or Right;
begin
for I in Index_4D loop
Assert (Expected (I) = Result (I), "Unexpected Integer at " & I'Image);
end loop;
end Test_Or;
procedure Test_Xor (Object : in out Test) is
Left : constant m128i := (0, 1, 2**16, 2**30);
Right : constant m128i := (0, 0, 2**16, 2**30 - 1);
Expected : constant m128i :=
(Get_Xor (Left (X), Right (X)),
Get_Xor (Left (Y), Right (Y)),
Get_Xor (Left (Z), Right (Z)),
Get_Xor (Left (W), Right (W)));
Result : constant m128i := Left xor Right;
begin
for I in Index_4D loop
Assert (Expected (I) = Result (I), "Unexpected Integer at " & I'Image);
end loop;
end Test_Xor;
----------------------------------------------------------------------------
package Caller is new AUnit.Test_Caller (Test);
Test_Suite : aliased AUnit.Test_Suites.Test_Suite;
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Name : constant String := "(SIMD - SSE2 - Integers - Logical) ";
begin
Test_Suite.Add_Test (Caller.Create
(Name & "Test function And_Not", Test_And_Not'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test 'and' operator", Test_And'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test 'or' operator", Test_Or'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test 'xor' operator", Test_Xor'Access));
return Test_Suite'Access;
end Suite;
end Test_SIMD_SSE2_Logical;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 1,607 | adb | with System; use System;
with Ada.Unchecked_Conversion;
with STM32_SVD.DMA; use STM32_SVD.DMA;
package body STM32GD.USART.Peripheral is
DMA_Index : Integer := 1;
function W is new Ada.Unchecked_Conversion (Address, UInt32);
protected body IRQ_Handler is
entry Wait when Data_Available is
begin
Data_Available := False;
end Wait;
procedure Handler is
begin
USART.ICR.TCCF := 1;
USART.ICR.IDLECF := 1;
USART.ICR.EOBCF := 1;
Data_Available := True;
end Handler;
end IRQ_Handler;
procedure Init is
Int_Scale : constant UInt32 := 4;
Int_Divider : constant UInt32 := (25 * UInt32 (Clock)) / (Int_Scale * Speed);
Frac_Divider : constant UInt32 := Int_Divider rem 100;
begin
USART.BRR.DIV_Fraction :=
STM32_SVD.USART.BRR_DIV_Fraction_Field (((Frac_Divider * 16) + 50) / 100 mod 16);
USART.BRR.DIV_Mantissa :=
STM32_SVD.USART.BRR_DIV_Mantissa_Field (Int_Divider / 100);
USART.CR1.UE := 1;
USART.CR1.TE := 1;
USART.CR1.RE := 1;
USART.ICR.ORECF := 1;
USART.ICR.FECF := 1;
end Init;
procedure Transmit (Data : in Byte) is
begin
USART.ICR.FECF := 1;
while USART.ISR.TXE = 0 loop
null;
end loop;
USART.TDR.TDR := UInt9 (Data);
end Transmit;
function Receive return Byte is
begin
USART.ICR.ORECF := 1;
USART.ICR.FECF := 1;
while USART.ISR.RXNE = 0 loop
null;
end loop;
return Byte (USART.RDR.RDR);
end Receive;
end STM32GD.USART.Peripheral;
|
AdaCore/gpr | Ada | 1,302 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
-- This package represents an entity source reference with an associated
-- message. This is mostly to report warnings/errors while parsing sources.
package body GPR2.Source_Reference.Text_Value is
------------
-- Create --
------------
function Create
(Sloc : GPR2.Source_Reference.Object;
Text : Text_Type) return Object'Class is
begin
return Object'
(Sloc with Text => To_Unbounded_String (String (Text)));
end Create;
function Create
(Filename : Path_Name.Full_Name;
Line, Column : Natural;
Text : Text_Type)
return Object'Class is
begin
return Create
(GPR2.Source_Reference.Object
(GPR2.Source_Reference.Create (Filename, Line, Column)),
Text);
end Create;
----------
-- Text --
----------
function Text (Self : Object) return Text_Type is
begin
return Text_Type (To_String (Self.Text));
end Text;
--------------------
-- Unchecked_Text --
--------------------
function Unchecked_Text (Self : Object) return Unbounded_String is
begin
return Self.Text;
end Unchecked_Text;
end GPR2.Source_Reference.Text_Value;
|
thorstel/Advent-of-Code-2018 | Ada | 1,456 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Input;
procedure Day03 is
type Fabric_Piece_Array is
array (Natural range 1 .. 1000, Natural range 1 .. 1000) of Natural;
Fabric_Piece : Fabric_Piece_Array := (others => (others => 0));
begin
-- Part 1
declare
Claim_Counter : Integer := 0;
begin
for Claim of Input.Claims loop
for I in (Claim.X + 1) .. (Claim.X + Claim.Width) loop
for J in (Claim.Y + 1) .. (Claim.Y + Claim.Height) loop
if Fabric_Piece (I, J) = 1 then
Claim_Counter := Claim_Counter + 1;
end if;
Fabric_Piece (I, J) := Fabric_Piece (I, J) + 1;
end loop;
end loop;
end loop;
Put_Line ("Part 1 =" & Integer'Image (Claim_Counter));
end;
-- Part 2
Outer_Loop :
for Claim of Input.Claims loop
declare
Is_Intact : Boolean := True;
begin
Check_Loop :
for I in (Claim.X + 1) .. (Claim.X + Claim.Width) loop
for J in (Claim.Y + 1) .. (Claim.Y + Claim.Height) loop
if Fabric_Piece (I, J) /= 1 then
Is_Intact := False;
exit Check_Loop;
end if;
end loop;
end loop Check_Loop;
if Is_Intact then
Put_Line ("Part 2 =" & Integer'Image (Claim.ID));
exit Outer_Loop;
end if;
end;
end loop Outer_Loop;
end Day03;
|
AdaCore/Ada_Drivers_Library | Ada | 9,543 | ads | ------------------------------------------------------------------------------
-- --
-- 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_i2c.h --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief Header file of I2C HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides definitions for the STM32F4 (ARM Cortex M4F
-- from ST Microelectronics) Inter-Integrated Circuit (I2C) facility.
private with STM32_SVD.I2C;
with HAL.I2C;
with System;
package STM32.I2C is
type I2C_Device_Mode is
(I2C_Mode,
SMBusDevice_Mode,
SMBusHost_Mode);
type I2C_Duty_Cycle is
(DutyCycle_16_9,
DutyCycle_2);
type I2C_Acknowledgement is (Ack_Disable, Ack_Enable);
type I2C_Direction is (Transmitter, Receiver);
type I2C_Addressing_Mode is
(Addressing_Mode_7bit,
Addressing_Mode_10bit);
type I2C_Configuration is record
Clock_Speed : UInt32;
Mode : I2C_Device_Mode := I2C_Mode;
Duty_Cycle : I2C_Duty_Cycle := DutyCycle_2;
Addressing_Mode : I2C_Addressing_Mode;
Own_Address : UInt10;
-- an I2C general call dispatches the same data to all connected
-- devices.
General_Call_Enabled : Boolean := False;
-- Clock stretching is a mean for a slave device to slow down the
-- i2c clock in order to process the communication.
Clock_Stretching_Enabled : Boolean := True;
Enable_DMA : Boolean := False;
end record;
type Internal_I2C_Port is private;
type I2C_Port (Periph : not null access Internal_I2C_Port) is
limited new HAL.I2C.I2C_Port with private;
procedure Configure
(This : in out I2C_Port;
Conf : I2C_Configuration)
with Post => Port_Enabled (This);
procedure Set_State (This : in out I2C_Port; Enabled : Boolean) with
Post => (Enabled = Port_Enabled (This));
function Port_Enabled (This : I2C_Port) return Boolean;
overriding
procedure Master_Transmit
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Data : HAL.I2C.I2C_Data;
Status : out HAL.I2C.I2C_Status;
Timeout : Natural := 1000);
overriding
procedure Master_Receive
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Data : out HAL.I2C.I2C_Data;
Status : out HAL.I2C.I2C_Status;
Timeout : Natural := 1000);
overriding
procedure Mem_Write
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : HAL.I2C.I2C_Memory_Address_Size;
Data : HAL.I2C.I2C_Data;
Status : out HAL.I2C.I2C_Status;
Timeout : Natural := 1000);
overriding
procedure Mem_Read
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : HAL.I2C.I2C_Memory_Address_Size;
Data : out HAL.I2C.I2C_Data;
Status : out HAL.I2C.I2C_Status;
Timeout : Natural := 1000);
type I2C_Interrupt is
(Error_Interrupt,
Event_Interrupt,
Buffer_Interrupt);
procedure Enable_Interrupt
(This : in out I2C_Port;
Source : I2C_Interrupt)
with Post => Enabled (This, Source);
procedure Disable_Interrupt
(This : in out I2C_Port;
Source : I2C_Interrupt)
with Post => not Enabled (This, Source);
function Enabled
(This : I2C_Port;
Source : I2C_Interrupt)
return Boolean;
private
type I2C_State is
(Reset,
Ready,
Master_Busy_Tx,
Master_Busy_Rx,
Mem_Busy_Tx,
Mem_Busy_Rx);
type Internal_I2C_Port is new STM32_SVD.I2C.I2C_Peripheral;
type I2C_Port (Periph : not null access Internal_I2C_Port) is
limited new HAL.I2C.I2C_Port with record
Config : I2C_Configuration;
State : I2C_State := Reset;
DMA_Enabled : Boolean := False;
end record;
type I2C_Status_Flag is
(Start_Bit,
Address_Sent,
Byte_Transfer_Finished,
Address_Sent_10bit,
Stop_Detection,
Rx_Data_Register_Not_Empty,
Tx_Data_Register_Empty,
Bus_Error,
Arbitration_Lost,
Ack_Failure,
UnderOverrun,
Packet_Error,
Timeout,
SMB_Alert,
Master_Slave_Mode,
Busy,
Transmitter_Receiver_Mode,
General_Call,
SMB_Default,
SMB_Host,
Dual_Flag);
-- Low level flag handling
function Flag_Status (This : I2C_Port;
Flag : I2C_Status_Flag)
return Boolean;
procedure Clear_Address_Sent_Status (This : I2C_Port);
-- Higher level flag handling
procedure Wait_While_Flag
(This : in out I2C_Port;
Flag : I2C_Status_Flag;
F_State : Boolean;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Wait_Master_Flag
(This : in out I2C_Port;
Flag : I2C_Status_Flag;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Master_Request_Write
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Master_Request_Read
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Mem_Request_Write
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : HAL.I2C.I2C_Memory_Address_Size;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Mem_Request_Read
(This : in out I2C_Port;
Addr : HAL.I2C.I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : HAL.I2C.I2C_Memory_Address_Size;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Data_Send
(This : in out I2C_Port;
Data : HAL.I2C.I2C_Data;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Data_Receive
(This : in out I2C_Port;
Data : out HAL.I2C.I2C_Data;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
function Data_Register_Address
(This : I2C_Port)
return System.Address;
-- For DMA transfer
end STM32.I2C;
|
charlie5/cBound | Ada | 1,777 | 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_lightiv_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_lightiv_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_lightiv_reply_t.Item,
Element_Array => xcb.xcb_glx_get_lightiv_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_lightiv_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_lightiv_reply_t.Pointer,
Element_Array => xcb.xcb_glx_get_lightiv_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_lightiv_reply_t;
|
AdaCore/spat | Ada | 10,061 | 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.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Unbounded_Synchronized_Queues;
with Ada.Exceptions;
with Ada.IO_Exceptions;
with Ada.Text_IO;
with SPAT.Log;
with SPAT.Strings;
with System.Multiprocessors;
package body SPAT.Spark_Files is
---------------------------------------------------------------------------
-- Parallelization support.
--
-- Reading and parsing the JSON formatted .spark files can easily be
-- parallelized, there is no dependency between them.
---------------------------------------------------------------------------
package Worker_Tasks is
-- Just use the number of CPUs on the system.
Num_Workers : constant System.Multiprocessors.CPU :=
System.Multiprocessors.Number_Of_CPUs;
-- The tasks get an input file name and return the read JSON result.
-- To be able to map the file name and the corresponding result, we
-- merge them into a single result record type.
type Parse_Result is
record
Key : SPARK_File_Name;
Result : GNATCOLL.JSON.Read_Result;
end record;
package Implementation is
-- Needed queue (interface) instantiations for input and output types.
package File_Queue_Interface is new
Ada.Containers.Synchronized_Queue_Interfaces
(Element_Type => SPARK_File_Name);
package File_Queues is new
Ada.Containers.Unbounded_Synchronized_Queues
(Queue_Interfaces => File_Queue_Interface);
package Result_Queue_Interface is new
Ada.Containers.Synchronized_Queue_Interfaces
(Element_Type => Parse_Result);
package Result_Queues is new
Ada.Containers.Unbounded_Synchronized_Queues
(Queue_Interfaces => Result_Queue_Interface);
end Implementation;
-- Establish the input queue type. This one expects a file name to
-- parse and any instantiated worker tasks will pick it up from there.
Input_File_Queue : Implementation.File_Queues.Queue;
-- Establish the output queue type. Here you can pick up the parsing
-- results.
Result_Queue : Implementation.Result_Queues.Queue;
------------------------------------------------------------------------
-- Stop
--
-- Tell all worker tasks to terminate.
------------------------------------------------------------------------
procedure Stop;
end Worker_Tasks;
package body Worker_Tasks is
task type Parse_Task;
type Task_List is
array (System.Multiprocessors.CPU range <>) of Parse_Task;
Workers : Task_List (1 .. Num_Workers);
------------------------------------------------------------------------
-- Parse_File
------------------------------------------------------------------------
function Parse_File
(Name : in SPARK_File_Name) return GNATCOLL.JSON.Read_Result;
------------------------------------------------------------------------
-- Parse_File
------------------------------------------------------------------------
function Parse_File (Name : in SPARK_File_Name)
return GNATCOLL.JSON.Read_Result
is
JSON_File : Ada.Text_IO.File_Type;
File_Content : JSON_Data;
begin
Ada.Text_IO.Open (File => JSON_File,
Mode => Ada.Text_IO.In_File,
Name => To_String (Source => Name));
while not Ada.Text_IO.End_Of_File (File => JSON_File) loop
Ada.Strings.Unbounded.Append
(Source => File_Content,
New_Item => Ada.Text_IO.Get_Line (File => JSON_File));
end loop;
Ada.Text_IO.Close (File => JSON_File);
return GNATCOLL.JSON.Read (Strm => File_Content);
end Parse_File;
task body Parse_Task is
Element : SPARK_File_Name;
Result : Worker_Tasks.Parse_Result;
begin
Main_Loop :
loop
Input_File_Queue.Dequeue (Element => Element);
Result.Key := Element;
begin
Result.Result := Parse_File (Name => Element);
exception
when E : Ada.IO_Exceptions.Name_Error =>
Result.Result :=
GNATCOLL.JSON.Read_Result'
(Success => False,
Error =>
GNATCOLL.JSON.Parsing_Error'
(Line => 1,
Column => 1,
Message =>
To_Name (Ada.Exceptions.Exception_Message (E))));
end;
Result_Queue.Enqueue (New_Item => Result);
end loop Main_Loop;
end Parse_Task;
------------------------------------------------------------------------
-- Stop
------------------------------------------------------------------------
procedure Stop is
begin
for Worker of Workers loop
abort Worker;
end loop;
end Stop;
end Worker_Tasks;
---------------------------------------------------------------------------
-- Num_Workers
--
-- Report the number of tasks used for parallel file reads.
---------------------------------------------------------------------------
function Num_Workers return Positive is
(Positive (Worker_Tasks.Num_Workers));
Pending : constant GNATCOLL.JSON.Read_Result :=
GNATCOLL.JSON.Read_Result'
(Success => False,
Error =>
GNATCOLL.JSON.Parsing_Error'(Line => Positive'Last,
Column => Positive'Last,
Message => To_Name ("Queued...")));
---------------------------------------------------------------------------
-- Read
---------------------------------------------------------------------------
not overriding
procedure Read (This : in out T;
Names : in Strings.SPARK_File_Names)
is
use type File_Maps.Cursor;
begin
-- Clear any old remnants and reserve capacity for the number of
-- files we will be trying to add, so we avoid rehashing during
-- the loop.
This.Clear;
This.Reserve_Capacity (Capacity => Names.Length);
Run_Parsers :
declare
Num_Expected : Natural := 0; -- How many responses to expect.
begin
-- Queue input files to the worker tasks.
for Name of Names loop
if This.Find (Key => Name) = File_Maps.No_Element then
This.Insert (Key => Name,
New_Item => Pending);
-- Establish key/value pair. The actual value will be
-- established later, but we need the key in the table,
-- otherwise Find above will never find anything.
Log.Debug
(Message =>
"Queuing """ & To_String (Source => Name) & """...");
Num_Expected := Num_Expected + 1;
Worker_Tasks.Input_File_Queue.Enqueue (New_Item => Name);
else
-- Skip file, we already got that one.
--
-- TODO: Normally we shouldn't be too concerned about
-- duplicates. This check is a leftover from the times
-- when we still got these values from the command-line
-- which could have specified the same file more than
-- once.
Log.Warning
(Message =>
"Duplicate file """ & To_String (Source => Name) &
""" ignored.");
end if;
end loop;
-- Collect results.
Collect_Results :
declare
Result : Worker_Tasks.Parse_Result;
begin
Log.Debug (Message => "Picking up results...");
for i in 1 .. Num_Expected loop
Wait_Loop :
loop
select
Worker_Tasks.Result_Queue.Dequeue (Element => Result);
This.Replace (Key => Result.Key,
New_Item => Result.Result);
Log.Debug
(Message =>
"""" & To_String (Result.Key) & """..." &
(if Result.Result.Success
then "ok."
else "error."));
-- Actual error message will be done by caller.
exit Wait_Loop;
or
delay 10.0;
-- Inform the user if this is taking way too long...
Log.Warning (Message => "Ten seconds have passed.");
Log.Warning (Message => "Still waiting for results.");
Log.Warning (Message => "This is taking awfully long!?");
end select;
end loop Wait_Loop;
end loop;
end Collect_Results;
end Run_Parsers;
end Read;
---------------------------------------------------------------------------
-- Shutdown
---------------------------------------------------------------------------
procedure Shutdown is
begin
Worker_Tasks.Stop;
end Shutdown;
end SPAT.Spark_Files;
|
shintakezou/drake | Ada | 31,787 | adb | with Ada.Exceptions.Finally;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Ada.Streams; -- [gcc-4.7] can not search in private with
with System;
package body Ada.Containers.Indefinite_Hashed_Sets is
use type Hash_Tables.Table_Access;
use type Copy_On_Write.Data_Access;
function Upcast is
new Unchecked_Conversion (Cursor, Hash_Tables.Node_Access);
function Downcast is
new Unchecked_Conversion (Hash_Tables.Node_Access, Cursor);
function Upcast is
new Unchecked_Conversion (Data_Access, Copy_On_Write.Data_Access);
function Downcast is
new Unchecked_Conversion (Copy_On_Write.Data_Access, Data_Access);
procedure Free is new Unchecked_Deallocation (Element_Type, Element_Access);
procedure Free is new Unchecked_Deallocation (Node, Cursor);
type Context_Type is limited record
Left : not null access Element_Type;
end record;
pragma Suppress_Initialization (Context_Type);
function Equivalent_Element (
Position : not null Hash_Tables.Node_Access;
Params : System.Address)
return Boolean;
function Equivalent_Element (
Position : not null Hash_Tables.Node_Access;
Params : System.Address)
return Boolean
is
Context : Context_Type;
for Context'Address use Params;
begin
return Equivalent_Elements (
Context.Left.all,
Downcast (Position).Element.all);
end Equivalent_Element;
function Equivalent_Node (Left, Right : not null Hash_Tables.Node_Access)
return Boolean;
function Equivalent_Node (Left, Right : not null Hash_Tables.Node_Access)
return Boolean is
begin
return Equivalent_Elements (
Downcast (Left).Element.all,
Downcast (Right).Element.all);
end Equivalent_Node;
procedure Allocate_Element (
Item : out Element_Access;
New_Item : Element_Type);
procedure Allocate_Element (
Item : out Element_Access;
New_Item : Element_Type) is
begin
Item := new Element_Type'(New_Item);
end Allocate_Element;
procedure Allocate_Node (Item : out Cursor; New_Item : Element_Type);
procedure Allocate_Node (Item : out Cursor; New_Item : Element_Type) is
package Holder is
new Exceptions.Finally.Scoped_Holder (Cursor, Free);
X : aliased Cursor := new Node;
begin
Holder.Assign (X);
Allocate_Element (X.Element, New_Item);
Holder.Clear;
Item := X;
end Allocate_Node;
procedure Copy_Node (
Target : out Hash_Tables.Node_Access;
Source : not null Hash_Tables.Node_Access);
procedure Copy_Node (
Target : out Hash_Tables.Node_Access;
Source : not null Hash_Tables.Node_Access)
is
New_Node : Cursor;
begin
Allocate_Node (New_Node, Downcast (Source).Element.all);
Target := Upcast (New_Node);
end Copy_Node;
procedure Free_Node (Object : in out Hash_Tables.Node_Access);
procedure Free_Node (Object : in out Hash_Tables.Node_Access) is
X : Cursor := Downcast (Object);
begin
Free (X.Element);
Free (X);
Object := null;
end Free_Node;
procedure Allocate_Data (
Target : out not null Copy_On_Write.Data_Access;
New_Length : Count_Type;
Capacity : Count_Type);
procedure Allocate_Data (
Target : out not null Copy_On_Write.Data_Access;
New_Length : Count_Type;
Capacity : Count_Type)
is
pragma Unreferenced (New_Length);
New_Data : constant Data_Access :=
new Data'(Super => <>, Table => null, Length => 0);
begin
Hash_Tables.Rebuild (New_Data.Table, Capacity);
Target := Upcast (New_Data);
end Allocate_Data;
procedure Copy_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type);
procedure Copy_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type)
is
pragma Unreferenced (Length);
pragma Unreferenced (New_Length);
New_Data : constant Data_Access :=
new Data'(Super => <>, Table => null, Length => 0);
begin
Hash_Tables.Copy (
New_Data.Table,
New_Data.Length,
Downcast (Source).Table,
Capacity,
Copy => Copy_Node'Access);
Target := Upcast (New_Data);
end Copy_Data;
procedure Free is new Unchecked_Deallocation (Data, Data_Access);
procedure Free_Data (Data : in out Copy_On_Write.Data_Access);
procedure Free_Data (Data : in out Copy_On_Write.Data_Access) is
X : Data_Access := Downcast (Data);
begin
Hash_Tables.Free (X.Table, X.Length, Free => Free_Node'Access);
Free (X);
Data := null;
end Free_Data;
procedure Reallocate (
Container : in out Set;
Capacity : Count_Type;
To_Update : Boolean);
procedure Reallocate (
Container : in out Set;
Capacity : Count_Type;
To_Update : Boolean) is
begin
Copy_On_Write.Unique (
Target => Container.Super'Access,
Target_Length => 0, -- Length is unused
Target_Capacity => Indefinite_Hashed_Sets.Capacity (Container),
New_Length => 0,
New_Capacity => Capacity,
To_Update => To_Update,
Allocate => Allocate_Data'Access,
Move => Copy_Data'Access,
Copy => Copy_Data'Access,
Free => Free_Data'Access,
Max_Length => Copy_On_Write.Zero'Access);
end Reallocate;
procedure Unique (Container : in out Set; To_Update : Boolean);
procedure Unique (Container : in out Set; To_Update : Boolean) is
begin
if Copy_On_Write.Shared (Container.Super.Data) then
Reallocate (
Container,
Capacity (Container), -- not shrinking
To_Update);
end if;
end Unique;
function Equivalent_Sets (
Left, Right : Set;
Equivalent : not null access function (
Left, Right : not null Hash_Tables.Node_Access)
return Boolean)
return Boolean;
function Equivalent_Sets (
Left, Right : Set;
Equivalent : not null access function (
Left, Right : not null Hash_Tables.Node_Access)
return Boolean)
return Boolean
is
Left_Length : constant Count_Type := Length (Left);
Right_Length : constant Count_Type := Length (Right);
begin
if Left_Length /= Right_Length then
return False;
elsif Left_Length = 0 or else Left.Super.Data = Right.Super.Data then
return True;
else
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Left_Data : constant Data_Access := Downcast (Left.Super.Data);
Right_Data : constant Data_Access := Downcast (Right.Super.Data);
begin
return Hash_Tables.Equivalent (
Left_Data.Table,
Left_Data.Length,
Right_Data.Table,
Right_Data.Length,
Equivalent => Equivalent);
end;
end if;
end Equivalent_Sets;
function Find (Container : Set; Hash : Hash_Type; Item : Element_Type)
return Cursor;
function Find (Container : Set; Hash : Hash_Type; Item : Element_Type)
return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (Hash_Tables.Find (
Downcast (Container.Super.Data).Table,
Hash,
Context'Address,
Equivalent => Equivalent_Element'Access));
end;
end if;
end Find;
-- implementation
function Empty_Set return Set is
begin
return (Finalization.Controlled with Super => (null, null));
end Empty_Set;
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= null;
end Has_Element;
overriding function "=" (Left, Right : Set) return Boolean is
function Equivalent (Left, Right : not null Hash_Tables.Node_Access)
return Boolean;
function Equivalent (Left, Right : not null Hash_Tables.Node_Access)
return Boolean is
begin
return Downcast (Left).Element.all = Downcast (Right).Element.all;
end Equivalent;
begin
return Equivalent_Sets (Left, Right, Equivalent => Equivalent'Access);
end "=";
function Equivalent_Sets (Left, Right : Set) return Boolean is
begin
return Equivalent_Sets (Left, Right,
Equivalent => Equivalent_Node'Access);
end Equivalent_Sets;
function To_Set (New_Item : Element_Type) return Set is
begin
return Result : Set do
Insert (Result, New_Item);
end return;
end To_Set;
-- diff (Generic_Array_To_Set)
--
--
--
--
--
--
--
--
function Capacity (Container : Set) return Count_Type is
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
if Data = null then
return 0;
else
return Hash_Tables.Capacity (Data.Table);
end if;
end Capacity;
procedure Reserve_Capacity (
Container : in out Set;
Capacity : Count_Type)
is
New_Capacity : constant Count_Type :=
Count_Type'Max (Capacity, Length (Container));
begin
Reallocate (Container, New_Capacity, True);
end Reserve_Capacity;
function Length (Container : Set) return Count_Type is
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
if Data = null then
return 0;
else
return Data.Length;
end if;
end Length;
function Is_Empty (Container : Set) return Boolean is
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
return Data = null or else Data.Length = 0;
end Is_Empty;
procedure Clear (Container : in out Set) is
begin
Copy_On_Write.Clear (Container.Super'Access, Free => Free_Data'Access);
end Clear;
function Element (Position : Cursor) return Element_Type is
begin
return Position.Element.all;
end Element;
procedure Replace_Element (
Container : in out Set;
Position : Cursor;
New_Item : Element_Type) is
begin
Unique (Container, True);
Free (Position.Element);
Allocate_Element (Position.Element, New_Item);
end Replace_Element;
procedure Query_Element (
Position : Cursor;
Process : not null access procedure (Element : Element_Type)) is
begin
Process (Position.Element.all);
end Query_Element;
function Constant_Reference (Container : aliased Set; Position : Cursor)
return Constant_Reference_Type
is
pragma Unreferenced (Container);
begin
return (Element => Position.Element.all'Access);
end Constant_Reference;
procedure Assign (Target : in out Set; Source : Set) is
begin
Copy_On_Write.Assign (
Target.Super'Access,
Source.Super'Access,
Free => Free_Data'Access);
end Assign;
function Copy (Source : Set; Capacity : Count_Type := 0) return Set is
begin
return Result : Set do
Copy_On_Write.Copy (
Result.Super'Access,
Source.Super'Access,
0, -- Length is unused
Count_Type'Max (Capacity, Length (Source)),
Allocate => Allocate_Data'Access,
Copy => Copy_Data'Access);
end return;
end Copy;
procedure Move (Target : in out Set; Source : in out Set) is
begin
Copy_On_Write.Move (
Target.Super'Access,
Source.Super'Access,
Free => Free_Data'Access);
-- diff
end Move;
procedure Insert (
Container : in out Set;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
is
-- diff
-- diff
-- diff
New_Hash : constant Hash_Type := Hash (New_Item);
begin
-- diff
-- diff
Position := Find (Container, New_Hash, New_Item);
Inserted := Position = null;
if Inserted then
Unique (Container, True);
Allocate_Node (Position, New_Item);
declare
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
Hash_Tables.Insert (
Data.Table,
Data.Length,
New_Hash,
Upcast (Position));
end;
end if;
end Insert;
procedure Insert (
Container : in out Set;
New_Item : Element_Type)
is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, New_Item, Position, Inserted);
if not Inserted then
raise Constraint_Error;
end if;
end Insert;
procedure Include (Container : in out Set; New_Item : Element_Type) is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, New_Item, Position, Inserted);
if not Inserted then
Replace_Element (Container, Position, New_Item);
end if;
end Include;
procedure Replace (Container : in out Set; New_Item : Element_Type) is
begin
Replace_Element (Container, Find (Container, New_Item), New_Item);
end Replace;
procedure Exclude (Container : in out Set; Item : Element_Type) is
Position : Cursor := Find (Container, Item);
begin
if Position /= null then
Delete (Container, Position);
end if;
end Exclude;
procedure Delete (Container : in out Set; Item : Element_Type) is
Position : Cursor := Find (Container, Item);
begin
Delete (Container, Position);
end Delete;
procedure Delete (Container : in out Set; Position : in out Cursor) is
Position_2 : Hash_Tables.Node_Access := Upcast (Position);
begin
Unique (Container, True);
declare
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
Hash_Tables.Remove (Data.Table, Data.Length, Position_2);
end;
Free_Node (Position_2);
Position := null;
end Delete;
procedure Union (Target : in out Set; Source : Set) is
begin
if Is_Empty (Source) or else Target.Super.Data = Source.Super.Data then
null;
elsif Is_Empty (Target) then
Assign (Target, Source);
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
Source_Data : constant Data_Access := Downcast (Source.Super.Data);
begin
Hash_Tables.Merge (
Target_Data.Table,
Target_Data.Length,
Source_Data.Table,
Source_Data.Length,
(others => True),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Union;
function Union (Left, Right : Set) return Set is
begin
return Result : Set do
if Is_Empty (Right) or else Left.Super.Data = Right.Super.Data then
Assign (Result, Left);
elsif Is_Empty (Left) then
Assign (Result, Right);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
Left_Data : constant Data_Access := Downcast (Left.Super.Data);
Right_Data : constant Data_Access :=
Downcast (Right.Super.Data);
begin
Hash_Tables.Copying_Merge (
Result_Data.Table,
Result_Data.Length,
Left_Data.Table,
Left_Data.Length,
Right_Data.Table,
Right_Data.Length,
(others => True),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Union;
procedure Intersection (Target : in out Set; Source : Set) is
begin
if Is_Empty (Target) or else Is_Empty (Source) then
Clear (Target);
elsif Target.Super.Data = Source.Super.Data then
null;
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
Source_Data : constant Data_Access := Downcast (Source.Super.Data);
begin
Hash_Tables.Merge (
Target_Data.Table,
Target_Data.Length,
Source_Data.Table,
Source_Data.Length,
(Hash_Tables.In_Both => True, others => False),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Intersection;
function Intersection (Left, Right : Set) return Set is
begin
return Result : Set do
if Is_Empty (Left) or else Is_Empty (Right) then
null; -- Empty_Set
elsif Left.Super.Data = Right.Super.Data then
Assign (Result, Left);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
Left_Data : constant Data_Access := Downcast (Left.Super.Data);
Right_Data : constant Data_Access :=
Downcast (Right.Super.Data);
begin
Hash_Tables.Copying_Merge (
Result_Data.Table,
Result_Data.Length,
Left_Data.Table,
Left_Data.Length,
Right_Data.Table,
Right_Data.Length,
(Hash_Tables.In_Both => True, others => False),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Intersection;
procedure Difference (Target : in out Set; Source : Set) is
begin
if Is_Empty (Target) or else Target.Super.Data = Source.Super.Data then
Clear (Target);
elsif Is_Empty (Source) then
null;
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
Source_Data : constant Data_Access := Downcast (Source.Super.Data);
begin
Hash_Tables.Merge (
Target_Data.Table,
Target_Data.Length,
Source_Data.Table,
Source_Data.Length,
(Hash_Tables.In_Only_Left => True, others => False),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Difference;
function Difference (Left, Right : Set) return Set is
begin
return Result : Set do
if Is_Empty (Left) or else Left.Super.Data = Right.Super.Data then
null; -- Empty_Set
elsif Is_Empty (Right) then
Assign (Result, Left);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
Left_Data : constant Data_Access := Downcast (Left.Super.Data);
Right_Data : constant Data_Access :=
Downcast (Right.Super.Data);
begin
Hash_Tables.Copying_Merge (
Result_Data.Table,
Result_Data.Length,
Left_Data.Table,
Left_Data.Length,
Right_Data.Table,
Right_Data.Length,
(Hash_Tables.In_Only_Left => True, others => False),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Difference;
procedure Symmetric_Difference (Target : in out Set; Source : Set) is
begin
if Target.Super.Data = Source.Super.Data then
Clear (Target);
elsif Is_Empty (Source) then
null;
elsif Is_Empty (Target) then
Assign (Target, Source);
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
Source_Data : constant Data_Access := Downcast (Source.Super.Data);
begin
Hash_Tables.Merge (
Target_Data.Table,
Target_Data.Length,
Source_Data.Table,
Source_Data.Length,
(Hash_Tables.In_Both => False, others => True),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Symmetric_Difference;
function Symmetric_Difference (Left, Right : Set) return Set is
begin
return Result : Set do
if Left.Super.Data = Right.Super.Data then
null; -- Empty_Set
elsif Is_Empty (Right) then
Assign (Result, Left);
elsif Is_Empty (Left) then
Assign (Result, Right);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
Left_Data : constant Data_Access := Downcast (Left.Super.Data);
Right_Data : constant Data_Access :=
Downcast (Right.Super.Data);
begin
Hash_Tables.Copying_Merge (
Result_Data.Table,
Result_Data.Length,
Left_Data.Table,
Left_Data.Length,
Right_Data.Table,
Right_Data.Length,
(Hash_Tables.In_Both => False, others => True),
Equivalent => Equivalent_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Symmetric_Difference;
function Overlap (Left, Right : Set) return Boolean is
begin
if Is_Empty (Left) or else Is_Empty (Right) then
return False;
elsif Left.Super.Data = Right.Super.Data then
return True;
else
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
return Hash_Tables.Overlap (
Downcast (Left.Super.Data).Table,
Downcast (Right.Super.Data).Table,
Equivalent => Equivalent_Node'Access);
end if;
end Overlap;
function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is
begin
if Is_Empty (Subset) or else Subset.Super.Data = Of_Set.Super.Data then
return True;
elsif Is_Empty (Of_Set) then
return False;
else
Unique (Subset'Unrestricted_Access.all, False); -- private
Unique (Of_Set'Unrestricted_Access.all, False); -- private
return Hash_Tables.Is_Subset (
Downcast (Subset.Super.Data).Table,
Downcast (Of_Set.Super.Data).Table,
Equivalent => Equivalent_Node'Access);
end if;
end Is_Subset;
function First (Container : Set) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
return Downcast (Hash_Tables.First (
Downcast (Container.Super.Data).Table));
end if;
end First;
function Next (Position : Cursor) return Cursor is
begin
return Downcast (Position.Super.Next);
end Next;
procedure Next (Position : in out Cursor) is
begin
Position := Downcast (Position.Super.Next);
end Next;
function Find (Container : Set; Item : Element_Type) return Cursor is
begin
return Find (Container, Hash (Item), Item);
end Find;
function Contains (Container : Set; Item : Element_Type) return Boolean is
begin
return Find (Container, Item) /= null;
end Contains;
function Equivalent_Elements (Left, Right : Cursor)
return Boolean is
begin
return Equivalent_Elements (Left.Element.all, Right.Element.all);
end Equivalent_Elements;
function Equivalent_Elements (Left : Cursor; Right : Element_Type)
return Boolean is
begin
return Equivalent_Elements (Left.Element.all, Right);
end Equivalent_Elements;
procedure Iterate (
Container : Set'Class;
Process : not null access procedure (Position : Cursor))
is
type P1 is access procedure (Position : Cursor);
type P2 is access procedure (Position : Hash_Tables.Node_Access);
function Cast is new Unchecked_Conversion (P1, P2);
begin
if not Is_Empty (Set (Container)) then
Unique (Set (Container)'Unrestricted_Access.all, False);
Hash_Tables.Iterate (
Downcast (Container.Super.Data).Table,
Cast (Process));
end if;
end Iterate;
function Iterate (Container : Set'Class)
return Set_Iterator_Interfaces.Forward_Iterator'Class is
begin
return Set_Iterator'(First => First (Set (Container)));
end Iterate;
overriding procedure Adjust (Object : in out Set) is
begin
Copy_On_Write.Adjust (Object.Super'Access);
end Adjust;
overriding function First (Object : Set_Iterator) return Cursor is
begin
return Object.First;
end First;
overriding function Next (Object : Set_Iterator; Position : Cursor)
return Cursor
is
pragma Unreferenced (Object);
begin
return Next (Position);
end Next;
package body Generic_Keys is
type Context_Type is limited record
Left : not null access Key_Type;
end record;
pragma Suppress_Initialization (Context_Type);
function Equivalent_Key (
Position : not null Hash_Tables.Node_Access;
Params : System.Address)
return Boolean;
function Equivalent_Key (
Position : not null Hash_Tables.Node_Access;
Params : System.Address)
return Boolean
is
Context : Context_Type;
for Context'Address use Params;
begin
return Equivalent_Keys (
Context.Left.all,
Key (Downcast (Position).Element.all));
end Equivalent_Key;
function Key (Position : Cursor) return Key_Type is
begin
return Key (Position.Element.all);
end Key;
function Element (Container : Set; Key : Key_Type) return Element_Type is
begin
return Element (Find (Container, Key));
end Element;
procedure Replace (
Container : in out Set;
Key : Key_Type;
New_Item : Element_Type) is
begin
Replace_Element (Container, Find (Container, Key), New_Item);
end Replace;
procedure Exclude (Container : in out Set; Key : Key_Type) is
Position : Cursor := Find (Container, Key);
begin
if Position /= null then
Delete (Container, Position);
end if;
end Exclude;
procedure Delete (Container : in out Set; Key : Key_Type) is
Position : Cursor := Find (Container, Key);
begin
Delete (Container, Position);
end Delete;
function Find (Container : Set; Key : Key_Type) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Key'Unrestricted_Access);
begin
return Downcast (Hash_Tables.Find (
Downcast (Container.Super.Data).Table,
Hash (Key),
Context'Address,
Equivalent => Equivalent_Key'Access));
end;
end if;
end Find;
function Contains (Container : Set; Key : Key_Type) return Boolean is
begin
return Find (Container, Key) /= null;
end Contains;
procedure Update_Element_Preserving_Key (
Container : in out Set;
Position : Cursor;
Process : not null access procedure (
Element : in out Element_Type)) is
begin
Process (Reference_Preserving_Key (Container, Position).Element.all);
end Update_Element_Preserving_Key;
function Reference_Preserving_Key (
Container : aliased in out Set;
Position : Cursor)
return Reference_Type is
begin
Unique (Container, True);
-- diff
return (Element => Position.Element.all'Access);
end Reference_Preserving_Key;
function Constant_Reference (Container : aliased Set; Key : Key_Type)
return Constant_Reference_Type is
begin
return Constant_Reference (Container, Find (Container, Key));
end Constant_Reference;
function Reference_Preserving_Key (
Container : aliased in out Set;
Key : Key_Type)
return Reference_Type is
begin
return Reference_Preserving_Key (Container, Find (Container, Key));
end Reference_Preserving_Key;
end Generic_Keys;
package body Streaming is
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Set)
is
Length : Count_Type'Base;
begin
Count_Type'Base'Read (Stream, Length);
Clear (Item);
for I in 1 .. Length loop
declare
New_Item : constant Element_Type := Element_Type'Input (Stream);
begin
-- diff
Include (Item, New_Item);
end;
end loop;
end Read;
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Set)
is
Length : constant Count_Type := Indefinite_Hashed_Sets.Length (Item);
begin
Count_Type'Write (Stream, Length);
if Length > 0 then
declare
Position : Cursor := First (Item);
begin
while Position /= null loop
Element_Type'Output (Stream, Position.Element.all);
Next (Position);
end loop;
end;
end if;
end Write;
end Streaming;
end Ada.Containers.Indefinite_Hashed_Sets;
|
onox/opus-ada | Ada | 8,528 | adb | -- Copyright (c) 2014 onox <[email protected]>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
with Ahven; use Ahven;
with Opus.Encoders;
use Opus;
use Opus.Encoders;
package body Test_Encoders is
Unexpected_Sampling_Rate_Message : constant String := "Unexpected sampling rate";
Unexpected_Application_Message : constant String := "Unexpected application";
Unexpected_Configuration_Message : constant String := "Unexpected configuration";
overriding
procedure Initialize (T : in out Test) is
begin
T.Set_Name ("Encoders");
T.Add_Test_Routine (Test_Create_VoIP_Encoder'Access, "Create encoder for VoIP applications");
T.Add_Test_Routine (Test_Create_Audio_Encoder'Access, "Create encoder for audio applications");
T.Add_Test_Routine (Test_Create_Low_Delay_Encoder'Access, "Create encoder for low delay applications");
T.Add_Test_Routine (Test_Destroy_Encoder'Access, "Destroy encoder");
T.Add_Test_Routine (Test_Reset_State'Access, "Reset state of encoder");
T.Add_Test_Routine (Test_Default_Configuration'Access, "Test the default configuration of the encoder");
T.Add_Test_Routine (Test_Change_Configuration'Access, "Test changing the configuration of the encoder");
end Initialize;
generic
Application : Application_Type;
procedure Test_Create_Encoder;
procedure Test_Create_Encoder is
Encoder_Mono_8_kHz, Encoder_Mono_16_kHz, Encoder_Stereo_48_kHz : Encoder_Data;
begin
Encoder_Mono_8_kHz := Create (Rate_8_kHz, Mono, Application);
Assert (Get_Sample_Rate (Encoder_Mono_8_kHz) = Rate_8_kHz, Unexpected_Sampling_Rate_Message);
Assert (Get_Application (Encoder_Mono_8_kHz) = Application, Unexpected_Application_Message);
Encoder_Mono_16_kHz := Create (Rate_16_kHz, Mono, Application);
Assert (Get_Sample_Rate (Encoder_Mono_16_kHz) = Rate_16_kHz, Unexpected_Sampling_Rate_Message);
Assert (Get_Application (Encoder_Mono_16_kHz) = Application, Unexpected_Application_Message);
Encoder_Stereo_48_kHz := Create (Rate_48_kHz, Stereo, Application);
Assert (Get_Sample_Rate (Encoder_Stereo_48_kHz) = Rate_48_kHz, Unexpected_Sampling_Rate_Message);
Assert (Get_Application (Encoder_Stereo_48_kHz) = Application, Unexpected_Application_Message);
end Test_Create_Encoder;
procedure Internal_Create_VoIP_Encoder is new Test_Create_Encoder (VoIP);
procedure Internal_Create_Audio_Encoder is new Test_Create_Encoder (Audio);
procedure Internal_Create_Low_Delay_Encoder is new Test_Create_Encoder (Restricted_Low_Delay);
procedure Test_Create_VoIP_Encoder renames Internal_Create_VoIP_Encoder;
procedure Test_Create_Audio_Encoder renames Internal_Create_Audio_Encoder;
procedure Test_Create_Low_Delay_Encoder renames Internal_Create_Low_Delay_Encoder;
procedure Test_Destroy_Encoder is
Encoder : constant Encoder_Data := Create (Rate_8_kHz, Mono, VoIP);
begin
Destroy (Encoder);
end Test_Destroy_Encoder;
procedure Test_Reset_State is
Encoder : constant Encoder_Data := Create (Rate_8_kHz, Stereo, Audio);
begin
Reset_State (Encoder);
end Test_Reset_State;
procedure Test_Default_Configuration is
Encoder : constant Encoder_Data := Create (Rate_8_kHz, Mono, VoIP);
begin
Assert (Get_Sample_Rate (Encoder) = Rate_8_kHz, Unexpected_Configuration_Message);
Assert (Get_Application (Encoder) = VoIP, Unexpected_Configuration_Message);
Assert (Get_Channels (Encoder) = Mono, Unexpected_Configuration_Message);
Assert (Get_Bandwidth (Encoder) = Full_Band, Unexpected_Configuration_Message);
Assert (Get_Max_Bandwidth (Encoder) = Full_Band, Unexpected_Configuration_Message);
Assert (Get_Complexity (Encoder) = 9, Unexpected_Configuration_Message);
Assert (not Get_DTX (Encoder), Unexpected_Configuration_Message);
Assert (Get_Force_Channels (Encoder) = Auto, Unexpected_Configuration_Message);
Assert (not Get_Inband_FEC (Encoder), Unexpected_Configuration_Message);
Assert (Get_LSB_Depth (Encoder) = 24, Unexpected_Configuration_Message);
Assert (Get_Packet_Loss (Encoder) = 0, Unexpected_Configuration_Message);
Assert (Get_Signal (Encoder) = Auto, Unexpected_Configuration_Message);
Assert (Get_VBR (Encoder), Unexpected_Configuration_Message);
Assert (Get_VBR_Constraint (Encoder), Unexpected_Configuration_Message);
Assert (not Get_Prediction_Disabled (Encoder), Unexpected_Configuration_Message);
Assert (Get_Expert_Frame_Duration (Encoder) = Argument, Unexpected_Configuration_Message);
end Test_Default_Configuration;
procedure Test_Change_Configuration is
Encoder : constant Encoder_Data := Create (Rate_8_kHz, Mono, VoIP);
begin
Set_Application (Encoder, Audio);
Assert (Get_Application (Encoder) = Audio, Unexpected_Configuration_Message);
Set_Application (Encoder, Restricted_Low_Delay);
Assert (Get_Application (Encoder) = Restricted_Low_Delay, Unexpected_Configuration_Message);
Set_Max_Bandwidth (Encoder, Narrow_Band);
Assert (Get_Max_Bandwidth (Encoder) = Narrow_Band, Unexpected_Configuration_Message);
Set_Max_Bandwidth (Encoder, Medium_Band);
Assert (Get_Max_Bandwidth (Encoder) = Medium_Band, Unexpected_Configuration_Message);
Set_Complexity (Encoder, 5);
Assert (Get_Complexity (Encoder) = 5, Unexpected_Configuration_Message);
Set_Complexity (Encoder, 10);
Assert (Get_Complexity (Encoder) = 10, Unexpected_Configuration_Message);
Assert (Get_Bitrate (Encoder) = 32_000, Unexpected_Configuration_Message);
Set_Bitrate (Encoder, 50_000);
Assert (Get_Bitrate (Encoder) = 50_000, Unexpected_Configuration_Message);
Set_Bitrate (Encoder, Auto);
Assert (Get_Bitrate (Encoder) = 32_000, Unexpected_Configuration_Message);
Set_DTX (Encoder, True);
Assert (Get_DTX (Encoder), Unexpected_Configuration_Message);
Set_DTX (Encoder, False);
Assert (not Get_DTX (Encoder), Unexpected_Configuration_Message);
Set_Inband_FEC (Encoder, True);
Assert (Get_Inband_FEC (Encoder), Unexpected_Configuration_Message);
Set_Inband_FEC (Encoder, False);
Assert (not Get_Inband_FEC (Encoder), Unexpected_Configuration_Message);
Set_LSB_Depth (Encoder, 8);
Assert (Get_LSB_Depth (Encoder) = 8, Unexpected_Configuration_Message);
Set_LSB_Depth (Encoder, 20);
Assert (Get_LSB_Depth (Encoder) = 20, Unexpected_Configuration_Message);
Set_VBR_Constraint (Encoder, False);
Assert (not Get_VBR_Constraint (Encoder), Unexpected_Configuration_Message);
Set_VBR_Constraint (Encoder, True);
Assert (Get_VBR_Constraint (Encoder), Unexpected_Configuration_Message);
Set_VBR (Encoder, False);
Assert (not Get_VBR (Encoder), Unexpected_Configuration_Message);
Set_VBR (Encoder, True);
Assert (Get_VBR (Encoder), Unexpected_Configuration_Message);
Set_Prediction_Disabled (Encoder, True);
Assert (Get_Prediction_Disabled (Encoder), Unexpected_Configuration_Message);
Set_Prediction_Disabled (Encoder, False);
Assert (not Get_Prediction_Disabled (Encoder), Unexpected_Configuration_Message);
Set_Expert_Frame_Duration (Encoder, Frame_10_ms);
Assert (Get_Expert_Frame_Duration (Encoder) = Frame_10_ms, Unexpected_Configuration_Message);
Set_Expert_Frame_Duration (Encoder, Argument);
Assert (Get_Expert_Frame_Duration (Encoder) = Argument, Unexpected_Configuration_Message);
end Test_Change_Configuration;
end Test_Encoders;
|
kraileth/ravenadm | Ada | 76,372 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Unix;
with Replicant;
with Parameters;
with PortScan.Log;
with PortScan.Tests;
with PortScan.Packager;
with File_Operations;
with Ada.Directories;
with Ada.Characters.Latin_1;
with Ada.Exceptions;
package body PortScan.Buildcycle is
package EX renames Ada.Exceptions;
package LAT renames Ada.Characters.Latin_1;
package DIR renames Ada.Directories;
package FOP renames File_Operations;
package LOG renames PortScan.Log;
package PKG renames PortScan.Packager;
package TST renames PortScan.Tests;
package PM renames Parameters;
package REP renames Replicant;
--------------------------------------------------------------------------------------------
-- build_package
--------------------------------------------------------------------------------------------
function build_package (id : builders;
sequence_id : port_id;
specification : PSP.Portspecs;
interactive : Boolean := False;
interphase : String := "") return Boolean
is
R : Boolean;
break_phase : constant phases := valid_test_phase (interphase);
run_selftest : constant Boolean := Unix.env_variable_defined (selftest);
pkgversion : constant String := HT.USS (all_ports (sequence_id).pkgversion);
normsslv : constant String := PM.ssl_selection (PM.configuration);
sslv : constant String := specification.get_ssl_variant (normsslv);
environ : constant String := environment_override (True, sslv);
env_nochain : constant String := environment_override (False, sslv);
port_prefix : constant String := get_port_prefix (id, environ);
variant : constant String := HT.USS (all_ports (sequence_id).port_variant);
begin
trackers (id).seq_id := sequence_id;
trackers (id).loglines := 0;
trackers (id).check_strip := not specification.debugging_is_on;
trackers (id).rpath_fatal := specification.rpath_check_errors_are_fatal;
trackers (id).disable_dog := specification.watchdog_disabled;
if not LOG.initialize_log (log_handle => trackers (id).log_handle,
head_time => trackers (id).head_time,
seq_id => trackers (id).seq_id,
slave_root => get_root (id),
UNAME => HT.USS (uname_mrv),
BENV => get_environment (id, environ),
COPTS => specification.options_summary (variant),
PTVAR => get_port_variables (id, environ),
block_dog => trackers (id).disable_dog)
then
LOG.finalize_log (trackers (id).log_handle,
trackers (id).head_time,
trackers (id).tail_time);
return False;
end if;
begin
for phase in phases'Range loop
phase_trackers (id) := phase;
case phase is
when blr_depends =>
R := exec_phase_depends (specification => specification,
phase_name => phase2str (phase),
id => id,
environ => environ);
when fetch =>
REP.hook_toolchain (id);
R := exec_phase_generic (id, phase, environ);
when extract | patch =>
R := exec_phase_generic (id, phase, environ);
when configure =>
if testing then
mark_file_system (id, "preconfig", environ);
end if;
R := exec_phase_generic (id, phase, environ);
when build =>
R := exec_phase_build (id, environ);
when stage =>
if testing then
mark_file_system (id, "prestage", env_nochain);
end if;
R := exec_phase_generic (id, phase, env_nochain);
when test =>
if testing and run_selftest then
R := exec_phase_generic (id, phase, environ);
end if;
REP.unhook_toolchain (id);
if R and then testing then
R := deinstall_all_packages (id, env_nochain);
if R then
R := install_run_depends (specification, id, env_nochain);
end if;
end if;
when pkg_package =>
R := PKG.exec_phase_package (specification => specification,
log_handle => trackers (id).log_handle,
log_name => LOG.log_name (trackers (id).seq_id),
phase_name => phase2str (phase),
seq_id => trackers (id).seq_id,
port_prefix => port_prefix,
rootdir => get_root (id));
when install =>
if testing then
R := exec_phase_install (id, pkgversion, env_nochain);
end if;
when check_plist =>
if testing then
R := TST.exec_check_plist (specification => specification,
log_handle => trackers (id).log_handle,
phase_name => phase2str (phase),
seq_id => trackers (id).seq_id,
port_prefix => port_prefix,
rootdir => get_root (id));
end if;
when deinstall =>
if testing then
R := exec_phase_deinstall (id, pkgversion, env_nochain);
end if;
end case;
exit when R = False;
exit when interactive and then phase = break_phase;
end loop;
exception
when crash : others =>
R := False;
TIO.Put_Line (trackers (id).log_handle, "!!!! CRASH !!!! " &
EX.Exception_Information (crash));
dump_stack (trackers (id).log_handle);
end;
LOG.finalize_log (trackers (id).log_handle,
trackers (id).head_time,
trackers (id).tail_time);
if interactive then
interact_with_builder (id, sslv);
end if;
return R;
end build_package;
--------------------------------------------------------------------------------------------
-- last_build_phase
--------------------------------------------------------------------------------------------
function last_build_phase (id : builders) return String is
begin
return phase2str (phase => phase_trackers (id));
end last_build_phase;
--------------------------------------------------------------------------------------------
-- max_time_without_output
--------------------------------------------------------------------------------------------
function max_time_without_output (phase : phases) return execution_limit
is
base : Integer;
begin
case phase is
when blr_depends => base := 15; -- octave forge extraction is driver
when fetch => return 480; -- 8 hours
when extract => base := 20;
when patch => base := 3;
when configure => base := 15;
when build => base := 40; -- for gcc linking, tex, *llvm linking*
when stage => base := 15; -- compiling impossible; toolchain removed
when test => base := 25;
when check_plist => base := 10; -- For packages with thousands of files
when pkg_package => base := 80;
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;
--------------------------------------------------------------------------------------------
-- phase2str
--------------------------------------------------------------------------------------------
function phase2str (phase : phases) return String
is
-- Locked into 12-character length limit. Any longer requires modification to
-- display package and build_status function.
begin
case phase is
when blr_depends => return "dependencies";
when fetch => return "fetch";
when extract => return "extract";
when patch => return "patch";
when configure => return "configure";
when build => return "build";
when stage => return "stage";
when test => return "test";
when pkg_package => return "package";
when install => return "install";
when deinstall => return "deinstall";
when check_plist => return "check-plist";
end case;
end phase2str;
--------------------------------------------------------------------------------------------
-- valid_test_phase #1
--------------------------------------------------------------------------------------------
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 stage;
elsif afterphase = "package" then
return pkg_package;
elsif afterphase = "install" then
return install;
elsif afterphase = "deinstall" then
return deinstall;
else
return phases'First;
end if;
end valid_test_phase;
--------------------------------------------------------------------------------------------
-- valid_test_phase #2
--------------------------------------------------------------------------------------------
function valid_test_phase (afterphase : String) return Boolean is
begin
return
afterphase = "extract" or else
afterphase = "patch" or else
afterphase = "configure" or else
afterphase = "build" or else
afterphase = "stage" or else
afterphase = "install" or else
afterphase = "deinstall";
end valid_test_phase;
--------------------------------------------------------------------------------------------
-- exec_phase_generic
--------------------------------------------------------------------------------------------
function exec_phase_generic
(id : builders;
phase : phases;
environ : String) return Boolean
is
time_limit : execution_limit := max_time_without_output (phase);
begin
return exec_phase (id => id,
phase => phase,
time_limit => time_limit,
environ => environ);
end exec_phase_generic;
--------------------------------------------------------------------------------------------
-- exec_phase_build
--------------------------------------------------------------------------------------------
function exec_phase_build
(id : builders;
environ : String) 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,
environ => environ);
if testing and then passed then
passed := detect_leftovers_and_MIA (id => id,
action => "preconfig",
description => "between port configure and build",
environ => environ);
end if;
LOG.log_phase_end (trackers (id).log_handle);
return passed;
end exec_phase_build;
--------------------------------------------------------------------------------------------
-- pkg_install_subroutine
--------------------------------------------------------------------------------------------
function pkg_install_subroutine (id : builders; root, env_vars, line : String) return Boolean
is
timed_out : Boolean;
time_limit : execution_limit := max_time_without_output (install);
PKG_ADD : constant String := "/usr/bin/ravensw add ";
portkey : constant String := convert_depend_origin_to_portkey (line);
ptid : constant port_id := ports_keys (HT.SUS (portkey));
pkgname : constant String := HT.replace_all (line, LAT.Colon, LAT.Hyphen);
pkgversion : constant String := HT.USS (all_ports (ptid).pkgversion);
pkgfile : constant String := pkgname & LAT.Hyphen & pkgversion & arc_ext;
fullpath : constant String := HT.USS (PM.configuration.dir_repository) & "/" & pkgfile;
command : constant String := PM.chroot_cmd & root & env_vars & PKG_ADD &
"/packages/All/" & pkgfile;
still_good : Boolean := True;
begin
if DIR.Exists (fullpath) then
TIO.Put_Line (trackers (id).log_handle, "===> Installing " & pkgname & " package");
TIO.Close (trackers (id).log_handle);
still_good := generic_execute (id, command, timed_out, time_limit);
TIO.Open (File => trackers (id).log_handle,
Mode => TIO.Append_File,
Name => LOG.log_name (trackers (id).seq_id));
if timed_out then
TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit));
end if;
else
still_good := False;
TIO.Put_Line (trackers (id).log_handle, "Dependency package not found: " & pkgfile);
end if;
return still_good;
end pkg_install_subroutine;
--------------------------------------------------------------------------------------------
-- exec_phase_depends
--------------------------------------------------------------------------------------------
function exec_phase_depends
(specification : PSP.Portspecs;
phase_name : String;
id : builders;
environ : String) return Boolean
is
root : constant String := get_root (id);
still_good : Boolean := True;
markers : HT.Line_Markers;
block : constant String :=
specification.combined_dependency_origins (include_run => not testing,
limit_to_run => False);
begin
LOG.log_phase_begin (trackers (id).log_handle, phase_name);
HT.initialize_markers (block, markers);
loop
exit when not still_good;
exit when not HT.next_line_present (block, markers);
declare
line : constant String := HT.extract_line (block, markers);
begin
still_good := pkg_install_subroutine (id, root, environ, line);
end;
end loop;
LOG.log_phase_end (trackers (id).log_handle);
return still_good;
end exec_phase_depends;
--------------------------------------------------------------------------------------------
-- install_run_depends
--------------------------------------------------------------------------------------------
function install_run_depends
(specification : PSP.Portspecs;
id : builders;
environ : String) return Boolean
is
phase_name : constant String := "test / install run dependencies";
root : constant String := get_root (id);
still_good : Boolean := True;
markers : HT.Line_Markers;
block : constant String :=
specification.combined_dependency_origins (include_run => True,
limit_to_run => True);
begin
LOG.log_phase_begin (trackers (id).log_handle, phase_name);
HT.initialize_markers (block, markers);
loop
exit when not still_good;
exit when not HT.next_line_present (block, markers);
declare
line : constant String := HT.extract_line (block, markers);
begin
still_good := pkg_install_subroutine (id, root, environ, line);
end;
end loop;
LOG.log_phase_end (trackers (id).log_handle);
return still_good;
end install_run_depends;
--------------------------------------------------------------------------------------------
-- deinstall_all_packages
--------------------------------------------------------------------------------------------
function deinstall_all_packages
(id : builders;
environ : String) return Boolean
is
time_limit : execution_limit := max_time_without_output (test);
root : constant String := get_root (id);
phase_name : constant String := "test / deinstall all packages";
PKG_RM_ALL : constant String := "/usr/bin/ravensw delete -a -y ";
command : constant String := PM.chroot_cmd & root & environ & PKG_RM_ALL;
still_good : Boolean := True;
timed_out : Boolean;
begin
LOG.log_phase_begin (trackers (id).log_handle, phase_name);
TIO.Put_Line (trackers (id).log_handle, "===> Autoremoving orphaned packages");
TIO.Close (trackers (id).log_handle);
still_good := generic_execute (id, command, timed_out, time_limit);
TIO.Open (File => trackers (id).log_handle,
Mode => TIO.Append_File,
Name => LOG.log_name (trackers (id).seq_id));
LOG.log_phase_end (trackers (id).log_handle);
return still_good;
end deinstall_all_packages;
--------------------------------------------------------------------------------------------
-- exec_phase_install
--------------------------------------------------------------------------------------------
function exec_phase_install
(id : builders;
pkgversion : String;
environ : String) return Boolean
is
procedure install_it (position : subpackage_crate.Cursor);
time_limit : execution_limit := max_time_without_output (install);
root : constant String := get_root (id);
namebase : constant String := HT.USS (all_ports (trackers (id).seq_id).port_namebase);
PKG_ADD : constant String := "/usr/bin/ravensw add ";
still_good : Boolean := True;
timed_out : Boolean;
procedure install_it (position : subpackage_crate.Cursor)
is
rec : subpackage_record renames subpackage_crate.Element (position);
subpackage : constant String := HT.USS (rec.subpackage);
pkgname : String := calculate_package_name (trackers (id).seq_id, subpackage);
PKG_FILE : constant String := "/packages/All/" & pkgname & arc_ext;
command : constant String := PM.chroot_cmd & root & environ & PKG_ADD & PKG_FILE;
begin
if still_good then
TIO.Put_Line (trackers (id).log_handle, "===> Installing " & pkgname & " package");
TIO.Close (trackers (id).log_handle);
still_good := generic_execute (id, command, timed_out, time_limit);
TIO.Open (File => trackers (id).log_handle,
Mode => TIO.Append_File,
Name => LOG.log_name (trackers (id).seq_id));
if timed_out then
TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit));
end if;
end if;
end install_it;
begin
LOG.log_phase_begin (trackers (id).log_handle, phase2str (install));
all_ports (trackers (id).seq_id).subpackages.Iterate (install_it'Access);
LOG.log_phase_end (trackers (id).log_handle);
return still_good;
end exec_phase_install;
--------------------------------------------------------------------------------------------
-- exec_phase
--------------------------------------------------------------------------------------------
function exec_phase (id : builders;
phase : phases;
time_limit : execution_limit;
environ : String;
phaseenv : String := "";
depends_phase : Boolean := False;
skip_header : Boolean := False;
skip_footer : Boolean := False)
return Boolean
is
root : constant String := get_root (id);
pid : port_id := trackers (id).seq_id;
result : Boolean;
timed_out : Boolean;
begin
-- 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 not skip_header then
LOG.log_phase_begin (trackers (id).log_handle, phase2str (phase));
end if;
TIO.Close (trackers (id).log_handle);
declare
command : constant String := PM.chroot_cmd & root & environ &
phaseenv & chroot_make_program & " -C /port " & 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
TIO.Open (File => trackers (id).log_handle,
Mode => TIO.Append_File,
Name => LOG.log_name (trackers (id).seq_id));
if timed_out then
TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit));
end if;
if not skip_footer then
LOG.log_phase_end (trackers (id).log_handle);
end if;
return result;
end exec_phase;
--------------------------------------------------------------------------------------------
-- get_port_variables
--------------------------------------------------------------------------------------------
function get_port_variables (id : builders; environ : String) return String
is
root : constant String := get_root (id);
command : constant String := PM.chroot_cmd & root & environ & chroot_make_program &
" -C /port -VCONFIGURE_ENV -VCONFIGURE_ARGS" &
" -VMAKE_ENV -VMAKE_ARGS -VPLIST_SUB -VSUB_LIST";
begin
return generic_system_command (command);
exception
when others => return discerr;
end get_port_variables;
--------------------------------------------------------------------------------------------
-- generic_system_command
--------------------------------------------------------------------------------------------
function generic_system_command (command : String) return String
is
content : HT.Text;
status : Integer;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
declare
message : String := command & " (return code =" & status'Img & ")";
projlen : Natural := message'Length + 5;
begin
REP.append_abnormal_log ("COMMAND: " & command);
REP.append_abnormal_log (" OUTPUT: " & HT.USS (content));
if projlen > 200 then
raise cycle_cmd_error
with "cmd: ..." & message (message'Last - 191 .. message'Last);
else
raise cycle_cmd_error with "cmd: " & message;
end if;
end;
end if;
return HT.USS (content);
end generic_system_command;
--------------------------------------------------------------------------------------------
-- set_uname_mrv
--------------------------------------------------------------------------------------------
procedure set_uname_mrv
is
command : constant String := HT.USS (PM.configuration.dir_sysroot) & "/usr/bin/uname -mrv";
begin
uname_mrv := HT.SUS (generic_system_command (command));
end set_uname_mrv;
--------------------------------------------------------------------------------------------
-- get_root
--------------------------------------------------------------------------------------------
function get_root (id : builders) return String
is
suffix : String := "/SL" & HT.zeropad (Integer (id), 2);
begin
return HT.USS (PM.configuration.dir_buildbase) & suffix;
end get_root;
--------------------------------------------------------------------------------------------
-- get_environment
--------------------------------------------------------------------------------------------
function get_environment (id : builders; environ : String) return String
is
root : constant String := get_root (id);
command : constant String := PM.chroot_cmd & root & environ;
begin
return generic_system_command (command);
exception
when others =>
return discerr;
end get_environment;
--------------------------------------------------------------------------------------------
-- environment_override
--------------------------------------------------------------------------------------------
function environment_override (toolchain : Boolean;
ssl_variant : String;
enable_tty : Boolean := False) return String
is
function set_terminal (enable_tty : Boolean) return String;
function toolchain_path return String;
function dyld_fallback return String;
localbase : constant String := HT.USS (PM.configuration.dir_localbase);
function set_terminal (enable_tty : Boolean) return String is
begin
if enable_tty then
return "TERM=xterm ";
end if;
return "TERM=dumb ";
end set_terminal;
function toolchain_path return String
is
defcomp : String := localbase & "/toolchain/" & default_compiler & "/bin:";
begin
if toolchain
then
if default_compiler /= previous_default then
return defcomp & localbase & "/toolchain/" & previous_default & "/bin:";
else
return defcomp;
end if;
else
return "";
end if;
end toolchain_path;
function dyld_fallback return String is
begin
case platform_type is
when macos => return "DYLD_FALLBACK_LIBRARY_PATH=" &
localbase & "/toolchain-fallback/" & default_compiler & "/lib ";
when others => return "";
end case;
end dyld_fallback;
PATH : constant String := "PATH=/bin:/usr/bin:"
& toolchain_path
& localbase & "/toolchain/bin:"
& localbase & "/sbin:"
& localbase & "/bin ";
TERM : constant String := set_terminal (enable_tty);
USER : constant String := "USER=root ";
HOME : constant String := "HOME=/root ";
LANG : constant String := "LANG=C ";
SHLL : constant String := "SHELL=/bin/sh ";
RAVN : constant String := "RAVENADM=building ";
SSLV : constant String := "SSL_VARIANT=" & ssl_variant & " ";
PKG8 : constant String := "RAVENSW_DBDIR=/var/db/pkg8 " &
"RAVENSW_CACHEDIR=/var/cache/pkg8 ";
CENV : constant String := HT.USS (customenv);
DYLD : constant String := dyld_fallback;
begin
return " /usr/bin/env -i " &
CENV & LANG & TERM & SHLL & USER & HOME & RAVN & SSLV & PKG8 & DYLD & PATH;
end environment_override;
--------------------------------------------------------------------------------------------
-- obtain_custom_environment
--------------------------------------------------------------------------------------------
procedure obtain_custom_environment
is
target_name : constant String := PM.raven_confdir & "/" &
HT.USS (PM.configuration.profile) & "-environment";
begin
customenv := HT.blank;
if not DIR.Exists (target_name) then
return;
end if;
declare
contents : String := FOP.get_file_contents (target_name);
markers : HT.Line_Markers;
begin
HT.initialize_markers (contents, markers);
loop
exit when not HT.next_line_present (contents, markers);
declare
line : constant String := HT.extract_line (contents, markers);
begin
if HT.contains (line, "=") then
HT.SU.Append (customenv, HT.trim (line) & " ");
end if;
end;
end loop;
end;
end obtain_custom_environment;
--------------------------------------------------------------------------------------------
-- initialize
--------------------------------------------------------------------------------------------
procedure initialize (test_mode : Boolean) is
begin
set_uname_mrv;
testing := test_mode;
declare
logdir : constant String := HT.USS (PM.configuration.dir_logs);
begin
if not DIR.Exists (logdir) then
DIR.Create_Path (New_Directory => logdir);
end if;
exception
when error : others =>
raise scan_log_error
with "failed to create " & logdir;
end;
obtain_custom_environment;
end initialize;
--------------------------------------------------------------------------------------------
-- initialize
--------------------------------------------------------------------------------------------
function exec_phase_deinstall
(id : builders;
pkgversion : String;
environ : String) return Boolean
is
procedure deinstall_it (position : subpackage_crate.Cursor);
time_limit : execution_limit := max_time_without_output (deinstall);
root : constant String := get_root (id);
namebase : constant String := HT.USS (all_ports (trackers (id).seq_id).port_namebase);
PKG_DELETE : constant String := "/usr/bin/ravensw delete -f -y ";
still_good : Boolean := True;
dyn_good : Boolean;
timed_out : Boolean;
procedure deinstall_it (position : subpackage_crate.Cursor)
is
rec : subpackage_record renames subpackage_crate.Element (position);
subpackage : constant String := HT.USS (rec.subpackage);
pkgname : String := calculate_package_name (trackers (id).seq_id, subpackage);
command : constant String := PM.chroot_cmd & root & environ & PKG_DELETE & pkgname;
begin
if still_good then
TIO.Put_Line (trackers (id).log_handle, "===> Deinstalling " & pkgname & " package");
TIO.Close (trackers (id).log_handle);
still_good := generic_execute (id, command, timed_out, time_limit);
TIO.Open (File => trackers (id).log_handle,
Mode => TIO.Append_File,
Name => LOG.log_name (trackers (id).seq_id));
if timed_out then
TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit));
end if;
end if;
end deinstall_it;
begin
LOG.log_phase_begin (trackers (id).log_handle, phase2str (deinstall));
dyn_good := log_linked_libraries (id, pkgversion, environ);
all_ports (trackers (id).seq_id).subpackages.Iterate (deinstall_it'Access);
if still_good then
still_good := detect_leftovers_and_MIA
(id => id,
action => "prestage",
description => "between staging and package deinstallation",
environ => environ);
end if;
LOG.log_phase_end (trackers (id).log_handle);
return still_good and then dyn_good;
end exec_phase_deinstall;
--------------------------------------------------------------------------------------------
-- stack_linked_libraries
--------------------------------------------------------------------------------------------
procedure stack_linked_libraries
(id : builders;
base : String;
filename : String;
environ : String)
is
command : String := PM.chroot_cmd & base & environ &
"/usr/bin/objdump-sysroot -p " & filename;
begin
declare
comres : String := generic_system_command (command);
markers : HT.Line_Markers;
pathstr : HT.Text := HT.blank;
initial : String := " NEEDED";
runpath : String := " RUNPATH";
rpath : String := " RPATH";
begin
HT.initialize_markers (comres, markers);
if HT.next_line_with_content_present (comres, runpath, markers) then
declare
line : constant String := HT.extract_line (comres, markers);
begin
pathstr := HT.SUS (FOP.convert_ORIGIN_in_runpath
(filename => filename,
runpath => HT.trim (HT.part_2 (line, runpath))));
end;
else
HT.initialize_markers (comres, markers);
if HT.next_line_with_content_present (comres, rpath, markers) then
declare
line : constant String := HT.extract_line (comres, markers);
begin
pathstr := HT.SUS (FOP.convert_ORIGIN_in_runpath
(filename => filename,
runpath => HT.trim (HT.part_2 (line, rpath))));
end;
end if;
end if;
HT.initialize_markers (comres, markers);
loop
exit when not HT.next_line_with_content_present (comres, initial, markers);
declare
line : constant String := HT.extract_line (comres, markers);
shlib : constant String := " " & HT.trim (HT.part_2 (line, initial));
shpayload : HT.Text := HT.SUS (HT.USS (pathstr) & shlib);
line_text : HT.Text := HT.SUS (line);
begin
if not trackers (id).dynlink.Contains (line_text) then
trackers (id).dynlink.Append (line_text);
end if;
if not trackers (id).runpaths.Contains (shpayload) then
trackers (id).runpaths.Append (shpayload);
end if;
end;
end loop;
end;
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
--------------------------------------------------------------------------------------------
function log_linked_libraries
(id : builders;
pkgversion : String;
environ : String) return Boolean
is
procedure log_dump (position : string_crate.Cursor);
procedure check_package (position : subpackage_crate.Cursor);
root : constant String := get_root (id);
namebase : constant String := HT.USS (all_ports (trackers (id).seq_id).port_namebase);
result : Boolean := True;
procedure log_dump (position : string_crate.Cursor)
is
info : String := " " & HT.USS (string_crate.Element (position));
begin
TIO.Put_Line (trackers (id).log_handle, info);
end log_dump;
procedure check_package (position : subpackage_crate.Cursor)
is
rec : subpackage_record renames subpackage_crate.Element (position);
subpackage : constant String := HT.USS (rec.subpackage);
pkgname : String := calculate_package_name (trackers (id).seq_id, subpackage);
command : constant String := PM.chroot_cmd & root & environ &
"/usr/bin/ravensw query %Fp " & pkgname;
comres : String := generic_system_command (command);
markers : HT.Line_Markers;
begin
trackers (id).dynlink.Clear;
trackers (id).runpaths.Clear;
trackers (id).checkpaths.Clear;
trackers (id).goodpaths.Clear;
HT.initialize_markers (comres, markers);
loop
exit when not HT.next_line_present (comres, markers);
declare
filename : constant String := HT.extract_line (comres, markers);
unstripped : Boolean;
begin
if dynamically_linked (base => root,
filename => filename,
strip_check => trackers (id).check_strip,
unstripped => unstripped)
then
stack_linked_libraries (id, root, filename, environ);
if not passed_runpath_check (id) then
result := False;
end if;
end if;
if unstripped then
TIO.Put_Line
(trackers (id).log_handle,
"### WARNING ### " & filename & " is not stripped. " &
"See Ravenporter's guide.");
end if;
end;
end loop;
if not trackers (id).dynlink.Is_Empty then
TIO.Put_Line (trackers (id).log_handle, "===> " & pkgname & " subpackage:");
trackers (id).dynlink.Iterate (log_dump'Access);
end if;
exception
when others => null;
end check_package;
begin
TIO.Put_Line (trackers (id).log_handle, "=> Checking shared library dependencies");
all_ports (trackers (id).seq_id).subpackages.Iterate (check_package'Access);
return result;
end log_linked_libraries;
--------------------------------------------------------------------------------------------
-- dynamically_linked
--------------------------------------------------------------------------------------------
function dynamically_linked
(base : String;
filename : String;
strip_check : Boolean;
unstripped : out Boolean) return Boolean
is
command : String :=
PM.chroot_cmd & base & " /usr/bin/file -b -L -e ascii -e encoding -e tar -e compress " &
"-h -m /usr/share/file/magic.mgc " & HT.shell_quoted (filename);
dynlinked : Boolean;
statlinked : Boolean;
begin
unstripped := False;
declare
comres : constant String := generic_system_command (command);
begin
dynlinked := HT.contains (comres, "dynamically linked");
if dynlinked then
statlinked := False;
else
statlinked := HT.contains (comres, "statically linked");
end if;
if strip_check then
if dynlinked or else statlinked then
if HT.contains (comres, ", not stripped") then
unstripped := True;
end if;
end if;
end if;
return dynlinked;
end;
exception
when others =>
return False;
end dynamically_linked;
--------------------------------------------------------------------------------------------
-- passed_runpath_check
--------------------------------------------------------------------------------------------
function passed_runpath_check (id : builders) return Boolean
is
procedure scan (position : string_crate.Cursor);
function errmsg_prefix return String;
result : Boolean := True;
root : constant String := get_root (id);
fail_result : Boolean := not trackers (id).rpath_fatal;
function errmsg_prefix return String is
begin
if trackers (id).rpath_fatal then
return "### FATAL ERROR ### ";
else
return "### WARNING ### ";
end if;
end errmsg_prefix;
procedure scan (position : string_crate.Cursor)
is
procedure squawk;
function get_system_lib_level_1 return String;
function get_system_lib_level_2 return String;
line : String := HT.USS (string_crate.Element (position));
paths : constant String := HT.part_1 (line, " ");
library : constant String := HT.part_2 (line, " ");
numfields : constant Natural := HT.count_char (paths, LAT.Colon) + 1;
attempted : Boolean := False;
function get_system_lib_level_1 return String is
begin
if platform_type = linux then
return "/lib/x86_64-linux-gnu";
else
return "/lib";
end if;
end get_system_lib_level_1;
function get_system_lib_level_2 return String is
begin
if platform_type = linux then
return "/usr/lib/x86_64-linux-gnu";
else
return "/usr/lib";
end if;
end get_system_lib_level_2;
systemdir_1 : constant String := get_system_lib_level_1;
systemdir_2 : constant String := get_system_lib_level_2;
systemlib_1 : constant String := systemdir_1 & "/" & library;
systemlib_2 : constant String := systemdir_2 & "/" & library;
syslib_1txt : HT.Text := HT.SUS (systemlib_1);
syslib_2txt : HT.Text := HT.SUS (systemlib_2);
procedure squawk is
begin
TIO.Put_Line (trackers (id).log_handle,
errmsg_prefix & library & " is not in located in " & systemdir_1 &
", " & systemdir_2 & " or within the RPATH/RUNPATH (" & paths & ")");
end squawk;
begin
-- Check system library paths first
if trackers (id).goodpaths.Contains (syslib_1txt) or else
trackers (id).goodpaths.Contains (syslib_2txt)
then
return;
end if;
if not trackers (id).checkpaths.Contains (syslib_1txt) then
if DIR.Exists (root & systemlib_1) then
trackers (id).goodpaths.Append (syslib_1txt);
return;
end if;
trackers (id).checkpaths.Append (syslib_1txt);
attempted := True;
end if;
if not trackers (id).checkpaths.Contains (syslib_2txt) then
if DIR.Exists (root & systemlib_2) then
trackers (id).goodpaths.Append (syslib_2txt);
return;
end if;
trackers (id).checkpaths.Append (syslib_2txt);
attempted := True;
end if;
if HT.IsBlank (paths) then
squawk;
result := fail_result;
return;
end if;
for n in 1 .. numfields loop
declare
testpath : String := HT.specific_field (paths, n, ":");
test_library : String := testpath & "/" & library;
test_lib_txt : HT.Text := HT.SUS (test_library);
begin
if trackers (id).goodpaths.Contains (test_lib_txt) then
return;
end if;
if not trackers (id).checkpaths.Contains (test_lib_txt) then
if DIR.Exists (root & test_library) then
trackers (id).goodpaths.Append (test_lib_txt);
return;
end if;
trackers (id).checkpaths.Append (test_lib_txt);
attempted := True;
end if;
end;
end loop;
if attempted then
squawk;
result := fail_result;
end if;
end scan;
begin
trackers (id).runpaths.Iterate (scan'Access);
return result;
end passed_runpath_check;
--------------------------------------------------------------------------------------------
-- timeout_multiplier_x10
--------------------------------------------------------------------------------------------
function timeout_multiplier_x10 return Positive
is
average5 : constant Float := load_core (instant_load => False);
avefloat : constant Float := average5 / Float (PM.configuration.number_cores);
begin
if avefloat <= 1.0 then
return 10;
else
return Integer (avefloat * 10.0);
end if;
exception
when others => return 10;
end timeout_multiplier_x10;
--------------------------------------------------------------------------------------------
-- load_core
--------------------------------------------------------------------------------------------
function load_core (instant_load : Boolean) return Float
is
function probe_load return String;
----------------- 123456789-123456789-123456789-
-- DFLY/FreeBSD: vm.loadavg: { 0.00 0.00 0.00 }
-- NetBSD: vm.loadavg: 0.00 0.00 0.00
-- Darwin: vm.loadavg: { 1.21 1.07 1.15 }
-- Linux: 0.00 0.01 0.05 3/382 15409
-- Solaris: [~42 chars]load average: 0.01, 0.01, 0.01
zero : constant Float := 0.0;
lo : Integer;
function probe_load return String
is
bsd : constant String := "/usr/bin/env LANG=C /sbin/sysctl vm.loadavg";
mac : constant String := "/usr/bin/env LANG=C /usr/sbin/sysctl vm.loadavg";
lin : constant String := "/bin/cat /proc/loadavg";
sol : constant String := "/usr/bin/uptime";
begin
case platform_type is
when dragonfly | freebsd =>
lo := 14;
return generic_system_command (bsd);
when macos =>
lo := 14;
return generic_system_command (mac);
when netbsd | openbsd =>
lo := 12;
return generic_system_command (bsd);
when linux =>
lo := 0;
return generic_system_command (lin);
when sunos =>
return generic_system_command (sol);
end case;
exception
when others =>
case platform_type is
when dragonfly | freebsd | macos => return "vm.loadavg: { 0.00 0.00 0.00 }";
when netbsd | openbsd => return "vm.loadavg: 0.00 0.00 0.00";
when linux => return "0.00 0.00 0.00";
when sunos => return "load average: 0.00, 0.00, 0.00";
end case;
end probe_load;
comres : constant String := probe_load;
begin
case platform_type is
when dragonfly | freebsd | netbsd | openbsd | linux | macos =>
declare
stripped : constant String := comres (comres'First + lo .. comres'Last);
begin
if instant_load then
return Float'Value (HT.specific_field (stripped, 1, " "));
else
return Float'Value (HT.specific_field (stripped, 2, " "));
end if;
end;
when sunos =>
declare
stripped : constant String := HT.part_2 (comres, "load average: ");
begin
if instant_load then
return Float'Value (HT.specific_field (stripped, 1, ", "));
else
return Float'Value (HT.specific_field (stripped, 2, ", "));
end if;
end;
end case;
exception
when others => return zero;
end load_core;
--------------------------------------------------------------------------------------------
-- builder_status
--------------------------------------------------------------------------------------------
function builder_status (id : builders;
shutdown : Boolean := False;
idle : Boolean := False)
return Display.builder_rec
is
phasestr : constant String := phase2str (phase_trackers (id));
result : Display.builder_rec;
orilimit : constant Positive := Display.fld_origin'Length;
orishort : constant Natural := orilimit - 1;
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 := HT.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
catport : constant String := get_port_variant (all_ports (trackers (id).seq_id));
numlines : constant String := format_loglines (trackers (id).loglines);
linehead : constant Natural := 8 - numlines'Length;
begin
result.Elapsed := LOG.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 > orilimit then
result.origin (1 .. orishort) := catport (catport'First .. catport'First + orishort);
result.origin (orilimit) := LAT.Asterisk;
else
result.origin (1 .. catport'Length) := catport;
end if;
end;
return result;
end builder_status;
--------------------------------------------------------------------------------------------
-- format_loglines
--------------------------------------------------------------------------------------------
function format_loglines (numlines : Natural) return String
is
begin
if numlines < 10000000 then -- 10 million
return HT.int2str (numlines);
end if;
declare
kilo : constant Natural := numlines / 1000;
kilotxt : constant String := HT.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;
--------------------------------------------------------------------------------------------
-- mark_file_system
--------------------------------------------------------------------------------------------
procedure mark_file_system (id : builders; action : String; environ : String)
is
function attributes (action : String) return String;
root : constant String := get_root (id);
mtfile : constant String := "/etc/mtree." & action & ".exclude";
resfile : TIO.File_Type;
function attributes (action : String) return String
is
core : constant String := "uid,gid,mode,sha1digest";
begin
if action = "preconfig" then
return core & ",time";
else
return core;
end if;
end attributes;
command : constant String := PM.chroot_cmd & root & environ &
" /usr/bin/mtree -X " & mtfile & " -cn -k " & attributes (action) & " -p /";
filename : constant String := root & "/tmp/mtree." & action;
begin
TIO.Create (File => resfile, Mode => TIO.Out_File, Name => filename);
TIO.Put (resfile, generic_system_command (command));
TIO.Close (resfile);
exception
when others =>
if TIO.Is_Open (resfile) then
TIO.Close (resfile);
end if;
end mark_file_system;
--------------------------------------------------------------------------------------------
-- interact_with_builder
--------------------------------------------------------------------------------------------
procedure interact_with_builder (id : builders; ssl_variant : String)
is
function shell return String;
root : constant String := get_root (id);
result : Boolean;
function shell return String is
begin
case platform_type is
when linux | sunos =>
return "/bin/bash";
when others =>
return "/bin/sh";
end case;
end shell;
command : String := PM.chroot_cmd & root &
environment_override (True, ssl_variant, True) & shell;
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;
--------------------------------------------------------------------------------------------
-- detect_leftovers_and_MIA
--------------------------------------------------------------------------------------------
function detect_leftovers_and_MIA
(id : builders;
action : String;
description : String;
environ : String) return Boolean
is
package crate is new CON.Vectors (Index_Type => Positive,
Element_Type => HT.Text,
"=" => HT.SU."=");
package local_sorter is new crate.Generic_Sorting ("<" => HT.SU."<");
function ignore_modifications return Boolean;
procedure print (cursor : crate.Cursor);
procedure close_active_modifications;
root : constant String := get_root (id);
mtfile : constant String := "/etc/mtree." & action & ".exclude";
filename : constant String := root & "/tmp/mtree." & action;
command : constant String := PM.chroot_cmd & root & environ &
"/usr/bin/mtree -X " & mtfile & " -f " & filename & " -p /";
lbasewrk : constant String := HT.USS (PM.configuration.dir_localbase);
lbase : constant String := lbasewrk (lbasewrk'First + 1 .. lbasewrk'Last);
lblen : constant Natural := lbase'Length;
status : Integer;
skiprest : Boolean;
passed : Boolean := True;
activemod : Boolean := False;
modport : HT.Text := HT.blank;
reasons : HT.Text := HT.blank;
leftover : crate.Vector;
missing : crate.Vector;
changed : crate.Vector;
markers : HT.Line_Markers;
-- we can't use generic_system_command because exit code /= 0 normally
comres : String := HT.USS (Unix.piped_command (command, status));
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 := HT.USS (modport);
fnlen : constant Natural := filename'Last;
begin
if filename = lbase & "/share/xml/catalog.ports" or else
filename = lbase & "/share/octave/octave_packages" or else
filename = lbase & "/share/info/dir" or else
filename = lbase & "/lib/gio/modules/giomodule.cache" or else
filename = lbase & "/share/pear/.depdb" or else
filename = lbase & "/share/pear/.filemap"
then
return True;
end if;
if filename = "." and then HT.equivalent (reasons, "modification") then
return True;
end if;
if fnlen > lblen + 7 and then
filename (1 .. lblen + 1) = lbase & "/"
then
if filename (fnlen - 4 .. fnlen) = "/ls-R" or else
filename (fnlen - 14 .. fnlen) = "/share/info/dir"
then
return True;
end if;
end if;
if fnlen > 47 + lblen and then
filename (1 .. 30 + lblen) = lbase & "/etc/gconf/gconf.xml.defaults/" and then
filename (fnlen - 3 .. fnlen) = ".xml"
then
if HT.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
HT.SU.Append (modport, " [ ");
HT.SU.Append (modport, reasons);
HT.SU.Append (modport, " ]");
if not changed.Contains (modport) then
changed.Append (modport);
end if;
end if;
activemod := False;
reasons := HT.blank;
modport := HT.blank;
end close_active_modifications;
procedure print (cursor : crate.Cursor)
is
dossier : constant String := HT.USS (crate.Element (cursor));
begin
TIO.Put_Line (trackers (id).log_handle, LAT.HT & dossier);
end print;
begin
HT.initialize_markers (comres, markers);
loop
skiprest := False;
exit when not HT.next_line_present (comres, markers);
declare
line : constant String := HT.extract_line (comres, markers);
linelen : constant Natural := line'Length;
begin
if not skiprest and then linelen > 6 then
declare
caboose : constant String := line (line'Last - 5 .. line'Last);
filename : HT.Text := HT.SUS (line (line'First .. line'Last - 6));
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 linelen > 7 then
declare
canopy : constant String := line (line'First .. line'First + 6);
filename : HT.Text := HT.SUS (line (line'First + 7 .. line'Last));
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 linelen > 10 then
declare
caboose : constant String := line (line'Last - 7 .. line'Last);
filename : HT.Text := HT.SUS (line (line'First + 2 .. line'Last - 8));
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
blank8 : constant String := " ";
begin
if linelen > 5 and then line (line'First) = LAT.HT then
-- reason, but only valid if modification is active
if activemod then
if not HT.IsBlank (reasons) then
HT.SU.Append (reasons, " | ");
end if;
HT.SU.Append
(reasons, HT.part_1 (line (line'First + 1 .. line'Last), " "));
end if;
skiprest := True;
end if;
if not skiprest and then line (line'Last) = LAT.Colon then
close_active_modifications;
activemod := True;
modport := HT.SUS (line (line'First .. line'Last - 1));
skiprest := True;
end if;
if not skiprest and then
line (line'Last - 7 .. line'Last) = " changed"
then
close_active_modifications;
activemod := True;
modport := HT.SUS (line (line'First .. line'Last - 8));
skiprest := True;
end if;
end;
end if;
end;
end loop;
close_active_modifications;
local_sorter.Sort (Container => changed);
local_sorter.Sort (Container => missing);
local_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;
--------------------------------------------------------------------------------------------
-- 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 and then not trackers (id).disable_dog;
truecommand : constant String := ravenexec & " " &
LOG.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;
--------------------------------------------------------------------------------------------
-- watchdog_message
--------------------------------------------------------------------------------------------
function watchdog_message (minutes : execution_limit) return String is
begin
return "### Watchdog killed runaway process! (no activity for" &
minutes'Img & " minutes) ###";
end watchdog_message;
--------------------------------------------------------------------------------------------
-- assemble_history_record
--------------------------------------------------------------------------------------------
function assemble_history_record (slave : builders;
pid : port_id;
action : Display.history_action) return Display.history_rec
is
HR : Display.history_rec;
HOLast : constant Natural := Display.history_origin'Last;
catport : String := get_port_variant (pid);
hyphens : constant Display.history_elapsed := "--:--:--";
begin
HR.id := slave;
HR.slavid := HT.zeropad (Integer (slave), 2);
HR.established := True;
HR.action := action;
HR.origin := (others => ' ');
HR.run_elapsed := LOG.elapsed_now;
if action = Display.action_shutdown then
HR.pkg_elapsed := hyphens;
else
if action = Display.action_skipped or else
action = Display.action_ignored
then
HR.pkg_elapsed := hyphens;
else
HR.pkg_elapsed := LOG.elapsed_HH_MM_SS (start => trackers (slave).head_time,
stop => trackers (slave).tail_time);
end if;
if catport'Last > HOLast then
HR.origin (1 .. HOLast - 1) := catport (1 .. HOLast - 1);
HR.origin (HOLast) := LAT.Asterisk;
else
HR.origin (1 .. catport'Last) := catport;
end if;
end if;
return HR;
end assemble_history_record;
--------------------------------------------------------------------------------------------
-- set_log_lines
--------------------------------------------------------------------------------------------
procedure set_log_lines (id : builders)
is
log_path : constant String := LOG.log_name (trackers (id).seq_id);
command : constant String := HT.USS (PM.configuration.dir_sysroot) &
"/usr/bin/wc -l " & log_path;
begin
declare
numtext : constant String :=
HT.part_1 (S => HT.trim (generic_system_command (command)), separator => " ");
begin
trackers (id).loglines := Natural'Value (numtext);
end;
exception
when others => null; -- just skip this cycle
end set_log_lines;
--------------------------------------------------------------------------------------------
-- elapsed_build
--------------------------------------------------------------------------------------------
function elapsed_build (id : builders) return String is
begin
return LOG.elapsed_HH_MM_SS (start => trackers (id).head_time,
stop => trackers (id).tail_time);
end elapsed_build;
--------------------------------------------------------------------------------------------
-- run_makesum
--------------------------------------------------------------------------------------------
procedure run_makesum (id : builders; ssl_variant : String)
is
root : constant String := get_root (id);
distinfo : constant String := root & "/port/distinfo";
locfile : constant String := "distinfo";
environ : constant String := environment_override (False, ssl_variant);
command : constant String := PM.chroot_cmd & root & environ &
chroot_make_program & " -C /port makesum";
content : HT.Text;
status : Integer;
use type DIR.File_Size, DIR.File_Kind;
begin
content := Unix.piped_command (command, status);
if status = 0 then
if DIR.Exists (distinfo) then
if not HT.IsBlank (content) then
TIO.Put_Line (HT.USS (content));
end if;
if DIR.Size (distinfo) = DIR.File_Size (0) then
-- The generated distinfo file is empty
-- Not only do we not copy it over, let's erase the port's distinfo
-- file if it exists
if DIR.Exists (locfile) and then
DIR.Kind (locfile) = DIR.Ordinary_File
then
DIR.Delete_File (locfile);
end if;
else
TIO.Put_Line ("Copying " & distinfo & " to current directory");
DIR.Copy_File (distinfo, locfile);
end if;
else
TIO.Put_Line ("####### failure, distinfo not found #######");
end if;
else
TIO.Put_Line ("####### MAKESUM COMMAND FAILED #######");
TIO.Put_Line ("hint 1: Check SITES array contents are valid and accessible");
TIO.Put_Line ("hint 2: Check that all distfile names are correct.");
end if;
end run_makesum;
--------------------------------------------------------------------------------------------
-- run_patch_regen
--------------------------------------------------------------------------------------------
procedure run_patch_regen (id : builders; sourceloc : String; ssl_variant : String)
is
function get_wrksrc return String;
function get_strip_component return String;
procedure copy_files (subdir : String; pattern : String);
root : constant String := get_root (id);
environ : constant String := environment_override (False, ssl_variant);
premake : constant String := PM.chroot_cmd & root & environ &
chroot_make_program & " -C /port ";
cextract : constant String := premake & "extract";
cpatch : constant String := premake & "do-patch";
function get_wrksrc return String
is
command : constant String := premake & " -V WRKSRC";
result : constant String := generic_system_command (command);
begin
return HT.first_line (result);
end get_wrksrc;
function get_strip_component return String
is
command : constant String := premake & " -V PATCH_STRIP:S/-p//";
result : constant String := generic_system_command (command);
begin
declare
raw : constant String := HT.first_line (result);
snumber : Integer;
begin
snumber := Integer'Value (raw);
return HT.int2str (snumber);
exception
when others =>
TIO.Put_Line ("Failed to convert '" & raw & "' to an integer; going with '0'");
return "0";
end;
end get_strip_component;
procedure copy_files (subdir : String; pattern : String)
is
shinydir : constant String := root & "/tmp/shiny";
begin
if sourceloc = "" then
FOP.replace_directory_contents (shinydir, subdir, pattern);
else
FOP.replace_directory_contents (shinydir, sourceloc & "/" & subdir, pattern);
end if;
end copy_files;
cregen : constant String := PM.chroot_cmd & root &
" /bin/sh /xports/Mk/Scripts/repatch.sh " & get_wrksrc & " " & get_strip_component;
begin
if DIR.Exists (root & "/port/patches") or else
DIR.Exists (root & "/port/opsys")
then
if Unix.external_command (cextract) then
if Unix.external_command (cpatch) then
if Unix.external_command (cregen) then
-- copy contents of /tmp/shiny to sourceloc/patches and sourceloc/files
copy_files ("patches", "patch-*");
copy_files ("dragonfly", "patch-*");
copy_files ("freebsd", "patch-*");
copy_files ("linux", "patch-*");
copy_files ("files", "extra-patch-*");
else
TIO.Put_Line ("patch regen: failed to regenerate patches");
end if;
else
TIO.Put_Line ("patch regen: failed to apply patches");
end if;
else
TIO.Put_Line ("patch regen: failed to extract distfile");
end if;
else
TIO.Put_Line ("This port has no patches to regenerated.");
end if;
end run_patch_regen;
--------------------------------------------------------------------------------------------
-- get_port_prefix
--------------------------------------------------------------------------------------------
function get_port_prefix (id : builders; environ : String) return String
is
root : constant String := get_root (id);
command : constant String := PM.chroot_cmd & root & environ &
chroot_make_program & " -C /port -V PREFIX";
result : constant String := generic_system_command (command);
begin
return HT.first_line (result);
end get_port_prefix;
end PortScan.Buildcycle;
|
reznikmm/matreshka | Ada | 4,209 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes;
with XML.DOM.Attributes.Internals;
package body ODF.DOM.Attributes.Text.Offset.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Attributes.Text.Offset.Text_Offset_Access)
return ODF.DOM.Attributes.Text.Offset.ODF_Text_Offset is
begin
return
(XML.DOM.Attributes.Internals.Create
(Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Attributes.Text.Offset.Text_Offset_Access)
return ODF.DOM.Attributes.Text.Offset.ODF_Text_Offset is
begin
return
(XML.DOM.Attributes.Internals.Wrap
(Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Attributes.Text.Offset.Internals;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 8,477 | ads | -- This spec has been automatically generated from STM32F411xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.EXTI is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- IMR_MR array element
subtype IMR_MR_Element is STM32_SVD.Bit;
-- IMR_MR array
type IMR_MR_Field_Array is array (0 .. 22) of IMR_MR_Element
with Component_Size => 1, Size => 23;
-- Type definition for IMR_MR
type IMR_MR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt23;
when True =>
-- MR as an array
Arr : IMR_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for IMR_MR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- Interrupt mask register (EXTI_IMR)
type IMR_Register is record
-- Interrupt Mask on line 0
MR : IMR_MR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IMR_Register use record
MR at 0 range 0 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- EMR_MR array element
subtype EMR_MR_Element is STM32_SVD.Bit;
-- EMR_MR array
type EMR_MR_Field_Array is array (0 .. 22) of EMR_MR_Element
with Component_Size => 1, Size => 23;
-- Type definition for EMR_MR
type EMR_MR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- MR as a value
Val : STM32_SVD.UInt23;
when True =>
-- MR as an array
Arr : EMR_MR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for EMR_MR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- Event mask register (EXTI_EMR)
type EMR_Register is record
-- Event Mask on line 0
MR : EMR_MR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EMR_Register use record
MR at 0 range 0 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- RTSR_TR array element
subtype RTSR_TR_Element is STM32_SVD.Bit;
-- RTSR_TR array
type RTSR_TR_Field_Array is array (0 .. 22) of RTSR_TR_Element
with Component_Size => 1, Size => 23;
-- Type definition for RTSR_TR
type RTSR_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt23;
when True =>
-- TR as an array
Arr : RTSR_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for RTSR_TR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- Rising Trigger selection register (EXTI_RTSR)
type RTSR_Register is record
-- Rising trigger event configuration of line 0
TR : RTSR_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTSR_Register use record
TR at 0 range 0 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- FTSR_TR array element
subtype FTSR_TR_Element is STM32_SVD.Bit;
-- FTSR_TR array
type FTSR_TR_Field_Array is array (0 .. 22) of FTSR_TR_Element
with Component_Size => 1, Size => 23;
-- Type definition for FTSR_TR
type FTSR_TR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TR as a value
Val : STM32_SVD.UInt23;
when True =>
-- TR as an array
Arr : FTSR_TR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for FTSR_TR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- Falling Trigger selection register (EXTI_FTSR)
type FTSR_Register is record
-- Falling trigger event configuration of line 0
TR : FTSR_TR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FTSR_Register use record
TR at 0 range 0 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- SWIER array element
subtype SWIER_Element is STM32_SVD.Bit;
-- SWIER array
type SWIER_Field_Array is array (0 .. 22) of SWIER_Element
with Component_Size => 1, Size => 23;
-- Type definition for SWIER
type SWIER_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWIER as a value
Val : STM32_SVD.UInt23;
when True =>
-- SWIER as an array
Arr : SWIER_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for SWIER_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- Software interrupt event register (EXTI_SWIER)
type SWIER_Register is record
-- Software Interrupt on line 0
SWIER : SWIER_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SWIER_Register use record
SWIER at 0 range 0 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- PR array element
subtype PR_Element is STM32_SVD.Bit;
-- PR array
type PR_Field_Array is array (0 .. 22) of PR_Element
with Component_Size => 1, Size => 23;
-- Type definition for PR
type PR_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PR as a value
Val : STM32_SVD.UInt23;
when True =>
-- PR as an array
Arr : PR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 23;
for PR_Field use record
Val at 0 range 0 .. 22;
Arr at 0 range 0 .. 22;
end record;
-- Pending register (EXTI_PR)
type PR_Register is record
-- Pending bit 0
PR : PR_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PR_Register use record
PR at 0 range 0 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- External interrupt/event controller
type EXTI_Peripheral is record
-- Interrupt mask register (EXTI_IMR)
IMR : aliased IMR_Register;
-- Event mask register (EXTI_EMR)
EMR : aliased EMR_Register;
-- Rising Trigger selection register (EXTI_RTSR)
RTSR : aliased RTSR_Register;
-- Falling Trigger selection register (EXTI_FTSR)
FTSR : aliased FTSR_Register;
-- Software interrupt event register (EXTI_SWIER)
SWIER : aliased SWIER_Register;
-- Pending register (EXTI_PR)
PR : aliased PR_Register;
end record
with Volatile;
for EXTI_Peripheral use record
IMR at 16#0# range 0 .. 31;
EMR at 16#4# range 0 .. 31;
RTSR at 16#8# range 0 .. 31;
FTSR at 16#C# range 0 .. 31;
SWIER at 16#10# range 0 .. 31;
PR at 16#14# range 0 .. 31;
end record;
-- External interrupt/event controller
EXTI_Periph : aliased EXTI_Peripheral
with Import, Address => System'To_Address (16#40013C00#);
end STM32_SVD.EXTI;
|
reznikmm/matreshka | Ada | 3,618 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.DG.Linear_Gradients.Hash is
new AMF.Elements.Generic_Hash (DG_Linear_Gradient, DG_Linear_Gradient_Access);
|
Pateldisolution/Ada-IntelliJ | Ada | 206 | adb | -- Single Delimiters
& ' ( ) * + , - . / : ; < = > |
-- Compound Delimiters
=> .. ** := /= >= <= << >> <>
-- Special cases
=>=
<=>
<<>
<<>>
<>>
character_literal('a')
apostrophe'delimiter
Character'('a')
|
stcarrez/mat | Ada | 5,103 | adb | -----------------------------------------------------------------------
-- mat-consoles-text - Text console interface
-- Copyright (C) 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Gtk.Enums;
with Gtk.Tree_View_Column;
with Util.Log.Loggers;
package body MAT.Consoles.Gtkmat is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("MAT.Consoles.Gtkmat");
-- ------------------------------
-- Initialize the console to display the result in the Gtk frame.
-- ------------------------------
procedure Initialize (Console : in out Console_Type;
Frame : in Gtk.Frame.Gtk_Frame) is
begin
Gtk.Scrolled_Window.Gtk_New (Console.Scrolled);
Gtk.Cell_Renderer_Text.Gtk_New (Console.Col_Text);
Console.Scrolled.Set_Policy (Gtk.Enums.Policy_Always, Gtk.Enums.Policy_Always);
Console.Frame := Frame;
Console.Frame.Add (Console.Scrolled);
Console.Col_Text.Ref;
-- Console.Frame.Show_All;
end Initialize;
-- Report a notice message.
overriding
procedure Notice (Console : in out Console_Type;
Kind : in Notice_Type;
Message : in String) is
begin
null;
end Notice;
-- Report an error message.
overriding
procedure Error (Console : in out Console_Type;
Message : in String) is
begin
null;
end Error;
-- Print the field value for the given field.
overriding
procedure Print_Field (Console : in out Console_Type;
Field : in Field_Type;
Value : in String;
Justify : in Justify_Type := J_LEFT) is
begin
Log.Debug ("Field {0} - {1}", Field_Type'Image (Field), Value);
Gtk.Tree_Store.Set (Console.List, Console.Current_Row, Console.Indexes (Field), Value);
end Print_Field;
-- Print the title for the given field.
overriding
procedure Print_Title (Console : in out Console_Type;
Field : in Field_Type;
Title : in String) is
Pos : constant Positive := Console.Field_Count;
begin
Console.Indexes (Field) := Glib.Gint (Pos - 1);
Console.Columns (Pos).Field := Field;
Console.Columns (Pos).Title := Ada.Strings.Unbounded.To_Unbounded_String (Title);
end Print_Title;
-- Start a new title in a report.
overriding
procedure Start_Title (Console : in out Console_Type) is
begin
Console.Field_Count := 0;
Console.Sizes := (others => 0);
Console.Cols := (others => 1);
Console.Indexes := (others => 0);
end Start_Title;
-- Finish a new title in a report.
procedure End_Title (Console : in out Console_Type) is
use type Glib.Guint;
use type Glib.Gint;
use type Gtk.Tree_View.Gtk_Tree_View;
use Gtk.Tree_Store;
Types : Glib.GType_Array (0 .. Glib.Guint (Console.Field_Count) - 1)
:= (others => Glib.GType_String);
Col : Gtk.Tree_View_Column.Gtk_Tree_View_Column;
Num : Glib.Gint;
begin
Gtk.Tree_Store.Gtk_New (Console.List, Types);
if Console.Tree /= null then
Console.Tree.Destroy;
end if;
Gtk.Tree_View.Gtk_New (Console.Tree, +Console.List);
-- Gtk.Tree_View.Gtk_New (Console.Tree);
for I in 1 .. Console.Field_Count loop
Gtk.Tree_View_Column.Gtk_New (Col);
Num := Console.Tree.Append_Column (Col);
Col.Set_Sort_Column_Id (Glib.Gint (I) - 1);
Col.Set_Title (Ada.Strings.Unbounded.To_String (Console.Columns (I).Title));
Col.Pack_Start (Console.Col_Text, True);
Col.Set_Sizing (Gtk.Tree_View_Column.Tree_View_Column_Autosize);
Col.Add_Attribute (Console.Col_Text, "text", Glib.Gint (I) - 1);
end loop;
-- Console.Tree.Set_Model (Gtk.Tree_Model.Gtk_Tree_Model (Console.List));
Console.Scrolled.Add (Console.Tree);
Console.Scrolled.Show_All;
end End_Title;
-- Start a new row in a report.
overriding
procedure Start_Row (Console : in out Console_Type) is
begin
Console.List.Append (Console.Current_Row, Gtk.Tree_Model.Null_Iter);
end Start_Row;
-- Finish a new row in a report.
overriding
procedure End_Row (Console : in out Console_Type) is
begin
null;
end End_Row;
end MAT.Consoles.Gtkmat;
|
reznikmm/matreshka | Ada | 3,989 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Fo_Page_Height_Attributes;
package Matreshka.ODF_Fo.Page_Height_Attributes is
type Fo_Page_Height_Attribute_Node is
new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node
and ODF.DOM.Fo_Page_Height_Attributes.ODF_Fo_Page_Height_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Fo_Page_Height_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Fo_Page_Height_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Fo.Page_Height_Attributes;
|
twdroeger/ada-awa | Ada | 3,614 | adb | -----------------------------------------------------------------------
-- awa-mail-clients-tests -- Unit tests for Mail clients
-- Copyright (C) 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Test_Caller;
with Util.Properties;
package body AWA.Mail.Clients.Tests is
procedure Free is
new Ada.Unchecked_Deallocation (Object => AWA.Mail.Clients.Mail_Manager'Class,
Name => AWA.Mail.Clients.Mail_Manager_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Object => AWA.Mail.Clients.Mail_Message'Class,
Name => AWA.Mail.Clients.Mail_Message_Access);
package Caller is new Util.Test_Caller (Test, "Mail.Clients");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test AWA.Mail.Clients.Factory",
Test_Factory'Access);
Caller.Add_Test (Suite, "Test AWA.Mail.Clients.Create_Message",
Test_Create_Message'Access);
end Add_Tests;
-- ------------------------------
-- Test the mail manager factory.
-- ------------------------------
procedure Test_Factory (T : in out Test) is
M : AWA.Mail.Clients.Mail_Manager_Access;
P : Util.Properties.Manager;
begin
M := AWA.Mail.Clients.Factory ("file", P);
T.Assert (M /= null, "Factory returned a null mail manager");
Free (M);
M := AWA.Mail.Clients.Factory ("something", P);
T.Assert (M = null, "Factory returned a non null mail manager");
end Test_Factory;
-- ------------------------------
-- Create an email message and verify its content.
-- ------------------------------
procedure Test_Create_Message (T : in out Test) is
procedure Send;
M : AWA.Mail.Clients.Mail_Manager_Access;
procedure Send is
Msg : AWA.Mail.Clients.Mail_Message_Access := M.Create_Message;
begin
Msg.Set_From (Name => "Iorek Byrnison", Address => "[email protected]");
Msg.Add_Recipient (Kind => TO, Name => "Tous les ours", Address => "[email protected]");
Msg.Set_Subject (Subject => "Decret");
Msg.Set_Body (Content => "Le palais doit etre debarasse des fantaisies humaines.");
Msg.Send;
Free (Msg);
end Send;
begin
M := AWA.Mail.Clients.Factory ("file", Util.Tests.Get_Properties);
T.Assert (M /= null, "Factory returned a null mail manager");
for I in 1 .. 10 loop
Send;
end loop;
Free (M);
-- The SMTP mailer could be disabled from the configuration.
M := AWA.Mail.Clients.Factory ("smtp", Util.Tests.Get_Properties);
if M /= null then
for I in 1 .. 10 loop
Send;
end loop;
Free (M);
end if;
end Test_Create_Message;
end AWA.Mail.Clients.Tests;
|
tum-ei-rcs/StratoX | Ada | 166 | adb | with p2; use p2;
procedure main with SPARK_Mode is
begin
-- trying to reprouce the problem StratoX has in hil.ads, but doesn't show up here
p2.foo;
end main;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.