id
int64 0
30.9k
| extension
stringclasses 1
value | max_stars_count
int64 0
17k
| max_stars_repo_name
stringlengths 7
106
| max_stars_repo_path
stringlengths 5
136
| text
stringlengths 9
1M
|
|---|---|---|---|---|---|
29,800
|
ada
| 1
|
danva994/ASFML-1.6
|
include/sf-system-randomizer.ads
|
-- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 <NAME> (<EMAIL>)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
-- // Headers
-- ////////////////////////////////////////////////////////////
with Sf.Config;
package Sf.System.Randomizer is
use Sf.Config;
-- ////////////////////////////////////////////////////////////
-- /// Set the seed for the random numbers generator. Using a known seed
-- /// allows you to reproduce the same sequence of random numbers
-- ///
-- /// \param Seed : Number to use as the seed
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfRandom_SetSeed (Seed : sfUint32);
-- ////////////////////////////////////////////////////////////
-- /// Get the seed used to generate random numbers the generator
-- ///
-- /// \return Current seed
-- ///
-- ////////////////////////////////////////////////////////////
function sfRandom_GetSeed return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get a random float number in a given range
-- ///
-- /// \param B : Start of the range
-- /// \param E : End of the range
-- ///
-- /// \return Random number in [B, E]
-- ///
-- ////////////////////////////////////////////////////////////
function sfRandom_Float (B, E : Float) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get a random integer number in a given range
-- ///
-- /// \param B : Start of the range
-- /// \param E : End of the range
-- ///
-- /// \return Random number in [Begin, End]
-- ///
-- ////////////////////////////////////////////////////////////
function sfRandom_Int (B, E : Integer) return Integer;
private
pragma Import (C, sfRandom_SetSeed, "sfRandom_SetSeed");
pragma Import (C, sfRandom_GetSeed, "sfRandom_GetSeed");
pragma Import (C, sfRandom_Float, "sfRandom_Float");
pragma Import (C, sfRandom_Int, "sfRandom_Int");
end Sf.System.Randomizer;
|
29,801
|
ada
| 81
|
fuzzysloth/ada-awa
|
awa/src/awa-events-queues-fifos.adb
|
<filename>awa/src/awa-events-queues-fifos.adb<gh_stars>10-100
-----------------------------------------------------------------------
-- awa-events-queues-fifos -- Fifo event queues (memory based)
-- Copyright (C) 2012 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Log.Loggers;
package body AWA.Events.Queues.Fifos is
use Util.Log;
Log : constant Loggers.Logger := Loggers.Create ("AWA.Events.Queues.Fifos");
procedure Free is
new Ada.Unchecked_Deallocation (Object => AWA.Events.Module_Event'Class,
Name => AWA.Events.Module_Event_Access);
-- ------------------------------
-- Get the queue name.
-- ------------------------------
overriding
function Get_Name (From : in Fifo_Queue) return String is
begin
return From.Name;
end Get_Name;
-- ------------------------------
-- Get the model queue reference object.
-- Returns a null object if the queue is not persistent.
-- ------------------------------
overriding
function Get_Queue (From : in Fifo_Queue) return AWA.Events.Models.Queue_Ref is
pragma Unreferenced (From);
begin
return AWA.Events.Models.Null_Queue;
end Get_Queue;
-- ------------------------------
-- Queue the event.
-- ------------------------------
procedure Enqueue (Into : in out Fifo_Queue;
Event : in AWA.Events.Module_Event'Class) is
E : constant Module_Event_Access := Copy (Event);
begin
Log.Debug ("Enqueue event on queue {0}", Into.Name);
E.Set_Event_Kind (Event.Get_Event_Kind);
Into.Fifo.Enqueue (E);
end Enqueue;
-- ------------------------------
-- Dequeue an event and process it with the <b>Process</b> procedure.
-- ------------------------------
procedure Dequeue (From : in out Fifo_Queue;
Process : access procedure (Event : in Module_Event'Class)) is
E : Module_Event_Access;
begin
Log.Debug ("Dequeue event queue {0}", From.Name);
From.Fifo.Dequeue (E, 0.0);
begin
Process (E.all);
exception
when E : others =>
Log.Error ("Exception when processing event", E);
end;
Free (E);
exception
when Fifo_Protected_Queue.Timeout =>
null;
end Dequeue;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in Fifo_Queue;
Name : in String) return Util.Beans.Objects.Object is
pragma Unreferenced (From, Name);
begin
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
-- ------------------------------
overriding
procedure Set_Value (From : in out Fifo_Queue;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "size" then
From.Fifo.Set_Size (Util.Beans.Objects.To_Integer (Value));
end if;
end Set_Value;
-- ------------------------------
-- Release the queue storage.
-- ------------------------------
overriding
procedure Finalize (From : in out Fifo_Queue) is
begin
while From.Fifo.Get_Count > 0 loop
declare
E : Module_Event_Access;
begin
From.Fifo.Dequeue (E);
Free (E);
end;
end loop;
end Finalize;
-- ------------------------------
-- Create the queue associated with the given name and configure it by using
-- the configuration properties.
-- ------------------------------
function Create_Queue (Name : in String;
Props : in EL.Beans.Param_Vectors.Vector;
Context : in EL.Contexts.ELContext'Class) return Queue_Access is
Result : constant Fifo_Queue_Access := new Fifo_Queue '(Name_Length => Name'Length,
Name => Name,
others => <>);
begin
EL.Beans.Initialize (Result.all, Props, Context);
return Result.all'Access;
end Create_Queue;
end AWA.Events.Queues.Fifos;
|
29,802
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/nested_proc1.adb
|
-- { dg-do run }
-- Test that a static link is correctly passed to a subprogram which is
-- indirectly called through an aggregate.
procedure Nested_Proc1 is
I : Integer := 0;
procedure P1 (X : Integer) is
begin
I := X;
end;
type Func_Ptr is access procedure (X : Integer);
type Arr is array (1..64) of Integer;
type Rec is record
F : Func_Ptr;
A : Arr;
end record;
procedure P2 (R : Rec) is
begin
R.F (1);
end;
begin
P2 ((F => P1'Access, A => (others => 0)));
if I /= 1 then
raise Program_Error;
end if;
end;
|
29,803
|
ada
| 1
|
vidkidz/crossbridge
|
llvm-gcc-4.2-2.9/gcc/ada/s-trafor-default.adb
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T R A C E S . F O R M A T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2005 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 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Parameters;
package body System.Traces.Format is
procedure Send_Trace (Id : Trace_T; Info : String) is separate;
------------------
-- Format_Trace --
------------------
function Format_Trace (Source : in String) return String_Trace is
Length : Integer := Source'Length;
Result : String_Trace := (others => ' ');
begin
-- If run-time tracing active, then fill the string
if Parameters.Runtime_Traces then
if Max_Size - Length > 0 then
Result (1 .. Length) := Source (1 .. Length);
Result (Length + 1 .. Max_Size) := (others => ' ');
Result (Length + 1) := ASCII.NUL;
else
Result (1 .. Max_Size - 1) := Source (1 .. Max_Size - 1);
Result (Max_Size) := ASCII.NUL;
end if;
end if;
return Result;
end Format_Trace;
------------
-- Append --
------------
function Append
(Source : String_Trace;
Annex : String)
return String_Trace
is
Result : String_Trace := (others => ' ');
Source_Length : Integer := 1;
Annex_Length : Integer := Annex'Length;
begin
if Parameters.Runtime_Traces then
-- First we determine the size used, without the spaces at the
-- end, if a String_Trace is present. Look at
-- System.Traces.Tasking for examples.
while Source (Source_Length) /= ASCII.NUL loop
Source_Length := Source_Length + 1;
end loop;
-- Then we fill the string.
if Source_Length - 1 + Annex_Length <= Max_Size then
Result (1 .. Source_Length - 1) :=
Source (1 .. Source_Length - 1);
Result (Source_Length .. Source_Length - 1 + Annex_Length) :=
Annex (1 .. Annex_Length);
Result (Source_Length + Annex_Length) := ASCII.NUL;
Result (Source_Length + Annex_Length + 1 .. Max_Size) :=
(others => ' ');
else
Result (1 .. Source_Length - 1) := Source (1 .. Source_Length - 1);
Result (Source_Length .. Max_Size - 1) :=
Annex (1 .. Max_Size - Source_Length);
Result (Max_Size) := ASCII.NUL;
end if;
end if;
return Result;
end Append;
end System.Traces.Format;
|
29,804
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/array25_pkg.ads
|
<gh_stars>1-10
generic
UB1 : Natural;
UB2 : Natural;
package Array25_Pkg is
type Arr1 is array (1 .. UB1) of Integer;
type Rec is record
Data : Arr1;
end record;
type Arr2 is array (1 .. UB2) of Rec;
procedure Get (A : out Arr2);
end Array25_Pkg;
|
29,805
|
ada
| 192
|
rocher/Ada_Drivers_Library
|
examples/stm32_h405/lcd_test/src/lcd_test.adb
|
<gh_stars>100-1000
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with STM32.GPIO; use STM32.GPIO;
with STM32.SPI; use STM32.SPI;
with STM32.Device; use STM32.Device;
with STM32_H405; use STM32_H405;
with HAL.Bitmap; use HAL.Bitmap;
with HAL.SPI; use HAL.SPI;
with PCD8544; use PCD8544;
with Ravenscar_Time;
procedure LCD_Test is
procedure Configure_GPIO;
procedure Configure_SPI;
LCD_SPI : STM32.SPI.SPI_Port renames SPI_2;
LCD_CLK : GPIO_Point renames EXT2_16;
LCD_DIN : GPIO_Point renames EXT2_19;
LCD_RST : GPIO_Point renames EXT2_9;
LCD_CS : GPIO_Point renames EXT2_17;
LCD_DC : GPIO_Point renames EXT2_2;
procedure Configure_GPIO is
begin
Enable_Clock (LCD_DIN & LCD_CLK & LCD_RST & LCD_DC & LCD_CS);
Configure_IO (LCD_RST & LCD_DC & LCD_CS,
(Resistors => Pull_Up,
Mode => Mode_Out,
Output_Type => Push_Pull,
Speed => Speed_25MHz));
Configure_IO (LCD_DIN & LCD_CLK,
(Resistors => Pull_Up,
Mode => Mode_AF,
AF_Output_Type => Push_Pull,
AF_Speed => Speed_25MHz,
AF => GPIO_AF_SPI2_5));
end Configure_GPIO;
procedure Configure_SPI is
begin
Enable_Clock (LCD_SPI);
Configure (LCD_SPI,
(Direction => D2Lines_FullDuplex,
Mode => Master,
Data_Size => Data_Size_8b,
Clock_Polarity => High,
Clock_Phase => P2Edge,
Slave_Management => Software_Managed,
Baud_Rate_Prescaler => BRP_8,
First_Bit => MSB,
CRC_Poly => 0));
Enable (LCD_SPI);
end Configure_SPI;
Display : PCD8544_Device
(Port => LCD_SPI'Access,
RST => LCD_RST'Access,
CS => LCD_CS'Access,
DC => LCD_DC'Access,
Time => Ravenscar_Time.Delays);
Bitmap : Any_Bitmap_Buffer;
Cursor : Rect :=
(Position => (0, 0),
Width => 8,
Height => 8);
begin
Configure_GPIO;
Configure_SPI;
Display.Initialize;
Display.Initialize_Layer
(Layer => 1,
Mode => M_1,
X => 0,
Y => 0,
Width => Display.Width,
Height => Display.Height);
Bitmap := Display.Hidden_Buffer (1);
loop
for X in 0 .. ((Display.Width / Cursor.Width) - 1) loop
for Y in 0 .. ((Display.Height / Cursor.Height) - 1) loop
Bitmap.Set_Source (White);
Bitmap.Fill;
Cursor.Position := (X * Cursor.Width, Y * Cursor.Height);
Bitmap.Set_Source (Black);
Bitmap.Fill_Rect (Cursor);
Display.Update_Layers;
delay 0.250;
end loop;
end loop;
end loop;
end LCD_Test;
|
29,806
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/Prime-decomposition/Ada/prime-decomposition-1.ada
|
<filename>Task/Prime-decomposition/Ada/prime-decomposition-1.ada
generic
type Number is private;
Zero : Number;
One : Number;
Two : Number;
with function "+" (X, Y : Number) return Number is <>;
with function "*" (X, Y : Number) return Number is <>;
with function "/" (X, Y : Number) return Number is <>;
with function "mod" (X, Y : Number) return Number is <>;
with function ">" (X, Y : Number) return Boolean is <>;
package Prime_Numbers is
type Number_List is array (Positive range <>) of Number;
function Decompose (N : Number) return Number_List;
function Is_Prime (N : Number) return Boolean;
end Prime_Numbers;
|
29,807
|
ada
| 0
|
Brawdunoir/administrative-family-tree-manager
|
arbre_genealogique.adb
|
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO;
use Ada.Text_IO;
package body Arbre_Genealogique is
--package arbre2 is -- On instancie un arbre binaire
-- new Arbre_Binaire (T_Cle => Integer);
--use arbre2;
-- Afficher des entiers (pour les clés).
procedure Afficher_Entier (N : in Integer) is
begin
Put(N, width => 0);
end Afficher_Entier;
procedure Afficher_Arbre_Binaire is new arbre.Afficher_Arbre_Binaire (Afficher_Cle => Afficher_Entier);
procedure Afficher_Cle_Binaire is new arbre.Afficher_Cle_Binaire (Afficher_Cle => Afficher_Entier);
procedure Initialiser_Gen(Arbre: out T_Arbre_Gen; Reg : out T_Registre;
Nom : in unbounded_string;
Prenom : in unbounded_string;
Jour_N : in Integer;
Mois_N : in Integer;
Annee_N : in Integer;
Sexe : in Character) is
Donnee : T_Donnee;
Cle : Integer;
begin
Initialiser_Donnee(Donnee, Nom, Prenom, Jour_N, Mois_N, Annee_N, Sexe);
Creer_Cle (Reg, Cle, Donnee);
Initialiser (Arbre, Cle);
Initialiser_Reg (Reg, Cle, Donnee);
end Initialiser_Gen;
function Est_Vide_Gen (Arbre : in T_Arbre_Gen) return Boolean is
begin
return Est_Vide(Arbre);
end Est_Vide_Gen;
function Nombre_Ancetre (Arbre : in T_Arbre_Gen; Cle : in Integer) return Integer is
begin
return Nombre_Fils (Arbre, Cle);
end Nombre_Ancetre;
procedure Ajouter_Parent (Arbre : in out T_Arbre_Gen; Reg : in out T_Registre; Cle_Individu : in Integer;
Nom : in unbounded_string;
Prenom : in unbounded_string;
Jour_N : in Integer;
Mois_N : in Integer;
Annee_N : in Integer;
Sexe : in Character) is
Donnee : T_Donnee;
Cle_Parent : Integer;
begin
Initialiser_Donnee (Donnee, Nom, Prenom, Jour_N, Mois_N, Annee_N, Sexe);
Creer_Cle (Reg, Cle_Parent, Donnee);
if Sexe = 'F' then
Ajouter_Fils_Gauche (Arbre, Cle_Individu, Cle_Parent);
else
Ajouter_Fils_Droit (Arbre, Cle_Individu, Cle_Parent);
end if;
-- on l'insère dans le registre après, car si la clé ou le parent existe déjà, l'exception est propagée
-- et l'individu n'est pas ajouté au registre
Inserer (Reg, Cle_Parent, Donnee);
exception
when Cle_Presente_Exception_Bin => raise Cle_Presente_Exception_Gen;
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
when Emplacement_Reserve_Exception_Bin => raise Emplacement_Reserve_Exception_Gen;
end Ajouter_Parent;
procedure Supprimer (Arbre : in out T_Arbre_Gen; Reg : in out T_Registre; Individu : in Integer) is
begin
Supprimer(Arbre, Individu);
exception
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
end Supprimer;
procedure Vider (Arbre : in out T_Arbre_Gen; Reg : in out T_Registre) is
begin
Vider(Arbre);
Vider(Reg);
end Vider;
procedure Afficher_Ancetre_Generation_X (Arbre : in T_Arbre_Gen; X : in Integer; compteur : in out Integer) is
begin
if compteur > X then
Afficher_Cle_Genealogique(Arbre);
New_Line;
else
if not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then
compteur := compteur + 1;
Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))), X, compteur);
Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))), X, compteur);
elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then
compteur := compteur +1;
Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))), X, compteur);
elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then
compteur := compteur + 1;
Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))), X, compteur);
else
null;
end if;
end if;
end Afficher_Ancetre_Generation_X;
procedure Ancetre_Generation_X (Arbre : in T_Arbre_Gen; Individu : in Integer; Generation : in Integer) is
compteur : Integer;
Pointeur_Individu : T_Pointeur_Binaire;
begin
New_Line;
Put("Les ancêtres de "); Put(Individu, width => 0); Put(" de la génération "); Put(Generation, width => 0); Put( " sont : "); New_Line;
compteur := 1;
Rechercher_Position(T_Pointeur_Binaire(Arbre), Individu, Pointeur_Individu);
Afficher_Ancetre_Generation_X (T_Arbre_Gen(Pointeur_Individu), Generation, compteur);
exception
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
end Ancetre_Generation_X;
procedure Ancetres_Sur_N_Generations (Arbre : in T_Arbre_Gen; Individu : in Integer; N : in Integer) is
compteur : Integer;
Pointeur_Individu : T_Pointeur_Binaire;
begin
New_Line;
Put("Les ancêtres de "); Put(Individu, width => 0); Put(" sur "); Put(N, width => 0); Put( " génération(s) sont : "); New_Line;
Rechercher_Position(T_Pointeur_Binaire(Arbre), Individu, Pointeur_Individu);
-- On affiche chaque génération X à partir d'Individu
for i in 1..N loop
compteur := 1;
Put("Generation "); Put(i); Put(" :"); New_Line;
Afficher_Ancetre_Generation_X (T_Arbre_Gen(Pointeur_Individu), i, compteur);
end loop;
exception
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
end Ancetres_Sur_N_Generations;
procedure Afficher_Ancetres_Homonymes (P1 : in T_Arbre_Gen; P2 : in T_Arbre_Gen; Reg : in T_Registre) is
begin
-- Si P1 et P2 ne sont pas vides...
if not Est_Vide_Gen(P1) and not Est_Vide_Gen(P2) then
-- S'ils ont le même nom, on les affiche !
if Retourner_Nom(Reg, Retourner_Cle(P1)) = Retourner_Nom(Reg, Retourner_Cle(P2)) then
Put_Line (To_String(Retourner_Nom(Reg, Retourner_Cle(P1))));
else
null;
end if;
end if;
-- Si les deux sont vides, on a atteint la fin de l'arbre, on s'arrête
if Est_Vide_Gen(P1) and Est_Vide_Gen(P2) then
null;
-- Sinon on va chercher dans tous les ancêtres de P2, si un correspond au premier ancêtre de P1 jusqu'à ce qu'on ai regardé
-- tous les ancêtres de P2, et alors on passe aux deuxièmes ancêtres de P1 et on recommence
else
if not Est_Vide_Fils_Droit(T_Pointeur_Binaire(P2)) and not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P2)) then
Afficher_Ancetres_Homonymes (P1, T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P2))), Reg);
Afficher_Ancetres_Homonymes(P1, T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P2))), Reg);
elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P2)) then
Afficher_Ancetres_Homonymes(P1, T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P2))), Reg);
elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(P2)) then
Afficher_Ancetres_Homonymes(P1, T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P2))), Reg);
else -- On est arrivé à la fin de l'arbre généalogique de P2
if Est_Vide_Fils_Droit(T_Pointeur_Binaire(P1)) and Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P1)) then
null; -- On est arrivé à la fin de l'arbre de P1
elsif Est_Vide_Fils_Droit(T_Pointeur_Binaire(P1)) then -- On recommence en prenant que le fils gauche
Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P1))), P2, Reg);
elsif Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P1)) then -- Ou bien on recommence en prenant que le fils droit
Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P1))), P2, Reg);
else -- Ou bien on prend les deux !!
Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P1))), P2, Reg);
Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P1))), P2, Reg);
end if;
end if;
end if;
end Afficher_Ancetres_Homonymes;
procedure Ancetres_Homonymes (Arbre : in T_Arbre_Gen; Reg : in T_Registre; Individu1 : in Integer; Individu2 : in Integer) is
Pointeur_Individu1 : T_Pointeur_Binaire;
Pointeur_Individu2 : T_Pointeur_Binaire;
begin
Rechercher_Position (T_Pointeur_Binaire(Arbre), Individu1, Pointeur_Individu1);
Rechercher_Position (T_Pointeur_Binaire(Arbre), Individu2, Pointeur_Individu2);
Afficher_Ancetres_Homonymes (T_Arbre_Gen(Pointeur_Individu1), T_Arbre_Gen(Pointeur_Individu2), Reg);
exception
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
end Ancetres_Homonymes;
procedure Afficher_Orphelins (Arbre : in T_Arbre_Gen) is
begin
if not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then
Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))));
Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))));
elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then
Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))));
elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then
Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))));
else
Afficher_Cle_Genealogique(Arbre); New_Line;
end if;
exception
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
end Afficher_Orphelins;
procedure Afficher_Monoparental (Arbre : in T_Arbre_Gen) is
begin
if not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then
Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))));
Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))));
elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then
Afficher_Cle_Genealogique(Arbre); New_Line;
Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))));
elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then
Afficher_Cle_Genealogique(Arbre); New_Line;
Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))));
else
null;
end if;
exception
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
end Afficher_Monoparental;
procedure Afficher_Biparental (Arbre : in T_Arbre_Gen) is
begin
if not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then
Afficher_Cle_Genealogique(Arbre); New_Line;
Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))));
Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))));
elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then
Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))));
elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then
Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))));
else
null;
end if;
exception
when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen;
end Afficher_Biparental;
procedure Afficher_Arbre_Genealogique (Arbre : in T_Arbre_Gen) is
begin
Afficher_Arbre_Binaire(T_Pointeur_Binaire(Arbre));
end Afficher_Arbre_Genealogique;
procedure Afficher_Cle_Genealogique (Arbre : in T_Arbre_Gen) is
begin
Afficher_Cle_Binaire(T_Pointeur_Binaire(Arbre));
end Afficher_Cle_Genealogique;
end Arbre_Genealogique;
|
29,808
|
ada
| 1
|
ytomino/vampire
|
source/tabula-villages.adb
|
<reponame>ytomino/vampire
-- The Village of Vampire by YT, このソースコードはNYSLです
package body Tabula.Villages is
use type Ada.Strings.Unbounded.Unbounded_String;
use type Casts.Person_Sex;
function Same_Id_And_Figure (Left, Right : Person_Type'Class) return Boolean is
begin
return Left.Id = Right.Id and then Left.Image = Right.Image;
end Same_Id_And_Figure;
function Option_Changed (Village : Village_Type) return Boolean is
Result : Boolean := False;
procedure Process (Item : in Root_Option_Item'Class) is
begin
if Item.Available and then Item.Changed then
Result := True;
end if;
end Process;
begin
Iterate_Options (Village_Type'Class (Village), Process'Access);
-- dyamic dispatch
return Result;
end Option_Changed;
function Joined (Village : Village_Type; User_Id : String)
return Person_Index'Base
is
Result : Person_Index'Base := No_Person;
procedure Process (Index : in Person_Index; Item : in Person_Type'Class) is
begin
if Item.Id = User_Id then
Result := Index;
end if;
end Process;
begin
Iterate_People (Village_Type'Class (Village), Process'Access);
return Result;
end Joined;
function Already_Joined_As_Another_Sex (
Village : Village_Type;
User_Id : String;
Sex : Casts.Person_Sex)
return Boolean
is
Result : Boolean := False;
procedure Process (Index : in Person_Index; Item : in Person_Type'Class) is
begin
if Item.Id = User_Id and then Item.Sex /= Sex then
Result := True;
end if;
end Process;
begin
Iterate_Escaped_People (Village_Type'Class (Village), Process'Access);
return Result;
end Already_Joined_As_Another_Sex;
function Male_And_Female (Village : Village_Type) return Boolean is
Existing : array (Casts.Person_Sex) of Boolean := (False, False);
procedure Process (Index : in Person_Index; Item : in Person_Type'Class) is
begin
Existing (Item.Sex) := True;
end Process;
begin
Iterate_People (Village_Type'Class (Village), Process'Access);
return Existing (Casts.Male) and then Existing (Casts.Female);
end Male_And_Female;
procedure Exclude_Taken (
Cast : in out Casts.Cast_Collection;
Village : in Village_Type)
is
procedure Process (Index : in Person_Index; Item : in Person_Type'Class) is
begin
-- remove all duplicated characters
Casts.Exclude_Person (Cast, Item.Name.Constant_Reference, Item.Group);
-- remove one duplicated work
Casts.Exclude_Work (Cast, Item.Work.Constant_Reference);
end Process;
begin
Iterate_People (Village_Type'Class (Village), Process'Access);
end Exclude_Taken;
end Tabula.Villages;
|
29,809
|
ada
| 0
|
xuedong/mini-ada
|
tests/typing/good/testfile-rec-1.adb
|
<reponame>xuedong/mini-ada
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
procedure R is begin R; end;
begin
R;
end;
|
29,810
|
ada
| 33
|
ytomino/drake
|
source/directories/a-dhfina.ads
|
<filename>source/directories/a-dhfina.ads
pragma License (Unrestricted);
-- Ada 2012
package Ada.Directories.Hierarchical_File_Names is
function Is_Simple_Name (Name : String) return Boolean
renames Ada.Hierarchical_File_Names.Is_Simple_Name;
function Is_Root_Directory_Name (Name : String) return Boolean
renames Ada.Hierarchical_File_Names.Is_Root_Directory_Name;
function Is_Parent_Directory_Name (Name : String) return Boolean
renames Ada.Hierarchical_File_Names.Is_Parent_Directory_Name;
function Is_Current_Directory_Name (Name : String) return Boolean
renames Ada.Hierarchical_File_Names.Is_Current_Directory_Name;
function Is_Full_Name (Name : String) return Boolean
renames Ada.Hierarchical_File_Names.Is_Full_Name;
function Is_Relative_Name (Name : String) return Boolean
renames Ada.Hierarchical_File_Names.Is_Relative_Name;
function Simple_Name (Name : String) return String
renames Directories.Simple_Name;
function Containing_Directory (Name : String) return String
renames Directories.Containing_Directory;
function Initial_Directory (Name : String) return String
renames Ada.Hierarchical_File_Names.Initial_Directory;
function Relative_Name (Name : String) return String
renames Ada.Hierarchical_File_Names.Relative_Name;
-- modified
function Compose (
Directory : String := "";
Relative_Name : String;
Extension : String := "";
Path_Delimiter : Ada.Hierarchical_File_Names.Path_Delimiter_Type :=
Ada.Hierarchical_File_Names.Default_Path_Delimiter) -- additional
return String
renames Ada.Hierarchical_File_Names.Compose;
end Ada.Directories.Hierarchical_File_Names;
|
29,811
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c95067a.ada
|
<gh_stars>1-10
-- C95067A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A FORMAL PARAMETER OF MODE IN OR IN OUT CAN BE OF A
-- LIMITED TYPE, INCLUDING A COMPOSITE LIMITED TYPE.
-- JWC 6/20/85
WITH REPORT; USE REPORT;
PROCEDURE C95067A IS
PACKAGE PKG IS
TYPE ITYPE IS LIMITED PRIVATE;
TASK T1 IS
ENTRY LOOK_IN_I (X : IN ITYPE; V : INTEGER; M : STRING);
ENTRY LOOK_INOUT_I (X : IN OUT ITYPE; V : INTEGER;
M : STRING);
ENTRY SET_I (X : IN OUT ITYPE; V : INTEGER);
END T1;
SUBTYPE INT_0_20 IS INTEGER RANGE 0 .. 20;
TYPE VRTYPE (C : INT_0_20 := 20) IS LIMITED PRIVATE;
TASK T2 IS
ENTRY LOOK_IN_VR (X : IN VRTYPE; C : INTEGER;
I : INTEGER; S : STRING; M : STRING);
ENTRY LOOK_INOUT_VR (X : IN OUT VRTYPE; C : INTEGER;
I : INTEGER; S : STRING;
M : STRING);
ENTRY SET_VR (X : IN OUT VRTYPE; C : INTEGER;
I : INTEGER; S : STRING);
END T2;
PRIVATE
TYPE ITYPE IS NEW INTEGER RANGE 0 .. 99;
TYPE VRTYPE (C : INT_0_20 := 20) IS
RECORD
I : INTEGER;
S : STRING (1 .. C);
END RECORD;
END PKG;
USE PKG;
I1 : ITYPE;
TYPE ATYPE IS ARRAY (1 .. 3) OF ITYPE;
A1 : ATYPE;
VR1 : VRTYPE;
D : CONSTANT INT_0_20 := 10;
TYPE RTYPE IS
RECORD
J : ITYPE;
R : VRTYPE (D);
END RECORD;
R1 : RTYPE;
PACKAGE BODY PKG IS
TASK BODY T1 IS
BEGIN
LOOP
SELECT
ACCEPT LOOK_IN_I (X : IN ITYPE; V : INTEGER;
M : STRING) DO
IF INTEGER (X) /= V THEN
FAILED ("WRONG SCALAR VALUE - " & M);
END IF;
END LOOK_IN_I;
OR
ACCEPT LOOK_INOUT_I (X : IN OUT ITYPE;
V : INTEGER;
M : STRING) DO
IF INTEGER (X) /= V THEN
FAILED ("WRONG SCALAR VALUE - " & M);
END IF;
END LOOK_INOUT_I;
OR
ACCEPT SET_I (X : IN OUT ITYPE; V : INTEGER) DO
X := ITYPE (IDENT_INT (V));
END SET_I;
OR
TERMINATE;
END SELECT;
END LOOP;
END T1;
TASK BODY T2 IS
BEGIN
LOOP
SELECT
ACCEPT LOOK_IN_VR (X : IN VRTYPE; C : INTEGER;
I : INTEGER; S : STRING;
M : STRING) DO
IF (X.C /= C OR X.I /= I) OR ELSE
X.S /= S THEN
FAILED ("WRONG COMPOSITE VALUE - " &
M);
END IF;
END LOOK_IN_VR;
OR
ACCEPT LOOK_INOUT_VR (X : IN OUT VRTYPE;
C : INTEGER; I : INTEGER;
S : STRING;
M : STRING) DO
IF (X.C /= C OR X.I /= I) OR ELSE
X.S /= S THEN
FAILED ("WRONG COMPOSITE VALUE - " &
M);
END IF;
END LOOK_INOUT_VR;
OR
ACCEPT SET_VR (X : IN OUT VRTYPE; C : INTEGER;
I : INTEGER; S : STRING) DO
X := (IDENT_INT(C), IDENT_INT(I),
IDENT_STR(S));
END SET_VR;
OR
TERMINATE;
END SELECT;
END LOOP;
END T2;
BEGIN
I1 := ITYPE (IDENT_INT(2));
FOR I IN A1'RANGE LOOP
A1 (I) := ITYPE (3 + IDENT_INT(I));
END LOOP;
VR1 := (IDENT_INT(5), IDENT_INT(4), IDENT_STR("01234"));
R1.J := ITYPE (IDENT_INT(6));
R1.R := (IDENT_INT(D), IDENT_INT(19),
IDENT_STR("ABCDEFGHIJ"));
END PKG;
TASK T3 IS
ENTRY CHECK_IN_I (X : IN ITYPE; V : INTEGER; M : STRING);
ENTRY CHECK_INOUT_I (X : IN OUT ITYPE; OV : INTEGER;
NV : INTEGER; M : STRING);
ENTRY CHECK_IN_A (X : IN ATYPE; V : INTEGER; M : STRING);
ENTRY CHECK_INOUT_A (X : IN OUT ATYPE; OV : INTEGER;
NV : INTEGER; M : STRING);
ENTRY CHECK_IN_VR (X : IN VRTYPE; C : INTEGER; I : INTEGER;
S : STRING; M : STRING);
ENTRY CHECK_INOUT_VR (X : IN OUT VRTYPE;
OC : INTEGER; OI : INTEGER; OS : STRING;
NC : INTEGER; NI : INTEGER; NS : STRING;
M : STRING);
ENTRY CHECK_IN_R (X : IN RTYPE; J : INTEGER; C : INTEGER;
I : INTEGER; S : STRING; M : STRING);
ENTRY CHECK_INOUT_R (X : IN OUT RTYPE; OJ : INTEGER;
OC : INTEGER; OI : INTEGER; OS : STRING;
NJ : INTEGER;
NC : INTEGER; NI : INTEGER; NS : STRING;
M : STRING);
END T3;
TASK BODY T3 IS
BEGIN
ACCEPT CHECK_IN_I (X : IN ITYPE; V : INTEGER; M : STRING) DO
T1.LOOK_IN_I (X, V, M);
END CHECK_IN_I;
ACCEPT CHECK_INOUT_I (X : IN OUT ITYPE; OV : INTEGER;
NV : INTEGER; M : STRING) DO
T1.LOOK_INOUT_I (X, OV, M & " - A");
T1.SET_I (X, NV);
T1.LOOK_INOUT_I (X, NV, M & " - B");
T1.LOOK_IN_I (X, NV, M & " - C");
END CHECK_INOUT_I;
ACCEPT CHECK_IN_A (X : IN ATYPE; V : INTEGER; M : STRING) DO
FOR I IN X'RANGE LOOP
T1.LOOK_IN_I (X(I), V+I, M & " -" &
INTEGER'IMAGE (I));
END LOOP;
END CHECK_IN_A;
ACCEPT CHECK_INOUT_A (X : IN OUT ATYPE; OV : INTEGER;
NV : INTEGER; M : STRING) DO
FOR I IN X'RANGE LOOP
T1.LOOK_INOUT_I (X(I), OV+I, M & " - A" &
INTEGER'IMAGE (I));
T1.SET_I (X(I), NV+I);
T1.LOOK_INOUT_I (X(I), NV+I, M & " - B" &
INTEGER'IMAGE (I));
T1.LOOK_IN_I (X(I), NV+I, M & " - C" &
INTEGER'IMAGE (I));
END LOOP;
END CHECK_INOUT_A;
ACCEPT CHECK_IN_VR (X : IN VRTYPE; C : INTEGER; I : INTEGER;
S : STRING; M : STRING) DO
T2.LOOK_IN_VR (X, C, I, S, M);
END CHECK_IN_VR;
ACCEPT CHECK_INOUT_VR (X : IN OUT VRTYPE;
OC : INTEGER; OI : INTEGER;
OS : STRING;
NC : INTEGER; NI : INTEGER;
NS : STRING;
M : STRING) DO
T2.LOOK_INOUT_VR (X, OC, OI, OS, M & " - A");
T2.SET_VR (X, NC, NI, NS);
T2.LOOK_INOUT_VR (X, NC, NI, NS, M & " - B");
T2.LOOK_IN_VR (X, NC, NI, NS, M & " - C");
END CHECK_INOUT_VR;
ACCEPT CHECK_IN_R (X : IN RTYPE; J : INTEGER; C : INTEGER;
I : INTEGER; S : STRING; M : STRING) DO
T1.LOOK_IN_I (X.J, J, M & " - A");
T2.LOOK_IN_VR (X.R, C, I, S, M & " - B");
END CHECK_IN_R;
ACCEPT CHECK_INOUT_R (X : IN OUT RTYPE; OJ : INTEGER;
OC : INTEGER; OI : INTEGER; OS : STRING;
NJ : INTEGER;
NC : INTEGER; NI : INTEGER; NS : STRING;
M : STRING) DO
T1.LOOK_INOUT_I (X.J, OJ, M & " - A");
T2.LOOK_INOUT_VR (X.R, OC, OI, OS, M & " - B");
T1.SET_I (X.J, NJ);
T2.SET_VR (X.R, NC, NI, NS);
T1.LOOK_INOUT_I (X.J, NJ, M & " - C");
T2.LOOK_INOUT_VR (X.R, NC, NI, NS, M & " - D");
T1.LOOK_IN_I (X.J, NJ, M & " - E");
T2.LOOK_IN_VR (X.R, NC, NI, NS, M & " - F");
END CHECK_INOUT_R;
END T3;
BEGIN
TEST ("C95067A", "CHECK THAT LIMITED PRIVATE/COMPOSITE TYPES " &
"CAN BE USED AS IN OR IN OUT FORMAL PARAMETERS");
T3.CHECK_IN_I (I1, 2, "IN I");
T3.CHECK_INOUT_I (I1, 2, 5, "INOUT I");
T3.CHECK_IN_A (A1, 3, "IN A");
T3.CHECK_INOUT_A (A1, 3, 17, "INOUT A");
T3.CHECK_IN_VR (VR1, 5, 4, "01234", "IN VR");
T3.CHECK_INOUT_VR (VR1, 5, 4, "01234", 10, 11, "9876543210",
"INOUT VR");
T3.CHECK_IN_R (R1, 6, D, 19, "ABCDEFGHIJ", "IN R");
T3.CHECK_INOUT_R (R1, 6, D, 19, "ABCDEFGHIJ", 13, D, 5,
"ZYXWVUTSRQ", "INOUT R");
RESULT;
END C95067A;
|
29,812
|
ada
| 13
|
Fabien-Chouteau/GESTE
|
src/geste-physics.adb
|
<reponame>Fabien-Chouteau/GESTE<filename>src/geste-physics.adb
------------------------------------------------------------------------------
-- --
-- GESTE --
-- --
-- Copyright (C) 2018 <NAME> --
-- --
-- --
-- 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 GESTE.Maths; use GESTE.Maths;
package body GESTE.Physics is
function Collide_Rect_Rect (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Rectangle and then B.Box.Kind = Rectangle,
Inline;
function Collide_Rect_Borders (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Rectangle and then B.Box.Kind = Rect_Borders,
Inline;
function Collide_Rect_Circle (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Rectangle and then B.Box.Kind = Circle,
Inline;
function Collide_Rect_Line (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Rectangle and then B.Box.Kind = Line,
Inline;
function Collide_Borders_Borders (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Rect_Borders and then B.Box.Kind = Rect_Borders,
Inline;
function Collide_Borders_Circle (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Rect_Borders and then B.Box.Kind = Circle,
Inline;
function Collide_Borders_Line (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Rect_Borders and then B.Box.Kind = Line,
Inline;
function Collide_Circle_Circle (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Circle and then B.Box.Kind = Circle,
Inline;
function Collide_Circle_Line (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Circle and then B.Box.Kind = Line,
Inline;
function Collide_Line_Line (A, B : Object'Class) return Boolean
with Pre => A.Box.Kind = Line and then B.Box.Kind = Line,
Inline;
-----------------
-- Set_Hit_Box --
-----------------
procedure Set_Hit_Box (This : in out Object; Box : Hit_Box_Type) is
begin
This.Box := Box;
end Set_Hit_Box;
-------------
-- Hit_Box --
-------------
function Hit_Box (This : Object) return Hit_Box_Type
is (This.Box);
-----------------------
-- Collide_Rect_Rect --
-----------------------
function Collide_Rect_Rect (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Rect_Rect;
--------------------------
-- Collide_Rect_Borders --
--------------------------
function Collide_Rect_Borders (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Rect_Borders;
-------------------------
-- Collide_Rect_Circle --
-------------------------
function Collide_Rect_Circle (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Rect_Circle;
-----------------------
-- Collide_Rect_Line --
-----------------------
function Collide_Rect_Line (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Rect_Line;
-----------------------------
-- Collide_Borders_Borders --
-----------------------------
function Collide_Borders_Borders (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Borders_Borders;
----------------------------
-- Collide_Borders_Circle --
----------------------------
function Collide_Borders_Circle (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Borders_Circle;
--------------------------
-- Collide_Borders_Line --
--------------------------
function Collide_Borders_Line (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Borders_Line;
---------------------------
-- Collide_Circle_Circle --
---------------------------
function Collide_Circle_Circle (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Circle_Circle;
-------------------------
-- Collide_Circle_Line --
-------------------------
function Collide_Circle_Line (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Circle_Line;
-----------------------
-- Collide_Line_Line --
-----------------------
function Collide_Line_Line (A, B : Object'Class) return Boolean
is
pragma Unreferenced (B, A);
begin
return False;
end Collide_Line_Line;
-------------
-- Collide --
-------------
function Collide (This : Object; Obj : Object'Class) return Boolean is
begin
case This.Box.Kind is
when None =>
return False;
when Rectangle =>
case Obj.Box.Kind is
when None =>
return False;
when Rectangle =>
return Collide_Rect_Rect (This, Obj);
when Rect_Borders =>
return Collide_Rect_Borders (This, Obj);
when Circle =>
return Collide_Rect_Circle (This, Obj);
when Line =>
return Collide_Rect_Line (This, Obj);
end case;
when Rect_Borders =>
case Obj.Box.Kind is
when None =>
return False;
when Rectangle =>
return Collide_Rect_Borders (Obj, This);
when Rect_Borders =>
return Collide_Borders_Borders (This, Obj);
when Circle =>
return Collide_Borders_Circle (This, Obj);
when Line =>
return Collide_Borders_Line (This, Obj);
end case;
when Circle =>
case Obj.Box.Kind is
when None =>
return False;
when Rectangle =>
return Collide_Rect_Circle (Obj, This);
when Rect_Borders =>
return Collide_Borders_Circle (Obj, This);
when Circle =>
return Collide_Circle_Circle (This, Obj);
when Line =>
return Collide_Circle_Line (This, Obj);
end case;
when Line =>
case Obj.Box.Kind is
when None =>
return False;
when Rectangle =>
return Collide_Rect_Line (Obj, This);
when Rect_Borders =>
return Collide_Borders_Line (Obj, This);
when Circle =>
return Collide_Circle_Line (Obj, This);
when Line =>
return Collide_Line_Line (This, Obj);
end case;
end case;
end Collide;
----------
-- Mass --
----------
function Mass (This : Object) return Value
is (This.M);
--------------
-- Set_Mass --
--------------
procedure Set_Mass (This : in out Object;
M : Value)
is
begin
This.M := M;
end Set_Mass;
--------------
-- Position --
--------------
function Position (This : Object) return GESTE.Maths_Types.Point
is (This.P);
------------------
-- Set_Position --
------------------
procedure Set_Position
(This : in out Object;
P : GESTE.Maths_Types.Point)
is
begin
This.P := P;
end Set_Position;
-----------
-- Speed --
-----------
function Speed (This : Object) return Vect
is (This.S);
---------------
-- Set_Speed --
---------------
procedure Set_Speed
(This : in out Object;
S : Vect)
is
begin
This.S := S;
end Set_Speed;
------------------
-- Acceleration --
------------------
function Acceleration (This : Object) return Vect
is (This.A);
----------------------
-- Set_Acceleration --
----------------------
procedure Set_Acceleration
(This : in out Object;
A : Vect)
is
begin
This.A := A;
end Set_Acceleration;
-----------
-- Force --
-----------
function Force (This : Object) return Vect
is (This.F);
-----------------
-- Apply_Force --
-----------------
procedure Apply_Force
(This : in out Object;
F : Vect)
is
begin
This.F.X := This.F.X + F.X;
This.F.Y := This.F.Y + F.Y;
end Apply_Force;
-------------------
-- Apply_Gravity --
-------------------
procedure Apply_Gravity (This : in out Object;
G : Value := 9.51)
is
begin
This.Apply_Force ((0.0, -G * This.Mass));
end Apply_Gravity;
-----------
-- Angle --
-----------
function Angle (This : Object) return Value
is (This.Angle);
---------------
-- Set_Angle --
---------------
procedure Set_Angle (This : in out Object;
Angle : Value)
is
begin
This.Angle := Angle;
end Set_Angle;
---------------
-- Direction --
---------------
function Direction (This : Object) return Vect is
begin
return (Sin (This.Angle), Cos (This.Angle));
end Direction;
----------
-- Step --
----------
procedure Step
(This : in out Object;
Elapsed : Value)
is
begin
This.A.X := This.F.X / This.M;
This.A.Y := This.F.Y / This.M;
This.F := No_Force;
This.S.X := This.S.X + This.A.X * Elapsed;
This.S.Y := This.S.Y + This.A.Y * Elapsed;
This.P.X := This.P.X + This.S.X * Elapsed;
This.P.Y := This.P.Y + This.S.Y * Elapsed;
end Step;
end GESTE.Physics;
|
29,813
|
ada
| 0
|
pat-rogers/OpenUxAS
|
src/ada/src/uxas-messages-lmcptask-uniqueautomationrequest-spark_boundary.adb
|
package body UxAS.Messages.LmcpTask.UniqueAutomationRequest.SPARK_Boundary with SPARK_Mode => Off is
---------------------------------------------------
-- Copy_PlanningState_From_TaskAutomationRequest --
---------------------------------------------------
procedure Copy_PlanningState_From_TaskAutomationRequest
(Target : in out My_UniqueAutomationRequest;
Source : uxas.messages.lmcptask.TaskAutomationRequest.TaskAutomationRequest)
is
begin
for planningState of Source.getPlanningStates.all loop
uxas.messages.lmcptask.UniqueAutomationRequest.Vect_PlanningState_Acc.Append (Target.Content.getPlanningStates.all, planningState); -- we need to do a clone here
end loop;
end Copy_PlanningState_From_TaskAutomationRequest;
-------------------------------------------
-- Copy_OriginalRequest_From_AutomationRequest --
-------------------------------------------
procedure Copy_OriginalRequest_From_AutomationRequest
(Target : in out My_UniqueAutomationRequest;
Source : My_Object_Any)
is
begin
Target.Content.setOriginalRequest (AutomationRequest_Acc (Unwrap (Source)));
end Copy_OriginalRequest_From_AutomationRequest;
-------------------------------------------------------
-- Copy_OriginalRequest_From_ImpactAutomationRequest --
-------------------------------------------------------
procedure Copy_OriginalRequest_From_ImpactAutomationRequest
(Target : in out My_UniqueAutomationRequest;
Source : ImpactAutomationRequest)
is
begin
Target.Content.setOriginalRequest (Source.getTrialRequest); -- we need to do a clone here
end Copy_OriginalRequest_From_ImpactAutomationRequest;
-----------------------------------------------------
-- Copy_OriginalRequest_From_TaskAutomationRequest --
-----------------------------------------------------
procedure Copy_OriginalRequest_From_TaskAutomationRequest
(Target : in out My_UniqueAutomationRequest;
Source : uxas.messages.lmcptask.TaskAutomationRequest.TaskAutomationRequest)
is
begin
Target.Content.setOriginalRequest (Source.getOriginalRequest); -- we need to do a clone here
end Copy_OriginalRequest_From_TaskAutomationRequest;
-----------------------------------------
-- Get_EntityList_From_OriginalRequest --
-----------------------------------------
function Get_EntityList_From_OriginalRequest
(Request : My_UniqueAutomationRequest) return Int64_Vect
is
L : constant Vect_Int64_Acc := Request.Content.getOriginalRequest.getEntityList;
begin
return R : Int64_Vect do
for E of L.all loop
Int64_Vects.Append (R, E);
end loop;
end return;
end Get_EntityList_From_OriginalRequest;
----------------------------------------------
-- Get_OperatingRegion_From_OriginalRequest --
----------------------------------------------
function Get_OperatingRegion_From_OriginalRequest
(Request : My_UniqueAutomationRequest) return Int64
is (Request.Content.getOriginalRequest.getOperatingRegion);
----------------------------
-- Get_PlanningStates_Ids --
----------------------------
function Get_PlanningStates_Ids
(Request : My_UniqueAutomationRequest) return Int64_Vect
is
L : constant uxas.messages.Lmcptask.UniqueAutomationRequest.Vect_PlanningState_Acc_Acc :=
Request.Content.getPlanningStates;
begin
return R : Int64_Vect do
for E of L.all loop
Int64_Vects.Append (R, E.getEntityID);
end loop;
end return;
end Get_PlanningStates_Ids;
---------------------------------------
-- Get_TaskList_From_OriginalRequest --
---------------------------------------
function Get_TaskList_From_OriginalRequest
(Request : My_UniqueAutomationRequest) return Int64_Vect
is
L : constant Vect_Int64_Acc := Request.Content.getOriginalRequest.getTaskList;
begin
return R : Int64_Vect do
for E of L.all loop
Int64_Vects.Append (R, E);
end loop;
end return;
end Get_TaskList_From_OriginalRequest;
------------------
-- setRequestID --
------------------
procedure setRequestID
(this : in out My_UniqueAutomationRequest;
RequestID : Int64)
is
begin
this.Content.setRequestID (RequestID);
end setRequestID;
-----------------------
-- setSandBoxRequest --
-----------------------
procedure setSandBoxRequest
(this : in out My_UniqueAutomationRequest;
SandBoxRequest : Boolean)
is
begin
this.Content.setSandBoxRequest (SandBoxRequest);
end setSandBoxRequest;
end UxAS.Messages.LmcpTask.UniqueAutomationRequest.SPARK_Boundary;
|
29,814
|
ada
| 4
|
davidkristola/vole
|
kv-avm-executable_lists.ads
|
with kv.avm.Control;
with kv.avm.Executables;
with kv.avm.Actor_References;
package kv.avm.Executable_Lists is
type Cursor_Type is new Natural;
subtype Index_Type is Cursor_Type range 1 .. Cursor_Type'LAST;
type Executable_Handle_Type is tagged private;
type Executable_Handle_Access is access Executable_Handle_Type;
function Get_List(Self : Executable_Handle_Type) return kv.avm.Control.Status_Type;
function Get_Cursor(Self : Executable_Handle_Type) return Cursor_Type;
function Get_Reference(Self : Executable_Handle_Type) return kv.avm.Actor_References.Actor_Reference_Type;
function Get_Executable(Self : Executable_Handle_Type) return kv.avm.Executables.Executable_Access;
type Executable_Holder_Type is tagged private;
procedure Initialize
(Self : in out Executable_Holder_Type;
Kind : in kv.avm.Control.Status_Type);
procedure Add
(Self : in out Executable_Holder_Type;
This : in kv.avm.Executables.Executable_Access;
Ref : in kv.avm.Actor_References.Actor_Reference_Type);
function Find(Self : Executable_Holder_Type; Executable : kv.avm.Executables.Executable_Access) return Cursor_Type;
function Is_In(Self : Executable_Holder_Type; Executable : kv.avm.Executables.Executable_Access) return Boolean;
function Get(Self : Executable_Holder_Type; Position : Cursor_Type) return kv.avm.Executables.Executable_Access;
procedure Delete -- deallocate the handle
(Self : in out Executable_Holder_Type;
This : in Cursor_Type);
procedure Drop -- just remove the handle from the list
(Self : in out Executable_Holder_Type;
This : in Cursor_Type);
procedure Drop
(Self : in out Executable_Holder_Type;
This : in kv.avm.Executables.Executable_Access);
procedure Acquire_From
(Self : in out Executable_Holder_Type;
Place : in Cursor_Type;
From : in out Executable_Holder_Type);
function Get_Handle
(Self : Executable_Holder_Type;
Position : Cursor_Type) return Executable_Handle_Access;
function Get_Last
(Self : Executable_Holder_Type) return Cursor_Type;
private
type Executable_Handle_Type is tagged
record
Executable : kv.avm.Executables.Executable_Access;
Reference : kv.avm.Actor_References.Actor_Reference_Type;
Status : kv.avm.Control.Status_Type; -- This is also the list that holds the executable
Position : Cursor_Type; -- Zero means that this executable isn't in a list
end record;
type Executable_Array_Type is array (Index_Type range <>) of Executable_Handle_Access;
type Executable_Array_Access is access Executable_Array_Type;
type Executable_Holder_Type is tagged
record
List : Executable_Array_Access;
Count : Cursor_Type;
Kind : kv.avm.Control.Status_Type;
end record;
procedure Add
(Self : in out Executable_Holder_Type;
This : in Executable_Handle_Access);
end kv.avm.Executable_Lists;
|
29,815
|
ada
| 1
|
annexi-strayline/ASAP-JSON
|
json-parser_machine.adb
|
<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- JSON Parser/Constructor --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
--- * <NAME> (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 JSON.Standards;
package body JSON.Parser_Machine is
Error_Unexpected_Exception: aliased constant String
:= "An unexpected exception occured.";
package Transitions is
-- Named according to the state on entry
procedure Start_Value (Machine: in out Parser_FSM);
procedure In_Null (Machine: in out Parser_FSM);
procedure In_True (Machine: in out Parser_FSM);
procedure In_False (Machine: in out Parser_FSM);
procedure In_Integer (Machine: in out Parser_FSM);
procedure In_Float (Machine: in out Parser_FSM);
procedure In_Integer_Exponent (Machine: in out Parser_FSM);
procedure In_Float_Exponent (Machine: in out Parser_FSM);
procedure Start_String (Machine: in out Parser_FSM);
procedure In_String (Machine: in out Parser_FSM);
procedure In_String_Escape (Machine: in out Parser_FSM);
procedure In_Unicode_Escape (Machine: in out Parser_FSM);
procedure After_Name (Machine: in out Parser_FSM);
procedure End_Value (Machine: in out Parser_FSM);
procedure After_Push (Machine: in out Parser_FSM);
procedure After_Value (Machine: in out Parser_FSM);
procedure Output (Machine: in out Parser_FSM) is null;
procedure Halt (Machine: in out Parser_FSM) is null;
type State_Entry is
not null access procedure (Machine: in out Parser_FSM);
Transition_Switch: constant array (Machine_State) of State_Entry
:= (Start_Value => Start_Value'Access,
In_Null => In_Null'Access,
In_True => In_True'Access,
In_False => In_False'Access,
In_Integer => In_Integer'Access,
In_Float => In_Float'Access,
In_Integer_Exponent => In_Integer_Exponent'Access,
In_Float_Exponent => In_Float_Exponent'Access,
Start_String => Start_String'Access,
In_String => In_String'Access,
In_String_Escape => In_String_Escape'Access,
In_Unicode_Escape => In_Unicode_Escape'Access,
After_Name => After_Name'Access,
End_Value => End_Value'Access,
After_Push => After_Push'Access,
After_Value => After_Value'Access,
Output => Output'Access,
Halt => Halt'Access);
end Transitions;
package body Transitions is separate;
--------------
-- Dispatch --
--------------
procedure Dispatch (Machine: in out Parser_FSM) with Inline is
begin
Transitions.Transition_Switch(Machine.State) (Machine);
end;
-------------------
-- Setup_Buffers --
-------------------
procedure Setup_Buffers (Machine: in out Parser_FSM;
Config : in JSON_String_Buffer_Config)
is begin
Setup_Buffer (Target => Machine.Name_Output, Config => Config);
Setup_Buffer (Target => Machine.String_Output, Config => Config);
end;
----------------------
-- Configure_Limits --
----------------------
procedure Configure_Limits (Machine: in out Parser_FSM;
Limits : in Codec_Limits)
is begin
Machine.Limits := Limits;
Machine.Limits_Enabled := True;
end;
---------------------
-- Last_Indication --
---------------------
function Last_Indication (Machine: Parser_FSM) return Operator_Indication is
(Machine.Indication);
-------------------
-- Last_Position --
-------------------
function Last_Position (Machine: Parser_FSM) return Text_Position is
(Machine.Position);
----------------------------
-- Current_Structure_Kind --
----------------------------
function Current_Structure_Kind (Machine: Parser_FSM)
return JSON_Structure_Kind is
(Machine.Level_Kind);
----------
-- Feed --
----------
procedure Feed (Machine : in out Parser_FSM;
Input : in Wide_Wide_Character;
Indication: out Operator_Indication)
is
procedure Advance_Line with Inline is
begin
if Machine.Position.Line < Positive'Last then
Machine.Position.Line := Machine.Position.Line + 1;
Machine.Position.Column := 0;
Machine.Position.Overflow := False;
-- If we could increment Line OK, since we're clearing
-- Column, this means we are no longer in Overflow, if we
-- were before (due Column overflowing)
else
Machine.Position.Overflow := True;
end if;
end;
begin
if Machine.Indication /= Ready then
raise Program_Error;
end if;
if Machine.Last_Was_CR then
-- CR is expected to be followed by LF. We don't have any real use
-- of checking if it is or not, we will always count it as a new
-- line.
Advance_Line;
Machine.Last_Was_CR := False;
end if;
if Input in JSON.Standards.Carriage_Return | JSON.Standards.Line_Feed
and then
Machine.State not in In_String | In_String_Escape | In_Unicode_Escape
then
if Input = JSON.Standards.Carriage_Return then
Machine.Last_Was_CR := True;
elsif Input = JSON.Standards.Line_Feed then
Advance_Line;
end if;
end if;
if Machine.Position.Column < Natural'Last then
Machine.Position.Column := Machine.Position.Column + 1;
else
Machine.Position.Overflow := True;
end if;
Machine.Input := Input;
Dispatch (Machine);
Indication := Machine.Indication;
exception
when others =>
Machine.State := Halt;
Machine.Indication := Invalid;
Machine.Error := Error_Unexpected_Exception'Access;
Indication := Machine.Indication;
end;
---------------------
-- Acknowledge_Pop --
---------------------
procedure Acknowledge_Pop (Machine : in out Parser_FSM;
Popped_To : in JSON_Structure_Kind;
Indication: out Operator_Indication)
is begin
Machine.Level_Kind := Popped_To;
Machine.Value_Kind := Popped_To;
Machine.State := End_Value;
Dispatch (Machine);
Indication := Machine.Indication;
exception
when others =>
Machine.State := Halt;
Machine.Indication := Invalid;
Machine.Error := Error_Unexpected_Exception'Access;
end;
----------------------
-- Acknowledge_Push --
----------------------
procedure Acknowledge_Push (Machine : in out Parser_FSM;
Indication: out Operator_Indication)
is begin
Machine.State := After_Push;
Machine.Indication := Ready;
Indication := Ready;
end;
-------------
-- Outputs --
-------------
procedure Output_Name (Machine: in out Parser_FSM;
Target : out JSON_String_Buffer)
is begin
Export (Source => Machine.Name_Output, Target => Target);
end;
function Output_Kind (Machine: Parser_FSM) return JSON_Value_Kind is
(Machine.Value_Kind);
procedure Output_Value (Machine: in out Parser_FSM;
Target : out JSON_String_Buffer)
is begin
Export (Source => Machine.String_Output, Target => Target);
end;
function Output_Value (Machine: Parser_FSM) return Boolean is
(Machine.Boolean_Output);
function Output_Value (Machine: Parser_FSM) return JSON_Integer_Value is
(Machine.Integer_Output);
function Output_Value (Machine: Parser_FSM) return JSON_Float_Value is
(Machine.Float_Output);
------------------------
-- Acknowledge_Output --
------------------------
procedure Acknowledge_Output (Machine : in out Parser_FSM;
Indication: out Operator_Indication)
is begin
Machine.State := End_Value;
Dispatch (Machine);
Indication := Machine.Indication;
exception
when others =>
Machine.State := Halt;
Machine.Indication := Invalid;
Machine.Error := Error_Unexpected_Exception'Access;
Indication := Machine.Indication;
end;
--------------------
-- Invalid_Reason --
--------------------
function Invalid_Reason (Machine: Parser_FSM) return String is
(Machine.Error.all);
--------------------
-- Emergency_Stop --
--------------------
Error_Emergency_Stop: aliased constant String
:= "Operator invoked Emergency Stop.";
procedure Emergency_Stop (Machine: in out Parser_FSM) is
begin
if Machine.Indication in Invalid | Done then
return;
end if;
Machine.State := Halt;
Machine.Indication := Invalid;
Machine.Error := Error_Emergency_Stop'Access;
end;
-----------
-- Reset --
-----------
procedure Reset (Machine: in out Parser_FSM) is
begin
Machine.State := Start_Value;
Machine.Indication := Ready;
Machine.Error := null;
Machine.Position := (Line => 1, Column => 0, Overflow => False);
Machine.Level := 0;
Machine.Level_Kind := JSON_Object;
Machine.String_Total := 0;
Machine.Entity_Total := 0;
end Reset;
end JSON.Parser_Machine;
|
29,816
|
ada
| 0
|
Fabien-Chouteau/ASFML
|
include/sf-graphics-blendmode.ads
|
--//////////////////////////////////////////////////////////
-- SFML - Simple and Fast Multimedia Library
-- Copyright (C) 2007-2015 <NAME> (<EMAIL>)
-- This software is provided 'as-is', without any express or implied warranty.
-- In no event will the authors be held liable for any damages arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it freely,
-- subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented;
-- you must not claim that you wrote the original software.
-- If you use this software in a product, an acknowledgment
-- in the product documentation would be appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such,
-- and must not be misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--//////////////////////////////////////////////////////////
package Sf.Graphics.BlendMode is
--//////////////////////////////////////////////////////////
--/ @brief Enumeration of the blending factors
--/
--//////////////////////////////////////////////////////////
--/< (0, 0, 0, 0)
--/< (1, 1, 1, 1)
--/< (src.r, src.g, src.b, src.a)
--/< (1, 1, 1, 1) - (src.r, src.g, src.b, src.a)
--/< (dst.r, dst.g, dst.b, dst.a)
--/< (1, 1, 1, 1) - (dst.r, dst.g, dst.b, dst.a)
--/< (src.a, src.a, src.a, src.a)
--/< (1, 1, 1, 1) - (src.a, src.a, src.a, src.a)
--/< (dst.a, dst.a, dst.a, dst.a)
--/< (1, 1, 1, 1) - (dst.a, dst.a, dst.a, dst.a)
type sfBlendFactor is
(sfBlendFactorZero,
sfBlendFactorOne,
sfBlendFactorSrcColor,
sfBlendFactorOneMinusSrcColor,
sfBlendFactorDstColor,
sfBlendFactorOneMinusDstColor,
sfBlendFactorSrcAlpha,
sfBlendFactorOneMinusSrcAlpha,
sfBlendFactorDstAlpha,
sfBlendFactorOneMinusDstAlpha);
pragma Convention (C, sfBlendFactor);
--//////////////////////////////////////////////////////////
--/ @brief Enumeration of the blending equations
--/
--//////////////////////////////////////////////////////////
--/< Pixel = Src * SrcFactor + Dst * DstFactor
--/< Pixel = Src * SrcFactor - Dst * DstFactor
--/< Pixel = Dst * DstFactor - Src * SrcFactor
type sfBlendEquation is
(sfBlendEquationAdd,
sfBlendEquationSubtract,
sfBlendEquationReverseSubtract);
pragma Convention (C, sfBlendEquation);
--//////////////////////////////////////////////////////////
--/ @brief Blending mode for drawing
--/
--//////////////////////////////////////////////////////////
--/< Source blending factor for the color channels
--/< Destination blending factor for the color channels
--/< Blending equation for the color channels
--/< Source blending factor for the alpha channel
--/< Destination blending factor for the alpha channel
--/< Blending equation for the alpha channel
type sfBlendMode is record
colorSrcFactor : aliased sfBlendFactor;
colorDstFactor : aliased sfBlendFactor;
colorEquation : aliased sfBlendEquation;
alphaSrcFactor : aliased sfBlendFactor;
alphaDstFactor : aliased sfBlendFactor;
alphaEquation : aliased sfBlendEquation;
end record;
pragma Convention (C_Pass_By_Copy, sfBlendMode);
--/< Blend source and dest according to dest alpha
sfBlendAlpha : aliased sfBlendMode;
--/< Add source to dest
sfBlendAdd : aliased sfBlendMode;
--/< Multiply source and dest
sfBlendMultiply : aliased sfBlendMode;
--/< Overwrite dest with source
sfBlendNone : aliased sfBlendMode;
private
pragma Import (C, sfBlendAlpha, "sfBlendAlpha");
pragma Import (C, sfBlendAdd, "sfBlendAdd");
pragma Import (C, sfBlendMultiply, "sfBlendMultiply");
pragma Import (C, sfBlendNone, "sfBlendNone");
end Sf.Graphics.BlendMode;
|
29,817
|
ada
| 0
|
passlab/rexompiler
|
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/complex.ads
|
<gh_stars>0
package Complex is
type Complex is
record
Re : Float := 0.0;
Im : Float := 0.0;
end record;
I : constant Complex := (0.0, 1.0);
function II return Complex;
end Complex;
|
29,818
|
ada
| 488
|
ouankou/rose
|
src/frontend/Experimental_Ada_ROSE_Connection/parser/support/source/generic_logging.adb
|
<filename>src/frontend/Experimental_Ada_ROSE_Connection/parser/support/source/generic_logging.adb
with Ada.Characters.Handling;
with Ada.Text_IO;
with Ada.Wide_Text_IO;
with GNAT.Traceback.Symbolic;
package body Generic_Logging is
Wide_Module_Name : constant Wide_String :=
Ada.Characters.Handling.To_Wide_String (Module_Name);
------------
-- EXPORTED:
------------
procedure Log (Message : in String) is
begin
Ada.Text_IO.Put_Line (Module_Name & ": " & Message);
end Log;
------------
-- EXPORTED:
------------
procedure Log_Wide (Message : in Wide_String) is
begin
Ada.Wide_Text_IO.Put_Line (Wide_Module_Name & ": " & Message);
end Log_Wide;
------------
-- EXPORTED:
------------
procedure Log_Exception (X : in Ada.Exceptions.Exception_Occurrence) is
begin
Log ("EXCEPTION: " & Ada.Exceptions.Exception_Name (X));
Log (Ada.Exceptions.Exception_Information (X));
Log ("TRACEBACK: ");
Log (GNAT.Traceback.Symbolic.Symbolic_Traceback (X));
end Log_Exception;
----------------------
-- EXPORTED (private):
----------------------
procedure Initialize (Self : in out Auto_Logger) is
begin
Log ("BEGIN");
exception
when X: others =>
Log_Exception (X);
Log ("Reraising exception in Initialize procedure. Should cause Program_Error");
raise;
end Initialize;
----------------------
-- EXPORTED (private):
----------------------
procedure Finalize (Self : in out Auto_Logger) is
begin
Log ("END");
exception
when X: others =>
Log_Exception (X);
Log ("Reraising exception in Initialize procedure. Should cause Program_Error");
raise;
end Finalize;
end Generic_Logging;
|
29,819
|
ada
| 0
|
AdaForge/Advent_of_Code_2020
|
puzzle_25/src/puzzle_25.adb
|
<filename>puzzle_25/src/puzzle_25.adb
procedure Puzzle_25 is
begin
null;
end Puzzle_25;
|
29,820
|
ada
| 0
|
Asier98/AdaCar
|
src/adacar-alarmas.adb
|
<reponame>Asier98/AdaCar
with Ada.Real_Time; use type Ada.Real_Time.Time; use Ada;
with AdaCar.Parametros;
package body AdaCar.Alarmas is
type Lista_Alarmas is array(Tipo_Alarmas) of Estado_Alarma;
protected Alarmas_PO
with Priority => Parametros.Techo_Alarmas_PO
is
procedure Notificar_Alarma(Alarma: Tipo_Alarmas);
function Leer_Listado_Alarmas return Lista_Alarmas;
private
Listado_Alarmas: Lista_Alarmas:= (Tipo_Alarmas'Range=>
Estado_Alarma'(Desactivada));
end Alarmas_PO;
----------------------
-- Notificar_Alarma --
----------------------
procedure Notificar_Alarma (Alarma : Tipo_Alarmas) is
begin
Alarmas_PO.Notificar_Alarma(Alarma);
end Notificar_Alarma;
task Alarmas_Task with Priority => Parametros.Prioridad_Alarmas_Task;
protected body Alarmas_PO is
procedure Notificar_Alarma(Alarma: Tipo_Alarmas) is
begin
Listado_Alarmas(Alarma):= Estado_Alarma'(Activada);
end Notificar_Alarma;
function Leer_Listado_Alarmas return Lista_Alarmas is
begin
return Listado_Alarmas;
end Leer_Listado_Alarmas;
end Alarmas_PO;
task body Alarmas_Task is
Tseg: constant Duration:= Parametros.Periodo_Alarmas_Task;
Periodo: constant Real_Time.Time_Span:= Real_Time.To_Time_Span(Tseg);
Next: Real_Time.Time:= Real_Time.Clock;
begin
null;
end Alarmas_Task;
end AdaCar.Alarmas;
|
29,821
|
ada
| 20
|
charlie5/lace
|
3-mid/physics/interface/source/private/box2d/box2d_physics.ads
|
with
float_Math;
package box2d_Physics
--
-- Provides an implementation of the physics interface using a binding to the Box2D C library.
--
is
pragma Pure;
package Math renames float_Math;
Error : exception;
end box2d_Physics;
|
29,822
|
ada
| 0
|
My-Colaborations/ada-ado
|
src/ado-utils-serialize.adb
|
<reponame>My-Colaborations/ada-ado
-----------------------------------------------------------------------
-- ado-utils-serialize -- Utility operations for JSON/XML serialization
-- Copyright (C) 2016, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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 ADO.Schemas;
package body ADO.Utils.Serialize is
-- ------------------------------
-- Write the entity to the serialization stream (JSON/XML).
-- ------------------------------
procedure Write_Entity (Stream : in out Util.Serialize.IO.Output_Stream'Class;
Name : in String;
Value : in ADO.Identifier) is
begin
Stream.Write_Long_Entity (Name, Long_Long_Integer (Value));
end Write_Entity;
-- ------------------------------
-- Write the entity to the serialization stream (JSON/XML).
-- ------------------------------
procedure Write_Entity (Stream : in out Util.Serialize.IO.Output_Stream'Class;
Name : in String;
Value : in ADO.Objects.Object_Key) is
begin
case Value.Of_Type is
when ADO.Objects.KEY_INTEGER =>
Write_Entity (Stream, Name, ADO.Objects.Get_Value (Value));
when ADO.Objects.KEY_STRING =>
Stream.Write_Entity (Name, ADO.Objects.Get_Value (Value));
end case;
end Write_Entity;
-- ------------------------------
-- Write the SQL query results to the serialization stream (JSON/XML).
-- ------------------------------
procedure Write_Query (Stream : in out Util.Serialize.IO.Output_Stream'Class;
Name : in String;
Query : in out ADO.Statements.Query_Statement) is
use ADO.Schemas;
Column_Count : Natural;
begin
Stream.Start_Array (Name);
if Query.Has_Elements then
Column_Count := Query.Get_Column_Count;
while Query.Has_Elements loop
Stream.Start_Entity ("");
for I in 1 .. Column_Count loop
declare
Name : constant String := Query.Get_Column_Name (I - 1);
begin
if Query.Is_Null (I - 1) then
Stream.Write_Null_Entity (Name);
else
case Query.Get_Column_Type (I - 1) is
-- Boolean column
when T_BOOLEAN =>
Stream.Write_Entity (Name, Query.Get_Boolean (I - 1));
when T_TINYINT | T_SMALLINT | T_INTEGER | T_LONG_INTEGER | T_YEAR =>
Stream.Write_Entity (Name, Query.Get_Integer (I - 1));
when T_FLOAT | T_DOUBLE | T_DECIMAL =>
Stream.Write_Null_Entity (Name);
when T_ENUM =>
Stream.Write_Entity (Name, Query.Get_String (I - 1));
when T_TIME | T_DATE | T_DATE_TIME | T_TIMESTAMP =>
Stream.Write_Entity (Name, Query.Get_Time (I - 1));
when T_CHAR | T_VARCHAR =>
Stream.Write_Entity (Name, Query.Get_String (I - 1));
when T_BLOB =>
Stream.Write_Null_Entity (Name);
when T_SET | T_UNKNOWN | T_NULL =>
Stream.Write_Null_Entity (Name);
end case;
end if;
end;
end loop;
Stream.End_Entity ("");
Query.Next;
end loop;
end if;
Stream.End_Array (Name);
end Write_Query;
end ADO.Utils.Serialize;
|
29,823
|
ada
| 1
|
brucegua/moocos
|
tools/scitools/conf/understand/ada/ada05/a-rttiev.ads
|
<reponame>brucegua/moocos
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . R E A L _ T I M E . T I M I N G _ E V E N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2005-2006, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
--
--
--
--
--
--
--
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Finalization;
package Ada.Real_Time.Timing_Events is
type Timing_Event is tagged limited private;
type Timing_Event_Handler
is access protected procedure (Event : in out Timing_Event);
procedure Set_Handler
(Event : in out Timing_Event;
At_Time : Time;
Handler : Timing_Event_Handler);
procedure Set_Handler
(Event : in out Timing_Event;
In_Time : Time_Span;
Handler : Timing_Event_Handler);
function Current_Handler
(Event : Timing_Event) return Timing_Event_Handler;
procedure Cancel_Handler
(Event : in out Timing_Event;
Cancelled : out Boolean);
function Time_Of_Event (Event : Timing_Event) return Time;
private
protected type Event_State is
-- D.15 (22/2) requires atomicity with respect to the operations
-- provided by the package and the timing events they manipulate. On
-- real-time operating systems suitable for implementing this package, a
-- different implementation strategy would be employed to meet that
-- requirement.
entry Set (Timeout : Time; Handler : Timing_Event_Handler);
-- Changes the timeout and handler values for procedure Set_Handler. Can
-- only execute when the event is 'available', to prevent a race
-- condition between the caller of Set_Handler and the internal Timer
-- task that processes the events. In particular, D.15 (22/2) requires
-- that there be no possibility of a new handler executing in response
-- to an old timeout.
procedure Reset;
-- First resets the timeout to Time_First and the handler to
-- null. Indicates that Set (for Set_Handler) can now change the timeout
-- and/or handler. Called only by the interal Timer task.
procedure Cancel;
-- Resets the timeout to Time_First and the handler to
-- null. Called by procedure Cancel_Handler and by procedure Reset.
function Current_Timeout return Time;
-- Returns the currently set timeout. The value Time_First is returned
-- if the Timing_Event is in the "cleared" state. Called by function
-- Time_of_Event.
function Current_Handler return Timing_Event_Handler;
-- Returns the currently set handler. The value null is returned if the
-- Timing_Event is in the "cleared" state. Called by function
-- Curent_Handler.
private
Timeout : Time := Time_First;
-- The time at which the user's handler should be invoked when the
-- event is "set" (i.e., when Handler is not null).
Handler : Timing_Event_Handler;
-- An access value designating the protected procedure to be invoked
-- at the Timeout time in the future. When this value is null the event
-- is said to be "cleared" and no timeout is processed.
Available : Boolean := True;
-- A flag controlling when users can change the Timeout and Handler
-- tuple. In particular the entry Set, called by procedure Set_Handler,
-- is controlled by this flag.
end Event_State;
type Timing_Event is new Ada.Finalization.Limited_Controlled with record
Control : Event_State;
end record;
overriding procedure Finalize (This : in out Timing_Event);
-- Finalization procedure is required to satisfy (RM D.15 (19/2)), which
-- says that the object must be cleared on finalization.
end Ada.Real_Time.Timing_Events;
|
29,824
|
ada
| 12
|
TUM-EI-RCS/StratoX
|
software/hal/boards/stm32f7_discovery/hal-audio.ads
|
<reponame>TUM-EI-RCS/StratoX<filename>software/hal/boards/stm32f7_discovery/hal-audio.ads
-- Generic spec for Audio drivers
-- /!\ This is work in progress and not at a real Hardware Abstraction Layer
with Ada.Interrupts.Names;
with Interfaces; use Interfaces;
with STM32.DMA;
package HAL.Audio is
Audio_Out_DMA_Interrupt : Ada.Interrupts.Interrupt_ID renames
Ada.Interrupts.Names.DMA2_Stream4_Interrupt;
type Audio_Buffer is array (Natural range <>) of Integer_16
with Component_Size => 16, Alignment => 32;
type Audio_Volume is new Natural range 0 .. 100;
type Audio_Frequency is
(Audio_Freq_8kHz,
Audio_Freq_11kHz,
Audio_Freq_16kHz,
Audio_Freq_22kHz,
Audio_Freq_44kHz,
Audio_Freq_48kHz,
Audio_Freq_96kHz)
with Size => 32;
for Audio_Frequency use
(Audio_Freq_8kHz => 8_000,
Audio_Freq_11kHz => 11_025,
Audio_Freq_16kHz => 16_000,
Audio_Freq_22kHz => 22_050,
Audio_Freq_44kHz => 44_100,
Audio_Freq_48kHz => 48_000,
Audio_Freq_96kHz => 96_000);
type DMA_Error is
(FIFO_Error,
Direct_Mode_Error,
Transfer_Error);
procedure Initialize_Audio_Out
(Volume : Audio_Volume;
Frequency : Audio_Frequency);
function DMA_Out_Status
(Flag : STM32.DMA.DMA_Status_Flag) return Boolean;
procedure DMA_Out_Clear_Status
(Flag : STM32.DMA.DMA_Status_Flag);
procedure Play
(Buffer : Audio_Buffer);
procedure Change_Buffer
(Buffer : Audio_Buffer);
procedure Pause;
procedure Resume;
procedure Stop;
procedure Set_Volume
(Volume : Audio_Volume);
procedure Set_Frequency
(Frequency : Audio_Frequency);
end HAL.Audio;
|
29,825
|
ada
| 18
|
jquorning/ada-wiki
|
src/wiki-plugins-variables.adb
|
<filename>src/wiki-plugins-variables.adb
-----------------------------------------------------------------------
-- wiki-plugins-variables -- Variables plugin
-- Copyright (C) 2020, 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Wiki.Filters.Variables;
package body Wiki.Plugins.Variables is
-- ------------------------------
-- Set or update a variable in the `Wiki.Filters.Variable` filter.
-- ------------------------------
overriding
procedure Expand (Plugin : in out Variable_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in out Plugin_Context) is
pragma Unreferenced (Plugin, Document);
begin
if Wiki.Attributes.Length (Params) >= 3 then
declare
First : Wiki.Attributes.Cursor := Wiki.Attributes.First (Params);
Second : Wiki.Attributes.Cursor;
begin
Wiki.Attributes.Next (First);
Second := First;
Wiki.Attributes.Next (Second);
Wiki.Filters.Variables.Add_Variable (Context.Filters,
Wiki.Attributes.Get_Wide_Value (First),
Wiki.Attributes.Get_Wide_Value (Second));
end;
end if;
end Expand;
-- ------------------------------
-- List the variables from the `Wiki.Filters.Variable` filter.
-- ------------------------------
overriding
procedure Expand (Plugin : in out List_Variable_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in out Plugin_Context) is
pragma Unreferenced (Plugin, Params);
procedure Print_Variable (Name : in Wiki.Strings.WString;
Value : in Wiki.Strings.WString);
Has_Table : Boolean := False;
Format : constant Format_Map := (others => False);
Attributes : Wiki.Attributes.Attribute_List;
procedure Print_Variable (Name : in Wiki.Strings.WString;
Value : in Wiki.Strings.WString) is
begin
Has_Table := True;
Context.Filters.Add_Row (Document);
Context.Filters.Add_Column (Document, Attributes);
Context.Filters.Add_Text (Document, Name, Format);
Context.Filters.Add_Column (Document, Attributes);
Context.Filters.Add_Text (Document, Value, Format);
end Print_Variable;
begin
Wiki.Filters.Variables.Iterate (Context.Filters, Print_Variable'Access);
if Has_Table then
Context.Filters.Finish_Table (Document);
end if;
end Expand;
end Wiki.Plugins.Variables;
|
29,826
|
ada
| 0
|
caqg/linux-home
|
.emacs.d/elpa/ada-mode-5.3.1/gps_source/string_utils.ads
|
------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2001-2016, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
-- This package provides a set of subprograms for manipulating and parsing
-- strings.
with GNAT.Strings;
with Interfaces.C.Strings;
with Basic_Types; use Basic_Types;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package String_Utils is
function "+"
(S : String) return Unbounded_String renames To_Unbounded_String;
function "+"
(S : Unbounded_String) return String renames To_String;
-- Utility conversion operators from String to Unbounded_String
function Hex_Value (Hex : String) return Natural;
-- Return the value for the hexadecimal number Hex. Raises
-- Constraint_Error is Hex is not an hexadecimal number.
procedure Skip_To_Blank
(Type_Str : String;
Index : in out Natural);
-- Skip to the next blank character
procedure Skip_To_Index
(Buffer : String;
Columns : out Visible_Column_Type;
Index_In_Line : String_Index_Type;
Index : in out String_Index_Type;
Tab_Width : Positive := 8);
procedure Skip_To_Index
(Buffer : Unbounded_String;
Columns : out Visible_Column_Type;
Index_In_Line : String_Index_Type;
Index : in out String_Index_Type;
Tab_Width : Positive := 8);
-- Assuming Index points to the begining of a line, move the index by
-- "Index_In_Line" characters, and give the new column value.
procedure Skip_Hexa_Digit
(Type_Str : String;
Index : in out Natural);
-- Move Index to the first character that can not be part of an hexadecimal
-- digit. Note that an hexadecimal digit can optionally start with '0x',
-- which is the only case where x is recognized as part of the digit.
procedure Skip_To_Char
(Type_Str : String;
Index : in out Natural;
Char : Character;
Step : Integer := 1);
procedure Skip_To_Char
(Type_Str : Unbounded_String;
Index : in out Natural;
Char : Character;
Step : Integer := 1);
-- Skip every character up to the first occurence of Char in the string.
-- If no occurrence found, then Index is set over Type_Str'Last.
procedure Skip_Word
(Type_Str : String;
Index : in out Natural;
Step : Integer := 1);
-- Skip the word starting at Index (at least one character, even if there
-- is no word).
-- Currently, a word is defined as any string made of alphanumeric
-- character or underscore.
procedure Skip_CPP_Token
(Type_Str : String;
Index : in out Natural;
Step : Integer := 1);
-- Skip the cpp token starting at Index (at least one character, even if
-- there is no cpp token).
-- Currently, a cpp token is defined as any string made of alphanumeric
-- character, underscore or period.
function Tab_Width return Positive;
pragma Inline (Tab_Width);
-- Default value of tab width in the text editor (current value is 8)
function Lines_Count (Text : String) return Natural;
-- Return the number of lines in Text
function Blank_Slice
(Count : Integer;
Use_Tabs : Boolean := False;
Tab_Width : Positive := 8) return String;
-- Return a string representing count blanks.
-- If Use_Tabs is True, use ASCII.HT characters as much as possible,
-- otherwise use only spaces.
-- Return a null string if Count is negative.
function Is_Blank (C : Character) return Boolean;
-- Return True if C is a blank character: CR, LF, HT or ' '
procedure Next_Line
(Buffer : String;
P : Natural;
Next : out Natural;
Success : out Boolean);
-- Return the start of the next line in Next or Buffer'Last if the end of
-- the buffer is reached.
-- Success is set to True if a new line was found, false otherwise (end of
-- buffer reached).
procedure Parse_Num
(Type_Str : String;
Index : in out Natural;
Result : out Long_Integer);
-- Parse the integer found at position Index in Type_Str.
-- Index is set to the position of the first character that does not
-- belong to the integer.
function Looking_At
(Type_Str : String;
Index : Natural;
Substring : String) return Boolean;
-- Return True if the characters starting at Index in Type_Str are
-- equivalent to Substring.
procedure Parse_Cst_String
(Type_Str : String;
Index : in out Natural;
Str : out String;
Str_Last : out Natural;
Backslash_Special : Boolean := True);
-- Parse the string pointed to by Index, and copy the result in Str.
-- Index must point to the opening " character, and will be set to
-- point after the closing " character.
-- Special characters, as output by gdb (["0a"]) are also interpreted
-- and converted to the equivalent Character value.
-- Str must be long enough to contain the string, not check is done. As a
-- special case, if Str'Length = 0 then no attempt is done to fill up
-- the string, and only Length is computed. Str_Last is set to the last
-- meaningful character in Str.
--
-- Index is set to the number of characters parsed in the string.
procedure Skip_Simple_Value
(Type_Str : String;
Index : in out Natural;
Array_Item_Separator : Character := ',';
End_Of_Array : Character := ')';
Repeat_Item_Start : Character := '<');
-- Skip the value of a simple value ("65 'A'" for instance).
-- This stops at the first special character.
--
-- Array_Item_Separator is the separator in an array value (ie "5, 2, 3").
-- End_Of_Array is the array that indicates the end of an array value, as
-- in "((1, 2), (3, 4))".
-- Repeat_Item_Start if the character that starts a repeat statements, as
-- in "<repeats .. times>"
function Reduce
(S : String;
Max_Length : Positive := Positive'Last;
Continuation : String := "...") return String;
-- Replace in string S all ASCII.LF and ASCII.HT characters with a space,
-- and replace multiple spaces with a single one. Return the resulting
-- string with at most Max_Length character including the continuation
-- characters. S should be encoded in UTF-8.
function Krunch
(S : String;
Max_String_Length : Positive := 20) return String;
-- If String is less than Max_String_Length characters long, return it,
-- otherwise return a krunched string no longer than Max_String_Length.
procedure Strip_CR
(Text : in out String;
Last : out Integer;
CR_Found : out Boolean);
-- Same as above, but works on Text, and more efficient
-- Text (Text'First .. Last) contains the new result.
-- CR_Found is set to True if a CR was found in Text.
procedure Strip_CR_And_NUL
(Text : in out String;
Last : out Integer;
CR_Found : out Boolean;
NUL_Found : out Boolean;
Trailing_Space_Found : out Boolean);
-- Same as Strip_CR, and strip also ASCII.NUL characters
-- Note that CR chars alone are not replaced by LF chars.
-- Also check if Text has trailing spaces in a line.
function Strip_Ending_Linebreaks (Text : String) return String;
-- Return a version of Text after stripping all ending CR and LF
-- characters.
function Do_Tab_Expansion
(Text : String; Tab_Size : Integer) return String;
-- Return a version of Text after all tabs have been correctly expanded
-- depending on the value of Tab_Size.
-- This function works correctly with multiple-line strings.
function Strip_Quotes (S : String) return String;
-- Remove the quotes and the spaces at the beginning and end of S
function Strip_Single_Underscores (S : String) return String;
-- Return S stripped of single underscores, and with multiple underscores
-- concatenated into one.
-- This is used to process menu shortcuts, for example
-- Strip_Single_Underscores ("/_Project/C_lean") returns "/Project/Clean"
function Image (N : Integer) return String;
-- Create a string image of the given Integer
function Safe_Value (S : String; Default : Integer := 1) return Integer;
-- Convert S to a Natural, making sure there is no exception raised.
-- If S doesn't contain a valid number, Default is returned.
function Number_Of_Digits (N : Integer) return Natural;
-- Return the number of digits for the given Integer number;
function Is_Entity_Letter (Char : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Entity_Letter);
-- Return True if the given letter is a valid letter for an entity name
-- (ie if the letter is either alphanumeric or an '_').
function Is_Operator_Letter (Char : Wide_Wide_Character) return Boolean;
-- Return True if the given letter is a valid operator
function Is_File_Letter (Char : Wide_Wide_Character) return Boolean;
pragma Inline (Is_File_Letter);
-- Return True if the given letter is a valid letter for a file name.
procedure Replace
(S : in out GNAT.Strings.String_Access;
Value : String);
-- Set S to Value, free previous content if any
procedure Replace
(S : in out GNAT.Strings.String_Access;
Value : GNAT.Strings.String_Access);
-- Idem, but does nothing if Value is null
function Has_Include_Directive (Str : String) return Boolean;
-- Return True is Str contains an #include directive
-------------------
-- Argument_List --
-------------------
function Clone
(List : GNAT.Strings.String_List) return GNAT.Strings.String_List;
-- Return a deep-copy of List. The returned value must be freed by the
-- caller.
procedure Append
(List : in out GNAT.Strings.String_List_Access;
List2 : GNAT.Strings.String_List);
procedure Append
(List : in out GNAT.Strings.String_List_Access;
Item : String);
-- Append all the strings in List2 to the end of List.
-- The strings in List2 are not duplicated.
-- List might be null initially.
---------------------------
-- C String manipulation --
---------------------------
procedure Copy_String
(Item : Interfaces.C.Strings.chars_ptr;
Str : out String;
Len : Natural);
-- Copy Len characters from Item to Str
----------------------------
-- Arguments manipulation --
----------------------------
function Protect
(S : String;
Protect_Quotes : Boolean := True;
Protect_Spaces : Boolean := False;
Protect_Backslashes : Boolean := True) return String;
-- Escape special characters in S.
-- Quotes are only escaped when Protect_Quotes is true.
-- Spaces are only escaped when Protect_Spaces is true.
function Unprotect (S : String) return String;
-- Unprotect an argument: remove the leading and ending '"',
-- and un-escape the "\" when necessary.
function Unquote (S : String) return String;
-- Remove the leading and ending '"' if present
function Revert (S : String; Separator : String := ".") return String;
-- Given a string S composed of names separated with Separator
-- (e.g. Put_Line.Text_IO.Ada), return the names reversed
-- (e.g. Ada.Text_IO.Put_Line).
----------------------
-- URL manipulation --
----------------------
function URL_Decode (URL : String) return String;
-- Decode URL into a regular string. Many characters are forbiden into an
-- URL and needs to be encoded. A character is encoded by %XY where XY is
-- the character's ASCII hexadecimal code. For example a space is encoded
-- as %20.
function Compare (A, B : String) return Integer;
function Compare (A, B : Integer) return Integer;
-- Return -1 if A<B, 1 if A>B and 0 otherwise. This routine is useful for
-- model specific sorting. The second version does the same comparing
-- integers. Even if not using string, it is better to keep this routine
-- next to the compare based on strings.
----------
-- Hash --
----------
generic
type Header_Num is range <>;
function Hash (Key : String) return Header_Num;
-- A generic hashing function working on String keys
generic
type Header_Num is range <>;
function Case_Insensitive_Hash (Key : String) return Header_Num;
-- A generic hashing function working on case insensitive String keys
private
pragma Inline (Is_Blank);
pragma Inline (Looking_At);
pragma Inline (Skip_To_Char);
pragma Inline (Copy_String);
pragma Inline (Replace);
pragma Inline (Compare);
end String_Utils;
|
29,827
|
ada
| 30
|
jrmarino/AdaBase
|
testcases/traits/traits.adb
|
<reponame>jrmarino/AdaBase<gh_stars>10-100
with Ada.Text_IO;
with Ada.Exceptions;
with AdaBase;
with Connect;
with GNAT.Traceback.Symbolic;
procedure Traits is
package SYM renames GNAT.Traceback.Symbolic;
package TIO renames Ada.Text_IO;
package CON renames Connect;
package EX renames Ada.Exceptions;
-- Database_Driver renames specific driver using subtype
procedure display_versions (driver : CON.Database_Driver);
procedure display_traits (driver : CON.Database_Driver);
procedure display_versions (driver : CON.Database_Driver) is
begin
TIO.Put_Line (" client info: " & driver.trait_client_info);
TIO.Put_Line ("client version: " & driver.trait_client_version);
TIO.Put_Line (" server info: " & driver.trait_server_info);
TIO.Put_Line ("server version: " & driver.trait_server_version);
TIO.Put_Line (" driver: " & driver.trait_driver);
end display_versions;
procedure display_traits (driver : CON.Database_Driver) is
begin
TIO.Put_Line ("");
TIO.Put_Line (" autocommit: " & driver.trait_autocommit'Img);
TIO.Put_Line (" column case: " & driver.trait_column_case'Img);
TIO.Put_Line (" error_mode: " & driver.trait_error_mode'Img);
TIO.Put_Line (" blob_size: " & driver.trait_max_blob_size'Img);
TIO.Put_Line (" multiquery on: " & driver.trait_multiquery_enabled'Img);
TIO.Put_Line (" encoding: " & driver.trait_character_set);
end display_traits;
begin
CON.connect_database;
display_versions (driver => CON.DR);
display_traits (driver => CON.DR);
CON.DR.disconnect;
CON.DR.set_trait_autocommit (trait => True);
CON.DR.set_trait_column_case (trait => AdaBase.upper_case);
CON.DR.set_trait_error_mode (trait => AdaBase.silent);
CON.DR.set_trait_max_blob_size (trait => 2 ** 16);
CON.DR.set_trait_multiquery_enabled (True);
CON.DR.set_trait_character_set ("");
CON.connect_database;
display_traits (driver => CON.DR);
CON.DR.disconnect;
exception
when E : others =>
TIO.Put_Line ("");
TIO.Put_Line ("exception name: " & EX.Exception_Name (E));
TIO.Put_Line ("exception msg : " & EX.Exception_Message (E));
TIO.Put_Line ("Traceback:");
TIO.Put_Line (SYM.Symbolic_Traceback (E));
end Traits;
|
29,828
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/Factorial/Ada/factorial-3.ada
|
<reponame>LaudateCorpus1/RosettaCodeData
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Elementary_Functions;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Text_IO.Complex_Io;
with Ada.Text_Io; use Ada.Text_Io;
procedure Factorial_Numeric_Approximation is
type Real is digits 15;
package Complex_Pck is new Ada.Numerics.Generic_Complex_Types(Real);
use Complex_Pck;
package Complex_Io is new Ada.Text_Io.Complex_Io(Complex_Pck);
use Complex_IO;
package Cmplx_Elem_Funcs is new Ada.Numerics.Generic_Complex_Elementary_Functions(Complex_Pck);
use Cmplx_Elem_Funcs;
function Gamma(X : Complex) return Complex is
package Elem_Funcs is new Ada.Numerics.Generic_Elementary_Functions(Real);
use Elem_Funcs;
use Ada.Numerics;
-- Coefficients used by the GNU Scientific Library
G : Natural := 7;
P : constant array (Natural range 0..G + 1) of Real := (
0.99999999999980993, 676.5203681218851, -1259.1392167224028,
771.32342877765313, -176.61502916214059, 12.507343278686905,
-0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7);
Z : Complex := X;
Cx : Complex;
Ct : Complex;
begin
if Re(Z) < 0.5 then
return Pi / (Sin(Pi * Z) * Gamma(1.0 - Z));
else
Z := Z - 1.0;
Set_Re(Cx, P(0));
Set_Im(Cx, 0.0);
for I in 1..P'Last loop
Cx := Cx + (P(I) / (Z + Real(I)));
end loop;
Ct := Z + Real(G) + 0.5;
return Sqrt(2.0 * Pi) * Ct**(Z + 0.5) * Exp(-Ct) * Cx;
end if;
end Gamma;
function Factorial(N : Complex) return Complex is
begin
return Gamma(N + 1.0);
end Factorial;
Arg : Complex;
begin
Put("factorial(-0.5)**2.0 = ");
Set_Re(Arg, -0.5);
Set_Im(Arg, 0.0);
Put(Item => Factorial(Arg) **2.0, Fore => 1, Aft => 8, Exp => 0);
New_Line;
for I in 0..9 loop
Set_Re(Arg, Real(I));
Set_Im(Arg, 0.0);
Put("factorial(" & Integer'Image(I) & ") = ");
Put(Item => Factorial(Arg), Fore => 6, Aft => 8, Exp => 0);
New_Line;
end loop;
end Factorial_Numeric_Approximation;
|
29,829
|
ada
| 0
|
csb6/libtcod-ada
|
src/libtcod-maps.ads
|
private with Ada.Finalization, fov_types_h;
package Libtcod.Maps is
Error : exception;
type X_Pos is new Interfaces.C.int range 0 .. Interfaces.C.int'Last;
type Y_Pos is new Interfaces.C.int range 0 .. Interfaces.C.int'Last;
type X_Diff is new Interfaces.C.int;
type Y_Diff is new Interfaces.C.Int;
procedure increment(x : in out X_Pos; d : X_Diff);
function "+"(x : X_Pos; d : X_Diff) return X_Pos;
function "-"(x : X_Pos; d : X_Pos) return X_Diff;
procedure increment(y : in out Y_Pos; d : Y_Diff);
function "+"(y : Y_Pos; d : Y_Diff) return Y_Pos;
function "-"(x : Y_Pos; d : Y_Pos) return Y_Diff;
type Radius is range 0 .. Integer'Last;
type Map is tagged limited private;
function make_map(w : Width; h : Height) return Map;
function get_width(m : Map) return Width with Inline;
function get_height(m : Map) return Height with Inline;
function get_cell_count(m : Map) return Natural with Inline;
procedure set_properties_all(m : in out Map; transparent, walkable : Boolean)
with Inline;
procedure set_properties(m : in out Map; x : X_Pos; y : Y_Pos;
transparent, walkable : Boolean) with Inline;
function is_transparent(m : Map; x : X_Pos; y : Y_Pos) return Boolean
with Inline;
function is_walkable(m : Map; x : X_Pos; y : Y_Pos) return Boolean
with Inline;
private
type Map is new Ada.Finalization.Limited_Controlled with record
data : access fov_types_h.TCOD_Map;
end record;
overriding procedure Finalize(m : in out Map);
end Libtcod.Maps;
|
29,830
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-5.ada
|
F1, F2 : File_Type;
begin
Open (F1, In_File, "city.ppm");
Open (F2, In_File, "city_emboss.ppm");
Ada.Text_IO.Put_Line ("Diff" & Float'Image (Diff (Get_PPM (F1), Get_PPM (F2))));
Close (F1);
Close (F2);
|
29,831
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/support/impbit.adb
|
with System;
with Ada.Text_IO;
procedure Impbit is
begin
Ada.Text_IO.Put_Line (System.Address'Size'Img);
end Impbit;
|
29,832
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/array29.adb
|
<gh_stars>1-10
-- { dg-do compile }
-- { dg-options "-O" }
package body Array29 is
procedure Copy (Src : in Matrix; Dst : out Matrix) is
begin
for I in Src'Range (1) loop
for J in Src'Range (2) loop
Dst (I, J) := Src (I, J);
end loop;
end loop;
end;
procedure Proc is
N : constant := 2;
FM1 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
FM2 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
A : constant array (1 .. 2) of Matrix (1 .. N, 1 .. N)
:= (Matrix (FM1), Matrix (FM2));
Final : Matrix (1 .. N, 1 .. N);
begin
Copy (Src => A (1), Dst => Final);
end;
end Array29;
|
29,833
|
ada
| 32
|
robdaemon/AdaYaml
|
test/src/yaml-lexer-tokenization_test.ads
|
<reponame>robdaemon/AdaYaml<filename>test/src/yaml-lexer-tokenization_test.ads<gh_stars>10-100
-- part of AdaYaml, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "copying.txt"
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
package Yaml.Lexer.Tokenization_Test is
type TC is new Test_Cases.Test_Case with record
Pool : Text.Pool.Reference;
end record;
overriding procedure Register_Tests (T : in out TC);
overriding procedure Set_Up (T : in out TC);
function Name (T : TC) return Message_String;
procedure Empty_Document (T : in out Test_Cases.Test_Case'Class);
procedure Single_Line_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Single_Line_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Explicit_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Sequence (T : in out Test_Cases.Test_Case'Class);
procedure Sequence_With_Block_Mappings (T : in out Test_Cases.Test_Case'Class);
procedure Single_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Single_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Double_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Double_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Escape_Sequences (T : in out Test_Cases.Test_Case'Class);
procedure Block_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Block_Scalars (T : in out Test_Cases.Test_Case'Class);
procedure Directives (T : in out Test_Cases.Test_Case'Class);
procedure Markers (T : in out Test_Cases.Test_Case'Class);
procedure Flow_Indicators (T : in out Test_Cases.Test_Case'Class);
procedure Adjacent_Map_Values (T : in out Test_Cases.Test_Case'Class);
procedure Tag_Handles (T : in out Test_Cases.Test_Case'Class);
procedure Verbatim_Tag_Handle (T : in out Test_Cases.Test_Case'Class);
procedure Anchors_And_Aliases (T : in out Test_Cases.Test_Case'Class);
procedure Empty_Lines (T : in out Test_Cases.Test_Case'Class);
end Yaml.Lexer.Tokenization_Test;
|
29,834
|
ada
| 33
|
persan/zeromq-Ada
|
eBindings/dl/tests/dl-test_all_suit.ads
|
with AUnit.Test_Suites;
package Dl.Test_All_Suit is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
-- Return the test suite
end Dl.Test_All_Suit;
|
29,835
|
ada
| 2
|
adithyap/coursework
|
ProgrammingLanguages/Ada/MergeSort/progmain.adb
|
with Text_Io;
with sort;
-- ------------------
procedure progmain is
-- Package usage declarations
use Text_Io;
use sort;
package Int_Io is new Integer_Io(Integer);
use Int_Io;
-- Variable declarations
A : m_array;
input_var : Integer;
array_sum : Integer;
-- Task declarations
task Reader is
entry start;
end Reader;
task Sum is
entry start;
end Sum;
task Printer is
entry start;
end Printer;
-- Task definitions
-- -----------------
task body Reader is
begin
accept start do
for i in 1..SIZE loop
Int_Io.Get(input_var);
A(i) := input_var;
end loop;
end start;
end Reader;
-- -----------------
-- -----------------
task body Sum is
begin
accept start do
null;
end start;
array_sum := 0;
for i in 1..SIZE loop
array_sum := array_sum + A(i);
end loop;
Put("Array sum: ");
Int_Io.Put(array_sum);
end Sum;
-- -----------------
-- -----------------
task body Printer is
begin
accept start do
null;
end start;
Put("Sorted array: ");
New_Line;
for i in 1..SIZE loop
Int_Io.Put(A(i));
end loop;
end Printer;
-- -----------------
begin
Reader.start;
MergeSort(A);
Sum.start;
Printer.start;
end progmain;
-- ------------------
|
29,836
|
ada
| 24
|
svn2github/matreshka
|
tools/documentation_generator/documentation_generator.ads
|
package Documentation_Generator is
pragma Pure;
end Documentation_Generator;
|
29,837
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c37210a.ada
|
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c37210a.ada
-- C37210A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT THE EXPRESSION IN A DISCRIMINANT ASSOCIATION WITH MORE
-- THAN ONE NAME IS EVALUATED ONCE FOR EACH NAME.
-- R.WILLIAMS 8/28/86
WITH REPORT; USE REPORT;
PROCEDURE C37210A IS
BUMP : INTEGER := IDENT_INT (0);
FUNCTION F RETURN INTEGER IS
BEGIN
BUMP := BUMP + 1;
RETURN BUMP;
END F;
FUNCTION CHECK (STR : STRING) RETURN INTEGER IS
BEGIN
IF BUMP /= 2 THEN
FAILED ( "INCORRECT DISCRIMINANT VALUES FOR " & STR);
END IF;
BUMP := IDENT_INT (0);
RETURN 5;
END CHECK;
BEGIN
TEST ( "C37210A", "CHECK THAT THE EXPRESSION IN A " &
"DISCRIMINANT ASSOCIATION WITH MORE THAN " &
"ONE NAME IS EVALUATED ONCE FOR EACH NAME" );
DECLARE
TYPE REC (D1, D2 : INTEGER) IS
RECORD
NULL;
END RECORD;
R : REC (D1 | D2 => F);
I1 : INTEGER := CHECK ( "R" );
TYPE ACC IS ACCESS REC;
AC : ACC (D1 | D2 => F);
I2 : INTEGER := CHECK ( "AC" );
PACKAGE PKG IS
TYPE PRIV (D1, D2 : INTEGER) IS PRIVATE;
TYPE PACC IS ACCESS PRIV;
TYPE LIM (D1, D2 : INTEGER) IS LIMITED PRIVATE;
TYPE LACC IS ACCESS LIM;
PRIVATE
TYPE PRIV (D1, D2 : INTEGER) IS
RECORD
NULL;
END RECORD;
TYPE LIM (D1, D2 : INTEGER) IS
RECORD
NULL;
END RECORD;
END PKG;
USE PKG;
BEGIN
DECLARE
P : PRIV (D1 | D2 => F);
I1 : INTEGER := CHECK ( "P" );
PA : PACC (D1 | D2 => F);
I2 : INTEGER := CHECK ( "PA" );
L : LIM (D1 | D2 => F);
I3 : INTEGER := CHECK ( "L" );
LA : LACC (D1 | D2 => F);
I : INTEGER;
BEGIN
I := CHECK ( "LA" );
END;
END;
RESULT;
END C37210A;
|
29,838
|
ada
| 9
|
stcarrez/ada-search
|
regtests/search-tokens-tests.adb
|
<reponame>stcarrez/ada-search
-----------------------------------------------------------------------
-- search-tokens-tests -- Tests for tokens
-- Copyright (C) 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with Search.Tokens.Factories.Default;
package body Search.Tokens.Tests is
package Caller is new Util.Test_Caller (Test, "Search.Tokens");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Search.Tokens.Factories",
Test_Create_Token'Access);
end Add_Tests;
procedure Test_Create_Token (T : in out Test) is
F : Search.Tokens.Factories.Default.Token_Factory;
Token1 : Search.Tokens.Token_Type;
Token2 : Search.Tokens.Token_Type;
Token3 : Search.Tokens.Token_Type;
begin
F.Create ("word", Token1);
T.Assert_Equals ("word", Token1.Get_Value, "Get_Value failed");
F.Create ("word", Token2);
T.Assert_Equals ("word", Token2.Get_Value, "Get_Value failed");
T.Assert (Token1 = Token2, "Token are different");
F.Create ("item", Token3);
T.Assert_Equals ("item", Token3.Get_Value, "Get_Value failed");
T.Assert (Token1 /= Token3, "Token are different");
end Test_Create_Token;
end Search.Tokens.Tests;
|
29,839
|
ada
| 33
|
ytomino/drake
|
examples/socket_client.adb
|
with Ada.Streams.Stream_IO.Sockets;
with Ada.Text_IO;
procedure socket_client is
begin
declare
End_Point : constant Ada.Streams.Stream_IO.Sockets.End_Point :=
Ada.Streams.Stream_IO.Sockets.Resolve ("google.com", 80);
File : Ada.Streams.Stream_IO.File_Type :=
Ada.Streams.Stream_IO.Sockets.Connect (End_Point);
-- [gcc-4.7] Connect (Resolve (...)) causes too early finalization
begin
pragma Assert (Ada.Streams.Stream_IO.Is_Open (File));
pragma Assert (Ada.Streams.Stream_IO.Stream (File).all
not in Ada.Streams.Seekable_Stream_Type);
String'Write (
Ada.Streams.Stream_IO.Stream (File),
"GET / HTTP/1.0" & ASCII.LF & ASCII.LF);
declare
C : Character;
begin
loop
Character'Read (
Ada.Streams.Stream_IO.Stream (File),
C);
Ada.Text_IO.Put (C);
end loop;
exception
when Ada.Streams.Stream_IO.End_Error => null;
end;
end;
pragma Debug (Ada.Debug.Put ("OK"));
end socket_client;
|
29,840
|
ada
| 1
|
vidkidz/crossbridge
|
llvm-gcc-4.2-2.9/gcc/ada/s-stchop.ads
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . S T A C K _ C H E C K I N G . O P E R A T I O N S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2005 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 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides a implementation of stack checking operations
-- using comparison with stack base and limit.
pragma Restrictions (No_Elaboration_Code);
-- We want to guarantee the absence of elaboration code because the
-- binder does not handle references to this package.
pragma Polling (Off);
-- Turn off polling, we do not want polling to take place during stack
-- checking operations. It causes infinite loops and other problems.
package System.Stack_Checking.Operations is
procedure Update_Stack_Cache (Stack : Stack_Access);
-- Set the stack cache for the current task. Note that this is only
-- for optimization purposes, nothing can be assumed about the
-- contents of the cache at any time, see Set_Stack_Info.
procedure Invalidate_Stack_Cache (Any_Stack : Stack_Access);
-- Invalidate cache entries for the task T that owns Any_Stack.
-- This causes the Set_Stack_Info function to be called during
-- the next stack check done by T. This can be used to interrupt
-- task T asynchronously.
-- Stack_Check should be called in loops for this to work reliably.
function Stack_Check (Stack_Address : System.Address) return Stack_Access;
-- This version of Stack_Check should not be inlined.
private
Cache : aliased Stack_Access := Null_Stack;
pragma Export (C, Cache, "_gnat_stack_cache");
pragma Export (C, Stack_Check, "_gnat_stack_check");
end System.Stack_Checking.Operations;
|
29,841
|
ada
| 60
|
jquorning/ada-util
|
src/sys/serialize/xml/util-serialize-io-xml.adb
|
<filename>src/sys/serialize/xml/util-serialize-io-xml.adb
-----------------------------------------------------------------------
-- util-serialize-io-xml -- XML Serialization Driver
-- Copyright (C) 2011, 2012, 2013, 2016, 2017, 2020, 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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.Characters.Conversions;
with Unicode;
with Unicode.CES.Utf8;
with Util.Log.Loggers;
with Util.Strings;
with Util.Dates.ISO8601;
with Util.Streams.Texts.TR;
with Util.Streams.Texts.WTR;
with Util.Beans.Objects.Maps;
package body Util.Serialize.IO.XML is
use Sax.Readers;
use Sax.Exceptions;
use Sax.Locators;
use Sax.Attributes;
use Unicode;
use Unicode.CES;
use Ada.Strings.Unbounded;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Serialize.IO.XML");
-- Return the location where the exception was raised.
function Get_Location (Except : Sax.Exceptions.Sax_Parse_Exception'Class)
return String is separate;
-- ------------------------------
-- Warning
-- ------------------------------
overriding
procedure Warning (Handler : in out Xhtml_Reader;
Except : Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Warn ("{0}", Get_Message (Except));
end Warning;
-- ------------------------------
-- Error
-- ------------------------------
overriding
procedure Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
Msg : constant String := Get_Message (Except);
Pos : constant Natural := Util.Strings.Index (Msg, ' ');
begin
-- The SAX error message contains the line+file name. Remove it because this part
-- will be added by the <b>Error</b> procedure.
if Pos > Msg'First and then Msg (Pos - 1) = ':' then
Handler.Handler.Error (Msg (Pos + 1 .. Msg'Last));
else
Handler.Handler.Error (Msg);
end if;
end Error;
-- ------------------------------
-- Fatal_Error
-- ------------------------------
overriding
procedure Fatal_Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
begin
Handler.Error (Except);
end Fatal_Error;
-- ------------------------------
-- Set_Document_Locator
-- ------------------------------
overriding
procedure Set_Document_Locator (Handler : in out Xhtml_Reader;
Loc : in out Sax.Locators.Locator) is
begin
Handler.Handler.Locator := Loc;
end Set_Document_Locator;
-- ------------------------------
-- Start_Document
-- ------------------------------
overriding
procedure Start_Document (Handler : in out Xhtml_Reader) is
begin
null;
end Start_Document;
-- ------------------------------
-- End_Document
-- ------------------------------
overriding
procedure End_Document (Handler : in out Xhtml_Reader) is
begin
null;
end End_Document;
-- ------------------------------
-- Start_Prefix_Mapping
-- ------------------------------
overriding
procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence;
URI : in Unicode.CES.Byte_Sequence) is
begin
null;
end Start_Prefix_Mapping;
-- ------------------------------
-- End_Prefix_Mapping
-- ------------------------------
overriding
procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence) is
begin
null;
end End_Prefix_Mapping;
-- ------------------------------
-- Start_Element
-- ------------------------------
overriding
procedure Start_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "";
Atts : in Sax.Attributes.Attributes'Class) is
pragma Unreferenced (Namespace_URI, Qname);
Attr_Count : Natural;
begin
Log.Debug ("Start object {0}", Local_Name);
Handler.Sink.Start_Object (Local_Name, Handler.Handler.all);
Attr_Count := Get_Length (Atts);
for I in 0 .. Attr_Count - 1 loop
declare
Name : constant String := Get_Qname (Atts, I);
Value : constant String := Get_Value (Atts, I);
begin
Handler.Sink.Set_Member (Name => Name,
Value => Util.Beans.Objects.To_Object (Value),
Logger => Handler.Handler.all,
Attribute => True);
end;
end loop;
end Start_Element;
-- ------------------------------
-- End_Element
-- ------------------------------
overriding
procedure End_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "") is
pragma Unreferenced (Namespace_URI, Qname);
Len : constant Natural := Length (Handler.Text);
begin
Handler.Sink.Finish_Object (Local_Name, Handler.Handler.all);
if Len > 0 then
-- Add debug message only when it is active (saves the To_String conversion).
if Log.Get_Level >= Util.Log.DEBUG_LEVEL then
Log.Debug ("Close object {0} -> {1}", Local_Name, To_String (Handler.Text));
end if;
Handler.Sink.Set_Member (Local_Name, Util.Beans.Objects.To_Object (Handler.Text),
Handler.Handler.all);
-- Clear the string using Delete so that the buffer is kept.
Ada.Strings.Unbounded.Delete (Source => Handler.Text, From => 1, Through => Len);
else
Log.Debug ("Close object {0}", Local_Name);
Handler.Sink.Set_Member (Local_Name, Util.Beans.Objects.To_Object (Handler.Text),
Handler.Handler.all);
end if;
end End_Element;
procedure Collect_Text (Handler : in out Xhtml_Reader;
Content : Unicode.CES.Byte_Sequence) is
begin
Append (Handler.Text, Content);
end Collect_Text;
-- ------------------------------
-- Characters
-- ------------------------------
overriding
procedure Characters (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
Collect_Text (Handler, Ch);
end Characters;
-- ------------------------------
-- Ignorable_Whitespace
-- ------------------------------
overriding
procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
if not Handler.Ignore_White_Spaces then
Collect_Text (Handler, Ch);
end if;
end Ignorable_Whitespace;
-- ------------------------------
-- Processing_Instruction
-- ------------------------------
overriding
procedure Processing_Instruction (Handler : in out Xhtml_Reader;
Target : in Unicode.CES.Byte_Sequence;
Data : in Unicode.CES.Byte_Sequence) is
pragma Unreferenced (Handler);
begin
Log.Error ("Processing instruction: {0}: {1}", Target, Data);
end Processing_Instruction;
-- ------------------------------
-- Skipped_Entity
-- ------------------------------
overriding
procedure Skipped_Entity (Handler : in out Xhtml_Reader;
Name : in Unicode.CES.Byte_Sequence) is
pragma Unmodified (Handler);
begin
null;
end Skipped_Entity;
-- ------------------------------
-- Start_Cdata
-- ------------------------------
overriding
procedure Start_Cdata (Handler : in out Xhtml_Reader) is
pragma Unmodified (Handler);
pragma Unreferenced (Handler);
begin
Log.Info ("Start CDATA");
end Start_Cdata;
-- ------------------------------
-- End_Cdata
-- ------------------------------
overriding
procedure End_Cdata (Handler : in out Xhtml_Reader) is
pragma Unmodified (Handler);
pragma Unreferenced (Handler);
begin
Log.Info ("End CDATA");
end End_Cdata;
-- ------------------------------
-- Resolve_Entity
-- ------------------------------
overriding
function Resolve_Entity (Handler : Xhtml_Reader;
Public_Id : Unicode.CES.Byte_Sequence;
System_Id : Unicode.CES.Byte_Sequence)
return Input_Sources.Input_Source_Access is
pragma Unreferenced (Handler);
begin
Log.Error ("Cannot resolve entity {0} - {1}", Public_Id, System_Id);
return null;
end Resolve_Entity;
overriding
procedure Start_DTD (Handler : in out Xhtml_Reader;
Name : Unicode.CES.Byte_Sequence;
Public_Id : Unicode.CES.Byte_Sequence := "";
System_Id : Unicode.CES.Byte_Sequence := "") is
begin
null;
end Start_DTD;
-- ------------------------------
-- Set the XHTML reader to ignore or not the white spaces.
-- When set to True, the ignorable white spaces will not be kept.
-- ------------------------------
procedure Set_Ignore_White_Spaces (Reader : in out Parser;
Value : in Boolean) is
begin
Reader.Ignore_White_Spaces := Value;
end Set_Ignore_White_Spaces;
-- ------------------------------
-- Set the XHTML reader to ignore empty lines.
-- ------------------------------
procedure Set_Ignore_Empty_Lines (Reader : in out Parser;
Value : in Boolean) is
begin
Reader.Ignore_Empty_Lines := Value;
end Set_Ignore_Empty_Lines;
-- ------------------------------
-- Get the current location (file and line) to report an error message.
-- ------------------------------
function Get_Location (Handler : in Parser) return String is
File : constant String := Util.Serialize.IO.Parser (Handler).Get_Location;
begin
if Handler.Locator = Sax.Locators.No_Locator then
return File;
else
return File & Sax.Locators.To_String (Handler.Locator);
end if;
end Get_Location;
-- ------------------------------
-- Parse an XML stream, and calls the appropriate SAX callbacks for each
-- event.
-- This is not re-entrant: you can not call Parse with the same Parser
-- argument in one of the SAX callbacks. This has undefined behavior.
-- ------------------------------
-- Parse the stream using the JSON parser.
procedure Parse (Handler : in out Parser;
Stream : in out Util.Streams.Buffered.Input_Buffer_Stream'Class;
Sink : in out Reader'Class) is
Buffer_Size : constant Positive := 256;
type String_Access is access all String (1 .. Buffer_Size);
type Stream_Input is new Input_Sources.Input_Source with record
Index : Natural;
Last : Natural;
Encoding : Unicode.CES.Encoding_Scheme;
Buffer : String_Access;
end record;
-- Return the next character in the string.
procedure Next_Char (From : in out Stream_Input;
C : out Unicode.Unicode_Char);
-- True if From is past the last character in the string.
function Eof (From : in Stream_Input) return Boolean;
procedure Fill (From : in out Stream_Input'Class);
procedure Fill (From : in out Stream_Input'Class) is
Last : Natural := From.Last;
begin
-- Move to the buffer start
if Last > From.Index and From.Index > From.Buffer'First then
From.Buffer (From.Buffer'First .. Last - 1 - From.Index + From.Buffer'First) :=
From.Buffer (From.Index .. Last - 1);
Last := Last - From.Index + From.Buffer'First;
From.Index := From.Buffer'First;
end if;
if From.Index > From.Last then
From.Index := From.Buffer'First;
end if;
begin
while not Stream.Is_Eof loop
Stream.Read (From.Buffer (Last));
Last := Last + 1;
exit when Last > From.Buffer'Last;
end loop;
exception
when others =>
null;
end;
From.Last := Last;
end Fill;
-- Return the next character in the string.
procedure Next_Char (From : in out Stream_Input;
C : out Unicode.Unicode_Char) is
begin
if From.Index + 6 >= From.Last then
Fill (From);
end if;
From.Encoding.Read (From.Buffer.all, From.Index, C);
end Next_Char;
-- True if From is past the last character in the string.
function Eof (From : in Stream_Input) return Boolean is
begin
if From.Index < From.Last then
return False;
end if;
return Stream.Is_Eof;
end Eof;
Input : Stream_Input;
Xml_Parser : Xhtml_Reader;
Buf : aliased String (1 .. Buffer_Size);
begin
Input.Buffer := Buf'Access;
Input.Index := Buf'First + 1;
Input.Last := Buf'First;
Input.Set_Encoding (Unicode.CES.Utf8.Utf8_Encoding);
Input.Encoding := Unicode.CES.Utf8.Utf8_Encoding;
Xml_Parser.Handler := Handler'Unchecked_Access;
Xml_Parser.Ignore_White_Spaces := Handler.Ignore_White_Spaces;
Xml_Parser.Ignore_Empty_Lines := Handler.Ignore_Empty_Lines;
Xml_Parser.Sink := Sink'Unchecked_Access;
Sax.Readers.Reader (Xml_Parser).Parse (Input);
Handler.Locator := Sax.Locators.No_Locator;
-- Ignore the Program_Error exception that SAX could raise if we know that the
-- error was reported.
exception
when Program_Error =>
Handler.Locator := Sax.Locators.No_Locator;
if not Handler.Has_Error then
raise;
end if;
when others =>
Handler.Locator := Sax.Locators.No_Locator;
raise;
end Parse;
-- Close the current XML entity if an entity was started
procedure Close_Current (Stream : in out Output_Stream'Class;
Indent : in Boolean);
-- ------------------------------
-- Close the current XML entity if an entity was started
-- ------------------------------
procedure Close_Current (Stream : in out Output_Stream'Class;
Indent : in Boolean) is
begin
if Stream.Close_Start then
Stream.Write ('>');
Stream.Close_Start := False;
end if;
if Indent then
if Stream.Indent /= 0 then
Stream.Write (ASCII.LF);
end if;
for I in 1 .. Stream.Level loop
Stream.Write (' ');
end loop;
end if;
end Close_Current;
-- -----------------------
-- Set the target output stream.
-- -----------------------
procedure Initialize (Stream : in out Output_Stream;
Output : in Util.Streams.Texts.Print_Stream_Access) is
begin
Stream.Stream := Output;
end Initialize;
-- -----------------------
-- Flush the buffer (if any) to the sink.
-- -----------------------
overriding
procedure Flush (Stream : in out Output_Stream) is
begin
Stream.Stream.Flush;
end Flush;
-- -----------------------
-- Close the sink.
-- -----------------------
overriding
procedure Close (Stream : in out Output_Stream) is
begin
Stream.Stream.Close;
end Close;
-- -----------------------
-- Write the buffer array to the output stream.
-- -----------------------
overriding
procedure Write (Stream : in out Output_Stream;
Buffer : in Ada.Streams.Stream_Element_Array) is
begin
Stream.Stream.Write (Buffer);
end Write;
-- ------------------------------
-- Write a character on the response stream and escape that character as necessary.
-- ------------------------------
procedure Write_Escape (Stream : in out Output_Stream'Class;
Char : in Wide_Wide_Character) is
type Unicode_Char is mod 2**32;
Code : constant Unicode_Char := Wide_Wide_Character'Pos (Char);
begin
-- If "?" or over, no escaping is needed (this covers
-- most of the Latin alphabet)
if Code >= 16#80# then
Stream.Write_Wide (Char);
elsif Code > 16#3F# or Code <= 16#20# then
Stream.Write (Character'Val (Code));
elsif Char = '<' then
Stream.Write ("<");
elsif Char = '>' then
Stream.Write (">");
elsif Char = '&' then
Stream.Write ("&");
else
Stream.Write (Character'Val (Code));
end if;
end Write_Escape;
-- ------------------------------
-- Write the value as a XML string. Special characters are escaped using the XML
-- escape rules.
-- ------------------------------
procedure Write_String (Stream : in out Output_Stream;
Value : in String) is
begin
Close_Current (Stream, False);
for I in Value'Range loop
Stream.Write_Escape (Ada.Characters.Conversions.To_Wide_Wide_Character (Value (I)));
end loop;
end Write_String;
-- ------------------------------
-- Write the value as a XML string. Special characters are escaped using the XML
-- escape rules.
-- ------------------------------
procedure Write_Wide_String (Stream : in out Output_Stream;
Value : in Wide_Wide_String) is
begin
Close_Current (Stream, False);
for I in Value'Range loop
Stream.Write_Escape (Value (I));
end loop;
end Write_Wide_String;
-- ------------------------------
-- Write the value as a XML string. Special characters are escaped using the XML
-- escape rules.
-- ------------------------------
procedure Write_String (Stream : in out Output_Stream;
Value : in Util.Beans.Objects.Object) is
use Util.Beans.Objects;
begin
Close_Current (Stream, False);
case Util.Beans.Objects.Get_Type (Value) is
when TYPE_NULL =>
null;
when TYPE_BOOLEAN =>
if Util.Beans.Objects.To_Boolean (Value) then
Stream.Write ("true");
else
Stream.Write ("false");
end if;
when TYPE_INTEGER =>
Stream.Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value));
when others =>
Stream.Write_String (Util.Beans.Objects.To_String (Value));
end case;
end Write_String;
-- ------------------------------
-- Start a new XML object.
-- ------------------------------
procedure Start_Entity (Stream : in out Output_Stream;
Name : in String) is
begin
Close_Current (Stream, True);
Stream.Close_Start := True;
Stream.Is_Closed := False;
Stream.Write ('<');
Stream.Write (Name);
Stream.Level := Stream.Level + 1;
end Start_Entity;
-- ------------------------------
-- Terminates the current XML object.
-- ------------------------------
procedure End_Entity (Stream : in out Output_Stream;
Name : in String) is
begin
Stream.Level := Stream.Level - 1;
Close_Current (Stream, Stream.Is_Closed);
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end End_Entity;
-- ------------------------------
-- Write the attribute name/value pair.
-- ------------------------------
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
Stream.Write (' ');
Stream.Write (Name);
Stream.Write ("=""");
Util.Streams.Texts.TR.Escape_Xml (Content => Value, Into => Stream.Stream.all);
Stream.Write ('"');
end Write_Attribute;
overriding
procedure Write_Wide_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is
begin
Stream.Write (' ');
Stream.Write (Name);
Stream.Write ("=""");
Util.Streams.Texts.WTR.Escape_Xml (Content => Value, Into => Stream.Stream.all);
Stream.Write ('"');
end Write_Wide_Attribute;
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is
begin
Stream.Write (' ');
Stream.Write (Name);
Stream.Write ("=""");
Stream.Stream.Write (Value);
Stream.Write ('"');
end Write_Attribute;
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is
begin
Stream.Write (' ');
Stream.Write (Name);
if Value then
Stream.Write ("=""true""");
else
Stream.Write ("=""false""");
end if;
end Write_Attribute;
-- ------------------------------
-- Write a XML name/value attribute.
-- ------------------------------
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is
use Util.Beans.Objects;
begin
Stream.Write (' ');
Stream.Write (Name);
Stream.Write ("=""");
case Util.Beans.Objects.Get_Type (Value) is
when TYPE_NULL =>
null;
when TYPE_BOOLEAN =>
if Util.Beans.Objects.To_Boolean (Value) then
Stream.Write ("true");
else
Stream.Write ("false");
end if;
when TYPE_INTEGER =>
Stream.Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value));
when others =>
Stream.Write (Util.Beans.Objects.To_String (Value));
end case;
Stream.Write ('"');
end Write_Attribute;
-- ------------------------------
-- Write the attribute with a null value.
-- ------------------------------
overriding
procedure Write_Null_Attribute (Stream : in out Output_Stream;
Name : in String) is
begin
null;
end Write_Null_Attribute;
-- ------------------------------
-- Write the entity value.
-- ------------------------------
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Close_Start := True;
Stream.Write_String (Value);
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end Write_Entity;
overriding
procedure Write_Wide_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is
begin
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Close_Start := True;
Stream.Write_Wide_String (Value);
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end Write_Wide_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is
begin
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
if Value then
Stream.Write (">true</");
else
Stream.Write (">false</");
end if;
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end Write_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is
begin
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Write ('>');
Stream.Stream.Write (Value);
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end Write_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Ada.Calendar.Time) is
begin
Stream.Write_Entity (Name, Util.Dates.ISO8601.Image (Value, Util.Dates.ISO8601.SUBSECOND));
end Write_Entity;
overriding
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Integer) is
begin
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Write ('>');
Stream.Stream.Write (Value);
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end Write_Long_Entity;
overriding
procedure Write_Enum_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
Stream.Write_Entity (Name, Value);
end Write_Enum_Entity;
-- ------------------------------
-- Write a XML name/value entity (see Write_Attribute).
-- ------------------------------
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is
use Util.Beans.Objects;
begin
case Util.Beans.Objects.Get_Type (Value) is
when TYPE_NULL =>
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Close_Start := True;
Stream.Write ("null");
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
when TYPE_BOOLEAN =>
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Close_Start := True;
if Util.Beans.Objects.To_Boolean (Value) then
Stream.Write ("true");
else
Stream.Write ("false");
end if;
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
when TYPE_INTEGER =>
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Close_Start := True;
Stream.Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value));
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
when TYPE_BEAN | TYPE_ARRAY =>
if Is_Array (Value) then
declare
Count : constant Natural := Util.Beans.Objects.Get_Count (Value);
begin
Close_Current (Stream, False);
for I in 1 .. Count loop
Stream.Write_Entity (Name, Util.Beans.Objects.Get_Value (Value, I));
end loop;
end;
else
declare
procedure Process (Name : in String; Item : in Object);
procedure Process (Name : in String; Item : in Object) is
begin
Stream.Write_Entity (Name, Item);
end Process;
begin
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Close_Start := True;
Util.Beans.Objects.Maps.Iterate (Value, Process'Access);
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end;
end if;
when others =>
Close_Current (Stream, True);
Stream.Write ('<');
Stream.Write (Name);
Stream.Close_Start := True;
Stream.Write_String (Util.Beans.Objects.To_String (Value));
Stream.Write ("</");
Stream.Write (Name);
Stream.Write ('>');
Stream.Is_Closed := True;
end case;
end Write_Entity;
-- ------------------------------
-- Write an entity with a null value.
-- ------------------------------
overriding
procedure Write_Null_Entity (Stream : in out Output_Stream;
Name : in String) is
begin
null;
end Write_Null_Entity;
-- ------------------------------
-- Starts a XML array.
-- ------------------------------
overriding
procedure Start_Array (Stream : in out Output_Stream;
Name : in String) is
pragma Unreferenced (Stream, Name);
begin
null;
end Start_Array;
-- ------------------------------
-- Terminates a XML array.
-- ------------------------------
overriding
procedure End_Array (Stream : in out Output_Stream;
Name : in String) is
begin
null;
end End_Array;
-- ------------------------------
-- Set the indentation level when writing XML entities.
-- ------------------------------
procedure Set_Indentation (Stream : in out Output_Stream;
Count : in Natural) is
begin
Stream.Indent := Count;
end Set_Indentation;
end Util.Serialize.IO.XML;
|
29,842
|
ada
| 1
|
jorge-real/TTS
|
examples/tts_example2.adb
|
<reponame>jorge-real/TTS<gh_stars>1-10
with System;
with Ada.Real_Time; use Ada.Real_Time;
with Time_Triggered_Scheduling; -- use Time_Triggered_Scheduling;
-- The following packages are for tracing and timing support
with Ada.Exceptions; use Ada.Exceptions;
with Logging_Support; use Logging_Support;
with Use_CPU; use Use_CPU;
with Ada.Text_IO; use Ada.Text_IO;
with Epoch_Support; use Epoch_Support;
with STM32.Board; use STM32.Board;
-- with Stats;
package body TTS_Example2 is
-- package MyStats is new Stats (5);
-- Instantiation of generic TT scheduler
No_Of_TT_Works : constant := 3;
package TT_Scheduler is new Time_Triggered_Scheduling (No_Of_TT_Works);
use TT_Scheduler;
function New_Slot (ms : Natural;
WId : Any_Work_Id;
Slot_Separation : Natural := 0) return Time_Slot;
function New_Slot (ms : Natural;
WId : Any_Work_Id;
Slot_Separation : Natural := 0) return Time_Slot is
Slot : Time_Slot;
begin
Slot.Slot_Duration := Milliseconds (ms);
Slot.Work_Id := WId;
Slot.Next_Slot_Separation := Milliseconds (Slot_Separation);
return Slot;
end New_Slot;
----------------------------
-- Time-triggered plans --
----------------------------
TTP1 : aliased Time_Triggered_Plan :=
(
New_Slot (30, 1),
New_Slot (70, Empty_Slot),
New_Slot (60, 2),
New_Slot (40, Empty_Slot),
New_Slot (90, 3),
New_Slot (10, Mode_Change_Slot)
);
TTP2 : aliased Time_Triggered_Plan :=
(
New_Slot (90, 3),
New_Slot (10, Empty_Slot),
New_Slot (60, 2),
New_Slot (40, Empty_Slot),
New_Slot (30, 1),
New_Slot (70, Mode_Change_Slot)
);
Null_Plan : aliased Time_Triggered_Plan :=
(
0 => New_Slot (100, Empty_Slot),
1 => New_Slot (100, Mode_Change_Slot)
);
-------------------
-- Task Patterns --
-------------------
-- A basic TT task
task type Basic_TT_Task (Work_Id : Regular_Work_Id;
Execution_Time_MS : Natural)
with Priority => System.Priority'Last is
end Basic_TT_Task;
task body Basic_TT_Task is
Work_To_Be_Done : constant Natural := Execution_Time_MS;
LED_To_Turn : User_LED;
When_Was_Released : Time;
-- Jitter : Time_Span;
begin
case Work_Id is
when 1 =>
LED_To_Turn := Red_LED;
when 2 =>
LED_To_Turn := Blue_LED;
when 3 =>
LED_To_Turn := Green_LED;
end case;
loop
Wait_For_Activation (Work_Id, When_Was_Released);
-- Jitter := Clock - When_Was_Released;
-- Log (No_Event, "|---> Jitter of Worker" & Integer'Image (Integer (Work_Id)) &
-- " = " & Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- MyStats.Register_Time(Integer(Work_Id)*2-1, Jitter);
Set (Probe_TT_Point);
Turn_On (LED_To_Turn);
Work (Work_To_Be_Done);
Turn_Off (LED_To_Turn);
Clear (Probe_TT_Point);
-- Log (Stop_Task, "W" & Character'Val (Character'Pos ('0') + Integer (Work_Id)));
end loop;
exception
when E : others =>
Put_Line ("Periodic worker W" & Character'Val (Character'Pos ('0') + Integer (Work_Id)) &
": " & Exception_Message (E));
end Basic_TT_Task;
-------------------------------
-- Priority scheduled tasks --
-------------------------------
task type DM_Task (Id : Natural; Period : Integer; Prio : System.Priority)
with Priority => Prio;
task body DM_Task is
Next : Time := Epoch;
Per : constant Time_Span := Milliseconds (Period);
Jitter : Time_Span;
begin
loop
delay until Next;
Jitter := Clock - Next;
Log (No_Event, "|---------> Jitter of DM Task" & Integer'Image (Id) &
" = " & Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- MyStats.Register_Time(Integer(Id)*2-1, Jitter);
-- Log (Start_Task, "T" & Character'Val (Character'Pos ('0') + Integer (Id)));
Set (Probe_ET_Point);
Turn_On (Orange_LED);
Work (5);
Next := Next + Per;
Turn_Off (Orange_LED);
Clear (Probe_ET_Point);
-- Log (Stop_Task, "T" & Character'Val (Character'Pos ('0') + Integer (Id)));
end loop;
exception
when E : others =>
Put_Line (Exception_Message (E));
end DM_Task;
-- Event-triggered tasks
T4 : DM_Task (Id => 4, Period => 90, Prio => System.Priority'First + 1);
T5 : DM_Task (Id => 5, Period => 210, Prio => System.Priority'First);
-- Time-triggered tasks
-- Work_ID, Execution (ms)
Wk1 : Basic_TT_Task (1, 20);
Wk2 : Basic_TT_Task (2, 40);
Wk3 : Basic_TT_Task (3, 60);
procedure Main is
K : Integer := 0; -- Number of iterations in main loop
begin
-- Generate trace header --
Log (No_Event, "1 M1"); -- Nr of modes
Log (No_Event, "5"); -- Nr of works + Nr of tasks
Log (No_Event, "W1 9.200 9.200 0.0 10"); -- Task_name Period Deadline Phasing Priority
Log (No_Event, "W2 9.200 9.200 0.0 9");
Log (No_Event, "W3 9.200 9.200 0.0 8");
Log (No_Event, "T4 0.600 0.600 0.0 5");
Log (No_Event, "T5 0.800 0.800 0.0 4");
Log (No_Event, ":BODY");
delay until Epoch;
loop
Log (Mode_Change, "M1");
Set_Plan (TTP1'Access);
delay until Epoch + Seconds (K * 30 + 10);
Log (Mode_Change, "Null Plan");
Set_Plan (Null_Plan'Access);
delay until Epoch + Seconds (K * 30 + 15);
Log (Mode_Change, "M2");
Set_Plan (TTP2'Access);
delay until Epoch + Seconds (K * 30 + 25);
Log (Mode_Change, "Null Plan");
Set_Plan (Null_Plan'Access);
delay until Epoch + Seconds (K * 30 + 30);
K := K + 1;
end loop;
-- MyStats.Print_Stats;
-- delay until Time_Last;
end Main;
procedure Configure_Probe_Points;
procedure Configure_Probe_Points is
Configuration : GPIO_Port_Configuration;
begin
Configuration.Mode := Mode_Out;
Configuration.Output_Type := Push_Pull;
Configuration.Speed := Speed_50MHz;
Configuration.Resistors := Floating;
Enable_Clock (Probe_TT_Point & Probe_ET_Point);
Configure_IO (Probe_TT_Point & Probe_ET_Point, Configuration);
Clear (Probe_TT_Point);
Clear (Probe_ET_Point);
end Configure_Probe_Points;
begin
Configure_Probe_Points;
Initialize_LEDs;
All_LEDs_Off;
end TTS_Example2;
|
29,843
|
ada
| 0
|
JCGobbi/Nucleo-STM32G474RE
|
ADL/drivers/stm32g474/stm32-spi.ads
|
<filename>ADL/drivers/stm32g474/stm32-spi.ads
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, 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_spi.h --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief Header file of SPI HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides definitions for the STM32G4 (ARM Cortex M4F
-- from ST Microelectronics) Serial Peripheral Interface (SPI) facility.
private with STM32_SVD.SPI;
with HAL.SPI;
with System;
package STM32.SPI is
type Internal_SPI_Port is private;
type SPI_Port (Periph : not null access Internal_SPI_Port) is
limited new HAL.SPI.SPI_Port with private;
type SPI_Data_Direction is
(D2Lines_FullDuplex,
D2Lines_RxOnly,
D1Line_Rx,
D1Line_Tx);
type SPI_Mode is (Master, Slave);
type SPI_Data_Size is
(Bits_4,
Bits_5,
Bits_6,
Bits_7,
Bits_8,
Bits_9,
Bits_10,
Bits_11,
Bits_12,
Bits_13,
Bits_14,
Bits_15,
Bits_16)
with Size => 4;
for SPI_Data_Size use
(Bits_4 => 2#0011#,
Bits_5 => 2#0100#,
Bits_6 => 2#0101#,
Bits_7 => 2#0110#,
Bits_8 => 2#0111#,
Bits_9 => 2#1000#,
Bits_10 => 2#1001#,
Bits_11 => 2#1010#,
Bits_12 => 2#1011#,
Bits_13 => 2#1100#,
Bits_14 => 2#1101#,
Bits_15 => 2#1110#,
Bits_16 => 2#1111#);
type SPI_Clock_Polarity is (High, Low);
type SPI_Clock_Phase is (P1Edge, P2Edge);
type SPI_Slave_Management is (Software_Managed, Hardware_Managed);
type SPI_Baud_Rate_Prescaler is
(BRP_2, BRP_4, BRP_8, BRP_16, BRP_32, BRP_64, BRP_128, BRP_256);
type SPI_First_Bit is (MSB, LSB);
type SPI_Configuration is record
Direction : SPI_Data_Direction;
Mode : SPI_Mode;
Data_Size : HAL.SPI.SPI_Data_Size;
Clock_Polarity : SPI_Clock_Polarity;
Clock_Phase : SPI_Clock_Phase;
Slave_Management : SPI_Slave_Management;
Baud_Rate_Prescaler : SPI_Baud_Rate_Prescaler;
First_Bit : SPI_First_Bit;
CRC_Poly : UInt16;
end record;
procedure Configure (This : in out SPI_Port; Conf : SPI_Configuration);
procedure Enable (This : in out SPI_Port);
procedure Disable (This : in out SPI_Port);
function Enabled (This : SPI_Port) return Boolean;
procedure Send (This : in out SPI_Port; Data : UInt16);
function Data (This : SPI_Port) return UInt16
with Inline;
procedure Send (This : in out SPI_Port; Data : UInt8);
function Data (This : SPI_Port) return UInt8
with Inline;
function Is_Busy (This : SPI_Port) return Boolean
with Inline;
function Rx_Is_Empty (This : SPI_Port) return Boolean
with Inline;
function Tx_Is_Empty (This : SPI_Port) return Boolean
with Inline;
function Busy (This : SPI_Port) return Boolean
with Inline;
function Underrun_Indicated (This : SPI_Port) return Boolean
with Inline;
function CRC_Error_Indicated (This : SPI_Port) return Boolean
with Inline;
function Mode_Fault_Indicated (This : SPI_Port) return Boolean
with Inline;
function Overrun_Indicated (This : SPI_Port) return Boolean
with Inline;
function Frame_Fmt_Error_Indicated (This : SPI_Port) return Boolean
with Inline;
procedure Clear_Overrun (This : SPI_Port);
procedure Reset_CRC (This : in out SPI_Port);
function CRC_Enabled (This : SPI_Port) return Boolean;
function Is_Data_Frame_16bit (This : SPI_Port) return Boolean;
function Current_Mode (This : SPI_Port) return SPI_Mode;
function Current_Data_Direction (This : SPI_Port) return SPI_Data_Direction;
-- The following I/O routines implement the higher level functionality for
-- CRC and data direction, among others.
type UInt8_Buffer is array (Natural range <>) of UInt8
with Alignment => 2;
-- The alignment is set to 2 because we treat component pairs as half_word
-- values when sending/receiving in 16-bit mode.
-- Blocking
overriding
function Data_Size (This : SPI_Port) return HAL.SPI.SPI_Data_Size;
overriding
procedure Transmit
(This : in out SPI_Port;
Data : HAL.SPI.SPI_Data_8b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000);
overriding
procedure Transmit
(This : in out SPI_Port;
Data : HAL.SPI.SPI_Data_16b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000);
procedure Transmit
(This : in out SPI_Port;
Outgoing : UInt8);
overriding
procedure Receive
(This : in out SPI_Port;
Data : out HAL.SPI.SPI_Data_8b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000);
overriding
procedure Receive
(This : in out SPI_Port;
Data : out HAL.SPI.SPI_Data_16b;
Status : out HAL.SPI.SPI_Status;
Timeout : Natural := 1000);
procedure Receive
(This : in out SPI_Port;
Incoming : out UInt8);
procedure Transmit_Receive
(This : in out SPI_Port;
Outgoing : UInt8_Buffer;
Incoming : out UInt8_Buffer;
Size : Positive);
procedure Transmit_Receive
(This : in out SPI_Port;
Outgoing : UInt8;
Incoming : out UInt8);
-- TODO: add the other higher-level HAL routines for interrupts and DMA
function Data_Register_Address
(This : SPI_Port)
return System.Address;
-- For DMA transfer
private
type Internal_SPI_Port is new STM32_SVD.SPI.SPI_Peripheral;
type SPI_Port (Periph : not null access Internal_SPI_Port) is
limited new HAL.SPI.SPI_Port with null record;
procedure Send_Receive_16bit_Mode
(This : in out SPI_Port;
Outgoing : UInt8_Buffer;
Incoming : out UInt8_Buffer;
Size : Positive);
procedure Send_Receive_8bit_Mode
(This : in out SPI_Port;
Outgoing : UInt8_Buffer;
Incoming : out UInt8_Buffer;
Size : Positive);
procedure Send_16bit_Mode
(This : in out SPI_Port;
Outgoing : HAL.SPI.SPI_Data_16b);
procedure Send_8bit_Mode
(This : in out SPI_Port;
Outgoing : HAL.SPI.SPI_Data_8b);
procedure Receive_16bit_Mode
(This : in out SPI_Port;
Incoming : out HAL.SPI.SPI_Data_16b);
procedure Receive_8bit_Mode
(This : in out SPI_Port;
Incoming : out HAL.SPI.SPI_Data_8b);
end STM32.SPI;
|
29,844
|
ada
| 7
|
Fabien-Chouteau/coffee-clock
|
src/GUI/settings_window.adb
|
-------------------------------------------------------------------------------
-- --
-- Coffee Clock --
-- --
-- Copyright (C) 2016-2017 <NAME> --
-- --
-- Coffee Clock 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. --
-- --
-- Coffee Clock 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 We Noise Maker. If not, see <http://www.gnu.org/licenses/>. --
-- --
-------------------------------------------------------------------------------
with Giza.Window; use Giza.Window;
with calandar_80x80;
with ok_80x80;
with Giza.GUI;
with Dialog_Window; use Dialog_Window;
with Ada.Text_IO; use Ada.Text_IO;
with HAL.Real_Time_Clock;
with Real_Time_Clock;
with Alarm_Handling;
package body Settings_Window is
-------------
-- On_Init --
-------------
overriding procedure On_Init
(This : in out Instance)
is
begin
This.Alarm.Set_Image (alarm_80x80.Image);
This.Alarm.Disable_Frame;
This.Clock.Set_Image (clock_80x80.Image);
This.Clock.Disable_Frame;
This.Calandar.Set_Image (calandar_80x80.Image);
This.Calandar.Disable_Frame;
This.Back.Set_Image (ok_80x80.Image);
This.Back.Disable_Frame;
This.Tile.Set_Size (This.Get_Size);
This.Tile.Set_Child (1, This.Alarm'Unchecked_Access);
This.Tile.Set_Child (2, This.Clock'Unchecked_Access);
This.Tile.Set_Child (3, This.Calandar'Unchecked_Access);
This.Tile.Set_Child (4, This.Back'Unchecked_Access);
This.Add_Child (This.Tile'Unchecked_Access, (0, 0));
end On_Init;
------------------
-- On_Displayed --
------------------
overriding
procedure On_Displayed (This : in out Instance) is
Date : HAL.Real_Time_Clock.RTC_Date;
Time : HAL.Real_Time_Clock.RTC_Time;
begin
if This.Select_Alarm.Get_Answer = Answer_Top then
Put_Line ("We have a new alarm");
This.Select_Alarm.Clear_Answer;
Alarm_Handling.Set_Alarm_Time (This.Select_Alarm.Get_Time);
end if;
if This.Select_Clock.Get_Answer = Answer_Top then
Put_Line ("We have a new Clock");
This.Select_Clock.Clear_Answer;
Date := Real_Time_Clock.Get_Date;
Real_Time_Clock.Set (This.Select_Clock.Get_Time, Date);
end if;
if This.Select_Date.Get_Answer = Answer_Top then
Put_Line ("We have a new Date");
This.Select_Date.Clear_Answer;
Time := Real_Time_Clock.Get_Time;
Real_Time_Clock.Set (Time, This.Select_Date.Get_Date);
end if;
end On_Displayed;
-----------------------
-- On_Position_Event --
-----------------------
overriding function On_Position_Event
(This : in out Instance;
Evt : Position_Event_Ref;
Pos : Point_T)
return Boolean
is
begin
if On_Position_Event (Parent (This), Evt, Pos) then
if This.Alarm.Active then
This.Alarm.Set_Active (False);
This.Select_Alarm.Set_Time (Alarm_Handling.Get_Alarm_Time);
Giza.GUI.Push (This.Select_Alarm'Unchecked_Access);
elsif This.Clock.Active then
This.Clock.Set_Active (False);
This.Select_Clock.Set_Time (Real_Time_Clock.Get_Time);
Giza.GUI.Push (This.Select_Clock'Unchecked_Access);
elsif This.Calandar.Active then
This.Calandar.Set_Active (False);
This.Select_Date.Set_Date (Real_Time_Clock.Get_Date);
Giza.GUI.Push (This.Select_Date'Unchecked_Access);
elsif This.Back.Active then
This.Back.Set_Active (False);
Giza.GUI.Pop;
end if;
return True;
else
return False;
end if;
end On_Position_Event;
end Settings_Window;
|
29,845
|
ada
| 15
|
mgrojo/adalib
|
ada-containers-generic_sort.ads
|
-- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
generic
type Index_Type is (<>);
with function Before (Left, Right : Index_Type) return Boolean;
with procedure Swap (Left, Right : in Index_Type);
procedure Ada.Containers.Generic_Sort
(First, Last : Index_Type'Base);
pragma Pure(Ada.Containers.Generic_Sort);
|
29,846
|
ada
| 1
|
ForYouEyesOnly/Space-Convoy
|
Sources/Globe_3d/objects/globe_3d-impostor.adb
|
pragma Warnings (Off);
pragma Style_Checks (Off);
with GLOBE_3D.Textures,
GLOBE_3D.Math;
with glut.Windows; use glut.Windows;
with GL.Errors;
with GLU;
with ada.Text_IO; use ada.Text_IO;
package body GLOBE_3D.Impostor is
package G3DT renames GLOBE_3D.Textures;
package G3DM renames GLOBE_3D.Math;
procedure destroy (o : in out Impostor)
is
use GL.Geometry, GL.Skins;
begin
free (o.skinned_Geometry.Geometry);
free (o.skinned_Geometry.Skin);
free (o.skinned_Geometry.Veneer);
end;
procedure free (o : in out p_Impostor)
is
procedure deallocate is new ada.unchecked_Deallocation (Impostor'Class, p_Impostor);
begin
if o /= null then
destroy (o.all);
end if;
deallocate (o);
end;
function get_Target (O : in Impostor) return p_Visual
is
begin
return o.Target;
end;
procedure set_Target (o : in out Impostor; Target : in p_Visual)
is
use GL, GL.Skins, GL.Geometry;
begin
o.Target := Target;
o.is_Terrain := Target.is_Terrain;
Target.pre_Calculate;
-- set o.skinned_Geometry.geometry.vertices & indices
--
declare
Width : GL.Double := Target.bounds.sphere_Radius * 1.00;
begin
o.Quads.Vertices (1) := ( - Width, - Width, 0.0);
o.Quads.Vertices (2) := (Width, - Width, 0.0);
o.Quads.Vertices (3) := (Width, Width, 0.0);
o.Quads.Vertices (4) := ( - Width, Width, 0.0);
end;
o.Quads.all.set_vertex_Id (1, 1, 1); -- tbd : the '.all' required for gnat gpl06 . .. not required in gpl07.
o.Quads.all.set_vertex_Id (1, 2, 2);
o.Quads.all.set_vertex_Id (1, 3, 3);
o.Quads.all.set_vertex_Id (1, 4, 4);
-- create the veneer, if necessary
--
if o.skinned_Geometry.Veneer = null then
--o.skinned_Geometry.Veneer := o.skinned_Geometry.Skin.new_Veneer (o.Quads.all);
o.skinned_Geometry.Veneer := o.skinned_Geometry.Skin.new_Veneer (o.skinned_geometry.Geometry.all);
end if;
--o.bounding_sphere_Radius := bounding_sphere_Radius (o.Quads.vertex_Pool.all);
--o.Bounds := o.skinned_Geometry.Geometry.Bounds;
end;
-- update trigger configuration
--
procedure set_freshen_count_update_trigger_Mod (o : in out Impostor; To : in Positive)
is
begin
o.freshen_count_update_trigger_Mod := Counter (To);
end;
function get_freshen_count_update_trigger_Mod (o : in Impostor) return Positive
is
begin
return Positive (o.freshen_count_update_trigger_Mod);
end;
procedure set_size_update_trigger_Delta (o : in out Impostor; To : in Positive)
is
begin
o.size_update_trigger_Delta := GL.SizeI (To);
end;
function get_size_update_trigger_Delta (o : in Impostor) return Positive
is
begin
return Positive (o.size_update_trigger_Delta);
end;
function general_Update_required (o : access Impostor; the_Camera : in p_Camera;
the_pixel_Region : in pixel_Region) return Boolean
is
use GL, Globe_3D.Math;
Camera_has_moved : Boolean := the_Camera.clipper.eye_Position /= o.prior_camera_Position;
Target_has_moved : Boolean := o.Target.Centre /= o.prior_target_Position;
begin
o.freshen_Count := o.freshen_Count + 1;
if o.freshen_Count > o.freshen_count_update_trigger_Mod then
return True;
end if;
if Camera_has_moved
and then abs (Angle (the_Camera.clipper.eye_Position, o.prior_target_Position, o.prior_camera_Position)) > to_Radians (degrees => 15.0)
then
return True;
end if;
if Target_has_moved
and then abs (Angle (o.target.Centre, o.prior_camera_Position, o.prior_target_Position)) > to_Radians (degrees => 15.0)
then
return True;
end if;
if o.prior_pixel_Region.Width > 40 -- ignore target rotation triggered updates when target is small on screen
and then o.prior_pixel_Region.Height > 40 --
and then o.prior_target_Rotation /= o.target.Rotation
then
return True;
end if;
return False;
end;
function size_Update_required (o : access Impostor; the_pixel_Region : in pixel_Region) return Boolean
is
use GL;
begin
return abs (the_pixel_Region.Width - o.prior_Width_Pixels) > o.size_update_trigger_Delta
or else abs (the_pixel_Region.Height - o.prior_Height_pixels) > o.size_update_trigger_Delta;
end;
function get_pixel_Region (o : access Impostor'Class; the_Camera : in globe_3d.p_Camera) return pixel_Region
is
use GL, globe_3d.Math;
target_Centre : Vector_3d := the_Camera.world_Rotation * (o.Target.Centre - the_Camera.clipper.eye_Position);
target_lower_Left : Vector_3d := target_Centre - (o.Target.bounds.sphere_Radius, o.Target.bounds.sphere_Radius, 0.0);
target_Centre_proj : Vector_4d := the_Camera.Projection_Matrix * target_Centre;
target_Lower_Left_proj : Vector_4d := the_Camera.Projection_Matrix * target_lower_Left;
target_Centre_norm : Vector_3d := (target_Centre_proj (0) / target_Centre_proj (3),
target_Centre_proj (1) / target_Centre_proj (3),
target_Centre_proj (2) / target_Centre_proj (3));
target_Lower_Left_norm : Vector_3d := (target_Lower_Left_proj (0) / target_Lower_Left_proj (3),
target_Lower_Left_proj (1) / target_Lower_Left_proj (3),
target_Lower_Left_proj (2) / target_Lower_Left_proj (3));
target_Centre_norm_0to1 : Vector_3d := (target_Centre_norm (0) * 0.5 + 0.5,
target_Centre_norm (1) * 0.5 + 0.5,
target_Centre_norm (2) * 0.5 + 0.5);
target_Lower_Left_norm_0to1 : Vector_3d := (target_Lower_Left_norm (0) * 0.5 + 0.5,
target_Lower_Left_norm (1) * 0.5 + 0.5,
target_Lower_Left_norm (2) * 0.5 + 0.5);
viewport_Width : Integer := the_Camera.clipper.main_Clipping.x2 - the_Camera.clipper.main_Clipping.x1 + 1;
viewport_Height : Integer := the_Camera.clipper.main_Clipping.y2 - the_Camera.clipper.main_Clipping.y1 + 1;
Width : Real := 2.0 * Real (viewport_Width) * (target_Centre_norm_0to1 (0) - target_Lower_Left_norm_0to1 (0));
Width_pixels : GL.Sizei := GL.Sizei (Integer (Real (viewport_Width) * target_Lower_Left_norm_0to1 (0) + Width)
- Integer (Real (viewport_Width) * target_Lower_Left_norm_0to1 (0))
+ 1);
Height : Real := 2.0 * Real (viewport_Height) * (target_Centre_norm_0to1 (1) - target_Lower_Left_norm_0to1 (1));
Height_pixels : GL.Sizei := GL.Sizei (Integer (Real (viewport_Height) * target_Lower_Left_norm_0to1 (1) + Height)
- Integer (Real (viewport_Height) * target_Lower_Left_norm_0to1 (1))
+ 1);
begin
o.all.target_camera_Distance := Norm (target_Centre); -- nb : cache distance from camera to target.
return (x => GL.Int (target_Lower_Left_norm_0to1 (0) * Real (Viewport_Width)),
y => GL.Int (target_Lower_Left_norm_0to1 (1) * Real (viewport_Height)),
width => Width_pixels,
height => Height_pixels);
end;
procedure update (o : in out Impostor;
the_Camera : in p_Camera;
texture_Pool : in GL.textures.p_Pool)
is
use GL, GL.Textures;
Width_size : GL.textures.Size := to_Size (Natural (o.current_Width_pixels));
Height_size : GL.textures.Size := to_Size (Natural (o.current_Height_pixels));
texture_Width : GL.sizei := GL.sizei (power_of_2_Ceiling (Natural (o.current_Width_pixels)));
texture_Height : GL.sizei := GL.sizei (power_of_2_Ceiling (Natural (o.current_Height_pixels)));
GL_Error : Boolean;
begin
o.prior_pixel_Region := (o.current_copy_X, o.current_copy_Y, o.current_Width_pixels, o.current_Height_pixels);
o.prior_Width_pixels := o.current_Width_pixels;
o.prior_Height_pixels := o.current_Height_pixels;
o.prior_target_Rotation := o.target.Rotation;
o.prior_target_Position := o.target.Centre;
o.prior_camera_Position := the_Camera.clipper.Eye_Position;
GL.ClearColor (0.0, 0.0, 0.0, 0.0);
render ((1 => o.Target), the_Camera.all); -- render the target for subsequent copy to impostor texture.
declare -- set texture coordinates for the veneer.
use GL.Skins;
the_Veneer : p_Veneer_transparent_unlit_textured := p_Veneer_transparent_unlit_textured (o.skinned_Geometry.Veneer);
X_first : Real := o.expand_X;
Y_first : Real := o.expand_Y;
X_last : Real := Real (o.current_Width_pixels) / Real (texture_Width) - X_First;
Y_last : Real := Real (o.current_Height_pixels) / Real (texture_Height) - Y_First;
begin
the_Veneer.texture_Coordinates := (1 => (s => X_first, t => Y_first),
2 => (s => X_last, t => Y_first),
3 => (s => X_last, t => Y_last),
4 => (s => X_first, t => Y_last));
end;
if Width_size /= GL.textures.Size_width (o.skin.Texture)
or else Height_size /= GL.textures.Size_height (o.skin.Texture)
then
free (texture_Pool.all, o.skin.Texture);
o.skin.all.Texture := new_Texture (texture_Pool, Natural (texture_Width), Natural (texture_Height));
end if;
enable (o.skin.all.Texture);
GL.CopyTexSubImage2D (gl.TEXTURE_2D, 0,
o.current_copy_x_Offset, o.current_copy_y_Offset,
o.current_copy_X, o.current_copy_Y,
o.current_copy_Width, o.current_copy_Height);
GL.Errors.log (error_occurred => gl_Error);
if gl_Error then
put_Line ("x_Offset : " & GL.Int'image (o.current_copy_x_Offset) & " ********");
put_Line ("y_Offset : " & GL.Int'image (o.current_copy_y_Offset));
put_Line ("start x : " & GL.Int'image (o.current_copy_X));
put_Line ("start y : " & GL.Int'image (o.current_copy_Y));
put_Line ("copy width : " & GL.sizei'image (o.current_copy_Width));
put_Line ("copy height : " & GL.sizei'image (o.current_copy_Height));
put_Line ("width_pixels : " & GL.sizei'image (o.current_Width_pixels));
put_Line ("height_pixels : " & GL.sizei'image (o.current_Height_pixels));
put_Line ("width_size : " & GL.textures.size'image (Width_size));
put_Line ("height_size : " & GL.textures.size'image (Height_size));
put_Line ("texture width : " & GL.sizei'image (texture_Width));
put_Line ("texutre height : " & GL.sizei'image (texture_Height));
end if;
o.never_Updated := False;
o.freshen_Count := 0;
end;
procedure freshen (o : in out Impostor'Class; the_Camera : in globe_3d.p_Camera;
texture_Pool : in GL.Textures.p_Pool;
is_Valid : out Boolean)
is
update_Required : Boolean := o.Update_required (the_Camera); -- nb : caches current update info
begin
if update_Required then
o.update (the_Camera, texture_Pool);
end if;
is_Valid := o.is_Valid;
end;
function target_camera_Distance (o : in Impostor'Class) return Real
is
begin
return o.target_camera_Distance;
end;
function is_Valid (o : in Impostor'Class) return Boolean
is
begin
return o.is_Valid;
end;
function never_Updated (o : in Impostor'Class) return Boolean
is
begin
return o.never_Updated;
end;
function frame_Count_since_last_update (o : in Impostor'Class) return Natural
is
begin
return Natural (o.freshen_Count);
end;
function skinned_Geometrys (o : in Impostor) return GL.skinned_geometry.skinned_Geometrys
is
begin
return (1 => o.skinned_Geometry);
end;
function face_Count (o : in Impostor) return Natural
is
begin
return 1;
end;
procedure Display (o : in out Impostor; clip : in Clipping_data)
is
begin
null; -- actual display is done by the renderer (ie glut.Windows), which requests all skinned Geometry's
-- and then applies 'gl state' sorting for performance, before drawing.
end Display;
procedure set_Alpha (o : in out Impostor; Alpha : in GL.Double)
is
begin
null; -- tbd
end;
function Bounds (o : in Impostor) return GL.geometry.Bounds_record
is
begin
return o.skinned_geometry.Geometry.Bounds;
end;
function is_Transparent (o : in Impostor) return Boolean
is
begin
return True; -- tbd : - if using gl alpha test, depth sorting is not needed apparently.
-- in which case this could be set to False, and treated as a non - transparent in g3d.render.
-- may then be faster (?).
-- - seems to make little difference . .. test with different vid card.
end;
function Skin (o : access Impostor) return GL.skins.p_Skin_transparent_unlit_textured
is
begin
return GL.skins.p_Skin_transparent_unlit_textured (o.skinned_geometry.skin);
end;
function Quads (o : in Impostor) return GL.geometry.primitives.p_Quads
is
use GL.Geometry.Primitives, GL.geometry.primal;
begin
return p_Quads (p_primal_Geometry (o.skinned_geometry.Geometry).Primitive);
end;
-- note : only old, unused code folows (may be useful) . ..
--
-- tbd : enable_rotation is no good for impostors, since they must be aligned with the viewport
-- it might be useful for general billboards however !
--
procedure enable_Rotation (o : in Impostor; camera_Site : in Vector_3D)
is
use globe_3d.Math, globe_3d.REF, GL;
lookAt : Vector_3D := (0.0, 0.0, 1.0);
objToCamProj : Vector_3D := Normalized ((camera_Site (0) - o.Centre (0), 0.0, camera_Site (2) - o.Centre (2)));
upAux : Vector_3D := lookAt * objToCamProj;
angleCosine : GL.Double := lookAt * objToCamProj;
begin
if angleCosine > - 0.9999
and angleCosine < 0.9999
then
GL.Rotate (arcCos (angleCosine) * 180.0 / 3.14, upAux (0), upAux (1), upAux (2));
end if;
declare
objToCam : Vector_3D := Normalized ((camera_Site (0) - o.Centre (0),
camera_Site (1) - o.Centre (1),
camera_Site (2) - o.Centre (2)));
begin
angleCosine := objToCamProj * objToCam;
if angleCosine > - 0.9999
and angleCosine < 0.9999
then
if objToCam (1) < 0.0 then
GL.Rotate (arcCos (angleCosine) * 180.0 / 3.14, 1.0, 0.0, 0.0);
else
GL.Rotate (arcCos (angleCosine) * 180.0 / 3.14, - 1.0, 0.0, 0.0);
end if;
end if;
end;
end;
--
-- based on lighthouse3d billboard example.
end GLOBE_3D.Impostor;
|
29,847
|
ada
| 0
|
optikos/oasis
|
source/nodes/program-nodes-extended_return_statements.ads
|
-- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Return_Object_Specifications;
with Program.Element_Vectors;
with Program.Elements.Exception_Handlers;
with Program.Elements.Extended_Return_Statements;
with Program.Element_Visitors;
package Program.Nodes.Extended_Return_Statements is
pragma Preelaborate;
type Extended_Return_Statement is
new Program.Nodes.Node
and Program.Elements.Extended_Return_Statements
.Extended_Return_Statement
and Program.Elements.Extended_Return_Statements
.Extended_Return_Statement_Text
with private;
function Create
(Return_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Return_Object : not null Program.Elements
.Return_Object_Specifications.Return_Object_Specification_Access;
Do_Token : Program.Lexical_Elements.Lexical_Element_Access;
Statements : Program.Element_Vectors.Element_Vector_Access;
Exception_Token : Program.Lexical_Elements.Lexical_Element_Access;
Exception_Handlers : Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
End_Token : Program.Lexical_Elements.Lexical_Element_Access;
Return_Token_2 : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Extended_Return_Statement;
type Implicit_Extended_Return_Statement is
new Program.Nodes.Node
and Program.Elements.Extended_Return_Statements
.Extended_Return_Statement
with private;
function Create
(Return_Object : not null Program.Elements
.Return_Object_Specifications.Return_Object_Specification_Access;
Statements : Program.Element_Vectors.Element_Vector_Access;
Exception_Handlers : Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Extended_Return_Statement
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Extended_Return_Statement is
abstract new Program.Nodes.Node
and Program.Elements.Extended_Return_Statements
.Extended_Return_Statement
with record
Return_Object : not null Program.Elements
.Return_Object_Specifications.Return_Object_Specification_Access;
Statements : Program.Element_Vectors.Element_Vector_Access;
Exception_Handlers : Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Extended_Return_Statement'Class);
overriding procedure Visit
(Self : not null access Base_Extended_Return_Statement;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Return_Object
(Self : Base_Extended_Return_Statement)
return not null Program.Elements.Return_Object_Specifications
.Return_Object_Specification_Access;
overriding function Statements
(Self : Base_Extended_Return_Statement)
return Program.Element_Vectors.Element_Vector_Access;
overriding function Exception_Handlers
(Self : Base_Extended_Return_Statement)
return Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
overriding function Is_Extended_Return_Statement_Element
(Self : Base_Extended_Return_Statement)
return Boolean;
overriding function Is_Statement_Element
(Self : Base_Extended_Return_Statement)
return Boolean;
type Extended_Return_Statement is
new Base_Extended_Return_Statement
and Program.Elements.Extended_Return_Statements
.Extended_Return_Statement_Text
with record
Return_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Do_Token : Program.Lexical_Elements.Lexical_Element_Access;
Exception_Token : Program.Lexical_Elements.Lexical_Element_Access;
End_Token : Program.Lexical_Elements.Lexical_Element_Access;
Return_Token_2 : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Extended_Return_Statement_Text
(Self : aliased in out Extended_Return_Statement)
return Program.Elements.Extended_Return_Statements
.Extended_Return_Statement_Text_Access;
overriding function Return_Token
(Self : Extended_Return_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Do_Token
(Self : Extended_Return_Statement)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Exception_Token
(Self : Extended_Return_Statement)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function End_Token
(Self : Extended_Return_Statement)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Return_Token_2
(Self : Extended_Return_Statement)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Extended_Return_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Extended_Return_Statement is
new Base_Extended_Return_Statement
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Extended_Return_Statement_Text
(Self : aliased in out Implicit_Extended_Return_Statement)
return Program.Elements.Extended_Return_Statements
.Extended_Return_Statement_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Extended_Return_Statement)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Extended_Return_Statement)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Extended_Return_Statement)
return Boolean;
end Program.Nodes.Extended_Return_Statements;
|
29,848
|
ada
| 0
|
optikos/oasis
|
source/oasis/program-elements-indexed_components.ads
|
-- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Expressions;
with Program.Lexical_Elements;
package Program.Elements.Indexed_Components is
pragma Pure (Program.Elements.Indexed_Components);
type Indexed_Component is
limited interface and Program.Elements.Expressions.Expression;
type Indexed_Component_Access is access all Indexed_Component'Class
with Storage_Size => 0;
not overriding function Prefix
(Self : Indexed_Component)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
not overriding function Expressions
(Self : Indexed_Component)
return Program.Elements.Expressions.Expression_Vector_Access is abstract;
type Indexed_Component_Text is limited interface;
type Indexed_Component_Text_Access is
access all Indexed_Component_Text'Class with Storage_Size => 0;
not overriding function To_Indexed_Component_Text
(Self : aliased in out Indexed_Component)
return Indexed_Component_Text_Access is abstract;
not overriding function Left_Bracket_Token
(Self : Indexed_Component_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Indexed_Component_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Indexed_Components;
|
29,849
|
ada
| 1
|
vidkidz/crossbridge
|
llvm-gcc-4.2-2.9/gcc/ada/g-trasym-vms-ia64.adb
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . T R A C E B A C K . S Y M B O L I C --
-- --
-- B o d y --
-- --
-- Copyright (C) 2005, 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Run-time symbolic traceback support for IA64/VMS
with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback;
with Interfaces.C;
with System;
with System.Aux_DEC;
with System.Soft_Links;
with System.Traceback_Entries;
package body GNAT.Traceback.Symbolic is
pragma Warnings (Off);
pragma Linker_Options ("--for-linker=sys$library:trace.exe");
use Interfaces.C;
use System;
use System.Aux_DEC;
use System.Traceback_Entries;
subtype User_Arg_Type is Unsigned_Longword;
subtype Cond_Value_Type is Unsigned_Longword;
type ASCIC is record
Count : unsigned_char;
Data : char_array (1 .. 255);
end record;
pragma Convention (C, ASCIC);
for ASCIC use record
Count at 0 range 0 .. 7;
Data at 1 range 0 .. 8 * 255 - 1;
end record;
for ASCIC'Size use 8 * 256;
function Fetch_ASCIC is new Fetch_From_Address (ASCIC);
procedure Symbolize
(Status : out Cond_Value_Type;
Current_PC : in Address;
Filename_Name : out Address;
Library_Name : out Address;
Record_Number : out Integer;
Image_Name : out Address;
Module_Name : out Address;
Routine_Name : out Address;
Line_Number : out Integer;
Relative_PC : out Address);
pragma Interface (External, Symbolize);
pragma Import_Valued_Procedure
(Symbolize, "TBK$I64_SYMBOLIZE",
(Cond_Value_Type, Address,
Address, Address, Integer,
Address, Address, Address, Integer,
Address),
(Value, Value,
Reference, Reference, Reference,
Reference, Reference, Reference, Reference,
Reference));
function Decode_Ada_Name (Encoded_Name : String) return String;
-- Decodes an Ada identifier name. Removes leading "_ada_" and trailing
-- __{DIGIT}+ or ${DIGIT}+, converts other "__" to '.'
---------------------
-- Decode_Ada_Name --
---------------------
function Decode_Ada_Name (Encoded_Name : String) return String is
Decoded_Name : String (1 .. Encoded_Name'Length);
Pos : Integer := Encoded_Name'First;
Last : Integer := Encoded_Name'Last;
DPos : Integer := 1;
begin
if Pos > Last then
return "";
end if;
-- Skip leading _ada_
if Encoded_Name'Length > 4
and then Encoded_Name (Pos .. Pos + 4) = "_ada_"
then
Pos := Pos + 5;
end if;
-- Skip trailing __{DIGIT}+ or ${DIGIT}+
if Encoded_Name (Last) in '0' .. '9' then
for J in reverse Pos + 2 .. Last - 1 loop
case Encoded_Name (J) is
when '0' .. '9' =>
null;
when '$' =>
Last := J - 1;
exit;
when '_' =>
if Encoded_Name (J - 1) = '_' then
Last := J - 2;
end if;
exit;
when others =>
exit;
end case;
end loop;
end if;
-- Now just copy encoded name to decoded name, converting "__" to '.'
while Pos <= Last loop
if Encoded_Name (Pos) = '_' and then Encoded_Name (Pos + 1) = '_'
and then Pos /= Encoded_Name'First
then
Decoded_Name (DPos) := '.';
Pos := Pos + 2;
else
Decoded_Name (DPos) := Encoded_Name (Pos);
Pos := Pos + 1;
end if;
DPos := DPos + 1;
end loop;
return Decoded_Name (1 .. DPos - 1);
end Decode_Ada_Name;
------------------------
-- Symbolic_Traceback --
------------------------
function Symbolic_Traceback (Traceback : Tracebacks_Array) return String is
Status : Cond_Value_Type;
Filename_Name_Addr : Address;
Library_Name_Addr : Address;
Record_Number : Integer;
Image_Name : ASCIC;
Image_Name_Addr : Address;
Module_Name : ASCIC;
Module_Name_Addr : Address;
Routine_Name : ASCIC;
Routine_Name_Addr : Address;
Line_Number : Integer;
Relative_PC : Address;
Res : String (1 .. 256 * Traceback'Length);
Len : Integer;
begin
if Traceback'Length > 0 then
Len := 0;
-- Since image computation is not thread-safe we need task lockout
System.Soft_Links.Lock_Task.all;
for J in Traceback'Range loop
Symbolize
(Status,
PC_For (Traceback (J)),
Filename_Name_Addr,
Library_Name_Addr,
Record_Number,
Image_Name_Addr,
Module_Name_Addr,
Routine_Name_Addr,
Line_Number,
Relative_PC);
Image_Name := Fetch_ASCIC (Image_Name_Addr);
Module_Name := Fetch_ASCIC (Module_Name_Addr);
Routine_Name := Fetch_ASCIC (Routine_Name_Addr);
declare
First : Integer := Len + 1;
Last : Integer := First + 80 - 1;
Pos : Integer;
Routine_Name_D : String := Decode_Ada_Name
(To_Ada
(Routine_Name.Data (1 .. size_t (Routine_Name.Count)),
False));
begin
Res (First .. Last) := (others => ' ');
Res (First .. First + Integer (Image_Name.Count) - 1) :=
To_Ada
(Image_Name.Data (1 .. size_t (Image_Name.Count)),
False);
Res (First + 10 ..
First + 10 + Integer (Module_Name.Count) - 1) :=
To_Ada
(Module_Name.Data (1 .. size_t (Module_Name.Count)),
False);
Res (First + 30 ..
First + 30 + Routine_Name_D'Length - 1) :=
Routine_Name_D;
-- If routine name doesn't fit 20 characters, output
-- the line number on next line at 50th position
if Routine_Name_D'Length > 20 then
Pos := First + 30 + Routine_Name_D'Length;
Res (Pos) := ASCII.LF;
Last := Pos + 80;
Res (Pos + 1 .. Last) := (others => ' ');
Pos := Pos + 51;
else
Pos := First + 50;
end if;
Res (Pos .. Pos + Integer'Image (Line_Number)'Length - 1) :=
Integer'Image (Line_Number);
Res (Last) := ASCII.LF;
Len := Last;
end;
end loop;
System.Soft_Links.Unlock_Task.all;
return Res (1 .. Len);
else
return "";
end if;
end Symbolic_Traceback;
function Symbolic_Traceback (E : Exception_Occurrence) return String is
begin
return Symbolic_Traceback (Tracebacks (E));
end Symbolic_Traceback;
end GNAT.Traceback.Symbolic;
|
29,850
|
ada
| 0
|
PThierry/ewok-kernel
|
src/ewok-debug.adb
|
--
-- Copyright 2018 The wookey project team <<EMAIL>>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
--
-- 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 ewok.tasks_shared; use ewok.tasks_shared;
with ewok.devices_shared; use ewok.devices_shared;
with ewok.exported;
with ewok.exported.gpios;
with ewok.gpio;
with soc.gpio;
with soc.usart; use soc.usart;
with soc.usart.interfaces;
#if CONFIG_KERNEL_PANIC_WIPE
with soc;
with soc.layout; use soc.layout;
#end if;
#if not CONFIG_KERNEL_PANIC_FREEZE
with m4;
with m4.scb;
#end if;
package body ewok.debug
with spark_mode => off
is
kernel_usart_id : unsigned_8;
TX_pin_config : aliased ewok.exported.gpios.t_gpio_config;
USART1_TX_pin_config : constant ewok.exported.gpios.t_gpio_config :=
(settings => ewok.exported.gpios.t_gpio_settings'(others => true),
kref => ewok.exported.gpios.t_gpio_ref'
(pin => 6,
port => soc.gpio.GPIO_PB),
mode => ewok.exported.gpios.GPIO_AF,
pupd => ewok.exported.gpios.GPIO_PULLUP,
otype => ewok.exported.gpios.GPIO_PUSH_PULL,
ospeed => ewok.exported.gpios.GPIO_HIGH_SPEED,
af => ewok.exported.gpios.GPIO_AF_USART1,
bsr_r => 0,
bsr_s => 0,
lck => 0,
exti_trigger => ewok.exported.gpios.GPIO_EXTI_TRIGGER_NONE,
exti_lock => ewok.exported.gpios.GPIO_EXTI_UNLOCKED,
exti_handler => 16#0000_0000#);
USART4_TX_pin_config : constant ewok.exported.gpios.t_gpio_config :=
(settings => ewok.exported.gpios.t_gpio_settings'(others => true),
#if CONFIG_WOOKEY
kref => ewok.exported.gpios.t_gpio_ref'
(pin => 0,
port => soc.gpio.GPIO_PA),
#else
kref => ewok.exported.gpios.t_gpio_ref'
(pin => 6,
port => soc.gpio.GPIO_PB),
#end if;
mode => ewok.exported.gpios.GPIO_AF,
pupd => ewok.exported.gpios.GPIO_PULLUP,
otype => ewok.exported.gpios.GPIO_PUSH_PULL,
ospeed => ewok.exported.gpios.GPIO_HIGH_SPEED,
af => ewok.exported.gpios.GPIO_AF_UART4,
bsr_r => 0,
bsr_s => 0,
lck => 0,
exti_trigger => ewok.exported.gpios.GPIO_EXTI_TRIGGER_NONE,
exti_lock => ewok.exported.gpios.GPIO_EXTI_UNLOCKED,
exti_handler => 16#0000_0000#);
USART6_TX_pin_config : constant ewok.exported.gpios.t_gpio_config :=
(settings => ewok.exported.gpios.t_gpio_settings'(others => true),
kref => ewok.exported.gpios.t_gpio_ref'
(pin => 6,
port => soc.gpio.GPIO_PC),
mode => ewok.exported.gpios.GPIO_AF,
pupd => ewok.exported.gpios.GPIO_PULLUP,
otype => ewok.exported.gpios.GPIO_PUSH_PULL,
ospeed => ewok.exported.gpios.GPIO_HIGH_SPEED,
af => ewok.exported.gpios.GPIO_AF_USART6,
bsr_r => 0,
bsr_s => 0,
lck => 0,
exti_trigger => ewok.exported.gpios.GPIO_EXTI_TRIGGER_NONE,
exti_lock => ewok.exported.gpios.GPIO_EXTI_UNLOCKED,
exti_handler => 16#0000_0000#);
procedure init
(usart : in unsigned_8)
is
ok : boolean;
begin
kernel_usart_id := usart;
case kernel_usart_id is
when 1 =>
TX_pin_config := USART1_TX_pin_config;
when 4 =>
TX_pin_config := USART4_TX_pin_config;
when 6 =>
TX_pin_config := USART6_TX_pin_config;
when others =>
raise program_error;
end case;
ewok.gpio.register (ID_KERNEL, ID_DEV_UNUSED, TX_pin_config'access, ok);
if not ok then
raise program_error;
end if;
ewok.gpio.config (TX_pin_config'access);
soc.usart.interfaces.configure
(kernel_usart_id, 115_200, DATA_9BITS, PARITY_ODD, STOP_1, ok);
if not ok then
raise program_error;
end if;
log (INFO,
"EwoK: USART" & unsigned_8'image (kernel_usart_id) & " initialized");
newline;
end init;
procedure putc (c : character)
is
begin
#if CONFIG_KERNEL_SERIAL
soc.usart.interfaces.transmit (kernel_usart_id, character'pos (c));
#else
null;
#end if;
end putc;
procedure log (s : string; nl : boolean := true)
is
begin
for i in s'range loop
putc (s(i));
end loop;
if nl then
putc (ASCII.CR);
putc (ASCII.LF);
end if;
end log;
procedure log (level : t_level; s : string)
is
begin
case level is
when DEBUG =>
log (BG_COLOR_ORANGE & s & BG_COLOR_BLACK);
when INFO =>
log (BG_COLOR_BLUE & s & BG_COLOR_BLACK);
when WARNING =>
log (BG_COLOR_ORANGE & s & BG_COLOR_BLACK);
when ERROR .. ALERT =>
log (BG_COLOR_RED & s & BG_COLOR_BLACK);
end case;
end log;
procedure alert (s : string)
is
begin
log (BG_COLOR_RED & s & BG_COLOR_BLACK, false);
end alert;
procedure newline
is
begin
log ("");
end newline;
procedure panic (s : string)
is
begin
log (BG_COLOR_RED & "panic: " & s & BG_COLOR_BLACK);
#if CONFIG_KERNEL_PANIC_FREEZE
loop null; end loop;
#end if;
#if CONFIG_KERNEL_PANIC_REBOOT
m4.scb.reset;
#end if;
#if CONFIG_KERNEL_PANIC_WIPE
declare
sram : array (0 .. soc.layout.USER_RAM_SIZE) of types.byte
with address => to_address(USER_RAM_BASE);
begin
-- Wiping the user applications in RAM before reseting. Kernel data
-- and bss are not cleared because the are in use and there should
-- be no sensible content in kernel data (secrets are hold by user tasks).
-- TODO: Clearing IPC content
sram := (others => 0);
m4.scb.reset;
end;
#end if;
end panic;
end ewok.debug;
|
29,851
|
ada
| 2
|
morbos/Ada_Drivers_Library
|
arch/ARM/STM32/driversL0/stm32-gpio.adb
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_gpio.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief GPIO HAL module driver. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with System; use System;
with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32.RCC;
with STM32.SYSCFG;
with System.Machine_Code;
package body STM32.GPIO is
procedure Lock_The_Pin (This : in out GPIO_Port; Pin : GPIO_Pin);
-- This is the routine that actually locks the pin for the port. It is an
-- internal routine and has no preconditions. We use it to avoid redundant
-- calls to the precondition that checks that the pin is not already
-- locked. The redundancy would otherwise occur because the routine that
-- locks an array of pins is implemented by calling the routine that locks
-- a single pin: both those Lock routines have a precondition that checks
-- that the pin(s) is not already being locked.
subtype GPIO_Pin_Index is Natural range 0 .. GPIO_Pin'Pos (GPIO_Pin'Last);
-------------
-- Any_Set --
-------------
function Any_Set (Pins : GPIO_Points) return Boolean is
begin
for Pin of Pins loop
if Pin.Set then
return True;
end if;
end loop;
return False;
end Any_Set;
----------
-- Mode --
----------
overriding
function Mode (This : GPIO_Point) return HAL.GPIO.GPIO_Mode is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
case This.Periph.MODER.Arr (Index) is
when Pin_IO_Modes'Enum_Rep (Mode_Out) => return HAL.GPIO.Output;
when Pin_IO_Modes'Enum_Rep (Mode_In) => return HAL.GPIO.Input;
when others => return HAL.GPIO.Unknown;
end case;
end Mode;
--------------
-- Set_Mode --
--------------
overriding
function Set_Mode
(This : in out GPIO_Point;
Mode : HAL.GPIO.GPIO_Config_Mode)
return Boolean
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
case Mode is
when HAL.GPIO.Output =>
This.Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Mode_Out);
when HAL.GPIO.Input =>
This.Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Mode_In);
end case;
return True;
end Set_Mode;
-------------------
-- Pull_Resistor --
-------------------
overriding
function Pull_Resistor
(This : GPIO_Point)
return HAL.GPIO.GPIO_Pull_Resistor
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
if This.Periph.PUPDR.Arr (Index) = 0 then
return HAL.GPIO.Floating;
elsif This.Periph.PUPDR.Arr (Index) = 1 then
return HAL.GPIO.Pull_Up;
else
return HAL.GPIO.Pull_Down;
end if;
end Pull_Resistor;
-----------------------
-- Set_Pull_Resistor --
-----------------------
overriding
function Set_Pull_Resistor
(This : in out GPIO_Point;
Pull : HAL.GPIO.GPIO_Pull_Resistor)
return Boolean
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
case Pull is
when HAL.GPIO.Floating =>
This.Periph.PUPDR.Arr (Index) := 0;
when HAL.GPIO.Pull_Up =>
This.Periph.PUPDR.Arr (Index) := 1;
when HAL.GPIO.Pull_Down =>
This.Periph.PUPDR.Arr (Index) := 2;
end case;
return True;
end Set_Pull_Resistor;
---------
-- Set --
---------
overriding
function Set (This : GPIO_Point) return Boolean is
Pin_Mask : constant UInt16 := GPIO_Pin'Enum_Rep (This.Pin);
begin
return (This.Periph.IDR.ID.Val and Pin_Mask) = Pin_Mask;
end Set;
-------------
-- All_Set --
-------------
function All_Set (Pins : GPIO_Points) return Boolean is
begin
for Pin of Pins loop
if not Pin.Set then
return False;
end if;
end loop;
return True;
end All_Set;
---------
-- Set --
---------
overriding
procedure Set (This : in out GPIO_Point) is
begin
This.Periph.BSRR.BS.Val := GPIO_Pin'Enum_Rep (This.Pin);
-- The bit-set and bit-reset registers ignore writes of zeros so we
-- don't need to preserve the existing bit values in those registers.
end Set;
---------
-- Set --
---------
procedure Set (Pins : in out GPIO_Points) is
begin
for Pin of Pins loop
Pin.Set;
end loop;
end Set;
-----------
-- Clear --
-----------
overriding
procedure Clear (This : in out GPIO_Point) is
begin
This.Periph.BSRR.BR.Val := GPIO_Pin'Enum_Rep (This.Pin);
-- The bit-set and bit-reset registers ignore writes of zeros so we
-- don't need to preserve the existing bit values in those registers.
end Clear;
-----------
-- Clear --
-----------
procedure Clear (Pins : in out GPIO_Points) is
begin
for Pin of Pins loop
Pin.Clear;
end loop;
end Clear;
------------
-- Toggle --
------------
overriding
procedure Toggle (This : in out GPIO_Point) is
begin
This.Periph.ODR.OD.Val := This.Periph.ODR.OD.Val xor GPIO_Pin'Enum_Rep (This.Pin);
end Toggle;
------------
-- Toggle --
------------
procedure Toggle (Points : in out GPIO_Points) is
begin
for Point of Points loop
Point.Toggle;
end loop;
end Toggle;
------------
-- Locked --
------------
function Locked (This : GPIO_Point) return Boolean is
Mask : constant UInt16 := GPIO_Pin'Enum_Rep (This.Pin);
begin
return (This.Periph.LCKR.LCK.Val and Mask) = Mask;
end Locked;
------------------
-- Lock_The_Pin --
------------------
procedure Lock_The_Pin (This : in out GPIO_Port; Pin : GPIO_Pin) is
-- Temp : UInt32;
-- pragma Volatile (Temp);
use System.Machine_Code;
use ASCII;
begin
-- As per the Reference Manual (RM0090; Doc ID 018909 Rev 6) pg 282,
-- a specific sequence is required to set the Lock bit. Throughout the
-- sequence the same value for the lower 15 bits of the word must be
-- used (ie the pin number). The lock bit is referred to as LCKK in
-- the doc.
-- Temp := LCCK or Pin'Enum_Rep;
--
-- -- set the lock bit
-- Port.LCKR := Temp;
--
-- -- clear the lock bit
-- Port.LCKR := Pin'Enum_Rep;
--
-- -- set the lock bit again
-- Port.LCKR := Temp;
--
-- -- read the lock bit
-- Temp := Port.LCKR;
--
-- -- read the lock bit again
-- Temp := Port.LCKR;
-- We use the following assembly language sequence because the above
-- high-level version in Ada works only if the optimizer is enabled.
-- This is not an issue specific to Ada. If you need a specific sequence
-- of instructions you should really specify those instructions.
-- We don't want the functionality to depend on the switches, and we
-- don't want to preclude debugging, hence the following:
-- Asm ("orr r3, %2, #65536" & LF & HT &
-- "str r3, %0" & LF & HT &
-- "ldr r3, %0" & LF & HT & -- temp <- pin or LCCK
-- "str r3, [%1, #28]" & LF & HT & -- temp -> lckr
-- "str %2, [%1, #28]" & LF & HT & -- pin -> lckr
-- "ldr r3, %0" & LF & HT &
-- "str r3, [%1, #28]" & LF & HT & -- temp -> lckr
-- "ldr r3, [%1, #28]" & LF & HT &
-- "str r3, %0" & LF & HT & -- temp <- lckr
-- "ldr r3, [%1, #28]" & LF & HT &
-- "str r3, %0" & LF & HT, -- temp <- lckr
-- Inputs => (Address'Asm_Input ("r", This'Address), -- %1
-- (GPIO_Pin'Asm_Input ("r", Pin))), -- %2
-- Outputs => (UInt32'Asm_Output ("=m", Temp)), -- %0
-- Volatile => True,
-- Clobber => ("r2, r3"));
null;
end Lock_The_Pin;
----------
-- Lock --
----------
procedure Lock (This : GPIO_Point) is
begin
Lock_The_Pin (This.Periph.all, This.Pin);
end Lock;
----------
-- Lock --
----------
procedure Lock (Points : GPIO_Points) is
begin
for Point of Points loop
if not Locked (Point) then
Point.Lock;
end if;
end loop;
end Lock;
------------------
-- Configure_IO --
------------------
procedure Configure_IO
(This : GPIO_Point;
Config : GPIO_Port_Configuration)
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
This.Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Config.Mode);
This.Periph.OTYPER.OT.Arr (Index) := Config.Output_Type = Open_Drain;
This.Periph.OSPEEDR.Arr (Index) := Pin_Output_Speeds'Enum_Rep (Config.Speed);
This.Periph.PUPDR.Arr (Index) := Internal_Pin_Resistors'Enum_Rep (Config.Resistors);
end Configure_IO;
------------------
-- Configure_IO --
------------------
procedure Configure_IO
(Points : GPIO_Points;
Config : GPIO_Port_Configuration)
is
begin
for Point of Points loop
Point.Configure_IO (Config);
end loop;
end Configure_IO;
----------------------------------
-- Configure_Alternate_Function --
----------------------------------
procedure Configure_Alternate_Function
(This : GPIO_Point;
AF : GPIO_Alternate_Function)
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
if Index < 8 then
This.Periph.AFRL.Arr (Index) := UInt4 (AF);
else
This.Periph.AFRH.Arr (Index) := UInt4 (AF);
end if;
end Configure_Alternate_Function;
----------------------------------
-- Configure_Alternate_Function --
----------------------------------
procedure Configure_Alternate_Function
(Points : GPIO_Points;
AF : GPIO_Alternate_Function)
is
begin
for Point of Points loop
Point.Configure_Alternate_Function (AF);
end loop;
end Configure_Alternate_Function;
---------------------------
-- Interrupt_Line_Number --
---------------------------
function Interrupt_Line_Number
(This : GPIO_Point) return EXTI.External_Line_Number
is
begin
return EXTI.External_Line_Number'Val (GPIO_Pin'Pos (This.Pin));
end Interrupt_Line_Number;
-----------------------
-- Configure_Trigger --
-----------------------
procedure Configure_Trigger
(This : GPIO_Point;
Trigger : EXTI.External_Triggers)
is
use STM32.EXTI;
Line : constant External_Line_Number := External_Line_Number'Val (GPIO_Pin'Pos (This.Pin));
use STM32.SYSCFG, STM32.RCC;
begin
SYSCFG_Clock_Enable;
Connect_External_Interrupt (This);
if Trigger in Interrupt_Triggers then
Enable_External_Interrupt (Line, Trigger);
else
Enable_External_Event (Line, Trigger);
end if;
end Configure_Trigger;
-----------------------
-- Configure_Trigger --
-----------------------
procedure Configure_Trigger
(Points : GPIO_Points;
Trigger : EXTI.External_Triggers)
is
begin
for Point of Points loop
Point.Configure_Trigger (Trigger);
end loop;
end Configure_Trigger;
end STM32.GPIO;
|
29,852
|
ada
| 0
|
kisom/rover-mk1
|
src/rosa/rosa-tasks.adb
|
<gh_stars>0
package body ROSA.Tasks is
procedure Create (Task_ID, Priority : in Unsigned_8; t : out Tasking) is
begin
t.Task_ID := Task_ID;
t.Priority := Priority;
t.State := Waiting;
end Create;
function Run (t : in Tasking) return Task_Status is
begin
if t.State /= Ready then
return Not_Ready;
end if;
-- Fill this in later.
return OK;
end Run;
function Suspend (t : in Tasking) return Task_Status is
begin
if t.State /= Running then
return Not_Running;
end if;
-- Fill this in later.
return OK;
end Suspend;
end ROSA.Tasks;
|
29,853
|
ada
| 1
|
persan/A-gst
|
src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_gstelement_h.ads
|
<filename>src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_gstelement_h.ads
pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h;
with glib;
with glib.Values;
with System;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h;
with glib;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstmessage_h;
-- with GStreamer.GST_Low_Level.glib_2_0_glib_gquark_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h is
-- unsupported macro: GST_TYPE_ELEMENT (gst_element_get_type ())
-- arg-macro: function GST_IS_ELEMENT (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ELEMENT);
-- arg-macro: function GST_IS_ELEMENT_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ELEMENT);
-- arg-macro: function GST_ELEMENT_GET_CLASS (obj)
-- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ELEMENT, GstElementClass);
-- arg-macro: function GST_ELEMENT (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ELEMENT, GstElement);
-- arg-macro: function GST_ELEMENT_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ELEMENT, GstElementClass);
-- arg-macro: function GST_ELEMENT_CAST (obj)
-- return (GstElement*)(obj);
-- arg-macro: function GST_STATE (elem)
-- return GST_ELEMENT_CAST(elem).current_state;
-- arg-macro: function GST_STATE_NEXT (elem)
-- return GST_ELEMENT_CAST(elem).next_state;
-- arg-macro: function GST_STATE_PENDING (elem)
-- return GST_ELEMENT_CAST(elem).pending_state;
-- arg-macro: function GST_STATE_TARGET (elem)
-- return GST_ELEMENT_CAST(elem).abidata.ABI.target_state;
-- arg-macro: function GST_STATE_RETURN (elem)
-- return GST_ELEMENT_CAST(elem).last_return;
-- arg-macro: function GST_STATE_GET_NEXT (cur, pending)
-- return (GstState)((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur)));
-- arg-macro: function GST_STATE_TRANSITION (cur, next)
-- return (GstStateChange)(((cur)<<3)or(next));
-- arg-macro: function GST_STATE_TRANSITION_CURRENT (trans)
-- return (GstState)((trans)>>3);
-- arg-macro: function GST_STATE_TRANSITION_NEXT (trans)
-- return (GstState)((trans)and16#7#);
-- arg-macro: function GST_ELEMENT_IS_LOCKED_STATE (elem)
-- return GST_OBJECT_FLAG_IS_SET(elem,GST_ELEMENT_LOCKED_STATE);
-- arg-macro: function GST_ELEMENT_NAME (elem)
-- return GST_OBJECT_NAME(elem);
-- arg-macro: function GST_ELEMENT_PARENT (elem)
-- return GST_ELEMENT_CAST(GST_OBJECT_PARENT(elem));
-- arg-macro: function GST_ELEMENT_BUS (elem)
-- return GST_ELEMENT_CAST(elem).bus;
-- arg-macro: function GST_ELEMENT_CLOCK (elem)
-- return GST_ELEMENT_CAST(elem).clock;
-- arg-macro: function GST_ELEMENT_PADS (elem)
-- return GST_ELEMENT_CAST(elem).pads;
-- arg-macro: function GST_ELEMENT_START_TIME (elem)
-- return GST_ELEMENT_CAST(elem).abidata.ABI.start_time;
-- unsupported macro: GST_ELEMENT_ERROR(el,domain,code,text,debug) G_STMT_START { gchar *__txt = _gst_element_error_printf text; gchar *__dbg = _gst_element_error_printf debug; if (__txt) GST_WARNING_OBJECT (el, "error: %s", __txt); if (__dbg) GST_WARNING_OBJECT (el, "error: %s", __dbg); gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR, GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); } G_STMT_END
-- unsupported macro: GST_ELEMENT_WARNING(el,domain,code,text,debug) G_STMT_START { gchar *__txt = _gst_element_error_printf text; gchar *__dbg = _gst_element_error_printf debug; if (__txt) GST_WARNING_OBJECT (el, "warning: %s", __txt); if (__dbg) GST_WARNING_OBJECT (el, "warning: %s", __dbg); gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING, GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); } G_STMT_END
-- unsupported macro: GST_ELEMENT_INFO(el,domain,code,text,debug) G_STMT_START { gchar *__txt = _gst_element_error_printf text; gchar *__dbg = _gst_element_error_printf debug; if (__txt) GST_INFO_OBJECT (el, "info: %s", __txt); if (__dbg) GST_INFO_OBJECT (el, "info: %s", __dbg); gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_INFO, GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); } G_STMT_END
-- arg-macro: function GST_STATE_GET_LOCK (elem)
-- return GST_ELEMENT_CAST(elem).state_lock;
-- arg-macro: function GST_STATE_GET_COND (elem)
-- return GST_ELEMENT_CAST(elem).state_cond;
-- arg-macro: procedure GST_STATE_LOCK (elem)
-- g_static_rec_mutex_lock(GST_STATE_GET_LOCK(elem))
-- arg-macro: procedure GST_STATE_TRYLOCK (elem)
-- g_static_rec_mutex_trylock(GST_STATE_GET_LOCK(elem))
-- arg-macro: procedure GST_STATE_UNLOCK (elem)
-- g_static_rec_mutex_unlock(GST_STATE_GET_LOCK(elem))
-- arg-macro: procedure GST_STATE_UNLOCK_FULL (elem)
-- g_static_rec_mutex_unlock_full(GST_STATE_GET_LOCK(elem))
-- arg-macro: procedure GST_STATE_LOCK_FULL (elem, t)
-- g_static_rec_mutex_lock_full(GST_STATE_GET_LOCK(elem), t)
-- arg-macro: procedure GST_STATE_WAIT (elem)
-- g_cond_wait (GST_STATE_GET_COND (elem), GST_OBJECT_GET_LOCK (elem))
-- arg-macro: procedure GST_STATE_TIMED_WAIT (elem, timeval)
-- g_cond_timed_wait (GST_STATE_GET_COND (elem), GST_OBJECT_GET_LOCK (elem), timeval)
-- arg-macro: procedure GST_STATE_SIGNAL (elem)
-- g_cond_signal (GST_STATE_GET_COND (elem));
-- arg-macro: procedure GST_STATE_BROADCAST (elem)
-- g_cond_broadcast (GST_STATE_GET_COND (elem));
-- arg-macro: procedure gst_element_get_name (elem)
-- gst_object_get_name(GST_OBJECT_CAST(elem))
-- arg-macro: procedure gst_element_set_name (elem, name)
-- gst_object_set_name(GST_OBJECT_CAST(elem),name)
-- arg-macro: procedure gst_element_get_parent (elem)
-- gst_object_get_parent(GST_OBJECT_CAST(elem))
-- arg-macro: procedure gst_element_set_parent (elem, parent)
-- gst_object_set_parent(GST_OBJECT_CAST(elem),parent)
-- GStreamer
-- * Copyright (C) 1999,2000 <NAME> <<EMAIL>>
-- * 2000,2004 <NAME> <<EMAIL>>
-- *
-- * gstelement.h: Header for GstElement
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- gstelement.h and gstelementfactory.h include eachother
type GstElement;
type GstState is
(GST_STATE_VOID_PENDING,
GST_STATE_NULL,
GST_STATE_READY,
GST_STATE_PAUSED,
GST_STATE_PLAYING);
pragma Convention (C, GstState); -- gst/gstelement.h:52
type anon_232;
type anon_233 is record
target_state : aliased GstState; -- gst/gstelement.h:575
start_time : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/gstelement.h:577
end record;
pragma Convention (C_Pass_By_Copy, anon_233);
type u_GstElement_u_gst_reserved_array is array (0 .. 3) of System.Address;
type anon_232 (discr : unsigned := 0) is record
case discr is
when 0 =>
ABI : aliased anon_233; -- gst/gstelement.h:578
when others =>
u_gst_reserved : u_GstElement_u_gst_reserved_array; -- gst/gstelement.h:580
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_232);
pragma Unchecked_Union (anon_232);--subtype GstElement is u_GstElement; -- gst/gstelement.h:28
type GstElementClass;
type u_GstElementClass_u_gst_reserved_array is array (0 .. 0) of System.Address;
--subtype GstElementClass is u_GstElementClass; -- gst/gstelement.h:29
-- gstmessage.h needs State
--*
-- * GstState:
-- * @GST_STATE_VOID_PENDING: no pending state.
-- * @GST_STATE_NULL : the NULL state or initial state of an element.
-- * @GST_STATE_READY : the element is ready to go to PAUSED.
-- * @GST_STATE_PAUSED : the element is PAUSED, it is ready to accept and
-- * process data. Sink elements however only accept one
-- * buffer and then block.
-- * @GST_STATE_PLAYING : the element is PLAYING, the #GstClock is running and
-- * the data is flowing.
-- *
-- * The possible states an element can be in. States can be changed using
-- * gst_element_set_state() and checked using gst_element_get_state().
--
--*
-- * GstStateChangeReturn:
-- * @GST_STATE_CHANGE_FAILURE : the state change failed
-- * @GST_STATE_CHANGE_SUCCESS : the state change succeeded
-- * @GST_STATE_CHANGE_ASYNC : the state change will happen asynchronously
-- * @GST_STATE_CHANGE_NO_PREROLL: the state change succeeded but the element
-- * cannot produce data in %GST_STATE_PAUSED.
-- * This typically happens with live sources.
-- *
-- * The possible return values from a state change function such as
-- * gst_element_set_state(). Only @GST_STATE_CHANGE_FAILURE is a real failure.
--
type GstStateChangeReturn is
(GST_STATE_CHANGE_FAILURE,
GST_STATE_CHANGE_SUCCESS,
GST_STATE_CHANGE_ASYNC,
GST_STATE_CHANGE_NO_PREROLL);
pragma Convention (C, GstStateChangeReturn); -- gst/gstelement.h:96
-- NOTE: this probably should be done with an #ifdef to decide
-- * whether to safe-cast or to just do the non-checking cast.
--
--*
-- * GST_STATE:
-- * @elem: a #GstElement to return state for.
-- *
-- * This macro returns the current #GstState of the element.
--
--*
-- * GST_STATE_NEXT:
-- * @elem: a #GstElement to return the next state for.
-- *
-- * This macro returns the next #GstState of the element.
--
--*
-- * GST_STATE_PENDING:
-- * @elem: a #GstElement to return the pending state for.
-- *
-- * This macro returns the currently pending #GstState of the element.
--
--*
-- * GST_STATE_TARGET:
-- * @elem: a #GstElement to return the target state for.
-- *
-- * This macro returns the target #GstState of the element.
-- *
-- * Since: 0.10.13
--
--*
-- * GST_STATE_RETURN:
-- * @elem: a #GstElement to return the last state result for.
-- *
-- * This macro returns the last #GstStateChangeReturn value.
--
--*
-- * GST_STATE_GET_NEXT:
-- * @cur: A starting #GstState
-- * @pending: A target #GstState
-- *
-- * Given a current state @cur and a target state @pending, calculate the next (intermediate)
-- * #GstState.
--
--*
-- * GST_STATE_TRANSITION:
-- * @cur: A current state
-- * @next: A next state
-- *
-- * Given a current state @cur and a next state @next, calculate the associated
-- * #GstStateChange transition.
--
--*
-- * GST_STATE_TRANSITION_CURRENT:
-- * @trans: A #GstStateChange
-- *
-- * Given a state transition @trans, extract the current #GstState.
--
--*
-- * GST_STATE_TRANSITION_NEXT:
-- * @trans: A #GstStateChange
-- *
-- * Given a state transition @trans, extract the next #GstState.
--
--*
-- * GstStateChange:
-- * @GST_STATE_CHANGE_NULL_TO_READY : state change from NULL to READY.
-- * <itemizedlist>
-- * <listitem><para>
-- * The element must check if the resources it needs are available. Device
-- * sinks and -sources typically try to probe the device to constrain their
-- * caps.
-- * </para></listitem>
-- * <listitem><para>
-- * The element opens the device (in case feature need to be probed).
-- * </para></listitem>
-- * </itemizedlist>
-- * @GST_STATE_CHANGE_READY_TO_PAUSED : state change from READY to PAUSED.
-- * <itemizedlist>
-- * <listitem><para>
-- * The element pads are activated in order to receive data in PAUSED.
-- * Streaming threads are started.
-- * </para></listitem>
-- * <listitem><para>
-- * Some elements might need to return %GST_STATE_CHANGE_ASYNC and complete
-- * the state change when they have enough information. It is a requirement
-- * for sinks to return %GST_STATE_CHANGE_ASYNC and complete the state change
-- * when they receive the first buffer or %GST_EVENT_EOS (preroll).
-- * Sinks also block the dataflow when in PAUSED.
-- * </para></listitem>
-- * <listitem><para>
-- * A pipeline resets the running_time to 0.
-- * </para></listitem>
-- * <listitem><para>
-- * Live sources return %GST_STATE_CHANGE_NO_PREROLL and don't generate data.
-- * </para></listitem>
-- * </itemizedlist>
-- * @GST_STATE_CHANGE_PAUSED_TO_PLAYING: state change from PAUSED to PLAYING.
-- * <itemizedlist>
-- * <listitem><para>
-- * Most elements ignore this state change.
-- * </para></listitem>
-- * <listitem><para>
-- * The pipeline selects a #GstClock and distributes this to all the children
-- * before setting them to PLAYING. This means that it is only alowed to
-- * synchronize on the #GstClock in the PLAYING state.
-- * </para></listitem>
-- * <listitem><para>
-- * The pipeline uses the #GstClock and the running_time to calculate the
-- * base_time. The base_time is distributed to all children when performing
-- * the state change.
-- * </para></listitem>
-- * <listitem><para>
-- * Sink elements stop blocking on the preroll buffer or event and start
-- * rendering the data.
-- * </para></listitem>
-- * <listitem><para>
-- * Sinks can post %GST_MESSAGE_EOS in the PLAYING state. It is not allowed
-- * to post %GST_MESSAGE_EOS when not in the PLAYING state.
-- * </para></listitem>
-- * <listitem><para>
-- * While streaming in PAUSED or PLAYING elements can create and remove
-- * sometimes pads.
-- * </para></listitem>
-- * <listitem><para>
-- * Live sources start generating data and return %GST_STATE_CHANGE_SUCCESS.
-- * </para></listitem>
-- * </itemizedlist>
-- * @GST_STATE_CHANGE_PLAYING_TO_PAUSED: state change from PLAYING to PAUSED.
-- * <itemizedlist>
-- * <listitem><para>
-- * Most elements ignore this state change.
-- * </para></listitem>
-- * <listitem><para>
-- * The pipeline calculates the running_time based on the last selected
-- * #GstClock and the base_time. It stores this information to continue
-- * playback when going back to the PLAYING state.
-- * </para></listitem>
-- * <listitem><para>
-- * Sinks unblock any #GstClock wait calls.
-- * </para></listitem>
-- * <listitem><para>
-- * When a sink does not have a pending buffer to play, it returns
-- * %GST_STATE_CHANGE_ASYNC from this state change and completes the state
-- * change when it receives a new buffer or an %GST_EVENT_EOS.
-- * </para></listitem>
-- * <listitem><para>
-- * Any queued %GST_MESSAGE_EOS items are removed since they will be reposted
-- * when going back to the PLAYING state. The EOS messages are queued in
-- * #GstBin containers.
-- * </para></listitem>
-- * <listitem><para>
-- * Live sources stop generating data and return %GST_STATE_CHANGE_NO_PREROLL.
-- * </para></listitem>
-- * </itemizedlist>
-- * @GST_STATE_CHANGE_PAUSED_TO_READY : state change from PAUSED to READY.
-- * <itemizedlist>
-- * <listitem><para>
-- * Sinks unblock any waits in the preroll.
-- * </para></listitem>
-- * <listitem><para>
-- * Elements unblock any waits on devices
-- * </para></listitem>
-- * <listitem><para>
-- * Chain or get_range functions return %GST_FLOW_WRONG_STATE.
-- * </para></listitem>
-- * <listitem><para>
-- * The element pads are deactivated so that streaming becomes impossible and
-- * all streaming threads are stopped.
-- * </para></listitem>
-- * <listitem><para>
-- * The sink forgets all negotiated formats
-- * </para></listitem>
-- * <listitem><para>
-- * Elements remove all sometimes pads
-- * </para></listitem>
-- * </itemizedlist>
-- * @GST_STATE_CHANGE_READY_TO_NULL : state change from READY to NULL.
-- * <itemizedlist>
-- * <listitem><para>
-- * Elements close devices
-- * </para></listitem>
-- * <listitem><para>
-- * Elements reset any internal state.
-- * </para></listitem>
-- * </itemizedlist>
-- *
-- * These are the different state changes an element goes through.
-- * %GST_STATE_NULL ⇒ %GST_STATE_PLAYING is called an upwards state change
-- * and %GST_STATE_PLAYING ⇒ %GST_STATE_NULL a downwards state change.
--
--< flags=0 >
subtype GstStateChange is unsigned;
GST_STATE_CHANGE_NULL_TO_READY : constant GstStateChange := 10;
GST_STATE_CHANGE_READY_TO_PAUSED : constant GstStateChange := 19;
GST_STATE_CHANGE_PAUSED_TO_PLAYING : constant GstStateChange := 28;
GST_STATE_CHANGE_PLAYING_TO_PAUSED : constant GstStateChange := 35;
GST_STATE_CHANGE_PAUSED_TO_READY : constant GstStateChange := 26;
GST_STATE_CHANGE_READY_TO_NULL : constant GstStateChange := 17; -- gst/gstelement.h:313
--*
-- * GstElementFlags:
-- * @GST_ELEMENT_LOCKED_STATE: ignore state changes from parent
-- * @GST_ELEMENT_IS_SINK: the element is a sink
-- * @GST_ELEMENT_UNPARENTING: Child is being removed from the parent bin.
-- * gst_bin_remove() on a child already being removed immediately returns FALSE
-- * @GST_ELEMENT_IS_SOURCE: the element is a source. Since 0.10.31
-- * @GST_ELEMENT_FLAG_LAST: offset to define more flags
-- *
-- * The standard flags that an element may have.
--
-- padding
subtype GstElementFlags is unsigned;
GST_ELEMENT_LOCKED_STATE : constant GstElementFlags := 16;
GST_ELEMENT_IS_SINK : constant GstElementFlags := 32;
GST_ELEMENT_UNPARENTING : constant GstElementFlags := 64;
GST_ELEMENT_IS_SOURCE : constant GstElementFlags := 128;
GST_ELEMENT_FLAG_LAST : constant GstElementFlags := 1048576; -- gst/gstelement.h:334
--*
-- * GST_ELEMENT_IS_LOCKED_STATE:
-- * @elem: A #GstElement to query
-- *
-- * Check if the element is in the locked state and therefore will ignore state
-- * changes from its parent object.
--
--*
-- * GST_ELEMENT_NAME:
-- * @elem: A #GstElement to query
-- *
-- * Gets the name of this element. Use only in core as this is not
-- * ABI-compatible. Others use gst_element_get_name()
--
--*
-- * GST_ELEMENT_PARENT:
-- * @elem: A #GstElement to query
-- *
-- * Get the parent object of this element.
--
--*
-- * GST_ELEMENT_BUS:
-- * @elem: A #GstElement to query
-- *
-- * Get the message bus of this element.
--
--*
-- * GST_ELEMENT_CLOCK:
-- * @elem: A #GstElement to query
-- *
-- * Get the clock of this element
--
--*
-- * GST_ELEMENT_PADS:
-- * @elem: A #GstElement to query
-- *
-- * Get the pads of this elements.
--
--*
-- * GST_ELEMENT_START_TIME:
-- * @elem: a #GstElement to return the start time for.
-- *
-- * This macro returns the start_time of the @elem. The start_time is the
-- * running_time of the pipeline when the element went to PAUSED.
-- *
-- * Since: 0.10.24
--
--*
-- * GST_ELEMENT_ERROR:
-- * @el: the element that generates the error
-- * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
-- * @code: error code defined for that domain (see #gstreamer-GstGError)
-- * @text: the message to display (format string and args enclosed in
-- parentheses)
-- * @debug: debugging information for the message (format string and args
-- enclosed in parentheses)
-- *
-- * Utility function that elements can use in case they encountered a fatal
-- * data processing error. The pipeline will post an error message and the
-- * application will be requested to stop further media processing.
--
--*
-- * GST_ELEMENT_WARNING:
-- * @el: the element that generates the warning
-- * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
-- * @code: error code defined for that domain (see #gstreamer-GstGError)
-- * @text: the message to display (format string and args enclosed in
-- parentheses)
-- * @debug: debugging information for the message (format string and args
-- enclosed in parentheses)
-- *
-- * Utility function that elements can use in case they encountered a non-fatal
-- * data processing problem. The pipeline will post a warning message and the
-- * application will be informed.
--
--*
-- * GST_ELEMENT_INFO:
-- * @el: the element that generates the information
-- * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
-- * @code: error code defined for that domain (see #gstreamer-GstGError)
-- * @text: the message to display (format string and args enclosed in
-- parentheses)
-- * @debug: debugging information for the message (format string and args
-- enclosed in parentheses)
-- *
-- * Utility function that elements can use in case they want to inform
-- * the application of something noteworthy that is not an error.
-- * The pipeline will post a info message and the
-- * application will be informed.
-- *
-- * Since: 0.10.12
--
-- the state change mutexes and conds
--*
-- * GST_STATE_GET_LOCK:
-- * @elem: a #GstElement
-- *
-- * Get a reference to the state lock of @elem.
-- * This lock is used by the core. It is taken while getting or setting
-- * the state, during state changes, and while finalizing.
--
--*
-- * GST_STATE_GET_COND:
-- * @elem: a #GstElement
-- *
-- * Get the conditional used to signal the completion of a state change.
--
--*
-- * GstElement:
-- * @state_lock: Used to serialize execution of gst_element_set_state()
-- * @state_cond: Used to signal completion of a state change
-- * @state_cookie: Used to detect concurrent execution of
-- * gst_element_set_state() and gst_element_get_state()
-- * @current_state: the current state of an element
-- * @next_state: the next state of an element, can be #GST_STATE_VOID_PENDING if
-- * the element is in the correct state.
-- * @pending_state: the final state the element should go to, can be
-- * #GST_STATE_VOID_PENDING if the element is in the correct state
-- * @last_return: the last return value of an element state change
-- * @bus: the bus of the element. This bus is provided to the element by the
-- * parent element or the application. A #GstPipeline has a bus of its own.
-- * @clock: the clock of the element. This clock is usually provided to the
-- * element by the toplevel #GstPipeline.
-- * @base_time: the time of the clock right before the element is set to
-- * PLAYING. Subtracting @base_time from the current clock time in the PLAYING
-- * state will yield the running_time against the clock.
-- * @numpads: number of pads of the element, includes both source and sink pads.
-- * @pads: list of pads
-- * @numsrcpads: number of source pads of the element.
-- * @srcpads: list of source pads
-- * @numsinkpads: number of sink pads of the element.
-- * @sinkpads: list of sink pads
-- * @pads_cookie: updated whenever the a pad is added or removed
-- *
-- * GStreamer element abstract base class.
--
type GstElement is record
object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/gstelement.h:542
state_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/gstelement.h:545
state_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstelement.h:548
state_cookie : aliased GLIB.guint32; -- gst/gstelement.h:549
current_state : aliased GstState; -- gst/gstelement.h:550
next_state : aliased GstState; -- gst/gstelement.h:551
pending_state : aliased GstState; -- gst/gstelement.h:552
last_return : aliased GstStateChangeReturn; -- gst/gstelement.h:553
bus : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus; -- gst/gstelement.h:555
clock : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:558
base_time : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTimeDiff; -- gst/gstelement.h:559
numpads : aliased GLIB.guint16; -- gst/gstelement.h:563
pads : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:564
numsrcpads : aliased GLIB.guint16; -- gst/gstelement.h:565
srcpads : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:566
numsinkpads : aliased GLIB.guint16; -- gst/gstelement.h:567
sinkpads : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:568
pads_cookie : aliased GLIB.guint32; -- gst/gstelement.h:569
abidata : aliased anon_232; -- gst/gstelement.h:581
end record;
pragma Convention (C_Pass_By_Copy, GstElement); -- gst/gstelement.h:540
--< public >
-- with LOCK
-- element state
-- allocated clock
-- NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock
-- element pads, these lists can only be iterated while holding
-- * the LOCK or checking the cookie after each LOCK.
--< private >
-- state set by application
-- running time of the last PAUSED state
-- adding + 0 to mark ABI change to be undone later
--*
-- * GstElementClass:
-- * @parent_class: the parent class structure
-- * @details: #GstElementDetails for elements of this class
-- * @elementfactory: the #GstElementFactory that creates these elements
-- * @padtemplates: a #GList of #GstPadTemplate
-- * @numpadtemplates: the number of padtemplates
-- * @pad_templ_cookie: changed whenever the padtemplates change
-- * @request_new_pad: called when a new pad is requested
-- * @release_pad: called when a request pad is to be released
-- * @get_state: get the state of the element
-- * @set_state: set a new state on the element
-- * @change_state: called by @set_state to perform an incremental state change
-- * @set_bus: set a #GstBus on the element
-- * @provide_clock: gets the #GstClock provided by the element
-- * @set_clock: set the #GstClock on the element
-- * @get_index: set a #GstIndex on the element
-- * @set_index: get the #GstIndex of an element
-- * @send_event: send a #GstEvent to the element
-- * @get_query_types: get the supported #GstQueryType of this element
-- * @query: perform a #GstQuery on the element
-- * @request_new_pad_full: called when a new pad is requested. Since: 0.10.32.
-- * @state_changed: called immediately after a new state was set. Since: 0.10.36.
-- *
-- * GStreamer element class. Override the vmethods to implement the element
-- * functionality.
--
type GstElementClass is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/gstelement.h:613
details : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementDetails; -- gst/gstelement.h:618
elementfactory : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementFactory; -- gst/gstelement.h:621
padtemplates : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:624
numpadtemplates : aliased GLIB.gint; -- gst/gstelement.h:625
pad_templ_cookie : aliased GLIB.guint32; -- gst/gstelement.h:626
pad_added : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:630
pad_removed : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:631
no_more_pads : access procedure (arg1 : access GstElement); -- gst/gstelement.h:632
request_new_pad : access function
(arg1 : access GstElement;
arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate;
arg3 : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:638
release_pad : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:639
get_state : access function
(arg1 : access GstElement;
arg2 : access GstState;
arg3 : access GstState;
arg4 : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GstStateChangeReturn; -- gst/gstelement.h:643
set_state : access function (arg1 : access GstElement; arg2 : GstState) return GstStateChangeReturn; -- gst/gstelement.h:644
change_state : access function (arg1 : access GstElement; arg2 : GstStateChange) return GstStateChangeReturn; -- gst/gstelement.h:645
set_bus : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus); -- gst/gstelement.h:648
provide_clock : access function (arg1 : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:651
set_clock : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock) return GLIB.gboolean; -- gst/gstelement.h:652
get_index : access function (arg1 : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex; -- gst/gstelement.h:655
set_index : access procedure (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex); -- gst/gstelement.h:656
send_event : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstelement.h:659
get_query_types : access function (arg1 : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstelement.h:661
query : access function (arg1 : access GstElement; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstelement.h:662
meta_data : System.Address; -- gst/gstelement.h:666
request_new_pad_full : access function
(arg1 : access GstElement;
arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate;
arg3 : access GLIB.gchar;
arg4 : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:672
state_changed : access procedure
(arg1 : access GstElement;
arg2 : GstState;
arg3 : GstState;
arg4 : GstState); -- gst/gstelement.h:675
u_gst_reserved : u_GstElementClass_u_gst_reserved_array; -- gst/gstelement.h:678
end record;
pragma Convention (C_Pass_By_Copy, GstElementClass); -- gst/gstelement.h:611
--< public >
-- the element details
-- FIXME-0.11: deprecate this in favour of meta_data
-- factory that the element was created from
-- templates for our pads
--< private >
-- signal callbacks
--< public >
-- virtual methods for subclasses
-- request/release pads
-- state changes
-- bus
-- set/get clocks
-- index
-- query functions
--< private >
-- FIXME-0.11: move up and replace details
--< public >
-- Virtual method for subclasses (additions)
-- FIXME-0.11 Make this the default behaviour
--< private >
-- element class pad templates
procedure gst_element_class_add_pad_template (klass : access GstElementClass; templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate); -- gst/gstelement.h:682
pragma Import (C, gst_element_class_add_pad_template, "gst_element_class_add_pad_template");
procedure gst_element_class_add_static_pad_template (klass : access GstElementClass; templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstStaticPadTemplate); -- gst/gstelement.h:683
pragma Import (C, gst_element_class_add_static_pad_template, "gst_element_class_add_static_pad_template");
function gst_element_class_get_pad_template (element_class : access GstElementClass; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstelement.h:684
pragma Import (C, gst_element_class_get_pad_template, "gst_element_class_get_pad_template");
function gst_element_class_get_pad_template_list (element_class : access GstElementClass) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstelement.h:685
pragma Import (C, gst_element_class_get_pad_template_list, "gst_element_class_get_pad_template_list");
-- element class meta data
procedure gst_element_class_set_documentation_uri (klass : access GstElementClass; uri : access GLIB.gchar); -- gst/gstelement.h:688
pragma Import (C, gst_element_class_set_documentation_uri, "gst_element_class_set_documentation_uri");
procedure gst_element_class_set_icon_name (klass : access GstElementClass; name : access GLIB.gchar); -- gst/gstelement.h:689
pragma Import (C, gst_element_class_set_icon_name, "gst_element_class_set_icon_name");
procedure gst_element_class_set_details (klass : access GstElementClass; details : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementDetails); -- gst/gstelement.h:691
pragma Import (C, gst_element_class_set_details, "gst_element_class_set_details");
procedure gst_element_class_set_details_simple
(klass : access GstElementClass;
longname : access GLIB.gchar;
classification : access GLIB.gchar;
description : access GLIB.gchar;
author : access GLIB.gchar); -- gst/gstelement.h:693
pragma Import (C, gst_element_class_set_details_simple, "gst_element_class_set_details_simple");
-- element instance
function gst_element_get_type return GLIB.GType; -- gst/gstelement.h:700
pragma Import (C, gst_element_get_type, "gst_element_get_type");
-- basic name and parentage stuff from GstObject
--*
-- * gst_element_get_name:
-- * @elem: a #GstElement to get the name of @elem.
-- *
-- * Returns a copy of the name of @elem.
-- * Caller should g_free() the return value after usage.
-- * For a nameless element, this returns NULL, which you can safely g_free()
-- * as well.
-- *
-- * Returns: (transfer full): the name of @elem. g_free() after usage. MT safe.
-- *
--
--*
-- * gst_element_set_name:
-- * @elem: a #GstElement to set the name of.
-- * @name: the new name
-- *
-- * Sets the name of the element, getting rid of the old name if there was one.
--
--*
-- * gst_element_get_parent:
-- * @elem: a #GstElement to get the parent of.
-- *
-- * Get the parent of an element.
-- *
-- * Returns: (transfer full): the parent of an element.
--
--*
-- * gst_element_set_parent:
-- * @elem: a #GstElement to set the parent of.
-- * @parent: the new parent #GstObject of the element.
-- *
-- * Sets the parent of an element.
--
-- clocking
function gst_element_requires_clock (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:747
pragma Import (C, gst_element_requires_clock, "gst_element_requires_clock");
function gst_element_provides_clock (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:748
pragma Import (C, gst_element_provides_clock, "gst_element_provides_clock");
function gst_element_provide_clock (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:749
pragma Import (C, gst_element_provide_clock, "gst_element_provide_clock");
function gst_element_get_clock (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock; -- gst/gstelement.h:750
pragma Import (C, gst_element_get_clock, "gst_element_get_clock");
function gst_element_set_clock (element : access GstElement; clock : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClock) return GLIB.gboolean; -- gst/gstelement.h:751
pragma Import (C, gst_element_set_clock, "gst_element_set_clock");
procedure gst_element_set_base_time (element : access GstElement; time : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime); -- gst/gstelement.h:752
pragma Import (C, gst_element_set_base_time, "gst_element_set_base_time");
function gst_element_get_base_time (element : access GstElement) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/gstelement.h:753
pragma Import (C, gst_element_get_base_time, "gst_element_get_base_time");
procedure gst_element_set_start_time (element : access GstElement; time : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime); -- gst/gstelement.h:754
pragma Import (C, gst_element_set_start_time, "gst_element_set_start_time");
function gst_element_get_start_time (element : access GstElement) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/gstelement.h:755
pragma Import (C, gst_element_get_start_time, "gst_element_get_start_time");
-- indexes
function gst_element_is_indexable (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:758
pragma Import (C, gst_element_is_indexable, "gst_element_is_indexable");
procedure gst_element_set_index (element : access GstElement; index : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex); -- gst/gstelement.h:759
pragma Import (C, gst_element_set_index, "gst_element_set_index");
function gst_element_get_index (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstindex_h.GstIndex; -- gst/gstelement.h:760
pragma Import (C, gst_element_get_index, "gst_element_get_index");
-- bus
procedure gst_element_set_bus (element : access GstElement; bus : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus); -- gst/gstelement.h:763
pragma Import (C, gst_element_set_bus, "gst_element_set_bus");
function gst_element_get_bus (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbus_h.GstBus; -- gst/gstelement.h:764
pragma Import (C, gst_element_get_bus, "gst_element_get_bus");
-- pad management
function gst_element_add_pad (element : access GstElement; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad) return GLIB.gboolean; -- gst/gstelement.h:767
pragma Import (C, gst_element_add_pad, "gst_element_add_pad");
function gst_element_remove_pad (element : access GstElement; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad) return GLIB.gboolean; -- gst/gstelement.h:768
pragma Import (C, gst_element_remove_pad, "gst_element_remove_pad");
procedure gst_element_no_more_pads (element : access GstElement); -- gst/gstelement.h:769
pragma Import (C, gst_element_no_more_pads, "gst_element_no_more_pads");
function gst_element_get_pad (element : access GstElement; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:772
pragma Import (C, gst_element_get_pad, "gst_element_get_pad");
function gst_element_get_static_pad (element : access GstElement; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:774
pragma Import (C, gst_element_get_static_pad, "gst_element_get_static_pad");
function gst_element_get_request_pad (element : access GstElement; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:775
pragma Import (C, gst_element_get_request_pad, "gst_element_get_request_pad");
function gst_element_request_pad
(element : access GstElement;
templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate;
name : access GLIB.gchar;
caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/gstelement.h:776
pragma Import (C, gst_element_request_pad, "gst_element_request_pad");
procedure gst_element_release_request_pad (element : access GstElement; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad); -- gst/gstelement.h:779
pragma Import (C, gst_element_release_request_pad, "gst_element_release_request_pad");
function gst_element_iterate_pads (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstelement.h:781
pragma Import (C, gst_element_iterate_pads, "gst_element_iterate_pads");
function gst_element_iterate_src_pads (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstelement.h:782
pragma Import (C, gst_element_iterate_src_pads, "gst_element_iterate_src_pads");
function gst_element_iterate_sink_pads (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstelement.h:783
pragma Import (C, gst_element_iterate_sink_pads, "gst_element_iterate_sink_pads");
-- event/query/format stuff
function gst_element_send_event (element : access GstElement; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstelement.h:786
pragma Import (C, gst_element_send_event, "gst_element_send_event");
function gst_element_seek
(element : access GstElement;
rate : GLIB.gdouble;
format : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat;
flags : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstSeekFlags;
cur_type : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstSeekType;
cur : GLIB.gint64;
stop_type : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstSeekType;
stop : GLIB.gint64) return GLIB.gboolean; -- gst/gstelement.h:787
pragma Import (C, gst_element_seek, "gst_element_seek");
function gst_element_get_query_types (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstelement.h:791
pragma Import (C, gst_element_get_query_types, "gst_element_get_query_types");
function gst_element_query (element : access GstElement; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstelement.h:792
pragma Import (C, gst_element_query, "gst_element_query");
-- messages
function gst_element_post_message (element : access GstElement; message : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstmessage_h.GstMessage) return GLIB.gboolean; -- gst/gstelement.h:795
pragma Import (C, gst_element_post_message, "gst_element_post_message");
-- error handling
-- gcc versions < 3.3 warn about NULL being passed as format to printf
-- skipped func _gst_element_error_printf
procedure gst_element_message_full
(element : access GstElement;
c_type : int;
domain : Glib.GQuark;
code : GLIB.gint;
text : access GLIB.gchar;
debug : access GLIB.gchar;
file : access GLIB.gchar;
c_function : access GLIB.gchar;
line : GLIB.gint); -- gst/gstelement.h:804
pragma Import (C, gst_element_message_full, "gst_element_message_full");
-- state management
function gst_element_is_locked_state (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:810
pragma Import (C, gst_element_is_locked_state, "gst_element_is_locked_state");
function gst_element_set_locked_state (element : access GstElement; locked_state : GLIB.gboolean) return GLIB.gboolean; -- gst/gstelement.h:811
pragma Import (C, gst_element_set_locked_state, "gst_element_set_locked_state");
function gst_element_sync_state_with_parent (element : access GstElement) return GLIB.gboolean; -- gst/gstelement.h:812
pragma Import (C, gst_element_sync_state_with_parent, "gst_element_sync_state_with_parent");
function gst_element_get_state
(element : access GstElement;
state : access GstState;
pending : access GstState;
timeout : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GstStateChangeReturn; -- gst/gstelement.h:814
pragma Import (C, gst_element_get_state, "gst_element_get_state");
function gst_element_set_state (element : access GstElement; state : GstState) return GstStateChangeReturn; -- gst/gstelement.h:818
pragma Import (C, gst_element_set_state, "gst_element_set_state");
procedure gst_element_abort_state (element : access GstElement); -- gst/gstelement.h:820
pragma Import (C, gst_element_abort_state, "gst_element_abort_state");
function gst_element_change_state (element : access GstElement; transition : GstStateChange) return GstStateChangeReturn; -- gst/gstelement.h:821
pragma Import (C, gst_element_change_state, "gst_element_change_state");
function gst_element_continue_state (element : access GstElement; ret : GstStateChangeReturn) return GstStateChangeReturn; -- gst/gstelement.h:823
pragma Import (C, gst_element_continue_state, "gst_element_continue_state");
procedure gst_element_lost_state (element : access GstElement); -- gst/gstelement.h:825
pragma Import (C, gst_element_lost_state, "gst_element_lost_state");
procedure gst_element_lost_state_full (element : access GstElement; new_base_time : GLIB.gboolean); -- gst/gstelement.h:826
pragma Import (C, gst_element_lost_state_full, "gst_element_lost_state_full");
-- factory management
function gst_element_get_factory (element : access GstElement) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelementfactory_h.GstElementFactory; -- gst/gstelement.h:829
pragma Import (C, gst_element_get_factory, "gst_element_get_factory");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
|
29,854
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/renaming2_pkg4.ads
|
-- { dg-excess-errors "no code generated" }
generic
type Length_T is range <>;
with function Next return Length_T is <>;
type Value_T is private;
with function Value (L : Length_T) return Value_T is <>;
package Renaming2_Pkg4 is
generic
type T is private;
package Inner is
type Slave_T is tagged null record;
function Next_Value return Value_T;
end Inner;
end Renaming2_Pkg4;
|
29,855
|
ada
| 0
|
python36/0xfa
|
src/numbers.adb
|
<reponame>python36/0xfa<filename>src/numbers.adb<gh_stars>0
package body numbers is
procedure inc (p_i : in out integer) is begin p_i := p_i + 1; end inc;
procedure dec (p_i : in out integer) is begin p_i := p_i - 1; end dec;
procedure inc (p_i : in out word) is begin p_i := p_i + 1; end inc;
procedure dec (p_i : in out word) is begin p_i := p_i - 1; end dec;
procedure inc (p_i : in out byte) is begin p_i := p_i + 1; end inc;
procedure dec (p_i : in out byte) is begin p_i := p_i - 1; end dec;
procedure incd (p_i : in out byte) is begin p_i := p_i + 2; end incd;
procedure incd (p_i : in out word) is begin p_i := p_i + 2; end incd;
function incd (p_i : word) return word is begin return p_i + 2; end incd;
procedure decd (p_i : in out word) is begin p_i := p_i - 2; end decd;
function swpb (w : word) return word is begin return sr(w, 8) or sl(w, 8); end swpb;
procedure swpb (w : in out word) is begin w := swpb(w); end swpb;
function words_add (a, b : word) return word is begin return a + b; end words_add;
function words_sub (a, b : word) return word is begin return a - b; end words_sub;
function words_mul (a, b : word) return word is begin return a * b; end words_mul;
function words_div (a, b : word) return word is begin return a / b; end words_div;
function words_pow (a, b : word) return word is begin return a ** natural(b); end words_pow;
function words_mod (a, b : word) return word is begin return a mod b; end words_mod;
function words_or (a, b : word) return word is begin return a or b; end words_or;
function words_and (a, b : word) return word is begin return a and b; end words_and;
function words_xor (a, b : word) return word is begin return a xor b; end words_xor;
function words_sl (a, b : word) return word is begin return sl(a, natural(b)); end words_sl;
function words_sr (a, b : word) return word is begin return sr(a, natural(b)); end words_sr;
function word_to_integer (w : word) return integer is
use type interfaces.unsigned_32;
begin
return uint32_to_integer(
(4294934528 * interfaces.unsigned_32(sr(w, 15))) or interfaces.unsigned_32(w));
end word_to_integer;
function validate_word (str : string) return boolean is
begin
void(value(str));
return true;
exception
when constraint_error => return false;
end validate_word;
function value (str : string) return word is
t_i : integer;
begin
if str(str'first) = '-' then
t_i := integer'value(str);
if t_i < -32768 then
raise constraint_error;
end if;
return integer_to_word(t_i);
elsif str'length > 2 and then str(str'first..(str'first + 1)) = "0x" then
return word'value("16#" & str((str'first + 2)..str'last) & '#');
else
return word'value(str);
end if;
end value;
procedure void (w : word) is
begin
null;
end void;
function to_positive (b : boolean; v : positive := 1) return positive is
begin
if b then
return v;
end if;
return positive'first;
end to_positive;
function to_natural (b : boolean; v : natural := 1) return natural is
begin
if b then
return v;
end if;
return natural'first;
end to_natural;
function to_word (b : boolean; v : word := 1) return word is
begin
if b then
return v;
end if;
return word'first;
end to_word;
function get_max_image_length (base : positive; val : word := word'last) return positive is
begin
if val = 0 then
return 1;
end if;
return positive(long_float'floor(word_func.log(x => long_float(val), base => long_float(base))) + 1.0);
end get_max_image_length;
function image (w : word; base : positive; fix_size : boolean := true) return string is
pragma assertion_policy (CHECK);
pragma assert (
base in ada.text_io.number_base'range,
string'("base " & base'img & " not in range " & ada.text_io.number_base'first'img & ".." & ada.text_io.number_base'last'img));
base_img_len : constant positive := base'img'length;
str : string(1..get_max_image_length(base, w) + base_img_len + 1) := (others => '*');
begin
natural_io.put(str, natural(w), base);
if fix_size then
return ada.strings.fixed.tail(str((str'first + base_img_len)..(str'last - 1)), get_max_image_length(base, word'last), '0');
end if;
return str((str'first + base_img_len)..(str'last - 1));
end image;
function hex (w : word; fix_size : boolean := true) return string is
begin
return "0x" & image(w, 16, fix_size);
end hex;
function bin (w : word; fix_size : boolean := true) return string is
begin
return "0b" & image(w, 2, fix_size);
end bin;
function odd (w : word) return boolean is
begin
return (w and 1) = 1;
end odd;
function even (w : word) return boolean is
begin
return (w and 1) = 0;
end even;
end numbers;
|
29,856
|
ada
| 0
|
zorodc/true-libs
|
stack/stack.adb
|
<gh_stars>0
pragma SPARK_Mode(On);
package body Stack is
function Top (S : in Stack) return Thing is (S.Elements (S.Quantity));
procedure Pop (S : in out Stack) is
begin S.Quantity := S.Quantity - 1; end Pop;
procedure Put (S : in out Stack; E : Thing) is
begin
S.Quantity := S.Quantity + 1;
S.Elements (S.Quantity) := E;
end Put;
end Stack;
|
29,857
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/vect16.ads
|
package Vect16 is
type Sarray is array (1 .. 4) of Long_Float;
for Sarray'Alignment use 16;
procedure Add_Sub (X, Y : Sarray; R,S : out Sarray);
end Vect16;
|
29,858
|
ada
| 0
|
Tim-Tom/project-euler
|
Ada/src/Problem_01.adb
|
<reponame>Tim-Tom/project-euler
with Ada.Integer_Text_IO;
with Ada.Text_IO;
package body Problem_01 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
procedure Solve is
sum : Integer := 0;
begin
for i in 1 .. 999 loop
if i mod 3 = 0 or i mod 5 = 0 then
sum := sum + i;
end if;
end loop;
I_IO.Put(sum);
IO.New_Line;
end Solve;
end Problem_01;
|
29,859
|
ada
| 0
|
JCGobbi/Nucleo-STM32G474RE
|
bb-runtimes/examples/monitor/common/srec.adb
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2013, 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System;
with System.Storage_Elements; use System.Storage_Elements;
with Interfaces; use Interfaces;
with Term; use Term;
with Console;
with Memwrite; use Memwrite;
package body Srec is
Has_Error : Boolean;
procedure Error (Msg : String) is
begin
Has_Error := True;
Console.Put_Line (Msg);
end Error;
procedure Read_Srec_Line is
C : Character;
begin
-- Read a line
Line_Len := 0;
loop
Console.Get (C);
case C is
when ASCII.LF =>
exit;
when ASCII.CR =>
null;
when others =>
if Line_Len = Line'Last then
Error ("Line too long");
Console.Put ("Line: ");
Console.Put_Line (Line);
return;
end if;
Line_Len := Line_Len + 1;
Line (Line_Len) := C;
end case;
end loop;
end Read_Srec_Line;
function Read_Hex (Pos : Line_Range) return Unsigned_8 is
H, L : Hex_Digit_Type;
begin
H := Read_Hex_Digit (Pos);
L := Read_Hex_Digit (Pos + 1);
if H = Bad_Hex or else L = Bad_Hex then
Error ("Bad hexa character");
return 0;
else
return Unsigned_8 (H * 16 + L);
end if;
end Read_Hex;
procedure Read_Srec is
Reclen : Unsigned_8;
Chksum : Unsigned_8;
P : Line_Range;
Addr : Unsigned_32;
B : Storage_Array (1 .. 1);
begin
Memwrite.Init;
Has_Error := False;
loop
-- Read a line
Read_Srec_Line;
if Has_Error then
return;
end if;
-- Check S-rec
if Line_Len = 0 then
-- Skip empty line (to easily deal with CR+LF).
null;
elsif Line_Len < 4
or else Line (1) /= 'S' or else Line (2) not in '0' .. '9'
then
Error ("Not an s-record");
return;
else
-- Check line length.
Reclen := Read_Hex (3);
if Line_Len /= Natural (Reclen) * 2 + 4 then
Error ("bad s-rec line length");
end if;
if Has_Error then
-- Either from read_hex or previous message
return;
end if;
-- Check integrity
Chksum := 0;
P := 3;
while P < Line_Len loop
Chksum := Chksum + Read_Hex (P);
P := P + 2;
end loop;
if Chksum /= 16#ff# then
Error ("Bad checksum");
end if;
if Has_Error then
-- Either from read_hex or previous message
return;
end if;
Reclen := Reclen - 1;
-- Handle record
case Line (2) is
when '0' =>
-- Block header are ignored
null;
when '5' =>
-- Record count is ignored
null;
when '1' | '2' | '8' | '9' =>
Error ("Only 4-bytes addresses handled");
return;
when '3' | '7' =>
-- Decode address
if Reclen < 4 then
Error ("Packet too short");
return;
end if;
Addr := 0;
for I in 1 .. 4 loop
Addr := Addr * 256 + Unsigned_32 (Read_Hex (3 + 2 * I));
-- Read_Hex already checked by checksum.
end loop;
if Line (2) = '7' then
-- Start address
if Reclen /= 4 then
Error ("Garbage for S7 record");
return;
end if;
Memwrite.Flush;
Memwrite.Exec_Addr := Addr;
Console.Put ('.');
return;
else
for I in 5 .. Reclen loop
B (1) :=
Storage_Element (Read_Hex (3 + Natural (2 * I)));
Memwrite.Write (Addr, B);
Addr := Addr + 1;
end loop;
end if;
when others =>
-- Won't happen
null;
end case;
Console.Put ('+');
end if;
end loop;
end Read_Srec;
end Srec;
|
29,860
|
ada
| 192
|
rocher/Ada_Drivers_Library
|
components/src/screen/pcd8544/pcd8544.adb
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of AdaCore nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body PCD8544 is
-------------------
-- Chip_Select --
-------------------
procedure Chip_Select (This : PCD8544_Device; Enabled : in Boolean)
is
begin
if This.CS /= null then
if Enabled then
This.CS.Clear;
else
This.CS.Set;
end if;
end if;
end Chip_Select;
-------------
-- Reset --
-------------
procedure Reset (This : in out PCD8544_Device) is
begin
if This.RST /= null then
This.RST.Clear;
This.RST.Set;
-- The datasheet specifies 100ns minimum for reset but this was
-- unreliable in testing, so we use a longer delay.
This.Time.Delay_Microseconds (100);
end if;
end Reset;
----------------
-- Transmit --
----------------
procedure Transmit (This : PCD8544_Device; Data : in UInt8) is
Status : SPI_Status;
begin
This.Chip_Select (True);
This.DC.Clear;
This.Port.Transmit (SPI_Data_8b'(1 => Data), Status);
This.Chip_Select (False);
if Status /= Ok then
raise SPI_Error with "PCD8544 SPI command transmit failed: " & Status'Image;
end if;
end Transmit;
----------------
-- Transmit --
----------------
procedure Transmit (This : PCD8544_Device; Data : in UInt8_Array) is
Status : SPI_Status;
begin
This.Chip_Select (True);
This.DC.Set;
This.Port.Transmit (SPI_Data_8b (Data), Status);
This.Chip_Select (False);
if Status /= Ok then
raise SPI_Error with "PCD8544 SPI data transmit failed: " & Status'Image;
end if;
end Transmit;
---------------------
-- Extended_Mode --
---------------------
procedure Extended_Mode (This : in out PCD8544_Device) is
begin
if This.FR.Extended_Mode /= True then
This.FR.Extended_Mode := True;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
end if;
end Extended_Mode;
------------------
-- Basic_Mode --
------------------
procedure Basic_Mode (This : in out PCD8544_Device) is
begin
if This.FR.Extended_Mode /= False then
This.FR.Extended_Mode := False;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
end if;
end Basic_Mode;
--------------------
-- Set_Contrast --
--------------------
procedure Set_Contrast
(This : in out PCD8544_Device;
Contrast : in PCD8544_Contrast) is
begin
This.Extended_Mode;
This.Transmit (PCD8544_CMD_SET_VOP or Contrast);
end Set_Contrast;
----------------
-- Set_Bias --
----------------
procedure Set_Bias
(This : in out PCD8544_Device;
Bias : in PCD8544_Bias) is
begin
This.Extended_Mode;
This.Transmit (PCD8544_CMD_SET_BIAS or Bias);
end Set_Bias;
-----------------------
-- Set_Temperature --
-----------------------
procedure Set_Temperature
(This : in out PCD8544_Device;
TC : in PCD8544_Temperature_Coefficient) is
begin
This.Extended_Mode;
This.Transmit (PCD8544_CMD_SET_TC or TC);
end Set_Temperature;
------------------------
-- Set_Display_Mode --
------------------------
procedure Set_Display_Mode
(This : in out PCD8544_Device;
Enable : in Boolean;
Invert : in Boolean) is
begin
This.Basic_Mode;
This.DR.Enable := Enable;
This.DR.Invert := Invert;
This.Transmit (PCD8544_CMD_DISPLAY or Convert (This.DR));
end Set_Display_Mode;
------------------
-- Initialize --
------------------
procedure Initialize (This : in out PCD8544_Device) is
Default_FR : PCD8544_Function_Register;
Default_DR : PCD8544_Display_Register;
begin
This.DC.Clear;
This.Reset;
This.FR := Default_FR;
This.DR := Default_DR;
-- Power on must be separate from other commands.
This.FR.Power_Down := False;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
This.Set_Contrast (PCD8544_Default_Contrast);
This.Set_Bias (PCD8544_Default_Bias);
This.Set_Temperature (PCD8544_Default_Temperature_Coefficient);
This.FR.Extended_Mode := False;
This.FR.Address_Mode := Vertical;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
This.Set_Display_Mode
(Enable => True,
Invert => True);
This.Device_Initialized := True;
end Initialize;
------------------------
-- Write_Raw_Pixels --
------------------------
procedure Write_Raw_Pixels
(This : in out PCD8544_Device;
Data : UInt8_Array)
is
begin
This.Chip_Select (True);
This.Basic_Mode;
This.Transmit (PCD8544_CMD_SET_X or 0);
This.Transmit (PCD8544_CMD_SET_Y or 0);
This.Transmit (Data);
This.Chip_Select (False);
end Write_Raw_Pixels;
-------------------
-- Initialized --
-------------------
overriding function Initialized (This : PCD8544_Device) return Boolean is
(This.Device_Initialized);
------------------
-- Max_Layers --
------------------
overriding function Max_Layers (This : PCD8544_Device) return Positive is
(1);
-----------------
-- Supported --
-----------------
overriding function Supported
(This : PCD8544_Device; Mode : FB_Color_Mode) return Boolean is
(Mode = HAL.Bitmap.M_1);
-----------------------
-- Set_Orientation --
-----------------------
overriding procedure Set_Orientation
(This : in out PCD8544_Device; Orientation : Display_Orientation)
is
begin
null;
end Set_Orientation;
----------------
-- Set_Mode --
----------------
overriding procedure Set_Mode
(This : in out PCD8544_Device; Mode : Wait_Mode) is null;
-------------
-- Width --
-------------
overriding function Width (This : PCD8544_Device) return Positive is
(Device_Width);
--------------
-- Height --
--------------
overriding function Height (This : PCD8544_Device) return Positive is
(Device_Height);
---------------
-- Swapped --
---------------
overriding function Swapped (This : PCD8544_Device) return Boolean is
(False);
----------------------
-- Set_Background --
----------------------
overriding procedure Set_Background (This : PCD8544_Device; R, G, B : UInt8)
is
begin
raise Program_Error;
end Set_Background;
------------------------
-- Initialize_Layer --
------------------------
overriding procedure Initialize_Layer
(This : in out PCD8544_Device;
Layer : Positive;
Mode : FB_Color_Mode;
X, Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last)
is
pragma Unreferenced (X, Y, Width, Height);
begin
if Layer /= 1 or else Mode /= M_1 then
raise Program_Error;
end if;
This.Memory_Layer.Actual_Width := This.Width;
This.Memory_Layer.Actual_Height := This.Height;
This.Memory_Layer.Addr := This.Memory_Layer.Data'Address;
This.Memory_Layer.Actual_Color_Mode := Mode;
for I in This.Memory_Layer.Data'Range loop
This.Memory_Layer.Data (I) := 0;
end loop;
This.Layer_Initialized := True;
end Initialize_Layer;
-------------------
-- Initialized --
-------------------
overriding function Initialized
(This : PCD8544_Device;
Layer : Positive) return Boolean
is
begin
return Layer = 1 and then This.Layer_Initialized;
end Initialized;
--------------------
-- Update_Layer --
--------------------
overriding procedure Update_Layer
(This : in out PCD8544_Device;
Layer : Positive;
Copy_Back : Boolean := False)
is
pragma Unreferenced (Copy_Back);
begin
if Layer /= 1 then
raise Program_Error;
end if;
This.Write_Raw_Pixels (This.Memory_Layer.Data);
end Update_Layer;
------------------
-- Color_Mode --
------------------
overriding function Color_Mode
(This : PCD8544_Device; Layer : Positive) return FB_Color_Mode
is
pragma Unreferenced (This);
begin
if Layer /= 1 then
raise Program_Error;
end if;
return M_1;
end Color_Mode;
---------------------
-- Hidden_Buffer --
---------------------
overriding function Hidden_Buffer
(This : in out PCD8544_Device; Layer : Positive)
return not null HAL.Bitmap.Any_Bitmap_Buffer
is
begin
if Layer /= 1 then
raise Program_Error;
end if;
return This.Memory_Layer'Unchecked_Access;
end Hidden_Buffer;
---------------------
-- Update_Layers --
---------------------
overriding procedure Update_Layers (This : in out PCD8544_Device) is
begin
This.Update_Layer (1);
end Update_Layers;
------------------
-- Pixel_Size --
------------------
overriding function Pixel_Size
(Display : PCD8544_Device; Layer : Positive) return Positive is
(1);
end PCD8544;
|
29,861
|
ada
| 1
|
io7m/coreland-openal-ada
|
openal-extension-efx.ads
|
<filename>openal-extension-efx.ads<gh_stars>1-10
with OpenAL.Context;
with OpenAL.Types;
with OpenAL.Source;
private with OpenAL.Extension.EFX_Thin;
package OpenAL.Extension.EFX is
type Extension_t is private;
function Is_Present (Device : in Context.Device_t) return Boolean;
function Load_Extension return Extension_t;
--
-- Effects.
--
type Effect_t is private;
type Effect_Array_t is array (Positive range <>) of Effect_t;
No_Effect : constant Effect_t;
type Effect_Type_t is
(Unknown_Effect,
Null_Effect,
Reverb,
Chorus,
Distortion,
Echo,
Flanger,
Frequency_Shifter,
Vocal_Morpher,
Pitch_Shifter,
Ring_Modulator,
Autowah,
Compressor,
Equalizer,
EAX_Reverb);
subtype Valid_Effect_Type_t is Effect_Type_t range Reverb .. Effect_Type_t'Last;
-- proc_map : alGenEffects
procedure Generate_Effects
(Extension : in Extension_t;
Effects : in out Effect_Array_t);
-- proc_map : alDeleteEffects
procedure Delete_Effects
(Extension : in Extension_t;
Effects : in Effect_Array_t);
-- proc_map : alIsEffect
function Effect_Is_Valid
(Extension : in Extension_t;
Effect : in Effect_t) return Boolean;
-- proc_map : alEffecti
procedure Set_Effect_Type
(Extension : in Extension_t;
Effect : in Effect_t;
Effect_Type : in Valid_Effect_Type_t);
-- proc_map : alGetEffecti
function Get_Effect_Type
(Extension : in Extension_t;
Effect : in Effect_t) return Effect_Type_t;
type Effect_Parameter_t is
(Autowah_Attack_Time,
Autowah_Peak_Gain,
Autowah_Release_Time,
Autowah_Resonance,
Chorus_Delay,
Chorus_Depth,
Chorus_Feedback,
Chorus_Phase,
Chorus_Rate,
Chorus_Waveform,
Distortion_Edge,
Distortion_EQ_Bandwidth,
Distortion_EQ_Center,
Distortion_Gain,
Distortion_Lowpass_Cutoff,
EAX_Reverb_Air_Absorption_Gain_HF,
EAX_Reverb_Decay_HF_Limit,
EAX_Reverb_Decay_HF_Ratio,
EAX_Reverb_Decay_LF_Ratio,
EAX_Reverb_Decay_Time,
EAX_Reverb_Density,
EAX_Reverb_Diffusion,
EAX_Reverb_Echo_Depth,
EAX_Reverb_Echo_Time,
EAX_Reverb_Gain,
EAX_Reverb_Gain_HF,
EAX_Reverb_Gain_LF,
EAX_Reverb_HF_Reference,
EAX_Reverb_Late_Reverb_Delay,
EAX_Reverb_Late_Reverb_Gain,
EAX_Reverb_Late_Reverb_Pan,
EAX_Reverb_LF_Reference,
EAX_Reverb_Modulation_Depth,
EAX_Reverb_Modulation_Time,
EAX_Reverb_Reflections_Delay,
EAX_Reverb_Reflections_Gain,
EAX_Reverb_Reflections_Pan,
EAX_Reverb_Room_Rolloff_Factor,
Echo_Damping,
Echo_Delay,
Echo_Feedback,
Echo_LR_Delay,
Echo_Spread,
Equalizer_High_Cutoff,
Equalizer_High_Gain,
Equalizer_Low_Cutoff,
Equalizer_Low_Gain,
Equalizer_Mid1_Center,
Equalizer_Mid1_Gain,
Equalizer_Mid1_Width,
Equalizer_Mid2_Center,
Equalizer_Mid2_Gain,
Equalizer_Mid2_Width,
Flanger_Delay,
Flanger_Depth,
Flanger_Feedback,
Flanger_Phase,
Flanger_Rate,
Flanger_Waveform,
Frequency_Shifter_Frequency,
Frequency_Shifter_Left_Direction,
Frequency_Shifter_Right_Direction,
Pitch_Shifter_Coarse_Tune,
Pitch_Shifter_Fine_Tune,
Reverb_Air_Absorption_Gain_HF,
Reverb_Decay_HF_Limit,
Reverb_Decay_HF_Ratio,
Reverb_Decay_Time,
Reverb_Density,
Reverb_Diffusion,
Reverb_Gain,
Reverb_Gain_HF,
Reverb_Late_Reverb_Delay,
Reverb_Late_Reverb_Gain,
Reverb_Reflections_Delay,
Reverb_Reflections_Gain,
Reverb_Room_Rolloff_Factor,
Ring_Modulator_Frequency,
Ring_Modulator_Highpass_Cutoff,
Ring_Modulator_Waveform,
Vocal_Morpher_Phoneme_A,
Vocal_Morpher_Phoneme_A_Coarse_Tuning,
Vocal_Morpher_Phoneme_B,
Vocal_Morpher_Phoneme_B_Coarse_Tuning,
Vocal_Morpher_Rate,
Vocal_Morpher_Waveform,
Compressor_On_Off);
-- proc_map : alEffectf
procedure Set_Effect_Parameter
(Extension : in Extension_t;
Effect : in Effect_t;
Parameter : in Effect_Parameter_t;
Value : in Types.Float_t);
--
-- Filters.
--
type Filter_t is private;
type Filter_Array_t is array (Positive range <>) of Filter_t;
No_Filter : constant Filter_t;
-- proc_map : alGenFilters
procedure Generate_Filters
(Extension : in Extension_t;
Filters : in out Filter_Array_t);
-- proc_map : alDeleteFilters
procedure Delete_Filters
(Extension : in Extension_t;
Filters : in Filter_Array_t);
-- proc_map : alIsFilter
function Filter_Is_Valid
(Extension : in Extension_t;
Filter : in Filter_t) return Boolean;
type Filter_Type_t is
(Unknown_Filter,
Null_Filter,
Low_Pass_Filter,
Band_Pass_Filter,
High_Pass_Filter);
subtype Valid_Filter_Type_t is Filter_Type_t range Low_Pass_Filter .. Filter_Type_t'Last;
-- proc_map : alFilteri
procedure Set_Filter_Type
(Extension : in Extension_t;
Filter : in Filter_t;
Filter_Type : in Valid_Filter_Type_t);
-- proc_map : alGetFilteri
function Get_Filter_Type
(Extension : in Extension_t;
Filter : in Filter_t) return Filter_Type_t;
type Filter_Parameter_t is
(Low_Pass_Gain,
Low_Pass_Gain_HF,
High_Pass_Gain,
High_Pass_Gain_LF,
Band_Pass_Gain,
Band_Pass_Gain_LF,
Band_Pass_Gain_HF);
-- proc_map : alFilterf
procedure Set_Filter_Parameter
(Extension : in Extension_t;
Filter : in Filter_t;
Parameter : in Filter_Parameter_t;
Value : in Types.Float_t);
--
-- Auxiliary_Effect_Slots.
--
type Auxiliary_Effect_Slot_t is private;
type Auxiliary_Effect_Slot_Array_t is array (Positive range <>) of Auxiliary_Effect_Slot_t;
No_Auxiliary_Effect_Slot : constant Auxiliary_Effect_Slot_t;
-- proc_map : alGenAuxiliaryEffectSlots
procedure Generate_Auxiliary_Effect_Slots
(Extension : in Extension_t;
Slots : in out Auxiliary_Effect_Slot_Array_t);
-- proc_map : alDeleteAuxiliaryEffectSlots
procedure Delete_Auxiliary_Effect_Slots
(Extension : in Extension_t;
Slots : in Auxiliary_Effect_Slot_Array_t);
-- proc_map : alIsAuxiliaryEffectSlot
function Auxiliary_Effect_Slot_Is_Valid
(Extension : in Extension_t;
Slot : in Auxiliary_Effect_Slot_t) return Boolean;
-- proc_map : alAuxiliaryEffectSloti
procedure Set_Auxiliary_Effect_Slot_Effect
(Extension : in Extension_t;
Slot : in Auxiliary_Effect_Slot_t;
Effect : in Effect_t);
subtype Gain_t is Types.Float_t range 0.0 .. 1.0;
-- proc_map : alAuxiliaryEffectSlotf
procedure Set_Auxiliary_Effect_Slot_Gain
(Extension : in Extension_t;
Slot : in Auxiliary_Effect_Slot_t;
Gain : in Gain_t);
-- proc_map : alAuxiliaryEffectSloti
procedure Set_Auxiliary_Effect_Slot_Auto_Send
(Extension : in Extension_t;
Slot : in Auxiliary_Effect_Slot_t;
Enable : in Boolean);
--
-- Source filtering and properties.
--
-- proc_map : alSourcei
procedure Set_Direct_Filter
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Filter : in Filter_t);
type Source_Auxiliary_Send_t is new Types.Unsigned_Integer_t;
-- proc_map : alSource3i
procedure Set_Auxiliary_Send_Filter
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Slot : in Auxiliary_Effect_Slot_t;
Source_Send : in Source_Auxiliary_Send_t := 0;
Filter : in Filter_t := No_Filter);
type Air_Absorption_Factor_t is new Types.Float_t range 0.0 .. 10.0;
-- proc_map : alSourcef
procedure Set_Air_Absorption_Factor
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Factor : in Air_Absorption_Factor_t);
type Room_Rolloff_Factor_t is new Types.Float_t range 0.0 .. 10.0;
-- proc_map : alSourcef
procedure Set_Room_Rolloff_Factor
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Factor : in Room_Rolloff_Factor_t);
type Cone_Outer_Gain_HF_Factor_t is new Types.Float_t range 0.0 .. 10.0;
-- proc_map : alSourcef
procedure Set_Cone_Outer_Gain_HF
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Factor : in Cone_Outer_Gain_HF_Factor_t);
-- proc_map : alSourcei
procedure Set_Direct_Filter_Gain_HF_Auto
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Enable : in Boolean);
-- proc_map : alSourcei
procedure Set_Auxiliary_Send_Filter_Gain_Auto
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Enable : in Boolean);
-- proc_map : alSourcei
procedure Set_Auxiliary_Send_Filter_Gain_HF_Auto
(Extension : in Extension_t;
Source : in OpenAL.Source.Source_t;
Enable : in Boolean);
--
-- Listener extensions.
--
type Meters_t is new Types.Float_t range 0.000001 .. Types.Float_t'Last;
-- proc_map : alListenerf
procedure Set_Meters_Per_Unit
(Extension : in Extension_t;
Meters : in Meters_t);
--
-- Context extensions.
--
-- proc_map : alcGetIntegerv
function Get_Major_Version
(Extension : in Extension_t) return Natural;
-- proc_map : alcGetIntegerv
function Get_Minor_Version
(Extension : in Extension_t) return Natural;
-- proc_map : alcGetIntegerv
function Get_Maximum_Auxiliary_Sends
(Extension : in Extension_t) return Source_Auxiliary_Send_t;
private
type Effect_t is new Types.Unsigned_Integer_t;
No_Effect : constant Effect_t := 0;
type Filter_t is new Types.Unsigned_Integer_t;
No_Filter : constant Filter_t := 0;
type Auxiliary_Effect_Slot_t is new Types.Unsigned_Integer_t;
No_Auxiliary_Effect_Slot : constant Auxiliary_Effect_Slot_t := 0;
type Extension_t is record
Owner_Context : Context.Context_t := Context.Invalid_Context;
Loaded : Boolean := False;
API : EFX_Thin.API_t;
end record;
procedure Check_Loaded (Extension : in Extension_t);
function Map_To_Effect_Type (Effect_Type : in Types.Integer_t) return Effect_Type_t;
function Map_To_Filter_Type (Filter_Type : in Types.Integer_t) return Filter_Type_t;
end OpenAL.Extension.EFX;
|
29,862
|
ada
| 36
|
rewriting/tom
|
src/tom/library/sl/ada/muvarstrategy.adb
|
with VisitFailurePackage, VisitablePackage, EnvironmentPackage;
use VisitFailurePackage, VisitablePackage, EnvironmentPackage;
with Ada.Text_IO; use Ada.Text_IO;
package body MuVarStrategy is
----------------------------------------------------------------------------
-- Object implementation
----------------------------------------------------------------------------
overriding
function toString(c: MuVar) return String is
str : access String := new String'("[");
begin
if c.name = null then
str := new String'(str.all & "null,");
else
str := new String'(str.all & c.name.all & ",");
end if;
if c.instance = null then
str := new String'(str.all & "null]");
else
str := new String'(str.all & toString(Object'Class(c.instance.all)) & "]");
end if;
return str.all;
end;
----------------------------------------------------------------------------
-- Strategy implementation
----------------------------------------------------------------------------
overriding
function visitLight(str:access MuVar; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is
begin
if str.instance /= null then
return visitLight(str.instance, any, i);
else
raise VisitFailure;
end if;
end;
overriding
function visit(str: access MuVar; i: access Introspector'Class) return Integer is
begin
if str.instance /= null then
return visit(str.instance, i);
else
return EnvironmentPackage.FAILURE;
end if;
end;
----------------------------------------------------------------------------
procedure makeMuVar(c : in out MuVar; s: access String) is
begin
initSubterm(c);
if s /= null then
c.name := new String'(s.all);
else
c.name := null;
end if;
end;
function newMuVar(s : access String) return StrategyPtr is
ret : StrategyPtr := new MuVar;
begin
makeMuVar(MuVar(ret.all), s);
return ret;
end;
function newMuVar(s : String) return StrategyPtr is
begin
return newMuVar(new String'(s));
end;
function equals(m : access MuVar; o : ObjectPtr) return Boolean is
mptr : access MuVar := null;
begin
if o /= null then
if o.all in MuVar'Class then
mptr := MuVar(o.all)'Access;
if mptr.name /= null then
return m.name.all = mptr.name.all;
else
if mptr.name = m.name and then mptr.instance = m.instance then
return true;
end if;
end if;
end if;
end if;
return false;
end;
function hashCode(m : access MuVar) return Integer is
begin
return 0;
end;
function getInstance(m: access MuVar) return StrategyPtr is
begin
return m.instance;
end;
procedure setInstance(m: access MuVar; s: StrategyPtr) is
begin
m.instance := s;
end;
procedure setName(m: access MuVar; n: access String) is
begin
if n /= null then
m.name := new String'(n.all);
else
m.name := null;
end if;
end;
function isExpanded(m: access Muvar) return Boolean is
begin
if m.instance = null then
return false;
else
return true;
end if;
end;
function getName(m: access Muvar) return access String is
begin
return m.name;
end;
----------------------------------------------------------------------------
end MuVarStrategy;
|
29,863
|
ada
| 2
|
glencornell/ada-socketcan
|
examples/bcm_simple_writer/bcm_simple_writer.adb
|
<filename>examples/bcm_simple_writer/bcm_simple_writer.adb
-- MIT License
--
-- Copyright (c) 2021 <NAME> <<EMAIL>>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with Ada.Text_Io;
with Sockets.Can.Broadcast_Manager;
with Sockets.Can_Frame;
with Interfaces;
with Create_Can_Frame;
procedure Bcm_Simple_Writer is
If_Name : constant String := "vcan0";
Unused_C : Character;
Bcm : Sockets.Can.Broadcast_Manager.Broadcast_Manager_Type;
Frame_1 : constant Sockets.Can_Frame.Can_Frame :=
Create_Can_Frame (Can_Id => 16#10#,
Data => (16#11#, 16#22#, 16#33#));
Frame_2 : Sockets.Can_Frame.Can_Frame :=
Create_Can_Frame (Can_Id => 16#20#,
Data => (1 => 16#AA#));
Frame_3 : constant Sockets.Can_Frame.Can_Frame :=
Create_Can_Frame (Can_Id => 16#30#,
Data => (16#DE#, 16#AD#, 16#BE#, 16#EF#));
task type T is
entry Start;
entry Stop;
end T;
task body T is
use type Interfaces.Unsigned_8;
I : Interfaces.Unsigned_8 := 255;
Terminated : Boolean := False;
begin
accept Start;
while not Terminated loop
I := I + 1;
Frame_2.Data(Frame_2.Data'First) := I;
Bcm.Send_Once (Frame_2);
select
accept Stop do
Terminated := True;
end Stop;
or
delay 0.1;
end select;
end loop;
end T;
Updater : T;
begin
Bcm.Create (If_Name);
Bcm.Send_Periodic (Frame_1, 0.5);
Bcm.Send_Once (Frame_2);
Bcm.Send_Once (Frame_3);
Updater.Start;
Ada.Text_Io.Put_Line ("Press any key to stop");
Ada.Text_Io.Get (Unused_C);
Updater.Stop;
end Bcm_Simple_Writer;
|
29,864
|
ada
| 24
|
svn2github/matreshka
|
source/xml/templates/xml-templates-processors.adb
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-2016, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Characters;
with XML.Templates.Processors.Parser;
with XML.Templates.Streams.Holders;
package body XML.Templates.Processors is
use type League.Strings.Universal_String;
Template_URI : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("http://forge.ada-ru.org/matreshka/template");
Else_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("else");
Elsif_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("elsif");
Evaluate_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("evaluate");
Expression_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("expression");
If_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("if");
For_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("for");
Boolean_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("boolean.");
procedure Substitute
(Self : in out Template_Processor'Class;
Text : League.Strings.Universal_String;
In_Attribute : Boolean;
Result : out League.Strings.Universal_String;
Success : in out Boolean);
-- Process text and substitute parameters.
procedure Process_Stream
(Content_Handler : in out XML.SAX.Content_Handlers
.SAX_Content_Handler'Class;
Lexical_Handler : in out XML.SAX.Lexical_Handlers
.SAX_Lexical_Handler'Class;
Stream : XML.Templates.Streams.XML_Stream_Element_Vectors.Vector;
Success : in out Boolean);
-- Process specified stream by dispatching each event to the content
-- or handler the lexical handler.
procedure Process_Characters
(Self : in out Template_Processor'Class;
Success : in out Boolean);
-- Process accumulated character data.
----------------
-- Characters --
----------------
overriding procedure Characters
(Self : in out Template_Processor;
Text : League.Strings.Universal_String;
Success : in out Boolean)
is
pragma Unreferenced (Success);
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.Text,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Text => Text));
elsif Self.Skip /= 0 then
null;
else
Self.Accumulated_Text.Append (Text);
end if;
end Characters;
-------------
-- Comment --
-------------
overriding procedure Comment
(Self : in out Template_Processor;
Text : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.Comment,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Text => Text));
elsif Self.Skip /= 0 then
null;
else
Self.Process_Characters (Success);
if not Success then
return;
end if;
Self.Lexical_Handler.Comment (Text, Success);
if not Success then
Self.Diagnosis := Self.Lexical_Handler.Error_String;
end if;
end if;
end Comment;
---------------
-- End_CDATA --
---------------
overriding procedure End_CDATA
(Self : in out Template_Processor;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.End_CDATA,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column)));
elsif Self.Skip /= 0 then
null;
else
Self.Process_Characters (Success);
if not Success then
return;
end if;
Self.Lexical_Handler.End_CDATA (Success);
if not Success then
Self.Diagnosis := Self.Lexical_Handler.Error_String;
end if;
end if;
end End_CDATA;
------------------
-- End_Document --
------------------
overriding procedure End_Document
(Self : in out Template_Processor;
Success : in out Boolean) is
begin
Self.Content_Handler.End_Document (Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
end if;
end End_Document;
-------------
-- End_DTD --
-------------
overriding procedure End_DTD
(Self : in out Template_Processor;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.End_DTD,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column)));
elsif Self.Skip /= 0 then
null;
else
Self.Lexical_Handler.End_DTD (Success);
if not Success then
Self.Diagnosis := Self.Lexical_Handler.Error_String;
end if;
end if;
end End_DTD;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out Template_Processor;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Accumulate := Self.Accumulate - 1;
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.End_Element,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Namespace_URI => Namespace_URI,
Local_Name => Local_Name,
Qualified_Name => Qualified_Name));
elsif Namespace_URI = Template_URI then
if Local_Name = For_Name then
Self.Namespaces.Pop_Context;
declare
Cursor : League.Holders.Iterable_Holder_Cursors.Cursor'Class
:= League.Holders.First (Self.Container_Value);
Stream : constant
XML.Templates.Streams.XML_Stream_Element_Vectors.Vector
:= Self.Stream;
Name : constant League.Strings.Universal_String
:= Self.Object_Name;
Holder : League.Holders.Holder;
Success : Boolean := True;
begin
Self.Stream.Clear;
Self.Object_Name.Clear;
while Cursor.Next loop
Holder := Cursor.Element;
if League.Holders.Is_Empty (Holder) then
return;
end if;
Self.Parameters.Include (Name, Holder);
Process_Stream (Self, Self, Stream, Success);
Self.Process_Characters (Success);
if not Success then
return;
end if;
end loop;
end;
end if;
end if;
elsif Self.Skip /= 0 then
Self.Skip := Self.Skip - 1;
if Self.Skip = 0 then
pragma Assert (Local_Name = If_Name);
Pop (Self.Run_Else_Stack, Self.Run_Else);
end if;
else
Self.Process_Characters (Success);
if not Success then
return;
end if;
Self.Namespaces.Pop_Context;
if Namespace_URI = Template_URI then
if Local_Name = If_Name then
Pop (Self.Run_Else_Stack, Self.Run_Else);
end if;
else
Self.Content_Handler.End_Element
(Namespace_URI, Local_Name, Qualified_Name, Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
return;
end if;
end if;
end if;
end End_Element;
-------------------
-- Set_Parameter --
-------------------
procedure Set_Parameter
(Self : in out Template_Processor'Class;
Name : League.Strings.Universal_String;
Value : League.Holders.Holder) is
begin
Self.Parameters.Include (Name.To_Casefold, Value);
end Set_Parameter;
------------------------
-- End_Prefix_Mapping --
------------------------
overriding procedure End_Prefix_Mapping
(Self : in out Template_Processor;
Prefix : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.End_Prefix_Mapping,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Prefix => Prefix));
elsif Self.Skip /= 0 then
null;
else
-- if Self.Namespaces.Namespace_URI (Prefix) /= Template_URI then
Self.Content_Handler.End_Prefix_Mapping (Prefix, Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
end if;
-- end if;
end if;
end End_Prefix_Mapping;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : Template_Processor) return League.Strings.Universal_String is
begin
return Self.Diagnosis;
end Error_String;
---------
-- Pop --
---------
procedure Pop (Self : in out Boolean_Stack; Value : out Boolean) is
begin
Value := Boolean'Val (Self and 1);
Self := Self / 2;
end Pop;
------------------------
-- Process_Characters --
------------------------
procedure Process_Characters
(Self : in out Template_Processor'Class;
Success : in out Boolean)
is
Text : constant League.Strings.Universal_String := Self.Accumulated_Text;
Aux : League.Strings.Universal_String;
begin
if not Text.Is_Empty then
Self.Accumulated_Text.Clear;
Self.Substitute (Text, False, Aux, Success);
end if;
end Process_Characters;
--------------------
-- Process_Stream --
--------------------
procedure Process_Stream
(Content_Handler : in out XML.SAX.Content_Handlers
.SAX_Content_Handler'Class;
Lexical_Handler : in out XML.SAX.Lexical_Handlers
.SAX_Lexical_Handler'Class;
Stream : XML.Templates.Streams.XML_Stream_Element_Vectors.Vector;
Success : in out Boolean) is
begin
for Event of Stream loop
case Event.Kind is
when XML.Templates.Streams.Empty =>
raise Program_Error;
when XML.Templates.Streams.Text =>
Content_Handler.Characters (Event.Text, Success);
when XML.Templates.Streams.Start_Element =>
Content_Handler.Start_Element
(Event.Namespace_URI,
Event.Local_Name,
Event.Qualified_Name,
Event.Attributes,
Success);
when XML.Templates.Streams.End_Element =>
Content_Handler.End_Element
(Event.Namespace_URI,
Event.Local_Name,
Event.Qualified_Name,
Success);
when XML.Templates.Streams.Start_Prefix_Mapping =>
Content_Handler.Start_Prefix_Mapping
(Event.Prefix, Event.Mapped_Namespace_URI, Success);
when XML.Templates.Streams.End_Prefix_Mapping =>
Content_Handler.End_Prefix_Mapping (Event.Prefix, Success);
when XML.Templates.Streams.Processing_Instruction =>
Content_Handler.Processing_Instruction (Event.Target, Event.Data, Success);
when XML.Templates.Streams.Comment =>
Lexical_Handler.Comment (Event.Text, Success);
when XML.Templates.Streams.Start_CDATA =>
Lexical_Handler.Start_CDATA (Success);
when XML.Templates.Streams.End_CDATA =>
Lexical_Handler.End_CDATA (Success);
when XML.Templates.Streams.Start_DTD =>
Lexical_Handler.Start_DTD
(Event.Name, Event.Public_Id, Event.System_Id, Success);
when XML.Templates.Streams.End_DTD =>
Lexical_Handler.End_DTD (Success);
end case;
if not Success then
return;
end if;
end loop;
end Process_Stream;
----------------------------
-- Processing_Instruction --
----------------------------
overriding procedure Processing_Instruction
(Self : in out Template_Processor;
Target : League.Strings.Universal_String;
Data : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.Processing_Instruction,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Target => Target,
Data => Data));
elsif Self.Skip /= 0 then
null;
else
Self.Process_Characters (Success);
if not Success then
return;
end if;
Self.Content_Handler.Processing_Instruction (Target, Data, Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
end if;
end if;
end Processing_Instruction;
----------
-- Push --
----------
procedure Push (Self : in out Boolean_Stack; Value : Boolean) is
begin
Self := Self * 2 + Boolean'Pos (Value);
end Push;
-------------------------
-- Set_Content_Handler --
-------------------------
procedure Set_Content_Handler
(Self : in out Template_Processor'Class;
Handler : XML.SAX.Readers.SAX_Content_Handler_Access) is
begin
Self.Content_Handler := Handler;
end Set_Content_Handler;
--------------------------
-- Set_Document_Locator --
--------------------------
overriding procedure Set_Document_Locator
(Self : in out Template_Processor;
Locator : XML.SAX.Locators.SAX_Locator) is
begin
Self.Locator := Locator;
Self.Content_Handler.Set_Document_Locator (Locator);
end Set_Document_Locator;
-------------------------
-- Set_Lexical_Handler --
-------------------------
procedure Set_Lexical_Handler
(Self : in out Template_Processor'Class;
Handler : XML.SAX.Readers.SAX_Lexical_Handler_Access) is
begin
Self.Lexical_Handler := Handler;
end Set_Lexical_Handler;
-----------------
-- Start_CDATA --
-----------------
overriding procedure Start_CDATA
(Self : in out Template_Processor;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.Start_CDATA,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column)));
elsif Self.Skip /= 0 then
null;
else
Self.Process_Characters (Success);
if not Success then
return;
end if;
Self.Lexical_Handler.Start_CDATA (Success);
if not Success then
Self.Diagnosis := Self.Lexical_Handler.Error_String;
end if;
end if;
end Start_CDATA;
--------------------
-- Start_Document --
--------------------
overriding procedure Start_Document
(Self : in out Template_Processor;
Success : in out Boolean) is
begin
Self.Content_Handler.Start_Document (Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
end if;
end Start_Document;
---------------
-- Start_DTD --
---------------
overriding procedure Start_DTD
(Self : in out Template_Processor;
Name : League.Strings.Universal_String;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.Start_DTD,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Name => Name,
Public_Id => Public_Id,
System_Id => System_Id));
elsif Self.Skip /= 0 then
null;
else
Self.Lexical_Handler.Start_DTD (Name, Public_Id, System_Id, Success);
if not Success then
Self.Diagnosis := Self.Lexical_Handler.Error_String;
end if;
end if;
end Start_DTD;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out Template_Processor;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
Result : XML.SAX.Attributes.SAX_Attributes;
Aux : League.Strings.Universal_String;
Value : Boolean;
begin
if Self.Accumulate /= 0 then
Self.Accumulate := Self.Accumulate + 1;
Self.Stream.Append
((Kind => XML.Templates.Streams.Start_Element,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Namespace_URI => Namespace_URI,
Local_Name => Local_Name,
Qualified_Name => Qualified_Name,
Attributes => Attributes));
elsif Self.Skip > 1 or else
(Self.Skip = 1
and not (Self.Run_Else
and Namespace_URI = Template_URI
and Local_Name in Else_Name | Elsif_Name))
then
Self.Skip := Self.Skip + 1;
else
Self.Process_Characters (Success);
Self.Namespaces.Push_Context;
if not Success then
return;
end if;
if Namespace_URI = Template_URI then
if Local_Name in Evaluate_Name | For_Name | If_Name | Elsif_Name
and then not Attributes.Is_Specified (Expression_Name)
then
-- Expression is not specified.
Self.Diagnosis :=
League.Strings.To_Universal_String
("'expression' attribute is not specified");
Success := False;
return;
elsif Local_Name = Evaluate_Name then
declare
Value : League.Holders.Holder;
begin
Parser.Evaluate_Simple_Expression
(Attributes (Expression_Name),
Self.Parameters,
Value,
Success);
if League.Holders.Has_Tag
(Value, XML.Templates.Streams.Holders.Value_Tag)
then
Process_Stream
(Self,
Self,
XML.Templates.Streams.Holders.Element (Value),
Success);
if not Success then
return;
end if;
else
raise Program_Error;
end if;
end;
elsif Local_Name = For_Name then
Parser.Evaluate_For_Expression
(Attributes (Expression_Name),
Self.Parameters,
Self.Object_Name,
Self.Container_Value,
Success);
if not Success then
return;
end if;
-- Enable accumulation of SAX events for future processing.
Self.Accumulate := 1;
elsif Local_Name = If_Name then
Push (Self.Run_Else_Stack, Self.Run_Else);
Self.Run_Else := True;
Parser.Evaluate_Boolean_Expression
(Attributes (Expression_Name),
Self.Parameters,
Value,
Success);
if not Success then
return;
end if;
if Value then
Self.Run_Else := False;
else
Self.Skip := 1;
end if;
elsif Local_Name = Elsif_Name then
if not Self.Run_Else then
Self.Skip := 2; -- Skip 'elsif' and everything after it
return;
end if;
Parser.Evaluate_Boolean_Expression
(Attributes (Expression_Name),
Self.Parameters,
Value,
Success);
if not Success then
return;
end if;
if Value then
Self.Run_Else := False;
Self.Skip := 0;
else
Self.Skip := 2; -- Skip 'elsif' and everything after it
end if;
elsif Local_Name = Else_Name then
if Self.Run_Else then
Self.Skip := 0;
else
Self.Skip := 2; -- Skip 'else' and everything after it
end if;
else
raise Program_Error;
end if;
else
for J in 1 .. Attributes.Length loop
if Attributes.Namespace_URI (J) = Template_URI then
if Attributes.Local_Name (J).Starts_With (Boolean_Name) then
Parser.Evaluate_Boolean_Expression
(Attributes.Value (J),
Self.Parameters,
Value,
Success);
if not Success then
return;
end if;
if Value then
Aux := Attributes.Local_Name (J).Tail_From
(Boolean_Name.Length + 1);
Result.Set_Value (Aux, Aux);
end if;
else
raise Program_Error;
end if;
elsif Attributes.Namespace_URI (J).Is_Empty then
Self.Substitute (Attributes (J), True, Aux, Success);
Result.Set_Value (Attributes.Qualified_Name (J), Aux);
else
Self.Substitute (Attributes (J), True, Aux, Success);
Result.Set_Value
(Attributes.Namespace_URI (J),
Attributes.Local_Name (J),
Aux);
end if;
if not Success then
return;
end if;
end loop;
Self.Content_Handler.Start_Element
(Namespace_URI, Local_Name, Qualified_Name, Result, Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
end if;
end if;
end if;
end Start_Element;
--------------------------
-- Start_Prefix_Mapping --
--------------------------
overriding procedure Start_Prefix_Mapping
(Self : in out Template_Processor;
Prefix : League.Strings.Universal_String;
Namespace_URI : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Self.Accumulate /= 0 then
Self.Stream.Append
((Kind => XML.Templates.Streams.Start_Prefix_Mapping,
Location => (System_Id => Self.Locator.System_Id,
Line => Self.Locator.Line,
Column => Self.Locator.Column),
Prefix => Prefix,
Mapped_Namespace_URI => Namespace_URI));
elsif Self.Skip /= 0 then
null;
else
Self.Namespaces.Declare_Prefix (Prefix, Namespace_URI);
if Namespace_URI /= Template_URI then
Self.Content_Handler.Start_Prefix_Mapping
(Prefix, Namespace_URI, Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
end if;
end if;
end if;
end Start_Prefix_Mapping;
----------------
-- Substitute --
----------------
procedure Substitute
(Self : in out Template_Processor'Class;
Text : League.Strings.Universal_String;
In_Attribute : Boolean;
Result : out League.Strings.Universal_String;
Success : in out Boolean)
is
use type League.Characters.Universal_Character;
procedure Process_Expression
(Text : League.Strings.Universal_String;
Success : in out Boolean);
-- Parse and execute expression.
------------------------
-- Process_Expression --
------------------------
procedure Process_Expression
(Text : League.Strings.Universal_String;
Success : in out Boolean)
is
Value : League.Holders.Holder;
begin
Parser.Evaluate_Simple_Expression
(Text, Self.Parameters, Value, Success);
if not Success then
raise Program_Error;
end if;
if League.Holders.Is_Universal_String (Value) then
if In_Attribute then
Result.Append (League.Holders.Element (Value));
else
Self.Content_Handler.Characters
(League.Holders.Element (Value), Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
return;
end if;
end if;
elsif League.Holders.Has_Tag
(Value, XML.Templates.Streams.Holders.Value_Tag)
then
if In_Attribute then
raise Program_Error;
else
Process_Stream
(Self.Content_Handler.all,
Self.Lexical_Handler.all,
XML.Templates.Streams.Holders.Element (Value),
Success);
if not Success then
return;
end if;
end if;
else
raise Program_Error;
end if;
end Process_Expression;
First : Positive := 1;
Dollar : Natural;
Last : Natural;
begin
Result.Clear;
while First <= Text.Length loop
Dollar := Text.Index (First, '$');
if Dollar = 0 then
if In_Attribute then
Result.Append (Text.Slice (First, Text.Length));
else
Self.Content_Handler.Characters
(Text.Slice (First, Text.Length), Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
return;
end if;
end if;
First := Text.Length + 1;
else
if In_Attribute then
Result.Append (Text.Slice (First, Dollar - 1));
else
Self.Content_Handler.Characters
(Text.Slice (First, Dollar - 1), Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
return;
end if;
end if;
if Dollar = Text.Length
or else Text (Dollar + 1) /= '{'
then
if In_Attribute then
Result.Append ('$');
else
Self.Content_Handler.Characters
(Text.Slice (Dollar, Dollar), Success);
if not Success then
Self.Diagnosis := Self.Content_Handler.Error_String;
return;
end if;
end if;
if Dollar < Text.Length and then Text (Dollar + 1) = '$' then
-- Escaped dollar sign.
First := Dollar + 2;
else
First := Dollar + 1;
end if;
else
-- Expression.
First := Dollar + 2;
Dollar := Text.Index (First, '}');
if Dollar = 0 then
raise Program_Error;
else
Last := Dollar - 1;
Process_Expression (Text.Slice (First, Last), Success);
First := Dollar + 1;
if not Success then
return;
end if;
end if;
end if;
end if;
end loop;
end Substitute;
end XML.Templates.Processors;
|
29,865
|
ada
| 0
|
VitalijBondarenko/notifyada
|
src/notify.ads
|
<filename>src/notify.ads
------------------------------------------------------------------------------
-- --
-- Copyright (c) 2014-2021 <NAME> <<EMAIL>> --
-- --
------------------------------------------------------------------------------
-- --
-- The MIT License (MIT) --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and/or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
-- Notify library API
with Glib; use Glib;
with Gtk.Enums; use Gtk.Enums;
package Notify is
function Notify_Init (App_Name : UTF8_String) return Boolean;
-- Initialized libnotify. This must be called before any other functions.
--
-- App_Name : The name of the application initializing libnotify.
-- Returns : TRUE if successful, or FALSE on error.
procedure Notify_Init (App_Name : UTF8_String);
-- Initialized libnotify. This must be called before any other functions.
-- The procedure ignores the initialization error. Use Notify_Is_Initted
-- function to get whether or not libnotify is initialized.
--
-- App_Name : The name of the application initializing libnotify.
procedure Notify_Uninit;
-- Uninitialized libnotify.
-- This should be called when the program no longer needs libnotify for
-- the rest of its lifecycle, typically just before exitting.
function Notify_Is_Initted return Boolean;
-- Gets whether or not libnotify is initialized.
--
-- Returns : TRUE if libnotify is initialized, or FALSE otherwise.
function Notify_Get_App_Name return UTF8_String;
-- Gets the application name registered.
--
-- Returns : The registered application name, passed to Notify_Init.
procedure Notify_Set_App_Name (App_Name : UTF8_String);
-- Sets the application name.
--
-- App_Name : The name of the application.
function Notify_Get_Server_Caps return Gtk.Enums.String_List.Glist;
-- Synchronously queries the server for its capabilities and returns them
-- in a String_List.
--
-- Returns : a String_List of server capability strings. Free the list
-- with Free_String_List.
function Notify_Get_Server_Info
(Name : out String_Ptr;
Vendor : out String_Ptr;
Version : out String_Ptr;
Spec_Version : out String_Ptr) return Boolean;
-- Synchronously queries the server for its information, specifically, the
-- name, vendor, server version, and the version of the notifications
-- specification that it is compliant with.
--
-- Name : a location to store the server name, or NULL.
-- Vendor : a location to store the server vendor, or NULL.
-- Version : a location to store the server version, or NULL.
-- Spec_Version : a location to store the version the service is compliant
-- with, or NULL.
-- Returns : TRUE if successful, and the variables passed will be set,
-- FALSE on error.
end Notify;
|
29,866
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/ada/a-cogeso.ads
|
<reponame>best08618/asylo
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.GENERIC_SORT --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011, 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/>. --
-- --
-- This unit was originally developed by <NAME>. --
------------------------------------------------------------------------------
-- Allows an anonymous array (or array-like container) to be sorted. Generic
-- formal Before returns the result of comparing the elements designated by
-- the indexes, and generic formal Swap exchanges the designated elements.
generic
type Index_Type is (<>);
with function Before (Left, Right : Index_Type) return Boolean;
with procedure Swap (Left, Right : Index_Type);
procedure Ada.Containers.Generic_Sort (First, Last : Index_Type'Base);
pragma Pure (Ada.Containers.Generic_Sort);
|
29,867
|
ada
| 0
|
vfinotti/cortex-m0-blinky-ada
|
main.ads
|
-------------------------------------------------------------------------------
-- Title : Blinky example status file
--
-- File : main.ads
-- Author : <NAME>
-- Created on : 2019-04-25 14:53:55
-- Description :
--
--
--
-------------------------------------------------------------------------------
package Main is
procedure Run;
pragma Export (C, Run, "main");
end Main;
|
29,868
|
ada
| 2
|
thindil/tashy2
|
tests/tk-ttklabelframe-test_data.ads
|
<reponame>thindil/tashy2<gh_stars>1-10
package Tk.TtkLabelFrame.Test_Data is
end Tk.TtkLabelFrame.Test_Data;
|
29,869
|
ada
| 65
|
PThierry/ewok-kernel
|
src/arch/socs/stm32f429/soc-dwt.adb
|
--
-- Copyright 2018 The wookey project team <<EMAIL>>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
--
-- 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 m4.systick;
package body soc.dwt
with spark_mode => on
is
-----------------------------------------------------
-- SPARK ghost functions and procedures
-----------------------------------------------------
function init_is_done
return boolean
is
begin
return init_done;
end init_is_done;
function check_32bits_overflow
return boolean
is
begin
return (init_done and then dwt_loops < unsigned_64(unsigned_32'Last));
end;
--------------------------------------------------
-- The Data Watchpoint and Trace unit (DWT) --
-- (Cf. ARMv7-M Arch. Ref. Manual, C1.8, p.779) --
--------------------------------------------------
procedure reset_timer
is
begin
DEMCR.TRCENA := true;
LAR := LAR_ENABLE_WRITE_KEY;
DWT_CYCCNT := 0; -- reset the counter
DWT_CONTROL.CYCCNTENA := false;
end reset_timer;
procedure start_timer
is
begin
DWT_CONTROL.CYCCNTENA := true; -- enable the counter
end start_timer;
procedure stop_timer
is
begin
DWT_CONTROL.CYCCNTENA := false; -- stop the counter
end stop_timer;
procedure ovf_manage
--with
-- Refined_Post => (dwt_loops = dwt_loops'Old
-- or dwt_loops = (dwt_loops'Old + 1))
is
dwt : unsigned_32;
begin
dwt := DWT_CYCCNT;
if dwt < last_dwt then
dwt_loops := dwt_loops + 1;
end if;
last_dwt := dwt;
end ovf_manage;
procedure init
is
begin
last_dwt := 0;
dwt_loops := 0;
reset_timer;
start_timer;
init_done := true;
end init;
procedure get_cycles_32 (cycles : out unsigned_32)
is
begin
cycles := DWT_CYCCNT; -- can't return volatile (SPARK RM 7.1.3(12))
end get_cycles_32;
procedure get_cycles (cycles : out unsigned_64)
is
cyccnt : unsigned_64;
begin
cyccnt := unsigned_64 (DWT_CYCCNT);
cycles := dwt_loops * 16#1_0000_0000# + cyccnt;
end get_cycles;
procedure get_microseconds (micros : out unsigned_64)
is
cycles : unsigned_64;
begin
get_cycles(cycles);
micros := cycles / (m4.systick.MAIN_CLOCK_FREQUENCY / 1000_000);
end get_microseconds;
procedure get_milliseconds (milli : out unsigned_64)
is
cycles : unsigned_64;
begin
get_cycles(cycles);
milli := cycles / (m4.systick.MAIN_CLOCK_FREQUENCY / 1000);
end get_milliseconds;
end soc.dwt;
|
29,870
|
ada
| 1
|
micahwelf/FLTK-Ada
|
src/fltk-widgets-menus-menu_buttons.ads
|
with
FLTK.Menu_Items;
package FLTK.Widgets.Menus.Menu_Buttons is
type Menu_Button is new Menu with private;
type Menu_Button_Reference (Data : access Menu_Button'Class) is limited null record
with Implicit_Dereference => Data;
-- signifies which mouse buttons cause the menu to appear
type Popup_Buttons is (No_Popup, Popup1, Popup2, Popup12, Popup3, Popup13, Popup23, Popup123);
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Menu_Button;
end Forge;
procedure Set_Popup_Kind
(This : in out Menu_Button;
Pop : in Popup_Buttons);
function Popup
(This : in out Menu_Button)
return FLTK.Menu_Items.Menu_Item;
procedure Draw
(This : in out Menu_Button);
function Handle
(This : in out Menu_Button;
Event : in Event_Kind)
return Event_Outcome;
private
type Menu_Button is new Menu with null record;
overriding procedure Finalize
(This : in out Menu_Button);
pragma Inline (Set_Popup_Kind);
pragma Inline (Popup);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Menus.Menu_Buttons;
|
29,871
|
ada
| 1
|
ytomino/vampire
|
source/tabula.ads
|
-- The Village of Vampire by YT, このソースコードはNYSLです
with Ada.Formatting;
package Tabula is
pragma Pure;
type Static_String_Access is access constant String;
for Static_String_Access'Storage_Size use 0;
-- string of Natural without spacing
function Image is
new Ada.Formatting.Integer_Image (
Natural,
Signs => Ada.Formatting.Triming_Sign_Marks);
end Tabula;
|
29,872
|
ada
| 3
|
daveshields/AdaEd
|
demos/list.ada
|
generic
type ELEMENT is private;
package LIST_PACKAGE is
type LIST is private;
EMPTY_LIST : constant LIST;
procedure APPEND(L : in out LIST; E : in ELEMENT);
procedure REMOVE(L : in out LIST; E : out ELEMENT);
procedure CONS(E : in ELEMENT; L : in out LIST);
function FIRST(L : in LIST) return ELEMENT;
function LAST(L : in LIST) return ELEMENT;
function IS_EMPTY(L : in LIST) return BOOLEAN;
EMPTY : exception;
private
type LIST_ITEM;
type LIST is access LIST_ITEM;
type LIST_ITEM is
record
ITEM : ELEMENT;
LINK : LIST := NULL;
end record;
EMPTY_LIST : constant LIST := NULL;
end LIST_PACKAGE;
package body LIST_PACKAGE is
FREE : LIST := EMPTY_LIST;
function IS_EMPTY(L : in LIST) return BOOLEAN is
--
-- Tests whether the LIST L is empty
--
begin
return L = EMPTY_LIST;
end IS_EMPTY;
function NEW_L(E : in ELEMENT) return LIST is
--
-- This procedure creates a list node and places the
-- element in it. It uses the FREE list if it is not empty.
--
P : LIST;
begin
if FREE = EMPTY_LIST then
return new LIST_ITEM'(E, NULL);
else
P := FREE;
FREE := FREE.LINK;
P.ITEM := E ;
return P;
end if;
end NEW_L;
procedure APPEND(L : in out LIST; E : in ELEMENT) is
--
-- This procedure appends the element E to the list L.
--
P : LIST;
begin
P := NEW_L(E);
if L = EMPTY_LIST then
P.LINK := P;
else
P.LINK := L.LINK;
L.LINK := P;
end if;
L := P;
end APPEND;
procedure REMOVE(L : in out LIST; E : out ELEMENT) is
--
-- This procedure removes the first item from the list L and
-- returns its value in E.
-- If the list is empty, it raises the exception EMPTY.
P : LIST;
begin
if L = EMPTY_LIST then
raise EMPTY;
end if;
P := L.LINK;
E := P.ITEM;
if P = L then
L := NULL; -- Removed last item from the list
else
L.LINK := P.LINK;
end if;
P.LINK := FREE; -- Add to the free list
FREE := P;
end REMOVE;
procedure CONS(E : in ELEMENT; L : in out LIST) is
--
-- This procedure adds the element E onto the front of the list
--
P : LIST;
begin
if L = EMPTY_LIST then
APPEND(L, E);
else
P := L;
APPEND(L, E);
L := P;
end if;
end CONS;
function FIRST(L : in LIST) return ELEMENT is
--
-- This function returns the first item in the list if the
-- list is not empty; otherwise it raises the exception EMPTY.
--
begin
if L = EMPTY_LIST then
raise EMPTY;
else
return L.LINK.ITEM;
end if;
end FIRST;
function LAST(L : in LIST) return ELEMENT is
--
-- This function returns the last item in the list if the
-- list is not empty; otherwise it raises the exception EMPTY.
--
begin
if L = EMPTY_LIST then
raise EMPTY;
else
return L.ITEM;
end if;
end LAST;
end LIST_PACKAGE;
|
29,873
|
ada
| 0
|
reznikmm/cvsweb2git
|
source/cvsweb-pushers.ads
|
-- BSD 3-Clause License
--
-- Copyright (c) 2017, <NAME>
-- 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 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 GNAT.OS_Lib;
with League.Calendars;
with League.Strings;
with League.String_Vectors;
with CvsWeb.Loaders;
package CvsWeb.Pushers is
type Pusher is tagged limited private;
procedure Initialize
(Self : in out Pusher;
Path : League.Strings.Universal_String);
procedure Push
(Self : in out Pusher;
Loader : in out CvsWeb.Loaders.Loader;
Skip : League.Calendars.Date_Time);
private
type Pusher is tagged limited record
Path : League.Strings.Universal_String;
Git : GNAT.OS_Lib.String_Access;
end record;
not overriding procedure Git_Add
(Self : Pusher;
File : League.Strings.Universal_String);
not overriding procedure Git_Commit
(Self : Pusher;
Date : League.Calendars.Date_Time;
Message : League.Strings.Universal_String;
List : League.String_Vectors.Universal_String_Vector);
not overriding procedure Exec
(Self : Pusher;
List : in out GNAT.OS_Lib.Argument_List);
end CvsWeb.Pushers;
|
29,874
|
ada
| 20
|
charlie5/lace
|
4-high/gel/applet/demo/sprite/chains_2d/launch_chains_2d.adb
|
<reponame>charlie5/lace<filename>4-high/gel/applet/demo/sprite/chains_2d/launch_chains_2d.adb
with
gel.Window.lumen,
gel.Applet.gui_world,
gel.Forge,
gel.Sprite,
gel.Joint,
Physics,
openGL.Palette;
pragma unreferenced (gel.Window.lumen);
procedure launch_Chains_2d
--
-- Creates a chain of balls in a 2D space.
--
is
use gel.Forge,
gel.Applet,
gel.Math,
opengl.Palette;
the_Applet : gel.Applet.gui_World.view := new_gui_Applet ("Chains 2D",
1536, 864,
space_Kind => physics.Box2D);
the_Ground : constant gel.Sprite.view := new_rectangle_Sprite (the_Applet.gui_World,
Mass => 0.0,
Width => 100.0,
Height => 1.0,
Color => apple_Green);
begin
the_Applet.gui_World .Gravity_is ((0.0, -10.0, 0.0));
the_Applet.gui_Camera.Site_is ((0.0, -30.0, 100.0));
the_Applet.Renderer .Background_is (Grey);
the_Applet.enable_simple_Dolly (in_World => gui_World.gui_world_Id);
the_Ground.Site_is ((0.0, -40.0, 0.0));
the_Applet.gui_World.add (the_Ground, and_Children => False);
-- Add joints.
--
declare
ball_Count : constant := 39;
the_root_Ball : constant gel.Sprite.view := new_circle_Sprite (the_Applet.gui_World, Mass => 0.0);
the_Balls : constant gel.Sprite.views := (1 .. ball_Count => new_circle_Sprite (the_Applet.gui_World, Mass => 1.0));
Parent : gel.Sprite.view := the_root_Ball;
new_Joint : gel.Joint .view;
begin
for i in the_Balls'Range
loop
the_Balls (i).Site_is ((Real (-i), 0.0, 0.0));
Parent.attach_via_Hinge (the_Child => the_Balls (i),
pivot_Axis => (0.0, 0.0, 1.0),
low_Limit => to_Radians (-180.0),
high_Limit => to_Radians ( 180.0),
new_joint => new_Joint);
Parent := the_Balls (i);
end loop;
the_Applet.gui_World.add (the_root_Ball, and_Children => True);
end;
while the_Applet.is_open
loop
the_Applet.freshen; -- Handle any new events, evolve physics and update the screen.
end loop;
gel.Applet.gui_world.free (the_Applet);
end launch_Chains_2d;
|
29,875
|
ada
| 0
|
jonashaggstrom/ada-canopen
|
src/aco-canopen.ads
|
with ACO.Configuration;
with ACO.Drivers;
with ACO.Events;
with ACO.Messages;
with Ada.Finalization;
with Ada.Real_Time; use Ada.Real_Time;
private with ACO.Messages.Buffer;
private with Ada.Synchronous_Task_Control;
package ACO.CANopen is
type Handler_Base
is abstract new Ada.Finalization.Limited_Controlled with record
Events : ACO.Events.Handler_Event_Manager;
end record;
type Handler
(Driver : not null access ACO.Drivers.Driver'Class)
is new Handler_Base with private;
procedure Start
(This : in out Handler);
procedure Put
(This : in out Handler;
Msg : in ACO.Messages.Message);
procedure Periodic_Actions
(This : in out Handler;
T_Now : in Ada.Real_Time.Time);
function Current_Time
(This : Handler)
return Ada.Real_Time.Time;
task type Periodic_Task
(This : not null access Handler;
Period_Dur : not null access Duration)
with Priority => ACO.Configuration.Periodic_Task_Priority;
private
type Handler
(Driver : not null access ACO.Drivers.Driver'Class)
is new Handler_Base with record
Messages : ACO.Messages.Buffer.Protected_Queue
(Ceiling => ACO.Configuration.Messages_Buffer_Ceiling);
Suspension : Ada.Synchronous_Task_Control.Suspension_Object;
end record;
end ACO.CANopen;
|
29,876
|
ada
| 1
|
persan/A-gst
|
tests/src/gstreamer-rtsp-transport-tests.ads
|
with AUnit.Test_Cases;
package GStreamer.Rtsp.transport.Tests is
use AUnit;
type Test_Case is new AUnit.Test_Cases.Test_Case with null record;
function Name (Test : Test_Case) return Message_String;
procedure Register_Tests (Test : in out Test_Case);
end GStreamer.Rtsp.transport.Tests;
|
29,877
|
ada
| 9
|
reznikmm/clic
|
src/clic.ads
|
<reponame>reznikmm/clic<filename>src/clic.ads<gh_stars>1-10
package CLIC
with Preelaborate
is
end CLIC;
|
29,878
|
ada
| 1
|
vidkidz/crossbridge
|
llvm-gcc-4.2-2.9/gcc/ada/a-stzfix.ads
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . W I D E _ W I D E _ F I X E D --
-- --
-- S p e c --
-- --
-- This specification is adapted from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Wide_Wide_Maps;
package Ada.Strings.Wide_Wide_Fixed is
pragma Preelaborate;
------------------------------------------------------------------------
-- Copy Procedure for Wide_Wide_Strings of Possibly Different Lengths --
------------------------------------------------------------------------
procedure Move
(Source : Wide_Wide_String;
Target : out Wide_Wide_String;
Drop : Truncation := Error;
Justify : Alignment := Left;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space);
------------------------
-- Search Subprograms --
------------------------
function Index
(Source : Wide_Wide_String;
Pattern : Wide_Wide_String;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
Wide_Wide_Maps.Identity) return Natural;
function Index
(Source : Wide_Wide_String;
Pattern : Wide_Wide_String;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural;
function Index
(Source : Wide_Wide_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
function Index
(Source : Wide_Wide_String;
Pattern : Wide_Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
Wide_Wide_Maps.Identity)
return Natural;
pragma Ada_05 (Index);
function Index
(Source : Wide_Wide_String;
Pattern : Wide_Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural;
pragma Ada_05 (Index);
function Index
(Source : Wide_Wide_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
pragma Ada_05 (Index);
function Index_Non_Blank
(Source : Wide_Wide_String;
Going : Direction := Forward) return Natural;
function Index_Non_Blank
(Source : Wide_Wide_String;
From : Positive;
Going : Direction := Forward) return Natural;
pragma Ada_05 (Index_Non_Blank);
function Count
(Source : Wide_Wide_String;
Pattern : Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
Wide_Wide_Maps.Identity)
return Natural;
function Count
(Source : Wide_Wide_String;
Pattern : Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Natural;
function Count
(Source : Wide_Wide_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural;
procedure Find_Token
(Source : Wide_Wide_String;
Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
Test : Membership;
First : out Positive;
Last : out Natural);
----------------------------------------------
-- Wide_Wide_String Translation Subprograms --
----------------------------------------------
function Translate
(Source : Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
return Wide_Wide_String;
procedure Translate
(Source : in out Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping);
function Translate
(Source : Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
return Wide_Wide_String;
procedure Translate
(Source : in out Wide_Wide_String;
Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function);
-------------------------------------------------
-- Wide_Wide_String Transformation Subprograms --
-------------------------------------------------
function Replace_Slice
(Source : Wide_Wide_String;
Low : Positive;
High : Natural;
By : Wide_Wide_String) return Wide_Wide_String;
procedure Replace_Slice
(Source : in out Wide_Wide_String;
Low : Positive;
High : Natural;
By : Wide_Wide_String;
Drop : Truncation := Error;
Justify : Alignment := Left;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space);
function Insert
(Source : Wide_Wide_String;
Before : Positive;
New_Item : Wide_Wide_String) return Wide_Wide_String;
procedure Insert
(Source : in out Wide_Wide_String;
Before : Positive;
New_Item : Wide_Wide_String;
Drop : Truncation := Error);
function Overwrite
(Source : Wide_Wide_String;
Position : Positive;
New_Item : Wide_Wide_String) return Wide_Wide_String;
procedure Overwrite
(Source : in out Wide_Wide_String;
Position : Positive;
New_Item : Wide_Wide_String;
Drop : Truncation := Right);
function Delete
(Source : Wide_Wide_String;
From : Positive;
Through : Natural) return Wide_Wide_String;
procedure Delete
(Source : in out Wide_Wide_String;
From : Positive;
Through : Natural;
Justify : Alignment := Left;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space);
-------------------------------------------
-- Wide_Wide_String Selector Subprograms --
-------------------------------------------
function Trim
(Source : Wide_Wide_String;
Side : Trim_End) return Wide_Wide_String;
procedure Trim
(Source : in out Wide_Wide_String;
Side : Trim_End;
Justify : Alignment := Left;
Pad : Wide_Wide_Character := Wide_Wide_Space);
function Trim
(Source : Wide_Wide_String;
Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
Right : Wide_Wide_Maps.Wide_Wide_Character_Set)
return Wide_Wide_String;
procedure Trim
(Source : in out Wide_Wide_String;
Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
Right : Wide_Wide_Maps.Wide_Wide_Character_Set;
Justify : Alignment := Ada.Strings.Left;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space);
function Head
(Source : Wide_Wide_String;
Count : Natural;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space)
return Wide_Wide_String;
procedure Head
(Source : in out Wide_Wide_String;
Count : Natural;
Justify : Alignment := Left;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space);
function Tail
(Source : Wide_Wide_String;
Count : Natural;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space)
return Wide_Wide_String;
procedure Tail
(Source : in out Wide_Wide_String;
Count : Natural;
Justify : Alignment := Left;
Pad : Wide_Wide_Character := Ada.Strings.Wide_Wide_Space);
--------------------------------------------
-- Wide_Wide_String Constructor Functions --
--------------------------------------------
function "*"
(Left : Natural;
Right : Wide_Wide_Character) return Wide_Wide_String;
function "*"
(Left : Natural;
Right : Wide_Wide_String) return Wide_Wide_String;
end Ada.Strings.Wide_Wide_Fixed;
|
29,879
|
ada
| 80
|
thindil/steamsky
|
tests/bases-test_data-tests.ads
|
-- This package has been generated automatically by GNATtest.
-- Do not edit any part of it, see GNATtest documentation for more details.
-- begin read only
with Gnattest_Generated;
package Bases.Test_Data.Tests is
type Test is new GNATtest_Generated.GNATtest_Standard.Bases.Test_Data
.Test with
null record;
procedure Test_Gain_Rep_e2afe4_901e58(Gnattest_T: in out Test);
-- bases.ads:191:4:Gain_Rep:Test_GainRep
procedure Test_Count_Price_d382e2_cce97c(Gnattest_T: in out Test);
-- bases.ads:207:4:Count_Price:Test_CountPrice
procedure Test_Generate_Base_Name_f6aaaa_29d5e9(Gnattest_T: in out Test);
-- bases.ads:222:4:Generate_Base_Name:Test_GenerateBaseName
procedure Test_Generate_Recruits_05fabc_06ea09(Gnattest_T: in out Test);
-- bases.ads:234:4:Generate_Recruits:Test_GenerateRecruits
procedure Test_Ask_For_Bases_023c5f_f3f6c6(Gnattest_T: in out Test);
-- bases.ads:242:4:Ask_For_Bases:Test_AskForBases
procedure Test_Ask_For_Events_4f17f6_3e359b(Gnattest_T: in out Test);
-- bases.ads:250:4:Ask_For_Events:Test_AskForEvents
procedure Test_Update_Population_31557d_10dec8(Gnattest_T: in out Test);
-- bases.ads:258:4:Update_Population:Test_UpdatePopulation
procedure Test_Update_Prices_56b29f_f6cd8d(Gnattest_T: in out Test);
-- bases.ads:266:4:Update_Prices:Test_UpdatePrices
end Bases.Test_Data.Tests;
-- end read only
|
29,880
|
ada
| 30
|
jrmarino/AdaBase
|
testcases/bad_select/bad_select.adb
|
<gh_stars>10-100
with AdaBase;
with Connect;
with CommonText;
with Ada.Text_IO;
with AdaBase.Results.Sets;
procedure Bad_Select is
package CON renames Connect;
package TIO renames Ada.Text_IO;
package ARS renames AdaBase.Results.Sets;
package CT renames CommonText;
row : ARS.Datarow;
sql : String := "SELECT fruit, calories FROM froits " &
"WHERE color = 'red'";
success : Boolean := True;
begin
-- PostgreSQL will abort a transaction even for a bad select
-- so in this case, let's not start any transactions
CON.DR.set_trait_autocommit (True);
CON.connect_database;
declare
stmt : CON.Stmt_Type := CON.DR.query (sql);
begin
TIO.Put_Line ("Query successful: " & stmt.successful'Img);
if not stmt.successful then
TIO.Put_Line (" Driver message: " & stmt.last_driver_message);
TIO.Put_Line (" Driver code: " & stmt.last_driver_code'Img);
TIO.Put_Line (" SQL State: " & stmt.last_sql_state);
success := False;
end if;
end;
if not success then
-- Fix SQL typo
sql (31) := 'u';
TIO.Put_Line ("");
TIO.Put_Line ("SQL now: " & sql);
declare
stmt : CON.Stmt_Type := CON.DR.query (sql);
begin
TIO.Put_Line ("Query successful: " & stmt.successful'Img);
row := stmt.fetch_next;
if not row.data_exhausted then
TIO.Put_Line (" Number fields:" & row.count'Img);
stmt.discard_rest;
TIO.Put_Line (" Data discarded: " & stmt.data_discarded'Img);
end if;
end;
end if;
CON.DR.disconnect;
end Bad_Select;
|
29,881
|
ada
| 6
|
Heziode/ada-dotenv
|
example/src/load_environment_variables.ads
|
<reponame>Heziode/ada-dotenv
package Load_Environment_Variables is
pragma Elaborate_Body;
end Load_Environment_Variables;
|
29,882
|
ada
| 24
|
svn2github/matreshka
|
source/league/matreshka-internals-settings-ini_files.adb
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Directories;
with Ada.Streams.Stream_IO;
with League.Stream_Element_Vectors.Internals;
with League.Text_Codecs;
with Matreshka.Internals.Stream_Element_Vectors;
with Matreshka.Internals.Unicode.Characters.Latin;
package body Matreshka.Internals.Settings.Ini_Files is
use Ada.Streams;
use League.Stream_Element_Vectors;
use League.Strings;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Unicode.Characters.Latin;
package Section_Maps is
new Ada.Containers.Hashed_Maps
(League.Strings.Universal_String,
Maps.Map,
League.Strings.Hash,
League.Strings."=",
Maps."=");
-- This map is used to group key/value pairs in sections for serialization.
Line_Delimiter : constant Stream_Element_Array := (0 => Line_Feed);
-- Line_Delimiter : constant Stream_Element_Array
-- := (0 => Carriage_Return, 1 => Line_Feed);
-- Operating system dependent delimiter of lines in the text file.
function To_Locale_String
(Item : League.Strings.Universal_String) return String;
-- Converts Universal_String to locale 8-bit string to use as file name for
-- standard Ada library subprograms.
procedure Load (Self : in out Ini_File_Settings'Class);
-- Loads data from the file.
procedure Parse
(Self : in out Ini_File_Settings'Class;
Data : League.Stream_Element_Vectors.Stream_Element_Vector);
-- Parses data.
function Serialize
(Self : Ini_File_Settings)
return League.Stream_Element_Vectors.Stream_Element_Vector;
-- Serializes data.
function Decode_Key
(Data : Ada.Streams.Stream_Element_Array)
return League.Strings.Universal_String;
-- Decodes key representation in the file into Universal_String.
function Decode_Value
(Data : Ada.Streams.Stream_Element_Array)
return League.Strings.Universal_String renames Decode_Key;
-- Decodes value representation in the file into Universal_String.
function Encode_Key
(Key : League.Strings.Universal_String)
return League.Stream_Element_Vectors.Stream_Element_Vector;
-- Encodes key to representation in the file.
function Encode_Value
(Key : League.Strings.Universal_String)
return League.Stream_Element_Vectors.Stream_Element_Vector
renames Encode_Key;
-- Encodes value to representation in the file.
function From_Hex
(Image : Ada.Streams.Stream_Element_Array)
return Matreshka.Internals.Unicode.Code_Unit_32;
-- Constructs Unicode code point from hexadecimal image. Returns
-- Code_Unit_32'Last when conversion failed.
--------------
-- Contains --
--------------
overriding function Contains
(Self : Ini_File_Settings;
Key : League.Strings.Universal_String) return Boolean is
begin
return Self.Values.Contains (Key);
end Contains;
------------
-- Create --
------------
function Create
(Manager : not null access Abstract_Manager'Class;
File_Name : League.Strings.Universal_String)
return not null Settings_Access is
begin
return Aux : constant not null Settings_Access
:= new Ini_File_Settings'
(Counter => <>,
Manager => Manager,
File_Name => File_Name,
Modified => False,
Values => Maps.Empty_Map)
do
declare
Self : Ini_File_Settings'Class
renames Ini_File_Settings'Class (Aux.all);
begin
Self.Load;
end;
end return;
end Create;
----------------
-- Decode_Key --
----------------
function Decode_Key
(Data : Ada.Streams.Stream_Element_Array)
return League.Strings.Universal_String
is
Key : League.Strings.Universal_String;
Index : Stream_Element_Offset := Data'First;
Code : Code_Unit_32;
begin
while Index <= Data'Last loop
Code := Code_Unit_32'Last;
if Data (Index) = Percent_Sign then
if Data (Index + 1) = Latin_Capital_Letter_U then
-- Unicode long format.
if Index + 7 <= Data'Last then
Code := From_Hex (Data (Index + 2 .. Index + 7));
end if;
Index := Index + 8;
elsif Data (Index + 1) = Latin_Small_Letter_U then
-- Unicode short format.
if Index + 5 <= Data'Last then
Code := From_Hex (Data (Index + 2 .. Index + 5));
end if;
Index := Index + 6;
else
-- Two digits format.
if Index + 2 <= Data'Last then
Code := From_Hex (Data (Index + 1 .. Index + 2));
end if;
Index := Index + 3;
end if;
else
Code := Code_Unit_32 (Data (Index));
Index := Index + 1;
end if;
if Is_Valid (Code) then
Key.Append (Wide_Wide_Character'Val (Code));
end if;
end loop;
return Key;
end Decode_Key;
----------------
-- Encode_Key --
----------------
function Encode_Key
(Key : League.Strings.Universal_String)
return League.Stream_Element_Vectors.Stream_Element_Vector
is
Aux : Stream_Element_Vector;
Code : Code_Point;
To_Hex : constant array (Code_Unit_32 range 0 .. 15) of Stream_Element
:= (Digit_Zero, Digit_One, Digit_Two, Digit_Three,
Digit_Four, Digit_Five, Digit_Six, Digit_Seven,
Digit_Eight, Digit_Nine, Latin_Capital_Letter_A,
Latin_Capital_Letter_B, Latin_Capital_Letter_C,
Latin_Capital_Letter_D, Latin_Capital_Letter_E,
Latin_Capital_Letter_F);
begin
for J in 1 .. Key.Length loop
Code :=
Wide_Wide_Character'Pos (Key.Element (J).To_Wide_Wide_Character);
if Code in Space .. Tilde then
Aux.Append (Stream_Element (Code));
elsif Code <= 16#FF# then
-- Two digits format.
Aux.Append (Percent_Sign);
Aux.Append (To_Hex ((Code / 16) mod 16));
Aux.Append (To_Hex (Code mod 16));
elsif Code <= 16#FFFF# then
-- Short Unicode form.
Aux.Append (Percent_Sign);
Aux.Append (Latin_Small_Letter_U);
Aux.Append (To_Hex ((Code / 4096) mod 16));
Aux.Append (To_Hex ((Code / 256) mod 16));
Aux.Append (To_Hex ((Code / 16) mod 16));
Aux.Append (To_Hex (Code mod 16));
else
-- Long Unicode form.
Aux.Append (Percent_Sign);
Aux.Append (Latin_Capital_Letter_U);
Aux.Append (To_Hex ((Code / 1048576) mod 16));
Aux.Append (To_Hex ((Code / 65536) mod 16));
Aux.Append (To_Hex ((Code / 4096) mod 16));
Aux.Append (To_Hex ((Code / 256) mod 16));
Aux.Append (To_Hex ((Code / 16) mod 16));
Aux.Append (To_Hex (Code mod 16));
end if;
end loop;
return Aux;
end Encode_Key;
--------------
-- Finalize --
--------------
overriding procedure Finalize
(Self : not null access Ini_File_Settings) is
begin
Self.Sync;
end Finalize;
--------------
-- From_Hex --
--------------
function From_Hex
(Image : Ada.Streams.Stream_Element_Array)
return Matreshka.Internals.Unicode.Code_Unit_32
is
Code : Code_Unit_32 := 0;
Index : Stream_Element_Offset := Image'First;
begin
while Index <= Image'Last loop
Code := Code * 16;
if Image (Index) in Digit_Zero .. Digit_Nine then
Code := Code + Code_Unit_32 (Image (Index)) - Digit_Zero;
elsif Image (Index)
in Latin_Capital_Letter_A .. Latin_Capital_Letter_F
then
Code :=
Code
+ Code_Unit_32 (Image (Index)) - Latin_Capital_Letter_A + 10;
elsif Image (Index)
in Latin_Small_Letter_A .. Latin_Small_Letter_F
then
Code :=
Code + Code_Unit_32 (Image (Index)) - Latin_Small_Letter_A + 10;
else
return Code_Unit_32'Last;
end if;
if Code not in Code_Point then
return Code_Unit_32'Last;
end if;
Index := Index + 1;
end loop;
return Code;
end From_Hex;
----------
-- Load --
----------
procedure Load (Self : in out Ini_File_Settings'Class) is
use Ada.Streams.Stream_IO;
File : File_Type;
Buffer : Stream_Element_Array (1 .. 1024);
Data : Stream_Element_Vector;
Last : Stream_Element_Offset;
begin
if Ada.Directories.Exists (To_Locale_String (Self.File_Name)) then
-- Load content of the file.
Open (File, In_File, To_Locale_String (Self.File_Name));
loop
Read (File, Buffer, Last);
exit when Last < Buffer'First;
Data.Append (Buffer (Buffer'First .. Last));
end loop;
Close (File);
-- Parse.
Self.Parse (Data);
end if;
end Load;
----------
-- Name --
----------
overriding function Name
(Self : not null access Ini_File_Settings)
return League.Strings.Universal_String is
begin
return Self.File_Name;
end Name;
-----------
-- Parse --
-----------
procedure Parse
(Self : in out Ini_File_Settings'Class;
Data : League.Stream_Element_Vectors.Stream_Element_Vector)
is
use Matreshka.Internals.Stream_Element_Vectors;
procedure Parse_Line;
-- Determine boundary of the next line.
Buffer : constant Shared_Stream_Element_Vector_Access
:= League.Stream_Element_Vectors.Internals.Internal (Data);
Line_First : Stream_Element_Offset;
Line_Last : Stream_Element_Offset;
Equal_Index : Stream_Element_Offset;
Key_Last : Stream_Element_Offset;
Value_First : Stream_Element_Offset;
Current_Section : Universal_String;
Key : Universal_String;
----------------
-- Parse_Line --
----------------
procedure Parse_Line is
begin
Line_First := Line_Last + 1;
-- Skip leading whitespaces.
while Line_First < Buffer.Length loop
exit when
Buffer.Value (Line_First) /= Space
and Buffer.Value (Line_First) /= Character_Tabulation
and Buffer.Value (Line_First) /= Carriage_Return
and Buffer.Value (Line_First) /= Line_Feed;
Line_First := Line_First + 1;
end loop;
Line_Last := Line_First;
Equal_Index := Line_First - 1;
-- Scan line.
while Line_Last < Buffer.Length loop
-- Exit when end of line is reached.
exit when
Buffer.Value (Line_Last) = Carriage_Return
or Buffer.Value (Line_Last) = Line_Feed;
-- Save position of first occurrence of equal sign.
if Buffer.Value (Line_Last) = Equals_Sign
and Equal_Index < Line_First
then
Equal_Index := Line_Last;
end if;
Line_Last := Line_Last + 1;
end loop;
Line_Last := Line_Last - 1;
-- Remove trailing whitespaces.
loop
exit when
Buffer.Value (Line_Last) /= Character_Tabulation
and Buffer.Value (Line_Last) /= Space;
Line_Last := Line_Last - 1;
end loop;
-- Determine key and value boundary.
if Equal_Index >= Line_First then
Key_Last := Equal_Index - 1;
while Key_Last >= Line_First loop
exit when
Buffer.Value (Key_Last) /= Character_Tabulation
and Buffer.Value (Key_Last) /= Space;
Key_Last := Key_Last - 1;
end loop;
Value_First := Equal_Index + 1;
while Value_First <= Line_Last loop
exit when
Buffer.Value (Value_First) /= Character_Tabulation
and Buffer.Value (Value_First) /= Space;
Value_First := Value_First + 1;
end loop;
end if;
end Parse_Line;
begin
Line_Last := -1;
loop
Parse_Line;
exit when Line_Last < Line_First;
if Buffer.Value (Line_First) = Semicolon then
-- This is a comment line.
null;
elsif Buffer.Value (Line_First) = Left_Square_Bracket then
-- Section.
Line_First := Line_First + 1;
if Buffer.Value (Line_Last) = Right_Square_Bracket then
Key_Last := Line_Last - 1;
else
Key_Last := Line_Last;
end if;
-- Strip leading whitespaces.
while Line_First <= Key_Last loop
exit when
Buffer.Value (Line_First) /= Character_Tabulation
and Buffer.Value (Line_First) /= Space;
Line_First := Line_First + 1;
end loop;
-- Strip trailing whitespaces.
while Key_Last >= Line_First loop
exit when
Buffer.Value (Key_Last) /= Character_Tabulation
and Buffer.Value (Key_Last) /= Space;
Key_Last := Key_Last - 1;
end loop;
Current_Section :=
Decode_Key (Buffer.Value (Line_First .. Key_Last));
elsif Equal_Index >= Line_First then
-- Key/value pair.
Key := Current_Section;
if not Key.Is_Empty then
Key.Append ('/');
end if;
Key.Append (Decode_Key (Buffer.Value (Line_First .. Key_Last)));
if not Self.Values.Contains (Key) then
Self.Values.Insert
(Key,
To_Stream_Element_Vector
(Buffer.Value (Value_First .. Line_Last)));
end if;
else
-- Incorrect line.
null;
end if;
end loop;
end Parse;
------------
-- Remove --
------------
overriding procedure Remove
(Self : in out Ini_File_Settings;
Key : League.Strings.Universal_String) is
begin
if Self.Values.Contains (Key) then
Self.Values.Delete (Key);
Self.Modified := True;
end if;
end Remove;
---------------
-- Serialize --
---------------
function Serialize
(Self : Ini_File_Settings)
return League.Stream_Element_Vectors.Stream_Element_Vector
is
procedure Group_Pair (Position : Maps.Cursor);
-- Add pair into sections map.
procedure Serialize_Section (Position : Section_Maps.Cursor);
-- Serialize specified section and its key/value pairs.
procedure Serialize_Pair (Position : Maps.Cursor);
-- Serialize specified key/value pair.
Aux : League.Stream_Element_Vectors.Stream_Element_Vector;
Sections : Section_Maps.Map;
----------------
-- Group_Pair --
----------------
procedure Group_Pair (Position : Maps.Cursor) is
procedure Insert_Pair
(Section_Key : Universal_String;
Section_Values : in out Maps.Map);
-- Insert current key/value pair into the specified section. It
-- removes first component of key name.
Key : constant Universal_String := Maps.Key (Position);
Value : constant Stream_Element_Vector
:= Maps.Element (Position);
Index : constant Natural := Key.Index ('/');
Section_Position : Section_Maps.Cursor;
-----------------
-- Insert_Pair --
-----------------
procedure Insert_Pair
(Section_Key : Universal_String;
Section_Values : in out Maps.Map) is
begin
if Index = 0 then
Section_Values.Insert (Key, Value);
else
Section_Values.Insert
(Key.Slice (Index + 1, Key.Length), Value);
end if;
end Insert_Pair;
begin
if Index = 0 then
Section_Position := Sections.Find (Empty_Universal_String);
if not Section_Maps.Has_Element (Section_Position) then
Sections.Insert (Empty_Universal_String, Maps.Empty_Map);
Section_Position := Sections.Find (Empty_Universal_String);
end if;
else
Section_Position := Sections.Find (Key.Slice (1, Index - 1));
if not Section_Maps.Has_Element (Section_Position) then
Sections.Insert (Key.Slice (1, Index - 1), Maps.Empty_Map);
Section_Position := Sections.Find (Key.Slice (1, Index - 1));
end if;
end if;
Sections.Update_Element (Section_Position, Insert_Pair'Access);
end Group_Pair;
--------------------
-- Serialize_Pair --
--------------------
procedure Serialize_Pair (Position : Maps.Cursor) is
Key : constant Universal_String := Maps.Key (Position);
Value : constant Stream_Element_Vector := Maps.Element (Position);
begin
Aux.Append (Encode_Key (Key));
Aux.Append (Equals_Sign);
Aux.Append (Value);
Aux.Append (Line_Delimiter);
end Serialize_Pair;
-----------------------
-- Serialize_Section --
-----------------------
procedure Serialize_Section (Position : Section_Maps.Cursor) is
Section : constant Universal_String := Section_Maps.Key (Position);
Values : constant Maps.Map := Section_Maps.Element (Position);
begin
Aux.Append (Left_Square_Bracket);
Aux.Append (Encode_Key (Section));
Aux.Append (Right_Square_Bracket);
Aux.Append (Line_Delimiter);
Values.Iterate (Serialize_Pair'Access);
Aux.Append (Line_Delimiter);
end Serialize_Section;
begin
-- Group key/value pair into sections.
Self.Values.Iterate (Group_Pair'Access);
-- Serialize sections and their key/value pairs.
Sections.Iterate (Serialize_Section'Access);
return Aux;
end Serialize;
---------------
-- Set_Value --
---------------
overriding procedure Set_Value
(Self : in out Ini_File_Settings;
Key : League.Strings.Universal_String;
Value : League.Holders.Holder) is
begin
Self.Modified := True;
Self.Values.Include (Key, Encode_Value (League.Holders.Element (Value)));
end Set_Value;
----------
-- Sync --
----------
overriding procedure Sync (Self : in out Ini_File_Settings) is
use Ada.Streams.Stream_IO;
use League.Stream_Element_Vectors.Internals;
Name : constant String := To_Locale_String (Self.File_Name);
File : File_Type;
Data : Stream_Element_Vector;
begin
if Self.Modified then
-- Serialize data.
Data := Serialize (Self);
-- Creates directory when necessary.
Ada.Directories.Create_Path
(Ada.Directories.Containing_Directory (Name));
-- Writes data into file.
Create (File, Out_File, Name);
Write (File, Internal (Data).Value (0 .. Internal (Data).Length - 1));
Close (File);
Self.Modified := False;
end if;
end Sync;
----------------------
-- To_Locale_String --
----------------------
function To_Locale_String
(Item : League.Strings.Universal_String) return String
is
Aux : constant Stream_Element_Array
:= League.Text_Codecs.Codec_For_Application_Locale.Encode
(Item).To_Stream_Element_Array;
Str : String (1 .. Aux'Length);
for Str'Address use Aux'Address;
pragma Import (Ada, Str);
begin
return Str;
end To_Locale_String;
-----------
-- Value --
-----------
overriding function Value
(Self : Ini_File_Settings;
Key : League.Strings.Universal_String)
return League.Holders.Holder is
begin
if Self.Values.Contains (Key) then
return
League.Holders.To_Holder
(Decode_Value (Self.Values.Element (Key).To_Stream_Element_Array));
else
return League.Holders.Empty_Holder;
end if;
end Value;
end Matreshka.Internals.Settings.Ini_Files;
|
29,883
|
ada
| 20
|
charlie5/lace
|
3-mid/impact/source/3d/collision/shapes/impact-d3-shape-convex-internal-cylinder.ads
|
with impact.d3.Shape.convex.internal;
-- #include "impact.d3.Shape.convex.internal.polyhedral.box.h"
-- #include "BulletCollision/BroadphaseCollision/impact.d3.collision.Proxy.h" // for the types
-- #include "LinearMath/impact.d3.Vector.h"
package impact.d3.Shape.convex.internal.cylinder
--
-- The impact.d3.Shape.convex.internal.cylinder class implements a cylinder shape primitive, centered around the origin. Its central axis aligned
-- with the Y axis. impact.d3.Shape.convex.internal.cylinderX is aligned with the X axis and impact.d3.Shape.convex.internal.cylinderZ around the Z axis.
--
is
type Item is new impact.d3.Shape.convex.internal.item with private;
type View is access all Item'Class;
overriding procedure calculateLocalInertia (Self : in Item; mass : in math.Real;
inertia : out math.Vector_3);
overriding function getName (Self : in Item) return String;
overriding function localGetSupportingVertexWithoutMargin (Self : in Item; vec : in math.Vector_3) return Math.Vector_3;
overriding function localGetSupportingVertex (Self : in Item; vec : in math.Vector_3) return Math.Vector_3;
overriding procedure batchedUnitVectorGetSupportingVertexWithoutMargin (Self : in Item; vectors : in Vector_3_array;
supportVerticesOut : out Vector_3_array;
numVectors : in Integer);
function getHalfExtentsWithMargin (Self : in Item) return math.Vector_3;
function getHalfExtentsWithoutMargin (Self : in Item) return math.Vector_3;
overriding procedure getAabb (Self : in Item; t : in Transform_3d;
aabbMin, aabbMax : out math.Vector_3);
overriding procedure setMargin (Self : in out Item; collisionMargin : in math.Real);
-- procedure calculateLocalInertia (Self : in Item; mass : in math.Real;
-- inertia : out math.Vector_3);
--
-- Use box inertia.
-- // virtual void calculateLocalInertia(impact.d3.Scalar mass,impact.d3.Vector& inertia) const;
function getUpAxis (Self : in Item) return Integer;
function getRadius (Self : in Item) return math.Real;
overriding procedure setLocalScaling (Self : in out Item; scaling : in math.Vector_3);
--------------
--- cylinderX
--
type cylinderX is new impact.d3.Shape.convex.internal.cylinder.Item with private;
overriding function localGetSupportingVertexWithoutMargin (Self : in cylinderX; vec : in math.Vector_3) return Math.Vector_3;
overriding procedure batchedUnitVectorGetSupportingVertexWithoutMargin (Self : in cylinderX; vectors : in Vector_3_array;
supportVerticesOut : out Vector_3_array;
numVectors : in Integer);
overriding function getName (Self : in cylinderX) return String;
-- virtual const char* getName()const
-- {
-- return "CylinderX";
-- }
overriding function getRadius (Self : in cylinderX) return math.Real;
-- virtual impact.d3.Scalar getRadius() const
-- {
-- return getHalfExtentsWithMargin().getY();
-- }
--------------
--- cylinderZ
--
type cylinderZ is new impact.d3.Shape.convex.internal.cylinder.Item with private;
overriding function localGetSupportingVertexWithoutMargin (Self : in cylinderZ; vec : in math.Vector_3) return Math.Vector_3;
overriding procedure batchedUnitVectorGetSupportingVertexWithoutMargin (Self : in cylinderZ; vectors : in Vector_3_array;
supportVerticesOut : out Vector_3_array;
numVectors : in Integer);
overriding function getName (Self : in cylinderZ) return String;
-- virtual const char* getName()const
-- {
-- return "CylinderZ";
-- }
overriding function getRadius (Self : in cylinderZ) return math.Real;
-- virtual impact.d3.Scalar getRadius() const
-- {
-- return getHalfExtentsWithMargin().getX();
-- }
package Forge
is
function to_cylinder_Shape (halfExtents : in math.Vector_3) return Item;
function to_cylinder_Z_Shape (halfExtents : in math.Vector_3) return cylinderZ;
function to_cylinder_X_Shape (halfExtents : in math.Vector_3) return cylinderX;
end Forge;
private
type Item is new impact.d3.Shape.convex.internal.item with
record
m_upAxis : Integer;
end record;
type cylinderX is new impact.d3.Shape.convex.internal.cylinder.item with null record;
type cylinderZ is new impact.d3.Shape.convex.internal.cylinder.item with null record;
end impact.d3.Shape.convex.internal.cylinder;
|
29,884
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/ada/exp_tss.adb
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ T S S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Einfo; use Einfo;
with Elists; use Elists;
with Exp_Util; use Exp_Util;
with Nlists; use Nlists;
with Lib; use Lib;
with Restrict; use Restrict;
with Rident; use Rident;
with Sem_Aux; use Sem_Aux;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
package body Exp_Tss is
--------------------
-- Base_Init_Proc --
--------------------
function Base_Init_Proc
(Typ : Entity_Id;
Ref : Entity_Id := Empty) return Entity_Id
is
Full_Type : E;
Proc : Entity_Id;
begin
pragma Assert (Is_Type (Typ));
if Is_Private_Type (Typ) then
Full_Type := Underlying_Type (Base_Type (Typ));
else
Full_Type := Typ;
end if;
if No (Full_Type) then
return Empty;
elsif Is_Concurrent_Type (Full_Type)
and then Present (Corresponding_Record_Type (Base_Type (Full_Type)))
then
-- The initialization routine to be called is that of the base type
-- of the corresponding record type, which may itself be a subtype
-- and possibly an itype.
return Init_Proc
(Base_Type (Corresponding_Record_Type (Base_Type (Full_Type))),
Ref);
else
Proc := Init_Proc (Base_Type (Full_Type), Ref);
if No (Proc)
and then Is_Composite_Type (Full_Type)
and then Is_Derived_Type (Full_Type)
then
return Init_Proc (Root_Type (Full_Type), Ref);
else
return Proc;
end if;
end if;
end Base_Init_Proc;
--------------
-- Copy_TSS --
--------------
-- Note: internally this routine is also used to initially set up
-- a TSS entry for a new type (case of being called from Set_TSS)
procedure Copy_TSS (TSS : Entity_Id; Typ : Entity_Id) is
FN : Node_Id;
begin
Ensure_Freeze_Node (Typ);
FN := Freeze_Node (Typ);
if No (TSS_Elist (FN)) then
Set_TSS_Elist (FN, New_Elmt_List);
end if;
-- We prepend here, so that a second call overrides the first, it
-- is not clear that this is required, but it seems reasonable.
Prepend_Elmt (TSS, TSS_Elist (FN));
end Copy_TSS;
-------------------
-- CPP_Init_Proc --
-------------------
function CPP_Init_Proc (Typ : Entity_Id) return Entity_Id is
FN : constant Node_Id := Freeze_Node (Typ);
Elmt : Elmt_Id;
begin
if not Is_CPP_Class (Root_Type (Typ))
or else No (FN)
or else No (TSS_Elist (FN))
then
return Empty;
else
Elmt := First_Elmt (TSS_Elist (FN));
while Present (Elmt) loop
if Is_CPP_Init_Proc (Node (Elmt)) then
return Node (Elmt);
end if;
Next_Elmt (Elmt);
end loop;
end if;
return Empty;
end CPP_Init_Proc;
------------------------
-- Find_Inherited_TSS --
------------------------
function Find_Inherited_TSS
(Typ : Entity_Id;
Nam : TSS_Name_Type) return Entity_Id
is
Btyp : Entity_Id := Typ;
Proc : Entity_Id;
begin
loop
Btyp := Base_Type (Btyp);
Proc := TSS (Btyp, Nam);
exit when Present (Proc)
or else not Is_Derived_Type (Btyp);
-- If Typ is a derived type, it may inherit attributes from some
-- ancestor.
Btyp := Etype (Btyp);
end loop;
if No (Proc) then
-- If nothing else, use the TSS of the root type
Proc := TSS (Base_Type (Underlying_Type (Typ)), Nam);
end if;
return Proc;
end Find_Inherited_TSS;
-----------------------
-- Get_TSS_Name_Type --
-----------------------
function Get_TSS_Name (E : Entity_Id) return TSS_Name_Type is
C1 : Character;
C2 : Character;
Nm : TSS_Name_Type;
begin
Get_Last_Two_Chars (Chars (E), C1, C2);
if C1 in 'A' .. 'Z' and then C2 in 'A' .. 'Z' then
Nm := (C1, C2);
for J in TSS_Names'Range loop
if Nm = TSS_Names (J) then
return Nm;
end if;
end loop;
end if;
return TSS_Null;
end Get_TSS_Name;
---------------------------------
-- Has_Non_Null_Base_Init_Proc --
---------------------------------
-- Note: if a base Init_Proc is present, and No_Default_Initialization is
-- present, then we must avoid testing for a null init proc, since there
-- is no init proc present in this case.
function Has_Non_Null_Base_Init_Proc (Typ : Entity_Id) return Boolean is
BIP : constant Entity_Id := Base_Init_Proc (Typ);
begin
return Present (BIP)
and then (Restriction_Active (No_Default_Initialization)
or else not Is_Null_Init_Proc (BIP));
end Has_Non_Null_Base_Init_Proc;
---------------
-- Init_Proc --
---------------
function Init_Proc
(Typ : Entity_Id;
Ref : Entity_Id := Empty) return Entity_Id
is
FN : constant Node_Id := Freeze_Node (Typ);
Elmt : Elmt_Id;
E1 : Entity_Id;
E2 : Entity_Id;
begin
if No (FN) then
return Empty;
elsif No (TSS_Elist (FN)) then
return Empty;
elsif No (Ref) then
Elmt := First_Elmt (TSS_Elist (FN));
while Present (Elmt) loop
if Is_Init_Proc (Node (Elmt)) then
if not Is_CPP_Class (Typ) then
return Node (Elmt);
-- For CPP classes, we are looking for the default constructor,
-- and so we must skip any non-default constructor.
elsif
No (Next
(First
(Parameter_Specifications (Parent (Node (Elmt))))))
then
return Node (Elmt);
end if;
end if;
Next_Elmt (Elmt);
end loop;
-- Non-default constructors are currently supported only in the context
-- of interfacing with C++.
else pragma Assert (Is_CPP_Class (Typ));
-- Use the referenced function to locate the init_proc matching
-- the C++ constructor.
Elmt := First_Elmt (TSS_Elist (FN));
while Present (Elmt) loop
if Is_Init_Proc (Node (Elmt)) then
E1 := Next_Formal (First_Formal (Node (Elmt)));
E2 := First_Formal (Ref);
while Present (E1) and then Present (E2) loop
if Chars (E1) /= Chars (E2)
or else Ekind (E1) /= Ekind (E2)
then
exit;
elsif Ekind (Etype (E1)) /= E_Anonymous_Access_Type
and then Ekind (Etype (E2)) /= E_Anonymous_Access_Type
and then Etype (E1) /= Etype (E2)
then
exit;
elsif Ekind (Etype (E1)) = E_Anonymous_Access_Type
and then Ekind (Etype (E2)) = E_Anonymous_Access_Type
and then Directly_Designated_Type (Etype (E1))
/= Directly_Designated_Type (Etype (E2))
then
exit;
end if;
E1 := Next_Formal (E1);
E2 := Next_Formal (E2);
end loop;
if No (E1) and then No (E2) then
return Node (Elmt);
end if;
end if;
Next_Elmt (Elmt);
end loop;
end if;
return Empty;
end Init_Proc;
----------------------
-- Is_CPP_Init_Proc --
----------------------
function Is_CPP_Init_Proc (E : Entity_Id) return Boolean is
C1 : Character;
C2 : Character;
begin
Get_Last_Two_Chars (Chars (E), C1, C2);
return C1 = TSS_CPP_Init_Proc (1) and then C2 = TSS_CPP_Init_Proc (2);
end Is_CPP_Init_Proc;
------------------
-- Is_Init_Proc --
------------------
function Is_Init_Proc (E : Entity_Id) return Boolean is
C1 : Character;
C2 : Character;
begin
Get_Last_Two_Chars (Chars (E), C1, C2);
return C1 = TSS_Init_Proc (1) and then C2 = TSS_Init_Proc (2);
end Is_Init_Proc;
------------
-- Is_TSS --
------------
function Is_TSS (E : Entity_Id; Nam : TSS_Name_Type) return Boolean is
C1 : Character;
C2 : Character;
begin
Get_Last_Two_Chars (Chars (E), C1, C2);
return C1 = Nam (1) and then C2 = Nam (2);
end Is_TSS;
function Is_TSS (N : Name_Id; Nam : TSS_Name_Type) return Boolean is
C1 : Character;
C2 : Character;
begin
Get_Last_Two_Chars (N, C1, C2);
return C1 = Nam (1) and then C2 = Nam (2);
end Is_TSS;
-------------------------
-- Make_Init_Proc_Name --
-------------------------
function Make_Init_Proc_Name (Typ : Entity_Id) return Name_Id is
begin
return Make_TSS_Name (Typ, TSS_Init_Proc);
end Make_Init_Proc_Name;
-------------------
-- Make_TSS_Name --
-------------------
function Make_TSS_Name
(Typ : Entity_Id;
Nam : TSS_Name_Type) return Name_Id
is
begin
Get_Name_String (Chars (Typ));
Add_Char_To_Name_Buffer (Nam (1));
Add_Char_To_Name_Buffer (Nam (2));
return Name_Find;
end Make_TSS_Name;
-------------------------
-- Make_TSS_Name_Local --
-------------------------
function Make_TSS_Name_Local
(Typ : Entity_Id;
Nam : TSS_Name_Type) return Name_Id
is
begin
Get_Name_String (Chars (Typ));
Add_Char_To_Name_Buffer ('_');
Add_Nat_To_Name_Buffer (Increment_Serial_Number);
Add_Char_To_Name_Buffer (Nam (1));
Add_Char_To_Name_Buffer (Nam (2));
return Name_Find;
end Make_TSS_Name_Local;
--------------
-- Same_TSS --
--------------
function Same_TSS (E1, E2 : Entity_Id) return Boolean is
E1C1 : Character;
E1C2 : Character;
E2C1 : Character;
E2C2 : Character;
begin
Get_Last_Two_Chars (Chars (E1), E1C1, E1C2);
Get_Last_Two_Chars (Chars (E2), E2C1, E2C2);
return
E1C1 = E2C1
and then
E1C2 = E2C2
and then
E1C1 in 'A' .. 'Z'
and then
E1C2 in 'A' .. 'Z';
end Same_TSS;
-------------------
-- Set_Init_Proc --
-------------------
procedure Set_Init_Proc (Typ : Entity_Id; Init : Entity_Id) is
begin
Set_TSS (Typ, Init);
end Set_Init_Proc;
-------------
-- Set_TSS --
-------------
procedure Set_TSS (Typ : Entity_Id; TSS : Entity_Id) is
begin
-- Make sure body of subprogram is frozen
-- Skip this for Init_Proc with No_Default_Initialization, since the
-- Init proc is a dummy void entity in this case to be ignored.
if (Is_Init_Proc (TSS) or else Is_CPP_Init_Proc (TSS))
and then Restriction_Active (No_Default_Initialization)
then
null;
-- Skip this if not in the same code unit (since it means we are using
-- an already existing TSS in another unit)
elsif not In_Same_Code_Unit (Typ, TSS) then
null;
-- Otherwise make sure body is frozen
else
Append_Freeze_Action (Typ, Unit_Declaration_Node (TSS));
end if;
-- Set TSS entry
Copy_TSS (TSS, Typ);
end Set_TSS;
---------
-- TSS --
---------
function TSS (Typ : Entity_Id; Nam : TSS_Name_Type) return Entity_Id is
FN : constant Node_Id := Freeze_Node (Typ);
Elmt : Elmt_Id;
Subp : Entity_Id;
begin
if No (FN) then
return Empty;
elsif No (TSS_Elist (FN)) then
return Empty;
else
Elmt := First_Elmt (TSS_Elist (FN));
while Present (Elmt) loop
if Is_TSS (Node (Elmt), Nam) then
Subp := Node (Elmt);
-- For stream subprograms, the TSS entity may be a renaming-
-- as-body of an already generated entity. Use that one rather
-- the one introduced by the renaming, which is an artifact of
-- current stream handling.
if Nkind (Parent (Parent (Subp))) =
N_Subprogram_Renaming_Declaration
and then
Present (Corresponding_Spec (Parent (Parent (Subp))))
then
return Corresponding_Spec (Parent (Parent (Subp)));
else
return Subp;
end if;
else
Next_Elmt (Elmt);
end if;
end loop;
end if;
return Empty;
end TSS;
function TSS (Typ : Entity_Id; Nam : Name_Id) return Entity_Id is
FN : constant Node_Id := Freeze_Node (Typ);
Elmt : Elmt_Id;
Subp : Entity_Id;
begin
if No (FN) then
return Empty;
elsif No (TSS_Elist (FN)) then
return Empty;
else
Elmt := First_Elmt (TSS_Elist (FN));
while Present (Elmt) loop
if Chars (Node (Elmt)) = Nam then
Subp := Node (Elmt);
-- For stream subprograms, the TSS entity may be a renaming-
-- as-body of an already generated entity. Use that one rather
-- the one introduced by the renaming, which is an artifact of
-- current stream handling.
if Nkind (Parent (Parent (Subp))) =
N_Subprogram_Renaming_Declaration
and then
Present (Corresponding_Spec (Parent (Parent (Subp))))
then
return Corresponding_Spec (Parent (Parent (Subp)));
else
return Subp;
end if;
else
Next_Elmt (Elmt);
end if;
end loop;
end if;
return Empty;
end TSS;
end Exp_Tss;
|
29,885
|
ada
| 2
|
rocher/TTS-Runtime-Ravenscar
|
runtime/s-ttssup.ads
|
with System.BB.Threads;
package System.TTS_Support is
pragma Preelaborate (TTS_Support);
procedure Hold (T : System.BB.Threads.Thread_Id;
Check_Protected_Action : Boolean := False);
procedure Continue (T : System.BB.Threads.Thread_Id);
function Is_Held (T : System.BB.Threads.Thread_Id)
return Boolean;
end System.TTS_Support;
|
29,886
|
ada
| 81
|
My-Colaborations/ada-awa
|
awa/src/awa-users.ads
|
-----------------------------------------------------------------------
-- awa-users -- Users module
-- Copyright (C) 2009, 2010, 2011, 2015, 2018, 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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.
-----------------------------------------------------------------------
-- = Users Module =
-- The `users` module manages the creation, update, removal and authentication
-- of users in an application. The module provides the foundations for user
-- management in a web application.
--
-- A user can register himself by using a subscription form. In that case,
-- a verification mail is sent and the user has to follow the verification
-- link defined in the mail to finish the registration process. The user
-- will authenticate using a password.
--
-- A user can also use an OAuth/OpenID account and be automatically authentified
-- and registered to the application. By using an external authentication
-- server, passwords are not stored in the application.
--
-- A user can have one or several permissions that allow to protect the
-- application data. User permissions are managed by the `Permissions.Module`.
--
-- @include awa-users-modules.ads
-- @include awa-users-servlets.ads
--
-- == Configuration ==
-- The *users* module uses a set of configuration properties to configure
-- the OpenID integration.
--
-- @include-config users.xml
--
-- @include awa-users-beans.ads
--
-- == Data model ==
-- [images/awa_users_model.png]
--
package AWA.Users is
pragma Preelaborate;
end AWA.Users;
|
29,887
|
ada
| 20
|
charlie5/lace
|
1-base/lace/applet/demo/event/distributed/source/chat-client-local.adb
|
<filename>1-base/lace/applet/demo/event/distributed/source/chat-client-local.adb
with
chat.Registrar,
lace.Response,
lace.Observer,
lace.Event.utility,
system.RPC,
ada.Exceptions,
ada.Text_IO;
package body chat.Client.local
is
-- Utility
--
function "+" (From : in unbounded_String) return String
renames to_String;
-- Responses
--
type Show is new lace.Response.item with null record;
-- Response is to display the chat message on the users console.
--
overriding
procedure respond (Self : in out Show; to_Event : in lace.Event.item'Class)
is
pragma Unreferenced (Self);
use ada.Text_IO;
the_Message : constant Message := Message (to_Event);
begin
put_Line (the_Message.Text (1 .. the_Message.Length));
end respond;
the_Response : aliased chat.Client.local.show;
-- Forge
--
function to_Client (Name : in String) return Item
is
begin
return Self : Item
do
Self.Name := to_unbounded_String (Name);
end return;
end to_Client;
-- Attributes
--
overriding
function Name (Self : in Item) return String
is
begin
return to_String (Self.Name);
end Name;
overriding
function as_Observer (Self : access Item) return lace.Observer.view
is
begin
return Self;
end as_Observer;
overriding
function as_Subject (Self : access Item) return lace.Subject.view
is
begin
return Self;
end as_Subject;
-- Operations
--
overriding
procedure register_Client (Self : in out Item; other_Client : in Client.view)
is
use lace.Event.utility,
ada.Text_IO;
begin
lace.Event.utility.connect (the_Observer => Self'unchecked_Access,
to_Subject => other_Client.as_Subject,
with_Response => the_Response'Access,
to_Event_Kind => to_Kind (chat.Client.Message'Tag));
put_Line (other_Client.Name & " is here.");
end register_Client;
overriding
procedure deregister_Client (Self : in out Item; other_Client_as_Observer : in lace.Observer.view;
other_Client_Name : in String)
is
use lace.Event.utility,
ada.Text_IO;
begin
begin
Self.as_Subject.deregister (other_Client_as_Observer,
to_Kind (chat.Client.Message'Tag));
exception
when constraint_Error =>
raise unknown_Client with "Other client not known. Deregister is not required.";
end;
Self.as_Observer.rid (the_Response'unchecked_Access,
to_Kind (chat.Client.Message'Tag),
other_Client_Name);
put_Line (other_Client_Name & " leaves.");
end deregister_Client;
overriding
procedure Registrar_has_shutdown (Self : in out Item)
is
use ada.Text_IO;
begin
put_Line ("The Registrar has shutdown. Press <Enter> to exit.");
Self.Registrar_has_shutdown := True;
end Registrar_has_shutdown;
task check_Registrar_lives
is
entry start (Self : in chat.Client.local.view);
entry halt;
end check_Registrar_lives;
task body check_Registrar_lives
is
use ada.Text_IO;
Done : Boolean := False;
Self : chat.Client.local.view;
begin
loop
select
accept start (Self : in chat.Client.local.view)
do
check_Registrar_lives.Self := Self;
end start;
or
accept halt
do
Done := True;
end halt;
or
delay 15.0;
end select;
exit when Done;
begin
chat.Registrar.ping;
exception
when system.RPC.communication_Error =>
put_Line ("The Registrar has died. Press <Enter> to exit.");
Self.Registrar_is_dead := True;
end;
end loop;
exception
when E : others =>
new_Line;
put_Line ("Error in check_Registrar_lives task.");
new_Line;
put_Line (ada.exceptions.exception_Information (E));
end check_Registrar_lives;
procedure start (Self : in out chat.Client.local.item)
is
use ada.Text_IO;
begin
-- Setup
--
begin
chat.Registrar.register (Self'unchecked_Access); -- Register our client with the registrar.
exception
when chat.Registrar.Name_already_used =>
put_Line (+Self.Name & " is already in use.");
check_Registrar_lives.halt;
return;
end;
lace.Event.utility.use_text_Logger ("events");
check_Registrar_lives.start (Self'unchecked_Access);
declare
Peers : constant chat.Client.views := chat.Registrar.all_Clients;
begin
for i in Peers'Range
loop
if Self'unchecked_Access /= Peers (i)
then
begin
Peers (i).register_Client (Self'unchecked_Access); -- Register our client with all other clients.
Self .register_Client (Peers (i)); -- Register all other clients with our client.
exception
when system.RPC.communication_Error
| storage_Error =>
null; -- Peer (i) has died, so ignore it and do nothing.
end;
end if;
end loop;
end;
-- Main loop
--
loop
declare
procedure broadcast (the_Text : in String)
is
the_Message : constant chat.Client.Message := (Length (Self.Name) + 2 + the_Text'Length,
+Self.Name & ": " & the_Text);
begin
Self.emit (the_Message);
end broadcast;
chat_Message : constant String := get_Line;
begin
exit
when chat_Message = "q"
or Self.Registrar_has_shutdown
or Self.Registrar_is_dead;
broadcast (chat_Message);
end;
end loop;
-- Shutdown
--
if not Self.Registrar_has_shutdown
and not Self.Registrar_is_dead
then
begin
chat.Registrar.deregister (Self'unchecked_Access);
exception
when system.RPC.communication_Error =>
Self.Registrar_is_dead := True;
end;
if not Self.Registrar_is_dead
then
declare
Peers : constant chat.Client.views := chat.Registrar.all_Clients;
begin
for i in Peers'Range
loop
if Self'unchecked_Access /= Peers (i)
then
begin
Peers (i).deregister_Client ( Self'unchecked_Access, -- Deregister our client with every other client.
+Self.Name);
exception
when system.RPC.communication_Error
| storage_Error =>
null; -- Peer is dead, so do nothing.
end;
end if;
end loop;
end;
end if;
end if;
check_Registrar_lives.halt;
lace.Event.utility.close;
end start;
-- 'last_chance_Handler' is commented out to avoid multiple definitions
-- of link symbols in 'build_All' test procedure (Tier 5).
--
-- procedure last_chance_Handler (Msg : in system.Address;
-- Line : in Integer);
--
-- pragma Export (C, last_chance_Handler,
-- "__gnat_last_chance_handler");
--
-- procedure last_chance_Handler (Msg : in System.Address;
-- Line : in Integer)
-- is
-- pragma Unreferenced (Msg, Line);
-- use ada.Text_IO;
-- begin
-- put_Line ("The Registrar is not running.");
-- put_Line ("Press Ctrl-C to quit.");
-- check_Registrar_lives.halt;
-- delay Duration'Last;
-- end last_chance_Handler;
end chat.Client.local;
|
29,888
|
ada
| 9
|
alire-project/clic
|
example/src/clic_ex-commands-config.adb
|
with GNAT.OS_Lib;
with Simple_Logging;
with CLIC.Config.Info;
with CLIC.Config.Edit;
with CLIC.Config.Load;
package body CLIC_Ex.Commands.Config is
package Trace renames Simple_Logging;
-------------
-- Execute --
-------------
overriding
procedure Execute (Cmd : in out Instance;
Args : AAA.Strings.Vector)
is
Enabled : Natural := 0;
Config_Path : constant String :=
(if Cmd.Global then "global_config.toml" else "local_config.toml");
begin
-- Check no multi-action
Enabled := Enabled + (if Cmd.List then 1 else 0);
Enabled := Enabled + (if Cmd.Get then 1 else 0);
Enabled := Enabled + (if Cmd.Set then 1 else 0);
Enabled := Enabled + (if Cmd.Unset then 1 else 0);
Enabled := Enabled + (if Cmd.Builtins_Doc then 1 else 0);
if Enabled > 1 then
Trace.Error ("Specify at most one subcommand");
GNAT.OS_Lib.OS_Exit (1);
end if;
if Enabled = 0 then
-- The default command is --list
Cmd.List := True;
end if;
if Cmd.Show_Origin and then not Cmd.List then
Trace.Error ("--show-origin only valid with --list");
GNAT.OS_Lib.OS_Exit (1);
end if;
if Cmd.List then
case Args.Count is
when 0 =>
Trace.Always
(CLIC.Config.Info.List
(Cmd.Config,
Filter => "*",
Show_Origin => Cmd.Show_Origin).Flatten (ASCII.LF));
when 1 =>
Trace.Always
(CLIC.Config.Info.List
(Cmd.Config,
Filter => Args.First_Element,
Show_Origin => Cmd.Show_Origin).Flatten (ASCII.LF));
when others =>
Trace.Error ("List expects at most one argument");
GNAT.OS_Lib.OS_Exit (1);
end case;
elsif Cmd.Get then
if Args.Count /= 1 then
Trace.Error ("Unset expects one argument");
GNAT.OS_Lib.OS_Exit (1);
end if;
if not CLIC.Config.Is_Valid_Config_Key (Args.First_Element) then
Trace.Error ("Invalid configration key '" &
Args.First_Element & "'");
GNAT.OS_Lib.OS_Exit (1);
end if;
if Cmd.Config.Defined (Args.First_Element) then
Trace.Always (Cmd.Config.Get_As_String (Args.First_Element));
else
Trace.Error ("Configuration key '" &
Args.First_Element &
"' is not defined");
GNAT.OS_Lib.OS_Exit (1);
end if;
elsif Cmd.Set then
if Args.Count /= 2 then
Trace.Error ("Set expects two arguments");
GNAT.OS_Lib.OS_Exit (1);
end if;
declare
Key : constant String := Args.Element (1);
Val : constant String := Args.Element (2);
begin
if not CLIC.Config.Is_Valid_Config_Key (Key) then
Trace.Error ("Invalid configration key '" & Key & "'");
GNAT.OS_Lib.OS_Exit (1);
end if;
if not CLIC.Config.Edit.Set (Config_Path, Key, Val) then
GNAT.OS_Lib.OS_Exit (1);
end if;
end;
elsif Cmd.Unset then
if Args.Count /= 1 then
Trace.Error ("Unset expects one argument");
GNAT.OS_Lib.OS_Exit (1);
end if;
declare
Key : constant String := Args.Element (1);
begin
if not CLIC.Config.Is_Valid_Config_Key (Key) then
Trace.Error ("Invalid configration key '" &
Key & "'");
GNAT.OS_Lib.OS_Exit (1);
end if;
if not CLIC.Config.Edit.Unset (Config_Path, Key) then
GNAT.OS_Lib.OS_Exit (1);
end if;
end;
end if;
end Execute;
--------------------
-- Setup_Switches --
--------------------
overriding
procedure Setup_Switches
(Cmd : in out Instance;
Config : in out CLIC.Subcommand.Switches_Configuration)
is
use CLIC.Subcommand;
begin
Define_Switch
(Config => Config,
Output => Cmd.List'Access,
Long_Switch => "--list",
Help => "List configuration options");
Define_Switch
(Config => Config,
Output => Cmd.Show_Origin'Access,
Long_Switch => "--show-origin",
Help => "Show origin of configuration values in --list");
Define_Switch
(Config => Config,
Output => Cmd.Get'Access,
Long_Switch => "--get",
Help => "Print value of a configuration option");
Define_Switch
(Config => Config,
Output => Cmd.Set'Access,
Long_Switch => "--set",
Help => "Set a configuration option");
Define_Switch
(Config => Config,
Output => Cmd.Unset'Access,
Long_Switch => "--unset",
Help => "Unset a configuration option");
Define_Switch
(Config => Config,
Output => Cmd.Global'Access,
Long_Switch => "--global",
Help => "Set and Unset global configuration instead" &
" of the local one");
Define_Switch
(Config => Config,
Output => Cmd.Builtins_Doc'Access,
Long_Switch => "--builtins-doc",
Help =>
"Print Markdown list of built-in configuration options");
end Setup_Switches;
end CLIC_Ex.Commands.Config;
|
29,889
|
ada
| 0
|
ekoeppen/MSP430_Generic_Ada_Drivers
|
msp430x2/msp430g2553/svd/msp430_svd-usci_b0_i2c_mode.ads
|
<filename>msp430x2/msp430g2553/svd/msp430_svd-usci_b0_i2c_mode.ads<gh_stars>0
-- This spec has been automatically generated from msp430g2553.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
-- USCI_B0 I2C Mode
package MSP430_SVD.USCI_B0_I2C_MODE is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Sync. Mode: USCI Mode 1
type UCB0CTL0_UCMODE_Field is
(-- Sync. Mode: USCI Mode: 0
Ucmode_0,
-- Sync. Mode: USCI Mode: 1
Ucmode_1,
-- Sync. Mode: USCI Mode: 2
Ucmode_2,
-- Sync. Mode: USCI Mode: 3
Ucmode_3)
with Size => 2;
for UCB0CTL0_UCMODE_Field use
(Ucmode_0 => 0,
Ucmode_1 => 1,
Ucmode_2 => 2,
Ucmode_3 => 3);
-- USCI B0 Control Register 0
type UCB0CTL0_Register is record
-- Sync-Mode 0:UART-Mode / 1:SPI-Mode
UCSYNC : MSP430_SVD.Bit := 16#0#;
-- Sync. Mode: USCI Mode 1
UCMODE : UCB0CTL0_UCMODE_Field :=
MSP430_SVD.USCI_B0_I2C_MODE.Ucmode_0;
-- Sync. Mode: Master Select
UCMST : MSP430_SVD.Bit := 16#0#;
-- unspecified
Reserved_4_4 : MSP430_SVD.Bit := 16#0#;
-- Multi-Master Environment
UCMM : MSP430_SVD.Bit := 16#0#;
-- 10-bit Slave Address Mode
UCSLA10 : MSP430_SVD.Bit := 16#0#;
-- 10-bit Address Mode
UCA10 : MSP430_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for UCB0CTL0_Register use record
UCSYNC at 0 range 0 .. 0;
UCMODE at 0 range 1 .. 2;
UCMST at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
UCMM at 0 range 5 .. 5;
UCSLA10 at 0 range 6 .. 6;
UCA10 at 0 range 7 .. 7;
end record;
-- USCI 1 Clock Source Select 1
type UCB0CTL1_UCSSEL_Field is
(-- USCI 0 Clock Source: 0
Ucssel_0,
-- USCI 0 Clock Source: 1
Ucssel_1,
-- USCI 0 Clock Source: 2
Ucssel_2,
-- USCI 0 Clock Source: 3
Ucssel_3)
with Size => 2;
for UCB0CTL1_UCSSEL_Field use
(Ucssel_0 => 0,
Ucssel_1 => 1,
Ucssel_2 => 2,
Ucssel_3 => 3);
-- USCI B0 Control Register 1
type UCB0CTL1_Register is record
-- USCI Software Reset
UCSWRST : MSP430_SVD.Bit := 16#0#;
-- Transmit START
UCTXSTT : MSP430_SVD.Bit := 16#0#;
-- Transmit STOP
UCTXSTP : MSP430_SVD.Bit := 16#0#;
-- Transmit NACK
UCTXNACK : MSP430_SVD.Bit := 16#0#;
-- Transmit/Receive Select/Flag
UCTR : MSP430_SVD.Bit := 16#0#;
-- unspecified
Reserved_5_5 : MSP430_SVD.Bit := 16#0#;
-- USCI 1 Clock Source Select 1
UCSSEL : UCB0CTL1_UCSSEL_Field :=
MSP430_SVD.USCI_B0_I2C_MODE.Ucssel_0;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for UCB0CTL1_Register use record
UCSWRST at 0 range 0 .. 0;
UCTXSTT at 0 range 1 .. 1;
UCTXSTP at 0 range 2 .. 2;
UCTXNACK at 0 range 3 .. 3;
UCTR at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
UCSSEL at 0 range 6 .. 7;
end record;
-- USCI B0 I2C Interrupt Enable Register
type UCB0I2CIE_Register is record
-- Arbitration Lost interrupt enable
UCALIE : MSP430_SVD.Bit := 16#0#;
-- START Condition interrupt enable
UCSTTIE : MSP430_SVD.Bit := 16#0#;
-- STOP Condition interrupt enable
UCSTPIE : MSP430_SVD.Bit := 16#0#;
-- NACK Condition interrupt enable
UCNACKIE : MSP430_SVD.Bit := 16#0#;
-- unspecified
Reserved_4_7 : MSP430_SVD.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for UCB0I2CIE_Register use record
UCALIE at 0 range 0 .. 0;
UCSTTIE at 0 range 1 .. 1;
UCSTPIE at 0 range 2 .. 2;
UCNACKIE at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
-- USCI B0 Status Register
type UCB0STAT_Register is record
-- Arbitration Lost interrupt Flag
UCALIFG : MSP430_SVD.Bit := 16#0#;
-- START Condition interrupt Flag
UCSTTIFG : MSP430_SVD.Bit := 16#0#;
-- STOP Condition interrupt Flag
UCSTPIFG : MSP430_SVD.Bit := 16#0#;
-- NAK Condition interrupt Flag
UCNACKIFG : MSP430_SVD.Bit := 16#0#;
-- Bus Busy Flag
UCBBUSY : MSP430_SVD.Bit := 16#0#;
-- General Call address received Flag
UCGC : MSP430_SVD.Bit := 16#0#;
-- SCL low
UCSCLLOW : MSP430_SVD.Bit := 16#0#;
-- USCI Listen mode
UCLISTEN : MSP430_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for UCB0STAT_Register use record
UCALIFG at 0 range 0 .. 0;
UCSTTIFG at 0 range 1 .. 1;
UCSTPIFG at 0 range 2 .. 2;
UCNACKIFG at 0 range 3 .. 3;
UCBBUSY at 0 range 4 .. 4;
UCGC at 0 range 5 .. 5;
UCSCLLOW at 0 range 6 .. 6;
UCLISTEN at 0 range 7 .. 7;
end record;
-- UCB0I2COA_UCOA array
type UCB0I2COA_UCOA_Field_Array is array (0 .. 9) of MSP430_SVD.Bit
with Component_Size => 1, Size => 10;
-- Type definition for UCB0I2COA_UCOA
type UCB0I2COA_UCOA_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- UCOA as a value
Val : MSP430_SVD.UInt10;
when True =>
-- UCOA as an array
Arr : UCB0I2COA_UCOA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 10;
for UCB0I2COA_UCOA_Field use record
Val at 0 range 0 .. 9;
Arr at 0 range 0 .. 9;
end record;
-- USCI B0 I2C Own Address
type UCB0I2COA_Register is record
-- I2C Own Address 0
UCOA : UCB0I2COA_UCOA_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_10_14 : MSP430_SVD.UInt5 := 16#0#;
-- I2C General Call enable
UCGCEN : MSP430_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for UCB0I2COA_Register use record
UCOA at 0 range 0 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
UCGCEN at 0 range 15 .. 15;
end record;
-- UCB0I2CSA_UCSA array
type UCB0I2CSA_UCSA_Field_Array is array (0 .. 9) of MSP430_SVD.Bit
with Component_Size => 1, Size => 10;
-- Type definition for UCB0I2CSA_UCSA
type UCB0I2CSA_UCSA_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- UCSA as a value
Val : MSP430_SVD.UInt10;
when True =>
-- UCSA as an array
Arr : UCB0I2CSA_UCSA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 10;
for UCB0I2CSA_UCSA_Field use record
Val at 0 range 0 .. 9;
Arr at 0 range 0 .. 9;
end record;
-- USCI B0 I2C Slave Address
type UCB0I2CSA_Register is record
-- I2C Slave Address 0
UCSA : UCB0I2CSA_UCSA_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_10_15 : MSP430_SVD.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for UCB0I2CSA_Register use record
UCSA at 0 range 0 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
end record;
-----------------
-- Peripherals --
-----------------
-- USCI_B0 I2C Mode
type USCI_B0_I2C_MODE_Peripheral is record
-- USCI B0 Control Register 0
UCB0CTL0 : aliased UCB0CTL0_Register;
-- USCI B0 Control Register 1
UCB0CTL1 : aliased UCB0CTL1_Register;
-- USCI B0 Baud Rate 0
UCB0BR0 : aliased MSP430_SVD.Byte;
-- USCI B0 Baud Rate 1
UCB0BR1 : aliased MSP430_SVD.Byte;
-- USCI B0 I2C Interrupt Enable Register
UCB0I2CIE : aliased UCB0I2CIE_Register;
-- USCI B0 Status Register
UCB0STAT : aliased UCB0STAT_Register;
-- USCI B0 Receive Buffer
UCB0RXBUF : aliased MSP430_SVD.Byte;
-- USCI B0 Transmit Buffer
UCB0TXBUF : aliased MSP430_SVD.Byte;
-- USCI B0 I2C Own Address
UCB0I2COA : aliased UCB0I2COA_Register;
-- USCI B0 I2C Slave Address
UCB0I2CSA : aliased UCB0I2CSA_Register;
end record
with Volatile;
for USCI_B0_I2C_MODE_Peripheral use record
UCB0CTL0 at 16#0# range 0 .. 7;
UCB0CTL1 at 16#1# range 0 .. 7;
UCB0BR0 at 16#2# range 0 .. 7;
UCB0BR1 at 16#3# range 0 .. 7;
UCB0I2CIE at 16#4# range 0 .. 7;
UCB0STAT at 16#5# range 0 .. 7;
UCB0RXBUF at 16#6# range 0 .. 7;
UCB0TXBUF at 16#7# range 0 .. 7;
UCB0I2COA at 16#B0# range 0 .. 15;
UCB0I2CSA at 16#B2# range 0 .. 15;
end record;
-- USCI_B0 I2C Mode
USCI_B0_I2C_MODE_Periph : aliased USCI_B0_I2C_MODE_Peripheral
with Import, Address => USCI_B0_I2C_MODE_Base;
end MSP430_SVD.USCI_B0_I2C_MODE;
|
29,890
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/a/a83a02b.ada
|
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/a/a83a02b.ada<gh_stars>1-10
-- A83A02B.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A LABEL IN A NESTED TASK CAN BE IDENTICAL TO A LABEL
-- OUTSIDE THE TASK.
-- "INSIDE LABEL": INSIDE * TASK BODY _TASK A
-- * BLOCK IN TASK BODY _TASKBLOCK B
-- * LOOP IN BLOCK IN TASK BODY _TASKBLOCKLOOP
-- * ACCEPT ST. WITHIN TASK BDY _TASKACCEPT D
-- "OUTSIDE LABEL": INSIDE * MAIN _MAIN 1
-- * BLOCK IN MAIN _BLOCK 2
-- * LOOP IN BLOCK IN MAIN _BLOCKLOOP 3
-- * LOOP IN MAIN _LOOP 4
-- CASES TESTED: A1 B2 A3 B4 | 1 2 3 4
-- D1 C2 C3 D4 ---+----------
-- A | X . X .
-- B | . X . X
-- C | . X X .
-- D | X . . X
-- RM 02/10/80
WITH REPORT ;
PROCEDURE A83A02B IS
USE REPORT ;
TASK TYPE TASK1 IS
ENTRY E1 ;
END TASK1 ;
TASK BODY TASK1 IS
BEGIN
<< LAB_TASK_MAIN >> NULL ; -- A1 A
<< LAB_TASK_BLOCKLOOP >> NULL ; -- A3
BEGIN
<< LAB_TASKBLOCK_BLOCK >> NULL ; -- B2 B
<< LAB_TASKBLOCK_LOOP >> NULL ; -- B4
FOR I IN 1..2 LOOP
<< LAB_TASKBLOCKLOOP_BLOCK >>NULL ; -- C2 C
<< LAB_TASKBLOCKLOOP_BLOCKLOOP >>
NULL ; -- C3
END LOOP;
END ;
ACCEPT E1 DO
<< LAB_TASKACCEPT_MAIN >> NULL ; -- D1 D
<< LAB_TASKACCEPT_LOOP >> NULL ; -- D4
END E1 ;
END TASK1 ;
BEGIN
TEST( "A83A02B" , "CHECK THAT A LABEL IN A NESTED TASK" &
" CAN BE IDENTICAL TO A LABEL" &
" OUTSIDE THE TASK" );
<< LAB_TASK_MAIN >> NULL ; -- A1 1
<< LAB_TASKACCEPT_MAIN >> NULL ; -- D1
BEGIN
<< LAB_TASKBLOCK_BLOCK >> NULL ; -- B2 2
<< LAB_TASKBLOCKLOOP_BLOCK >> NULL ; -- C2
FOR I IN 1..2 LOOP
<< LAB_TASK_BLOCKLOOP >> NULL ; -- A3 3
<< LAB_TASKBLOCKLOOP_BLOCKLOOP >> NULL ; -- C3
END LOOP;
END ;
FOR I IN 1..2 LOOP
<< LAB_TASKBLOCK_LOOP >> NULL ; -- B4 4
<< LAB_TASKACCEPT_LOOP >> NULL ; -- D4
END LOOP;
RESULT ;
END A83A02B ;
|
29,891
|
ada
| 25
|
thierr26/ada-keystore
|
src/keystore-gpg.adb
|
-----------------------------------------------------------------------
-- keystore-gpg -- helpers to open keystores protected with GPG
-- Copyright (C) 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Keystore.GPG is
-- ------------------------------
-- Open the keystore file and unlock the wallet using GPG.
-- Raises the Bad_Password exception if no key slot match an available GPG key.
-- ------------------------------
procedure Open (Container : in out Wallet_File;
Context : in out Context_Type;
Path : in String;
Data_Path : in String := "";
Config : in Wallet_Config := Secure_Config) is
Info : Keystore.Wallet_Info;
Slot : Key_Slot;
begin
Container.Open (Path => Path, Data_Path => Data_Path,
Config => Config, Info => Info);
if Info.Header_Count = 0 then
raise Bad_Password with "No password to unlock the keystore";
end if;
Context.Load_Secrets (Container);
Container.Set_Master_Key (Context);
Container.Unlock (Context, Slot);
end Open;
end Keystore.GPG;
|
29,892
|
ada
| 52
|
onox/orka
|
orka/src/orka/interface/orka-logging.ads
|
<filename>orka/src/orka/interface/orka-logging.ads<gh_stars>10-100
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.Loggers;
with Orka.Transforms.Singles.Vectors;
with Orka.Transforms.Doubles.Vectors;
package Orka.Logging is
pragma Preelaborate;
subtype Source is Loggers.Source;
subtype Message_Type is Loggers.Message_Type;
subtype Severity is Loggers.Severity;
-----------------------------------------------------------------------------
function Image (Value : Duration) return String;
-- Return the image of the given duration with an appropriate suffix
function Image (Value : Orka.Transforms.Singles.Vectors.Vector4) return String;
function Image (Value : Orka.Transforms.Doubles.Vectors.Vector4) return String;
function Trim (Value : String) return String;
-----------------------------------------------------------------------------
procedure Set_Logger (Logger : Loggers.Logger_Ptr);
procedure Log
(From : Source;
Kind : Message_Type;
Level : Severity;
Message : String);
-- Log the message using the logger
--
-- If no logger has been set, it will log the message to the terminal.
generic
From : Source;
package Messages is
procedure Log (Level : Severity; Message : String);
end Messages;
end Orka.Logging;
|
29,893
|
ada
| 15
|
mgrojo/adalib
|
ada-directories-hierarchical_file_names.ads
|
<filename>ada-directories-hierarchical_file_names.ads
-- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.Directories.Hierarchical_File_Names is
function Is_Simple_Name (Name : in String) return Boolean;
function Is_Root_Directory_Name (Name : in String) return Boolean;
function Is_Parent_Directory_Name (Name : in String) return Boolean;
function Is_Current_Directory_Name (Name : in String) return Boolean;
function Is_Full_Name (Name : in String) return Boolean;
function Is_Relative_Name (Name : in String) return Boolean;
function Simple_Name (Name : in String) return String
renames Ada.Directories.Simple_Name;
function Containing_Directory (Name : in String) return String
renames Ada.Directories.Containing_Directory;
function Initial_Directory (Name : in String) return String;
function Relative_Name (Name : in String) return String;
function Compose (Directory : in String := "";
Relative_Name : in String;
Extension : in String := "") return String;
end Ada.Directories.Hierarchical_File_Names;
|
29,894
|
ada
| 0
|
hgrodriguez/spi_two_devices
|
src/main_master_itsybitsy.adb
|
--===========================================================================
--
-- This is the main master program for the ItsyBitsy for the
-- use cases:
-- 3: Master ItsyBitsy -> Slave Pico
-- 4: Master ItsyBitsy -> Slave ItsyBitsy
--
--===========================================================================
--
-- Copyright 2022 (C) <NAME>
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with HAL;
with HAL.SPI;
with RP.Clock;
with RP.GPIO;
with RP.SPI;
with RP.Device;
with ItsyBitsy;
with SPI_Master_ItsyBitsy;
procedure Main_Master_ItsyBitsy is
THE_VALUE : constant HAL.UInt16 := HAL.UInt16 (16#55AA#);
Data_Out_16 : HAL.SPI.SPI_Data_16b (1 .. 1)
:= (others => THE_VALUE);
Status_Out : HAL.SPI.SPI_Status;
Data_In_16 : HAL.SPI.SPI_Data_16b (1 .. 1) := (others => 0);
Status_In : HAL.SPI.SPI_Status;
Word : HAL.UInt16;
use HAL;
use HAL.SPI;
use RP.SPI;
begin
RP.Clock.Initialize (ItsyBitsy.XOSC_Frequency);
RP.Clock.Enable (RP.Clock.PERI);
RP.Device.Timer.Enable;
ItsyBitsy.LED.Configure (RP.GPIO.Output);
SPI_Master_ItsyBitsy.Initialize;
loop
-- construct the values for the transmission
for Higher_Byte in HAL.UInt8'Range loop
for Lower_Byte in HAL.UInt8'Range loop
Word := Shift_Left (Value => HAL.UInt16 (Higher_Byte),
Amount => 8) or HAL.UInt16 (Lower_Byte);
Data_Out_16 (1) := Word;
SPI_Master_ItsyBitsy.SPI.Transmit (Data_Out_16, Status_Out);
SPI_Master_ItsyBitsy.SPI.Receive (Data_In_16, Status_In, 0);
RP.Device.Timer.Delay_Milliseconds (100);
ItsyBitsy.LED.Toggle;
end loop;
end loop;
end loop;
end Main_Master_ItsyBitsy;
|
29,895
|
ada
| 488
|
ouankou/rose
|
src/frontend/Experimental_Ada_ROSE_Connection/parser/ada_c_demo/source/c_code_h.ads
|
<filename>src/frontend/Experimental_Ada_ROSE_Connection/parser/ada_c_demo/source/c_code_h.ads<gh_stars>100-1000
package c_code_h is
procedure c_func;
pragma Import (C, c_func);
procedure c_ada_caller;
pragma Import (C, c_ada_caller);
end c_code_h;
|
29,896
|
ada
| 15
|
AdaCore/training_material
|
courses/fundamentals_of_ada/labs/solar_system/adv_280_low_level_programming/question_3/src/solar_system-graphics.ads
|
<reponame>AdaCore/training_material<filename>courses/fundamentals_of_ada/labs/solar_system/adv_280_low_level_programming/question_3/src/solar_system-graphics.ads
package Solar_System.Graphics is
protected Graphic_Context is
procedure Set_Window(W: Window_ID);
entry Get_Window(W: out Window_ID; C : out Canvas_ID);
private
Window : Window_ID;
Canvas : Canvas_ID;
Is_Set : Boolean := False;
end Graphic_Context;
task T_Display;
private
procedure Draw_Body(Object : Body_Type; Canvas : Canvas_ID);
end Solar_System.Graphics;
|
29,897
|
ada
| 1
|
stcarrez/helios
|
src/helios-commands-register.adb
|
<filename>src/helios-commands-register.adb
-----------------------------------------------------------------------
-- helios-commands-register -- Command to register the agent in hyperion
-- Copyright (C) 2018, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Command_Line;
with Util.Beans.Objects;
with Util.Log;
with Swagger.Credentials.OAuth;
with Security.Random;
with Helios.Datas;
with Helios.Rest.Clients;
with Helios.Rest.Models;
with GNAT.Sockets;
package body Helios.Commands.Register is
use Ada.Text_IO;
use type GNAT.Strings.String_Access;
function Get_Default_Value (Context : in Context_Type;
Name : in String) return GNAT.Strings.String_Access;
function Get_Ip (Command : in Command_Type) return Swagger.UString;
function Get_Name (Command : in Command_Type) return Swagger.UString;
function Get_Name (Command : in Command_Type) return Swagger.UString is
begin
if Command.Name = null then
return Swagger.To_UString (GNAT.Sockets.Host_Name);
else
return Swagger.To_UString (Command.Name.all);
end if;
end Get_Name;
function Get_Ip (Command : in Command_Type) return Swagger.UString is
begin
return Swagger.To_UString (Command.IP.all);
end Get_Ip;
-- Execute a information command to report information about the agent and monitoring.
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
Client : Helios.Rest.Clients.Client_Type;
Agent : Helios.Rest.Models.Agent_Type;
Host : Helios.Rest.Models.Host_Type;
Cred : aliased Swagger.Credentials.OAuth.OAuth2_Credential_Type;
Scope : constant String := "agent:register";
Rand : Security.Random.Generator;
Host_Key : Swagger.UString;
begin
Load (Context);
if Command.Client_Id = null or else Command.Client_Id.all = "" then
Put_Line ("Missing client_id parameter");
Helios.Commands.Usage (Args, Name);
elsif Command.Client_Secret = null or else Command.Client_Secret.all = "" then
Put_Line ("Missing client_secret parameter");
Helios.Commands.Usage (Args, Name);
elsif Args.Get_Count /= 2 then
Helios.Commands.Usage (Args, Name);
else
-- Step 1: get an OAuth access token.
Cred.Set_Application_Identifier (Command.Client_Id.all);
Cred.Set_Application_Secret (Command.Client_Secret.all);
Client.Set_Server (Args.Get_Argument (1) & "/api/v1");
Cred.Set_Provider_URI (Args.Get_Argument (1) & "/oauth/token");
Cred.Request_Token (Context.Server.Get ("username"),
Context.Server.Get ("password"), Scope);
Client.Set_Credentials (Cred'Access);
-- Step 2: register the agent to the server.
Client.Register_Agent (Name => Get_Name (Command),
Ip => Get_Ip (Command),
Agent_Key => Swagger.To_UString (Rand.Generate (Bits => 1024)),
Result => Agent);
if Client.Get_Status /= 200 then
Command.Log (Util.Log.ERROR_LEVEL, Name, "Registration of helios agent failed.");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
return;
end if;
-- Step 3: register the host in the monitoring server.
Host_Key := Swagger.To_UString (Rand.Generate (Bits => 1024));
Client.Create_Host (Name => Get_Name (Command),
Ip => Get_Ip (Command),
Agent_Id => Integer (Agent.Id),
Agent_Key => Agent.Key,
Host_Key => Host_Key,
Result => Host);
if Client.Get_Status /= 200 then
Command.Log (Util.Log.ERROR_LEVEL, Name, "Creation of host failed.");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
return;
end if;
-- Step 4: save the connection information in the server configuration file.
Context.Server.Set ("client_id", Command.Client_Id.all);
Context.Server.Set ("client_secret", Command.Client_Secret.all);
Context.Server.Set ("agent_key", Agent.Key);
Context.Server.Set ("server_url", Args.Get_Argument (1) & "/api/v1");
Context.Server.Set ("server_oauth_url", Args.Get_Argument (1) & "/oauth/token");
Context.Server.Set ("agent_id", Long_Long_Integer'Image (Agent.Id));
Context.Server.Set ("host_id", Long_Long_Integer'Image (Host.Id));
Context.Server.Set ("host_key", Host_Key);
Save_Server_Configuration (Context);
end if;
end Execute;
function Get_Default_Value (Context : in Context_Type;
Name : in String) return GNAT.Strings.String_Access is
Value : constant Util.Beans.Objects.Object := Context.Server.Get_Value (Name);
begin
if Util.Beans.Objects.Is_Null (Value) then
return null;
else
return new String '(Util.Beans.Objects.To_String (Value));
end if;
end Get_Default_Value;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
package GC renames GNAT.Command_Line;
begin
Command.Client_Id := Get_Default_Value (Context, "client_id");
Command.Client_Secret := Get_Default_Value (Context, "client_secret");
GC.Define_Switch (Config, Command.Client_Id'Access,
"", "--client-id=", "Define the helios client identifier");
GC.Define_Switch (Config, Command.Client_Secret'Access,
"", "--client-secret=", "Define the helios client secret");
GC.Define_Switch (Config, Command.Server'Access,
"", "--server=", "Server hostname or IP address");
GC.Define_Switch (Config, Command.Port'Access,
"", "--port=", "Server TCP/IP port");
GC.Define_Switch (Config, Command.IP'Access,
"", "--client-ip=", "IP address of the host to use");
end Setup;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type) is
pragma Unreferenced (Command, Name, Context);
begin
Ada.Text_IO.Put_Line ("register: register the agent to the Hyperion monitoring server");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("");
end Help;
end Helios.Commands.Register;
|
29,898
|
ada
| 0
|
wooky/aoc.kt
|
src/main/ada/aoc.ads
|
package AOC is
package Day is
type Day is abstract tagged limited null record;
type Access_Day is access Day'Class;
procedure Init (D : in out Day; Root : String) is abstract;
function Part_1 (D : Day) return String is abstract;
function Part_2 (D : Day) return String is abstract;
end Day;
package Runner is
type Runner is abstract tagged limited null record;
type Access_Runner is access Runner'Class;
function Get_Day (R : Runner; Day_Number : Natural) return Day.Access_Day is abstract;
end Runner;
end AOC;
|
29,899
|
ada
| 0
|
AntonioRamosNieto/TFG-STM32F429
|
STM32F4/ToyOBDH/src/sensor.adb
|
<reponame>AntonioRamosNieto/TFG-STM32F429
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, Universidad Politécnica de Madrid --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
-- --
------------------------------------------------------------------------------
-- Temperature sensor implementation.
-- This version is for a TMP36 sensor connected to GPIO pin 5 of
-- the F429 Discovery Board. See the board user manual and the
-- mapping in STM32.ADC.
with STM32.Board; use STM32.Board;
with STM32.Device; use STM32.Device;
with HAL; use HAL;
with STM32.ADC; use STM32.ADC;
with STM32.GPIO; use STM32.GPIO;
package body Sensor is
-- ADC parameters
Converter : Analog_To_Digital_Converter renames ADC_1;
Input_Channel : constant Analog_Input_Channel := 5;
Input : constant GPIO_Point := PA5;
-- Local subprograms
procedure Initialize;
----------------
-- Initialize --
----------------
procedure Initialize is
All_Regular_Conversions : constant Regular_Channel_Conversions :=
(1 => (Channel => Input_Channel,
Sample_Time => Sample_144_Cycles)); -- needs 10 us minimum
begin
Initialize_LEDs;
Enable_Clock (Input);
Configure_IO (Input, (Mode => Mode_Analog, Resistors => Floating));
Enable_Clock (Converter);
Reset_All_ADC_Units;
Configure_Common_Properties
(Mode => Independent,
Prescalar => PCLK2_Div_2,
DMA_Mode => Disabled,
Sampling_Delay => Sampling_Delay_5_Cycles);
Configure_Unit
(Converter,
Resolution => ADC_Resolution_12_Bits,
Alignment => Right_Aligned);
Configure_Regular_Conversions
(Converter,
Continuous => False,
Trigger => Software_Triggered,
Enable_EOC => True,
Conversions => All_Regular_Conversions);
Enable (Converter);
end Initialize;
---------
-- Get --
---------
procedure Get (Reading : out Sensor_Reading) is
Successful : Boolean;
begin
Start_Conversion (Converter);
Poll_For_Status (Converter,
Regular_Channel_Conversion_Complete,
Successful);
if not Successful then
Red_LED.Toggle;
Reading := 0;
else
Green_LED.Toggle;
Reading := Sensor_Reading (Conversion_Value (Converter));
end if;
end Get;
begin
Initialize;
end Sensor;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.